diff --git a/static/payment/assets/img/puff.svg b/static/payment/assets/img/puff.svg index fb3058c..288de9e 100644 --- a/static/payment/assets/img/puff.svg +++ b/static/payment/assets/img/puff.svg @@ -1,37 +1,37 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/web/.editorconfig b/web/.editorconfig index 5306e31..88061d3 100644 --- a/web/.editorconfig +++ b/web/.editorconfig @@ -1,15 +1,15 @@ -# @see: http://editorconfig.org - -root = true - -[*] # 表示所有文件适用 -charset = utf-8 # 设置文件字符集为 utf-8 -indent_style = space # 缩进风格(tab | space) -indent_size = 2 # 缩进大小 -max_line_length = 130 # 最大行长度 -end_of_line = crlf # 控制换行类型(lf | cr | crlf) -insert_final_newline = true # 始终在文件末尾插入一个新行 - -[*.md] # 表示仅对 md 文件适用以下规则 -max_line_length = off # 关闭最大行长度限制 -trim_trailing_whitespace = false # 关闭末尾空格修剪 +# @see: http://editorconfig.org + +root = true + +[*] # 表示所有文件适用 +charset = utf-8 # 设置文件字符集为 utf-8 +indent_style = space # 缩进风格(tab | space) +indent_size = 2 # 缩进大小 +max_line_length = 130 # 最大行长度 +end_of_line = crlf # 控制换行类型(lf | cr | crlf) +insert_final_newline = true # 始终在文件末尾插入一个新行 + +[*.md] # 表示仅对 md 文件适用以下规则 +max_line_length = off # 关闭最大行长度限制 +trim_trailing_whitespace = false # 关闭末尾空格修剪 diff --git a/web/.env b/web/.env index d2fd61c..38a17db 100644 --- a/web/.env +++ b/web/.env @@ -1,14 +1,14 @@ -# 生产环境优先级 -# development & production & test > .env - -# title -VITE_GLOB_APP_TITLE = 'BEpusdt' - -# 静态资源url -VITE_IMG_BASE_URL = 'https://my-image-cdn.com' - -# 本地mock数据 true开启 false关闭 -VITE_APP_OPEN_MOCK = false - -# 资源公共路径 -VITE_PUBLIC_PATH = '/secure/' +# 生产环境优先级 +# development & production & test > .env + +# title +VITE_GLOB_APP_TITLE = 'BEpusdt' + +# 静态资源url +VITE_IMG_BASE_URL = 'https://my-image-cdn.com' + +# 本地mock数据 true开启 false关闭 +VITE_APP_OPEN_MOCK = false + +# 资源公共路径 +VITE_PUBLIC_PATH = '/secure/' diff --git a/web/.env.development b/web/.env.development index 1fc6864..727caa1 100644 --- a/web/.env.development +++ b/web/.env.development @@ -1,12 +1,12 @@ -# 开发环境 -VITE_USER_NODE_ENV = development - -# 路由模式 hash | history -VITE_ROUTER_MODE = hash - -# 打包路径 开发环境地址前缀 (一般 '/' 或 './' 都可以,如果开发环境 '/' 打包预览白屏,请使用 './') -# 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上,所以这里 VITE_PUBLIC_PATH 为 '/' -VITE_PUBLIC_PATH = './' - -# 请求路径 管理系统/开发环境 -VITE_APP_BASE_URL = 'http://127.0.0.1:8080' +# 开发环境 +VITE_USER_NODE_ENV = development + +# 路由模式 hash | history +VITE_ROUTER_MODE = hash + +# 打包路径 开发环境地址前缀 (一般 '/' 或 './' 都可以,如果开发环境 '/' 打包预览白屏,请使用 './') +# 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上,所以这里 VITE_PUBLIC_PATH 为 '/' +VITE_PUBLIC_PATH = './' + +# 请求路径 管理系统/开发环境 +VITE_APP_BASE_URL = 'http://127.0.0.1:8080' diff --git a/web/.env.test b/web/.env.test index 70d7ec6..0c27b61 100644 --- a/web/.env.test +++ b/web/.env.test @@ -1,11 +1,11 @@ -# 开发环境 -VITE_USER_NODE_ENV = test - -# 路由模式 hash | history -VITE_ROUTER_MODE = hash - -# 开发环境地址前缀 (一般 '/' 或 './' 都可以) -VITE_PUBLIC_PATH = '/test' - -# 请求路径 管理系统/开发环境 +# 开发环境 +VITE_USER_NODE_ENV = test + +# 路由模式 hash | history +VITE_ROUTER_MODE = hash + +# 开发环境地址前缀 (一般 '/' 或 './' 都可以) +VITE_PUBLIC_PATH = '/test' + +# 请求路径 管理系统/开发环境 VITE_APP_BASE_URL = '/' \ No newline at end of file diff --git a/web/.gitignore b/web/.gitignore index c0bc218..393a9e2 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -1,27 +1,27 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist.zip -dist.7z -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -!.vscode/settings.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist.zip +dist.7z +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +!.vscode/settings.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/web/.husky/commit-msg b/web/.husky/commit-msg index 341f3e4..70bd3dd 100644 --- a/web/.husky/commit-msg +++ b/web/.husky/commit-msg @@ -1 +1 @@ -npx --no-install commitlint --edit "$1" +npx --no-install commitlint --edit "$1" diff --git a/web/.husky/pre-commit b/web/.husky/pre-commit index 2da2b37..b18d041 100644 --- a/web/.husky/pre-commit +++ b/web/.husky/pre-commit @@ -1 +1 @@ -npm run lint:lint-staged +npm run lint:lint-staged diff --git a/web/.prettierrc.cjs b/web/.prettierrc.cjs index 77317ce..8012dd0 100644 --- a/web/.prettierrc.cjs +++ b/web/.prettierrc.cjs @@ -1,41 +1,41 @@ -// @see: https://www.prettier.cn - -module.exports = { - // 指定最大换行长度 - printWidth: 130, - // 缩进制表符宽度 | 空格数 - tabWidth: 2, - // 使用制表符而不是空格缩进行 (true:制表符,false:空格) - useTabs: false, - // 结尾不用分号 (true:有,false:没有) - semi: true, - // 使用单引号 (true:单引号,false:双引号) - singleQuote: false, - // 在对象字面量中决定是否将属性名用引号括起来 可选值 "" - quoteProps: 'as-needed', - // 在JSX中使用单引号而不是双引号 (true:单引号,false:双引号) - jsxSingleQuote: false, - // 多行时尽可能打印尾随逗号 可选值"" - trailingComma: 'none', - // 在对象,数组括号与文字之间加空格 "{ foo: bar }" (true:有,false:没有) - bracketSpacing: true, - // 将 > 多行元素放在最后一行的末尾,而不是单独放在下一行 (true:放末尾,false:单独一行) - bracketSameLine: false, - // (x) => {} 箭头函数参数只有一个时是否要有小括号 (avoid:省略括号,always:不省略括号) - arrowParens: 'avoid', - // 指定要使用的解析器,不需要写文件开头的 @prettier - requirePragma: false, - // 可以在文件顶部插入一个特殊标记,指定该文件已使用 Prettier 格式化 - insertPragma: false, - // 用于控制文本是否应该被换行以及如何进行换行 - proseWrap: 'preserve', - // 在html中空格是否是敏感的 "css" - 遵守 CSS 显示属性的默认值, "strict" - 空格被认为是敏感的 ,"ignore" - 空格被认为是不敏感的 - htmlWhitespaceSensitivity: 'css', - // 控制在 Vue 单文件组件中
-

- - License - - - Vue - - - Vite - - - arco.design - -

-
- -### 介绍 📖 - -SnowAdmin 是一个清新优雅、高颜值且功能强大的后台管理模板,基于最新的前端技术栈,包括 Vue3, Vite6, TypeScript, Pinia。它内置了丰富的主题配置和组件,代码规范严谨,实现了自动化的文件路由系统。SnowAdmin 为您提供了一站式的后台管理解决方案,无需额外配置,开箱即用。同样是一个快速学习前沿技术的最佳实践。 - -### 版本 📦 - -**预览及文档** - -项目预览地址:[SnowAdmin](http://115.190.79.132/#/login) - -项目文档地址:[SnowAdmin-开发指南](http://115.190.79.132:81/) - -**代码仓库** - -| 平台 | 仓库地址 | -| ------ | ------------------------------------------------------ | -| GitHub | [Github 仓库](https://github.com/WangFan-io/SnowAdmin) | -| Gitee | [Gitee 仓库](https://gitee.com/wang_fan_w/SnowAdmin) | - -> 完整版分支:main -> -> 极简版分支:main-thin -> -> ⚠️主要的维护在github上,提issue/pr请认准github主战场 -> -> 大家也可以进wx群交流,二维码在介绍末尾 - -### 先行预览 🖼️ - -![登录页](https://ooo.0x0.ooo/2025/04/11/O0lhbG.png) - -![首页](https://ooo.0x0.ooo/2025/04/11/O0lnVI.png) - -![文件库](https://ooo.0x0.ooo/2025/04/11/O0l7qD.png) - -![国际化](https://ooo.0x0.ooo/2025/04/11/O0lNAF.png) - -![横向布局](https://ooo.0x0.ooo/2025/04/11/O0leQ6.png) - -![混合布局](https://ooo.0x0.ooo/2025/04/11/O0lrCP.png) - -![主题配置](https://ooo.0x0.ooo/2025/04/11/O0lKnb.png) - -![黑暗模式-1](https://ooo.0x0.ooo/2025/04/11/O0lZ4l.png) - -![黑暗模式-2](https://ooo.0x0.ooo/2025/04/11/O0lv6g.png) - -![黑暗模式-3](https://ooo.0x0.ooo/2025/04/11/O0lgkB.png) - -### 项目功能 🔨 - -- 清晰的项目架构:结构清晰,优雅易懂,代码全注释 -- 前沿技术应用:采用 Vue3, Vite6, TypeScript等最新流行的技术栈 -- 内置RBAC角色权限模型,实现路由、角色、按钮权限访问控制 -- 使用 Pinia 替代 Vuex,轻量、简单、易用,集成 Pinia 持久化插件 -- 支持 Arco-Design 组件大小切换、多主题布局、暗黑模式、i18n 国际化 -- 使用 VueRouter 配置动态路由权限拦截、路由懒加载,支持页面按钮权限控制 -- 使用 KeepAlive 对页面进行缓存,支持多级嵌套路由缓存 -- 使用 Prettier 统一格式化代码,集成 ESLint、Stylelint 代码校验规范 -- 使用 husky、lint-staged、commitlint等插件,规范提交信息 -- 丰富的页面组件:内置多样页面和组件,包括 401、404、500 页面,以及布局组件、标签组件、主题配置组件等 - -### 环境准备 🏝️ - -确保你的环境满足以下要求(重要): - -- **git**: 你需要 git 来克隆和管理项目版本。 -- **NodeJS**: >=18.12.0,推荐 20.12.0 或更高。 -- **pnpm**: >= 8.7.0,推荐最新版本。 - -### 安装使用步骤 📔 - -### 从 GitHub 获取代码 🔗 - -```bash -# 克隆代码 -git clone https://github.com/WangFan-io/SnowAdmin.git -``` - -### 从 Gitee 获取代码 🔗 - -```bash -# 克隆代码 -git clone https://gitee.com/wang_fan_w/SnowAdmin.git -``` - -### 安装依赖 📌 - -安装项目依赖 - -```bash -pnpm install -``` - -### 插件配置 🛠️ - -安装 Vue - Official,禁用 Vetur - -- [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) - Vue 服务插件 - -### 项目启动 🚀 - -```json -{ - // 开发环境启动 - "dev": "vite", - // 开发环境构建 - "build:dev": "vue-tsc && vite build --mode development", - // 生产环境构建 - "build:prod": "vue-tsc && vite build --mode production", - // 测试环境构建 - "build:test": "vue-tsc && vite build --mode test", - // 预览环境启动 - "preview": "vite preview" -} -``` - -### 文件资源目录 📚 - -```text -SnowAdmin -├─ .husky # husky 配置文件 -├─ .vscode # VSCode 推荐配置 -├─ build # vite项目配置目录 -├─ public # 静态资源文件(该文件夹不会被打包) -├─ src -│ ├─ api # API 接口管理 -│ ├─ assets # 静态资源文件 -│ ├─ components # 全局组件 -│ ├─ config # 全局配置项 -│ ├─ directives # 全局自定义指令文件 -│ ├─ globals # 全局函数 -│ ├─ hooks # 常用 Hooks 封装 -│ ├─ lang # 语言国际化 i18n -│ ├─ layout # 框架布局模块 -│ ├─ mock # 本地数据mock -│ ├─ router # 路由管理 -│ ├─ store # pinia store -│ ├─ style # 全局样式文件 -│ ├─ typings # 全局 ts 声明 -│ ├─ utils # 常用工具库 -│ ├─ views # 项目所有页面 -│ ├─ App.vue # 项目主组件 -│ ├─ main.ts # 项目入口文件 -│ └─ vite-env.d.ts # 指定 ts 识别 vue -├─ .editorconfig # 代码编辑器配置文件 -├─ .env # 通用环境配置 -├─ .env.development # 开发环境配置 -├─ .env.production # 生产环境配置 -├─ .env.test # 测试环境配置 -├─ .eslintignore # 忽略 Eslint 校验 -├─ .eslintrc.cjs # Eslint 校验配置文件 -├─ .gitignore # 忽略 git 提交 -├─ .prettierignore # 忽略 Prettier 格式化 -├─ .prettierrc.cjs # Prettier 格式化配置 -├─ .stylelintignore # 忽略 Stylelint 校验 -├─ .stylelintrc.cjs # Stylelint 格式化配置 -├─ commitlint.config.cjs # git 提交规范配置 -├─ index.html # 入口 html -├─ LICENSE # 开源协议 -├─ lint-staged.config.cjs # lint-staged 配置文件 -├─ package-lock.json # 依赖包包版本锁 -├─ package.json # 依赖包管理 -├─ pnpm-lock.yaml # 依赖包包版本锁 -├─ README.md # README 介绍 -├─ tsconfig.json # typescript 全局配置 -└─ vite.config.ts # vite 全局配置文件 -``` - -### 浏览器支持 🌎 - -- 本地开发推荐使用 Chrome 最新版浏览器 [Download](https://www.google.com/intl/zh-CN/chrome/)。 -- 生产环境支持现代浏览器,不再支持 IE 浏览器,更多浏览器可以查看 [Can I Use Es Module](https://caniuse.com/?search=ESModule)。 - -| ![IE](https://i.imgtg.com/2023/04/11/8z7ot.png) | ![Edge](https://i.imgtg.com/2023/04/11/8zr3p.png) | ![Firefox](https://i.imgtg.com/2023/04/11/8zKiU.png) | ![Chrome](https://i.imgtg.com/2023/04/11/8zNrx.png) | ![Safari](https://i.imgtg.com/2023/04/11/8zeGj.png) | -| :---------------------------------------------: | :-----------------------------------------------: | :--------------------------------------------------: | :-------------------------------------------------: | :-------------------------------------------------: | -| not support | last 2 versions | last 2 versions | last 2 versions | last 2 versions | - -### 鸣谢列表 🧩 - -- [vue:https://v3.cn.vuejs.org/](https://v3.cn.vuejs.org/) -- [axios:https://github.com/axios/axios](https://github.com/axios/axios) -- [nprogress:https://github.com/rstacruz/nprogress](https://github.com/rstacruz/nprogress) -- [sortablejs:https://github.com/SortableJS/Sortabl](https://github.com/SortableJS/Sortable) -- [sass:https://github.com/sass/sass](https://github.com/sass/sass) -- [typescript:https://github.com/microsoft/TypeScript](https://github.com/microsoft/TypeScript) -- [vite:https://github.com/vitejs/vite](https://github.com/vitejs/vite) -- [wangeditor:https://github.com/wangeditor-team/wangEditor](https://github.com/wangeditor-team/wangEditor) -- [qrcodejs:https://github.com/davidshimjs/qrcodejs](https://github.com/davidshimjs/qrcodejs) -- [print-js:https://github.com/crabbly/Print.js](https://github.com/crabbly/Print.js) -- [eslint:https://github.com/eslint/eslint](https://github.com/eslint/eslint) -- [prettier:https://github.com/prettier/prettier](https://github.com/prettier/prettier) -- [arco.design:https://arco.design/](https://arco.design/) -- [pinyin-pro:https://github.com/zh-lx/pinyin-pro](https://github.com/zh-lx/pinyin-pro) -- [qrcode:https://www.npmjs.com/package/qrcode](https://www.npmjs.com/package/qrcode) -- [jsbarcode:https://github.com/lindell/JsBarcode/wiki/Options](https://github.com/lindell/JsBarcode/wiki/Options) -- [fingerprintjs2:https://www.npmjs.com/package/fingerprintjs2](https://www.npmjs.com/package/fingerprintjs2) - -### 特别鸣谢 🎉 - -- [vue-next-admin:http://vuenextadmin.ccfast.cc/](http://vuenextadmin.ccfast.cc/) -- [Gi-admin:https://lin-97.github.io/gi-demo/](https://lin-97.github.io/gi-demo/#/home) -- [Geeker-Admin:https://admin.spicyboy.cn/](https://admin.spicyboy.cn/#/home/index) - -感谢以上框架为本项目提供了帮助,项目中的很多设计思想值得参考和学习,再次感谢。 - -### 学习 & 交流 🏫 - -| SnowAdmin 交流群 | -| :---------------------------------------------------------------------------------------------------------: | -| ![微信图片_20250726141221](https://github.com/user-attachments/assets/8c1ebf3c-4630-487e-9a54-810fd4d6972c) | - -使用过程中有各种问题也可以进群交流,欢迎大家积极参与 - -### 支持作者 🌟 - -如果觉得框架不错,或者已经在使用了,希望你可以去 [GitHub](https://github.com/WangFan-io/SnowAdmin) ⭐ Star,这将是对我极大的鼓励与支持。 - -### 免责条款 📫 - -您充分了解并同意,您必须为自己使用本服务及注册帐号下的一切行为负责,包括您所发表的任何内容以及由此产生的任何后果。您应对本服务中的内容自行加以判断,并自行承担因使用内容而引起的所有风险。 - -`SnowAdmin` 对网站上所显示的信息或资料的准确性、内容、完整性、合法性、可靠性、可操作性或可用性不承担任何责任。 - -`SnowAdmin` 二次开发使用者因为违法而触犯中华人民共和国法律的,一切后果自己负责,`SnowAdmin` 作者不承担任何责任。 - -本声明未涉及的问题参见国家有关法律法规,当本声明与国家法律法规冲突时,以国家法律法规为准。 - -### 学习 & 商用 🌈 - -`SnowAdmin` 是免费和开源的,可免费用于学习、商业使用 。 - -### 捐赠 💖 - -| 微信 | 支付宝 | -| :------------------------------------------------: | :--------------------------------------------------: | -| ![微信](https://ooo.0x0.ooo/2025/07/20/OYtFn1.jpg) | ![支付宝](https://ooo.0x0.ooo/2025/07/20/OYth4I.jpg) | +# SnowAdmin + +
+

+ + License + + + Vue + + + Vite + + + arco.design + +

+
+ +### 介绍 📖 + +SnowAdmin 是一个清新优雅、高颜值且功能强大的后台管理模板,基于最新的前端技术栈,包括 Vue3, Vite6, TypeScript, Pinia。它内置了丰富的主题配置和组件,代码规范严谨,实现了自动化的文件路由系统。SnowAdmin 为您提供了一站式的后台管理解决方案,无需额外配置,开箱即用。同样是一个快速学习前沿技术的最佳实践。 + +### 版本 📦 + +**预览及文档** + +项目预览地址:[SnowAdmin](http://115.190.79.132/#/login) + +项目文档地址:[SnowAdmin-开发指南](http://115.190.79.132:81/) + +**代码仓库** + +| 平台 | 仓库地址 | +| ------ | ------------------------------------------------------ | +| GitHub | [Github 仓库](https://github.com/WangFan-io/SnowAdmin) | +| Gitee | [Gitee 仓库](https://gitee.com/wang_fan_w/SnowAdmin) | + +> 完整版分支:main +> +> 极简版分支:main-thin +> +> ⚠️主要的维护在github上,提issue/pr请认准github主战场 +> +> 大家也可以进wx群交流,二维码在介绍末尾 + +### 先行预览 🖼️ + +![登录页](https://ooo.0x0.ooo/2025/04/11/O0lhbG.png) + +![首页](https://ooo.0x0.ooo/2025/04/11/O0lnVI.png) + +![文件库](https://ooo.0x0.ooo/2025/04/11/O0l7qD.png) + +![国际化](https://ooo.0x0.ooo/2025/04/11/O0lNAF.png) + +![横向布局](https://ooo.0x0.ooo/2025/04/11/O0leQ6.png) + +![混合布局](https://ooo.0x0.ooo/2025/04/11/O0lrCP.png) + +![主题配置](https://ooo.0x0.ooo/2025/04/11/O0lKnb.png) + +![黑暗模式-1](https://ooo.0x0.ooo/2025/04/11/O0lZ4l.png) + +![黑暗模式-2](https://ooo.0x0.ooo/2025/04/11/O0lv6g.png) + +![黑暗模式-3](https://ooo.0x0.ooo/2025/04/11/O0lgkB.png) + +### 项目功能 🔨 + +- 清晰的项目架构:结构清晰,优雅易懂,代码全注释 +- 前沿技术应用:采用 Vue3, Vite6, TypeScript等最新流行的技术栈 +- 内置RBAC角色权限模型,实现路由、角色、按钮权限访问控制 +- 使用 Pinia 替代 Vuex,轻量、简单、易用,集成 Pinia 持久化插件 +- 支持 Arco-Design 组件大小切换、多主题布局、暗黑模式、i18n 国际化 +- 使用 VueRouter 配置动态路由权限拦截、路由懒加载,支持页面按钮权限控制 +- 使用 KeepAlive 对页面进行缓存,支持多级嵌套路由缓存 +- 使用 Prettier 统一格式化代码,集成 ESLint、Stylelint 代码校验规范 +- 使用 husky、lint-staged、commitlint等插件,规范提交信息 +- 丰富的页面组件:内置多样页面和组件,包括 401、404、500 页面,以及布局组件、标签组件、主题配置组件等 + +### 环境准备 🏝️ + +确保你的环境满足以下要求(重要): + +- **git**: 你需要 git 来克隆和管理项目版本。 +- **NodeJS**: >=18.12.0,推荐 20.12.0 或更高。 +- **pnpm**: >= 8.7.0,推荐最新版本。 + +### 安装使用步骤 📔 + +### 从 GitHub 获取代码 🔗 + +```bash +# 克隆代码 +git clone https://github.com/WangFan-io/SnowAdmin.git +``` + +### 从 Gitee 获取代码 🔗 + +```bash +# 克隆代码 +git clone https://gitee.com/wang_fan_w/SnowAdmin.git +``` + +### 安装依赖 📌 + +安装项目依赖 + +```bash +pnpm install +``` + +### 插件配置 🛠️ + +安装 Vue - Official,禁用 Vetur + +- [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) - Vue 服务插件 + +### 项目启动 🚀 + +```json +{ + // 开发环境启动 + "dev": "vite", + // 开发环境构建 + "build:dev": "vue-tsc && vite build --mode development", + // 生产环境构建 + "build:prod": "vue-tsc && vite build --mode production", + // 测试环境构建 + "build:test": "vue-tsc && vite build --mode test", + // 预览环境启动 + "preview": "vite preview" +} +``` + +### 文件资源目录 📚 + +```text +SnowAdmin +├─ .husky # husky 配置文件 +├─ .vscode # VSCode 推荐配置 +├─ build # vite项目配置目录 +├─ public # 静态资源文件(该文件夹不会被打包) +├─ src +│ ├─ api # API 接口管理 +│ ├─ assets # 静态资源文件 +│ ├─ components # 全局组件 +│ ├─ config # 全局配置项 +│ ├─ directives # 全局自定义指令文件 +│ ├─ globals # 全局函数 +│ ├─ hooks # 常用 Hooks 封装 +│ ├─ lang # 语言国际化 i18n +│ ├─ layout # 框架布局模块 +│ ├─ mock # 本地数据mock +│ ├─ router # 路由管理 +│ ├─ store # pinia store +│ ├─ style # 全局样式文件 +│ ├─ typings # 全局 ts 声明 +│ ├─ utils # 常用工具库 +│ ├─ views # 项目所有页面 +│ ├─ App.vue # 项目主组件 +│ ├─ main.ts # 项目入口文件 +│ └─ vite-env.d.ts # 指定 ts 识别 vue +├─ .editorconfig # 代码编辑器配置文件 +├─ .env # 通用环境配置 +├─ .env.development # 开发环境配置 +├─ .env.production # 生产环境配置 +├─ .env.test # 测试环境配置 +├─ .eslintignore # 忽略 Eslint 校验 +├─ .eslintrc.cjs # Eslint 校验配置文件 +├─ .gitignore # 忽略 git 提交 +├─ .prettierignore # 忽略 Prettier 格式化 +├─ .prettierrc.cjs # Prettier 格式化配置 +├─ .stylelintignore # 忽略 Stylelint 校验 +├─ .stylelintrc.cjs # Stylelint 格式化配置 +├─ commitlint.config.cjs # git 提交规范配置 +├─ index.html # 入口 html +├─ LICENSE # 开源协议 +├─ lint-staged.config.cjs # lint-staged 配置文件 +├─ package-lock.json # 依赖包包版本锁 +├─ package.json # 依赖包管理 +├─ pnpm-lock.yaml # 依赖包包版本锁 +├─ README.md # README 介绍 +├─ tsconfig.json # typescript 全局配置 +└─ vite.config.ts # vite 全局配置文件 +``` + +### 浏览器支持 🌎 + +- 本地开发推荐使用 Chrome 最新版浏览器 [Download](https://www.google.com/intl/zh-CN/chrome/)。 +- 生产环境支持现代浏览器,不再支持 IE 浏览器,更多浏览器可以查看 [Can I Use Es Module](https://caniuse.com/?search=ESModule)。 + +| ![IE](https://i.imgtg.com/2023/04/11/8z7ot.png) | ![Edge](https://i.imgtg.com/2023/04/11/8zr3p.png) | ![Firefox](https://i.imgtg.com/2023/04/11/8zKiU.png) | ![Chrome](https://i.imgtg.com/2023/04/11/8zNrx.png) | ![Safari](https://i.imgtg.com/2023/04/11/8zeGj.png) | +| :---------------------------------------------: | :-----------------------------------------------: | :--------------------------------------------------: | :-------------------------------------------------: | :-------------------------------------------------: | +| not support | last 2 versions | last 2 versions | last 2 versions | last 2 versions | + +### 鸣谢列表 🧩 + +- [vue:https://v3.cn.vuejs.org/](https://v3.cn.vuejs.org/) +- [axios:https://github.com/axios/axios](https://github.com/axios/axios) +- [nprogress:https://github.com/rstacruz/nprogress](https://github.com/rstacruz/nprogress) +- [sortablejs:https://github.com/SortableJS/Sortabl](https://github.com/SortableJS/Sortable) +- [sass:https://github.com/sass/sass](https://github.com/sass/sass) +- [typescript:https://github.com/microsoft/TypeScript](https://github.com/microsoft/TypeScript) +- [vite:https://github.com/vitejs/vite](https://github.com/vitejs/vite) +- [wangeditor:https://github.com/wangeditor-team/wangEditor](https://github.com/wangeditor-team/wangEditor) +- [qrcodejs:https://github.com/davidshimjs/qrcodejs](https://github.com/davidshimjs/qrcodejs) +- [print-js:https://github.com/crabbly/Print.js](https://github.com/crabbly/Print.js) +- [eslint:https://github.com/eslint/eslint](https://github.com/eslint/eslint) +- [prettier:https://github.com/prettier/prettier](https://github.com/prettier/prettier) +- [arco.design:https://arco.design/](https://arco.design/) +- [pinyin-pro:https://github.com/zh-lx/pinyin-pro](https://github.com/zh-lx/pinyin-pro) +- [qrcode:https://www.npmjs.com/package/qrcode](https://www.npmjs.com/package/qrcode) +- [jsbarcode:https://github.com/lindell/JsBarcode/wiki/Options](https://github.com/lindell/JsBarcode/wiki/Options) +- [fingerprintjs2:https://www.npmjs.com/package/fingerprintjs2](https://www.npmjs.com/package/fingerprintjs2) + +### 特别鸣谢 🎉 + +- [vue-next-admin:http://vuenextadmin.ccfast.cc/](http://vuenextadmin.ccfast.cc/) +- [Gi-admin:https://lin-97.github.io/gi-demo/](https://lin-97.github.io/gi-demo/#/home) +- [Geeker-Admin:https://admin.spicyboy.cn/](https://admin.spicyboy.cn/#/home/index) + +感谢以上框架为本项目提供了帮助,项目中的很多设计思想值得参考和学习,再次感谢。 + +### 学习 & 交流 🏫 + +| SnowAdmin 交流群 | +| :---------------------------------------------------------------------------------------------------------: | +| ![微信图片_20250726141221](https://github.com/user-attachments/assets/8c1ebf3c-4630-487e-9a54-810fd4d6972c) | + +使用过程中有各种问题也可以进群交流,欢迎大家积极参与 + +### 支持作者 🌟 + +如果觉得框架不错,或者已经在使用了,希望你可以去 [GitHub](https://github.com/WangFan-io/SnowAdmin) ⭐ Star,这将是对我极大的鼓励与支持。 + +### 免责条款 📫 + +您充分了解并同意,您必须为自己使用本服务及注册帐号下的一切行为负责,包括您所发表的任何内容以及由此产生的任何后果。您应对本服务中的内容自行加以判断,并自行承担因使用内容而引起的所有风险。 + +`SnowAdmin` 对网站上所显示的信息或资料的准确性、内容、完整性、合法性、可靠性、可操作性或可用性不承担任何责任。 + +`SnowAdmin` 二次开发使用者因为违法而触犯中华人民共和国法律的,一切后果自己负责,`SnowAdmin` 作者不承担任何责任。 + +本声明未涉及的问题参见国家有关法律法规,当本声明与国家法律法规冲突时,以国家法律法规为准。 + +### 学习 & 商用 🌈 + +`SnowAdmin` 是免费和开源的,可免费用于学习、商业使用 。 + +### 捐赠 💖 + +| 微信 | 支付宝 | +| :------------------------------------------------: | :--------------------------------------------------: | +| ![微信](https://ooo.0x0.ooo/2025/07/20/OYtFn1.jpg) | ![支付宝](https://ooo.0x0.ooo/2025/07/20/OYth4I.jpg) | diff --git a/web/build/vite-plugin.ts b/web/build/vite-plugin.ts index 0dddc0e..7d13a4a 100644 --- a/web/build/vite-plugin.ts +++ b/web/build/vite-plugin.ts @@ -1,73 +1,73 @@ -import vue from "@vitejs/plugin-vue"; -import { resolve } from "path"; -import { PluginOption } from "vite"; -import { vitePluginForArco } from "@arco-plugins/vite-vue"; -import { createSvgIconsPlugin } from "vite-plugin-svg-icons"; -import AutoImport from "unplugin-auto-import/vite"; -import { ArcoResolver } from "unplugin-vue-components/resolvers"; -import Components from "unplugin-vue-components/vite"; -import { viteMockServe } from "vite-plugin-mock"; -import eslintPlugin from "vite-plugin-eslint"; -/** - * 创建 vite 插件 - * @param viteEnv - */ -export const createVitePlugins = (viteEnv: ViteEnv): (PluginOption | PluginOption[])[] => { - const env = viteEnv; - return [ - vue(), - // esLint 报错信息显示在浏览器界面上 - eslintPlugin(), - vitePluginForArco({ - style: "css" - }), - createSvgIconsPlugin({ - // 配置src下存放svg的路径,这里表示在src/assets/svgs文件夹下 - iconDirs: [resolve(process.cwd(), "src/assets/svgs")], - symbolId: "icon-[dir]-[name]" - }), - AutoImport({ - // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等 - imports: ["vue", "vue-router"], - // 自动导入的目录-自定义全局函数 - dirs: ["src/globals"], - // arco组件的按需加载 - resolvers: [ArcoResolver()], - // 解决eslint报错问题 - eslintrc: { - // 这里先设置成true然后npm run dev 运行之后会生成 .eslintrc-auto-import.json 文件之后,在改为false - enabled: false, - filepath: "./.eslintrc-auto-import.json", // 生成的文件路径 - globalsPropValue: true - }, - // 配置文件生成位置 - dts: "src/auto-import.d.ts" - }), - Components({ - resolvers: [ - // arco组件的按需加载 - ArcoResolver({ - sideEffect: true - }) - ], - // 自动加载组件的目录配置,默认的为 'src/components' - dirs: ["src/components"], - // 组件的有效文件扩展名 - extensions: ["vue"], - // 配置文件生成位置 - dts: "src/components.d.ts" - }), - viteMockServe({ - mockPath: "./src/mock/", // 目录位置 - logger: true, // 是否在控制台显示请求日志 - supportTs: true, // 是否读取ts文件模块 - localEnabled: env.VITE_APP_OPEN_MOCK === "true", // 设置是否启用本地mock文件 - prodEnabled: env.VITE_APP_OPEN_MOCK === "true", // 设置打包是否启用mock功能 - // 这样可以控制关闭mock的时候不让mock打包到最终代码内 - injectCode: ` - import { setupProdMockServer } from '../src/mock/index'; - setupProdMockServer(); - ` - }) - ]; -}; +import vue from "@vitejs/plugin-vue"; +import { resolve } from "path"; +import { PluginOption } from "vite"; +import { vitePluginForArco } from "@arco-plugins/vite-vue"; +import { createSvgIconsPlugin } from "vite-plugin-svg-icons"; +import AutoImport from "unplugin-auto-import/vite"; +import { ArcoResolver } from "unplugin-vue-components/resolvers"; +import Components from "unplugin-vue-components/vite"; +import { viteMockServe } from "vite-plugin-mock"; +import eslintPlugin from "vite-plugin-eslint"; +/** + * 创建 vite 插件 + * @param viteEnv + */ +export const createVitePlugins = (viteEnv: ViteEnv): (PluginOption | PluginOption[])[] => { + const env = viteEnv; + return [ + vue(), + // esLint 报错信息显示在浏览器界面上 + eslintPlugin(), + vitePluginForArco({ + style: "css" + }), + createSvgIconsPlugin({ + // 配置src下存放svg的路径,这里表示在src/assets/svgs文件夹下 + iconDirs: [resolve(process.cwd(), "src/assets/svgs")], + symbolId: "icon-[dir]-[name]" + }), + AutoImport({ + // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等 + imports: ["vue", "vue-router"], + // 自动导入的目录-自定义全局函数 + dirs: ["src/globals"], + // arco组件的按需加载 + resolvers: [ArcoResolver()], + // 解决eslint报错问题 + eslintrc: { + // 这里先设置成true然后npm run dev 运行之后会生成 .eslintrc-auto-import.json 文件之后,在改为false + enabled: false, + filepath: "./.eslintrc-auto-import.json", // 生成的文件路径 + globalsPropValue: true + }, + // 配置文件生成位置 + dts: "src/auto-import.d.ts" + }), + Components({ + resolvers: [ + // arco组件的按需加载 + ArcoResolver({ + sideEffect: true + }) + ], + // 自动加载组件的目录配置,默认的为 'src/components' + dirs: ["src/components"], + // 组件的有效文件扩展名 + extensions: ["vue"], + // 配置文件生成位置 + dts: "src/components.d.ts" + }), + viteMockServe({ + mockPath: "./src/mock/", // 目录位置 + logger: true, // 是否在控制台显示请求日志 + supportTs: true, // 是否读取ts文件模块 + localEnabled: env.VITE_APP_OPEN_MOCK === "true", // 设置是否启用本地mock文件 + prodEnabled: env.VITE_APP_OPEN_MOCK === "true", // 设置打包是否启用mock功能 + // 这样可以控制关闭mock的时候不让mock打包到最终代码内 + injectCode: ` + import { setupProdMockServer } from '../src/mock/index'; + setupProdMockServer(); + ` + }) + ]; +}; diff --git a/web/commitlint.config.cjs b/web/commitlint.config.cjs index dfa4c56..23b9f1b 100644 --- a/web/commitlint.config.cjs +++ b/web/commitlint.config.cjs @@ -1,52 +1,52 @@ -module.exports = { - ignores: [commit => commit.includes("init")], - extends: ["@commitlint/config-conventional"], - rules: { - "body-leading-blank": [2, "always"], - "footer-leading-blank": [1, "always"], - "header-max-length": [2, "always", 108], - "subject-empty": [2, "never"], - "type-empty": [2, "never"], - "type-enum": [ - 2, - "always", - [ - "feat", - "fix", - "style", - "perf", - "refactor", - "test", - "chore", - "docs", - "workflow", - "build", - "ci", - "revert", - "wip", - "release", - "deps", - "merge", - "sync" - // feat:交新功能 - // fix:bug修复 - // style: 调整代码格式,未修改代码逻辑 - // perf: 性能优化 - // refactor:代码重构,既没修复bug也没有添加新功能 - // test:增加测试 - // chore: 其他修改(不在上述类型中的修改) - // docs:修改文档或注释 - // workflow: 工作流 - // build: 项目打包构建相关的配置修改 - // ci: 持续集成相关 - // revert: 恢复上一次提交(回滚) - // wip: work in progress 工作中 还没完成 - // release: 发版 - // deps: 依赖相关的修改 - // merge 代码合并 - // sync 同步主线或分支的Bug - // scope 说明 commit 影响的范围,比如数据层、控制层、视图层等等 - ] - ] - } -}; +module.exports = { + ignores: [commit => commit.includes("init")], + extends: ["@commitlint/config-conventional"], + rules: { + "body-leading-blank": [2, "always"], + "footer-leading-blank": [1, "always"], + "header-max-length": [2, "always", 108], + "subject-empty": [2, "never"], + "type-empty": [2, "never"], + "type-enum": [ + 2, + "always", + [ + "feat", + "fix", + "style", + "perf", + "refactor", + "test", + "chore", + "docs", + "workflow", + "build", + "ci", + "revert", + "wip", + "release", + "deps", + "merge", + "sync" + // feat:交新功能 + // fix:bug修复 + // style: 调整代码格式,未修改代码逻辑 + // perf: 性能优化 + // refactor:代码重构,既没修复bug也没有添加新功能 + // test:增加测试 + // chore: 其他修改(不在上述类型中的修改) + // docs:修改文档或注释 + // workflow: 工作流 + // build: 项目打包构建相关的配置修改 + // ci: 持续集成相关 + // revert: 恢复上一次提交(回滚) + // wip: work in progress 工作中 还没完成 + // release: 发版 + // deps: 依赖相关的修改 + // merge 代码合并 + // sync 同步主线或分支的Bug + // scope 说明 commit 影响的范围,比如数据层、控制层、视图层等等 + ] + ] + } +}; diff --git a/web/lint-staged.config.cjs b/web/lint-staged.config.cjs index 6ca4340..04d1d40 100644 --- a/web/lint-staged.config.cjs +++ b/web/lint-staged.config.cjs @@ -1,8 +1,8 @@ -module.exports = { - "*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"], - "{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": ["prettier --write--parser json"], - "package.json": ["prettier --write"], - "*.vue": ["eslint --fix", "prettier --write", "stylelint --fix"], - "*.{scss,less,styl,html}": ["stylelint --fix", "prettier --write"], - "*.md": ["prettier --write"] -}; +module.exports = { + "*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"], + "{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": ["prettier --write--parser json"], + "package.json": ["prettier --write"], + "*.vue": ["eslint --fix", "prettier --write", "stylelint --fix"], + "*.{scss,less,styl,html}": ["stylelint --fix", "prettier --write"], + "*.md": ["prettier --write"] +}; diff --git a/web/public/assets/css/loading.css b/web/public/assets/css/loading.css index 34efd58..369d828 100644 --- a/web/public/assets/css/loading.css +++ b/web/public/assets/css/loading.css @@ -1,61 +1,61 @@ -body { - margin: 0; - overflow: hidden; -} -.init-page { - width: 100vw; - height: 100vh; - left: 0; - top: 0; - display: flex; - align-items: center; - justify-content: center; - background: #fff; -} -/* HTML:
*/ -.snow-loader { - width: 45px; - aspect-ratio: 1; - - --c: no-repeat linear-gradient(rgb(22, 93, 255) 0 0); - - background: - var(--c) 0% 50%, - var(--c) 50% 50%, - var(--c) 100% 50%; - background-size: 20% 100%; - animation: l1 1s infinite linear; -} - -@keyframes l1 { - 0% { - background-size: - 20% 100%, - 20% 100%, - 20% 100%; - } - 33% { - background-size: - 20% 10%, - 20% 100%, - 20% 100%; - } - 50% { - background-size: - 20% 100%, - 20% 10%, - 20% 100%; - } - 66% { - background-size: - 20% 100%, - 20% 100%, - 20% 10%; - } - 100% { - background-size: - 20% 100%, - 20% 100%, - 20% 100%; - } -} +body { + margin: 0; + overflow: hidden; +} +.init-page { + width: 100vw; + height: 100vh; + left: 0; + top: 0; + display: flex; + align-items: center; + justify-content: center; + background: #fff; +} +/* HTML:
*/ +.snow-loader { + width: 45px; + aspect-ratio: 1; + + --c: no-repeat linear-gradient(rgb(22, 93, 255) 0 0); + + background: + var(--c) 0% 50%, + var(--c) 50% 50%, + var(--c) 100% 50%; + background-size: 20% 100%; + animation: l1 1s infinite linear; +} + +@keyframes l1 { + 0% { + background-size: + 20% 100%, + 20% 100%, + 20% 100%; + } + 33% { + background-size: + 20% 10%, + 20% 100%, + 20% 100%; + } + 50% { + background-size: + 20% 100%, + 20% 10%, + 20% 100%; + } + 66% { + background-size: + 20% 100%, + 20% 100%, + 20% 10%; + } + 100% { + background-size: + 20% 100%, + 20% 100%, + 20% 100%; + } +} diff --git a/web/src/App.vue b/web/src/App.vue index 979ccdb..709c8c3 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -1,18 +1,18 @@ - - - - - + + + + + diff --git a/web/src/api/index.ts b/web/src/api/index.ts index 4128cd7..00167a3 100644 --- a/web/src/api/index.ts +++ b/web/src/api/index.ts @@ -1,101 +1,101 @@ -import axios from "axios"; - -import { Message } from "@arco-design/web-vue"; -import { useUserInfoStore } from "@/store/modules/user-info"; -import pinia from "@/store/index"; - -declare module "axios" { - interface AxiosInstance { - (config: AxiosRequestConfig): Promise; - } -} - -// 创建axios实例 -const service = axios.create(); - -// 请求拦截器 -service.interceptors.request.use( - function (config: any) { - // 发送请求之前做什么 - // 获取token鉴权 - let userInfo: any = {}; - if (localStorage.getItem("user-info")) { - userInfo = JSON.parse(localStorage.getItem("user-info") as string); - } - if (userInfo?.token) { - // 有token,在请求头中携带token - config.headers.Authorization = userInfo.token; - } - return config; - }, - function (error: any) { - // 请求错误 - return Promise.reject(error); - } -); - -// 响应拦截器 -service.interceptors.response.use( - function (response: any) { - if (response.status != 200) { - Message.error("服务器异常,请联系管理员"); - - return Promise.reject(response.data); - } - - let res = response.data; - if (res.code == 400) { - Message.error(res.msg); - - return Promise.reject(res); - } - - if (res.code == 403) { - // 清除 localStorage - localStorage.removeItem("user-info"); - - // 清除 Pinia store 中的 token 和用户信息 - const userStore = useUserInfoStore(pinia); - userStore.logOut(); - - // 跳转到登录页(保留当前路径前缀,如 /admin) - const basePath = window.location.pathname.split("#")[0]; - window.location.href = `${basePath}#/login`; - - return Promise.reject(res); - } - if (res.code == 404) { - Message.error("请求连接超时"); - - return Promise.reject(res); - } - if (res.code != 200) { - Message.error(res.message); - - return Promise.reject(res); - } - - // 返回数据 - return Promise.resolve(res); - }, - function (error: any) { - // 处理 HTTP 错误状态码 - if (error.response) { - if (error.response.status === 403) { - localStorage.removeItem("user-info"); - const userStore = useUserInfoStore(pinia); - userStore.logOut(); - - Message.error("登录已过期,请重新登录"); - - const basePath = window.location.pathname.split("#")[0]; - - return (window.location.href = `${basePath}#/login`); - } - - return Message.error(error.message || "请求失败"); - } - } -); - -export default service; +import axios from "axios"; + +import { Message } from "@arco-design/web-vue"; +import { useUserInfoStore } from "@/store/modules/user-info"; +import pinia from "@/store/index"; + +declare module "axios" { + interface AxiosInstance { + (config: AxiosRequestConfig): Promise; + } +} + +// 创建axios实例 +const service = axios.create(); + +// 请求拦截器 +service.interceptors.request.use( + function (config: any) { + // 发送请求之前做什么 + // 获取token鉴权 + let userInfo: any = {}; + if (localStorage.getItem("user-info")) { + userInfo = JSON.parse(localStorage.getItem("user-info") as string); + } + if (userInfo?.token) { + // 有token,在请求头中携带token + config.headers.Authorization = userInfo.token; + } + return config; + }, + function (error: any) { + // 请求错误 + return Promise.reject(error); + } +); + +// 响应拦截器 +service.interceptors.response.use( + function (response: any) { + if (response.status != 200) { + Message.error("服务器异常,请联系管理员"); + + return Promise.reject(response.data); + } + + let res = response.data; + if (res.code == 400) { + Message.error(res.msg); + + return Promise.reject(res); + } + + if (res.code == 403) { + // 清除 localStorage + localStorage.removeItem("user-info"); + + // 清除 Pinia store 中的 token 和用户信息 + const userStore = useUserInfoStore(pinia); + userStore.logOut(); + + // 跳转到登录页(保留当前路径前缀,如 /admin) + const basePath = window.location.pathname.split("#")[0]; + window.location.href = `${basePath}#/login`; + + return Promise.reject(res); + } + if (res.code == 404) { + Message.error("请求连接超时"); + + return Promise.reject(res); + } + if (res.code != 200) { + Message.error(res.message); + + return Promise.reject(res); + } + + // 返回数据 + return Promise.resolve(res); + }, + function (error: any) { + // 处理 HTTP 错误状态码 + if (error.response) { + if (error.response.status === 403) { + localStorage.removeItem("user-info"); + const userStore = useUserInfoStore(pinia); + userStore.logOut(); + + Message.error("登录已过期,请重新登录"); + + const basePath = window.location.pathname.split("#")[0]; + + return (window.location.href = `${basePath}#/login`); + } + + return Message.error(error.message || "请求失败"); + } + } +); + +export default service; diff --git a/web/src/api/modules/home/index.ts b/web/src/api/modules/home/index.ts index e8df76d..69c5c98 100644 --- a/web/src/api/modules/home/index.ts +++ b/web/src/api/modules/home/index.ts @@ -1,9 +1,9 @@ -import axios from "@/api"; - -export const getDashboardHomeAPI = (data: any) => { - return axios({ - url: "/api/dashboard/home", - method: "post", - data - }); -}; +import axios from "@/api"; + +export const getDashboardHomeAPI = (data: any) => { + return axios({ + url: "/api/dashboard/home", + method: "post", + data + }); +}; diff --git a/web/src/api/modules/rate/index.ts b/web/src/api/modules/rate/index.ts index 33f4e12..930c318 100644 --- a/web/src/api/modules/rate/index.ts +++ b/web/src/api/modules/rate/index.ts @@ -1,32 +1,32 @@ -import axios from "@/api"; - -export const getRateListAPI = (data: any) => { - return axios({ - url: "/api/rate/list", - method: "post", - data - }); -}; - -export const getSyntaxListAPI = () => { - return axios({ - url: "/api/rate/syntax", - method: "post" - }); -}; - -export const setSyntaxAPI = (data: any) => { - return axios({ - url: "/api/rate/set_syntax", - method: "post", - data - }); -}; - -export const onSyncAPI = (data: any) => { - return axios({ - url: "/api/rate/sync", - method: "post", - data - }); -}; +import axios from "@/api"; + +export const getRateListAPI = (data: any) => { + return axios({ + url: "/api/rate/list", + method: "post", + data + }); +}; + +export const getSyntaxListAPI = () => { + return axios({ + url: "/api/rate/syntax", + method: "post" + }); +}; + +export const setSyntaxAPI = (data: any) => { + return axios({ + url: "/api/rate/set_syntax", + method: "post", + data + }); +}; + +export const onSyncAPI = (data: any) => { + return axios({ + url: "/api/rate/sync", + method: "post", + data + }); +}; diff --git a/web/src/api/modules/system/index.ts b/web/src/api/modules/system/index.ts index a995ce1..ee1be73 100644 --- a/web/src/api/modules/system/index.ts +++ b/web/src/api/modules/system/index.ts @@ -1,58 +1,58 @@ -import axios from "@/api"; - -// 获取菜单数据 -export const getRoutersAPI = () => { - return axios({ - url: "/api/auth/menu", - method: "get" - }); -}; - -// 获取字典数据 -export const getDictAPI = () => { - return axios({ - url: "/mock/system/getDict", - method: "get" - }); -}; - -// 获取部门数据 -export const getDivisionAPI = () => { - return axios({ - url: "/mock/system/getDivision", - method: "get" - }); -}; - -// 获取角色数据 -export const getRoleAPI = () => { - return axios({ - url: "/mock/system/getRole", - method: "get" - }); -}; - -// 获取账户数据 -export const getAccountAPI = () => { - return axios({ - url: "/mock/system/getAccount", - method: "get" - }); -}; - -// 获取菜单管理列表 -export const getMenuListAPI = () => { - return axios({ - url: "/mock/menu/getMenuList", - method: "get" - }); -}; - -// 根据角色获取权限数据 -export const getUserPermissionAPI = (params: { role: string }) => { - return axios({ - url: "/mock/menu/getUserPermission", - method: "get", - params - }); -}; +import axios from "@/api"; + +// 获取菜单数据 +export const getRoutersAPI = () => { + return axios({ + url: "/api/auth/menu", + method: "get" + }); +}; + +// 获取字典数据 +export const getDictAPI = () => { + return axios({ + url: "/mock/system/getDict", + method: "get" + }); +}; + +// 获取部门数据 +export const getDivisionAPI = () => { + return axios({ + url: "/mock/system/getDivision", + method: "get" + }); +}; + +// 获取角色数据 +export const getRoleAPI = () => { + return axios({ + url: "/mock/system/getRole", + method: "get" + }); +}; + +// 获取账户数据 +export const getAccountAPI = () => { + return axios({ + url: "/mock/system/getAccount", + method: "get" + }); +}; + +// 获取菜单管理列表 +export const getMenuListAPI = () => { + return axios({ + url: "/mock/menu/getMenuList", + method: "get" + }); +}; + +// 根据角色获取权限数据 +export const getUserPermissionAPI = (params: { role: string }) => { + return axios({ + url: "/mock/menu/getUserPermission", + method: "get", + params + }); +}; diff --git a/web/src/api/modules/user/index.ts b/web/src/api/modules/user/index.ts index 2fa00ff..8aec0f9 100644 --- a/web/src/api/modules/user/index.ts +++ b/web/src/api/modules/user/index.ts @@ -1,37 +1,37 @@ -import axios from "@/api"; - -// 登录 -export const loginAPI = (data: any) => { - return axios({ - url: "/api/auth/login", - method: "post", - data - }); -}; - -// 获取用户信息 -export const getUserInfoAPI = (params?: any) => { - return axios({ - url: "/api/auth/info", - method: "get", - params - }); -}; - -// 安全设置 -export const securityAPI = (data: any) => { - return axios({ - url: "/api/auth/security", - method: "post", - data - }); -}; - -// 设置密码 -export const setPasswordAPI = (data: any) => { - return axios({ - url: "/api/auth/set_password", - method: "post", - data - }); -}; +import axios from "@/api"; + +// 登录 +export const loginAPI = (data: any) => { + return axios({ + url: "/api/auth/login", + method: "post", + data + }); +}; + +// 获取用户信息 +export const getUserInfoAPI = (params?: any) => { + return axios({ + url: "/api/auth/info", + method: "get", + params + }); +}; + +// 安全设置 +export const securityAPI = (data: any) => { + return axios({ + url: "/api/auth/security", + method: "post", + data + }); +}; + +// 设置密码 +export const setPasswordAPI = (data: any) => { + return axios({ + url: "/api/auth/set_password", + method: "post", + data + }); +}; diff --git a/web/src/api/modules/wallet/index.ts b/web/src/api/modules/wallet/index.ts index 49b1384..afabca0 100644 --- a/web/src/api/modules/wallet/index.ts +++ b/web/src/api/modules/wallet/index.ts @@ -1,33 +1,33 @@ -import axios from "@/api"; - -export const getWalletListAPI = (data: any) => { - return axios({ - url: "/api/wallet/list", - method: "post", - data - }); -}; - -export const delWalletAPI = (data: any) => { - return axios({ - url: "/api/wallet/del", - method: "post", - data - }); -}; - -export const addWalletAPI = (data: any) => { - return axios({ - url: "/api/wallet/add", - method: "post", - data - }); -}; - -export const modWalletAPI = (data: any) => { - return axios({ - url: "/api/wallet/mod", - method: "post", - data - }); -}; +import axios from "@/api"; + +export const getWalletListAPI = (data: any) => { + return axios({ + url: "/api/wallet/list", + method: "post", + data + }); +}; + +export const delWalletAPI = (data: any) => { + return axios({ + url: "/api/wallet/del", + method: "post", + data + }); +}; + +export const addWalletAPI = (data: any) => { + return axios({ + url: "/api/wallet/add", + method: "post", + data + }); +}; + +export const modWalletAPI = (data: any) => { + return axios({ + url: "/api/wallet/mod", + method: "post", + data + }); +}; diff --git a/web/src/assets/fonts/fonts.scss b/web/src/assets/fonts/fonts.scss index c2b1223..07f99cd 100644 --- a/web/src/assets/fonts/fonts.scss +++ b/web/src/assets/fonts/fonts.scss @@ -1,6 +1,6 @@ -@font-face { - font-family: "AliFangYuanTi"; /*字体名-自定义*/ - src: url("./AlimamaFangYuanTiVF-Thin.ttf"); /* 字体路径 */ - font-weight: normal; - font-style: normal; -} +@font-face { + font-family: "AliFangYuanTi"; /*字体名-自定义*/ + src: url("./AlimamaFangYuanTiVF-Thin.ttf"); /* 字体路径 */ + font-weight: normal; + font-style: normal; +} diff --git a/web/src/directives/index.ts b/web/src/directives/index.ts index 339f42f..6c65aae 100644 --- a/web/src/directives/index.ts +++ b/web/src/directives/index.ts @@ -1,31 +1,31 @@ -import { App, Directive } from "vue"; -import antiShake from "@/directives/modules/global/anti-shake"; -import throttle from "@/directives/modules/global/throttle"; -import custom from "@/directives/modules/global/custom"; -import hasPerm from "@/directives/modules/permission/has-perm"; -import hasRole from "@/directives/modules/permission/has-role"; - -// 定义安装函数 -// install 函数是一个对象中的方法,其作用是将一系列指令对象安装到 Vue 应用实例中,它自带两个参数:app 和 options -// app就是vue实例,options则是安装函数的参数(可选) -// install 方法的定义就插件对象,install 方法会在引入插件时自动被 vue 调用,并传参 vue 实例和 options - -const group: { [key: string]: Directive } = { - antiShake, - throttle, - custom, - hasPerm, - hasRole -}; - -const directives = { - install(app: App) { - // 将一系列自定义指令对象安装到 Vue 应用实例中 - for (const key in group) { - app.directive(key, group[key]); - } - } -}; - -// 导出安装函数 -export default directives; +import { App, Directive } from "vue"; +import antiShake from "@/directives/modules/global/anti-shake"; +import throttle from "@/directives/modules/global/throttle"; +import custom from "@/directives/modules/global/custom"; +import hasPerm from "@/directives/modules/permission/has-perm"; +import hasRole from "@/directives/modules/permission/has-role"; + +// 定义安装函数 +// install 函数是一个对象中的方法,其作用是将一系列指令对象安装到 Vue 应用实例中,它自带两个参数:app 和 options +// app就是vue实例,options则是安装函数的参数(可选) +// install 方法的定义就插件对象,install 方法会在引入插件时自动被 vue 调用,并传参 vue 实例和 options + +const group: { [key: string]: Directive } = { + antiShake, + throttle, + custom, + hasPerm, + hasRole +}; + +const directives = { + install(app: App) { + // 将一系列自定义指令对象安装到 Vue 应用实例中 + for (const key in group) { + app.directive(key, group[key]); + } + } +}; + +// 导出安装函数 +export default directives; diff --git a/web/src/directives/modules/global/anti-shake.ts b/web/src/directives/modules/global/anti-shake.ts index 497317e..e988808 100644 --- a/web/src/directives/modules/global/anti-shake.ts +++ b/web/src/directives/modules/global/anti-shake.ts @@ -1,50 +1,50 @@ -import { Directive } from "vue"; - -const antiShake: Directive = { - mounted(el, binding) { - // 判断是否是函数,防抖指令必须绑定函数 - if (typeof binding.value != "function") { - return console.warn("Anti-shake instructions must be bound to a function"); - } - let timeout: any = null; - // 给el添加自定义事件-防抖函数 - el.__onClick__ = () => { - if (timeout) clearTimeout(timeout); - timeout = setTimeout(() => { - // 由于绑定的是函数,这里直接调用绑定之即可(也就是调用绑定的函数) - binding.value(); - }, 500); - }; - // 监听点击事件,点击后调用绑定的自定义事件 - el.addEventListener("click", el.__onClick__); - }, - beforeUnmount(el) { - el.removeEventListener("click", el.__onClick__); - } -}; - -export default antiShake; - -// 每个生命周期都有两个参数,el、binding -// 其中el为绑定的dom元素,binding为指令的传入值 -// app.directive("focus", { -// 在绑定元素的 attribute 前 -// 或事件监听器应用前调用 -// created(el, binding, vnode) { -// // 下面会介绍各个参数的细节 -// }, -// // 在元素被插入到 DOM 前调用 -// beforeMount(el, binding, vnode) {}, -// // 在绑定元素的父组件 -// // 及他自己的所有子节点都挂载完成后调用 -// mounted(el, binding, vnode) {}, -// // 绑定元素的父组件更新前调用 -// beforeUpdate(el, binding, vnode, prevVnode) {}, -// // 在绑定元素的父组件 -// // 及他自己的所有子节点都更新后调用 -// updated(el, binding, vnode, prevVnode) {}, -// // 绑定元素的父组件卸载前调用 -// beforeUnmount(el, binding, vnode) {}, -// // 绑定元素的父组件卸载后调用 -// unmounted(el, binding, vnode) {} -// }); +import { Directive } from "vue"; + +const antiShake: Directive = { + mounted(el, binding) { + // 判断是否是函数,防抖指令必须绑定函数 + if (typeof binding.value != "function") { + return console.warn("Anti-shake instructions must be bound to a function"); + } + let timeout: any = null; + // 给el添加自定义事件-防抖函数 + el.__onClick__ = () => { + if (timeout) clearTimeout(timeout); + timeout = setTimeout(() => { + // 由于绑定的是函数,这里直接调用绑定之即可(也就是调用绑定的函数) + binding.value(); + }, 500); + }; + // 监听点击事件,点击后调用绑定的自定义事件 + el.addEventListener("click", el.__onClick__); + }, + beforeUnmount(el) { + el.removeEventListener("click", el.__onClick__); + } +}; + +export default antiShake; + +// 每个生命周期都有两个参数,el、binding +// 其中el为绑定的dom元素,binding为指令的传入值 +// app.directive("focus", { +// 在绑定元素的 attribute 前 +// 或事件监听器应用前调用 +// created(el, binding, vnode) { +// // 下面会介绍各个参数的细节 +// }, +// // 在元素被插入到 DOM 前调用 +// beforeMount(el, binding, vnode) {}, +// // 在绑定元素的父组件 +// // 及他自己的所有子节点都挂载完成后调用 +// mounted(el, binding, vnode) {}, +// // 绑定元素的父组件更新前调用 +// beforeUpdate(el, binding, vnode, prevVnode) {}, +// // 在绑定元素的父组件 +// // 及他自己的所有子节点都更新后调用 +// updated(el, binding, vnode, prevVnode) {}, +// // 绑定元素的父组件卸载前调用 +// beforeUnmount(el, binding, vnode) {}, +// // 绑定元素的父组件卸载后调用 +// unmounted(el, binding, vnode) {} +// }); diff --git a/web/src/directives/modules/global/custom.ts b/web/src/directives/modules/global/custom.ts index c88257a..24bfd5e 100644 --- a/web/src/directives/modules/global/custom.ts +++ b/web/src/directives/modules/global/custom.ts @@ -1,13 +1,13 @@ -import { Directive } from "vue"; - -const custom: Directive = { - mounted(el, binding) { - el.__onClick__ = () => { - let { goodsId, event } = binding.value; - event(goodsId); - }; - el.addEventListener("click", el.__onClick__); - } -}; - -export default custom; +import { Directive } from "vue"; + +const custom: Directive = { + mounted(el, binding) { + el.__onClick__ = () => { + let { goodsId, event } = binding.value; + event(goodsId); + }; + el.addEventListener("click", el.__onClick__); + } +}; + +export default custom; diff --git a/web/src/directives/modules/global/throttle.ts b/web/src/directives/modules/global/throttle.ts index 8128dfa..6fccc0e 100644 --- a/web/src/directives/modules/global/throttle.ts +++ b/web/src/directives/modules/global/throttle.ts @@ -1,31 +1,31 @@ -import { Directive } from "vue"; - -const throttle: Directive = { - mounted(el, binding) { - if (typeof binding.value != "function") { - return console.warn("The throttling instruction must be bound to a function"); - } - let countDown = 0; - let timer: any = null; - el.__onClick__ = () => { - if (timer) return; - if (countDown == 0) { - binding.value(); - countDown = 1; - } - timer = setInterval(() => { - countDown--; - if (countDown <= 0) { - clearInterval(timer); - timer = null; - } - }, 1000); - }; - el.addEventListener("click", el.__onClick__); - }, - beforeUnmount(el) { - el.removeEventListener("click", el.__onClick__); - } -}; - -export default throttle; +import { Directive } from "vue"; + +const throttle: Directive = { + mounted(el, binding) { + if (typeof binding.value != "function") { + return console.warn("The throttling instruction must be bound to a function"); + } + let countDown = 0; + let timer: any = null; + el.__onClick__ = () => { + if (timer) return; + if (countDown == 0) { + binding.value(); + countDown = 1; + } + timer = setInterval(() => { + countDown--; + if (countDown <= 0) { + clearInterval(timer); + timer = null; + } + }, 1000); + }; + el.addEventListener("click", el.__onClick__); + }, + beforeUnmount(el) { + el.removeEventListener("click", el.__onClick__); + } +}; + +export default throttle; diff --git a/web/src/hooks/useDevicesSize.ts b/web/src/hooks/useDevicesSize.ts index 6deae7a..cf65c9d 100644 --- a/web/src/hooks/useDevicesSize.ts +++ b/web/src/hooks/useDevicesSize.ts @@ -1,21 +1,21 @@ -import { computed } from "vue"; -import { useWindowSize } from "@vueuse/core"; - -interface DeviceSize { - isPc: ComputedRef; - isPad: ComputedRef; - isMobile: ComputedRef; -} -/** - * 小于 768px:适配移动设备(如手机)。 - * 768px - 1024px:适配平板设备。 - * 大于 1024px:适配桌面设备。 - * @returns PC窗口isPc, 平板窗口isPad, 移动端窗口isMobile - */ -export const useDevicesSize = (): DeviceSize => { - const { width } = useWindowSize(); - const isPc = computed(() => width.value > 1024); - const isPad = computed(() => width.value > 768 && width.value <= 1024); - const isMobile = computed(() => width.value <= 768); - return { isPc, isPad, isMobile }; -}; +import { computed } from "vue"; +import { useWindowSize } from "@vueuse/core"; + +interface DeviceSize { + isPc: ComputedRef; + isPad: ComputedRef; + isMobile: ComputedRef; +} +/** + * 小于 768px:适配移动设备(如手机)。 + * 768px - 1024px:适配平板设备。 + * 大于 1024px:适配桌面设备。 + * @returns PC窗口isPc, 平板窗口isPad, 移动端窗口isMobile + */ +export const useDevicesSize = (): DeviceSize => { + const { width } = useWindowSize(); + const isPc = computed(() => width.value > 1024); + const isPad = computed(() => width.value > 768 && width.value <= 1024); + const isMobile = computed(() => width.value <= 768); + return { isPc, isPad, isMobile }; +}; diff --git a/web/src/hooks/useGlobalProperties.ts b/web/src/hooks/useGlobalProperties.ts index dc65cfe..13e63d9 100644 --- a/web/src/hooks/useGlobalProperties.ts +++ b/web/src/hooks/useGlobalProperties.ts @@ -1,3 +1,3 @@ -// 用于全局使用globalProperties -import { getCurrentInstance, ComponentInternalInstance } from "vue"; -export default () => (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties; +// 用于全局使用globalProperties +import { getCurrentInstance, ComponentInternalInstance } from "vue"; +export default () => (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties; diff --git a/web/src/hooks/useMenuMethod.ts b/web/src/hooks/useMenuMethod.ts index 1ca1018..d3f495e 100644 --- a/web/src/hooks/useMenuMethod.ts +++ b/web/src/hooks/useMenuMethod.ts @@ -1,29 +1,29 @@ -/** - * 菜单处理hooks,内置多种菜单处理场景 - * @returns 菜单处理方法 - */ -export const useMenuMethod = () => { - /** - * 多级菜单的显示隐藏 - * @param {Menu.MenuOptions} item 菜单的item - * @returns type:1为目录,并且不隐藏,返回true,否则返回false - */ - const menuShow = (item: Menu.MenuOptions) => { - if (item.meta.type == 1 && !item.meta.hide) return true; - return false; - }; - /** - * 单级菜单的显示隐藏 - * @param {Menu.MenuOptions} item 菜单的item - * @returns type:2为菜单,并且单级菜单不隐藏,返回true,否则返回false - */ - const aMenuShow = (item: Menu.MenuOptions) => { - if (item.meta.type == 2 && !item.meta.hide) return true; - return false; - }; - - return { - menuShow, - aMenuShow - }; -}; +/** + * 菜单处理hooks,内置多种菜单处理场景 + * @returns 菜单处理方法 + */ +export const useMenuMethod = () => { + /** + * 多级菜单的显示隐藏 + * @param {Menu.MenuOptions} item 菜单的item + * @returns type:1为目录,并且不隐藏,返回true,否则返回false + */ + const menuShow = (item: Menu.MenuOptions) => { + if (item.meta.type == 1 && !item.meta.hide) return true; + return false; + }; + /** + * 单级菜单的显示隐藏 + * @param {Menu.MenuOptions} item 菜单的item + * @returns type:2为菜单,并且单级菜单不隐藏,返回true,否则返回false + */ + const aMenuShow = (item: Menu.MenuOptions) => { + if (item.meta.type == 2 && !item.meta.hide) return true; + return false; + }; + + return { + menuShow, + aMenuShow + }; +}; diff --git a/web/src/hooks/useRoutingMethod.ts b/web/src/hooks/useRoutingMethod.ts index 1707310..d3c868c 100644 --- a/web/src/hooks/useRoutingMethod.ts +++ b/web/src/hooks/useRoutingMethod.ts @@ -1,83 +1,83 @@ -import pinia from "@/store/index"; -import { storeToRefs } from "pinia"; -import { useRouteConfigStore } from "@/store/modules/route-config"; -import { findCategoryById, findPathOfParentNode } from "@/utils/tree-tools"; - -/** - * 路由处理hooks,内置多种路由处理场景 - * @returns 路由方法 - */ -export const useRoutingMethod = () => { - /** - * 从一维路由中查找路由 - * @param {string} path 路由的path - * @returns 查找到的路由,undefined则表示未找到 - */ - const findLinearArray = (path: string) => { - const routerStore = useRouteConfigStore(pinia); - const { routeTree } = storeToRefs(routerStore); - return findCategoryById(routeTree.value, "path", path); - }; - - /** - * 根据当前路由找到所有直属父级路由 - * @param {string} path 路由的path - * @returns 查找到的所有父级路由,未找到则null - */ - const getAllParentRoute = (path: string) => { - const routerStore = useRouteConfigStore(pinia); - const { routeTree } = storeToRefs(routerStore); - return findPathOfParentNode(routeTree.value, "path", path); - }; - - /** - * 从一维路由中判断路由是否存在 - * @param {string} key 路由的name - * @returns 路由是否存在,true存在 false不存在 - */ - const hasRoute = (key: string) => { - const routerStore = useRouteConfigStore(pinia); - const { routeList } = storeToRefs(routerStore); - return routeList.value.some((item: Menu.MenuOptions) => item.name == key); - }; - - /** - * 从tabs路由中查找路由 - * @param {string} key 路由的name - * @returns 查找到的路由,undefined则表示未找到 - */ - const findTagsList = (key: string) => { - const routerStore = useRouteConfigStore(pinia); - const { tabsList } = storeToRefs(routerStore); - return tabsList.value.find((item: Menu.MenuOptions) => item.name == key); - }; - - /** - * 处理外链跳转,打开一个新窗口并根据url跳转 - * @param {any} route 路由 - */ - const openExternalLinks = (route: any) => { - // 处理外链跳转 - if (route.meta.link && !route.meta.iframe) { - window.open(route.meta.link as string, "_blank"); - } - }; - - /** - * 检测是否是动态匹配路由,如果是动态匹配路由,则path必然带有"/:"字样,例如:/user/:id - * @param {string} path 路由path - * @returns 是否是动态匹配路由 - */ - const isDynamicRoute = (path: string) => { - return path.includes("/:"); - }; - - return { - findLinearArray, - getAllParentRoute, - findTagsList, - openExternalLinks, - isDynamicRoute, - hasRoute - }; -}; +import pinia from "@/store/index"; +import { storeToRefs } from "pinia"; +import { useRouteConfigStore } from "@/store/modules/route-config"; +import { findCategoryById, findPathOfParentNode } from "@/utils/tree-tools"; + +/** + * 路由处理hooks,内置多种路由处理场景 + * @returns 路由方法 + */ +export const useRoutingMethod = () => { + /** + * 从一维路由中查找路由 + * @param {string} path 路由的path + * @returns 查找到的路由,undefined则表示未找到 + */ + const findLinearArray = (path: string) => { + const routerStore = useRouteConfigStore(pinia); + const { routeTree } = storeToRefs(routerStore); + return findCategoryById(routeTree.value, "path", path); + }; + + /** + * 根据当前路由找到所有直属父级路由 + * @param {string} path 路由的path + * @returns 查找到的所有父级路由,未找到则null + */ + const getAllParentRoute = (path: string) => { + const routerStore = useRouteConfigStore(pinia); + const { routeTree } = storeToRefs(routerStore); + return findPathOfParentNode(routeTree.value, "path", path); + }; + + /** + * 从一维路由中判断路由是否存在 + * @param {string} key 路由的name + * @returns 路由是否存在,true存在 false不存在 + */ + const hasRoute = (key: string) => { + const routerStore = useRouteConfigStore(pinia); + const { routeList } = storeToRefs(routerStore); + return routeList.value.some((item: Menu.MenuOptions) => item.name == key); + }; + + /** + * 从tabs路由中查找路由 + * @param {string} key 路由的name + * @returns 查找到的路由,undefined则表示未找到 + */ + const findTagsList = (key: string) => { + const routerStore = useRouteConfigStore(pinia); + const { tabsList } = storeToRefs(routerStore); + return tabsList.value.find((item: Menu.MenuOptions) => item.name == key); + }; + + /** + * 处理外链跳转,打开一个新窗口并根据url跳转 + * @param {any} route 路由 + */ + const openExternalLinks = (route: any) => { + // 处理外链跳转 + if (route.meta.link && !route.meta.iframe) { + window.open(route.meta.link as string, "_blank"); + } + }; + + /** + * 检测是否是动态匹配路由,如果是动态匹配路由,则path必然带有"/:"字样,例如:/user/:id + * @param {string} path 路由path + * @returns 是否是动态匹配路由 + */ + const isDynamicRoute = (path: string) => { + return path.includes("/:"); + }; + + return { + findLinearArray, + getAllParentRoute, + findTagsList, + openExternalLinks, + isDynamicRoute, + hasRoute + }; +}; diff --git a/web/src/hooks/useThemeMethods.ts b/web/src/hooks/useThemeMethods.ts index 9c3b7bb..42325d0 100644 --- a/web/src/hooks/useThemeMethods.ts +++ b/web/src/hooks/useThemeMethods.ts @@ -1,99 +1,99 @@ -import { storeToRefs } from "pinia"; -import { useThemeConfig } from "@/store/modules/theme-config"; -import { generate, getRgbStr } from "@arco-design/color"; -/** - * 主题处理hooks,内置多种主题处理场景 - * @returns 主题方法 - */ -export const useThemeMethods = () => { - /** - * @description: 初始化主题 - */ - const initTheme = () => { - // 黑暗模式和主题色 - setDarkMode(); - // 色弱模式和灰色模式 - const themeStore = useThemeConfig(); - const { grayMode } = storeToRefs(themeStore); - if (grayMode.value) { - setGray(); - } else { - setColorWeak(); - } - }; - - /** - * @description: 暗黑模式 - */ - const setDarkMode = () => { - const themeStore = useThemeConfig(); - const { darkMode, asideDark } = storeToRefs(themeStore); - if (darkMode.value) { - // 设置为暗黑主题 - document.body.setAttribute("arco-theme", "dark"); - asideDark.value = false; // 黑暗模式与侧边栏深色互斥 - } else { - // 恢复亮色主题 - document.body.removeAttribute("arco-theme"); - } - // 黑暗模式切换后需要更新主题色 - setThemeColor(); - }; - - /** - * @description: 主题色设置 - */ - const setThemeColor = () => { - const themeStore = useThemeConfig(); - const { themeColor, darkMode } = storeToRefs(themeStore); - // 对于给定的颜色,使用算法生成包含10种颜色的渐变样本。这适用于光模式和暗模式。 - let list = generate(themeColor.value, { list: true, dark: darkMode.value }); - list.forEach((color: string, index: number) => { - // https://arco.design/palette/list - // arco的颜色等级为1-10,这里需要index+1 - document.body.style.setProperty(`--primary-${index + 1}`, getRgbStr(color)); - }); - }; - - /** - * @description: 色弱模式 - */ - const setColorWeak = () => { - // 获取html - const htmlCase = document.querySelector("html") as HTMLHtmlElement | null; - if (!htmlCase) return; - const themeStore = useThemeConfig(); - const { colorWeakMode, grayMode } = storeToRefs(themeStore); - if (colorWeakMode.value) { - grayMode.value = false; // 色弱模式和灰色模式互斥 - htmlCase.style.filter = "invert(80%)"; // 反转色80% - } else { - htmlCase.style.filter = ""; - } - }; - - /** - * @description: 灰色模式 - */ - const setGray = () => { - // 获取html - const htmlCase = document.querySelector("html") as HTMLHtmlElement | null; - if (!htmlCase) return; - const themeStore = useThemeConfig(); - const { colorWeakMode, grayMode } = storeToRefs(themeStore); - if (grayMode.value) { - colorWeakMode.value = false; // 色弱模式和灰色模式互斥 - htmlCase.style.filter = "grayscale(100%)"; // 灰度100% - } else { - htmlCase.style.filter = ""; - } - }; - - return { - initTheme, - setDarkMode, - setThemeColor, - setColorWeak, - setGray - }; -}; +import { storeToRefs } from "pinia"; +import { useThemeConfig } from "@/store/modules/theme-config"; +import { generate, getRgbStr } from "@arco-design/color"; +/** + * 主题处理hooks,内置多种主题处理场景 + * @returns 主题方法 + */ +export const useThemeMethods = () => { + /** + * @description: 初始化主题 + */ + const initTheme = () => { + // 黑暗模式和主题色 + setDarkMode(); + // 色弱模式和灰色模式 + const themeStore = useThemeConfig(); + const { grayMode } = storeToRefs(themeStore); + if (grayMode.value) { + setGray(); + } else { + setColorWeak(); + } + }; + + /** + * @description: 暗黑模式 + */ + const setDarkMode = () => { + const themeStore = useThemeConfig(); + const { darkMode, asideDark } = storeToRefs(themeStore); + if (darkMode.value) { + // 设置为暗黑主题 + document.body.setAttribute("arco-theme", "dark"); + asideDark.value = false; // 黑暗模式与侧边栏深色互斥 + } else { + // 恢复亮色主题 + document.body.removeAttribute("arco-theme"); + } + // 黑暗模式切换后需要更新主题色 + setThemeColor(); + }; + + /** + * @description: 主题色设置 + */ + const setThemeColor = () => { + const themeStore = useThemeConfig(); + const { themeColor, darkMode } = storeToRefs(themeStore); + // 对于给定的颜色,使用算法生成包含10种颜色的渐变样本。这适用于光模式和暗模式。 + let list = generate(themeColor.value, { list: true, dark: darkMode.value }); + list.forEach((color: string, index: number) => { + // https://arco.design/palette/list + // arco的颜色等级为1-10,这里需要index+1 + document.body.style.setProperty(`--primary-${index + 1}`, getRgbStr(color)); + }); + }; + + /** + * @description: 色弱模式 + */ + const setColorWeak = () => { + // 获取html + const htmlCase = document.querySelector("html") as HTMLHtmlElement | null; + if (!htmlCase) return; + const themeStore = useThemeConfig(); + const { colorWeakMode, grayMode } = storeToRefs(themeStore); + if (colorWeakMode.value) { + grayMode.value = false; // 色弱模式和灰色模式互斥 + htmlCase.style.filter = "invert(80%)"; // 反转色80% + } else { + htmlCase.style.filter = ""; + } + }; + + /** + * @description: 灰色模式 + */ + const setGray = () => { + // 获取html + const htmlCase = document.querySelector("html") as HTMLHtmlElement | null; + if (!htmlCase) return; + const themeStore = useThemeConfig(); + const { colorWeakMode, grayMode } = storeToRefs(themeStore); + if (grayMode.value) { + colorWeakMode.value = false; // 色弱模式和灰色模式互斥 + htmlCase.style.filter = "grayscale(100%)"; // 灰度100% + } else { + htmlCase.style.filter = ""; + } + }; + + return { + initTheme, + setDarkMode, + setThemeColor, + setColorWeak, + setGray + }; +}; diff --git a/web/src/lang/index.ts b/web/src/lang/index.ts index 7d318ae..56257a3 100644 --- a/web/src/lang/index.ts +++ b/web/src/lang/index.ts @@ -1,39 +1,39 @@ -import { createI18n } from "vue-i18n"; -import zhCN from "@/lang/modules/zhCN"; -import enUS from "@/lang/modules/enUS"; - -/* 获取语言 */ -const getLang = () => { - let store = localStorage.getItem("theme-config"); - if (store) { - return JSON.parse(store)?.language || "zh-CN"; - } else { - return "zh-CN"; - } -}; -/* 这里必须是messages名称 */ -const messages = { - "zh-CN": zhCN, - "en-US": enUS -}; - -const i18n = createI18n({ - legacy: false, // Composition API模式需要设为false - globalInjection: true, // 全局生效: $ - locale: getLang(), // 默认语言 - messages, // 数据源 - missing: (_: string, key: string) => { - return removeBeforeFirstDot(key); - } -}); - -/** - * @param { string } str 国际化key - * @returns 去掉第一个点之前的字符串,例如:"menu.home" => "home",否则返回原字符串 - */ -function removeBeforeFirstDot(str: string) { - const dotIndex = str.indexOf("."); - return dotIndex >= 0 ? str.slice(dotIndex + 1) : str; -} - -export default i18n; +import { createI18n } from "vue-i18n"; +import zhCN from "@/lang/modules/zhCN"; +import enUS from "@/lang/modules/enUS"; + +/* 获取语言 */ +const getLang = () => { + let store = localStorage.getItem("theme-config"); + if (store) { + return JSON.parse(store)?.language || "zh-CN"; + } else { + return "zh-CN"; + } +}; +/* 这里必须是messages名称 */ +const messages = { + "zh-CN": zhCN, + "en-US": enUS +}; + +const i18n = createI18n({ + legacy: false, // Composition API模式需要设为false + globalInjection: true, // 全局生效: $ + locale: getLang(), // 默认语言 + messages, // 数据源 + missing: (_: string, key: string) => { + return removeBeforeFirstDot(key); + } +}); + +/** + * @param { string } str 国际化key + * @returns 去掉第一个点之前的字符串,例如:"menu.home" => "home",否则返回原字符串 + */ +function removeBeforeFirstDot(str: string) { + const dotIndex = str.indexOf("."); + return dotIndex >= 0 ? str.slice(dotIndex + 1) : str; +} + +export default i18n; diff --git a/web/src/lang/modules/enUS.ts b/web/src/lang/modules/enUS.ts index fcfc3f9..ba46b0e 100644 --- a/web/src/lang/modules/enUS.ts +++ b/web/src/lang/modules/enUS.ts @@ -1,119 +1,119 @@ -export default { - system: { - ["login"]: "login", - ["not-power"]: "No permission", - ["not-found"]: "Page not found", - ["zh-CN"]: "中文", - ["en-US"]: "English", - ["refresh"]: "refresh", - ["close-current"]: "close current", - ["close-left-side"]: "close left side", - ["close-right-side"]: "close right side", - ["close-other"]: "close other", - ["close-all"]: "close all", - ["switch-to-night-mode"]: "switch to night mode", - ["switch-to-daytime-mode"]: "switch to daytime mode", - ["full-screen"]: "full screen", - ["exit-full-screen"]: "exit full screen", - ["system-settings"]: "system settings", - ["theme-settings"]: "theme settings", - ["personal-information"]: "personal information", - ["change-password"]: "change password", - ["project-address"]: "project address", - ["logout"]: "logout", - ["notice"]: "Notice", - ["message"]: "Message", - ["backlog"]: "Backlog", - ["switch-language-to-preview"]: "Please switch the language to preview the internationalization effect", - ["please-enter-something"]: "Please enter something" - }, - menu: { - ["home"]: "home", - ["file"]: "file", - ["document-library"]: "document-library", - ["table"]: "table", - ["common-table"]: "common-table", - ["custom-table"]: "custom-table", - ["form"]: "form", - ["common-form"]: "common-form", - ["step-form"]: "step-form", - ["multilevel"]: "multilevel", - ["second-1"]: "second-1", - ["second-2"]: "second-2", - ["third-1"]: "third-1", - ["third-2"]: "third-2", - ["third-3"]: "third-3", - ["third-4"]: "third-4", - ["third-5"]: "third-5", - ["third-6"]: "third-6", - ["third-7"]: "third-7", - ["third-8"]: "third-8", - ["third-9"]: "third-9", - ["component"]: "component", - ["player"]: "player", - ["print"]: "print", - ["draggable"]: "draggable", - ["editor"]: "editor", - ["newbie"]: "newbie", - ["icon-selector"]: "icon-selector", - ["user-center"]: "user-center", - ["fingerprintjs2"]: "fingerprintjs2", - ["barcode"]: "barcode", - ["qrcode"]: "qrcode", - ["pinyin"]: "pinyin", - ["markdown"]: "Markdown", - ["directive"]: "directive", - ["anti-shake"]: "anti-shake", - ["throttle"]: "throttle", - ["test-directive"]: "test-directive", - ["personal"]: "personal", - ["userinfo"]: "userinfo", - ["user-settings"]: "user-settings", - ["system"]: "system", - ["account"]: "account", - ["role"]: "role", - ["menu"]: "menu", - ["division"]: "division", - ["dictionary"]: "dictionary", - ["log"]: "log", - ["about"]: "about", - ["link"]: "link", - ["internal"]: "internal", - ["uigradients"]: "uigradients", - ["color-taking-tool"]: "color-taking-tool", - ["grid-generator"]: "grid-generator", - ["external"]: "external", - ["vue"]: "vue", - ["vite"]: "vite", - ["github"]: "github", - ["SnowAdmin-Docs"]: "SnowAdmin-Docs", - ["juejin"]: "juejin", - ["disable-menu"]: "disable-menu", - ["hide-menu"]: "hide-menu", - ["system-monitor"]: "system monitor", - ["onlineuser"]: "online user", - ["crontab"]: "crontab", - ["crontab-logs"]: "crontab logs", - ["i18n"]: "i18n", - ["amap"]: "amap", - ["permission"]: "permission", - ["btn-perm"]: "btn perm", - ["admin-page"]: "admin page", - ["common-page"]: "common page", - ["functions"]: "functions", - ["routing-operation"]: "routing operation", - ["common-route"]: "common route", - ["dynamic-route"]: "dynamic route", - ["audio"]: "audio", - ["recorder"]: "recorder", - ["virtual-list"]: "virtual-list", - ["common-tools"]: "common tools", - ["tree-tools"]: "tree-tools", - ["file-tools"]: "file-tools", - ["verify-tools"]: "verify tools", - ["common-layouts"]: "common layouts", - ["data-screen"]: "data screen", - ["thin-preview"]: "thin preview", - ["test"]: "test" - } -}; +export default { + system: { + ["login"]: "login", + ["not-power"]: "No permission", + ["not-found"]: "Page not found", + ["zh-CN"]: "中文", + ["en-US"]: "English", + ["refresh"]: "refresh", + ["close-current"]: "close current", + ["close-left-side"]: "close left side", + ["close-right-side"]: "close right side", + ["close-other"]: "close other", + ["close-all"]: "close all", + ["switch-to-night-mode"]: "switch to night mode", + ["switch-to-daytime-mode"]: "switch to daytime mode", + ["full-screen"]: "full screen", + ["exit-full-screen"]: "exit full screen", + ["system-settings"]: "system settings", + ["theme-settings"]: "theme settings", + ["personal-information"]: "personal information", + ["change-password"]: "change password", + ["project-address"]: "project address", + ["logout"]: "logout", + ["notice"]: "Notice", + ["message"]: "Message", + ["backlog"]: "Backlog", + ["switch-language-to-preview"]: "Please switch the language to preview the internationalization effect", + ["please-enter-something"]: "Please enter something" + }, + menu: { + ["home"]: "home", + ["file"]: "file", + ["document-library"]: "document-library", + ["table"]: "table", + ["common-table"]: "common-table", + ["custom-table"]: "custom-table", + ["form"]: "form", + ["common-form"]: "common-form", + ["step-form"]: "step-form", + ["multilevel"]: "multilevel", + ["second-1"]: "second-1", + ["second-2"]: "second-2", + ["third-1"]: "third-1", + ["third-2"]: "third-2", + ["third-3"]: "third-3", + ["third-4"]: "third-4", + ["third-5"]: "third-5", + ["third-6"]: "third-6", + ["third-7"]: "third-7", + ["third-8"]: "third-8", + ["third-9"]: "third-9", + ["component"]: "component", + ["player"]: "player", + ["print"]: "print", + ["draggable"]: "draggable", + ["editor"]: "editor", + ["newbie"]: "newbie", + ["icon-selector"]: "icon-selector", + ["user-center"]: "user-center", + ["fingerprintjs2"]: "fingerprintjs2", + ["barcode"]: "barcode", + ["qrcode"]: "qrcode", + ["pinyin"]: "pinyin", + ["markdown"]: "Markdown", + ["directive"]: "directive", + ["anti-shake"]: "anti-shake", + ["throttle"]: "throttle", + ["test-directive"]: "test-directive", + ["personal"]: "personal", + ["userinfo"]: "userinfo", + ["user-settings"]: "user-settings", + ["system"]: "system", + ["account"]: "account", + ["role"]: "role", + ["menu"]: "menu", + ["division"]: "division", + ["dictionary"]: "dictionary", + ["log"]: "log", + ["about"]: "about", + ["link"]: "link", + ["internal"]: "internal", + ["uigradients"]: "uigradients", + ["color-taking-tool"]: "color-taking-tool", + ["grid-generator"]: "grid-generator", + ["external"]: "external", + ["vue"]: "vue", + ["vite"]: "vite", + ["github"]: "github", + ["SnowAdmin-Docs"]: "SnowAdmin-Docs", + ["juejin"]: "juejin", + ["disable-menu"]: "disable-menu", + ["hide-menu"]: "hide-menu", + ["system-monitor"]: "system monitor", + ["onlineuser"]: "online user", + ["crontab"]: "crontab", + ["crontab-logs"]: "crontab logs", + ["i18n"]: "i18n", + ["amap"]: "amap", + ["permission"]: "permission", + ["btn-perm"]: "btn perm", + ["admin-page"]: "admin page", + ["common-page"]: "common page", + ["functions"]: "functions", + ["routing-operation"]: "routing operation", + ["common-route"]: "common route", + ["dynamic-route"]: "dynamic route", + ["audio"]: "audio", + ["recorder"]: "recorder", + ["virtual-list"]: "virtual-list", + ["common-tools"]: "common tools", + ["tree-tools"]: "tree-tools", + ["file-tools"]: "file-tools", + ["verify-tools"]: "verify tools", + ["common-layouts"]: "common layouts", + ["data-screen"]: "data screen", + ["thin-preview"]: "thin preview", + ["test"]: "test" + } +}; diff --git a/web/src/lang/modules/zhCN.ts b/web/src/lang/modules/zhCN.ts index 429bc5e..b33075d 100644 --- a/web/src/lang/modules/zhCN.ts +++ b/web/src/lang/modules/zhCN.ts @@ -1,128 +1,128 @@ -export default { - system: { - ["login"]: "登录", - ["not-power"]: "没有权限", - ["not-found"]: "未找到页面", - ["zh-CN"]: "中文", - ["en-US"]: "English", - ["refresh"]: "刷新", - ["close-current"]: "关闭当前", - ["close-left-side"]: "关闭左侧", - ["close-right-side"]: "关闭右侧", - ["close-other"]: "关闭其它", - ["close-all"]: "关闭全部", - ["switch-to-night-mode"]: "切换黑夜模式", - ["switch-to-daytime-mode"]: "切换白天模式", - ["full-screen"]: "全屏", - ["exit-full-screen"]: "退出全屏", - ["system-settings"]: "系统设置", - ["theme-settings"]: "主题设置", - ["personal-information"]: "个人信息", - ["change-password"]: "修改密码", - ["project-address"]: "项目地址", - ["logout"]: "退出登录", - ["notice"]: "通知", - ["message"]: "消息", - ["backlog"]: "待办", - ["switch-language-to-preview"]: "请切换语言来预览国际化效果", - ["please-enter-something"]: "请输入" - }, - menu: { - ["home"]: "首页", - ["wallet"]: "钱包管理", - ["order"]: "交易订单", - ["rate"]: "汇率监控", - ["rate-list"]: "同步记录", - ["rate-syntax"]: "汇率配置", - ["system-base"]: "基本设置", - ["system-rpc"]: "区块节点", - ["create-order"]: "创建订单", - ["github-api-doc"]: "对接文档", - ["file"]: "文件管理", - ["document-library"]: "文件库", - ["table"]: "列表管理", - ["common-table"]: "普通列表", - ["custom-table"]: "自定义列表", - ["form"]: "表单管理", - ["common-form"]: "普通表单", - ["step-form"]: "分步表单", - ["multilevel"]: "多级菜单", - ["second-1"]: "二级菜单-1", - ["second-2"]: "二级菜单-2", - ["third-1"]: "三级菜单-1", - ["third-2"]: "三级菜单-2", - ["third-3"]: "三级菜单-3", - ["third-4"]: "三级菜单-4", - ["third-5"]: "三级菜单-5", - ["third-6"]: "三级菜单-6", - ["third-7"]: "三级菜单-7", - ["third-8"]: "三级菜单-8", - ["third-9"]: "三级菜单-9", - ["component"]: "组件管理", - ["player"]: "播放器", - ["print"]: "打印", - ["draggable"]: "拖拽", - ["editor"]: "富文本", - ["newbie"]: "新手指引", - ["icon-selector"]: "图标选择器", - ["user-center"]: "用户中心", - ["fingerprintjs2"]: "浏览器指纹", - ["barcode"]: "条形码", - ["qrcode"]: "二维码", - ["pinyin"]: "拼音转换", - ["markdown"]: "Markdown", - ["directive"]: "自定义指令", - ["anti-shake"]: "防抖", - ["throttle"]: "节流", - ["test-directive"]: "测试指令", - ["personal"]: "个人中心", - ["userinfo"]: "用户信息", - ["user-settings"]: "用户设置", - ["system"]: "系统管理", - ["account"]: "账号管理", - ["role"]: "角色管理", - ["menu"]: "菜单管理", - ["division"]: "部门管理", - ["dictionary"]: "字典管理", - ["log"]: "系统日志", - ["about"]: "关于项目", - ["link"]: "外部链接", - ["internal"]: "内部", - ["uigradients"]: "渐变配色", - ["color-taking-tool"]: "取色工具", - ["grid-generator"]: "网格生成器", - ["external"]: "外部", - ["vue"]: "vue官网", - ["vite"]: "vite官网", - ["github"]: "github", - ["SnowAdmin-Docs"]: "SnowAdmin文档", - ["juejin"]: "掘金", - ["disable-menu"]: "停用菜单", - ["hide-menu"]: "隐藏菜单", - ["system-monitor"]: "系统监控", - ["onlineuser"]: "在线用户", - ["crontab"]: "定时任务", - ["crontab-logs"]: "任务日志", - ["i18n"]: "国际化", - ["amap"]: "高德地图", - ["permission"]: "权限测试", - ["btn-perm"]: "按钮权限", - ["admin-page"]: "管理员页面", - ["common-page"]: "普通角色页面", - ["functions"]: "常用功能", - ["routing-operation"]: "路由操作", - ["common-route"]: "普通路由", - ["dynamic-route"]: "动态路由", - ["audio"]: "音频", - ["recorder"]: "录音", - ["virtual-list"]: "虚拟列表", - ["common-tools"]: "常用工具类", - ["tree-tools"]: "树处理工具类", - ["file-tools"]: "文件工具类", - ["verify-tools"]: "校验工具类", - ["common-layouts"]: "常用布局", - ["data-screen"]: "数据大屏", - ["thin-preview"]: "极简版预览", - ["test"]: "测试" - } -}; +export default { + system: { + ["login"]: "登录", + ["not-power"]: "没有权限", + ["not-found"]: "未找到页面", + ["zh-CN"]: "中文", + ["en-US"]: "English", + ["refresh"]: "刷新", + ["close-current"]: "关闭当前", + ["close-left-side"]: "关闭左侧", + ["close-right-side"]: "关闭右侧", + ["close-other"]: "关闭其它", + ["close-all"]: "关闭全部", + ["switch-to-night-mode"]: "切换黑夜模式", + ["switch-to-daytime-mode"]: "切换白天模式", + ["full-screen"]: "全屏", + ["exit-full-screen"]: "退出全屏", + ["system-settings"]: "系统设置", + ["theme-settings"]: "主题设置", + ["personal-information"]: "个人信息", + ["change-password"]: "修改密码", + ["project-address"]: "项目地址", + ["logout"]: "退出登录", + ["notice"]: "通知", + ["message"]: "消息", + ["backlog"]: "待办", + ["switch-language-to-preview"]: "请切换语言来预览国际化效果", + ["please-enter-something"]: "请输入" + }, + menu: { + ["home"]: "首页", + ["wallet"]: "钱包管理", + ["order"]: "交易订单", + ["rate"]: "汇率监控", + ["rate-list"]: "同步记录", + ["rate-syntax"]: "汇率配置", + ["system-base"]: "基本设置", + ["system-rpc"]: "区块节点", + ["create-order"]: "创建订单", + ["github-api-doc"]: "对接文档", + ["file"]: "文件管理", + ["document-library"]: "文件库", + ["table"]: "列表管理", + ["common-table"]: "普通列表", + ["custom-table"]: "自定义列表", + ["form"]: "表单管理", + ["common-form"]: "普通表单", + ["step-form"]: "分步表单", + ["multilevel"]: "多级菜单", + ["second-1"]: "二级菜单-1", + ["second-2"]: "二级菜单-2", + ["third-1"]: "三级菜单-1", + ["third-2"]: "三级菜单-2", + ["third-3"]: "三级菜单-3", + ["third-4"]: "三级菜单-4", + ["third-5"]: "三级菜单-5", + ["third-6"]: "三级菜单-6", + ["third-7"]: "三级菜单-7", + ["third-8"]: "三级菜单-8", + ["third-9"]: "三级菜单-9", + ["component"]: "组件管理", + ["player"]: "播放器", + ["print"]: "打印", + ["draggable"]: "拖拽", + ["editor"]: "富文本", + ["newbie"]: "新手指引", + ["icon-selector"]: "图标选择器", + ["user-center"]: "用户中心", + ["fingerprintjs2"]: "浏览器指纹", + ["barcode"]: "条形码", + ["qrcode"]: "二维码", + ["pinyin"]: "拼音转换", + ["markdown"]: "Markdown", + ["directive"]: "自定义指令", + ["anti-shake"]: "防抖", + ["throttle"]: "节流", + ["test-directive"]: "测试指令", + ["personal"]: "个人中心", + ["userinfo"]: "用户信息", + ["user-settings"]: "用户设置", + ["system"]: "系统管理", + ["account"]: "账号管理", + ["role"]: "角色管理", + ["menu"]: "菜单管理", + ["division"]: "部门管理", + ["dictionary"]: "字典管理", + ["log"]: "系统日志", + ["about"]: "关于项目", + ["link"]: "外部链接", + ["internal"]: "内部", + ["uigradients"]: "渐变配色", + ["color-taking-tool"]: "取色工具", + ["grid-generator"]: "网格生成器", + ["external"]: "外部", + ["vue"]: "vue官网", + ["vite"]: "vite官网", + ["github"]: "github", + ["SnowAdmin-Docs"]: "SnowAdmin文档", + ["juejin"]: "掘金", + ["disable-menu"]: "停用菜单", + ["hide-menu"]: "隐藏菜单", + ["system-monitor"]: "系统监控", + ["onlineuser"]: "在线用户", + ["crontab"]: "定时任务", + ["crontab-logs"]: "任务日志", + ["i18n"]: "国际化", + ["amap"]: "高德地图", + ["permission"]: "权限测试", + ["btn-perm"]: "按钮权限", + ["admin-page"]: "管理员页面", + ["common-page"]: "普通角色页面", + ["functions"]: "常用功能", + ["routing-operation"]: "路由操作", + ["common-route"]: "普通路由", + ["dynamic-route"]: "动态路由", + ["audio"]: "音频", + ["recorder"]: "录音", + ["virtual-list"]: "虚拟列表", + ["common-tools"]: "常用工具类", + ["tree-tools"]: "树处理工具类", + ["file-tools"]: "文件工具类", + ["verify-tools"]: "校验工具类", + ["common-layouts"]: "常用布局", + ["data-screen"]: "数据大屏", + ["thin-preview"]: "极简版预览", + ["test"]: "测试" + } +}; diff --git a/web/src/layout/components/Aside/index.vue b/web/src/layout/components/Aside/index.vue index 493fdba..fa56f7e 100644 --- a/web/src/layout/components/Aside/index.vue +++ b/web/src/layout/components/Aside/index.vue @@ -1,75 +1,75 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Header/components/Breadcrumb/index.vue b/web/src/layout/components/Header/components/Breadcrumb/index.vue index adf1764..deb8e6c 100644 --- a/web/src/layout/components/Header/components/Breadcrumb/index.vue +++ b/web/src/layout/components/Header/components/Breadcrumb/index.vue @@ -1,81 +1,81 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Header/components/Notice/index.vue b/web/src/layout/components/Header/components/Notice/index.vue index cce6c06..ab6a9bb 100644 --- a/web/src/layout/components/Header/components/Notice/index.vue +++ b/web/src/layout/components/Header/components/Notice/index.vue @@ -1,75 +1,75 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Header/components/button-collapsed/index.vue b/web/src/layout/components/Header/components/button-collapsed/index.vue index 82276dd..cbec681 100644 --- a/web/src/layout/components/Header/components/button-collapsed/index.vue +++ b/web/src/layout/components/Header/components/button-collapsed/index.vue @@ -1,48 +1,48 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Header/components/header-left/index.vue b/web/src/layout/components/Header/components/header-left/index.vue index ca18c98..4a93914 100644 --- a/web/src/layout/components/Header/components/header-left/index.vue +++ b/web/src/layout/components/Header/components/header-left/index.vue @@ -1,19 +1,19 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Header/components/header-right/index.vue b/web/src/layout/components/Header/components/header-right/index.vue index 4b07079..08a5622 100644 --- a/web/src/layout/components/Header/components/header-right/index.vue +++ b/web/src/layout/components/Header/components/header-right/index.vue @@ -1,224 +1,224 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Header/components/system-settings/index.vue b/web/src/layout/components/Header/components/system-settings/index.vue index ba5fae0..163645a 100644 --- a/web/src/layout/components/Header/components/system-settings/index.vue +++ b/web/src/layout/components/Header/components/system-settings/index.vue @@ -1,154 +1,154 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Header/components/theme-settings/index.vue b/web/src/layout/components/Header/components/theme-settings/index.vue index 107b931..e8c459c 100644 --- a/web/src/layout/components/Header/components/theme-settings/index.vue +++ b/web/src/layout/components/Header/components/theme-settings/index.vue @@ -1,237 +1,237 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Header/index.vue b/web/src/layout/components/Header/index.vue index cc756a3..cc6c898 100644 --- a/web/src/layout/components/Header/index.vue +++ b/web/src/layout/components/Header/index.vue @@ -1,22 +1,22 @@ - - - - + + + + diff --git a/web/src/layout/components/Logo/index.vue b/web/src/layout/components/Logo/index.vue index 96ec560..fa4a974 100644 --- a/web/src/layout/components/Logo/index.vue +++ b/web/src/layout/components/Logo/index.vue @@ -1,78 +1,78 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Menu/index.vue b/web/src/layout/components/Menu/index.vue index ac4176f..0d45030 100644 --- a/web/src/layout/components/Menu/index.vue +++ b/web/src/layout/components/Menu/index.vue @@ -1,53 +1,53 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Menu/menu-item-icon.vue b/web/src/layout/components/Menu/menu-item-icon.vue index 21119b7..5c0f57a 100644 --- a/web/src/layout/components/Menu/menu-item-icon.vue +++ b/web/src/layout/components/Menu/menu-item-icon.vue @@ -1,19 +1,19 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Menu/menu-item.vue b/web/src/layout/components/Menu/menu-item.vue index 315c40a..fc27604 100644 --- a/web/src/layout/components/Menu/menu-item.vue +++ b/web/src/layout/components/Menu/menu-item.vue @@ -1,37 +1,37 @@ - - - - - + + + + + diff --git a/web/src/layout/components/Tabs/index.vue b/web/src/layout/components/Tabs/index.vue index 4664f0e..31df13f 100644 --- a/web/src/layout/components/Tabs/index.vue +++ b/web/src/layout/components/Tabs/index.vue @@ -1,187 +1,187 @@ - - - - - + + + + + diff --git a/web/src/layout/components/drawer-aside/index.vue b/web/src/layout/components/drawer-aside/index.vue index 9289381..0f0ba6a 100644 --- a/web/src/layout/components/drawer-aside/index.vue +++ b/web/src/layout/components/drawer-aside/index.vue @@ -1,98 +1,98 @@ - - - - - - + + + + + + diff --git a/web/src/layout/index.vue b/web/src/layout/index.vue index afa7eab..ce59ba1 100644 --- a/web/src/layout/index.vue +++ b/web/src/layout/index.vue @@ -1,24 +1,24 @@ - - - - - + + + + + diff --git a/web/src/layout/layout-defaults/index.vue b/web/src/layout/layout-defaults/index.vue index b257e1b..1c8740c 100644 --- a/web/src/layout/layout-defaults/index.vue +++ b/web/src/layout/layout-defaults/index.vue @@ -1,37 +1,37 @@ - - - - - + + + + + diff --git a/web/src/layout/layout-head/index.vue b/web/src/layout/layout-head/index.vue index 1a38719..f336c83 100644 --- a/web/src/layout/layout-head/index.vue +++ b/web/src/layout/layout-head/index.vue @@ -1,134 +1,134 @@ - - - - - + + + + + diff --git a/web/src/layout/layout-mixing/index.vue b/web/src/layout/layout-mixing/index.vue index 1ee05ac..5afe747 100644 --- a/web/src/layout/layout-mixing/index.vue +++ b/web/src/layout/layout-mixing/index.vue @@ -1,217 +1,217 @@ - - - - - + + + + + diff --git a/web/src/main.ts b/web/src/main.ts index d0baf3e..bf18056 100644 --- a/web/src/main.ts +++ b/web/src/main.ts @@ -1,43 +1,43 @@ -import { createApp } from "vue"; -import "@/style.css"; -import App from "@/App.vue"; -// arco-design -import ArcoVue from "@arco-design/web-vue"; -// vue-router -import router from "@/router/index"; -// pinia -import pinia from "@/store/index"; -// arco-css -import "@arco-design/web-vue/dist/arco.css"; -// vchart-arco-theme 主题关联-黑暗模式 -import { initVChartArcoTheme } from "@visactor/vchart-arco-theme"; -// 额外引入图标库 -import ArcoVueIcon from "@arco-design/web-vue/es/icon"; -// 注册全局svg -import "virtual:svg-icons-register"; -// 引入i18n -import i18n from "@/lang/index"; -// 引入字体 -import "@/assets/fonts/fonts.scss"; -// 引入自定义指令 -import directives from "@/directives/index"; - -// vchart黑暗模式 -// https://arco.design/react/docs/vchart -initVChartArcoTheme(); - -const app = createApp(App); - -// app.use(plugin, options) -// 其中 plugin 表示要传递的插件对象, options 参数是可选的,表示选项配置 -// https://cn.vuejs.org/api/application.html#app-use - -app.use(ArcoVue, { - componentPrefix: "arco" -}); -app.use(pinia); -app.use(ArcoVueIcon); -app.use(router); -app.use(i18n); -app.use(directives); -app.mount("#app"); +import { createApp } from "vue"; +import "@/style.css"; +import App from "@/App.vue"; +// arco-design +import ArcoVue from "@arco-design/web-vue"; +// vue-router +import router from "@/router/index"; +// pinia +import pinia from "@/store/index"; +// arco-css +import "@arco-design/web-vue/dist/arco.css"; +// vchart-arco-theme 主题关联-黑暗模式 +import { initVChartArcoTheme } from "@visactor/vchart-arco-theme"; +// 额外引入图标库 +import ArcoVueIcon from "@arco-design/web-vue/es/icon"; +// 注册全局svg +import "virtual:svg-icons-register"; +// 引入i18n +import i18n from "@/lang/index"; +// 引入字体 +import "@/assets/fonts/fonts.scss"; +// 引入自定义指令 +import directives from "@/directives/index"; + +// vchart黑暗模式 +// https://arco.design/react/docs/vchart +initVChartArcoTheme(); + +const app = createApp(App); + +// app.use(plugin, options) +// 其中 plugin 表示要传递的插件对象, options 参数是可选的,表示选项配置 +// https://cn.vuejs.org/api/application.html#app-use + +app.use(ArcoVue, { + componentPrefix: "arco" +}); +app.use(pinia); +app.use(ArcoVueIcon); +app.use(router); +app.use(i18n); +app.use(directives); +app.mount("#app"); diff --git a/web/src/mock/_data/system_menu.ts b/web/src/mock/_data/system_menu.ts index 1c16d2f..cf766dd 100644 --- a/web/src/mock/_data/system_menu.ts +++ b/web/src/mock/_data/system_menu.ts @@ -1,1847 +1,1847 @@ -/** - * 路由path路径与文件夹名称相同,找文件可以浏览器地址快速查找,方便定位文件 - * - * component - * 模块加载路径,除了layout外,全部默认路径为src/views文件夹内的文件 - * 不要以"/"开头,结尾不要带文件扩展名,如:".vue" - * 举例:views文件夹下的home文件夹下的home.vue - * component: "home/home" - * - * id的具体配置规则: - * 父节点: id: '01' - * |-- 子节点1: '0101' - * | |-- 子节点1-1: '010101' - * | |-- 子节点1-2: '010102' - * |-- 子节点2: '0102' - * | |-- 子节点2-1: '010201' - * | |-- 子节点2-2: '010202' - * 当然,你们也可以自行设计id结构,只要保证id的唯一性即可,最后接口返回的是一个树形结构 - * 注意:节点id不能与parentId相同,否则在遍历路由树的时候会报错 - * 在这种层级编码设计模式下,​不可能自然产生节点ID与parentId相同的情况,但还是需要注意手动录入的情况 - * - * - * 路由meta对象参数,我们通常将属性放到meta对象中 - * meta: { - * title: 国际化key,无对应Key则直接展示 - * isFull: 是否全屏显示,开启条件: true \ false - * hide: 是否隐藏此路由,不会显示在菜单树,可以访问 - * disable: 是否停用此路由-不显示且不可访问 - * keepAlive: 是否缓存组件 - * affix: 固定在Tabs栏上-开启后Tabs栏无关闭按钮 - * link: 是否是超链接菜单,开启外链条件:1、 link:链接地址不为空 2、iframe: false - * iframe: 是否内嵌外链窗口,开启条件:1、iframe:true 2、link:链接地址不为空 - * roles: 路由权限标识,取角色权限,超级管理员:admin;普通角色:common - * svgIcon: svg菜单图标,优先级高于icon,取src/assets/svgs内的svg文件 - * icon: 普通icon菜单图标,默认取arco.design图标 - * sort: 排序字段 - * type: 1目录 2菜单 3按钮 - * } - */ - -/** - * 路由的层级设置 - * layout为框架布局,顶层路由 - * layout.children下的路由为systemMenu菜单,例如:首页、系统设置、权限管理等 - */ -export const systemMenu = [ - // layout-二级路由(主要渲染页面) - { - id: "01", // 路由id - parentId: "0", // 顶层路由 parentId: 0 - path: "/home", // 路由path - name: "home", // 路由name - component: "home/home", // 路由跳转的文件路径,默认在src/views内,这里就是src/views/home/home.vue - meta: { - title: "home", // 国际化key,无对应Key则直接展示 - hide: false, // 是否隐藏此路由-不显示但可访问 - disable: false, // 是否停用此路由-不显示且不可访问 - keepAlive: false, // 是否缓存组件 - affix: true, // 固定在Tabs栏上-开启后Tabs栏无关闭按钮 - link: "", // 是否外链 - iframe: false, // 是否内嵌外链窗口 - isFull: false, // 是否全屏显示 - roles: ["admin", "common"], // 路由角色权限 - svgIcon: "home", // svg菜单图标,优先级高于icon,取src/assets/svgs内的svg文件 - icon: "", // 普通icon菜单图标,默认取arco.design图标 - sort: 1, // 排序字段 - type: 2 // type 1目录 2菜单 3按钮 - }, - children: null // 存储子节点字段,默认为null - }, - { - id: "02", - parentId: "0", - path: "/file", - name: "file", - redirect: "/file/document-library", - meta: { - title: "file", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "folder-menu", - sort: 2, - type: 1 - }, - children: null - }, - { - id: "0201", - parentId: "02", - path: "/file/document-library", - name: "document-library", - component: "file/document-library/document-library", - meta: { - title: "document-library", - hide: false, - disable: false, - keepAlive: true, - affix: false, - isFull: false, - link: "", - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "03", - parentId: "0", - path: "/table", - name: "table", - redirect: "/table/common-table", - meta: { - title: "table", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "table", - sort: 3, - type: 1 - }, - children: null - }, - { - id: "0301", - parentId: "03", - path: "/table/common-table", - name: "common-table", - component: "table/common-table/common-table", - meta: { - title: "common-table", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "0302", - parentId: "03", - path: "/table/custom-table", - name: "custom-table", - component: "table/custom-table/custom-table", - meta: { - title: "custom-table", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "04", - parentId: "0", - path: "/form", - name: "form", - redirect: "/form/common-form", - meta: { - title: "form", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "form", - sort: 4, - type: 1 - }, - children: null - }, - { - id: "0401", - parentId: "04", - path: "/form/common-form", - name: "common-form", - component: "form/common-form/common-form", - meta: { - title: "common-form", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "0402", - parentId: "04", - path: "/form/step-form", - name: "step-form", - component: "form/step-form/step-form", - meta: { - title: "step-form", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "05", - parentId: "0", - path: "/multilevel", - name: "multilevel", - redirect: "/multilevel/second-1", - meta: { - title: "multilevel", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "switch", - sort: 5, - type: 1 - }, - children: null - }, - { - id: "0501", - parentId: "05", - path: "/multilevel/second-1", - name: "second-1", - component: "multilevel/second/second-1", - meta: { - title: "second-1", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "0502", - parentId: "05", - path: "/multilevel/second-2", - name: "second-2", - redirect: "/multilevel/third-1", - meta: { - title: "second-2", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 1 - }, - children: null - }, - { - id: "050201", - parentId: "0502", - path: "/multilevel/third-2", - name: "third-2", - component: "multilevel/third/third-2", - meta: { - title: "third-2", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "050202", - parentId: "0502", - path: "/multilevel/third-1", - name: "third-1", - component: "multilevel/third/third-1", - meta: { - title: "third-1", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "050203", - parentId: "0502", - path: "/multilevel/third-3", - name: "third-3", - component: "multilevel/third/third-3", - meta: { - title: "third-3", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3, - type: 2 - }, - children: null - }, - { - id: "06", - parentId: "0", - path: "/component", - name: "component", - redirect: "/component/player", - meta: { - title: "component", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "classify", - sort: 6, - type: 1 - }, - children: null - }, - { - id: "0601", - parentId: "06", - path: "/component/player", - name: "player", - component: "component/player/player", - meta: { - title: "player", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "0602", - parentId: "06", - path: "/component/print", - name: "print", - component: "component/print/print", - meta: { - title: "print", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "0603", - parentId: "06", - path: "/component/draggable", - name: "draggable", - component: "component/draggable/draggable", - meta: { - title: "draggable", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3, - type: 2 - }, - children: null - }, - { - id: "0604", - parentId: "06", - path: "/component/editor", - name: "editor", - component: "component/editor/editor", - meta: { - title: "editor", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 4, - type: 2 - }, - children: null - }, - { - id: "0605", - parentId: "06", - path: "/component/newbie", - name: "newbie", - component: "component/newbie/newbie", - meta: { - title: "newbie", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 5, - type: 2 - }, - children: null - }, - { - id: "0606", - parentId: "06", - path: "/component/icon-selector", - name: "icon-selector", - component: "component/icon-selector/icon-selector", - meta: { - title: "icon-selector", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 6, - type: 2 - }, - children: null - }, - { - id: "0607", - parentId: "06", - path: "/component/user-center", - name: "user-center", - component: "component/user-center/user-center", - meta: { - title: "user-center", - hide: true, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 7, - type: 2 - }, - children: null - }, - { - id: "0608", - parentId: "06", - path: "/component/fingerprintjs2", - name: "fingerprintjs2", - component: "component/fingerprintjs2/fingerprintjs2", - meta: { - title: "fingerprintjs2", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 8, - type: 2 - }, - children: null - }, - { - id: "0609", - parentId: "06", - path: "/component/barcode", - name: "barcode", - component: "component/barcode/barcode", - meta: { - title: "barcode", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 9, - type: 2 - }, - children: null - }, - { - id: "0610", - parentId: "06", - path: "/component/qrcode", - name: "qrcode", - component: "component/qrcode/qrcode", - meta: { - title: "qrcode", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 10, - type: 2 - }, - children: null - }, - { - id: "0611", - parentId: "06", - path: "/component/pinyin", - name: "pinyin", - component: "component/pinyin/pinyin", - meta: { - title: "pinyin", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 11, - type: 2 - }, - children: null - }, - { - id: "0612", - parentId: "06", - path: "/component/recorder", - name: "recorder", - component: "component/recorder/recorder", - meta: { - title: "recorder", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 12, - type: 2 - }, - children: null - }, - { - id: "0613", - parentId: "06", - path: "/component/virtual-list", - name: "virtual-list", - component: "component/virtual-list/index", - meta: { - title: "virtual-list", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 13, - type: 2 - }, - children: null - }, - { - id: "0614", - parentId: "06", - path: "/component/common-layouts", - name: "common-layouts", - component: "component/common-layouts/index", - meta: { - title: "common-layouts", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 14, - type: 2 - }, - children: null - }, - { - id: "07", - parentId: "0", - path: "/directive", - name: "directive", - redirect: "/directive/anti-shake", - meta: { - title: "directive", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "directives", - sort: 7, - type: 1 - }, - children: null - }, - { - id: "0701", - parentId: "07", - path: "/directive/anti-shake", - name: "anti-shake", - component: "directive/anti-shake/anti-shake", - meta: { - title: "anti-shake", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "0702", - parentId: "07", - path: "/directive/throttle", - name: "throttle", - component: "directive/throttle/throttle", - meta: { - title: "throttle", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "0703", - parentId: "07", - path: "/directive/test-directive", - name: "test-directive", - component: "directive/test-directive/test-directive", - meta: { - title: "test-directive", - hide: true, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3, - type: 2 - }, - children: null - }, - // { - // id: "08", - // parentId: "0", - // path: "/personal", - // name: "personal", - // redirect: "/personal/userinfo", - // meta: { - // title: "personal", - // hide: false, - // disable: false, - // keepAlive: true, - // affix: false, - // link: "", - // iframe: false, - // isFull: false, - // roles: ["admin"], - // svgIcon: "user", - // sort: 8, - // type: 1 - // }, - // children: null - // }, - // { - // id: "0801", - // parentId: "08", - // path: "/personal/userinfo", - // name: "userinfo", - // component: "personal/userinfo/userinfo", - // meta: { - // title: "userinfo", - // hide: false, - // disable: false, - // keepAlive: true, - // affix: false, - // link: "", - // iframe: false, - // isFull: false, - // roles: ["admin"], - // icon: "icon-menu", - // sort: 1, - // type: 2 - // }, - // children: null - // }, - // { - // id: "0802", - // parentId: "08", - // path: "/personal/user-settings", - // name: "user-settings", - // component: "personal/user-settings/user-settings", - // meta: { - // title: "user-settings", - // hide: false, - // disable: false, - // keepAlive: true, - // affix: false, - // link: "", - // iframe: false, - // isFull: false, - // roles: ["admin"], - // icon: "icon-menu", - // sort: 2, - // type: 2 - // }, - // children: null - // }, - { - id: "09", - parentId: "0", - path: "/functions", - name: "functions", - redirect: "/functions/routing-operation", - meta: { - title: "functions", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "functions", - sort: 9, - type: 1 - }, - children: null - }, - { - id: "0901", - parentId: "09", - path: "/functions/routing-operation", - name: "routing-operation", - component: "functions/routing-operation/index", - meta: { - title: "routing-operation", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "090101", - parentId: "0901", - path: "/functions/routing-operation/common-route", - name: "common-route", - component: "functions/routing-operation/common-route", - meta: { - title: "common-route", - hide: true, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "switch", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "090102", - parentId: "0901", - path: "/functions/routing-operation/dynamic-route/:name/:text", - name: "dynamic-route", - component: "functions/routing-operation/dynamic-route", - meta: { - title: "dynamic-route", - hide: true, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "switch", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "0902", - parentId: "09", - path: "/functions/common-tools", - name: "common-tools", - component: "functions/common-tools/common-tools", - meta: { - title: "common-tools", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "0903", - parentId: "09", - path: "/functions/tree-tools", - name: "tree-tools", - component: "functions/tree-tools/tree-tools", - meta: { - title: "tree-tools", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3, - type: 2 - }, - children: null - }, - { - id: "0904", - parentId: "09", - path: "/functions/file-tools", - name: "file-tools", - component: "functions/file-tools/file-tools", - meta: { - title: "file-tools", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 4, - type: 2 - }, - children: null - }, - { - id: "0905", - parentId: "09", - path: "/functions/verify-tools", - name: "verify-tools", - component: "functions/verify-tools/verify-tools", - meta: { - title: "verify-tools", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 5, - type: 2 - }, - children: null - }, - { - id: "10", - parentId: "0", - path: "/system", - name: "system", - redirect: "/system/account", - meta: { - title: "system", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin", "common"], - svgIcon: "set", - sort: 10, - type: 1 - }, - children: null - }, - { - id: "1001", - parentId: "10", - path: "/system/account", - name: "account", - component: "system/account/account", - meta: { - title: "account", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "1002", - parentId: "10", - path: "/system/role", - name: "role", - component: "system/role/role", - meta: { - title: "role", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "1003", - parentId: "10", - path: "/system/menu", - name: "menu", - component: "system/menu/menu", - meta: { - title: "menu", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3, - type: 2 - }, - children: null - }, - { - id: "1004", - parentId: "10", - path: "/system/division", - name: "division", - component: "system/division/division", - meta: { - title: "division", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 4, - type: 2 - }, - children: null - }, - { - id: "1005", - parentId: "10", - path: "/system/dictionary", - name: "dictionary", - component: "system/dictionary/dictionary", - meta: { - title: "dictionary", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 5, - type: 2 - }, - children: null - }, - { - id: "1006", - parentId: "10", - path: "/system/log", - name: "log", - component: "system/log/log", - meta: { - title: "log", - hide: true, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 6, - type: 2 - }, - children: null - }, - { - id: "1007", - parentId: "10", - path: "/system/userinfo", - name: "userinfo", - component: "system/userinfo/userinfo", - meta: { - title: "userinfo", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin", "common"], - icon: "icon-menu", - sort: 7, - type: 2 - }, - children: null - }, - { - id: "11", - parentId: "0", - path: "/disable-menu", - name: "disable-menu", - component: "disable-menu/disable-menu", - meta: { - title: "disable-menu", - hide: false, - disable: true, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "switch", - sort: 11, - type: 2 - }, - children: null - }, - { - id: "12", - parentId: "0", - path: "/hide-menu", - name: "hide-menu", - component: "hide-menu/hide-menu", - meta: { - title: "hide-menu", - hide: true, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "switch", - sort: 12, - type: 2 - }, - children: null - }, - { - id: "13", - parentId: "0", - path: "/permission", - name: "permission", - redirect: "/permission/btn-perm", - meta: { - title: "permission", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin", "common"], - svgIcon: "defend", - sort: 13, - type: 1 - }, - children: null - }, - { - id: "1301", - parentId: "13", - path: "/permission/btn-perm", - name: "btn-perm", - component: "permission/btn-perm/btn-perm", - meta: { - title: "btn-perm", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin", "common"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "1302", - parentId: "13", - path: "/permission/admin-page", - name: "admin-page", - component: "permission/admin-page/admin-page", - meta: { - title: "admin-page", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "1303", - parentId: "13", - path: "/permission/common-page", - name: "common-page", - component: "permission/common-page/common-page", - meta: { - title: "common-page", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["common"], - icon: "icon-menu", - sort: 3, - type: 2 - }, - children: null - }, - { - id: "14", - parentId: "0", - path: "/link", - name: "link", - redirect: "/link/internal", - meta: { - title: "link", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "link", - sort: 14, - type: 1 - }, - children: null - }, - { - id: "1401", - parentId: "14", - path: "/link/internal", - name: "internal", - redirect: "/link/internal/uigradients", - meta: { - title: "internal", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 1 - }, - children: null - }, - { - id: "140101", - parentId: "1401", - path: "/link/internal/uigradients", - name: "uigradients", - component: "link/internal/internal", - meta: { - title: "uigradients", - hide: false, - keepAlive: true, - disable: false, - affix: false, - link: "https://uigradients.com/#HoneyDew", // 链接 - iframe: true, // 区分是否内链 true内链 false外链 - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "140102", - parentId: "1401", - path: "/link/internal/color-taking-tool", - name: "color-taking-tool", - component: "link/internal/internal", - meta: { - title: "color-taking-tool", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "https://photokit.com/colors/eyedropper/?lang=zh", // 链接 - iframe: true, // 区分是否内链 true内链 false外链 - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "140103", - parentId: "1401", - path: "/link/internal/grid-generator", - name: "grid-generator", - component: "link/internal/internal", - meta: { - title: "grid-generator", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "https://cssgrid-generator.netlify.app/", // 链接 - iframe: true, // 区分是否内链 true内链 false外链 - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3, - type: 2 - }, - children: null - }, - { - id: "140104", - parentId: "1401", - path: "/link/internal/gaodemap", - name: "gaodemap", - component: "link/internal/internal", - meta: { - title: "amap", - hide: false, - keepAlive: true, - disable: false, - affix: false, - link: "http://115.190.79.132:82/", // 链接 - iframe: true, // 区分是否内链 true内链 false外链 - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 4, - type: 2 - }, - children: null - }, - { - id: "1402", - parentId: "14", - path: "/link/external", - name: "external", - redirect: "/link/external/link-vue", - meta: { - title: "external", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 1 - }, - children: null - }, - { - id: "140201", - parentId: "1402", - path: "/link/external/SnowAdmin-Docs", - name: "SnowAdmin-Docs", - component: "link/external/external", - meta: { - title: "SnowAdmin-Docs", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "http://115.190.79.132:81/", // 链接 - iframe: false, // 区分是否内链 true内链 false外链 - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 5, - type: 2 - }, - children: null - }, - { - id: "140202", - parentId: "1402", - path: "/link/external/vue", - name: "vue", - component: "link/external/external", - meta: { - title: "vue", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "https://cn.vuejs.org/", // 链接 - iframe: false, // 区分是否内链 true内链 false外链 - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "140203", - parentId: "1402", - path: "/link/external/vite", - name: "vite", - component: "link/external/external", - meta: { - title: "vite", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "https://www.vitejs.net/", // 链接 - iframe: false, // 区分是否内链 true内链 false外链 - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "140204", - parentId: "1402", - path: "/link/external/github", - name: "github", - component: "link/external/external", - meta: { - title: "github", - hide: false, - disable: true, - keepAlive: true, - affix: false, - link: "https://github.com/WangFan-io/SnowAdmin", // 链接 - iframe: false, // 区分是否内链 true内链 false外链 - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3, - type: 2 - }, - children: null - }, - { - id: "140205", - parentId: "1402", - path: "/link/external/juejin", - name: "juejin", - component: "link/external/external", - meta: { - title: "juejin", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "https://juejin.cn/user/1728883023940600", // 链接 - iframe: false, // 区分是否内链 true内链 false外链 - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 4, - type: 2 - }, - children: null - }, - { - id: "15", - parentId: "0", - path: "/monitor", - name: "monitor", - redirect: "/monitor/onlineuser", - meta: { - title: "system-monitor", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "financial-statement", - sort: 15, - type: 1 - }, - children: null - }, - { - id: "1501", - parentId: "15", - path: "/monitor/onlineuser", - name: "onlineuser", - component: "monitor/onlineuser/index", - meta: { - title: "onlineuser", - hide: false, - keepAlive: true, - disable: false, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 1, - type: 2 - }, - children: null - }, - { - id: "1502", - parentId: "15", - path: "/monitor/crontab", - name: "crontab", - component: "monitor/crontab/index", - meta: { - title: "crontab", - hide: false, - keepAlive: true, - disable: false, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 2, - type: 2 - }, - children: null - }, - { - id: "1503", - parentId: "15", - path: "/monitor/crontab-logs", - name: "crontab-logs", - component: "monitor/crontab-logs/index", - meta: { - title: "crontab-logs", - hide: false, - keepAlive: true, - disable: false, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3, - type: 2 - }, - children: null - }, - { - id: "16", - parentId: "0", - path: "/SnowAdmin-Thin", - name: "thin-preview", - component: "link/external/external", - meta: { - title: "thin-preview", - hide: false, - disable: false, - keepAlive: false, - affix: true, - link: "http://115.190.79.132:83/#/login", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "propaganda", - icon: "", - sort: 16, - type: 2 - }, - children: null - }, - { - id: "17", - parentId: "0", - path: "/i18n", - name: "i18n", - component: "i18n/show/index", - meta: { - title: "i18n", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin"], - svgIcon: "earth", - sort: 17, - type: 2 - }, - children: null - }, - { - id: "18", - parentId: "0", - path: "/about", - name: "about", - component: "about/about", - meta: { - title: "about", - hide: false, - disable: false, - keepAlive: true, - affix: false, - link: "", - iframe: false, - isFull: false, - roles: ["admin", "common"], - svgIcon: "about", - sort: 18, - type: 2 - }, - children: null - } -]; - -// 权限数据 -export const permissionData = [ - { - id: "130101", - parentId: "1301", - meta: { - title: "新增按钮", - hide: false, - disable: false, - roles: ["admin"], - permission: "sys:btn:add", - sort: 1, - type: 3 - } - }, - { - id: "130102", - parentId: "1301", - meta: { - title: "编辑按钮", - hide: false, - disable: false, - roles: ["admin"], - permission: "sys:btn:edit", - sort: 2, - type: 3 - } - }, - { - id: "130103", - parentId: "1301", - meta: { - title: "删除按钮", - hide: false, - disable: false, - roles: ["admin"], - permission: "sys:btn:delete", - sort: 3, - type: 3 - } - }, - { - id: "130201", - parentId: "1301", - meta: { - title: "新增按钮-2", - hide: false, - disable: false, - roles: ["admin", "common"], - permission: "common:btn:add", - sort: 1, - type: 3 - } - }, - { - id: "130202", - parentId: "1301", - meta: { - title: "编辑按钮-2", - hide: false, - disable: false, - roles: ["admin", "common"], - permission: "common:btn:edit", - sort: 2, - type: 3 - } - }, - { - id: "130203", - parentId: "1301", - meta: { - title: "删除按钮-2", - hide: false, - disable: false, - roles: ["admin", "common"], - permission: "common:btn:delete", - sort: 3, - type: 3 - } - } -]; +/** + * 路由path路径与文件夹名称相同,找文件可以浏览器地址快速查找,方便定位文件 + * + * component + * 模块加载路径,除了layout外,全部默认路径为src/views文件夹内的文件 + * 不要以"/"开头,结尾不要带文件扩展名,如:".vue" + * 举例:views文件夹下的home文件夹下的home.vue + * component: "home/home" + * + * id的具体配置规则: + * 父节点: id: '01' + * |-- 子节点1: '0101' + * | |-- 子节点1-1: '010101' + * | |-- 子节点1-2: '010102' + * |-- 子节点2: '0102' + * | |-- 子节点2-1: '010201' + * | |-- 子节点2-2: '010202' + * 当然,你们也可以自行设计id结构,只要保证id的唯一性即可,最后接口返回的是一个树形结构 + * 注意:节点id不能与parentId相同,否则在遍历路由树的时候会报错 + * 在这种层级编码设计模式下,​不可能自然产生节点ID与parentId相同的情况,但还是需要注意手动录入的情况 + * + * + * 路由meta对象参数,我们通常将属性放到meta对象中 + * meta: { + * title: 国际化key,无对应Key则直接展示 + * isFull: 是否全屏显示,开启条件: true \ false + * hide: 是否隐藏此路由,不会显示在菜单树,可以访问 + * disable: 是否停用此路由-不显示且不可访问 + * keepAlive: 是否缓存组件 + * affix: 固定在Tabs栏上-开启后Tabs栏无关闭按钮 + * link: 是否是超链接菜单,开启外链条件:1、 link:链接地址不为空 2、iframe: false + * iframe: 是否内嵌外链窗口,开启条件:1、iframe:true 2、link:链接地址不为空 + * roles: 路由权限标识,取角色权限,超级管理员:admin;普通角色:common + * svgIcon: svg菜单图标,优先级高于icon,取src/assets/svgs内的svg文件 + * icon: 普通icon菜单图标,默认取arco.design图标 + * sort: 排序字段 + * type: 1目录 2菜单 3按钮 + * } + */ + +/** + * 路由的层级设置 + * layout为框架布局,顶层路由 + * layout.children下的路由为systemMenu菜单,例如:首页、系统设置、权限管理等 + */ +export const systemMenu = [ + // layout-二级路由(主要渲染页面) + { + id: "01", // 路由id + parentId: "0", // 顶层路由 parentId: 0 + path: "/home", // 路由path + name: "home", // 路由name + component: "home/home", // 路由跳转的文件路径,默认在src/views内,这里就是src/views/home/home.vue + meta: { + title: "home", // 国际化key,无对应Key则直接展示 + hide: false, // 是否隐藏此路由-不显示但可访问 + disable: false, // 是否停用此路由-不显示且不可访问 + keepAlive: false, // 是否缓存组件 + affix: true, // 固定在Tabs栏上-开启后Tabs栏无关闭按钮 + link: "", // 是否外链 + iframe: false, // 是否内嵌外链窗口 + isFull: false, // 是否全屏显示 + roles: ["admin", "common"], // 路由角色权限 + svgIcon: "home", // svg菜单图标,优先级高于icon,取src/assets/svgs内的svg文件 + icon: "", // 普通icon菜单图标,默认取arco.design图标 + sort: 1, // 排序字段 + type: 2 // type 1目录 2菜单 3按钮 + }, + children: null // 存储子节点字段,默认为null + }, + { + id: "02", + parentId: "0", + path: "/file", + name: "file", + redirect: "/file/document-library", + meta: { + title: "file", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "folder-menu", + sort: 2, + type: 1 + }, + children: null + }, + { + id: "0201", + parentId: "02", + path: "/file/document-library", + name: "document-library", + component: "file/document-library/document-library", + meta: { + title: "document-library", + hide: false, + disable: false, + keepAlive: true, + affix: false, + isFull: false, + link: "", + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "03", + parentId: "0", + path: "/table", + name: "table", + redirect: "/table/common-table", + meta: { + title: "table", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "table", + sort: 3, + type: 1 + }, + children: null + }, + { + id: "0301", + parentId: "03", + path: "/table/common-table", + name: "common-table", + component: "table/common-table/common-table", + meta: { + title: "common-table", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "0302", + parentId: "03", + path: "/table/custom-table", + name: "custom-table", + component: "table/custom-table/custom-table", + meta: { + title: "custom-table", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "04", + parentId: "0", + path: "/form", + name: "form", + redirect: "/form/common-form", + meta: { + title: "form", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "form", + sort: 4, + type: 1 + }, + children: null + }, + { + id: "0401", + parentId: "04", + path: "/form/common-form", + name: "common-form", + component: "form/common-form/common-form", + meta: { + title: "common-form", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "0402", + parentId: "04", + path: "/form/step-form", + name: "step-form", + component: "form/step-form/step-form", + meta: { + title: "step-form", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "05", + parentId: "0", + path: "/multilevel", + name: "multilevel", + redirect: "/multilevel/second-1", + meta: { + title: "multilevel", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "switch", + sort: 5, + type: 1 + }, + children: null + }, + { + id: "0501", + parentId: "05", + path: "/multilevel/second-1", + name: "second-1", + component: "multilevel/second/second-1", + meta: { + title: "second-1", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "0502", + parentId: "05", + path: "/multilevel/second-2", + name: "second-2", + redirect: "/multilevel/third-1", + meta: { + title: "second-2", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 1 + }, + children: null + }, + { + id: "050201", + parentId: "0502", + path: "/multilevel/third-2", + name: "third-2", + component: "multilevel/third/third-2", + meta: { + title: "third-2", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "050202", + parentId: "0502", + path: "/multilevel/third-1", + name: "third-1", + component: "multilevel/third/third-1", + meta: { + title: "third-1", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "050203", + parentId: "0502", + path: "/multilevel/third-3", + name: "third-3", + component: "multilevel/third/third-3", + meta: { + title: "third-3", + link: "", + hide: false, + keepAlive: true, + affix: false, + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3, + type: 2 + }, + children: null + }, + { + id: "06", + parentId: "0", + path: "/component", + name: "component", + redirect: "/component/player", + meta: { + title: "component", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "classify", + sort: 6, + type: 1 + }, + children: null + }, + { + id: "0601", + parentId: "06", + path: "/component/player", + name: "player", + component: "component/player/player", + meta: { + title: "player", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "0602", + parentId: "06", + path: "/component/print", + name: "print", + component: "component/print/print", + meta: { + title: "print", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "0603", + parentId: "06", + path: "/component/draggable", + name: "draggable", + component: "component/draggable/draggable", + meta: { + title: "draggable", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3, + type: 2 + }, + children: null + }, + { + id: "0604", + parentId: "06", + path: "/component/editor", + name: "editor", + component: "component/editor/editor", + meta: { + title: "editor", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 4, + type: 2 + }, + children: null + }, + { + id: "0605", + parentId: "06", + path: "/component/newbie", + name: "newbie", + component: "component/newbie/newbie", + meta: { + title: "newbie", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 5, + type: 2 + }, + children: null + }, + { + id: "0606", + parentId: "06", + path: "/component/icon-selector", + name: "icon-selector", + component: "component/icon-selector/icon-selector", + meta: { + title: "icon-selector", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 6, + type: 2 + }, + children: null + }, + { + id: "0607", + parentId: "06", + path: "/component/user-center", + name: "user-center", + component: "component/user-center/user-center", + meta: { + title: "user-center", + hide: true, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 7, + type: 2 + }, + children: null + }, + { + id: "0608", + parentId: "06", + path: "/component/fingerprintjs2", + name: "fingerprintjs2", + component: "component/fingerprintjs2/fingerprintjs2", + meta: { + title: "fingerprintjs2", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 8, + type: 2 + }, + children: null + }, + { + id: "0609", + parentId: "06", + path: "/component/barcode", + name: "barcode", + component: "component/barcode/barcode", + meta: { + title: "barcode", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 9, + type: 2 + }, + children: null + }, + { + id: "0610", + parentId: "06", + path: "/component/qrcode", + name: "qrcode", + component: "component/qrcode/qrcode", + meta: { + title: "qrcode", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 10, + type: 2 + }, + children: null + }, + { + id: "0611", + parentId: "06", + path: "/component/pinyin", + name: "pinyin", + component: "component/pinyin/pinyin", + meta: { + title: "pinyin", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 11, + type: 2 + }, + children: null + }, + { + id: "0612", + parentId: "06", + path: "/component/recorder", + name: "recorder", + component: "component/recorder/recorder", + meta: { + title: "recorder", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 12, + type: 2 + }, + children: null + }, + { + id: "0613", + parentId: "06", + path: "/component/virtual-list", + name: "virtual-list", + component: "component/virtual-list/index", + meta: { + title: "virtual-list", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 13, + type: 2 + }, + children: null + }, + { + id: "0614", + parentId: "06", + path: "/component/common-layouts", + name: "common-layouts", + component: "component/common-layouts/index", + meta: { + title: "common-layouts", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 14, + type: 2 + }, + children: null + }, + { + id: "07", + parentId: "0", + path: "/directive", + name: "directive", + redirect: "/directive/anti-shake", + meta: { + title: "directive", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "directives", + sort: 7, + type: 1 + }, + children: null + }, + { + id: "0701", + parentId: "07", + path: "/directive/anti-shake", + name: "anti-shake", + component: "directive/anti-shake/anti-shake", + meta: { + title: "anti-shake", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "0702", + parentId: "07", + path: "/directive/throttle", + name: "throttle", + component: "directive/throttle/throttle", + meta: { + title: "throttle", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "0703", + parentId: "07", + path: "/directive/test-directive", + name: "test-directive", + component: "directive/test-directive/test-directive", + meta: { + title: "test-directive", + hide: true, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3, + type: 2 + }, + children: null + }, + // { + // id: "08", + // parentId: "0", + // path: "/personal", + // name: "personal", + // redirect: "/personal/userinfo", + // meta: { + // title: "personal", + // hide: false, + // disable: false, + // keepAlive: true, + // affix: false, + // link: "", + // iframe: false, + // isFull: false, + // roles: ["admin"], + // svgIcon: "user", + // sort: 8, + // type: 1 + // }, + // children: null + // }, + // { + // id: "0801", + // parentId: "08", + // path: "/personal/userinfo", + // name: "userinfo", + // component: "personal/userinfo/userinfo", + // meta: { + // title: "userinfo", + // hide: false, + // disable: false, + // keepAlive: true, + // affix: false, + // link: "", + // iframe: false, + // isFull: false, + // roles: ["admin"], + // icon: "icon-menu", + // sort: 1, + // type: 2 + // }, + // children: null + // }, + // { + // id: "0802", + // parentId: "08", + // path: "/personal/user-settings", + // name: "user-settings", + // component: "personal/user-settings/user-settings", + // meta: { + // title: "user-settings", + // hide: false, + // disable: false, + // keepAlive: true, + // affix: false, + // link: "", + // iframe: false, + // isFull: false, + // roles: ["admin"], + // icon: "icon-menu", + // sort: 2, + // type: 2 + // }, + // children: null + // }, + { + id: "09", + parentId: "0", + path: "/functions", + name: "functions", + redirect: "/functions/routing-operation", + meta: { + title: "functions", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "functions", + sort: 9, + type: 1 + }, + children: null + }, + { + id: "0901", + parentId: "09", + path: "/functions/routing-operation", + name: "routing-operation", + component: "functions/routing-operation/index", + meta: { + title: "routing-operation", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "090101", + parentId: "0901", + path: "/functions/routing-operation/common-route", + name: "common-route", + component: "functions/routing-operation/common-route", + meta: { + title: "common-route", + hide: true, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "switch", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "090102", + parentId: "0901", + path: "/functions/routing-operation/dynamic-route/:name/:text", + name: "dynamic-route", + component: "functions/routing-operation/dynamic-route", + meta: { + title: "dynamic-route", + hide: true, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "switch", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "0902", + parentId: "09", + path: "/functions/common-tools", + name: "common-tools", + component: "functions/common-tools/common-tools", + meta: { + title: "common-tools", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "0903", + parentId: "09", + path: "/functions/tree-tools", + name: "tree-tools", + component: "functions/tree-tools/tree-tools", + meta: { + title: "tree-tools", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3, + type: 2 + }, + children: null + }, + { + id: "0904", + parentId: "09", + path: "/functions/file-tools", + name: "file-tools", + component: "functions/file-tools/file-tools", + meta: { + title: "file-tools", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 4, + type: 2 + }, + children: null + }, + { + id: "0905", + parentId: "09", + path: "/functions/verify-tools", + name: "verify-tools", + component: "functions/verify-tools/verify-tools", + meta: { + title: "verify-tools", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 5, + type: 2 + }, + children: null + }, + { + id: "10", + parentId: "0", + path: "/system", + name: "system", + redirect: "/system/account", + meta: { + title: "system", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin", "common"], + svgIcon: "set", + sort: 10, + type: 1 + }, + children: null + }, + { + id: "1001", + parentId: "10", + path: "/system/account", + name: "account", + component: "system/account/account", + meta: { + title: "account", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "1002", + parentId: "10", + path: "/system/role", + name: "role", + component: "system/role/role", + meta: { + title: "role", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "1003", + parentId: "10", + path: "/system/menu", + name: "menu", + component: "system/menu/menu", + meta: { + title: "menu", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3, + type: 2 + }, + children: null + }, + { + id: "1004", + parentId: "10", + path: "/system/division", + name: "division", + component: "system/division/division", + meta: { + title: "division", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 4, + type: 2 + }, + children: null + }, + { + id: "1005", + parentId: "10", + path: "/system/dictionary", + name: "dictionary", + component: "system/dictionary/dictionary", + meta: { + title: "dictionary", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 5, + type: 2 + }, + children: null + }, + { + id: "1006", + parentId: "10", + path: "/system/log", + name: "log", + component: "system/log/log", + meta: { + title: "log", + hide: true, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 6, + type: 2 + }, + children: null + }, + { + id: "1007", + parentId: "10", + path: "/system/userinfo", + name: "userinfo", + component: "system/userinfo/userinfo", + meta: { + title: "userinfo", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin", "common"], + icon: "icon-menu", + sort: 7, + type: 2 + }, + children: null + }, + { + id: "11", + parentId: "0", + path: "/disable-menu", + name: "disable-menu", + component: "disable-menu/disable-menu", + meta: { + title: "disable-menu", + hide: false, + disable: true, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "switch", + sort: 11, + type: 2 + }, + children: null + }, + { + id: "12", + parentId: "0", + path: "/hide-menu", + name: "hide-menu", + component: "hide-menu/hide-menu", + meta: { + title: "hide-menu", + hide: true, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "switch", + sort: 12, + type: 2 + }, + children: null + }, + { + id: "13", + parentId: "0", + path: "/permission", + name: "permission", + redirect: "/permission/btn-perm", + meta: { + title: "permission", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin", "common"], + svgIcon: "defend", + sort: 13, + type: 1 + }, + children: null + }, + { + id: "1301", + parentId: "13", + path: "/permission/btn-perm", + name: "btn-perm", + component: "permission/btn-perm/btn-perm", + meta: { + title: "btn-perm", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin", "common"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "1302", + parentId: "13", + path: "/permission/admin-page", + name: "admin-page", + component: "permission/admin-page/admin-page", + meta: { + title: "admin-page", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "1303", + parentId: "13", + path: "/permission/common-page", + name: "common-page", + component: "permission/common-page/common-page", + meta: { + title: "common-page", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["common"], + icon: "icon-menu", + sort: 3, + type: 2 + }, + children: null + }, + { + id: "14", + parentId: "0", + path: "/link", + name: "link", + redirect: "/link/internal", + meta: { + title: "link", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "link", + sort: 14, + type: 1 + }, + children: null + }, + { + id: "1401", + parentId: "14", + path: "/link/internal", + name: "internal", + redirect: "/link/internal/uigradients", + meta: { + title: "internal", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 1 + }, + children: null + }, + { + id: "140101", + parentId: "1401", + path: "/link/internal/uigradients", + name: "uigradients", + component: "link/internal/internal", + meta: { + title: "uigradients", + hide: false, + keepAlive: true, + disable: false, + affix: false, + link: "https://uigradients.com/#HoneyDew", // 链接 + iframe: true, // 区分是否内链 true内链 false外链 + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "140102", + parentId: "1401", + path: "/link/internal/color-taking-tool", + name: "color-taking-tool", + component: "link/internal/internal", + meta: { + title: "color-taking-tool", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "https://photokit.com/colors/eyedropper/?lang=zh", // 链接 + iframe: true, // 区分是否内链 true内链 false外链 + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "140103", + parentId: "1401", + path: "/link/internal/grid-generator", + name: "grid-generator", + component: "link/internal/internal", + meta: { + title: "grid-generator", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "https://cssgrid-generator.netlify.app/", // 链接 + iframe: true, // 区分是否内链 true内链 false外链 + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3, + type: 2 + }, + children: null + }, + { + id: "140104", + parentId: "1401", + path: "/link/internal/gaodemap", + name: "gaodemap", + component: "link/internal/internal", + meta: { + title: "amap", + hide: false, + keepAlive: true, + disable: false, + affix: false, + link: "http://115.190.79.132:82/", // 链接 + iframe: true, // 区分是否内链 true内链 false外链 + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 4, + type: 2 + }, + children: null + }, + { + id: "1402", + parentId: "14", + path: "/link/external", + name: "external", + redirect: "/link/external/link-vue", + meta: { + title: "external", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 1 + }, + children: null + }, + { + id: "140201", + parentId: "1402", + path: "/link/external/SnowAdmin-Docs", + name: "SnowAdmin-Docs", + component: "link/external/external", + meta: { + title: "SnowAdmin-Docs", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "http://115.190.79.132:81/", // 链接 + iframe: false, // 区分是否内链 true内链 false外链 + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 5, + type: 2 + }, + children: null + }, + { + id: "140202", + parentId: "1402", + path: "/link/external/vue", + name: "vue", + component: "link/external/external", + meta: { + title: "vue", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "https://cn.vuejs.org/", // 链接 + iframe: false, // 区分是否内链 true内链 false外链 + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "140203", + parentId: "1402", + path: "/link/external/vite", + name: "vite", + component: "link/external/external", + meta: { + title: "vite", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "https://www.vitejs.net/", // 链接 + iframe: false, // 区分是否内链 true内链 false外链 + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "140204", + parentId: "1402", + path: "/link/external/github", + name: "github", + component: "link/external/external", + meta: { + title: "github", + hide: false, + disable: true, + keepAlive: true, + affix: false, + link: "https://github.com/WangFan-io/SnowAdmin", // 链接 + iframe: false, // 区分是否内链 true内链 false外链 + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3, + type: 2 + }, + children: null + }, + { + id: "140205", + parentId: "1402", + path: "/link/external/juejin", + name: "juejin", + component: "link/external/external", + meta: { + title: "juejin", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "https://juejin.cn/user/1728883023940600", // 链接 + iframe: false, // 区分是否内链 true内链 false外链 + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 4, + type: 2 + }, + children: null + }, + { + id: "15", + parentId: "0", + path: "/monitor", + name: "monitor", + redirect: "/monitor/onlineuser", + meta: { + title: "system-monitor", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "financial-statement", + sort: 15, + type: 1 + }, + children: null + }, + { + id: "1501", + parentId: "15", + path: "/monitor/onlineuser", + name: "onlineuser", + component: "monitor/onlineuser/index", + meta: { + title: "onlineuser", + hide: false, + keepAlive: true, + disable: false, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 1, + type: 2 + }, + children: null + }, + { + id: "1502", + parentId: "15", + path: "/monitor/crontab", + name: "crontab", + component: "monitor/crontab/index", + meta: { + title: "crontab", + hide: false, + keepAlive: true, + disable: false, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 2, + type: 2 + }, + children: null + }, + { + id: "1503", + parentId: "15", + path: "/monitor/crontab-logs", + name: "crontab-logs", + component: "monitor/crontab-logs/index", + meta: { + title: "crontab-logs", + hide: false, + keepAlive: true, + disable: false, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3, + type: 2 + }, + children: null + }, + { + id: "16", + parentId: "0", + path: "/SnowAdmin-Thin", + name: "thin-preview", + component: "link/external/external", + meta: { + title: "thin-preview", + hide: false, + disable: false, + keepAlive: false, + affix: true, + link: "http://115.190.79.132:83/#/login", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "propaganda", + icon: "", + sort: 16, + type: 2 + }, + children: null + }, + { + id: "17", + parentId: "0", + path: "/i18n", + name: "i18n", + component: "i18n/show/index", + meta: { + title: "i18n", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin"], + svgIcon: "earth", + sort: 17, + type: 2 + }, + children: null + }, + { + id: "18", + parentId: "0", + path: "/about", + name: "about", + component: "about/about", + meta: { + title: "about", + hide: false, + disable: false, + keepAlive: true, + affix: false, + link: "", + iframe: false, + isFull: false, + roles: ["admin", "common"], + svgIcon: "about", + sort: 18, + type: 2 + }, + children: null + } +]; + +// 权限数据 +export const permissionData = [ + { + id: "130101", + parentId: "1301", + meta: { + title: "新增按钮", + hide: false, + disable: false, + roles: ["admin"], + permission: "sys:btn:add", + sort: 1, + type: 3 + } + }, + { + id: "130102", + parentId: "1301", + meta: { + title: "编辑按钮", + hide: false, + disable: false, + roles: ["admin"], + permission: "sys:btn:edit", + sort: 2, + type: 3 + } + }, + { + id: "130103", + parentId: "1301", + meta: { + title: "删除按钮", + hide: false, + disable: false, + roles: ["admin"], + permission: "sys:btn:delete", + sort: 3, + type: 3 + } + }, + { + id: "130201", + parentId: "1301", + meta: { + title: "新增按钮-2", + hide: false, + disable: false, + roles: ["admin", "common"], + permission: "common:btn:add", + sort: 1, + type: 3 + } + }, + { + id: "130202", + parentId: "1301", + meta: { + title: "编辑按钮-2", + hide: false, + disable: false, + roles: ["admin", "common"], + permission: "common:btn:edit", + sort: 2, + type: 3 + } + }, + { + id: "130203", + parentId: "1301", + meta: { + title: "删除按钮-2", + hide: false, + disable: false, + roles: ["admin", "common"], + permission: "common:btn:delete", + sort: 3, + type: 3 + } + } +]; diff --git a/web/src/mock/_utils.ts b/web/src/mock/_utils.ts index 3ef2804..f9a56ed 100644 --- a/web/src/mock/_utils.ts +++ b/web/src/mock/_utils.ts @@ -1,187 +1,187 @@ -import Mock from "mockjs"; - -/** 返回成功数据 */ -export const resultSuccess = (data: unknown) => { - return Mock.mock({ - code: 200, - data, - message: "请求成功", - success: true - }); -}; - -/** 返回失败数据 */ -export const resultError = (data: unknown, message: string, code = 500) => { - return Mock.mock({ - code, - data, - message, - success: false - }); -}; - -/** - * 路由树递归排序 - * 1、先给当前层排序 - * 2、若当前层有children则递归排序 - * @param {array} tree 根据角色权限过滤后的路由树 - * @returns 返回排序之后的树 - */ -export const treeSort = (tree: Menu.MenuOptions[]) => { - if (!tree || tree.length == 0) return []; - tree.sort((a: Menu.MenuOptions, b: Menu.MenuOptions) => { - // a和b都是undefined则相等 - if (a.meta.sort != 0 && !a.meta.sort && b.meta.sort != 0 && !b.meta.sort) { - return 0; - } - // a是undefined则a被排在b之后 - if (a.meta.sort != 0 && !a.meta.sort) return 1; - // b是undefined则b被排在a之后 - if (b.meta.sort != 0 && !b.meta.sort) return -1; - return a.meta.sort - b.meta.sort; - }); - - // 深层递归 - return tree.map((item: any) => { - if (item?.children?.length > 0) { - item.children = treeSort(item.children); - } - return item; - }); -}; - -/** - * 过滤路由树,返回有权限的树 - * 1、根据角色权限过滤原始路由树 - * 2、过滤禁用的菜单,该菜单是不可访问的,直接去掉 - * @param {array} tree 根据角色权限过滤原始路由树 - * @returns 返回有权限的树 - */ -export const filterByDisable = (tree: any, userRoles: Array) => { - return tree.filter((item: any) => { - // 过滤角色权限 - if (item?.meta?.roles) { - if (!roleBase(item.meta.roles, userRoles)) return false; - } - // 过滤是否禁用 - if (item?.meta?.disable) return false; - return true; - }); -}; - -/** - * 校验该角色是否有路由权限 - * @param {array} roles 路由的角色权限 - * @returns 是否有权限 true是 false否 - */ -export const roleBase = (roles: Array, userRoles: Array) => { - // 如果是admin则直接放行 - if (userRoles.includes("admin")) return true; - // 否则判断权限 - return userRoles.some((item: string) => roles.includes(item)); -}; - -/** - * 深拷贝 - * @param { string } data 需要深拷贝的数据 - * @returns 深拷贝的数据 - */ -export function deepClone(data: any) { - let stack = []; - let cloned; - if (Array.isArray(data)) { - cloned = []; - } else if (typeof data === "object" && data !== null) { - cloned = {}; - } else { - return data; - } - stack.push({ - original: data, - copy: cloned - }); - while (stack.length > 0) { - let current: any = stack.pop(); - let original = current.original; - let copy = current.copy; - - for (let key in original) { - if (original.hasOwnProperty(key)) { - let value = original[key]; - - if (typeof value === "object" && value !== null) { - copy[key] = Array.isArray(value) ? [] : {}; - - stack.push({ - original: value, - copy: copy[key] - }); - } else { - copy[key] = value; - } - } - } - } - return cloned; -} - -/** - * 将扁平路由组装成树形结构 - * @param {array} nodes 扁平数组 - * @returns 树形结构 - */ -export const buildTreeOptimized = (nodes: Menu.MenuOptions[]) => { - const nodeMap = new Map(); // 哈希表存储所有节点 - const roots = []; // 存储顶层节点 - const duplicates = new Set(); // 检测重复ID - - // 第一次遍历: 注册所有节点 & 检测重复 - for (const node of nodes) { - const id = node.id; - - // 循环引用检测 - if (node.id === node.parentId) { - throw new Error(`循环引用: ${node.id} -> ${node.parentId}`); - } - - // 重复ID检测 - if (nodeMap.has(id)) { - duplicates.add(id); - continue; - } - - // 初始化子节点为null,这里children必须得是null,因为arco.design的展开列表组件根据数组判断是否显示展开按钮,哪怕是空数组也会显示展开按钮 - node.children = null; - nodeMap.set(id, node); - } - - // 输出重复警告 - if (duplicates.size > 0) { - console.warn(`检测到重复ID: ${Array.from(duplicates).join(", ")}`); - } - - // 第二次遍历: 构建树结构 - for (const node of nodes) { - const { parentId } = node; - - // 跳过已处理的重复节点 - if (duplicates.has(node.id)) continue; - - if (parentId === "0") { - roots.push(node); // 顶层节点 - } else if (parentId) { - const parent = nodeMap.get(parentId); - if (parent) { - // 初始化父节点的children为数组(若为null) - if (parent.children === null) { - parent.children = []; - } - parent.children.push(node); - } - } else { - console.warn(`独立节点 ${node.id}: parentId为空`); - } - } - - return roots; -}; +import Mock from "mockjs"; + +/** 返回成功数据 */ +export const resultSuccess = (data: unknown) => { + return Mock.mock({ + code: 200, + data, + message: "请求成功", + success: true + }); +}; + +/** 返回失败数据 */ +export const resultError = (data: unknown, message: string, code = 500) => { + return Mock.mock({ + code, + data, + message, + success: false + }); +}; + +/** + * 路由树递归排序 + * 1、先给当前层排序 + * 2、若当前层有children则递归排序 + * @param {array} tree 根据角色权限过滤后的路由树 + * @returns 返回排序之后的树 + */ +export const treeSort = (tree: Menu.MenuOptions[]) => { + if (!tree || tree.length == 0) return []; + tree.sort((a: Menu.MenuOptions, b: Menu.MenuOptions) => { + // a和b都是undefined则相等 + if (a.meta.sort != 0 && !a.meta.sort && b.meta.sort != 0 && !b.meta.sort) { + return 0; + } + // a是undefined则a被排在b之后 + if (a.meta.sort != 0 && !a.meta.sort) return 1; + // b是undefined则b被排在a之后 + if (b.meta.sort != 0 && !b.meta.sort) return -1; + return a.meta.sort - b.meta.sort; + }); + + // 深层递归 + return tree.map((item: any) => { + if (item?.children?.length > 0) { + item.children = treeSort(item.children); + } + return item; + }); +}; + +/** + * 过滤路由树,返回有权限的树 + * 1、根据角色权限过滤原始路由树 + * 2、过滤禁用的菜单,该菜单是不可访问的,直接去掉 + * @param {array} tree 根据角色权限过滤原始路由树 + * @returns 返回有权限的树 + */ +export const filterByDisable = (tree: any, userRoles: Array) => { + return tree.filter((item: any) => { + // 过滤角色权限 + if (item?.meta?.roles) { + if (!roleBase(item.meta.roles, userRoles)) return false; + } + // 过滤是否禁用 + if (item?.meta?.disable) return false; + return true; + }); +}; + +/** + * 校验该角色是否有路由权限 + * @param {array} roles 路由的角色权限 + * @returns 是否有权限 true是 false否 + */ +export const roleBase = (roles: Array, userRoles: Array) => { + // 如果是admin则直接放行 + if (userRoles.includes("admin")) return true; + // 否则判断权限 + return userRoles.some((item: string) => roles.includes(item)); +}; + +/** + * 深拷贝 + * @param { string } data 需要深拷贝的数据 + * @returns 深拷贝的数据 + */ +export function deepClone(data: any) { + let stack = []; + let cloned; + if (Array.isArray(data)) { + cloned = []; + } else if (typeof data === "object" && data !== null) { + cloned = {}; + } else { + return data; + } + stack.push({ + original: data, + copy: cloned + }); + while (stack.length > 0) { + let current: any = stack.pop(); + let original = current.original; + let copy = current.copy; + + for (let key in original) { + if (original.hasOwnProperty(key)) { + let value = original[key]; + + if (typeof value === "object" && value !== null) { + copy[key] = Array.isArray(value) ? [] : {}; + + stack.push({ + original: value, + copy: copy[key] + }); + } else { + copy[key] = value; + } + } + } + } + return cloned; +} + +/** + * 将扁平路由组装成树形结构 + * @param {array} nodes 扁平数组 + * @returns 树形结构 + */ +export const buildTreeOptimized = (nodes: Menu.MenuOptions[]) => { + const nodeMap = new Map(); // 哈希表存储所有节点 + const roots = []; // 存储顶层节点 + const duplicates = new Set(); // 检测重复ID + + // 第一次遍历: 注册所有节点 & 检测重复 + for (const node of nodes) { + const id = node.id; + + // 循环引用检测 + if (node.id === node.parentId) { + throw new Error(`循环引用: ${node.id} -> ${node.parentId}`); + } + + // 重复ID检测 + if (nodeMap.has(id)) { + duplicates.add(id); + continue; + } + + // 初始化子节点为null,这里children必须得是null,因为arco.design的展开列表组件根据数组判断是否显示展开按钮,哪怕是空数组也会显示展开按钮 + node.children = null; + nodeMap.set(id, node); + } + + // 输出重复警告 + if (duplicates.size > 0) { + console.warn(`检测到重复ID: ${Array.from(duplicates).join(", ")}`); + } + + // 第二次遍历: 构建树结构 + for (const node of nodes) { + const { parentId } = node; + + // 跳过已处理的重复节点 + if (duplicates.has(node.id)) continue; + + if (parentId === "0") { + roots.push(node); // 顶层节点 + } else if (parentId) { + const parent = nodeMap.get(parentId); + if (parent) { + // 初始化父节点的children为数组(若为null) + if (parent.children === null) { + parent.children = []; + } + parent.children.push(node); + } + } else { + console.warn(`独立节点 ${node.id}: parentId为空`); + } + } + + return roots; +}; diff --git a/web/src/mock/file/index.ts b/web/src/mock/file/index.ts index 32bf752..3856b74 100644 --- a/web/src/mock/file/index.ts +++ b/web/src/mock/file/index.ts @@ -1,194 +1,194 @@ -import type { MockMethod } from "vite-plugin-mock"; -import { resultSuccess } from "../_utils"; - -export default [ - { - url: "/mock/document-library/tree", - method: "get", - timeout: 500, - response: () => { - let list = [ - { - title: "总公司", - key: "0-0", - children: [ - { - title: "行政部门", - key: "0-0-0", - children: [ - { - title: "人力资源部", - key: "0-0-0-0", - children: [{ title: "员工出差申请表", key: "0-0-0-0-0" }] - }, - { - title: "财务部", - key: "0-0-0-1", - children: [{ title: "行政费用预算分析", key: "0-0-0-0-1" }] - }, - { - title: "法务部", - key: "0-0-0-2", - children: [{ title: "公司章程", key: "0-0-0-0-2" }] - }, - { title: "行政工作计划", key: "0-0-0-3" }, - - { title: "会议室预订统计", key: "0-0-0-4" }, - { title: "月度工作总结", key: "0-0-0-5" } - ] - }, - { - title: "业务部门", - key: "0-0-1", - children: [ - { title: "客户反馈集锦", key: "0-0-1-0" }, - { title: "市场分析报告-季度", key: "0-0-1-1" } - ] - }, - { - title: "技术部门", - key: "0-0-2", - children: [ - { title: "代码审查记录", key: "0-0-2-0" }, - { title: "数据库优化方案", key: "0-0-2-1" }, - { title: "技术支持工单", key: "0-0-2-2" }, - { title: "安全漏洞扫描报告", key: "0-0-2-3" }, - { title: "系统性能调优总结", key: "0-0-2-4" }, - { title: "软件版本发布计划", key: "0-0-2-5" }, - { title: "技术培训材料", key: "0-0-2-6" }, - { title: "技术文档更新计划", key: "0-0-2-7" } - ] - }, - { - title: "后勤部门", - key: "0-0-3", - children: [ - { title: "设施维护报告", key: "0-0-3-0" }, - { title: "物流运输安排", key: "0-0-3-1" }, - { title: "仓库库存清单", key: "0-0-3-2" }, - { title: "办公室布局设计", key: "0-0-3-3" }, - { title: "设备采购申请表", key: "0-0-3-4" }, - { title: "食品安全检查记录", key: "0-0-3-5" } - ] - } - ] - } - ]; - return resultSuccess(list); - } - }, - { - url: "/mock/document-library/table", - method: "get", - timeout: 500, - response: () => { - let list = [ - { - key: "1", - source: "bilibili", - sourceSvg: "bilibili", - sourceType: "分享", - flow: "5015", - percent: "75", - status: 1, - createTime: "2024-05-27 09:00:00" - }, - { - key: "2", - source: "微信", - sourceSvg: "wechat", - sourceType: "分享", - flow: "3217", - percent: "60", - status: 0, - createTime: "2024-05-26 15:30:00" - }, - { - key: "3", - source: "QQ音乐", - sourceSvg: "QQ音乐", - sourceType: "搜索", - flow: "1343", - percent: "55", - status: 1, - createTime: "2024-05-25 12:45:00" - }, - { - key: "4", - source: "百度", - sourceSvg: "百度", - sourceType: "搜索", - flow: "1235", - percent: "20", - status: 0, - createTime: "2024-05-24 11:20:00" - }, - { - key: "5", - source: "优酷", - sourceSvg: "优酷", - sourceType: "首页推荐", - flow: "3456", - percent: "20", - status: 1, - createTime: "2024-05-23 14:10:00" - }, - { - key: "6", - source: "网易云音乐", - sourceSvg: "网易云音乐", - sourceType: "每日一推", - flow: "5873", - percent: "30", - status: 0, - createTime: "2024-05-22 10:05:00" - }, - { - key: "7", - source: "抖音", - sourceSvg: "抖音", - sourceType: "自然", - flow: "5465", - percent: "86", - status: 1, - createTime: "2024-05-21 08:45:00" - }, - { - key: "8", - source: "西瓜视频", - sourceSvg: "西瓜视频", - sourceType: "搜索", - flow: "4642", - percent: "45", - status: 0, - createTime: "2024-05-20 16:30:00" - }, - { - key: "9", - source: "微博", - sourceSvg: "微博", - sourceType: "搜索", - flow: "2375", - percent: "60", - status: 1, - createTime: "2024-05-19 09:20:00" - }, - { - key: "10", - source: "豆瓣", - sourceSvg: "豆瓣", - sourceType: "搜索", - flow: "2465", - percent: "40", - status: 0, - createTime: "2024-05-18 13:55:00" - } - ]; - let data = { - list, - total: list.length - }; - return resultSuccess(data); - } - } -] as MockMethod[]; +import type { MockMethod } from "vite-plugin-mock"; +import { resultSuccess } from "../_utils"; + +export default [ + { + url: "/mock/document-library/tree", + method: "get", + timeout: 500, + response: () => { + let list = [ + { + title: "总公司", + key: "0-0", + children: [ + { + title: "行政部门", + key: "0-0-0", + children: [ + { + title: "人力资源部", + key: "0-0-0-0", + children: [{ title: "员工出差申请表", key: "0-0-0-0-0" }] + }, + { + title: "财务部", + key: "0-0-0-1", + children: [{ title: "行政费用预算分析", key: "0-0-0-0-1" }] + }, + { + title: "法务部", + key: "0-0-0-2", + children: [{ title: "公司章程", key: "0-0-0-0-2" }] + }, + { title: "行政工作计划", key: "0-0-0-3" }, + + { title: "会议室预订统计", key: "0-0-0-4" }, + { title: "月度工作总结", key: "0-0-0-5" } + ] + }, + { + title: "业务部门", + key: "0-0-1", + children: [ + { title: "客户反馈集锦", key: "0-0-1-0" }, + { title: "市场分析报告-季度", key: "0-0-1-1" } + ] + }, + { + title: "技术部门", + key: "0-0-2", + children: [ + { title: "代码审查记录", key: "0-0-2-0" }, + { title: "数据库优化方案", key: "0-0-2-1" }, + { title: "技术支持工单", key: "0-0-2-2" }, + { title: "安全漏洞扫描报告", key: "0-0-2-3" }, + { title: "系统性能调优总结", key: "0-0-2-4" }, + { title: "软件版本发布计划", key: "0-0-2-5" }, + { title: "技术培训材料", key: "0-0-2-6" }, + { title: "技术文档更新计划", key: "0-0-2-7" } + ] + }, + { + title: "后勤部门", + key: "0-0-3", + children: [ + { title: "设施维护报告", key: "0-0-3-0" }, + { title: "物流运输安排", key: "0-0-3-1" }, + { title: "仓库库存清单", key: "0-0-3-2" }, + { title: "办公室布局设计", key: "0-0-3-3" }, + { title: "设备采购申请表", key: "0-0-3-4" }, + { title: "食品安全检查记录", key: "0-0-3-5" } + ] + } + ] + } + ]; + return resultSuccess(list); + } + }, + { + url: "/mock/document-library/table", + method: "get", + timeout: 500, + response: () => { + let list = [ + { + key: "1", + source: "bilibili", + sourceSvg: "bilibili", + sourceType: "分享", + flow: "5015", + percent: "75", + status: 1, + createTime: "2024-05-27 09:00:00" + }, + { + key: "2", + source: "微信", + sourceSvg: "wechat", + sourceType: "分享", + flow: "3217", + percent: "60", + status: 0, + createTime: "2024-05-26 15:30:00" + }, + { + key: "3", + source: "QQ音乐", + sourceSvg: "QQ音乐", + sourceType: "搜索", + flow: "1343", + percent: "55", + status: 1, + createTime: "2024-05-25 12:45:00" + }, + { + key: "4", + source: "百度", + sourceSvg: "百度", + sourceType: "搜索", + flow: "1235", + percent: "20", + status: 0, + createTime: "2024-05-24 11:20:00" + }, + { + key: "5", + source: "优酷", + sourceSvg: "优酷", + sourceType: "首页推荐", + flow: "3456", + percent: "20", + status: 1, + createTime: "2024-05-23 14:10:00" + }, + { + key: "6", + source: "网易云音乐", + sourceSvg: "网易云音乐", + sourceType: "每日一推", + flow: "5873", + percent: "30", + status: 0, + createTime: "2024-05-22 10:05:00" + }, + { + key: "7", + source: "抖音", + sourceSvg: "抖音", + sourceType: "自然", + flow: "5465", + percent: "86", + status: 1, + createTime: "2024-05-21 08:45:00" + }, + { + key: "8", + source: "西瓜视频", + sourceSvg: "西瓜视频", + sourceType: "搜索", + flow: "4642", + percent: "45", + status: 0, + createTime: "2024-05-20 16:30:00" + }, + { + key: "9", + source: "微博", + sourceSvg: "微博", + sourceType: "搜索", + flow: "2375", + percent: "60", + status: 1, + createTime: "2024-05-19 09:20:00" + }, + { + key: "10", + source: "豆瓣", + sourceSvg: "豆瓣", + sourceType: "搜索", + flow: "2465", + percent: "40", + status: 0, + createTime: "2024-05-18 13:55:00" + } + ]; + let data = { + list, + total: list.length + }; + return resultSuccess(data); + } + } +] as MockMethod[]; diff --git a/web/src/mock/index.ts b/web/src/mock/index.ts index ae7c550..fee62c8 100644 --- a/web/src/mock/index.ts +++ b/web/src/mock/index.ts @@ -1,12 +1,12 @@ -import { createProdMockServer } from "vite-plugin-mock/es/createProdMockServer"; - -import testModule from "./test/index"; -import userModule from "./user/index"; -import systemModule from "./system/index"; -import fileModule from "./file/index"; -import tableModule from "./table/index"; -import monitorModule from "./monitor/index"; - -export function setupProdMockServer() { - createProdMockServer([...testModule, ...userModule, ...systemModule, ...fileModule, ...tableModule, ...monitorModule]); -} +import { createProdMockServer } from "vite-plugin-mock/es/createProdMockServer"; + +import testModule from "./test/index"; +import userModule from "./user/index"; +import systemModule from "./system/index"; +import fileModule from "./file/index"; +import tableModule from "./table/index"; +import monitorModule from "./monitor/index"; + +export function setupProdMockServer() { + createProdMockServer([...testModule, ...userModule, ...systemModule, ...fileModule, ...tableModule, ...monitorModule]); +} diff --git a/web/src/mock/system/index.ts b/web/src/mock/system/index.ts index d9f2b59..2a3b714 100644 --- a/web/src/mock/system/index.ts +++ b/web/src/mock/system/index.ts @@ -1,4 +1,4 @@ -import menu from "./menu"; -import system from "./system"; - -export default [...menu, ...system]; +import menu from "./menu"; +import system from "./system"; + +export default [...menu, ...system]; diff --git a/web/src/mock/system/menu.ts b/web/src/mock/system/menu.ts index 0fc8a80..df25166 100644 --- a/web/src/mock/system/menu.ts +++ b/web/src/mock/system/menu.ts @@ -1,74 +1,74 @@ -import type { MockMethod } from "vite-plugin-mock"; -import { deepClone, filterByDisable, buildTreeOptimized, treeSort, resultSuccess } from "../_utils"; -import { systemMenu, permissionData } from "../_data/system_menu"; - -/** - * 初始化 - * 后端接口需要做的事情: - * 1、根据token判断角色 - * 2、过滤扁平路由,根据角色过滤权限和非禁用的节点 - * 3、将扁平路由转换为树结构 - * 4、路由树排序 - * 5、返回路由树 - * - * 前端调用接口拿到路由数据后: - * 1、将模块设置为真实模块 - * 2、存储路由树,用于生成菜单 - * 3、根据树生成一维路由数组 - * 4、动态添加路由 - * 5、缓存一维路由 - */ - -/** - * post请求body,get请求query - * /mock/menu/getRouters 获取路由数据 - * /mock/menu/getMenuList 获取菜单列表数据-菜单管理 - * /mock/menu/getUserPermission 根据角色获取权限数据 - * /mock/menu/getPermission 获取权限数据 - */ -export default [ - { - url: "/mock/menu/getRouters", - method: "get", - timeout: 300, - response: ({ headers }: any) => { - let token = headers.authorization; - // 根据token或登录账号判断是什么角色,这里模拟两个角色,admin、common - let userRoles = token === "Admin-Token" ? ["admin"] : ["common"]; - const originMenu: any = deepClone(systemMenu); - // 1. 过滤扁平路由,根据角色返回有权限且非禁用的节点 - const survivalTree = filterByDisable(originMenu, userRoles); - // 2. 将扁平路由转换为树结构 - // 2. 给路由树排序 - // 3. 返回路由树 - return resultSuccess(treeSort(buildTreeOptimized(survivalTree))); - } - }, - { - url: "/mock/menu/getMenuList", - method: "get", - timeout: 300, - response: () => { - // 菜单管理这里需要查看到所有菜单,无需判断角色权限、禁用菜单 - // 将扁平路由和权限菜单合并 - const originMenu: any = [...deepClone(systemMenu), ...deepClone(permissionData)]; - // 1. 将扁平路由转换为树结构 - // 2. 给路由树排序 - // 3. 返回路由树 - return resultSuccess(treeSort(buildTreeOptimized(originMenu))); - } - }, - { - url: "/mock/menu/getUserPermission", - method: "get", - timeout: 300, - response: ({ query }: any) => { - let { role } = query; - // 将扁平路由和权限菜单合并 - const originMenu: any = [...deepClone(systemMenu), ...deepClone(permissionData)]; - // 根据角色过滤id - let idList = originMenu.filter((item: any) => item.meta.roles.includes(role)).map((item: any) => item.id); - return resultSuccess(idList); - } - } -] as MockMethod[]; +import type { MockMethod } from "vite-plugin-mock"; +import { deepClone, filterByDisable, buildTreeOptimized, treeSort, resultSuccess } from "../_utils"; +import { systemMenu, permissionData } from "../_data/system_menu"; + +/** + * 初始化 + * 后端接口需要做的事情: + * 1、根据token判断角色 + * 2、过滤扁平路由,根据角色过滤权限和非禁用的节点 + * 3、将扁平路由转换为树结构 + * 4、路由树排序 + * 5、返回路由树 + * + * 前端调用接口拿到路由数据后: + * 1、将模块设置为真实模块 + * 2、存储路由树,用于生成菜单 + * 3、根据树生成一维路由数组 + * 4、动态添加路由 + * 5、缓存一维路由 + */ + +/** + * post请求body,get请求query + * /mock/menu/getRouters 获取路由数据 + * /mock/menu/getMenuList 获取菜单列表数据-菜单管理 + * /mock/menu/getUserPermission 根据角色获取权限数据 + * /mock/menu/getPermission 获取权限数据 + */ +export default [ + { + url: "/mock/menu/getRouters", + method: "get", + timeout: 300, + response: ({ headers }: any) => { + let token = headers.authorization; + // 根据token或登录账号判断是什么角色,这里模拟两个角色,admin、common + let userRoles = token === "Admin-Token" ? ["admin"] : ["common"]; + const originMenu: any = deepClone(systemMenu); + // 1. 过滤扁平路由,根据角色返回有权限且非禁用的节点 + const survivalTree = filterByDisable(originMenu, userRoles); + // 2. 将扁平路由转换为树结构 + // 2. 给路由树排序 + // 3. 返回路由树 + return resultSuccess(treeSort(buildTreeOptimized(survivalTree))); + } + }, + { + url: "/mock/menu/getMenuList", + method: "get", + timeout: 300, + response: () => { + // 菜单管理这里需要查看到所有菜单,无需判断角色权限、禁用菜单 + // 将扁平路由和权限菜单合并 + const originMenu: any = [...deepClone(systemMenu), ...deepClone(permissionData)]; + // 1. 将扁平路由转换为树结构 + // 2. 给路由树排序 + // 3. 返回路由树 + return resultSuccess(treeSort(buildTreeOptimized(originMenu))); + } + }, + { + url: "/mock/menu/getUserPermission", + method: "get", + timeout: 300, + response: ({ query }: any) => { + let { role } = query; + // 将扁平路由和权限菜单合并 + const originMenu: any = [...deepClone(systemMenu), ...deepClone(permissionData)]; + // 根据角色过滤id + let idList = originMenu.filter((item: any) => item.meta.roles.includes(role)).map((item: any) => item.id); + return resultSuccess(idList); + } + } +] as MockMethod[]; diff --git a/web/src/mock/table/index.ts b/web/src/mock/table/index.ts index f81ebad..ecba64b 100644 --- a/web/src/mock/table/index.ts +++ b/web/src/mock/table/index.ts @@ -1,233 +1,233 @@ -import type { MockMethod } from "vite-plugin-mock"; -import { resultSuccess } from "../_utils"; - -export default [ - { - url: "/mock/common-table/list", - method: "get", - timeout: 500, - response: () => { - let list = [ - { - key: "1", - name: "陈思源", - avatar: "陈", - phone: "13812345678", - email: "zhangsan@example.com", - address: "北京市朝阳区", - status: 1, - createTime: "2024-05-27 09:00:00" - }, - { - key: "2", - name: "李婉娴", - avatar: "李", - phone: "13987654321", - email: "lisi@example.com", - address: "上海市浦东新区", - status: 0, - createTime: "2024-05-26 15:30:00" - }, - { - key: "3", - name: "王雨菲", - avatar: "王", - phone: "13666666666", - email: "wangwu@example.com", - address: "广州市天河区", - status: 1, - createTime: "2024-05-25 12:45:00" - }, - { - key: "4", - name: "张晨曦", - avatar: "张", - phone: "13788888888", - email: "zhaoliu@example.com", - address: "深圳市福田区", - status: 0, - createTime: "2024-05-24 11:20:00" - }, - { - key: "5", - name: "赵梦琪", - avatar: "赵", - phone: "13599999999", - email: "qianqi@example.com", - address: "成都市锦江区", - status: 1, - createTime: "2024-05-23 14:10:00" - }, - { - key: "6", - name: "刘昊然", - avatar: "刘", - phone: "13377777777", - email: "sunba@example.com", - address: "杭州市西湖区", - status: 0, - createTime: "2024-05-22 10:05:00" - }, - { - key: "7", - name: "孙梦洁", - avatar: "孙", - phone: "13266666666", - email: "zhoujiu@example.com", - address: "南京市鼓楼区", - status: 1, - createTime: "2024-05-21 08:45:00" - }, - { - key: "8", - name: "黄俊杰", - avatar: "黄", - phone: "13155555555", - email: "wushi@example.com", - address: "重庆市渝中区", - status: 0, - createTime: "2024-05-20 16:30:00" - }, - { - key: "9", - name: "周雨萱", - avatar: "周", - phone: "13044444444", - email: "zhengshiyi@example.com", - address: "武汉市江汉区", - status: 1, - createTime: "2024-05-19 09:20:00" - }, - { - key: "10", - name: "韩雪儿", - avatar: "韩", - phone: "13933333333", - email: "kongshier@example.com", - address: "西安市雁塔区", - status: 0, - createTime: "2024-05-18 13:55:00" - } - ]; - let data = { - list, - total: list.length - }; - return resultSuccess(data); - } - }, - { - url: "/mock/custom-table/list", - method: "get", - timeout: 500, - response: () => { - let list = [ - { - key: "1", - serial: "57", - name: "WEIJEIWGSDG", - content: "图文", - searchType: "阅读量", - contentSize: 3700, - status: 1, - createTime: "2024-05-27 09:00:00" - }, - { - key: "2", - serial: "58", - name: "DHDWEH", - content: "图文", - searchType: "阅读量", - contentSize: 3700, - status: 0, - createTime: "2024-05-26 15:30:00" - }, - { - key: "3", - serial: "59", - name: "SHEHWAE", - content: "视频", - searchType: "播放量", - contentSize: 2500, - status: 1, - createTime: "2024-05-25 12:45:00" - }, - { - key: "4", - serial: "60", - name: "WEHJUK", - content: "视频", - searchType: "播放量", - contentSize: 2500, - status: 0, - createTime: "2024-05-24 11:20:00" - }, - { - key: "5", - serial: "61", - name: "EYTUJDGSD", - content: "音频", - searchType: "播放量", - contentSize: 2500, - status: 1, - createTime: "2024-05-23 14:10:00" - }, - { - key: "6", - serial: "62", - name: "RTIFSDF", - content: "图文", - searchType: "阅读量", - contentSize: 3700, - status: 0, - createTime: "2024-05-22 10:05:00" - }, - { - key: "7", - serial: "63", - name: "OIKSHHFD", - content: "图文", - searchType: "阅读量", - contentSize: 3700, - status: 1, - createTime: "2024-05-21 08:45:00" - }, - { - key: "8", - serial: "64", - name: "QEUHRKO", - content: "视频", - searchType: "播放量", - contentSize: 2500, - status: 0, - createTime: "2024-05-20 16:30:00" - }, - { - key: "9", - serial: "65", - name: "JSGSDRI", - content: "视频", - searchType: "播放量", - contentSize: 2300, - status: 1, - createTime: "2024-05-19 09:20:00" - }, - { - key: "10", - serial: "66", - name: "AOUSTHREGG", - content: "音频", - searchType: "播放量", - contentSize: 2300, - status: 0, - createTime: "2024-05-18 13:55:00" - } - ]; - let data = { - list, - total: list.length - }; - return resultSuccess(data); - } - } -] as MockMethod[]; +import type { MockMethod } from "vite-plugin-mock"; +import { resultSuccess } from "../_utils"; + +export default [ + { + url: "/mock/common-table/list", + method: "get", + timeout: 500, + response: () => { + let list = [ + { + key: "1", + name: "陈思源", + avatar: "陈", + phone: "13812345678", + email: "zhangsan@example.com", + address: "北京市朝阳区", + status: 1, + createTime: "2024-05-27 09:00:00" + }, + { + key: "2", + name: "李婉娴", + avatar: "李", + phone: "13987654321", + email: "lisi@example.com", + address: "上海市浦东新区", + status: 0, + createTime: "2024-05-26 15:30:00" + }, + { + key: "3", + name: "王雨菲", + avatar: "王", + phone: "13666666666", + email: "wangwu@example.com", + address: "广州市天河区", + status: 1, + createTime: "2024-05-25 12:45:00" + }, + { + key: "4", + name: "张晨曦", + avatar: "张", + phone: "13788888888", + email: "zhaoliu@example.com", + address: "深圳市福田区", + status: 0, + createTime: "2024-05-24 11:20:00" + }, + { + key: "5", + name: "赵梦琪", + avatar: "赵", + phone: "13599999999", + email: "qianqi@example.com", + address: "成都市锦江区", + status: 1, + createTime: "2024-05-23 14:10:00" + }, + { + key: "6", + name: "刘昊然", + avatar: "刘", + phone: "13377777777", + email: "sunba@example.com", + address: "杭州市西湖区", + status: 0, + createTime: "2024-05-22 10:05:00" + }, + { + key: "7", + name: "孙梦洁", + avatar: "孙", + phone: "13266666666", + email: "zhoujiu@example.com", + address: "南京市鼓楼区", + status: 1, + createTime: "2024-05-21 08:45:00" + }, + { + key: "8", + name: "黄俊杰", + avatar: "黄", + phone: "13155555555", + email: "wushi@example.com", + address: "重庆市渝中区", + status: 0, + createTime: "2024-05-20 16:30:00" + }, + { + key: "9", + name: "周雨萱", + avatar: "周", + phone: "13044444444", + email: "zhengshiyi@example.com", + address: "武汉市江汉区", + status: 1, + createTime: "2024-05-19 09:20:00" + }, + { + key: "10", + name: "韩雪儿", + avatar: "韩", + phone: "13933333333", + email: "kongshier@example.com", + address: "西安市雁塔区", + status: 0, + createTime: "2024-05-18 13:55:00" + } + ]; + let data = { + list, + total: list.length + }; + return resultSuccess(data); + } + }, + { + url: "/mock/custom-table/list", + method: "get", + timeout: 500, + response: () => { + let list = [ + { + key: "1", + serial: "57", + name: "WEIJEIWGSDG", + content: "图文", + searchType: "阅读量", + contentSize: 3700, + status: 1, + createTime: "2024-05-27 09:00:00" + }, + { + key: "2", + serial: "58", + name: "DHDWEH", + content: "图文", + searchType: "阅读量", + contentSize: 3700, + status: 0, + createTime: "2024-05-26 15:30:00" + }, + { + key: "3", + serial: "59", + name: "SHEHWAE", + content: "视频", + searchType: "播放量", + contentSize: 2500, + status: 1, + createTime: "2024-05-25 12:45:00" + }, + { + key: "4", + serial: "60", + name: "WEHJUK", + content: "视频", + searchType: "播放量", + contentSize: 2500, + status: 0, + createTime: "2024-05-24 11:20:00" + }, + { + key: "5", + serial: "61", + name: "EYTUJDGSD", + content: "音频", + searchType: "播放量", + contentSize: 2500, + status: 1, + createTime: "2024-05-23 14:10:00" + }, + { + key: "6", + serial: "62", + name: "RTIFSDF", + content: "图文", + searchType: "阅读量", + contentSize: 3700, + status: 0, + createTime: "2024-05-22 10:05:00" + }, + { + key: "7", + serial: "63", + name: "OIKSHHFD", + content: "图文", + searchType: "阅读量", + contentSize: 3700, + status: 1, + createTime: "2024-05-21 08:45:00" + }, + { + key: "8", + serial: "64", + name: "QEUHRKO", + content: "视频", + searchType: "播放量", + contentSize: 2500, + status: 0, + createTime: "2024-05-20 16:30:00" + }, + { + key: "9", + serial: "65", + name: "JSGSDRI", + content: "视频", + searchType: "播放量", + contentSize: 2300, + status: 1, + createTime: "2024-05-19 09:20:00" + }, + { + key: "10", + serial: "66", + name: "AOUSTHREGG", + content: "音频", + searchType: "播放量", + contentSize: 2300, + status: 0, + createTime: "2024-05-18 13:55:00" + } + ]; + let data = { + list, + total: list.length + }; + return resultSuccess(data); + } + } +] as MockMethod[]; diff --git a/web/src/mock/test/index.ts b/web/src/mock/test/index.ts index aea34d3..d018da0 100644 --- a/web/src/mock/test/index.ts +++ b/web/src/mock/test/index.ts @@ -1,21 +1,21 @@ -import type { MockMethod } from "vite-plugin-mock"; -import { resultSuccess, resultError } from "../_utils"; - -export default [ - { - url: "/mock/test/success", - method: "get", - timeout: 300, - response: () => { - return resultSuccess("SnowAdmin开源免费,Welcome!"); - } - }, - { - url: "/mock/test/fail", - method: "get", - timeout: 300, - response: () => { - return resultError(null, "模拟mock数据出错", 500); - } - } -] as MockMethod[]; +import type { MockMethod } from "vite-plugin-mock"; +import { resultSuccess, resultError } from "../_utils"; + +export default [ + { + url: "/mock/test/success", + method: "get", + timeout: 300, + response: () => { + return resultSuccess("SnowAdmin开源免费,Welcome!"); + } + }, + { + url: "/mock/test/fail", + method: "get", + timeout: 300, + response: () => { + return resultError(null, "模拟mock数据出错", 500); + } + } +] as MockMethod[]; diff --git a/web/src/mock/user/index.ts b/web/src/mock/user/index.ts index d8bf4dc..c66ce51 100644 --- a/web/src/mock/user/index.ts +++ b/web/src/mock/user/index.ts @@ -1,76 +1,76 @@ -import type { MockMethod } from "vite-plugin-mock"; -import { resultSuccess, resultError, deepClone } from "../_utils"; -import { accountData } from "../_data/system_data"; -import { permissionData } from "../_data/system_menu"; -import { roleData } from "../_data/system_data"; -/** - * post请求body,get请求query - * /mock/login 用户登录 - * /mock/user/getUserInfo 获取用户信息 - */ -export default [ - { - url: "/mock/login", - method: "post", - timeout: 300, - response: ({ body }: any) => { - let { username, password } = body; - // 根据登录账号返回token,这里模拟两个账号 - // 1、admin账号 - // 2、common账号 - if (username === "admin" && password === "123456") { - return resultSuccess({ token: "Admin-Token" }); - } - if (username === "common" && password === "123456") { - return resultSuccess({ token: "Common-Token" }); - } - return resultError(null, "账号或者密码错误", 500); - } - }, - { - url: "/mock/user/getUserInfo", - method: "get", - timeout: 300, - response: ({ headers, query }: any) => { - let data: any = { - user: {}, // 账户信息 - roles: [], // 角色 - permissions: [] // 权限 - }; - let account = deepClone(accountData); - - // 传入id则通过id匹配,否则通过token匹配 - if (query.id) { - data.user = account.find((item: any) => item.id == query.id); - } else { - // 1、拿账户信息 - if (headers.authorization == "Admin-Token") { - // 管理员账户 - data.user = account.find((item: any) => item.id == 1); - } else { - // 普通账户 - data.user = account.find((item: any) => item.id == 2); - } - } - - // 2、根据账户拿角色信息 - let roleInfo = roleData.filter((item: any) => data.user.roles.includes(item.code)); - data.user.roles = roleInfo; - data.roles = roleInfo.map((item: any) => item.code); - - // 3、拿权限信息 - // 超级管理员 - if (data.roles.includes("admin")) { - data.permissions = ["*:*:*"]; - } else { - // 非admin账号则只拿对应角色的权限 - let list = permissionData.filter((permission: any) => { - return data.roles.some((item: string) => permission.meta.roles.includes(item)); - }); - data.permissions = list.map(item => item.meta.permission); - } - - return resultSuccess(data); - } - } -] as MockMethod[]; +import type { MockMethod } from "vite-plugin-mock"; +import { resultSuccess, resultError, deepClone } from "../_utils"; +import { accountData } from "../_data/system_data"; +import { permissionData } from "../_data/system_menu"; +import { roleData } from "../_data/system_data"; +/** + * post请求body,get请求query + * /mock/login 用户登录 + * /mock/user/getUserInfo 获取用户信息 + */ +export default [ + { + url: "/mock/login", + method: "post", + timeout: 300, + response: ({ body }: any) => { + let { username, password } = body; + // 根据登录账号返回token,这里模拟两个账号 + // 1、admin账号 + // 2、common账号 + if (username === "admin" && password === "123456") { + return resultSuccess({ token: "Admin-Token" }); + } + if (username === "common" && password === "123456") { + return resultSuccess({ token: "Common-Token" }); + } + return resultError(null, "账号或者密码错误", 500); + } + }, + { + url: "/mock/user/getUserInfo", + method: "get", + timeout: 300, + response: ({ headers, query }: any) => { + let data: any = { + user: {}, // 账户信息 + roles: [], // 角色 + permissions: [] // 权限 + }; + let account = deepClone(accountData); + + // 传入id则通过id匹配,否则通过token匹配 + if (query.id) { + data.user = account.find((item: any) => item.id == query.id); + } else { + // 1、拿账户信息 + if (headers.authorization == "Admin-Token") { + // 管理员账户 + data.user = account.find((item: any) => item.id == 1); + } else { + // 普通账户 + data.user = account.find((item: any) => item.id == 2); + } + } + + // 2、根据账户拿角色信息 + let roleInfo = roleData.filter((item: any) => data.user.roles.includes(item.code)); + data.user.roles = roleInfo; + data.roles = roleInfo.map((item: any) => item.code); + + // 3、拿权限信息 + // 超级管理员 + if (data.roles.includes("admin")) { + data.permissions = ["*:*:*"]; + } else { + // 非admin账号则只拿对应角色的权限 + let list = permissionData.filter((permission: any) => { + return data.roles.some((item: string) => permission.meta.roles.includes(item)); + }); + data.permissions = list.map(item => item.meta.permission); + } + + return resultSuccess(data); + } + } +] as MockMethod[]; diff --git a/web/src/router/index.ts b/web/src/router/index.ts index d4340c7..425fec7 100644 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -1,109 +1,109 @@ -import NProgress from "@/config/nprogress"; -import pinia from "@/store/index"; -import { createRouter, createWebHashHistory } from "vue-router"; -import { staticRoutes, notFoundAndNoPower } from "@/router/route.ts"; -import { currentlyRoute } from "@/router/route-output"; -import { storeToRefs } from "pinia"; -import { useUserInfoStore } from "@/store/modules/user-info"; -import { useRouteConfigStore } from "@/store/modules/route-config"; -import { useRoutingMethod } from "@/hooks/useRoutingMethod"; -/** - * 创建vue的路由示例 - * @method createRouter(options: RouterOptions): Router - * @link 参考:https://next.router.vuejs.org/zh/api/#createrouter - */ -const router = createRouter({ - history: createWebHashHistory(), - /** - * 设置静态路由,其它的路由通过addRoute动态添加 - * 1、staticRoutes登录页、layout页、默认页面('/') - * 2、notFoundAndNoPower 添加默认 401、500界面,防止提示 No match found for location with path 'xxx' - * 2、后端控制路由中也需要添加 notFoundAndNoPower 401、500界面 - * 静态添加 notFoundAndNoPower 401、500界面将全屏显示 - * 如果要 notFoundAndNoPower 在layout容器展示,则需要移除静态添加并将其添加到缓存路由树 - */ - routes: [...staticRoutes, ...notFoundAndNoPower] -}); - -/** - * 路由加载前需要判断用户是否登录 - * 1、去登录页,无token,放行 - * 2、没有token,直接重定向到登录页 - * 3、去登录页,有token,直接重定向到home页 - * 4、去非登录页,有token,用户信息是否存在,有则放行,否则重新获取路由信息、初始化路由 - * 注意: - * 全局routeTree不能持久化缓存 - * 页面刷新会导致addRoute动态添加的路由失效,需要重新初始化路由 - */ -router.beforeEach(async (to: any, _: any, next: any) => { - NProgress.start(); // 开启进度条 - const store = useUserInfoStore(pinia); - const routeStore = useRouteConfigStore(pinia); - const { token } = storeToRefs(store); - const { routeTree } = storeToRefs(routeStore); - // console.log("去", to, "来自", from); - // next()内部加了path等于跳转指定路由会再次触发router.beforeEach,内部无参数等于放行,不会触发router.beforeEach - - // 1、去登录页,无token,放行 - if (to.path === "/login" && !token.value) return next(); - - // 2、没有token,直接重定向到登录页 - if (!token.value) return next("/login"); - - // 3、去登录页,有token,直接重定向到home页 - if (to.path === "/login" && token.value) { - // 项目内的跳转,处理跳转路由高亮 - currentlyRoute(to); - return next("/home"); - } - - // 4、去非登录页,有token,用户信息是否存在,有则放行,否则重新获取路由信息、初始化路由 - // 判断路由是否获取,先获取账号信息和路由信息,添加路由后再跳转(页面刷新时触发) - // 解决刷新页面404的问题 - if (!routeTree.value.length) { - const routeStore = useRouteConfigStore(pinia); - - try { - // 获取账号信息 - await store.setAccount(); - // 获取路由信息 - await routeStore.initSetRouter(); - - // 判断是否是动态路由 - const { isDynamicRoute } = useRoutingMethod(); - if (isDynamicRoute(to.path)) { - return next({ name: to.name, params: to.params }); - } else { - return next({ path: to.path, query: to.query }); - } - } catch (error) { - console.error(error); - - return next(false); - } - } - - // 获取外链路由的处理函数 - // 所有的路由正常放行,只不过额外判断是否是外链,如果是,则打开新窗口跳转外链 - // 外链的页面依旧正常打开,只不过不会参与缓存与tabs显示,符合路由跳转的直觉 - const { openExternalLinks } = useRoutingMethod(); - // 处理外链跳转 - openExternalLinks(to); - // 项目内的跳转,处理跳转路由高亮 - currentlyRoute(to); - // 动态路由添加过走这里,直接放行 - next(); -}); - -// 路由跳转错误 -router.onError((error: any) => { - NProgress.done(); - console.warn("路由错误", error.message); -}); - -// 路由加载后 -router.afterEach(() => { - NProgress.done(); -}); - -export default router; +import NProgress from "@/config/nprogress"; +import pinia from "@/store/index"; +import { createRouter, createWebHashHistory } from "vue-router"; +import { staticRoutes, notFoundAndNoPower } from "@/router/route.ts"; +import { currentlyRoute } from "@/router/route-output"; +import { storeToRefs } from "pinia"; +import { useUserInfoStore } from "@/store/modules/user-info"; +import { useRouteConfigStore } from "@/store/modules/route-config"; +import { useRoutingMethod } from "@/hooks/useRoutingMethod"; +/** + * 创建vue的路由示例 + * @method createRouter(options: RouterOptions): Router + * @link 参考:https://next.router.vuejs.org/zh/api/#createrouter + */ +const router = createRouter({ + history: createWebHashHistory(), + /** + * 设置静态路由,其它的路由通过addRoute动态添加 + * 1、staticRoutes登录页、layout页、默认页面('/') + * 2、notFoundAndNoPower 添加默认 401、500界面,防止提示 No match found for location with path 'xxx' + * 2、后端控制路由中也需要添加 notFoundAndNoPower 401、500界面 + * 静态添加 notFoundAndNoPower 401、500界面将全屏显示 + * 如果要 notFoundAndNoPower 在layout容器展示,则需要移除静态添加并将其添加到缓存路由树 + */ + routes: [...staticRoutes, ...notFoundAndNoPower] +}); + +/** + * 路由加载前需要判断用户是否登录 + * 1、去登录页,无token,放行 + * 2、没有token,直接重定向到登录页 + * 3、去登录页,有token,直接重定向到home页 + * 4、去非登录页,有token,用户信息是否存在,有则放行,否则重新获取路由信息、初始化路由 + * 注意: + * 全局routeTree不能持久化缓存 + * 页面刷新会导致addRoute动态添加的路由失效,需要重新初始化路由 + */ +router.beforeEach(async (to: any, _: any, next: any) => { + NProgress.start(); // 开启进度条 + const store = useUserInfoStore(pinia); + const routeStore = useRouteConfigStore(pinia); + const { token } = storeToRefs(store); + const { routeTree } = storeToRefs(routeStore); + // console.log("去", to, "来自", from); + // next()内部加了path等于跳转指定路由会再次触发router.beforeEach,内部无参数等于放行,不会触发router.beforeEach + + // 1、去登录页,无token,放行 + if (to.path === "/login" && !token.value) return next(); + + // 2、没有token,直接重定向到登录页 + if (!token.value) return next("/login"); + + // 3、去登录页,有token,直接重定向到home页 + if (to.path === "/login" && token.value) { + // 项目内的跳转,处理跳转路由高亮 + currentlyRoute(to); + return next("/home"); + } + + // 4、去非登录页,有token,用户信息是否存在,有则放行,否则重新获取路由信息、初始化路由 + // 判断路由是否获取,先获取账号信息和路由信息,添加路由后再跳转(页面刷新时触发) + // 解决刷新页面404的问题 + if (!routeTree.value.length) { + const routeStore = useRouteConfigStore(pinia); + + try { + // 获取账号信息 + await store.setAccount(); + // 获取路由信息 + await routeStore.initSetRouter(); + + // 判断是否是动态路由 + const { isDynamicRoute } = useRoutingMethod(); + if (isDynamicRoute(to.path)) { + return next({ name: to.name, params: to.params }); + } else { + return next({ path: to.path, query: to.query }); + } + } catch (error) { + console.error(error); + + return next(false); + } + } + + // 获取外链路由的处理函数 + // 所有的路由正常放行,只不过额外判断是否是外链,如果是,则打开新窗口跳转外链 + // 外链的页面依旧正常打开,只不过不会参与缓存与tabs显示,符合路由跳转的直觉 + const { openExternalLinks } = useRoutingMethod(); + // 处理外链跳转 + openExternalLinks(to); + // 项目内的跳转,处理跳转路由高亮 + currentlyRoute(to); + // 动态路由添加过走这里,直接放行 + next(); +}); + +// 路由跳转错误 +router.onError((error: any) => { + NProgress.done(); + console.warn("路由错误", error.message); +}); + +// 路由加载后 +router.afterEach(() => { + NProgress.done(); +}); + +export default router; diff --git a/web/src/router/route-output.ts b/web/src/router/route-output.ts index 90f02eb..98fbc14 100644 --- a/web/src/router/route-output.ts +++ b/web/src/router/route-output.ts @@ -1,91 +1,91 @@ -import pinia from "@/store/index"; -import { storeToRefs } from "pinia"; -import { useRouteConfigStore } from "@/store/modules/route-config"; -import { useThemeConfig } from "@/store/modules/theme-config"; -import { deepClone } from "@/utils/index"; -import { arrayFlattened } from "@/utils/tree-tools"; - -/** - * 统一处理所有的路由跳转:当前路由高亮、tabs栏数据 - * 处理项目内跳转,存入当前跳转路由和tabs标签栏数据 - * menu和tabs以及手动刷新浏览器等功能只需要跳转即可,缓存和高亮的逻辑这边负责 - * @param {any} current 需要跳转的路由和路由参数 - */ -export const currentlyRoute = (current: any) => { - const route = deepCloneRoute(current); - const themeStore = useThemeConfig(); - const { isTabs } = storeToRefs(themeStore); - const store = useRouteConfigStore(pinia); - const { tabsList, routeList } = storeToRefs(store); - // tabs无数据则默认添加首页 - if (tabsList.value.length == 0 && routeList.value.length != 0) { - store.setTabs(routeList.value[0]); - } - // 存入当前路由-高亮 - store.setCurrentRoute(route); - // 如果是外链路由则不做后续任何缓存操作,条件: 有外链 && 非内嵌 - if (route.meta.link && !route.meta.iframe) return; - // 存入tabs栏数据,条件:开启tabs - if (isTabs.value && !route.meta.isFull) store.setTabs(route); - // 不缓存路由 || 不渲染tabs ,符合任意条件则不缓存路由 - if (!route.meta.keepAlive || !isTabs.value) return; - store.setRoutePaths(route.path); // 缓存路由 -}; - -/** - * 深拷贝路由,切断与原路由的联系,防止路由参数污染 - * @param route 当前路由 - * @returns 深拷贝后的路由 - */ -export const deepCloneRoute = (route: any) => { - return deepClone({ - path: route.fullPath, - name: route.name, - meta: route.meta, - query: route.query, - params: route.params - }); -}; - -/** - * 模块替换,对路由中的模块进行转换 - * @param {array} tree 过滤角色权限后的树 - */ -export const moduleReplacement = (tree: any) => { - tree.forEach((item: any) => { - item.children && delete item.children; - moduleMatch(item); - }); - return tree; -}; - -/** - * 模块匹配 - * 1、导入 views 目录及其子目录下的所有 .vue 文件。 - * 2、匹配views下的所有文件路径,将模块转换为按需引入的真实模块 - * 3、未匹配上,不做处理 - */ -// 匹配views里面所有的.vue文件 -const modules = import.meta.glob("@/views/**/*.vue"); -export const moduleMatch = (item: any) => { - // 匹配每个views文件夹下的文件路径 - for (const key in modules) { - const dir = key.split("views/")[1].replace(".vue", ""); - // 若匹配上,则替换真实模块 - if (item.component === dir) { - // 按需引入modules - // 将模块的导入操作和实际使用操作解耦,使得我们可以在需要的时候才执行导入操作 - item.component = () => modules[key](); - } - } -}; - -/** - * 路由树转一维数组 - * @param {array} tree 路由树 - * @returns 一维路由数组 - */ -export function linearArray(tree: any) { - const nodes: any = deepClone(tree); - return arrayFlattened(nodes, "children"); -} +import pinia from "@/store/index"; +import { storeToRefs } from "pinia"; +import { useRouteConfigStore } from "@/store/modules/route-config"; +import { useThemeConfig } from "@/store/modules/theme-config"; +import { deepClone } from "@/utils/index"; +import { arrayFlattened } from "@/utils/tree-tools"; + +/** + * 统一处理所有的路由跳转:当前路由高亮、tabs栏数据 + * 处理项目内跳转,存入当前跳转路由和tabs标签栏数据 + * menu和tabs以及手动刷新浏览器等功能只需要跳转即可,缓存和高亮的逻辑这边负责 + * @param {any} current 需要跳转的路由和路由参数 + */ +export const currentlyRoute = (current: any) => { + const route = deepCloneRoute(current); + const themeStore = useThemeConfig(); + const { isTabs } = storeToRefs(themeStore); + const store = useRouteConfigStore(pinia); + const { tabsList, routeList } = storeToRefs(store); + // tabs无数据则默认添加首页 + if (tabsList.value.length == 0 && routeList.value.length != 0) { + store.setTabs(routeList.value[0]); + } + // 存入当前路由-高亮 + store.setCurrentRoute(route); + // 如果是外链路由则不做后续任何缓存操作,条件: 有外链 && 非内嵌 + if (route.meta.link && !route.meta.iframe) return; + // 存入tabs栏数据,条件:开启tabs + if (isTabs.value && !route.meta.isFull) store.setTabs(route); + // 不缓存路由 || 不渲染tabs ,符合任意条件则不缓存路由 + if (!route.meta.keepAlive || !isTabs.value) return; + store.setRoutePaths(route.path); // 缓存路由 +}; + +/** + * 深拷贝路由,切断与原路由的联系,防止路由参数污染 + * @param route 当前路由 + * @returns 深拷贝后的路由 + */ +export const deepCloneRoute = (route: any) => { + return deepClone({ + path: route.fullPath, + name: route.name, + meta: route.meta, + query: route.query, + params: route.params + }); +}; + +/** + * 模块替换,对路由中的模块进行转换 + * @param {array} tree 过滤角色权限后的树 + */ +export const moduleReplacement = (tree: any) => { + tree.forEach((item: any) => { + item.children && delete item.children; + moduleMatch(item); + }); + return tree; +}; + +/** + * 模块匹配 + * 1、导入 views 目录及其子目录下的所有 .vue 文件。 + * 2、匹配views下的所有文件路径,将模块转换为按需引入的真实模块 + * 3、未匹配上,不做处理 + */ +// 匹配views里面所有的.vue文件 +const modules = import.meta.glob("@/views/**/*.vue"); +export const moduleMatch = (item: any) => { + // 匹配每个views文件夹下的文件路径 + for (const key in modules) { + const dir = key.split("views/")[1].replace(".vue", ""); + // 若匹配上,则替换真实模块 + if (item.component === dir) { + // 按需引入modules + // 将模块的导入操作和实际使用操作解耦,使得我们可以在需要的时候才执行导入操作 + item.component = () => modules[key](); + } + } +}; + +/** + * 路由树转一维数组 + * @param {array} tree 路由树 + * @returns 一维路由数组 + */ +export function linearArray(tree: any) { + const nodes: any = deepClone(tree); + return arrayFlattened(nodes, "children"); +} diff --git a/web/src/router/route.ts b/web/src/router/route.ts index 164707d..3a9db91 100644 --- a/web/src/router/route.ts +++ b/web/src/router/route.ts @@ -1,90 +1,90 @@ -import { HOME_PATH } from "@/config/index"; -import Layout from "@/layout/index.vue"; -/** - * 路由path路径与文件夹名称相同,找文件可以浏览器地址快速查找,方便定位文件 - * - * 路由meta对象参数,我们通常将属性放到meta对象中 - * meta: { - * title: 菜单栏以及 tabsView 栏、菜单搜索名称(国际化) - * hide: 是否隐藏此路由,不会显示在菜单树,可以访问 - * disable: 是否停用,不会显示在菜单树,且不可访问 - * keepAlive: 是否缓存组件状态 - * affix: 是否固定在 tabsView 栏上 - * link: 是否是超链接菜单,开启外链条件:1、 link:链接地址不为空 2、iframe: false - * iframe: 是否内嵌窗口,开启条件:1、iframe:true 2、link:链接地址不为空 - * roles: 当前路由权限表示,取角色管理。路由控制显示、隐藏。 超级管理员:admin;普通角色:common - * icon: 菜单、tabsView 图标等 - * svgIcon: svg图标 - * sort: 菜单顺序 - * } - */ - -/** - * 静态路由 (默认路由) - * 此路由不要动,用于做静态路由定向,如果要添加路由,请在 `layout-children` 中添加 - * @description 前端控制路由 直接改 mock/_data/system_menu 中的路由,后端控制则不需要 - * @returns 返回路由菜单数据 - */ -export const staticRoutes = [ - { - path: "/", - redirect: HOME_PATH - }, - { - path: "/login", - name: "login", - component: () => import("@/views/login/login.vue"), - meta: { - title: "login" - } - }, - { - path: "/layout", - name: "layout", - redirect: HOME_PATH, - component: Layout, // 容器布局-顶层路由 - // 二级路由-主要渲染页面 - children: [] - } - /** - * 提示:写在这里的为全屏界面,不建议写在这里非全屏界面,请写在 layout.children 路由数组中 - * - */ -]; - -/** - * 定义401、404、500界面 - * 401无权限 - * 404页面不存在 - * 500网络断开 - * @link 参考:https://router.vuejs.org/zh/guide/essentials/history-mode.html#netlify - */ -export const notFoundAndNoPower = [ - { - path: "/401", // 无权限,跳转401 - name: "no-access", - component: () => import("@/views/error/401.vue"), - meta: { - title: "no-access", - hide: true - } - }, - { - path: "/500", // 无网络-浏览器离线 - name: "no-network", - component: () => import("@/views/error/500.vue"), - meta: { - title: "no-network", - hide: true - } - }, - { - path: "/:path(.*)*", // 匹配任意路由,兜底,未找到页面的时候跳转该页面 - name: "not-found", - component: () => import("@/views/error/404.vue"), - meta: { - title: "not-found", - hide: true - } - } -]; +import { HOME_PATH } from "@/config/index"; +import Layout from "@/layout/index.vue"; +/** + * 路由path路径与文件夹名称相同,找文件可以浏览器地址快速查找,方便定位文件 + * + * 路由meta对象参数,我们通常将属性放到meta对象中 + * meta: { + * title: 菜单栏以及 tabsView 栏、菜单搜索名称(国际化) + * hide: 是否隐藏此路由,不会显示在菜单树,可以访问 + * disable: 是否停用,不会显示在菜单树,且不可访问 + * keepAlive: 是否缓存组件状态 + * affix: 是否固定在 tabsView 栏上 + * link: 是否是超链接菜单,开启外链条件:1、 link:链接地址不为空 2、iframe: false + * iframe: 是否内嵌窗口,开启条件:1、iframe:true 2、link:链接地址不为空 + * roles: 当前路由权限表示,取角色管理。路由控制显示、隐藏。 超级管理员:admin;普通角色:common + * icon: 菜单、tabsView 图标等 + * svgIcon: svg图标 + * sort: 菜单顺序 + * } + */ + +/** + * 静态路由 (默认路由) + * 此路由不要动,用于做静态路由定向,如果要添加路由,请在 `layout-children` 中添加 + * @description 前端控制路由 直接改 mock/_data/system_menu 中的路由,后端控制则不需要 + * @returns 返回路由菜单数据 + */ +export const staticRoutes = [ + { + path: "/", + redirect: HOME_PATH + }, + { + path: "/login", + name: "login", + component: () => import("@/views/login/login.vue"), + meta: { + title: "login" + } + }, + { + path: "/layout", + name: "layout", + redirect: HOME_PATH, + component: Layout, // 容器布局-顶层路由 + // 二级路由-主要渲染页面 + children: [] + } + /** + * 提示:写在这里的为全屏界面,不建议写在这里非全屏界面,请写在 layout.children 路由数组中 + * + */ +]; + +/** + * 定义401、404、500界面 + * 401无权限 + * 404页面不存在 + * 500网络断开 + * @link 参考:https://router.vuejs.org/zh/guide/essentials/history-mode.html#netlify + */ +export const notFoundAndNoPower = [ + { + path: "/401", // 无权限,跳转401 + name: "no-access", + component: () => import("@/views/error/401.vue"), + meta: { + title: "no-access", + hide: true + } + }, + { + path: "/500", // 无网络-浏览器离线 + name: "no-network", + component: () => import("@/views/error/500.vue"), + meta: { + title: "no-network", + hide: true + } + }, + { + path: "/:path(.*)*", // 匹配任意路由,兜底,未找到页面的时候跳转该页面 + name: "not-found", + component: () => import("@/views/error/404.vue"), + meta: { + title: "not-found", + hide: true + } + } +]; diff --git a/web/src/store/config/index.ts b/web/src/store/config/index.ts index ab7eaea..263b332 100644 --- a/web/src/store/config/index.ts +++ b/web/src/store/config/index.ts @@ -1,16 +1,16 @@ -/** - * https://prazdevs.github.io/pinia-plugin-persistedstate/zh/guide/config.html - * @description: 持久化配置 - * @param {string} key 存储的key - * @param {Array} paths 需要持久化的字段 - * @return {*} - */ -const persistedstateConfig = (key: string, paths?: Array) => { - return { - key, - storage: localStorage, // 存储方式,使用localStorage,也可以使用sessionStorage - paths - }; -}; - -export default persistedstateConfig; +/** + * https://prazdevs.github.io/pinia-plugin-persistedstate/zh/guide/config.html + * @description: 持久化配置 + * @param {string} key 存储的key + * @param {Array} paths 需要持久化的字段 + * @return {*} + */ +const persistedstateConfig = (key: string, paths?: Array) => { + return { + key, + storage: localStorage, // 存储方式,使用localStorage,也可以使用sessionStorage + paths + }; +}; + +export default persistedstateConfig; diff --git a/web/src/store/index.ts b/web/src/store/index.ts index 41b0b65..4e7a3cb 100644 --- a/web/src/store/index.ts +++ b/web/src/store/index.ts @@ -1,12 +1,12 @@ -// https://pinia.vuejs.org/zh/ -// https://prazdevs.github.io/pinia-plugin-persistedstate/zh/ -// store/index.js -import { createPinia } from "pinia"; -import piniaPluginPersistedstate from "pinia-plugin-persistedstate"; - -// 创建 -const pinia = createPinia(); -pinia.use(piniaPluginPersistedstate); - -// 导出 -export default pinia; +// https://pinia.vuejs.org/zh/ +// https://prazdevs.github.io/pinia-plugin-persistedstate/zh/ +// store/index.js +import { createPinia } from "pinia"; +import piniaPluginPersistedstate from "pinia-plugin-persistedstate"; + +// 创建 +const pinia = createPinia(); +pinia.use(piniaPluginPersistedstate); + +// 导出 +export default pinia; diff --git a/web/src/store/modules/route-config.ts b/web/src/store/modules/route-config.ts index fa224f8..7ab225d 100644 --- a/web/src/store/modules/route-config.ts +++ b/web/src/store/modules/route-config.ts @@ -1,173 +1,173 @@ -import { defineStore } from "pinia"; -import router from "@/router/index"; -import { staticRoutes } from "@/router/route"; -import { getRoutersAPI } from "@/api/modules/system/index"; -import { moduleReplacement, linearArray } from "@/router/route-output"; -import { getUrlWithParams } from "@/utils/index"; - -/** - * 路由列表 - * @method setTabsTitle 设置tabs标签页名称 - * @methods setRoutePaths 设置路由名称集合 - * @methods setTabs 添加tabs标签页 - * @methods setCurrentRoute 设置系统内的当前路由 - * @methods removeTabsList 删除tabs页的指定路由 - * @methods removeRouteName 删除缓存路由名,用于取消页面缓存,单个删除 - * @methods removeRoutePaths 删除缓存路由名,用于取消页面缓存,批量删除 - * @methods resetRoute 重置动态添加的路由 - * @methods initSetRouter 路由初始化 - */ -export const routeConfigStore = () => { - const routeTree = ref([]); // 有访问权限的路由树 - const routeList = ref([]); // 有访问权限的一维路由数组 - const cacheRoutes = ref([]); // 所有可缓存路由的路由路径 - const tabsList = ref([]); // 标签页数据 - const currentRoute = ref({}); // 当前路由 - - /** - * 设置tabs名称 - * @param {string} title 路由名称 - */ - function setTabsTitle(title: string) { - for (let i = 0; i < tabsList.value.length; i++) { - if (tabsList.value[i].path == getUrlWithParams()) { - tabsList.value[i].meta.title = title; - break; - } - } - } - - /** - * 设置可缓存路由的路径 -> fullPath - * 同路由不同参兼容,会开启多个标签页,fullPath可做标识 - * @param {string} path 路由fullPath - */ - function setRoutePaths(path: string) { - let state = cacheRoutes.value.some((item: string) => item === path); - if (state) return; - cacheRoutes.value.push(path); - } - - /** - * 添加tabs标签页 - * @param {object} route 当前tabs路由 - */ - function setTabs(route: Menu.MenuOptions) { - // 顶层手动添加的全屏静态路由不参与tabs - if (staticRoutes.some(item => item.name == route.name)) return; - // 不在可访问的路由中则不参与tabs - if (!routeList.value.some((item: any) => item.name == route.name)) return; - // 当前路由在tags中是否存在 - let index = tabsList.value.findIndex((item: Menu.MenuOptions) => item.path === route.path); - // 不存在,直接缓存 - if (index == -1) return tabsList.value.push(route); - } - /** - * 设置系统内的当前路由数据 - * @param {object} data 当前路由 - */ - function setCurrentRoute(data: Menu.MenuOptions) { - // 名称一样不代表参数相同,这不用做已存在匹配,直接存储当前路由 - currentRoute.value = data; - } - /** - * 删除tabs页的指定路由 - * @param {string} path 路由fullPath - */ - function removeTabsList(path: string) { - const index = tabsList.value.findIndex((item: Menu.MenuOptions) => item.path === path); - if (tabsList.value[index].meta.affix) return; - if (index === -1) return; - tabsList.value.splice(index, 1); - } - /** - * 删除缓存路由,用于取消页面缓存,单个删除 - * @param {string} path 路由 - */ - function removeRouteName(path: string) { - const index = cacheRoutes.value.findIndex((item: string) => item === path); - if (index === -1) return; - cacheRoutes.value.splice(index, 1); - } - /** - * 删除缓存路由,用于取消页面缓存,批量删除 - * @param {Array} list 路由 - */ - function removeRoutePaths(list: Array) { - cacheRoutes.value = cacheRoutes.value.filter((item: string) => !list.includes(item)); - } - /** - * 重置动态添加的路由 - */ - async function resetRoute() { - // 清除标签页数据 - tabsList.value = []; - // 清除有访问权限的路由树 - routeTree.value = []; - // 清除所有可缓存路由的路由路径 - cacheRoutes.value = []; - // 清除当前路由 - currentRoute.value = {}; - // 清除动态添加的路由 - routeList.value.forEach((item: any) => { - if (router.hasRoute(item.name)) router.removeRoute(item.name); - }); - // 清除有访问权限的一维路由数组 - routeList.value = []; - } - - /** - * 路由初始化 - * 1、获取过滤角色权限后排过序的的路由树,后端处理 - * 2、获取路由树转换的一维路由 - * 3、将模块设置为真实模块 - * 4、动态添加路由 - * 5、存储路由树,用于生成菜单 - * 6、缓存一维路由 - */ - async function initSetRouter() { - // 1、获取过滤角色权限后的树,后端做排序处理 - let { data } = await getRoutersAPI(); - - // 验证数据有效性 - if (!data || !Array.isArray(data) || data.length === 0) { - return; - } - - // 2、获取路由树转换的一维路由 - let flatRoute = linearArray(data); - // 3、将模块设置为真实模块 - let realTree = await moduleReplacement(flatRoute); - // 4、动态添加路由 - realTree.forEach((route: any) => { - if (route.meta.isFull) { - router.addRoute(route); - } else { - router.addRoute("layout", route); - } - }); - // 5、存储路由树,用于生成菜单 - routeTree.value = data; - // 6、缓存一维路由 - routeList.value = flatRoute; - } - - return { - routeTree, - routeList, - cacheRoutes, - tabsList, - currentRoute, - setTabsTitle, - setRoutePaths, - setTabs, - setCurrentRoute, - removeTabsList, - removeRouteName, - removeRoutePaths, - resetRoute, - initSetRouter - }; -}; - -export const useRouteConfigStore = defineStore("route-config", routeConfigStore); +import { defineStore } from "pinia"; +import router from "@/router/index"; +import { staticRoutes } from "@/router/route"; +import { getRoutersAPI } from "@/api/modules/system/index"; +import { moduleReplacement, linearArray } from "@/router/route-output"; +import { getUrlWithParams } from "@/utils/index"; + +/** + * 路由列表 + * @method setTabsTitle 设置tabs标签页名称 + * @methods setRoutePaths 设置路由名称集合 + * @methods setTabs 添加tabs标签页 + * @methods setCurrentRoute 设置系统内的当前路由 + * @methods removeTabsList 删除tabs页的指定路由 + * @methods removeRouteName 删除缓存路由名,用于取消页面缓存,单个删除 + * @methods removeRoutePaths 删除缓存路由名,用于取消页面缓存,批量删除 + * @methods resetRoute 重置动态添加的路由 + * @methods initSetRouter 路由初始化 + */ +export const routeConfigStore = () => { + const routeTree = ref([]); // 有访问权限的路由树 + const routeList = ref([]); // 有访问权限的一维路由数组 + const cacheRoutes = ref([]); // 所有可缓存路由的路由路径 + const tabsList = ref([]); // 标签页数据 + const currentRoute = ref({}); // 当前路由 + + /** + * 设置tabs名称 + * @param {string} title 路由名称 + */ + function setTabsTitle(title: string) { + for (let i = 0; i < tabsList.value.length; i++) { + if (tabsList.value[i].path == getUrlWithParams()) { + tabsList.value[i].meta.title = title; + break; + } + } + } + + /** + * 设置可缓存路由的路径 -> fullPath + * 同路由不同参兼容,会开启多个标签页,fullPath可做标识 + * @param {string} path 路由fullPath + */ + function setRoutePaths(path: string) { + let state = cacheRoutes.value.some((item: string) => item === path); + if (state) return; + cacheRoutes.value.push(path); + } + + /** + * 添加tabs标签页 + * @param {object} route 当前tabs路由 + */ + function setTabs(route: Menu.MenuOptions) { + // 顶层手动添加的全屏静态路由不参与tabs + if (staticRoutes.some(item => item.name == route.name)) return; + // 不在可访问的路由中则不参与tabs + if (!routeList.value.some((item: any) => item.name == route.name)) return; + // 当前路由在tags中是否存在 + let index = tabsList.value.findIndex((item: Menu.MenuOptions) => item.path === route.path); + // 不存在,直接缓存 + if (index == -1) return tabsList.value.push(route); + } + /** + * 设置系统内的当前路由数据 + * @param {object} data 当前路由 + */ + function setCurrentRoute(data: Menu.MenuOptions) { + // 名称一样不代表参数相同,这不用做已存在匹配,直接存储当前路由 + currentRoute.value = data; + } + /** + * 删除tabs页的指定路由 + * @param {string} path 路由fullPath + */ + function removeTabsList(path: string) { + const index = tabsList.value.findIndex((item: Menu.MenuOptions) => item.path === path); + if (tabsList.value[index].meta.affix) return; + if (index === -1) return; + tabsList.value.splice(index, 1); + } + /** + * 删除缓存路由,用于取消页面缓存,单个删除 + * @param {string} path 路由 + */ + function removeRouteName(path: string) { + const index = cacheRoutes.value.findIndex((item: string) => item === path); + if (index === -1) return; + cacheRoutes.value.splice(index, 1); + } + /** + * 删除缓存路由,用于取消页面缓存,批量删除 + * @param {Array} list 路由 + */ + function removeRoutePaths(list: Array) { + cacheRoutes.value = cacheRoutes.value.filter((item: string) => !list.includes(item)); + } + /** + * 重置动态添加的路由 + */ + async function resetRoute() { + // 清除标签页数据 + tabsList.value = []; + // 清除有访问权限的路由树 + routeTree.value = []; + // 清除所有可缓存路由的路由路径 + cacheRoutes.value = []; + // 清除当前路由 + currentRoute.value = {}; + // 清除动态添加的路由 + routeList.value.forEach((item: any) => { + if (router.hasRoute(item.name)) router.removeRoute(item.name); + }); + // 清除有访问权限的一维路由数组 + routeList.value = []; + } + + /** + * 路由初始化 + * 1、获取过滤角色权限后排过序的的路由树,后端处理 + * 2、获取路由树转换的一维路由 + * 3、将模块设置为真实模块 + * 4、动态添加路由 + * 5、存储路由树,用于生成菜单 + * 6、缓存一维路由 + */ + async function initSetRouter() { + // 1、获取过滤角色权限后的树,后端做排序处理 + let { data } = await getRoutersAPI(); + + // 验证数据有效性 + if (!data || !Array.isArray(data) || data.length === 0) { + return; + } + + // 2、获取路由树转换的一维路由 + let flatRoute = linearArray(data); + // 3、将模块设置为真实模块 + let realTree = await moduleReplacement(flatRoute); + // 4、动态添加路由 + realTree.forEach((route: any) => { + if (route.meta.isFull) { + router.addRoute(route); + } else { + router.addRoute("layout", route); + } + }); + // 5、存储路由树,用于生成菜单 + routeTree.value = data; + // 6、缓存一维路由 + routeList.value = flatRoute; + } + + return { + routeTree, + routeList, + cacheRoutes, + tabsList, + currentRoute, + setTabsTitle, + setRoutePaths, + setTabs, + setCurrentRoute, + removeTabsList, + removeRouteName, + removeRoutePaths, + resetRoute, + initSetRouter + }; +}; + +export const useRouteConfigStore = defineStore("route-config", routeConfigStore); diff --git a/web/src/store/modules/theme-config.ts b/web/src/store/modules/theme-config.ts index 4e7c37c..7a4cd88 100644 --- a/web/src/store/modules/theme-config.ts +++ b/web/src/store/modules/theme-config.ts @@ -1,113 +1,113 @@ -import { defineStore } from "pinia"; -import persistedstateConfig from "@/store/config/index"; -/** - * 全局配置 - * @methods setCollapsed 设置菜单折叠 - * @methods setRefreshPage 刷新页面 - * @methods setLanguage 设置语言 - */ -const themeConfig = () => { - // 是否折叠菜单 - const collapsed = ref(false); - // 刷新页面 - const refreshPage = ref(true); - // 系统语言 - const language = ref("zh-CN"); - // 黑暗模式 - const darkMode = ref(false); - // 菜单手风琴 - const isAccordion = ref(true); - // 面包屑渲染 - const isBreadcrumb = ref(true); - // 标签栏渲染 - const isTabs = ref(true); - // 页脚渲染 - const isFooter = ref(true); - // 水印 - const watermark = ref(""); - // 水印风格 - const watermarkStyle = ref<{ fontSize: number; color: string }>({ - fontSize: 12, - color: "rgba(0, 0, 0, 0.15)" - }); - // 水印角度 - const watermarkRotate = ref(330); - // 水印间隙 - const watermarkGap = ref<[number, number]>([100, 100]); - // 防止调试 - const debugPrevention = ref(false); - // 布局模式:layoutDefaults、layoutHead、layoutMixing - const layoutType = ref("layoutDefaults"); - // 色弱模式 - const colorWeakMode = ref(false); - // 灰色模式 - const grayMode = ref(false); - // 侧边栏深色 - const asideDark = ref(false); - // 页面过渡方式 - const transitionPage = ref("fadeInOut"); - // 主题色 - const themeColor = ref("#165DFF"); - // 调色盘 - const presetColors = ref([ - "#165DFF", - "#F53F3F", - "#F77234", - "#FF7D00", - "#F7BA1E", - "#FADC19", - "#9FDB1D", - "#00B42A", - "#3491FA", - "#c34d9c", - "#722ED1", - "#E6A23C", - "#F56C6C", - "#409EFF", - "#42b883", - "#b1d391" - ]); - - // 折叠菜单 - function setCollapsed(data: boolean) { - collapsed.value = data; - } - // 刷新页面 - function setRefreshPage(data: boolean) { - refreshPage.value = data; - } - // 设置语言 - function setLanguage(data: string) { - language.value = data; - } - - return { - collapsed, - refreshPage, - language, - darkMode, - isAccordion, - isBreadcrumb, - isTabs, - isFooter, - watermark, - watermarkStyle, - watermarkRotate, - watermarkGap, - debugPrevention, - layoutType, - colorWeakMode, - grayMode, - asideDark, - transitionPage, - themeColor, - presetColors, - setCollapsed, - setRefreshPage, - setLanguage - }; -}; - -export const useThemeConfig = defineStore("theme-config", themeConfig, { - persist: persistedstateConfig("theme-config") -}); +import { defineStore } from "pinia"; +import persistedstateConfig from "@/store/config/index"; +/** + * 全局配置 + * @methods setCollapsed 设置菜单折叠 + * @methods setRefreshPage 刷新页面 + * @methods setLanguage 设置语言 + */ +const themeConfig = () => { + // 是否折叠菜单 + const collapsed = ref(false); + // 刷新页面 + const refreshPage = ref(true); + // 系统语言 + const language = ref("zh-CN"); + // 黑暗模式 + const darkMode = ref(false); + // 菜单手风琴 + const isAccordion = ref(true); + // 面包屑渲染 + const isBreadcrumb = ref(true); + // 标签栏渲染 + const isTabs = ref(true); + // 页脚渲染 + const isFooter = ref(true); + // 水印 + const watermark = ref(""); + // 水印风格 + const watermarkStyle = ref<{ fontSize: number; color: string }>({ + fontSize: 12, + color: "rgba(0, 0, 0, 0.15)" + }); + // 水印角度 + const watermarkRotate = ref(330); + // 水印间隙 + const watermarkGap = ref<[number, number]>([100, 100]); + // 防止调试 + const debugPrevention = ref(false); + // 布局模式:layoutDefaults、layoutHead、layoutMixing + const layoutType = ref("layoutDefaults"); + // 色弱模式 + const colorWeakMode = ref(false); + // 灰色模式 + const grayMode = ref(false); + // 侧边栏深色 + const asideDark = ref(false); + // 页面过渡方式 + const transitionPage = ref("fadeInOut"); + // 主题色 + const themeColor = ref("#165DFF"); + // 调色盘 + const presetColors = ref([ + "#165DFF", + "#F53F3F", + "#F77234", + "#FF7D00", + "#F7BA1E", + "#FADC19", + "#9FDB1D", + "#00B42A", + "#3491FA", + "#c34d9c", + "#722ED1", + "#E6A23C", + "#F56C6C", + "#409EFF", + "#42b883", + "#b1d391" + ]); + + // 折叠菜单 + function setCollapsed(data: boolean) { + collapsed.value = data; + } + // 刷新页面 + function setRefreshPage(data: boolean) { + refreshPage.value = data; + } + // 设置语言 + function setLanguage(data: string) { + language.value = data; + } + + return { + collapsed, + refreshPage, + language, + darkMode, + isAccordion, + isBreadcrumb, + isTabs, + isFooter, + watermark, + watermarkStyle, + watermarkRotate, + watermarkGap, + debugPrevention, + layoutType, + colorWeakMode, + grayMode, + asideDark, + transitionPage, + themeColor, + presetColors, + setCollapsed, + setRefreshPage, + setLanguage + }; +}; + +export const useThemeConfig = defineStore("theme-config", themeConfig, { + persist: persistedstateConfig("theme-config") +}); diff --git a/web/src/store/modules/user-info.ts b/web/src/store/modules/user-info.ts index c060cf4..68b9368 100644 --- a/web/src/store/modules/user-info.ts +++ b/web/src/store/modules/user-info.ts @@ -1,64 +1,64 @@ -import { defineStore } from "pinia"; -import persistedstateConfig from "@/store/config/index"; -import { getUserInfoAPI } from "@/api/modules/user/index"; - -interface Account { - user: any; // 用户信息 - roles: string[]; // 角色 - permissions: string[]; // 权限 -} - -/** - * 用户信息 - * @methods setAccount 设置账号信息 - * @methods setToken 设置token - * @methods logOut 退出登录 - */ -const userInfoStore = () => { - // 账号信息 - const account = ref({ - user: {}, // 用户信息 - roles: [], // 角色 - permissions: [] // 权限 - }); - - const trade_type = ref>({}); - const trade_fiat = ref([]); - const trade_crypto = ref([]); - const admin_username = ref(""); - - async function setAccount() { - let data = await getUserInfoAPI(); - - // 确保返回的数据有效 - if (data && data.data) { - trade_type.value = data.data.trade_type || {}; - trade_fiat.value = data.data.trade_fiat || []; - trade_crypto.value = data.data.trade_crypto || []; - admin_username.value = data.data.admin_username || ""; - } - } - - // 设置token - const token = ref(""); - async function setToken(data: string) { - token.value = data; - } - - // 退出登录 - async function logOut() { - // 清除账号数据 - account.value = { - user: {}, - roles: [], - permissions: [] - }; - token.value = ""; - } - - return { account, token, setAccount, setToken, logOut, trade_type, trade_fiat, trade_crypto, admin_username }; -}; - -export const useUserInfoStore = defineStore("user-info", userInfoStore, { - persist: persistedstateConfig("user-info", ["token", "account", "trade_type", "trade_fiat", "trade_crypto", "admin_username"]) -}); +import { defineStore } from "pinia"; +import persistedstateConfig from "@/store/config/index"; +import { getUserInfoAPI } from "@/api/modules/user/index"; + +interface Account { + user: any; // 用户信息 + roles: string[]; // 角色 + permissions: string[]; // 权限 +} + +/** + * 用户信息 + * @methods setAccount 设置账号信息 + * @methods setToken 设置token + * @methods logOut 退出登录 + */ +const userInfoStore = () => { + // 账号信息 + const account = ref({ + user: {}, // 用户信息 + roles: [], // 角色 + permissions: [] // 权限 + }); + + const trade_type = ref>({}); + const trade_fiat = ref([]); + const trade_crypto = ref([]); + const admin_username = ref(""); + + async function setAccount() { + let data = await getUserInfoAPI(); + + // 确保返回的数据有效 + if (data && data.data) { + trade_type.value = data.data.trade_type || {}; + trade_fiat.value = data.data.trade_fiat || []; + trade_crypto.value = data.data.trade_crypto || []; + admin_username.value = data.data.admin_username || ""; + } + } + + // 设置token + const token = ref(""); + async function setToken(data: string) { + token.value = data; + } + + // 退出登录 + async function logOut() { + // 清除账号数据 + account.value = { + user: {}, + roles: [], + permissions: [] + }; + token.value = ""; + } + + return { account, token, setAccount, setToken, logOut, trade_type, trade_fiat, trade_crypto, admin_username }; +}; + +export const useUserInfoStore = defineStore("user-info", userInfoStore, { + persist: persistedstateConfig("user-info", ["token", "account", "trade_type", "trade_fiat", "trade_crypto", "admin_username"]) +}); diff --git a/web/src/style/index.scss b/web/src/style/index.scss index 926fdf2..9d2f3a0 100644 --- a/web/src/style/index.scss +++ b/web/src/style/index.scss @@ -1,32 +1,32 @@ -@use "@/style/var/index" as *; -@use "@/style/model"; -@use "@/style/media"; -* { - padding: 0; - margin: 0; -} -html, -body, -#app { - padding: 0; - margin: 0; - overflow: hidden; -} -html { - font-size: 14px; -} -#app { - overflow: hidden; -} - -// 设置全局颜色-关联黑暗模式 -// 全局取一级容器背景色$color-bg-2,main窗口取边框色浅色$color-border-1 -body { - color: $color-text-1; // 整体文字的颜色 - background: $color-bg-2; // body背景颜色 -} - -// 设置nprogress进度条样式 -#nprogress .bar { - background: $color-primary !important; -} +@use "@/style/var/index" as *; +@use "@/style/model"; +@use "@/style/media"; +* { + padding: 0; + margin: 0; +} +html, +body, +#app { + padding: 0; + margin: 0; + overflow: hidden; +} +html { + font-size: 14px; +} +#app { + overflow: hidden; +} + +// 设置全局颜色-关联黑暗模式 +// 全局取一级容器背景色$color-bg-2,main窗口取边框色浅色$color-border-1 +body { + color: $color-text-1; // 整体文字的颜色 + background: $color-bg-2; // body背景颜色 +} + +// 设置nprogress进度条样式 +#nprogress .bar { + background: $color-primary !important; +} diff --git a/web/src/style/media/index.scss b/web/src/style/media/index.scss index ebab64b..a695185 100644 --- a/web/src/style/media/index.scss +++ b/web/src/style/media/index.scss @@ -1 +1 @@ -@use "@/style/media/layout"; +@use "@/style/media/layout"; diff --git a/web/src/style/media/layout.scss b/web/src/style/media/layout.scss index 28258ef..92a8bbb 100644 --- a/web/src/style/media/layout.scss +++ b/web/src/style/media/layout.scss @@ -1,45 +1,45 @@ -@use "@/style/var/index" as *; - -// 处理首页数据图大小 -// 页面宽度 大于 0px 小于 992px; -@media screen and (min-width: $xs) and (max-width: $lg) { - .sell-histogram { - width: 100%; - height: 400px; - padding-bottom: $padding; - } - .daily-analysis { - width: 100%; - height: 400px; - padding-bottom: $padding; - } -} - -// 页面宽度 大于 992px 小于 1600px; -@media screen and (min-width: $lg) and (max-width: $xxl) { - .sell-histogram { - width: 100%; - height: 400px; - padding-bottom: $padding; - } - .daily-analysis { - width: 100%; - height: 400px; - padding-bottom: $padding; - } -} - -// 页面宽度 大于 1600px; -@media screen and (min-width: $xxl) { - .sell-histogram { - width: calc(100% - 600px - $padding); - height: 400px; - padding-bottom: $padding; - } - .daily-analysis { - width: 600px; - height: 400px; - padding-bottom: $padding; - margin-left: $padding; - } -} +@use "@/style/var/index" as *; + +// 处理首页数据图大小 +// 页面宽度 大于 0px 小于 992px; +@media screen and (min-width: $xs) and (max-width: $lg) { + .sell-histogram { + width: 100%; + height: 400px; + padding-bottom: $padding; + } + .daily-analysis { + width: 100%; + height: 400px; + padding-bottom: $padding; + } +} + +// 页面宽度 大于 992px 小于 1600px; +@media screen and (min-width: $lg) and (max-width: $xxl) { + .sell-histogram { + width: 100%; + height: 400px; + padding-bottom: $padding; + } + .daily-analysis { + width: 100%; + height: 400px; + padding-bottom: $padding; + } +} + +// 页面宽度 大于 1600px; +@media screen and (min-width: $xxl) { + .sell-histogram { + width: calc(100% - 600px - $padding); + height: 400px; + padding-bottom: $padding; + } + .daily-analysis { + width: 600px; + height: 400px; + padding-bottom: $padding; + margin-left: $padding; + } +} diff --git a/web/src/typings/arco.d.ts b/web/src/typings/arco.d.ts index 2e42409..0d36e9f 100644 --- a/web/src/typings/arco.d.ts +++ b/web/src/typings/arco.d.ts @@ -1,7 +1,7 @@ -/* ArcoDesign命名空间 */ -declare namespace ArcoDesign { - interface ArcoSubmit { - values: Record; - errors: Record | undefined; - } -} +/* ArcoDesign命名空间 */ +declare namespace ArcoDesign { + interface ArcoSubmit { + values: Record; + errors: Record | undefined; + } +} diff --git a/web/src/typings/global.d.ts b/web/src/typings/global.d.ts index dca7536..42e7491 100644 --- a/web/src/typings/global.d.ts +++ b/web/src/typings/global.d.ts @@ -1,50 +1,50 @@ -/* ts命名空间 */ -/* 路由-Menu */ -declare namespace Menu { - interface MenuOptions { - id: string; - parentId: string; - fullPath?: stirng; - path: string; - name: string; - redirect?: string; - component?: string | (() => Promise); - meta: MetaType; - children?: MenuOptions[] | null | any; - } - interface MetaType { - title: string; - hide: boolean; - disable: boolean; - keepAlive: boolean; - affix: boolean; - link?: string; - iframe?: boolean; - roles: Array; - icon?: string; - svgIcon?: string; - sort?: number; - type?: number; - } -} -/* tabs菜单 */ -declare namespace TabsMenu { - interface list { - list: Array<{ type: number; icon: string; title: string }>; - } - interface menu { - type: number; - icon: string; - title: string; - } -} - -/* viteEnv */ -interface ViteEnv { - VITE_GLOB_APP_TITLE: string; - VITE_IMG_BASE_URL: string; - VITE_APP_OPEN_MOCK: boolean | string; - VITE_USER_NODE_ENV: "development" | "production" | "test"; - VITE_PUBLIC_PATH: string; - VITE_APP_BASE_URL: string; -} +/* ts命名空间 */ +/* 路由-Menu */ +declare namespace Menu { + interface MenuOptions { + id: string; + parentId: string; + fullPath?: stirng; + path: string; + name: string; + redirect?: string; + component?: string | (() => Promise); + meta: MetaType; + children?: MenuOptions[] | null | any; + } + interface MetaType { + title: string; + hide: boolean; + disable: boolean; + keepAlive: boolean; + affix: boolean; + link?: string; + iframe?: boolean; + roles: Array; + icon?: string; + svgIcon?: string; + sort?: number; + type?: number; + } +} +/* tabs菜单 */ +declare namespace TabsMenu { + interface list { + list: Array<{ type: number; icon: string; title: string }>; + } + interface menu { + type: number; + icon: string; + title: string; + } +} + +/* viteEnv */ +interface ViteEnv { + VITE_GLOB_APP_TITLE: string; + VITE_IMG_BASE_URL: string; + VITE_APP_OPEN_MOCK: boolean | string; + VITE_USER_NODE_ENV: "development" | "production" | "test"; + VITE_PUBLIC_PATH: string; + VITE_APP_BASE_URL: string; +} diff --git a/web/src/utils/index.ts b/web/src/utils/index.ts index 5877586..a9e9af7 100644 --- a/web/src/utils/index.ts +++ b/web/src/utils/index.ts @@ -1,195 +1,195 @@ -/** - * 深拷贝 - * @param { string } data 需要深拷贝的数据 - * @returns 深拷贝的数据 - */ -export function deepClone(data: any) { - let stack = []; - let cloned; - if (Array.isArray(data)) { - cloned = []; - } else if (typeof data === "object" && data !== null) { - cloned = {}; - } else { - return data; - } - stack.push({ - original: data, - copy: cloned - }); - while (stack.length > 0) { - let current: any = stack.pop(); - let original = current.original; - let copy = current.copy; - - for (let key in original) { - if (original.hasOwnProperty(key)) { - let value = original[key]; - - if (typeof value === "object" && value !== null) { - copy[key] = Array.isArray(value) ? [] : {}; - - stack.push({ - original: value, - copy: copy[key] - }); - } else { - copy[key] = value; - } - } - } - } - return cloned; -} - -/** - * 获取浏览器默认语言 - * @returns 语言类型 - */ -export const webDefaultLanguage = () => navigator.language; - -/** - * 时间戳转 年月日时分秒 - * 若timestamp不传则取当前时间 - * 若type不传则取 年月日时分秒 - * @param { number } timestamp 时间戳 - * @return 返回年月日时分秒字符串 - */ -export const getTimestamp = (timestamp: string | number | null, type: string) => { - let date = null; - if (timestamp) { - date = new Date(timestamp); - } else { - date = new Date(); - } - let Year = String(date.getFullYear()); - let Moth = String(date.getMonth() + 1).padStart(2, "0"); - let Day = String(date.getDate()).padStart(2, "0"); - let Hour = String(date.getHours()).padStart(2, "0"); - let Minute = String(date.getMinutes()).padStart(2, "0"); - let Seconds = String(date.getSeconds()).padStart(2, "0"); - if (type === "yyyy") { - return `${Year}`; - } - if (type === "yyyy-MM") { - return `${Year}-${Moth}`; - } - if (type === "yyyy-MM-dd") { - return `${Year}-${Moth}-${Day}`; - } - return `${Year}-${Moth}-${Day} ${Hour}:${Minute}:${Seconds}`; -}; - -/** - * 根据当前日期前推指定日期 - * @param { number } days 需要前推的天数 - * @return {Array[]} 是否为空对象 [前推天数的日期,当前日期] - */ -export const getDatesForwardDate = (days = 0) => { - const today = new Date(); - const firstDay: any = new Date(today); - firstDay.setDate(firstDay.getDate() - days); // 向前推指定天,得到前指定天数的第一天 - - const lastDay: any = new Date(today); - lastDay.setDate(lastDay.getDate() - 1); // 昨天是前指定天数的最后一天 - - const firstDayFormatted = getTimestamp(firstDay, "YYYY-MM-DD"); - const lastDayFormatted = getTimestamp(lastDay, "YYYY-MM-DD"); - return [firstDayFormatted, lastDayFormatted]; -}; - -/** - * 给formData循环添加参数,过滤null、undefined、空字符串、NaN - * 示例:let data = appendFormData(your-object); - * @param { object } obj 参数对象 - * @return 返回formData对象 - */ -export const appendFormData = (obj: any) => { - let formData = new FormData(); - function deepAppendFormData(formData: any, data: any, parentKey = "") { - if (Array.isArray(data) || (typeof data === "object" && data !== null)) { - // 如果数据是数组或对象,序列化为 JSON 字符串 - formData.append(parentKey, JSON.stringify(data)); - } else if (data !== null && data !== undefined && !Number.isNaN(data) && data !== "") { - // 如果数据是基本类型,直接添加 - formData.append(parentKey, data); - } - } - for (let key in obj) { - if (obj.hasOwnProperty(key)) { - deepAppendFormData(formData, obj[key], key); - } - } - deepAppendFormData(formData, obj); - return formData; -}; - -/** - * 判断是否为空对象 - * @param {object} obj 对象 - * @returns {boolean} 是否为空对象 - */ -export const isEmptyObject = (obj: object) => { - // 校验是否为对象且不为 null - if (typeof obj !== "object" || obj === null) { - return false; - } - return Object.keys(obj).length === 0 && obj.constructor === Object; -}; - -/** - * 判断是否为安全环境https或localhost - * @returns 是否为安全环境https或localhost - */ -export const isSecureEnvironment = () => { - const { protocol, hostname } = window.location; - - // 检查协议是否为HTTPS - const isHttps = protocol === "https:"; - - // 检查主机名是否为localhost或本地IP(支持IPv4和IPv6) - const isLocalhost = - hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "[::1]" || hostname === "::1"; - - return isHttps || isLocalhost; -}; - -/** - * 获取不同路由模式所对应的 url + params - * @returns {String} 返回路径 - */ -export const getUrlWithParams = () => { - type UrlParams = { - hash: string; - history: string; - }; - - if (typeof window === "undefined") return ""; - const url: UrlParams = { - hash: window.location.hash.substring(1), - history: window.location.pathname + window.location.search - }; - const mode = (import.meta.env.VITE_ROUTER_MODE as keyof UrlParams) || "history"; - return url[mode] || ""; -}; - -/** - * 下划线转驼峰 - * @param v 下划线字符串 - * @returns 驼峰字符串 - */ -export const getPascalCase = (v: string) => { - // 处理空字符串情况 - if (!v) return v; - - // 1. 替换所有下划线序列及其后的首个字符 - // - 正则 /_+(.)/g 匹配一个或多个下划线后紧跟的任意字符 - // - 替换函数将匹配的字符转为大写(字母则大写,非字母则原样保留) - let result = v.replace(/_+(.)/g, (_, char) => char.toUpperCase()); - - // 2. 删除开头和结尾剩余的下划线 - result = result.replace(/^_+|_+$/g, ""); - - // 3. 将首字母转为大写后返回 - return result.charAt(0).toUpperCase() + result.slice(1); -}; +/** + * 深拷贝 + * @param { string } data 需要深拷贝的数据 + * @returns 深拷贝的数据 + */ +export function deepClone(data: any) { + let stack = []; + let cloned; + if (Array.isArray(data)) { + cloned = []; + } else if (typeof data === "object" && data !== null) { + cloned = {}; + } else { + return data; + } + stack.push({ + original: data, + copy: cloned + }); + while (stack.length > 0) { + let current: any = stack.pop(); + let original = current.original; + let copy = current.copy; + + for (let key in original) { + if (original.hasOwnProperty(key)) { + let value = original[key]; + + if (typeof value === "object" && value !== null) { + copy[key] = Array.isArray(value) ? [] : {}; + + stack.push({ + original: value, + copy: copy[key] + }); + } else { + copy[key] = value; + } + } + } + } + return cloned; +} + +/** + * 获取浏览器默认语言 + * @returns 语言类型 + */ +export const webDefaultLanguage = () => navigator.language; + +/** + * 时间戳转 年月日时分秒 + * 若timestamp不传则取当前时间 + * 若type不传则取 年月日时分秒 + * @param { number } timestamp 时间戳 + * @return 返回年月日时分秒字符串 + */ +export const getTimestamp = (timestamp: string | number | null, type: string) => { + let date = null; + if (timestamp) { + date = new Date(timestamp); + } else { + date = new Date(); + } + let Year = String(date.getFullYear()); + let Moth = String(date.getMonth() + 1).padStart(2, "0"); + let Day = String(date.getDate()).padStart(2, "0"); + let Hour = String(date.getHours()).padStart(2, "0"); + let Minute = String(date.getMinutes()).padStart(2, "0"); + let Seconds = String(date.getSeconds()).padStart(2, "0"); + if (type === "yyyy") { + return `${Year}`; + } + if (type === "yyyy-MM") { + return `${Year}-${Moth}`; + } + if (type === "yyyy-MM-dd") { + return `${Year}-${Moth}-${Day}`; + } + return `${Year}-${Moth}-${Day} ${Hour}:${Minute}:${Seconds}`; +}; + +/** + * 根据当前日期前推指定日期 + * @param { number } days 需要前推的天数 + * @return {Array[]} 是否为空对象 [前推天数的日期,当前日期] + */ +export const getDatesForwardDate = (days = 0) => { + const today = new Date(); + const firstDay: any = new Date(today); + firstDay.setDate(firstDay.getDate() - days); // 向前推指定天,得到前指定天数的第一天 + + const lastDay: any = new Date(today); + lastDay.setDate(lastDay.getDate() - 1); // 昨天是前指定天数的最后一天 + + const firstDayFormatted = getTimestamp(firstDay, "YYYY-MM-DD"); + const lastDayFormatted = getTimestamp(lastDay, "YYYY-MM-DD"); + return [firstDayFormatted, lastDayFormatted]; +}; + +/** + * 给formData循环添加参数,过滤null、undefined、空字符串、NaN + * 示例:let data = appendFormData(your-object); + * @param { object } obj 参数对象 + * @return 返回formData对象 + */ +export const appendFormData = (obj: any) => { + let formData = new FormData(); + function deepAppendFormData(formData: any, data: any, parentKey = "") { + if (Array.isArray(data) || (typeof data === "object" && data !== null)) { + // 如果数据是数组或对象,序列化为 JSON 字符串 + formData.append(parentKey, JSON.stringify(data)); + } else if (data !== null && data !== undefined && !Number.isNaN(data) && data !== "") { + // 如果数据是基本类型,直接添加 + formData.append(parentKey, data); + } + } + for (let key in obj) { + if (obj.hasOwnProperty(key)) { + deepAppendFormData(formData, obj[key], key); + } + } + deepAppendFormData(formData, obj); + return formData; +}; + +/** + * 判断是否为空对象 + * @param {object} obj 对象 + * @returns {boolean} 是否为空对象 + */ +export const isEmptyObject = (obj: object) => { + // 校验是否为对象且不为 null + if (typeof obj !== "object" || obj === null) { + return false; + } + return Object.keys(obj).length === 0 && obj.constructor === Object; +}; + +/** + * 判断是否为安全环境https或localhost + * @returns 是否为安全环境https或localhost + */ +export const isSecureEnvironment = () => { + const { protocol, hostname } = window.location; + + // 检查协议是否为HTTPS + const isHttps = protocol === "https:"; + + // 检查主机名是否为localhost或本地IP(支持IPv4和IPv6) + const isLocalhost = + hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "[::1]" || hostname === "::1"; + + return isHttps || isLocalhost; +}; + +/** + * 获取不同路由模式所对应的 url + params + * @returns {String} 返回路径 + */ +export const getUrlWithParams = () => { + type UrlParams = { + hash: string; + history: string; + }; + + if (typeof window === "undefined") return ""; + const url: UrlParams = { + hash: window.location.hash.substring(1), + history: window.location.pathname + window.location.search + }; + const mode = (import.meta.env.VITE_ROUTER_MODE as keyof UrlParams) || "history"; + return url[mode] || ""; +}; + +/** + * 下划线转驼峰 + * @param v 下划线字符串 + * @returns 驼峰字符串 + */ +export const getPascalCase = (v: string) => { + // 处理空字符串情况 + if (!v) return v; + + // 1. 替换所有下划线序列及其后的首个字符 + // - 正则 /_+(.)/g 匹配一个或多个下划线后紧跟的任意字符 + // - 替换函数将匹配的字符转为大写(字母则大写,非字母则原样保留) + let result = v.replace(/_+(.)/g, (_, char) => char.toUpperCase()); + + // 2. 删除开头和结尾剩余的下划线 + result = result.replace(/^_+|_+$/g, ""); + + // 3. 将首字母转为大写后返回 + return result.charAt(0).toUpperCase() + result.slice(1); +}; diff --git a/web/src/utils/loading-page.ts b/web/src/utils/loading-page.ts index 470a95f..8c20bdc 100644 --- a/web/src/utils/loading-page.ts +++ b/web/src/utils/loading-page.ts @@ -1,29 +1,29 @@ -/** - * 全局加载 loading-page - * @method start 创建 loading - * @method done 移除 loading - */ -export const loadingPage = { - // 开始渲染loading - start: () => { - // 获取顶层body - // 将新创建的dc-loader元素(div)插入到body元素的子元素列表中的指定位置(在指定元素之前) - // 插入的位置是作为body元素的第一个子元素,即页面的最顶部位置 - const bodyDom: Element = document.body; - const div = document.createElement("div"); - div.className = "loading-page"; - const loader = document.createElement("div"); - loader.className = "dc-loader"; - div.appendChild(loader); - bodyDom.insertBefore(div, bodyDom.firstChild); - }, - // 结束渲染loading - done: (time: number = 0) => { - setTimeout(() => { - // 找到第一个匹配对象 - // 找到loading-page的父节点,移除loading-page - const dom = document.querySelector(".loading-page"); - dom?.parentNode?.removeChild(dom); - }, time); - } -}; +/** + * 全局加载 loading-page + * @method start 创建 loading + * @method done 移除 loading + */ +export const loadingPage = { + // 开始渲染loading + start: () => { + // 获取顶层body + // 将新创建的dc-loader元素(div)插入到body元素的子元素列表中的指定位置(在指定元素之前) + // 插入的位置是作为body元素的第一个子元素,即页面的最顶部位置 + const bodyDom: Element = document.body; + const div = document.createElement("div"); + div.className = "loading-page"; + const loader = document.createElement("div"); + loader.className = "dc-loader"; + div.appendChild(loader); + bodyDom.insertBefore(div, bodyDom.firstChild); + }, + // 结束渲染loading + done: (time: number = 0) => { + setTimeout(() => { + // 找到第一个匹配对象 + // 找到loading-page的父节点,移除loading-page + const dom = document.querySelector(".loading-page"); + dom?.parentNode?.removeChild(dom); + }, time); + } +}; diff --git a/web/src/utils/px2px.ts b/web/src/utils/px2px.ts index bb71b17..e46a6fe 100644 --- a/web/src/utils/px2px.ts +++ b/web/src/utils/px2px.ts @@ -1,15 +1,15 @@ -/** - * px转响应式px - * 示例:$px2px(20, 1920),在1920px的设计稿上元素大小为20px,若在其它窗口大小下,会根据窗口大小自动缩放 - * @param {number} px 设计稿元素大小 - * @param {number} viewport 设计稿窗口大小 - * @returns {number} 响应式px - */ -export const px2px = (px: number, viewport: number): number => { - const viewportWidth: number = (window.innerWidth || document.documentElement.clientWidth) as number; - let originalWidth = px; - let originalViewport = viewport; - // 计算新视口下的宽度 - let newWidth = (originalWidth / originalViewport) * viewportWidth; - return parseInt(String(newWidth)); -}; +/** + * px转响应式px + * 示例:$px2px(20, 1920),在1920px的设计稿上元素大小为20px,若在其它窗口大小下,会根据窗口大小自动缩放 + * @param {number} px 设计稿元素大小 + * @param {number} viewport 设计稿窗口大小 + * @returns {number} 响应式px + */ +export const px2px = (px: number, viewport: number): number => { + const viewportWidth: number = (window.innerWidth || document.documentElement.clientWidth) as number; + let originalWidth = px; + let originalViewport = viewport; + // 计算新视口下的宽度 + let newWidth = (originalWidth / originalViewport) * viewportWidth; + return parseInt(String(newWidth)); +}; diff --git a/web/src/utils/testRoute.ts b/web/src/utils/testRoute.ts index d77bb6c..1051f03 100644 --- a/web/src/utils/testRoute.ts +++ b/web/src/utils/testRoute.ts @@ -1,117 +1,117 @@ -/** - * @description: 测试多级菜单 - */ -export const testMultilevelMenu = [ - { - path: "/multilevel-menu/third-menu-3", - name: "third-menu-3", - component: () => import("@/views/multilevel-menu/third-menu/third-menu-3.vue"), - meta: { - title: "third-menu-3", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 3 - } - }, - { - path: "/multilevel-menu/third-menu-4", - name: "third-menu-4", - component: () => import("@/views/multilevel-menu/third-menu/third-menu-4.vue"), - meta: { - title: "third-menu-4", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 4 - } - }, - { - path: "/multilevel-menu/third-menu-5", - name: "third-menu-5", - component: () => import("@/views/multilevel-menu/third-menu/third-menu-5.vue"), - meta: { - title: "third-menu-5", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 5 - } - }, - { - path: "/multilevel-menu/third-menu-6", - name: "third-menu-6", - component: () => import("@/views/multilevel-menu/third-menu/third-menu-6.vue"), - meta: { - title: "third-menu-6", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 6 - } - }, - { - path: "/multilevel-menu/third-menu-7", - name: "third-menu-7", - component: () => import("@/views/multilevel-menu/third-menu/third-menu-7.vue"), - meta: { - title: "third-menu-7", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 7 - } - }, - { - path: "/multilevel-menu/third-menu-8", - name: "third-menu-8", - component: () => import("@/views/multilevel-menu/third-menu/third-menu-8.vue"), - meta: { - title: "third-menu-8", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 8 - } - }, - { - path: "/multilevel-menu/third-menu-9", - name: "third-menu-9", - component: () => import("@/views/multilevel-menu/third-menu/third-menu-9.vue"), - meta: { - title: "third-menu-9", - link: "", - hide: false, - keepAlive: true, - affix: false, - iframe: false, - roles: ["admin"], - icon: "icon-menu", - sort: 9 - } - } -]; +/** + * @description: 测试多级菜单 + */ +export const testMultilevelMenu = [ + { + path: "/multilevel-menu/third-menu-3", + name: "third-menu-3", + component: () => import("@/views/multilevel-menu/third-menu/third-menu-3.vue"), + meta: { + title: "third-menu-3", + link: "", + hide: false, + keepAlive: true, + affix: false, + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 3 + } + }, + { + path: "/multilevel-menu/third-menu-4", + name: "third-menu-4", + component: () => import("@/views/multilevel-menu/third-menu/third-menu-4.vue"), + meta: { + title: "third-menu-4", + link: "", + hide: false, + keepAlive: true, + affix: false, + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 4 + } + }, + { + path: "/multilevel-menu/third-menu-5", + name: "third-menu-5", + component: () => import("@/views/multilevel-menu/third-menu/third-menu-5.vue"), + meta: { + title: "third-menu-5", + link: "", + hide: false, + keepAlive: true, + affix: false, + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 5 + } + }, + { + path: "/multilevel-menu/third-menu-6", + name: "third-menu-6", + component: () => import("@/views/multilevel-menu/third-menu/third-menu-6.vue"), + meta: { + title: "third-menu-6", + link: "", + hide: false, + keepAlive: true, + affix: false, + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 6 + } + }, + { + path: "/multilevel-menu/third-menu-7", + name: "third-menu-7", + component: () => import("@/views/multilevel-menu/third-menu/third-menu-7.vue"), + meta: { + title: "third-menu-7", + link: "", + hide: false, + keepAlive: true, + affix: false, + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 7 + } + }, + { + path: "/multilevel-menu/third-menu-8", + name: "third-menu-8", + component: () => import("@/views/multilevel-menu/third-menu/third-menu-8.vue"), + meta: { + title: "third-menu-8", + link: "", + hide: false, + keepAlive: true, + affix: false, + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 8 + } + }, + { + path: "/multilevel-menu/third-menu-9", + name: "third-menu-9", + component: () => import("@/views/multilevel-menu/third-menu/third-menu-9.vue"), + meta: { + title: "third-menu-9", + link: "", + hide: false, + keepAlive: true, + affix: false, + iframe: false, + roles: ["admin"], + icon: "icon-menu", + sort: 9 + } + } +]; diff --git a/web/src/views/error/401.vue b/web/src/views/error/401.vue index 7d9a9d9..8701716 100644 --- a/web/src/views/error/401.vue +++ b/web/src/views/error/401.vue @@ -1,49 +1,49 @@ - - - - - + + + + + diff --git a/web/src/views/error/404.vue b/web/src/views/error/404.vue index 2eabf03..510dbdb 100644 --- a/web/src/views/error/404.vue +++ b/web/src/views/error/404.vue @@ -1,49 +1,49 @@ - - - - - + + + + + diff --git a/web/src/views/error/500.vue b/web/src/views/error/500.vue index ca200b9..165f2db 100644 --- a/web/src/views/error/500.vue +++ b/web/src/views/error/500.vue @@ -1,55 +1,55 @@ - - - - - + + + + + diff --git a/web/src/views/home/components/analysis-chart.vue b/web/src/views/home/components/analysis-chart.vue index 9f937f6..178a58d 100644 --- a/web/src/views/home/components/analysis-chart.vue +++ b/web/src/views/home/components/analysis-chart.vue @@ -1,192 +1,192 @@ - - - - - + + + + + diff --git a/web/src/views/home/components/data-box.vue b/web/src/views/home/components/data-box.vue index cdbd74a..9db73b9 100644 --- a/web/src/views/home/components/data-box.vue +++ b/web/src/views/home/components/data-box.vue @@ -1,87 +1,87 @@ - - - - - + + + + + diff --git a/web/src/views/home/components/finance.vue b/web/src/views/home/components/finance.vue index ccf4890..359161d 100644 --- a/web/src/views/home/components/finance.vue +++ b/web/src/views/home/components/finance.vue @@ -1,145 +1,145 @@ - - - - - + + + + + diff --git a/web/src/views/home/components/histogram-chart.vue b/web/src/views/home/components/histogram-chart.vue index 1e3ce7d..7035eaf 100644 --- a/web/src/views/home/components/histogram-chart.vue +++ b/web/src/views/home/components/histogram-chart.vue @@ -1,222 +1,222 @@ - - - - - + + + + + diff --git a/web/src/views/home/home.vue b/web/src/views/home/home.vue index 16bc1b8..dfe3cbf 100644 --- a/web/src/views/home/home.vue +++ b/web/src/views/home/home.vue @@ -1,273 +1,273 @@ - - - - - + + + + + diff --git a/web/src/views/login/components/login-banner.vue b/web/src/views/login/components/login-banner.vue index 500e3f4..39be57a 100644 --- a/web/src/views/login/components/login-banner.vue +++ b/web/src/views/login/components/login-banner.vue @@ -1,39 +1,39 @@ - - - - + + + + diff --git a/web/src/views/login/components/login-form.vue b/web/src/views/login/components/login-form.vue index e5ca8ce..03198d4 100644 --- a/web/src/views/login/components/login-form.vue +++ b/web/src/views/login/components/login-form.vue @@ -1,162 +1,162 @@ - - - - - + + + + + diff --git a/web/src/views/login/login.vue b/web/src/views/login/login.vue index 7176a5e..285d9a3 100644 --- a/web/src/views/login/login.vue +++ b/web/src/views/login/login.vue @@ -1,60 +1,60 @@ - - - - + + + + diff --git a/web/src/views/order/config.ts b/web/src/views/order/config.ts index acc77fe..0e3e91a 100644 --- a/web/src/views/order/config.ts +++ b/web/src/views/order/config.ts @@ -1,64 +1,64 @@ -interface List { - id: number; - order_id: string; - trade_id: string; - trade_type: string; - rate: string; - amount: string; - money: number; - address: string; - from_address: string; - status: number; - name: string; - api_type: string; - return_url: string; - notify_url: string; - notify_num: number; - notify_state: number; - ref_hash: string; - ref_block_num: number; - expired_at: string; - confirmed_at?: string; - created_at?: string; - updated_at?: string; -} - -interface FormData { - form: { - order_id: string; - trade_id: string; - trade_type: string; - address: string; - status?: number; - createTime: string[]; - }; - search: boolean; -} - -interface AddForm { - name: string; - address: string; - trade_type: string; - remark: string; - other_notify: number; -} - -interface ModForm { - id: number; - name: string; - status: number; - address: string; - trade_type: string; - remark: string; - other_notify: number; -} - -interface Pagination { - showPageSize: boolean; - showTotal: boolean; - current: number; - pageSize: number; - total: number; -} - -export type { List, FormData, Pagination, AddForm, ModForm }; +interface List { + id: number; + order_id: string; + trade_id: string; + trade_type: string; + rate: string; + amount: string; + money: number; + address: string; + from_address: string; + status: number; + name: string; + api_type: string; + return_url: string; + notify_url: string; + notify_num: number; + notify_state: number; + ref_hash: string; + ref_block_num: number; + expired_at: string; + confirmed_at?: string; + created_at?: string; + updated_at?: string; +} + +interface FormData { + form: { + order_id: string; + trade_id: string; + trade_type: string; + address: string; + status?: number; + createTime: string[]; + }; + search: boolean; +} + +interface AddForm { + name: string; + address: string; + trade_type: string; + remark: string; + other_notify: number; +} + +interface ModForm { + id: number; + name: string; + status: number; + address: string; + trade_type: string; + remark: string; + other_notify: number; +} + +interface Pagination { + showPageSize: boolean; + showTotal: boolean; + current: number; + pageSize: number; + total: number; +} + +export type { List, FormData, Pagination, AddForm, ModForm }; diff --git a/web/src/views/order/order.vue b/web/src/views/order/order.vue index f4a9777..8e38d76 100644 --- a/web/src/views/order/order.vue +++ b/web/src/views/order/order.vue @@ -1,433 +1,433 @@ - - - - - + + + + + diff --git a/web/src/views/rate/list.ts b/web/src/views/rate/list.ts index e5a0372..9edaf11 100644 --- a/web/src/views/rate/list.ts +++ b/web/src/views/rate/list.ts @@ -1,46 +1,46 @@ -interface List { - id: number; - fiat: string; - crypto: string; - rate: number; - raw_rate: number; - created_at: string; - key?: string; -} - -interface FormData { - form: { - fiat: string; - crypto: string; - datetime: string[]; - }; - search: boolean; -} - -interface AddForm { - name: string; - address: string; - trade_type: string; - remark: string; - other_notify: number; -} - -interface ModForm { - id: number; - name: string; - status: number; - address: string; - trade_type: string; - remark: string; - other_notify: number; -} - -interface Pagination { - showPageSize: boolean; - showTotal: boolean; - current: number; - pageSize: number; - total: number; -} - -export type { List, FormData, Pagination, AddForm, ModForm }; +interface List { + id: number; + fiat: string; + crypto: string; + rate: number; + raw_rate: number; + created_at: string; + key?: string; +} + +interface FormData { + form: { + fiat: string; + crypto: string; + datetime: string[]; + }; + search: boolean; +} + +interface AddForm { + name: string; + address: string; + trade_type: string; + remark: string; + other_notify: number; +} + +interface ModForm { + id: number; + name: string; + status: number; + address: string; + trade_type: string; + remark: string; + other_notify: number; +} + +interface Pagination { + showPageSize: boolean; + showTotal: boolean; + current: number; + pageSize: number; + total: number; +} + +export type { List, FormData, Pagination, AddForm, ModForm }; diff --git a/web/src/views/rate/list.vue b/web/src/views/rate/list.vue index 7dd3297..0d956be 100644 --- a/web/src/views/rate/list.vue +++ b/web/src/views/rate/list.vue @@ -1,184 +1,184 @@ - - - - - + + + + + diff --git a/web/src/views/rate/syntax.ts b/web/src/views/rate/syntax.ts index 3e5ef0a..2dd0df3 100644 --- a/web/src/views/rate/syntax.ts +++ b/web/src/views/rate/syntax.ts @@ -1,12 +1,12 @@ -interface List { - key: string; - fiat: string; - crypto: string; - syntax: string; -} -interface EditForm { - fiat: string; - crypto: string; - syntax: string; -} -export type { List, EditForm }; +interface List { + key: string; + fiat: string; + crypto: string; + syntax: string; +} +interface EditForm { + fiat: string; + crypto: string; + syntax: string; +} +export type { List, EditForm }; diff --git a/web/src/views/rate/syntax.vue b/web/src/views/rate/syntax.vue index af3feeb..2e8c471 100644 --- a/web/src/views/rate/syntax.vue +++ b/web/src/views/rate/syntax.vue @@ -1,777 +1,777 @@ - - - - - + + + + + diff --git a/web/src/views/wallet/config.ts b/web/src/views/wallet/config.ts index b4e9d44..41486f2 100644 --- a/web/src/views/wallet/config.ts +++ b/web/src/views/wallet/config.ts @@ -1,47 +1,47 @@ -interface List { - id: number; - name: string; - address: string; - status: number; - createTime: string; - trade_type?: string; - remark?: string; - other_notify?: number; -} - -interface FormData { - form: { - name: string; - address: string; - trade_type: string; - }; - search: boolean; -} - -interface AddForm { - name: string; - address: string; - trade_type: string; - remark: string; - other_notify: number; -} - -interface ModForm { - id: number; - name: string; - status: number; - address: string; - trade_type: string; - remark: string; - other_notify: number; -} - -interface Pagination { - showPageSize: boolean; - showTotal: boolean; - current: number; - pageSize: number; - total: number; -} - -export type { List, FormData, Pagination, AddForm, ModForm }; +interface List { + id: number; + name: string; + address: string; + status: number; + createTime: string; + trade_type?: string; + remark?: string; + other_notify?: number; +} + +interface FormData { + form: { + name: string; + address: string; + trade_type: string; + }; + search: boolean; +} + +interface AddForm { + name: string; + address: string; + trade_type: string; + remark: string; + other_notify: number; +} + +interface ModForm { + id: number; + name: string; + status: number; + address: string; + trade_type: string; + remark: string; + other_notify: number; +} + +interface Pagination { + showPageSize: boolean; + showTotal: boolean; + current: number; + pageSize: number; + total: number; +} + +export type { List, FormData, Pagination, AddForm, ModForm }; diff --git a/web/src/views/wallet/wallet.vue b/web/src/views/wallet/wallet.vue index 850402e..01654c7 100644 --- a/web/src/views/wallet/wallet.vue +++ b/web/src/views/wallet/wallet.vue @@ -1,652 +1,652 @@ - - - - - + + + + + diff --git a/web/src/vite-env.d.ts b/web/src/vite-env.d.ts index 859f9d5..55dbcb3 100644 --- a/web/src/vite-env.d.ts +++ b/web/src/vite-env.d.ts @@ -1,26 +1,26 @@ -/// -declare module "*.vue" { - import { DefineComponent } from "vue"; - const component: DefineComponent; - export default component; -} -declare module "vue-i18n"; -declare module "@arco-design/color"; -declare module "sortablejs"; -declare module "vue-codemirror6"; -declare module "@codemirror/theme-one-dark"; -declare module "@codemirror/lang-json"; -declare module "@codemirror/lang-javascript"; -declare module "@codemirror/lang-vue"; -declare module "nprogress"; -declare module "@wangeditor/editor-for-vue"; -declare module "@/directives/modules/custom"; -declare module "mockjs"; -declare module "@/store/modules/route-config"; -declare module "fingerprintjs2"; -declare module "@arco-design/web-vue"; -declare module "vue-router"; -declare module "pinia"; -declare module "postcss-preset-env"; -declare module "qrcode"; -declare module "vue-virtual-scroller"; +/// +declare module "*.vue" { + import { DefineComponent } from "vue"; + const component: DefineComponent; + export default component; +} +declare module "vue-i18n"; +declare module "@arco-design/color"; +declare module "sortablejs"; +declare module "vue-codemirror6"; +declare module "@codemirror/theme-one-dark"; +declare module "@codemirror/lang-json"; +declare module "@codemirror/lang-javascript"; +declare module "@codemirror/lang-vue"; +declare module "nprogress"; +declare module "@wangeditor/editor-for-vue"; +declare module "@/directives/modules/custom"; +declare module "mockjs"; +declare module "@/store/modules/route-config"; +declare module "fingerprintjs2"; +declare module "@arco-design/web-vue"; +declare module "vue-router"; +declare module "pinia"; +declare module "postcss-preset-env"; +declare module "qrcode"; +declare module "vue-virtual-scroller"; diff --git a/web/tsconfig.json b/web/tsconfig.json index a68955b..c528bd6 100644 --- a/web/tsconfig.json +++ b/web/tsconfig.json @@ -1,48 +1,48 @@ -{ - // 编译选项 - "compilerOptions": { - /* ES */ - "target": "ESNext", // 指定ECMAScript目标版本 - "module": "ESNext", // 设置程序的模块系统 - "lib": ["ESNext", "DOM"], //TS需要引用的库,即声明文件,es5 默认引用dom、es5、scripthost,如需要使用es的高级版本特性,通常都需要配置,如es8的数组新特性需要引入"ES2019.Array", - "allowJs": true, // 允许编译 javascript 文件 - "checkJs": true, // 报告 javascript 文件中的错误 - - /* 模块解析 */ - "moduleResolution": "node", //模块解析策略。默认使用node的模块解析策略 - "allowImportingTsExtensions": true, // 允许导入包含 TypeScript 文档扩展名。 - "resolveJsonModule": true, //允许导入扩展名为".json"的模块 - "sourceMap": true, // 是否生成相应的Map映射的文件,默认:false - // "isolatedModules": true, //将每个文件作为单独的模块(与"ts.transpileModule"类似)。 - "noEmit": true, // 不输出文件,即编译后不会生成任何js文件 - "jsx": "preserve", //preserve模式,在preserve模式下生成代码中会保留JSX以供后续的转换操作使用 - - /* 类型检查 */ - "strict": true, //启用所有严格类型检查选项 - "noUnusedLocals": true, // 若有未使用的局部变量则抛错 - "noUnusedParameters": true, // 检若有未使用的函数参数则抛错 - "noFallthroughCasesInSwitch": true, // 防止switch语句贯穿(即如果没有break语句后面不会执行) - "esModuleInterop": true, // 是否通过为所有导入模块创建命名空间对象,允许CommonJS和ES模块之间的互操作性,开启改选项时,也自动开启allowSyntheticDefaultImports选项,默认:false - "skipLibCheck": true, //忽略所有的声明文件( *.d.ts)的类型检查 - - /* path */ - "baseUrl": "./", // 解析非相对模块的基地址,默认是当前目录 - "paths": { - // 模块名到基于 baseUrl的路径映射的列表 - "@/*": ["src/*"] - } - }, - // include也可以指定要编译的路径列表,这里的路径可以是文件夹,也可以是文件,可以使用相对和绝对路径,而且可以使用通配符,比如"./src"即表示要编译src文件夹下的所有文件以及子文件夹的文件 - "include": [ - "src/**/*", - "src/**/*.ts", - "src/**/*.tsx", - "src/**/*.vue", - "src/auto-import.d.ts", // 与vite.config.ts-AutoImport-dts路径一致 - "build/**/*.ts", - "build/**/*.d.ts", - "vite.config.ts" - ], // 指定被编译文件所在的目录 - // exclude表示要排除的、不编译的文件,它也可以指定一个列表,规则和include一样,可以是文件或文件夹,可以是相对路径或绝对路径,可以使用通配符 - "exclude": ["node_modules", "dist", "**/*.js"] // 指定不需要被编译的目录 -} +{ + // 编译选项 + "compilerOptions": { + /* ES */ + "target": "ESNext", // 指定ECMAScript目标版本 + "module": "ESNext", // 设置程序的模块系统 + "lib": ["ESNext", "DOM"], //TS需要引用的库,即声明文件,es5 默认引用dom、es5、scripthost,如需要使用es的高级版本特性,通常都需要配置,如es8的数组新特性需要引入"ES2019.Array", + "allowJs": true, // 允许编译 javascript 文件 + "checkJs": true, // 报告 javascript 文件中的错误 + + /* 模块解析 */ + "moduleResolution": "node", //模块解析策略。默认使用node的模块解析策略 + "allowImportingTsExtensions": true, // 允许导入包含 TypeScript 文档扩展名。 + "resolveJsonModule": true, //允许导入扩展名为".json"的模块 + "sourceMap": true, // 是否生成相应的Map映射的文件,默认:false + // "isolatedModules": true, //将每个文件作为单独的模块(与"ts.transpileModule"类似)。 + "noEmit": true, // 不输出文件,即编译后不会生成任何js文件 + "jsx": "preserve", //preserve模式,在preserve模式下生成代码中会保留JSX以供后续的转换操作使用 + + /* 类型检查 */ + "strict": true, //启用所有严格类型检查选项 + "noUnusedLocals": true, // 若有未使用的局部变量则抛错 + "noUnusedParameters": true, // 检若有未使用的函数参数则抛错 + "noFallthroughCasesInSwitch": true, // 防止switch语句贯穿(即如果没有break语句后面不会执行) + "esModuleInterop": true, // 是否通过为所有导入模块创建命名空间对象,允许CommonJS和ES模块之间的互操作性,开启改选项时,也自动开启allowSyntheticDefaultImports选项,默认:false + "skipLibCheck": true, //忽略所有的声明文件( *.d.ts)的类型检查 + + /* path */ + "baseUrl": "./", // 解析非相对模块的基地址,默认是当前目录 + "paths": { + // 模块名到基于 baseUrl的路径映射的列表 + "@/*": ["src/*"] + } + }, + // include也可以指定要编译的路径列表,这里的路径可以是文件夹,也可以是文件,可以使用相对和绝对路径,而且可以使用通配符,比如"./src"即表示要编译src文件夹下的所有文件以及子文件夹的文件 + "include": [ + "src/**/*", + "src/**/*.ts", + "src/**/*.tsx", + "src/**/*.vue", + "src/auto-import.d.ts", // 与vite.config.ts-AutoImport-dts路径一致 + "build/**/*.ts", + "build/**/*.d.ts", + "vite.config.ts" + ], // 指定被编译文件所在的目录 + // exclude表示要排除的、不编译的文件,它也可以指定一个列表,规则和include一样,可以是文件或文件夹,可以是相对路径或绝对路径,可以使用通配符 + "exclude": ["node_modules", "dist", "**/*.js"] // 指定不需要被编译的目录 +} diff --git a/web/vite.config.ts b/web/vite.config.ts index 0374954..0de9b7d 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -1,100 +1,100 @@ -import { defineConfig, loadEnv } from "vite"; -import path from "path"; -import { resolve } from "path"; -import { include } from "./build/optimize"; -import postcssPresetEnv from "postcss-preset-env"; -import { createVitePlugins } from "./build/vite-plugin"; -import fs from "fs"; -// const themePath = normalizePath(path.normalize("./src/style/global-theme.scss")); - -// https://vitejs.dev/config/ -export default defineConfig(({ mode }) => { - // 根路径 - const root = process.cwd(); - // 获取跟路径对应的文件 - const env: any = loadEnv(mode, root); - return { - // 生产环境服务的公共基础路径-用于生出环境的代理的路径 - base: env.VITE_PUBLIC_PATH, - server: { - // host: "0.0.0.0", - open: false, - // 为开发服务器配置自定义代理规则-用于开发时的代理 - proxy: { - "/api": { - target: env.VITE_APP_BASE_URL, - changeOrigin: true - } - }, - allowedHosts: [".localhost"] - }, - // 插件:路径build/vite-plugin - plugins: [ - ...createVitePlugins(env), - { - name: "rename-index", - closeBundle() { - const indexPath = path.join(__dirname, "dist/index.html"); - const securePath = path.join(__dirname, "dist/secure.html"); - if (fs.existsSync(indexPath)) { - fs.renameSync(indexPath, securePath); - } - } - } - ], - resolve: { - // 配置别名-绝对路径 - alias: { - "@assets": path.join(__dirname, "src/assets"), - "@": resolve(__dirname, "./src") - } - }, - css: { - postcss: { - plugins: [postcssPresetEnv()] - }, - preprocessorOptions: { - scss: { - // additionalData的内容会在每个scss文件的开头自动注入 - additionalData: `@use "@/style/var/index.scss" as *; ` - } - } - }, - // 依赖预加载 https://cn.vitejs.dev/config/dep-optimization-options.html#dep-optimization-options - optimizeDeps: { - include - }, - build: { - outDir: "dist", // 指定打包路径,默认为项目根目录下的dist目录 - // minify: "esbuild", // esbuild打包更快但是不能去除console.log,terser打包慢但能去除console.log - minify: "terser", // Vite 2.6.x 以上需要配置 minify:"terser",terserOptions才能生效,terser可以去除 console.log - terserOptions: { - compress: { - keep_infinity: true, // 防止 Infinity 被压缩成 1/0,这可能会导致 Chrome 上的性能问题 - drop_console: true, // 生产环境去除 console - drop_debugger: true // 生产环境去除 debugger - }, - format: { - comments: true // 删除注释 - } - }, - assetsInlineLimit: 50 * 1024, // 打包内联阈值100kb - chunkSizeWarningLimit: 10000, // 规定触发警告的 chunk 大小, 这里设置阈值为50kb, 消除打包大小超过500kb警告 - // 静态资源打包到dist下的不同目录,将文件类型css、js、jpg等文件分开存储 - rollupOptions: { - output: { - chunkFileNames: chunkInfo => { - // 自定义文件命名,避免下划线开头 - const name = chunkInfo.name; - if (name.startsWith("_")) { - return `assets/js/helper-${name.slice(1)}-[hash].js`; - } - return "assets/js/[name]-[hash].js"; - }, - entryFileNames: "assets/js/[name]-[hash].js", - assetFileNames: "assets/[ext]/[name]-[hash].[ext]" - } - } - } - }; -}); +import { defineConfig, loadEnv } from "vite"; +import path from "path"; +import { resolve } from "path"; +import { include } from "./build/optimize"; +import postcssPresetEnv from "postcss-preset-env"; +import { createVitePlugins } from "./build/vite-plugin"; +import fs from "fs"; +// const themePath = normalizePath(path.normalize("./src/style/global-theme.scss")); + +// https://vitejs.dev/config/ +export default defineConfig(({ mode }) => { + // 根路径 + const root = process.cwd(); + // 获取跟路径对应的文件 + const env: any = loadEnv(mode, root); + return { + // 生产环境服务的公共基础路径-用于生出环境的代理的路径 + base: env.VITE_PUBLIC_PATH, + server: { + // host: "0.0.0.0", + open: false, + // 为开发服务器配置自定义代理规则-用于开发时的代理 + proxy: { + "/api": { + target: env.VITE_APP_BASE_URL, + changeOrigin: true + } + }, + allowedHosts: [".localhost"] + }, + // 插件:路径build/vite-plugin + plugins: [ + ...createVitePlugins(env), + { + name: "rename-index", + closeBundle() { + const indexPath = path.join(__dirname, "dist/index.html"); + const securePath = path.join(__dirname, "dist/secure.html"); + if (fs.existsSync(indexPath)) { + fs.renameSync(indexPath, securePath); + } + } + } + ], + resolve: { + // 配置别名-绝对路径 + alias: { + "@assets": path.join(__dirname, "src/assets"), + "@": resolve(__dirname, "./src") + } + }, + css: { + postcss: { + plugins: [postcssPresetEnv()] + }, + preprocessorOptions: { + scss: { + // additionalData的内容会在每个scss文件的开头自动注入 + additionalData: `@use "@/style/var/index.scss" as *; ` + } + } + }, + // 依赖预加载 https://cn.vitejs.dev/config/dep-optimization-options.html#dep-optimization-options + optimizeDeps: { + include + }, + build: { + outDir: "dist", // 指定打包路径,默认为项目根目录下的dist目录 + // minify: "esbuild", // esbuild打包更快但是不能去除console.log,terser打包慢但能去除console.log + minify: "terser", // Vite 2.6.x 以上需要配置 minify:"terser",terserOptions才能生效,terser可以去除 console.log + terserOptions: { + compress: { + keep_infinity: true, // 防止 Infinity 被压缩成 1/0,这可能会导致 Chrome 上的性能问题 + drop_console: true, // 生产环境去除 console + drop_debugger: true // 生产环境去除 debugger + }, + format: { + comments: true // 删除注释 + } + }, + assetsInlineLimit: 50 * 1024, // 打包内联阈值100kb + chunkSizeWarningLimit: 10000, // 规定触发警告的 chunk 大小, 这里设置阈值为50kb, 消除打包大小超过500kb警告 + // 静态资源打包到dist下的不同目录,将文件类型css、js、jpg等文件分开存储 + rollupOptions: { + output: { + chunkFileNames: chunkInfo => { + // 自定义文件命名,避免下划线开头 + const name = chunkInfo.name; + if (name.startsWith("_")) { + return `assets/js/helper-${name.slice(1)}-[hash].js`; + } + return "assets/js/[name]-[hash].js"; + }, + entryFileNames: "assets/js/[name]-[hash].js", + assetFileNames: "assets/[ext]/[name]-[hash].[ext]" + } + } + } + }; +});