Compare commits

..

61 Commits

Author SHA1 Message Date
xiaoxian521
307944cdb5 release: update 3.6.1 2022-10-27 02:42:33 +08:00
xiaoxian521
f5a75356df feat: 打包构建添加可选 gzipbrotli 压缩模式 2022-10-27 02:35:56 +08:00
xiaoxian521
54ebd19875 feat: 添加打包是否启动cdn替换本地库配置,默认false不启动 2022-10-26 19:44:44 +08:00
xiaoxian521
303fc25af3 fix: 修复路由中父级name不应和子级name重复,会造成重定向跳转404问题 2022-10-26 11:09:33 +08:00
xiaoxian521
a455072d7a chore: update axios latest 2022-10-26 00:16:34 +08:00
xiaoxian521
2bbf04b191 chore: update 2022-10-25 17:36:35 +08:00
xiaoxian521
e4c33a7d22 fix: 修复title过长显示样式问题 2022-10-25 15:50:18 +08:00
xiaoxian521
6765ce8644 workflow: update 2022-10-25 13:33:31 +08:00
xiaoxian521
2d639c8f48 release: update 3.6.0 2022-10-25 13:07:18 +08:00
RealityBoy
6ef4cf9fb6 refactor: permission (#357)
* refactor: permission

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* fix: 修复`mix`混合模式导航在生产环境左侧菜单一定机率不显示的问题

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update
2022-10-25 12:17:13 +08:00
xiaoxian521
cedc84d31a chore: update @pureadmin/utils latest 2022-10-20 23:17:42 +08:00
xiaoxian521
f0af6bf830 types: update shims-vue.d.ts 2022-10-20 12:48:38 +08:00
xiaoxian521
a209f49be5 chore: update 2022-10-19 23:48:53 +08:00
xiaoxian521
8b44336779 chore: update 2022-10-19 23:31:05 +08:00
xiaoxian521
7bd7ea34ad feat: 添加json编辑器demo 2022-10-19 23:24:02 +08:00
xiaoxian521
5dbba0f3ff feat: 添加打字机组件demo 2022-10-19 18:54:26 +08:00
xiaoxian521
f9cf804627 chore: update @pureadmin/utils latest 2022-10-19 17:01:25 +08:00
xiaoxian521
b871d8528e perf: 优化登录回车事件 2022-10-19 14:11:12 +08:00
xiaoxian521
fc33e7e3f2 style: update 2022-10-19 12:56:43 +08:00
xiaoxian521
47e296c861 chore: update 2022-10-18 22:17:46 +08:00
xiaoxian521
5bce4dfa6a fix: 修复horizontal模式下menu在生产环境显示问题 2022-10-18 19:16:17 +08:00
xiaoxian521
e50d13a84a fix: 修复清空缓存并返回登录页时未清空主题 2022-10-18 18:51:08 +08:00
xiaoxian521
b1bce9f4ce feat: 添加文件下载demo 2022-10-18 17:54:17 +08:00
xiaoxian521
aae35ff5d9 chore: update @pureadmin/utils 2022-10-17 12:46:30 +08:00
xiaoxian521
2cc1d8d736 chore: update debounce demo 2022-10-16 15:29:03 +08:00
xiaoxian521
b6f0e7736c chore: update 2022-10-08 19:00:16 +08:00
xiaoxian521
89bf050f70 chore: update 2022-10-01 20:06:48 +08:00
xiaoxian521
6f0b44d959 chore: 升级、优化@pureadmin/utils里的isUrl函数 2022-09-20 15:50:47 +08:00
xiaoxian521
0e87633c8b style: 样式优化 2022-09-18 19:58:42 +08:00
xiaoxian521
e349c469fa chore: update 2022-09-18 14:54:35 +08:00
xiaoxian521
0af0f8c447 style: perf dark model 2022-09-17 12:42:30 +08:00
RealityBoy
c119328176 perf: 优化页面布局 (#349)
* perf: 优化页面布局

* fix: update
2022-09-17 11:52:46 +08:00
xiaoxian521
4d1a9ea8e7 chore: update 2022-09-15 14:41:46 +08:00
xiaoxian521
af25f6ca6e chore: update extensions.json 2022-09-13 17:55:46 +08:00
xiaoxian521
2231b88f6d chore: update 2022-09-12 23:10:59 +08:00
xiaoxian521
685d7beb11 chore: 优化样式 2022-09-11 19:46:53 +08:00
xiaoxian521
f14889ef56 perf: 使用/** */替换//注释,对编辑器的智能提示更友好 2022-09-11 16:46:01 +08:00
xiaoxian521
fafbdc7c69 perf: 从tailwind.css中移除不常用的@apply 2022-09-11 11:32:10 +08:00
xiaoxian521
ad6ced45cc release: update 3.5.0 2022-09-10 21:44:17 +08:00
xiaoxian521
3d96b9acd4 chore: update 2022-09-09 00:02:15 +08:00
xiaoxian521
594f9b98ab feat: 添加cssnano,打包时压缩css体积 2022-09-08 17:23:48 +08:00
xiaoxian521
392105e820 chore: use pnpm shell-emulator instead of cross-env 2022-09-07 21:59:03 +08:00
xiaoxian521
f629663641 chore: update 2022-09-07 16:55:49 +08:00
RealityBoy
3683bd46a4 refactor: use tailwindcss replace unocss (#342)
* refactor: use `tailwindcss` replace `unocss`

* fix: update
2022-09-07 15:07:01 +08:00
Yalin
4dfde1bea6 docs:注释文案修正 (#344) 2022-09-07 14:09:54 +08:00
xiaoxian521
4e506555ad fix: token过期,刷新死循环 2022-09-06 23:22:06 +08:00
xiaoxian521
45f912c2f5 chore: update 2022-09-05 22:21:10 +08:00
xiaoxian521
d44b35937b chore: update 2022-09-04 12:34:43 +08:00
xiaoxian521
594abd7372 chore: update 2022-09-03 13:56:30 +08:00
xiaoxian521
869964ea7e chore: update 2022-08-31 11:37:18 +08:00
xiaoxian521
4c26318126 docs: update 2022-08-31 11:19:27 +08:00
xiaoxian521
ab3468b758 chore: update 2022-08-31 11:01:36 +08:00
xiaoxian521
1dbd29735e docs: update 2022-08-31 01:39:09 +08:00
xiaoxian521
2def54c775 workflow: add gitee Deploy 2022-08-31 00:40:03 +08:00
xiaoxian521
67e8532d37 chore: update 2022-08-29 17:14:25 +08:00
一万
fb2c016ebe feat: add el-table-infinite-scroll demo (#335) 2022-08-24 23:25:00 +08:00
xiaoxian521
3056527701 perf: 重置路由时,清空缓存页面 2022-08-24 16:08:05 +08:00
xiaoxian521
cef79dfca0 chore: window.process定义在index.html中,防止低版本浏览器报错 2022-08-24 09:46:19 +08:00
xiaoxian521
769410efdf chore: 开启vscode括号对指南 2022-08-23 20:47:35 +08:00
xiaoxian521
c7dbb07858 chore: update unocss 2022-08-23 17:59:38 +08:00
xiaoxian521
cc92b3e51e style: reset.scss 2022-08-23 16:58:52 +08:00
148 changed files with 3249 additions and 2774 deletions

View File

@@ -8,4 +8,12 @@ VITE_ROUTER_HISTORY = "hash"
VITE_PROXY_DOMAIN_REAL = "" VITE_PROXY_DOMAIN_REAL = ""
# 是否为打包后的文件提供传统浏览器兼容性支持 支持 true 不支持 false # 是否为打包后的文件提供传统浏览器兼容性支持 支持 true 不支持 false
VITE_LEGACY = false VITE_LEGACY = false
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
VITE_CDN = false
# 是否启用gzip压缩或brotli压缩分两种情况删除原始文件和不删除原始文件
# 压缩时不删除原始文件的配置gzip、brotli、both同时开启 gzip 与 brotli 压缩、none不开启压缩默认
# 压缩时删除原始文件的配置gzip-clear、brotli-clear、both-clear同时开启 gzip 与 brotli 压缩、none不开启压缩默认
VITE_COMPRESSION = "none"

View File

@@ -12,3 +12,11 @@ VITE_PROXY_DOMAIN_REAL = ""
# 是否为打包后的文件提供传统浏览器兼容性支持 支持 true 不支持 false # 是否为打包后的文件提供传统浏览器兼容性支持 支持 true 不支持 false
VITE_LEGACY = false VITE_LEGACY = false
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
VITE_CDN = false
# 是否启用gzip压缩或brotli压缩分两种情况删除原始文件和不删除原始文件
# 压缩时不删除原始文件的配置gzip、brotli、both同时开启 gzip 与 brotli 压缩、none不开启压缩默认
# 压缩时删除原始文件的配置gzip-clear、brotli-clear、both-clear同时开启 gzip 与 brotli 压缩、none不开启压缩默认
VITE_COMPRESSION = "none"

View File

@@ -1,4 +1,10 @@
public public
dist dist
*.d.ts *.d.ts
package.json package.json
.eslintrc.js
.prettierrc.js
commitlint.config.js
postcss.config.js
tailwind.config.js
stylelint.config.js

39
.github/workflows/gitee.yml vendored Normal file
View File

@@ -0,0 +1,39 @@
name: Build and Deploy
permissions:
contents: write
on:
push:
branches:
- master
jobs:
deploy:
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: "16"
registry-url: https://registry.npmjs.com/
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Deploy 🔧
run: |
pnpm install
sed -i "s#VITE_PUBLIC_PATH = /#VITE_PUBLIC_PATH = /vue-pure-admin/#g" $(pwd)/.env.production
pnpm build
cd dist
touch README.md .nojekyll
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: dist
clean: true

View File

@@ -1,6 +1,6 @@
module.exports = { module.exports = {
"*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"], "*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"],
"{!(package)*.json,.!(browserslist)*rc}": ["prettier --write--parser json"], "{!(package)*.json}": ["prettier --write--parser json"],
"package.json": ["prettier --write"], "package.json": ["prettier --write"],
"*.vue": ["eslint --fix", "prettier --write", "stylelint --fix"], "*.vue": ["eslint --fix", "prettier --write", "stylelint --fix"],
"*.{vue,css,scss,postcss,less}": ["stylelint --fix", "prettier --write"], "*.{vue,css,scss,postcss,less}": ["stylelint --fix", "prettier --write"],

3
.npmrc Normal file
View File

@@ -0,0 +1,3 @@
shamefully-hoist=true
strict-peer-dependencies=false
shell-emulator=true

View File

@@ -1,15 +1,18 @@
{ {
"recommendations": [ "recommendations": [
"christian-kohler.path-intellisense",
"vscode-icons-team.vscode-icons", "vscode-icons-team.vscode-icons",
"davidanson.vscode-markdownlint", "davidanson.vscode-markdownlint",
"stylelint.vscode-stylelint", "stylelint.vscode-stylelint",
"bradlc.vscode-tailwindcss",
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"esbenp.prettier-vscode", "esbenp.prettier-vscode",
"lokalise.i18n-ally", "lokalise.i18n-ally",
"redhat.vscode-yaml",
"csstools.postcss",
"mikestead.dotenv", "mikestead.dotenv",
"eamodio.gitlens", "eamodio.gitlens",
"antfu.iconify", "antfu.iconify",
"antfu.unocss",
"Vue.volar" "Vue.volar"
] ]
} }

View File

@@ -6,6 +6,7 @@
}, },
"editor.tabSize": 2, "editor.tabSize": 2,
"editor.formatOnPaste": true, "editor.formatOnPaste": true,
"editor.guides.bracketPairs": "active",
"files.autoSave": "afterDelay", "files.autoSave": "afterDelay",
"git.confirmSync": false, "git.confirmSync": false,
"workbench.startupEditor": "newUntitledFile", "workbench.startupEditor": "newUntitledFile",

View File

@@ -1,3 +1,65 @@
# 3.6.1 (2022-10-27)
### 🎫 Feat
- Add whether to start `cdn` for packaging to replace the local library configuration, the default `false` does not start
- Added optional `gzip` and `brotli` compression modes for packaging builds
### 🐞 Bug fixes
- Fix `title` too long display style problem
- Fix the parent `name` in the route should not be repeated with the child `name`, which will cause redirection to jump `404` problem
### 🍏 Perf
- Upgrade `axios` to the latest version
# 3.6.0 (2022-10-25)
### 🎫 Feat
- Add file download `demo`
- Add typewriter component `demo`
- Added `json` editor `demo`
### ✔️ refactor
- Refactor the permission module, adopt the most commonly used `RBAC` (Role-Based Access List): role-based permission control (User -> Role -> Permission), and update the page permission and button permission `demo` example, button Permissions support three operation modes (judging permissions in component mode, judging permissions in function mode, and judging permissions in instruction mode)
### 🐞 Bug fixes
- Fixed the theme not being emptied when clearing the cache and returning to the login page
- Fix `menu` display problem in production environment in `horizontal` mode
- Fixed the problem that the `mix` mixed mode navigation might not be displayed in the left menu of the production environment
- After the `token` expires, calling the refresh `token` interface will cause an infinite loop
### 🍏 Perf
- Removed uncommon `@apply` from `tailwind.css`
- Replace `//` comments with `/** */`, which is more friendly to the editor's intellisense
- Optimize the login enter event
- Simplified some functions, eliminated useless functions, and optimized page loading speed
# 3.5.0 (2022-9-10)
### 🎫 Feat
- Add `cssnano` to compress the size of `css` when packaging
- Add `element-plus` seamless scrolling `Table` page demo
- Open `vscode` bracket pair guide
### ✔️ refactor
- Replace `unocss` with `tailwindcss`, add `tailwindcss` [documentation](https://xiaoxian521.github.io/pure-admin-doc/pages/39156f/)
### 🐞 Bug fixes
- `token` expires, refresh the infinite loop
### 🍏 Perf
- When resetting the route, clear the cached page
# 3.4.6 (2022-8-23) # 3.4.6 (2022-8-23)
### 🐞 Bug fixes ### 🐞 Bug fixes

View File

@@ -1,3 +1,65 @@
# 3.6.1 (2022-10-27)
### 🎫 Feat
- Add whether to start `cdn` for packaging to replace the local library configuration, the default `false` does not start
- Added optional `gzip` and `brotli` compression modes for packaging builds
### 🐞 Bug fixes
- Fix `title` too long display style problem
- Fix the parent `name` in the route should not be repeated with the child `name`, which will cause redirection to jump `404` problem
### 🍏 Perf
- Upgrade `axios` to the latest version
# 3.6.0 (2022-10-25)
### 🎫 Feat
- Add file download `demo`
- Add typewriter component `demo`
- Added `json` editor `demo`
### ✔️ refactor
- Refactor the permission module, adopt the most commonly used `RBAC` (Role-Based Access List): role-based permission control (User -> Role -> Permission), and update the page permission and button permission `demo` example, button Permissions support three operation modes (judging permissions in component mode, judging permissions in function mode, and judging permissions in instruction mode)
### 🐞 Bug fixes
- Fixed the theme not being emptied when clearing the cache and returning to the login page
- Fix `menu` display problem in production environment in `horizontal` mode
- Fixed the problem that the `mix` mixed mode navigation might not be displayed in the left menu of the production environment
- After the `token` expires, calling the refresh `token` interface will cause an infinite loop
### 🍏 Perf
- Removed uncommon `@apply` from `tailwind.css`
- Replace `//` comments with `/** */`, which is more friendly to the editor's intellisense
- Optimize the login enter event
- Simplified some functions, eliminated useless functions, and optimized page loading speed
# 3.5.0 (2022-9-10)
### 🎫 Feat
- Add `cssnano` to compress the size of `css` when packaging
- Add `element-plus` seamless scrolling `Table` page demo
- Open `vscode` bracket pair guide
### ✔️ refactor
- Replace `unocss` with `tailwindcss`, add `tailwindcss` [documentation](https://xiaoxian521.github.io/pure-admin-doc/pages/39156f/)
### 🐞 Bug fixes
- `token` expires, refresh the infinite loop
### 🍏 Perf
- When resetting the route, clear the cached page
# 3.4.6 (2022-8-23) # 3.4.6 (2022-8-23)
### 🐞 Bug fixes ### 🐞 Bug fixes

View File

@@ -1,3 +1,65 @@
# 3.6.1 (2022-10-27)
### 🎫 Feat
- 添加打包是否启动`cdn`替换本地库配置,默认`false`不启动
- 添加打包构建可选`gzip``brotli`压缩模式
### 🐞 Bug fixes
- 修复`title`过长显示样式问题
- 修复路由中父级`name`不应和子级`name`重复,会造成重定向跳转`404`问题
### 🍏 Perf
- 升级`axios`至最新版
# 3.6.0 (2022-10-25)
### 🎫 Feat
- 添加文件下载`demo`
- 添加打字机组件`demo`
- 添加`json`编辑器`demo`
### ✔️ refactor
- 重构权限模块,采用目前最常用的`RBAC`Role-Based Access List: 基于角色的权限控制( 用户 -> 角色 -> 权限 ),并更新页面权限和按钮权限`demo`示例,按钮权限支持三种操作模式(组件方式判断权限、函数方式判断权限、指令方式判断权限)
### 🐞 Bug fixes
- 修复清空缓存并返回登录页时未清空主题
- 修复`horizontal`模式下`menu`在生产环境显示问题
- 修复`mix`混合模式导航在生产环境左侧菜单一定机率不显示的问题
- `token`过期后调用刷新`token`接口会无限循环的问题
### 🍏 Perf
-`tailwind.css`中移除不常用的`@apply`
- 使用`/** */`替换`//`注释,对编辑器的智能提示更友好
- 优化登录回车事件
- 简化了一些函数,剔除了无用函数,优化了页面加载速度
# 3.5.0 (2022-9-10)
### 🎫 Feat
- 添加 `cssnano` ,打包时压缩 `css` 体积
- 添加 `element-plus` 无缝滚动 `Table` 页面 demo
- 开启 `vscode` 括号对指南
### ✔️ refactor
- 使用 `tailwindcss` 替换 `unocss`,新增 `tailwindcss` [使用文档](http://yiming_chang.gitee.io/pure-admin-doc/pages/39156f/)
### 🐞 Bug fixes
- `token` 过期,刷新死循环
### 🍏 Perf
- 重置路由时,清空缓存页面
# 3.4.6 (2022-8-23) # 3.4.6 (2022-8-23)
### 🐞 Bug fixes ### 🐞 Bug fixes
@@ -29,7 +91,7 @@
- 将平台的大部分工具以及 hooks 都集中到[@pureadmin/utils](https://pure-admin-utils-docs.vercel.app/),并删除集中到这个库里的代码,减少平台体积 - 将平台的大部分工具以及 hooks 都集中到[@pureadmin/utils](https://pure-admin-utils-docs.vercel.app/),并删除集中到这个库里的代码,减少平台体积
- 添加[unplugin-vue-define-options](https://www.npmjs.com/package/unplugin-vue-define-options)插件,页面可直接写 `defineOptions({name: 自定义名称})` - 添加[unplugin-vue-define-options](https://www.npmjs.com/package/unplugin-vue-define-options)插件,页面可直接写 `defineOptions({name: 自定义名称})`
- 添加项目文件、语言分析工具 [cloc](https://www.npmjs.com/package/cloc) - 添加项目文件、语言分析工具 [cloc](https://www.npmjs.com/package/cloc)
- 添加登页国际化 - 添加登页国际化
- 添加完整路由配置表类型声明 - 添加完整路由配置表类型声明
- 添加虚拟列表页面 demo - 添加虚拟列表页面 demo
- 添加 `PDF` 预览页面 demo - 添加 `PDF` 预览页面 demo

View File

@@ -17,7 +17,9 @@ vue-pure-admin is a free and open source middle and back-end template. Using the
## Docs ## Docs
- [Click Watch Docs](https://pure-admin-doc.vercel.app) - [Click me to view the domestic documentation site](http://yiming_chang.gitee.io/pure-admin-doc)
- [Click me to view foreign document site 1](https://xiaoxian521.github.io/pure-admin-doc)
- [Click me to view foreign document site 2](https://pure-admin-doc.vercel.app)
## Thin ## Thin
@@ -29,7 +31,9 @@ vue-pure-admin is a free and open source middle and back-end template. Using the
## Preview ## Preview
- [vue-pure-admin](https://vue-pure-admin.vercel.app) - [Click me to view the domestic preview station](http://yiming_chang.gitee.io/vue-pure-admin)
- [Click me to view foreign preview site 1](https://xiaoxian521.github.io/vue-pure-admin)
- [Click me to view foreign preview station 2](https://vue-pure-admin.vercel.app)
- PC - PC
<p align="center"> <p align="center">

View File

@@ -17,7 +17,9 @@ vue-pure-admin 是一个免费开源的中后台模版。使用了最新的`vue3
## 配套文档 ## 配套文档
- [点我查看文档](https://pure-admin-doc.vercel.app) - [点我查看国内文档](http://yiming_chang.gitee.io/pure-admin-doc)
- [点我查看国外文档站 1](https://xiaoxian521.github.io/pure-admin-doc)
- [点我查看国外文档站 2](https://pure-admin-doc.vercel.app)
## 精简版 ## 精简版
@@ -29,7 +31,9 @@ vue-pure-admin 是一个免费开源的中后台模版。使用了最新的`vue3
## 预览 ## 预览
- [vue-pure-admin](https://vue-pure-admin.vercel.app) - [点我查看国内预览站](http://yiming_chang.gitee.io/vue-pure-admin)
- [点我查看国外预览站 1](https://xiaoxian521.github.io/vue-pure-admin)
- [点我查看国外预览站 2](https://vue-pure-admin.vercel.app)
- PC 端 - PC 端
<p align="center"> <p align="center">
@@ -141,7 +145,7 @@ pnpm build
一群已满,下面是二群,群里严禁`黄``赌``毒``vpn`等违法行为! 一群已满,下面是二群,群里严禁`黄``赌``毒``vpn`等违法行为!
<img src="https://pure-admin-doc.vercel.app/img/support/qq.png" width="150px" height="225px" /> <img src="http://yiming_chang.gitee.io/pure-admin-doc/img/support/qq.png" width="150px" height="225px" />
## 许可证 ## 许可证

67
build/cdn.ts Normal file
View File

@@ -0,0 +1,67 @@
import { Plugin as importToCDN } from "vite-plugin-cdn-import";
/**
* @description 打包时采用`cdn`模式仅限外网使用默认不采用如果需要采用cdn模式请在 .env.production 文件,将 VITE_CDN 设置成true
* 平台采用国内cdnhttps://www.bootcdn.cn当然你也可以选择 https://unpkg.com 或者 https://www.jsdelivr.com
* 提醒mockjs不能用cdn模式引入会报错。正确的方式是生产环境删除mockjs使用真实的后端请求
* 注意上面提到的仅限外网使用也不是完全肯定的如果你们公司内网部署的有相关js、css文件也可以将下面配置对应改一下整一套内网版cdn
*/
export const cdn = importToCDN({
//prodUrl解释 name: 对应下面modules的nameversion: 自动读取本地package.json中dependencies依赖中对应包的版本号path: 对应下面modules的path
prodUrl: "https://cdn.bootcdn.net/ajax/libs/{name}/{version}/{path}",
modules: [
{
name: "vue",
var: "Vue",
path: "vue.global.prod.min.js"
},
{
name: "vue-router",
var: "VueRouter",
path: "vue-router.global.min.js"
},
{
name: "vue-i18n",
var: "VueI18n",
path: "vue-i18n.runtime.global.prod.min.js"
},
// 项目中没有直接安装vue-demi但是pinia用到了所以需要在引入pinia前引入vue-demihttps://github.com/vuejs/pinia/blob/v2/packages/pinia/package.json#L77
{
name: "vue-demi",
var: "VueDemi",
path: "index.iife.min.js"
},
{
name: "pinia",
var: "Pinia",
path: "pinia.iife.min.js"
},
{
name: "element-plus",
var: "ElementPlus",
path: "index.full.min.js",
css: "index.min.css"
},
{
name: "axios",
var: "axios",
path: "axios.min.js"
},
{
name: "dayjs",
var: "dayjs",
path: "dayjs.min.js"
},
{
name: "echarts",
var: "echarts",
path: "echarts.min.js"
},
{
name: "lodash",
var: "lodash",
// 可写`完整路径`,会替换`prodUrl`
path: "https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"
}
]
});

63
build/compress.ts Normal file
View File

@@ -0,0 +1,63 @@
import type { Plugin } from "vite";
import { isArray } from "@pureadmin/utils";
import compressPlugin from "vite-plugin-compression";
export const configCompressPlugin = (
compress: ViteCompression
): Plugin | Plugin[] => {
if (compress === "none") return null;
const gz = {
// 生成的压缩包后缀
ext: ".gz",
// 体积大于threshold才会被压缩
threshold: 0,
// 默认压缩.js|mjs|json|css|html后缀文件设置成true压缩全部文件
filter: () => true,
// 压缩后是否删除原始文件
deleteOriginFile: false
};
const br = {
ext: ".br",
algorithm: "brotliCompress",
threshold: 0,
filter: () => true,
deleteOriginFile: false
};
const codeList = [
{ k: "gzip", v: gz },
{ k: "brotli", v: br },
{ k: "both", v: [gz, br] }
];
const plugins: Plugin[] = [];
codeList.forEach(item => {
if (compress.includes(item.k)) {
if (compress.includes("clear")) {
if (isArray(item.v)) {
item.v.forEach(vItem => {
plugins.push(
compressPlugin(Object.assign(vItem, { deleteOriginFile: true }))
);
});
} else {
plugins.push(
compressPlugin(Object.assign(item.v, { deleteOriginFile: true }))
);
}
} else {
if (isArray(item.v)) {
item.v.forEach(vItem => {
plugins.push(compressPlugin(vItem));
});
} else {
plugins.push(compressPlugin(item.v));
}
}
}
});
return plugins;
};

View File

@@ -1,13 +1,15 @@
// 处理环境变量 /** 处理环境变量 */
const warpperEnv = (envConf: Recordable): ViteEnv => { const warpperEnv = (envConf: Recordable): ViteEnv => {
// 此处为默认值,无需修改 /** 此处为默认值,无需修改 */
const ret: ViteEnv = { const ret: ViteEnv = {
VITE_PORT: 8848, VITE_PORT: 8848,
VITE_PUBLIC_PATH: "", VITE_PUBLIC_PATH: "",
VITE_PROXY_DOMAIN: "", VITE_PROXY_DOMAIN: "",
VITE_PROXY_DOMAIN_REAL: "", VITE_PROXY_DOMAIN_REAL: "",
VITE_ROUTER_HISTORY: "", VITE_ROUTER_HISTORY: "",
VITE_LEGACY: false VITE_LEGACY: false,
VITE_CDN: false,
VITE_COMPRESSION: "none"
}; };
for (const envName of Object.keys(envConf)) { for (const envName of Object.keys(envConf)) {
@@ -28,12 +30,12 @@ const warpperEnv = (envConf: Recordable): ViteEnv => {
return ret; return ret;
}; };
// 跨域代理重写 /** 跨域代理重写 */
const regExps = (value: string, reg: string): string => { const regExps = (value: string, reg: string): string => {
return value.replace(new RegExp(`^${reg}`, "g"), ""); return value.replace(new RegExp(`^${reg}`, "g"), "");
}; };
// 环境变量 /** 环境变量 */
const loadEnv = (): ViteEnv => { const loadEnv = (): ViteEnv => {
return import.meta.env; return import.meta.env;
}; };

View File

@@ -1,11 +1,12 @@
import { cdn } from "./cdn";
import { resolve } from "path"; import { resolve } from "path";
import Unocss from "unocss/vite";
import vue from "@vitejs/plugin-vue"; import vue from "@vitejs/plugin-vue";
import { viteBuildInfo } from "./info"; import { viteBuildInfo } from "./info";
import svgLoader from "vite-svg-loader"; import svgLoader from "vite-svg-loader";
import legacy from "@vitejs/plugin-legacy"; import legacy from "@vitejs/plugin-legacy";
import vueJsx from "@vitejs/plugin-vue-jsx"; import vueJsx from "@vitejs/plugin-vue-jsx";
import { viteMockServe } from "vite-plugin-mock"; import { viteMockServe } from "vite-plugin-mock";
import { configCompressPlugin } from "./compress";
import VueI18n from "@intlify/vite-plugin-vue-i18n"; import VueI18n from "@intlify/vite-plugin-vue-i18n";
import { visualizer } from "rollup-plugin-visualizer"; import { visualizer } from "rollup-plugin-visualizer";
import removeConsole from "vite-plugin-remove-console"; import removeConsole from "vite-plugin-remove-console";
@@ -13,7 +14,12 @@ import themePreprocessorPlugin from "@pureadmin/theme";
import { genScssMultipleScopeVars } from "/@/layout/theme"; import { genScssMultipleScopeVars } from "/@/layout/theme";
import DefineOptions from "unplugin-vue-define-options/vite"; import DefineOptions from "unplugin-vue-define-options/vite";
export function getPluginsList(command, VITE_LEGACY) { export function getPluginsList(
command: string,
VITE_LEGACY: boolean,
VITE_CDN: boolean,
VITE_COMPRESSION: ViteCompression
) {
const prodMock = true; const prodMock = true;
const lifecycle = process.env.npm_lifecycle_event; const lifecycle = process.env.npm_lifecycle_event;
return [ return [
@@ -26,7 +32,8 @@ export function getPluginsList(command, VITE_LEGACY) {
}), }),
// jsx、tsx语法支持 // jsx、tsx语法支持
vueJsx(), vueJsx(),
Unocss(), VITE_CDN ? cdn : null,
configCompressPlugin(VITE_COMPRESSION),
DefineOptions(), DefineOptions(),
// 线上环境删除console // 线上环境删除console
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }), removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),

View File

@@ -10,6 +10,9 @@
/> />
<title>vue-pure-admin</title> <title>vue-pure-admin</title>
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<script>
window.process = {};
</script>
</head> </head>
<body> <body>
@@ -33,9 +36,7 @@
border-radius: 50%; border-radius: 50%;
width: 2.5em; width: 2.5em;
height: 2.5em; height: 2.5em;
-webkit-animation-fill-mode: both;
animation-fill-mode: both; animation-fill-mode: both;
-webkit-animation: loadAnimation 1.8s infinite ease-in-out;
animation: loadAnimation 1.8s infinite ease-in-out; animation: loadAnimation 1.8s infinite ease-in-out;
} }
@@ -45,10 +46,7 @@
margin: 80px auto; margin: 80px auto;
position: relative; position: relative;
text-indent: -9999em; text-indent: -9999em;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0); transform: translateZ(0);
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s; animation-delay: -0.16s;
top: 0; top: 0;
transform: translate(-50%, 0); transform: translate(-50%, 0);
@@ -63,7 +61,6 @@
.loader:before { .loader:before {
left: -3.5em; left: -3.5em;
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s; animation-delay: -0.32s;
} }
@@ -71,18 +68,6 @@
left: 3.5em; left: 3.5em;
} }
@-webkit-keyframes loadAnimation {
0%,
80%,
100% {
box-shadow: 0 2.5em 0 -1.3em;
}
40% {
box-shadow: 0 2.5em 0 0;
}
}
@keyframes loadAnimation { @keyframes loadAnimation {
0%, 0%,
80%, 80%,

View File

@@ -18,6 +18,10 @@ buttons:
hscloseRightTabs: Close RightTabs hscloseRightTabs: Close RightTabs
hscloseOtherTabs: Close OtherTabs hscloseOtherTabs: Close OtherTabs
hscloseAllTabs: Close AllTabs hscloseAllTabs: Close AllTabs
hswholeFullScreen: Whole FullScreen
hswholeExitFullScreen: Whole ExitFullScreen
hscontentFullScreen: Content FullScreen
hscontentExitFullScreen: Content ExitFullScreen
menus: menus:
hshome: Home hshome: Home
hslogin: Login hslogin: Login
@@ -28,7 +32,7 @@ menus:
hsRole: Role Manage hsRole: Role Manage
hsDept: Dept Manage hsDept: Dept Manage
hseditor: Editor hseditor: Editor
hserror: Error Page hsabnormal: Abnormal Page
hsfourZeroFour: "404" hsfourZeroFour: "404"
hsfourZeroOne: "403" hsfourZeroOne: "403"
hsFive: "500" hsFive: "500"
@@ -44,6 +48,8 @@ menus:
hsflowChart: Flow Chart hsflowChart: Flow Chart
hsseamless: Seamless Scroll hsseamless: Seamless Scroll
hscontextmenu: Context Menu hscontextmenu: Context Menu
hstypeit: Typeit Components
hsjsoneditor: JSON Editor
hsmenus: MultiLevel Menu hsmenus: MultiLevel Menu
hsmenu1: Menu1 hsmenu1: Menu1
hsmenu1-1: Menu1-1 hsmenu1-1: Menu1-1
@@ -61,6 +67,7 @@ menus:
hsMenuTree: Menu Tree hsMenuTree: Menu Tree
hsWatermark: Water Mark hsWatermark: Water Mark
hsPrint: Print hsPrint: Print
hsDownload: Download
hsExternalPage: External Page hsExternalPage: External Page
hsPureDocument: Pure Doc(Embedded) hsPureDocument: Pure Doc(Embedded)
externalLink: Pure Doc(External) externalLink: Pure Doc(External)
@@ -86,6 +93,7 @@ menus:
hsVirtualList: Virtual List hsVirtualList: Virtual List
hsPdf: PDF Preview hsPdf: PDF Preview
hsExecl: Export Excel hsExecl: Export Excel
hsInfiniteScroll: Table Infinite Scroll
status: status:
hsLoad: Loading... hsLoad: Loading...
login: login:

View File

@@ -18,6 +18,10 @@ buttons:
hscloseRightTabs: 关闭右侧标签页 hscloseRightTabs: 关闭右侧标签页
hscloseOtherTabs: 关闭其他标签页 hscloseOtherTabs: 关闭其他标签页
hscloseAllTabs: 关闭全部标签页 hscloseAllTabs: 关闭全部标签页
hswholeFullScreen: 整体页面全屏
hswholeExitFullScreen: 整体页面退出全屏
hscontentFullScreen: 内容区全屏
hscontentExitFullScreen: 内容区退出全屏
menus: menus:
hshome: 首页 hshome: 首页
hslogin: 登录 hslogin: 登录
@@ -28,7 +32,7 @@ menus:
hsRole: 角色管理 hsRole: 角色管理
hsDept: 部门管理 hsDept: 部门管理
hseditor: 编辑器 hseditor: 编辑器
hserror: 错误页面 hsabnormal: 异常页面
hsfourZeroFour: "404" hsfourZeroFour: "404"
hsfourZeroOne: "403" hsfourZeroOne: "403"
hsFive: "500" hsFive: "500"
@@ -44,6 +48,8 @@ menus:
hsflowChart: 流程图 hsflowChart: 流程图
hsseamless: 无缝滚动 hsseamless: 无缝滚动
hscontextmenu: 右键菜单 hscontextmenu: 右键菜单
hstypeit: 打字机组件
hsjsoneditor: JSON编辑器
hsmenus: 多级菜单 hsmenus: 多级菜单
hsmenu1: 菜单1 hsmenu1: 菜单1
hsmenu1-1: 菜单1-1 hsmenu1-1: 菜单1-1
@@ -61,6 +67,7 @@ menus:
hsMenuTree: 菜单树结构 hsMenuTree: 菜单树结构
hsWatermark: 水印 hsWatermark: 水印
hsPrint: 打印 hsPrint: 打印
hsDownload: 下载
hsExternalPage: 外部页面 hsExternalPage: 外部页面
hsPureDocument: 平台文档(内嵌) hsPureDocument: 平台文档(内嵌)
externalLink: 平台文档(外链) externalLink: 平台文档(外链)
@@ -86,6 +93,7 @@ menus:
hsVirtualList: 虚拟列表 hsVirtualList: 虚拟列表
hsPdf: PDF预览 hsPdf: PDF预览
hsExecl: 导出Excel hsExecl: 导出Excel
hsInfiniteScroll: 表格无限滚动
status: status:
hsLoad: 加载中... hsLoad: 加载中...
login: login:

View File

@@ -1,7 +1,12 @@
// 根据角色动态生成路由 // 模拟后端动态生成路由
import { MockMethod } from "vite-plugin-mock"; import { MockMethod } from "vite-plugin-mock";
// http://mockjs.com/examples.html#Object /**
* roles页面级别权限这里模拟二种 "admin"、"common"
* admin管理员角色
* common普通角色
*/
const systemRouter = { const systemRouter = {
path: "/system", path: "/system",
meta: { meta: {
@@ -15,7 +20,8 @@ const systemRouter = {
name: "User", name: "User",
meta: { meta: {
icon: "flUser", icon: "flUser",
title: "menus.hsUser" title: "menus.hsUser",
roles: ["admin"]
} }
}, },
{ {
@@ -23,7 +29,8 @@ const systemRouter = {
name: "Role", name: "Role",
meta: { meta: {
icon: "role", icon: "role",
title: "menus.hsRole" title: "menus.hsRole",
roles: ["admin"]
} }
}, },
{ {
@@ -31,7 +38,8 @@ const systemRouter = {
name: "Dept", name: "Dept",
meta: { meta: {
icon: "dept", icon: "dept",
title: "menus.hsDept" title: "menus.hsDept",
roles: ["admin"]
} }
}, },
{ {
@@ -41,7 +49,8 @@ const systemRouter = {
meta: { meta: {
icon: "dict", icon: "dict",
title: "menus.hsDict", title: "menus.hsDict",
keepAlive: true keepAlive: true,
roles: ["admin"]
} }
} }
] ]
@@ -52,13 +61,14 @@ const permissionRouter = {
meta: { meta: {
title: "menus.permission", title: "menus.permission",
icon: "lollipop", icon: "lollipop",
rank: 7 rank: 10
}, },
children: [ children: [
{ {
path: "/permission/page/index", path: "/permission/page/index",
name: "PermissionPage", name: "PermissionPage",
meta: { meta: {
roles: ["admin", "common"],
title: "menus.permissionPage" title: "menus.permissionPage"
} }
}, },
@@ -67,7 +77,8 @@ const permissionRouter = {
name: "PermissionButton", name: "PermissionButton",
meta: { meta: {
title: "menus.permissionButton", title: "menus.permissionButton",
authority: [] roles: ["admin", "common"],
auths: ["btn_add", "btn_edit", "btn_delete"]
} }
} }
] ]
@@ -78,7 +89,7 @@ const frameRouter = {
meta: { meta: {
icon: "monitor", icon: "monitor",
title: "menus.hsExternalPage", title: "menus.hsExternalPage",
rank: 10 rank: 7
}, },
children: [ children: [
{ {
@@ -86,14 +97,16 @@ const frameRouter = {
name: "FramePure", name: "FramePure",
meta: { meta: {
title: "menus.hsPureDocument", title: "menus.hsPureDocument",
frameSrc: "https://pure-admin-doc.vercel.app" frameSrc: "http://yiming_chang.gitee.io/pure-admin-doc",
roles: ["admin", "common"]
} }
}, },
{ {
path: "/external", path: "/external",
name: "https://pure-admin-doc.vercel.app", name: "http://yiming_chang.gitee.io/pure-admin-doc",
meta: { meta: {
title: "menus.externalLink" title: "menus.externalLink",
roles: ["admin", "common"]
} }
}, },
{ {
@@ -101,7 +114,8 @@ const frameRouter = {
name: "FrameEp", name: "FrameEp",
meta: { meta: {
title: "menus.hsEpDocument", title: "menus.hsEpDocument",
frameSrc: "https://element-plus.org/zh-CN/" frameSrc: "https://element-plus.org/zh-CN/",
roles: ["admin", "common"]
} }
} }
] ]
@@ -119,7 +133,8 @@ const tabsRouter = {
path: "/tabs/index", path: "/tabs/index",
name: "Tabs", name: "Tabs",
meta: { meta: {
title: "menus.hstabs" title: "menus.hstabs",
roles: ["admin", "common"]
} }
}, },
{ {
@@ -127,7 +142,8 @@ const tabsRouter = {
name: "TabQueryDetail", name: "TabQueryDetail",
meta: { meta: {
// 不在menu菜单中显示 // 不在menu菜单中显示
showLink: false showLink: false,
roles: ["admin", "common"]
} }
}, },
{ {
@@ -135,39 +151,22 @@ const tabsRouter = {
component: "params-detail", component: "params-detail",
name: "TabParamsDetail", name: "TabParamsDetail",
meta: { meta: {
showLink: false showLink: false,
roles: ["admin", "common"]
} }
} }
] ]
}; };
// 添加不同按钮权限到/permission/button页面中
function setDifAuthority(authority, routes) {
routes.children[1].meta.authority = [authority];
return routes;
}
export default [ export default [
{ {
url: "/getAsyncRoutes", url: "/getAsyncRoutes",
method: "get", method: "get",
response: ({ query }) => { response: () => {
if (query.name === "admin") { return {
return { success: true,
code: 0, data: [systemRouter, permissionRouter, frameRouter, tabsRouter]
info: [ };
tabsRouter,
frameRouter,
systemRouter,
setDifAuthority("v-admin", permissionRouter)
]
};
} else {
return {
code: 0,
info: [tabsRouter, setDifAuthority("v-test", permissionRouter)]
};
}
} }
} }
] as MockMethod[]; ] as MockMethod[];

View File

@@ -6,7 +6,7 @@ export default [
method: "post", method: "post",
response: () => { response: () => {
return { return {
code: 0, success: true,
data: { data: {
list: [ list: [
{ {

36
mock/login.ts Normal file
View File

@@ -0,0 +1,36 @@
// 根据角色动态生成路由
import { MockMethod } from "vite-plugin-mock";
export default [
{
url: "/login",
method: "post",
response: ({ body }) => {
if (body.username === "admin") {
return {
success: true,
data: {
username: "admin",
// 一个用户可能有多个角色
roles: ["admin"],
accessToken: "eyJhbGciOiJIUzUxMiJ9.admin",
refreshToken: "eyJhbGciOiJIUzUxMiJ9.adminRefresh",
expires: "2023/10/30 00:00:00"
}
};
} else {
return {
success: true,
data: {
username: "common",
// 一个用户可能有多个角色
roles: ["common"],
accessToken: "eyJhbGciOiJIUzUxMiJ9.common",
refreshToken: "eyJhbGciOiJIUzUxMiJ9.commonRefresh",
expires: "2023/10/30 00:00:00"
}
};
}
}
}
] as MockMethod[];

View File

@@ -29,8 +29,8 @@ export default [
method: "get", method: "get",
response: () => { response: () => {
return { return {
code: 0, success: true,
info: mapList() data: mapList()
}; };
} }
} }

27
mock/refreshToken.ts Normal file
View File

@@ -0,0 +1,27 @@
import { MockMethod } from "vite-plugin-mock";
// 模拟刷新token接口
export default [
{
url: "/refreshToken",
method: "post",
response: ({ body }) => {
if (body.refreshToken) {
return {
success: true,
data: {
accessToken: "eyJhbGciOiJIUzUxMiJ9.admin",
refreshToken: "eyJhbGciOiJIUzUxMiJ9.adminRefresh",
// `expires`选择这种日期格式是为了方便调试,后端直接设置时间戳或许更方便(每次都应该递增)。如果后端返回的是时间戳格式,前端开发请来到这个目录`src/utils/auth.ts`,把第`38`行的代码换成expires = data.expires即可。
expires: "2023/10/30 23:59:59"
}
};
} else {
return {
success: false,
data: {}
};
}
}
}
] as MockMethod[];

View File

@@ -6,7 +6,7 @@ export default [
method: "post", method: "post",
response: () => { response: () => {
return { return {
code: 0, success: true,
data: { data: {
list: [ list: [
{ {
@@ -71,7 +71,7 @@ export default [
method: "post", method: "post",
response: () => { response: () => {
return { return {
code: 0, success: true,
data: [ data: [
{ {
name: "杭州总公司", name: "杭州总公司",
@@ -212,7 +212,7 @@ export default [
method: "post", method: "post",
response: () => { response: () => {
return { return {
code: 0, success: true,
data: { data: {
list: [ list: [
{ {

View File

@@ -1,20 +1,20 @@
{ {
"name": "vue-pure-admin", "name": "vue-pure-admin",
"version": "3.4.6", "version": "3.6.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "cross-env --max_old_space_size=4096 vite", "dev": "NODE_OPTIONS=--max-old-space-size=4096 vite",
"serve": "pnpm dev", "serve": "pnpm dev",
"build": "rimraf dist && cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build", "build": "rimraf dist && NODE_OPTIONS=--max-old-space-size=8192 vite build",
"build:staging": "rimraf dist && cross-env vite build --mode staging", "build:staging": "rimraf dist && vite build --mode staging",
"report": "rimraf dist && cross-env vite build", "report": "rimraf dist && vite build",
"preview": "vite preview", "preview": "vite preview",
"preview:build": "pnpm build && vite preview", "preview:build": "pnpm build && vite preview",
"typecheck": "tsc --noEmit && vue-tsc --noEmit --skipLibCheck", "typecheck": "tsc --noEmit && vue-tsc --noEmit --skipLibCheck",
"cloc": "cross-env --max_old_space_size=4096 cloc . --exclude-dir=node_modules --exclude-lang=YAML", "cloc": "NODE_OPTIONS=--max-old-space-size=4096 cloc . --exclude-dir=node_modules --exclude-lang=YAML",
"clean:cache": "rm -rf node_modules && rm -rf .eslintcache && pnpm install", "clean:cache": "rm -rf node_modules && rm -rf .eslintcache && pnpm install",
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix", "lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock,build}/**/*.{vue,js,ts,tsx}\" --fix",
"lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"", "lint:prettier": "prettier --write \"src/**/*.{js,ts,json,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint --cache --fix \"**/*.{vue,css,scss,postcss,less}\" --cache --cache-location node_modules/.cache/stylelint/", "lint:stylelint": "stylelint --cache --fix \"**/*.{vue,css,scss,postcss,less}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js", "lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
"lint:pretty": "pretty-quick --staged", "lint:pretty": "pretty-quick --staged",
@@ -35,21 +35,21 @@
"@pureadmin/components": "^1.1.0", "@pureadmin/components": "^1.1.0",
"@pureadmin/descriptions": "^1.1.0", "@pureadmin/descriptions": "^1.1.0",
"@pureadmin/table": "^1.2.0", "@pureadmin/table": "^1.2.0",
"@pureadmin/utils": "^0.1.1", "@pureadmin/utils": "^1.1.5",
"@vueuse/core": "^9.1.0", "@vueuse/core": "^9.4.0",
"@vueuse/motion": "^2.0.0-beta.12", "@vueuse/motion": "^2.0.0-beta.12",
"@vueuse/shared": "^9.1.0", "@vueuse/shared": "^9.4.0",
"@wangeditor/editor": "^5.1.14", "@wangeditor/editor": "^5.1.21",
"@wangeditor/editor-for-vue": "^5.1.12", "@wangeditor/editor-for-vue": "^5.1.12",
"animate.css": "^4.1.1", "animate.css": "^4.1.1",
"axios": "^0.27.2", "axios": "^1.1.3",
"china-area-data": "^5.0.1", "china-area-data": "^5.0.1",
"cropperjs": "^1.5.12", "cropperjs": "^1.5.12",
"css-color-function": "^1.3.3", "dayjs": "^1.11.5",
"dayjs": "^1.11.4",
"driver.js": "^0.9.8", "driver.js": "^0.9.8",
"echarts": "^5.3.3", "echarts": "^5.4.0",
"element-plus": "^2.2.14", "el-table-infinite-scroll": "^3.0.1",
"element-plus": "^2.2.18",
"element-resize-detector": "^1.2.3", "element-resize-detector": "^1.2.3",
"js-cookie": "^3.0.1", "js-cookie": "^3.0.1",
"jsbarcode": "^3.11.5", "jsbarcode": "^3.11.5",
@@ -60,33 +60,33 @@
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"path": "^0.12.7", "path": "^0.12.7",
"pinia": "^2.0.19", "pinia": "^2.0.23",
"qrcode": "^1.5.1", "qrcode": "^1.5.1",
"qs": "^6.11.0", "qs": "^6.11.0",
"resize-observer-polyfill": "^1.5.1", "resize-observer-polyfill": "^1.5.1",
"responsive-storage": "^2.1.0", "responsive-storage": "^2.1.0",
"rgb-hex": "^4.0.0",
"sortablejs": "^1.15.0", "sortablejs": "^1.15.0",
"swiper": "^8.3.2", "swiper": "^8.4.4",
"typeit": "^8.7.0",
"v-contextmenu": "3.0.0", "v-contextmenu": "3.0.0",
"vue": "^3.2.37", "vue": "^3.2.40",
"vue-form-create2": "^1.2.8", "vue-form-create2": "^1.2.8",
"vue-i18n": "^9.2.2", "vue-i18n": "^9.2.2",
"vue-json-pretty": "^2.1.1", "vue-json-pretty": "^2.2.2",
"vue-pdf-embed": "^1.1.4", "vue-pdf-embed": "^1.1.4",
"vue-router": "^4.1.3", "vue-router": "^4.1.6",
"vue-types": "^4.2.1", "vue-types": "^4.2.1",
"vue-virtual-scroller": "^2.0.0-alpha.1", "vue-virtual-scroller": "^2.0.0-alpha.1",
"vuedraggable": "^4.1.0", "vuedraggable": "^4.1.0",
"vxe-table": "^4.3.0-beta.5", "vxe-table": "^4.3.5",
"xe-utils": "^3.5.6", "xe-utils": "^3.5.7",
"xgplayer": "^2.31.7", "xgplayer": "^2.32.1",
"xlsx": "^0.18.5" "xlsx": "^0.18.5"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "13.1.0", "@commitlint/cli": "13.1.0",
"@commitlint/config-conventional": "13.1.0", "@commitlint/config-conventional": "13.1.0",
"@faker-js/faker": "^7.4.0", "@faker-js/faker": "^7.5.0",
"@iconify-icons/carbon": "^1.2.8", "@iconify-icons/carbon": "^1.2.8",
"@iconify-icons/ep": "^1.2.7", "@iconify-icons/ep": "^1.2.7",
"@iconify-icons/fa": "^1.2.3", "@iconify-icons/fa": "^1.2.3",
@@ -96,7 +96,7 @@
"@iconify-icons/ri": "^1.2.3", "@iconify-icons/ri": "^1.2.3",
"@iconify-icons/uil": "^1.2.2", "@iconify-icons/uil": "^1.2.2",
"@iconify/vue": "^3.2.1", "@iconify/vue": "^3.2.1",
"@intlify/vite-plugin-vue-i18n": "^6.0.1", "@intlify/vite-plugin-vue-i18n": "^6.0.3",
"@pureadmin/theme": "^2.4.0", "@pureadmin/theme": "^2.4.0",
"@types/element-resize-detector": "1.1.3", "@types/element-resize-detector": "1.1.3",
"@types/js-cookie": "^3.0.1", "@types/js-cookie": "^3.0.1",
@@ -110,15 +110,15 @@
"@types/sortablejs": "^1.13.0", "@types/sortablejs": "^1.13.0",
"@typescript-eslint/eslint-plugin": "^5.10.2", "@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2", "@typescript-eslint/parser": "^5.10.2",
"@vitejs/plugin-legacy": "^2.0.0", "@vitejs/plugin-legacy": "^2.2.0",
"@vitejs/plugin-vue": "^3.0.1", "@vitejs/plugin-vue": "^3.1.2",
"@vitejs/plugin-vue-jsx": "^2.0.0", "@vitejs/plugin-vue-jsx": "^2.0.1",
"@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0", "@vue/eslint-config-typescript": "^10.0.0",
"@vue/runtime-core": "^3.2.37", "@vue/runtime-core": "^3.2.40",
"autoprefixer": "^10.4.8", "autoprefixer": "^10.4.12",
"cloc": "^2.10.0", "cloc": "^2.10.0",
"cross-env": "7.0.3", "cssnano": "^5.1.13",
"eslint": "^8.8.0", "eslint": "^8.8.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.4.1", "eslint-plugin-vue": "^8.4.1",
@@ -126,14 +126,14 @@
"husky": "^7.0.4", "husky": "^7.0.4",
"lint-staged": "11.1.2", "lint-staged": "11.1.2",
"picocolors": "^1.0.0", "picocolors": "^1.0.0",
"postcss": "^8.4.16", "postcss": "^8.4.17",
"postcss-html": "^1.5.0", "postcss-html": "^1.5.0",
"postcss-import": "^14.1.0", "postcss-import": "^15.0.0",
"postcss-scss": "^4.0.4", "postcss-scss": "^4.0.5",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"pretty-quick": "3.1.1", "pretty-quick": "3.1.1",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"rollup-plugin-visualizer": "^5.7.1", "rollup-plugin-visualizer": "^5.8.2",
"sass": "^1.53.0", "sass": "^1.53.0",
"sass-loader": "^13.0.2", "sass-loader": "^13.0.2",
"stylelint": "^14.3.0", "stylelint": "^14.3.0",
@@ -142,21 +142,23 @@
"stylelint-config-recommended": "^6.0.0", "stylelint-config-recommended": "^6.0.0",
"stylelint-config-standard": "^24.0.0", "stylelint-config-standard": "^24.0.0",
"stylelint-order": "^5.0.0", "stylelint-order": "^5.0.0",
"tailwindcss": "^3.2.1",
"terser": "^5.15.0",
"typescript": "^4.7.4", "typescript": "^4.7.4",
"unocss": "^0.45.9", "unplugin-vue-define-options": "0.7.3",
"unplugin-vue-define-options": "^0.7.3", "vite": "^3.1.8",
"vite": "^3.0.9", "vite-plugin-cdn-import": "^0.3.5",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-mock": "^2.9.6", "vite-plugin-mock": "^2.9.6",
"vite-plugin-remove-console": "^1.1.0", "vite-plugin-remove-console": "^1.1.0",
"vite-svg-loader": "^3.4.0", "vite-svg-loader": "^3.6.0",
"vue-eslint-parser": "^8.2.0", "vue-eslint-parser": "^8.2.0",
"vue-tsc": "^0.40.1" "vue-tsc": "^0.40.13"
}, },
"pnpm": { "pnpm": {
"peerDependencyRules": { "peerDependencyRules": {
"ignoreMissing": [ "ignoreMissing": [
"rollup", "rollup",
"terser",
"webpack" "webpack"
] ]
} }

2865
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,8 @@
module.exports = { module.exports = {
plugins: [require("autoprefixer"), require("postcss-import")] plugins: {
"postcss-import": {},
tailwindcss: {},
autoprefixer: {},
...(process.env.NODE_ENV === "production" ? { cssnano: {} } : {})
}
}; };

View File

@@ -95,7 +95,6 @@
.c:active { .c:active {
transform: translate(0px, 4px); transform: translate(0px, 4px);
-webkit-transform: translate(0px, 4px);
box-shadow: 0px 1px 0px 0px #3486d5; box-shadow: 0px 1px 0px 0px #3486d5;
} }
@@ -223,8 +222,6 @@
} }
input[type="checkbox"].toggle { input[type="checkbox"].toggle {
-moz-appearance: none;
-webkit-appearance: none;
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
@@ -299,36 +296,6 @@
animation: anim-out-pseudo 0.75s; animation: anim-out-pseudo 0.75s;
} }
@-webkit-keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
@-moz-keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
@-ms-keyframes anim-in {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
@keyframes anim-in { @keyframes anim-in {
0% { 0% {
width: 0%; width: 0%;
@@ -339,36 +306,6 @@
} }
} }
@-webkit-keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.3);
}
100% {
background: transparent;
}
}
@-moz-keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.3);
}
100% {
background: transparent;
}
}
@-ms-keyframes anim-in-pseudo {
0% {
background: rgba(0, 0, 0, 0.3);
}
100% {
background: transparent;
}
}
@keyframes anim-in-pseudo { @keyframes anim-in-pseudo {
0% { 0% {
background: rgba(0, 0, 0, 0.3); background: rgba(0, 0, 0, 0.3);
@@ -379,36 +316,6 @@
} }
} }
@-webkit-keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
@-moz-keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
@-ms-keyframes anim-out {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
@keyframes anim-out { @keyframes anim-out {
0% { 0% {
width: 0%; width: 0%;
@@ -419,36 +326,6 @@
} }
} }
@-webkit-keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.35);
}
100% {
background: transparent;
}
}
@-moz-keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.35);
}
100% {
background: transparent;
}
}
@-ms-keyframes anim-out-pseudo {
0% {
background: rgba(0, 0, 0, 0.35);
}
100% {
background: transparent;
}
}
@keyframes anim-out-pseudo { @keyframes anim-out-pseudo {
0% { 0% {
background: rgba(0, 0, 0, 0.35); background: rgba(0, 0, 0, 0.35);
@@ -515,9 +392,6 @@
.php, .php,
.php::after { .php::after {
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s; transition: all 0.5s;
} }

View File

@@ -1,5 +1,5 @@
{ {
"Version": "3.4.6", "Version": "3.6.1",
"Title": "PureAdmin", "Title": "PureAdmin",
"FixedHeader": true, "FixedHeader": true,
"HiddenSideBar": false, "HiddenSideBar": false,

View File

@@ -1,15 +1,14 @@
import { http } from "../utils/http"; import { http } from "../utils/http";
type Result = { type Result = {
success: boolean;
data?: { data?: {
/** 列表数据 */ /** 列表数据 */
list: Array<any>; list: Array<any>;
}; };
code?: number;
msg?: string;
}; };
// 卡片列表 /** 卡片列表 */
export const getCardList = (data?: object) => { export const getCardList = (data?: object) => {
return http.request<Result>("post", "/getCardList", { data }); return http.request<Result>("post", "/getCardList", { data });
}; };

View File

@@ -1,11 +1,11 @@
import { http } from "../utils/http"; import { http } from "../utils/http";
type Result = { type Result = {
code: number; success: boolean;
info: Array<any>; data: Array<any>;
}; };
// 地图数据 /** 地图数据 */
export const mapJson = (params?: object) => { export const mapJson = (params?: object) => {
return http.request<Result>("get", "/getMapInfo", { params }); return http.request<Result>("get", "/getMapInfo", { params });
}; };

View File

@@ -1,10 +1,10 @@
import { http } from "../utils/http"; import { http } from "../utils/http";
type Result = { type Result = {
code: number; success: boolean;
info: Array<any>; data: Array<any>;
}; };
export const getAsyncRoutes = (params?: object) => { export const getAsyncRoutes = () => {
return http.request<Result>("get", "/getAsyncRoutes", { params }); return http.request<Result>("get", "/getAsyncRoutes");
}; };

View File

@@ -1,27 +1,26 @@
import { http } from "../utils/http"; import { http } from "../utils/http";
type Result = { type Result = {
success: boolean;
data?: { data?: {
/** 列表数据 */ /** 列表数据 */
list: Array<any>; list: Array<any>;
/** 总数 */ /** 总数 */
total: number; total?: number;
}; };
code?: number;
msg?: string;
}; };
// 获取用户管理列表 /** 获取用户管理列表 */
export const getUserList = (data?: object) => { export const getUserList = (data?: object) => {
return http.request<Result>("post", "/user", { data }); return http.request<Result>("post", "/user", { data });
}; };
// 获取角色管理列表 /** 获取角色管理列表 */
export const getRoleList = (data?: object) => { export const getRoleList = (data?: object) => {
return http.request<Result>("post", "/role", { data }); return http.request<Result>("post", "/role", { data });
}; };
// 获取部门管理列表 /** 获取部门管理列表 */
export const getDeptList = (data?: object) => { export const getDeptList = (data?: object) => {
return http.request<Result>("post", "/dept", { data }); return http.request<Result>("post", "/dept", { data });
}; };

View File

@@ -1,26 +1,39 @@
import { http } from "../utils/http"; import { http } from "../utils/http";
type Result = { export type UserResult = {
svg?: string; success: boolean;
code?: number; data: {
info?: object; /** 用户名 */
username: string;
/** 当前登陆用户的角色 */
roles: Array<string>;
/** `token` */
accessToken: string;
/** 用于调用刷新`accessToken`的接口时所需的`token` */
refreshToken: string;
/** `accessToken`的过期时间(格式'xxxx/xx/xx xx:xx:xx' */
expires: Date;
};
}; };
// 获取验证码 export type RefreshTokenResult = {
export const getVerify = () => { success: boolean;
return http.request<Result>("get", "/captcha"); data: {
/** `token` */
accessToken: string;
/** 用于调用刷新`accessToken`的接口时所需的`token` */
refreshToken: string;
/** `accessToken`的过期时间(格式'xxxx/xx/xx xx:xx:xx' */
expires: Date;
};
}; };
// 登录 /** 登录 */
export const getLogin = (data: object) => { export const getLogin = (data?: object) => {
return http.request("post", "/login", { data }); return http.request<UserResult>("post", "/login", { data });
}; };
// 刷新token /** 刷新token */
export const refreshToken = (data: object) => { export const refreshTokenApi = (data?: object) => {
return http.request("post", "/refreshToken", { data }); return http.request<RefreshTokenResult>("post", "/refreshToken", { data });
}; };
// export const searchVague = (data: object) => {
// return http.request("post", "/searchVague", { data });
// };

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 36 36"><path d="M19.41 18l8.29-8.29a1 1 0 0 0-1.41-1.41L18 16.59l-8.29-8.3a1 1 0 0 0-1.42 1.42l8.3 8.29l-8.3 8.29A1 1 0 1 0 9.7 27.7l8.3-8.29l8.29 8.29a1 1 0 0 0 1.41-1.41z" fill="currentColor"></path></svg>

Before

Width:  |  Height:  |  Size: 395 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 36 36"><path d="M26 17H10a1 1 0 0 0 0 2h16a1 1 0 0 0 0-2z" fill="currentColor"></path></svg>

Before

Width:  |  Height:  |  Size: 279 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none"><path d="M7 12l7 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M7 12l7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M21 12H7.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" ></path><path d="M3 3v18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></g></svg>

Before

Width:  |  Height:  |  Size: 647 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 20 20"><path d="M3 5h14V3H3v2zm12 8V7H5v6h10zM3 17h14v-2H3v2z" fill="currentColor"></path></svg>

Before

Width:  |  Height:  |  Size: 284 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g transform="translate(24 0) scale(-1 1)"><g fill="none"><path d="M7 12l7 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M7 12l7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M21 12H7.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M3 3v18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></g></g></svg>

Before

Width:  |  Height:  |  Size: 693 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 512 512"><path d="M400 148l-21.12-24.57A191.43 191.43 0 0 0 240 64C134 64 48 150 48 256s86 192 192 192a192.09 192.09 0 0 0 181.07-128" fill="none" stroke="currentColor" stroke-linecap="square" stroke-miterlimit="10" stroke-width="32"></path><path d="M464 68.45V220a4 4 0 0 1-4 4H308.45a4 4 0 0 1-2.83-6.83L457.17 65.62a4 4 0 0 1 6.83 2.83z" fill="currentColor"></path></svg>

Before

Width:  |  Height:  |  Size: 561 B

View File

@@ -0,0 +1,5 @@
import auth from "./src/auth";
const Auth = auth;
export { Auth };

View File

@@ -0,0 +1,20 @@
import { defineComponent, Fragment } from "vue";
import { hasAuth } from "/@/router/utils";
export default defineComponent({
name: "Auth",
props: {
value: {
type: undefined,
default: []
}
},
setup(props, { slots }) {
return () => {
if (!slots) return null;
return hasAuth(props.value) ? (
<Fragment>{slots.default?.()}</Fragment>
) : null;
};
}
});

View File

@@ -102,7 +102,7 @@ onMounted(() => {
v-for="(item, key) in titleLists" v-for="(item, key) in titleLists"
:key="key" :key="key"
:title="item.text" :title="item.text"
class="dark:color-bg_color" class="dark:text-bg_color"
@mouseenter.prevent="onEnter(key)" @mouseenter.prevent="onEnter(key)"
@mouseleave.prevent="focusIndex = -1" @mouseleave.prevent="focusIndex = -1"
> >
@@ -116,7 +116,8 @@ onMounted(() => {
:disabled="item.disabled" :disabled="item.disabled"
:style="{ :style="{
cursor: item.disabled === false ? 'pointer' : 'not-allowed', cursor: item.disabled === false ? 'pointer' : 'not-allowed',
color: item.disabled === false ? '' : '#00000040' color: item.disabled === false ? '' : '#00000040',
background: 'transparent'
}" }"
@click="onControl(item, key)" @click="onControl(item, key)"
> >

View File

@@ -35,7 +35,7 @@ const nodeDragNode = item => {
<!-- 左侧bpmn元素选择器 --> <!-- 左侧bpmn元素选择器 -->
<div class="node-panel"> <div class="node-panel">
<div <div
class="node-item dark:color-bg_color" class="node-item dark:text-bg_color"
v-for="item in props.nodeList" v-for="item in props.nodeList"
:key="item.text" :key="item.text"
@mousedown="nodeDragNode(item)" @mousedown="nodeDragNode(item)"

View File

@@ -118,7 +118,7 @@ watch(
</script> </script>
<template> <template>
<div class="selector w-350px"> <div class="selector w-[350px]">
<el-input v-model="inputValue" disabled> <el-input v-model="inputValue" disabled>
<template #append> <template #append>
<el-popover <el-popover
@@ -132,7 +132,7 @@ watch(
> >
<template #reference> <template #reference>
<div <div
class="w-40px h-32px cursor-pointer flex justify-center items-center" class="w-[40px] h-[32px] cursor-pointer flex justify-center items-center"
@click="visible = !visible" @click="visible = !visible"
> >
<IconifyIconOnline :icon="currentActiveType + icon" /> <IconifyIconOnline :icon="currentActiveType + icon" />
@@ -156,12 +156,12 @@ watch(
> >
<el-divider class="tab-divider" border-style="dashed" /> <el-divider class="tab-divider" border-style="dashed" />
<el-scrollbar height="220px"> <el-scrollbar height="220px">
<ul class="flex-wrap px-2 ml-2"> <ul class="flex flex-wrap px-2 ml-2">
<li <li
v-for="(item, key) in pageList" v-for="(item, key) in pageList"
:key="key" :key="key"
:title="item" :title="item"
class="icon-item p-2 w-1/10 cursor-pointer mr-2 mt-1 flex justify-center items-center border border-solid" class="icon-item p-2 w-[1/10] cursor-pointer mr-2 mt-1 flex justify-center items-center border border-solid"
:style="iconItemStyle(item)" :style="iconItemStyle(item)"
@click="onChangeIcon(item)" @click="onChangeIcon(item)"
> >

View File

@@ -7,13 +7,11 @@ import Menu from "@iconify-icons/ep/menu";
import HomeFilled from "@iconify-icons/ep/home-filled"; import HomeFilled from "@iconify-icons/ep/home-filled";
import SetUp from "@iconify-icons/ep/set-up"; import SetUp from "@iconify-icons/ep/set-up";
import Edit from "@iconify-icons/ep/edit"; import Edit from "@iconify-icons/ep/edit";
import Setting from "@iconify-icons/ep/setting";
import Lollipop from "@iconify-icons/ep/lollipop"; import Lollipop from "@iconify-icons/ep/lollipop";
import Link from "@iconify-icons/ep/link"; import Link from "@iconify-icons/ep/link";
import Position from "@iconify-icons/ep/position"; import Position from "@iconify-icons/ep/position";
import Histogram from "@iconify-icons/ep/histogram"; import Histogram from "@iconify-icons/ep/histogram";
import RefreshRight from "@iconify-icons/ep/refresh-right"; import RefreshRight from "@iconify-icons/ep/refresh-right";
import ArrowDown from "@iconify-icons/ep/arrow-down";
import Close from "@iconify-icons/ep/close"; import Close from "@iconify-icons/ep/close";
import CloseBold from "@iconify-icons/ep/close-bold"; import CloseBold from "@iconify-icons/ep/close-bold";
import Bell from "@iconify-icons/ep/bell"; import Bell from "@iconify-icons/ep/bell";
@@ -36,13 +34,11 @@ addIcon("menu", Menu);
addIcon("home-filled", HomeFilled); addIcon("home-filled", HomeFilled);
addIcon("set-up", SetUp); addIcon("set-up", SetUp);
addIcon("edit", Edit); addIcon("edit", Edit);
addIcon("setting", Setting);
addIcon("lollipop", Lollipop); addIcon("lollipop", Lollipop);
addIcon("link", Link); addIcon("link", Link);
addIcon("position", Position); addIcon("position", Position);
addIcon("histogram", Histogram); addIcon("histogram", Histogram);
addIcon("refresh-right", RefreshRight); addIcon("refresh-right", RefreshRight);
addIcon("arrow-down", ArrowDown);
addIcon("close", Close); addIcon("close", Close);
addIcon("close-bold", CloseBold); addIcon("close-bold", CloseBold);
addIcon("bell", Bell); addIcon("bell", Bell);
@@ -89,6 +85,14 @@ import User from "@iconify-icons/ri/user-3-fill";
import Lock from "@iconify-icons/ri/lock-fill"; import Lock from "@iconify-icons/ri/lock-fill";
import MenuUnfold from "@iconify-icons/ri/menu-unfold-fill"; import MenuUnfold from "@iconify-icons/ri/menu-unfold-fill";
import MenuFold from "@iconify-icons/ri/menu-fold-fill"; import MenuFold from "@iconify-icons/ri/menu-fold-fill";
import Setting from "@iconify-icons/ri/settings-3-line";
import ArrowDown from "@iconify-icons/ri/arrow-down-s-line";
import CloseLeftTags from "@iconify-icons/ri/text-direction-r";
import CloseRightTags from "@iconify-icons/ri/text-direction-l";
import CloseOtherTags from "@iconify-icons/ri/text-spacing";
import CloseAllTags from "@iconify-icons/ri/subtract-line";
import Fullscreen from "@iconify-icons/ri/fullscreen-fill";
import ExitFullscreen from "@iconify-icons/ri/fullscreen-exit-fill";
addIcon("arrow-right-s-line", ArrowRightSLine); addIcon("arrow-right-s-line", ArrowRightSLine);
addIcon("arrow-left-s-line", ArrowLeftSLine); addIcon("arrow-left-s-line", ArrowLeftSLine);
addIcon("logout-circle-r-line", LogoutCircleRLine); addIcon("logout-circle-r-line", LogoutCircleRLine);
@@ -116,6 +120,14 @@ addIcon("user", User);
addIcon("lock", Lock); addIcon("lock", Lock);
addIcon("menu-unfold", MenuUnfold); addIcon("menu-unfold", MenuUnfold);
addIcon("menu-fold", MenuFold); addIcon("menu-fold", MenuFold);
addIcon("setting", Setting);
addIcon("arrow-down", ArrowDown);
addIcon("close-left-tags", CloseLeftTags);
addIcon("close-right-tags", CloseRightTags);
addIcon("close-other-tags", CloseOtherTags);
addIcon("close-all-tags", CloseAllTags);
addIcon("fullscreen", Fullscreen);
addIcon("exit-fullscreen", ExitFullscreen);
// Font Awesome 4 // Font Awesome 4
import FaUser from "@iconify-icons/fa/user"; import FaUser from "@iconify-icons/fa/user";

View File

@@ -92,8 +92,8 @@ onBeforeMount(() => {
// 获取模拟车辆信息 // 获取模拟车辆信息
mapJson() mapJson()
.then(({ info }) => { .then(({ data }) => {
let points: object = info.map(v => { let points: object = data.map(v => {
return { return {
lnglat: [v.lng, v.lat], lnglat: [v.lng, v.lat],
...v ...v

View File

@@ -78,7 +78,7 @@ export default defineComponent({
const _width: number = await getOriginWidth(unref(renderText), options); const _width: number = await getOriginWidth(unref(renderText), options);
options.scale = options.scale =
props.width === 0 ? undefined : (props.width / _width) * 4; props.width === 0 ? undefined : (props.width / _width) * 4;
const canvasRef: HTMLCanvasElement = await toCanvas( const canvasRef: any = await toCanvas(
unref(wrapRef) as HTMLCanvasElement, unref(wrapRef) as HTMLCanvasElement,
unref(renderText), unref(renderText),
options options

View File

@@ -166,7 +166,7 @@ let autoPlay = computed(() => {
}); });
let scrollSwitch = computed(() => { let scrollSwitch = computed(() => {
// 从 props 解构出来的 属性 不再具有应性. // 从 props 解构出来的 属性 不再具有应性.
return (props.data as any).length >= unref(options).limitMoveNum; return (props.data as any).length >= unref(options).limitMoveNum;
}); });

View File

@@ -117,12 +117,12 @@ export default defineComponent({
<> <>
<div <div
{...attrs} {...attrs}
class="w-99/100 mt-6 p-2 bg-white dark:bg-dark" class="w-[99/100] mt-6 p-2 bg-bg_color"
v-loading={props.loading} v-loading={props.loading}
element-loading-svg={loadingSvg} element-loading-svg={loadingSvg}
element-loading-svg-view-box="-10, -10, 50, 50" element-loading-svg-view-box="-10, -10, 50, 50"
> >
<div class="flex justify-between w-full h-60px p-4"> <div class="flex justify-between w-full h-[60px] p-4">
<p class="font-bold truncate">{props.title}</p> <p class="font-bold truncate">{props.title}</p>
<div class="flex items-center justify-around"> <div class="flex items-center justify-around">
<div class="flex mr-4">{slots?.buttons()}</div> <div class="flex mr-4">{slots?.buttons()}</div>

View File

@@ -0,0 +1,44 @@
import { h, defineComponent } from "vue";
import TypeIt from "typeit";
// 打字机效果组件(只是简单的封装下,更多配置项参考 https://www.typeitjs.com/docs/vanilla/usage#options
export default defineComponent({
name: "TypeIt",
props: {
/** 打字速度,以每一步之间的毫秒数为单位 */
speed: {
type: Number,
default: 200
},
values: {
type: Array,
defalut: []
},
className: {
type: String,
default: "type-it"
},
cursor: {
type: Boolean,
default: true
}
},
render() {
return h(
"span",
{
class: this.className
},
{
default: () => []
}
);
},
mounted() {
new TypeIt(`.${this.className}`, {
strings: this.values,
speed: this.speed,
cursor: this.cursor
}).go();
}
});

View File

@@ -27,7 +27,7 @@ const getConfig = (key?: string): ServerConfigs => {
return config; return config;
}; };
// 获取项目动态全局配置 /** 获取项目动态全局配置 */
export const getServerConfig = async (app: App): Promise<undefined> => { export const getServerConfig = async (app: App): Promise<undefined> => {
app.config.globalProperties.$config = getConfig(); app.config.globalProperties.$config = getConfig();
return axios({ return axios({

View File

@@ -0,0 +1,13 @@
import { hasAuth } from "/@/router/utils";
import { Directive, type DirectiveBinding } from "vue";
export const auth: Directive = {
mounted(el: HTMLElement, binding: DirectiveBinding) {
const { value } = binding;
if (value) {
!hasAuth(value) && el.parentNode.removeChild(el);
} else {
throw new Error("need auths! Like v-auth=\"['btn.add','btn.edit']\"");
}
}
};

View File

@@ -1,7 +1,6 @@
import { Directive, type DirectiveBinding, type VNode } from "vue"; import { Directive, type DirectiveBinding, type VNode } from "vue";
import elementResizeDetectorMaker from "element-resize-detector"; import elementResizeDetectorMaker from "element-resize-detector";
import type { Erd } from "element-resize-detector"; import type { Erd } from "element-resize-detector";
import { optimizeFps } from "@pureadmin/utils";
import { emitter } from "/@/utils/mitt"; import { emitter } from "/@/utils/mitt";
const erd: Erd = elementResizeDetectorMaker({ const erd: Erd = elementResizeDetectorMaker({
@@ -14,9 +13,7 @@ export const resize: Directive = {
const width = elem.offsetWidth; const width = elem.offsetWidth;
const height = elem.offsetHeight; const height = elem.offsetHeight;
if (binding?.instance) { if (binding?.instance) {
optimizeFps(() => { emitter.emit("resize", { detail: { width, height } });
emitter.emit("resize", { detail: { width, height } });
})();
} else { } else {
vnode.el.dispatchEvent( vnode.el.dispatchEvent(
new CustomEvent("resize", { detail: { width, height } }) new CustomEvent("resize", { detail: { width, height } })

View File

@@ -1,2 +1,2 @@
export * from "./permission"; export * from "./auth";
export * from "./elResizeDetector"; export * from "./elResizeDetector";

View File

@@ -1,18 +0,0 @@
import { usePermissionStoreHook } from "/@/store/modules/permission";
import { Directive } from "vue";
import type { DirectiveBinding } from "vue";
export const auth: Directive = {
mounted(el: HTMLElement, binding: DirectiveBinding) {
const { value } = binding;
if (value) {
const authRoles = value;
const hasAuth = usePermissionStoreHook().buttonAuth.includes(authRoles);
if (!hasAuth) {
el.parentNode.removeChild(el);
}
} else {
throw new Error("need roles! Like v-auth=\"['admin','test']\"");
}
}
};

View File

@@ -5,9 +5,7 @@ import mixNav from "./sidebar/mixNav.vue";
import avatars from "/@/assets/avatars.jpg"; import avatars from "/@/assets/avatars.jpg";
import { useNav } from "/@/layout/hooks/useNav"; import { useNav } from "/@/layout/hooks/useNav";
import Breadcrumb from "./sidebar/breadCrumb.vue"; import Breadcrumb from "./sidebar/breadCrumb.vue";
import { deviceDetection } from "@pureadmin/utils";
import topCollapse from "./sidebar/topCollapse.vue"; import topCollapse from "./sidebar/topCollapse.vue";
import screenfull from "../components/screenfull/index.vue";
import { useTranslationLang } from "../hooks/useTranslationLang"; import { useTranslationLang } from "../hooks/useTranslationLang";
import globalization from "/@/assets/svg/globalization.svg?component"; import globalization from "/@/assets/svg/globalization.svg?component";
@@ -50,18 +48,16 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
<Search /> <Search />
<!-- 通知 --> <!-- 通知 -->
<Notice id="header-notice" /> <Notice id="header-notice" />
<!-- 全屏 -->
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
<!-- 国际化 --> <!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click"> <el-dropdown id="header-translation" trigger="click">
<globalization <globalization
class="navbar-bg-hover w-40px h-48px p-11px cursor-pointer outline-none" class="navbar-bg-hover w-[40px] h-[48px] p-[11px] cursor-pointer outline-none"
/> />
<template #dropdown> <template #dropdown>
<el-dropdown-menu class="translation"> <el-dropdown-menu class="translation">
<el-dropdown-item <el-dropdown-item
:style="getDropdownItemStyle(locale, 'zh')" :style="getDropdownItemStyle(locale, 'zh')"
:class="['!dark:color-white', getDropdownItemClass(locale, 'zh')]" :class="['dark:!text-white', getDropdownItemClass(locale, 'zh')]"
@click="translationCh" @click="translationCh"
> >
<IconifyIconOffline <IconifyIconOffline
@@ -73,7 +69,7 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:style="getDropdownItemStyle(locale, 'en')" :style="getDropdownItemStyle(locale, 'en')"
:class="['!dark:color-white', getDropdownItemClass(locale, 'en')]" :class="['dark:!text-white', getDropdownItemClass(locale, 'en')]"
@click="translationEn" @click="translationEn"
> >
<span class="check-en" v-show="locale === 'en'"> <span class="check-en" v-show="locale === 'en'">
@@ -88,7 +84,7 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover"> <span class="el-dropdown-link navbar-bg-hover">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" /> <img v-if="avatars" :src="avatars" :style="avatarsStyle" />
<p v-if="username" class="dark:color-white">{{ username }}</p> <p v-if="username" class="dark:text-white">{{ username }}</p>
</span> </span>
<template #dropdown> <template #dropdown>
<el-dropdown-menu class="logout"> <el-dropdown-menu class="logout">
@@ -103,7 +99,7 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
</template> </template>
</el-dropdown> </el-dropdown>
<span <span
class="el-icon-setting navbar-bg-hover" class="set-icon navbar-bg-hover"
:title="t('buttons.hssystemSet')" :title="t('buttons.hssystemSet')"
@click="onPanel" @click="onPanel"
> >
@@ -153,15 +149,6 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
border-radius: 50%; border-radius: 50%;
} }
} }
.el-icon-setting {
height: 48px;
width: 38px;
padding: 12px;
display: flex;
cursor: pointer;
align-items: center;
}
} }
.breadcrumb-container { .breadcrumb-container {

View File

@@ -45,7 +45,7 @@ function hoverDescription(event, description) {
<template> <template>
<div <div
class="notice-container border-b-1 border-[#f0f0f0] dark:border-[#303030]" class="notice-container border-b-[1px] border-solid border-[#f0f0f0] dark:border-[#303030]"
> >
<el-avatar <el-avatar
v-if="props.noticeItem.avatar" v-if="props.noticeItem.avatar"
@@ -54,7 +54,7 @@ function hoverDescription(event, description) {
class="notice-container-avatar" class="notice-container-avatar"
/> />
<div class="notice-container-text"> <div class="notice-container-text">
<div class="notice-text-title color-[#000000d9] dark:color-white"> <div class="notice-text-title text-[#000000d9] dark:text-white">
<el-tooltip <el-tooltip
popper-class="notice-title-popper" popper-class="notice-title-popper"
:disabled="!titleTooltip" :disabled="!titleTooltip"
@@ -93,7 +93,7 @@ function hoverDescription(event, description) {
{{ props.noticeItem.description }} {{ props.noticeItem.description }}
</div> </div>
</el-tooltip> </el-tooltip>
<div class="notice-text-datetime color-[#00000073] dark:color-white"> <div class="notice-text-datetime text-[#00000073] dark:text-white">
{{ props.noticeItem.datetime }} {{ props.noticeItem.datetime }}
</div> </div>
</div> </div>

View File

@@ -18,15 +18,21 @@ emitter.on("openPanel", () => {
<template> <template>
<div :class="{ show: show }" class="right-panel-container"> <div :class="{ show: show }" class="right-panel-container">
<div class="right-panel-background" /> <div class="right-panel-background" />
<div ref="target" class="right-panel bg-white dark:bg-dark"> <div ref="target" class="right-panel bg-bg_color">
<div class="right-panel-items"> <div class="right-panel-items">
<div class="project-configuration"> <div class="project-configuration">
<h3>项目配置</h3> <h3 class="dark:text-white">项目配置</h3>
<el-icon title="关闭配置" class="el-icon-close" @click="show = !show"> <span title="关闭配置">
<IconifyIconOffline icon="close" /> <IconifyIconOffline
</el-icon> class="dark:text-white"
icon="close"
@click="show = !show"
/>
</span>
</div> </div>
<div class="border-b-1 border-[#dcdfe6] dark:border-[#303030]" /> <div
class="border-b-[1px] border-solid border-[#dcdfe6] dark:border-[#303030]"
/>
<slot /> <slot />
</div> </div>
</div> </div>
@@ -119,7 +125,7 @@ emitter.on("openPanel", () => {
top: 15px; top: 15px;
margin-left: 10px; margin-left: 10px;
i { svg {
font-size: 20px; font-size: 20px;
margin-right: 20px; margin-right: 20px;

View File

@@ -8,7 +8,7 @@ const { isFullscreen, toggle } = useFullscreen();
<template> <template>
<div <div
class="screen-full w-36px h-48px flex-ac cursor-pointer navbar-bg-hover" class="screen-full w-[36px] h-[48px] flex-ac cursor-pointer navbar-bg-hover"
@click="toggle" @click="toggle"
> >
<FontIcon <FontIcon

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="search-footer color-[#333] dark:color-white"> <div class="search-footer text-[#333] dark:text-white">
<span class="search-footer-item"> <span class="search-footer-item">
<enterOutlined class="icon" /> <enterOutlined class="icon" />
确认 确认

View File

@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { cloneDeep } from "lodash-unified";
import SearchResult from "./SearchResult.vue"; import SearchResult from "./SearchResult.vue";
import SearchFooter from "./SearchFooter.vue"; import SearchFooter from "./SearchFooter.vue";
import { useNav } from "/@/layout/hooks/useNav"; import { useNav } from "/@/layout/hooks/useNav";
@@ -31,7 +32,7 @@ const handleSearch = useDebounceFn(search, 300);
/** 菜单树形结构 */ /** 菜单树形结构 */
const menusData = computed(() => { const menusData = computed(() => {
return deleteChildren(usePermissionStoreHook().menusTree); return deleteChildren(cloneDeep(usePermissionStoreHook().wholeMenus));
}); });
const show = computed({ const show = computed({

View File

@@ -9,7 +9,7 @@ function handleSearch() {
<template> <template>
<div <div
class="search-container w-40px h-48px flex-c cursor-pointer navbar-bg-hover" class="search-container w-[40px] h-[48px] flex-c cursor-pointer navbar-bg-hover"
@click="handleSearch" @click="handleSearch"
> >
<IconifyIconOffline icon="search" /> <IconifyIconOffline icon="search" />

View File

@@ -14,6 +14,7 @@ import panel from "../panel/index.vue";
import { emitter } from "/@/utils/mitt"; import { emitter } from "/@/utils/mitt";
import { resetRouter } from "/@/router"; import { resetRouter } from "/@/router";
import { templateRef } from "@vueuse/core"; import { templateRef } from "@vueuse/core";
import { removeToken } from "/@/utils/auth";
import { routerArrays } from "/@/layout/types"; import { routerArrays } from "/@/layout/types";
import { useNav } from "/@/layout/hooks/useNav"; import { useNav } from "/@/layout/hooks/useNav";
import { useAppStoreHook } from "/@/store/modules/app"; import { useAppStoreHook } from "/@/store/modules/app";
@@ -131,16 +132,17 @@ const multiTagsCacheChange = () => {
/** 清空缓存并返回登录页 */ /** 清空缓存并返回登录页 */
function onReset() { function onReset() {
router.push("/login"); removeToken();
storageLocal.clear();
storageSession.clear();
const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig(); const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig();
useAppStoreHook().setLayout(Layout); useAppStoreHook().setLayout(Layout);
setEpThemeColor(EpThemeColor); setEpThemeColor(EpThemeColor);
useMultiTagsStoreHook().multiTagsCacheChange(MultiTagsCache); useMultiTagsStoreHook().multiTagsCacheChange(MultiTagsCache);
toggleClass(Grey, "html-grey", document.querySelector("html")); toggleClass(Grey, "html-grey", document.querySelector("html"));
toggleClass(Weak, "html-weakness", document.querySelector("html")); toggleClass(Weak, "html-weakness", document.querySelector("html"));
router.push("/login");
useMultiTagsStoreHook().handleTags("equal", [...routerArrays]); useMultiTagsStoreHook().handleTags("equal", [...routerArrays]);
storageLocal.clear();
storageSession.clear();
resetRouter(); resetRouter();
} }
@@ -309,7 +311,7 @@ nextTick(() => {
<el-divider>界面显示</el-divider> <el-divider>界面显示</el-divider>
<ul class="setting"> <ul class="setting">
<li> <li>
<span>灰色模式</span> <span class="dark:text-white">灰色模式</span>
<el-switch <el-switch
v-model="settings.greyVal" v-model="settings.greyVal"
inline-prompt inline-prompt
@@ -320,7 +322,7 @@ nextTick(() => {
/> />
</li> </li>
<li> <li>
<span>色弱模式</span> <span class="dark:text-white">色弱模式</span>
<el-switch <el-switch
v-model="settings.weakVal" v-model="settings.weakVal"
inline-prompt inline-prompt
@@ -331,7 +333,7 @@ nextTick(() => {
/> />
</li> </li>
<li> <li>
<span>隐藏标签页</span> <span class="dark:text-white">隐藏标签页</span>
<el-switch <el-switch
v-model="settings.tabsVal" v-model="settings.tabsVal"
inline-prompt inline-prompt
@@ -342,7 +344,7 @@ nextTick(() => {
/> />
</li> </li>
<li> <li>
<span>侧边栏Logo</span> <span class="dark:text-white">侧边栏Logo</span>
<el-switch <el-switch
v-model="logoVal" v-model="logoVal"
inline-prompt inline-prompt
@@ -355,7 +357,7 @@ nextTick(() => {
/> />
</li> </li>
<li> <li>
<span>标签页持久化</span> <span class="dark:text-white">标签页持久化</span>
<el-switch <el-switch
v-model="settings.multiTagsCache" v-model="settings.multiTagsCache"
inline-prompt inline-prompt
@@ -367,7 +369,7 @@ nextTick(() => {
</li> </li>
<li> <li>
<span>标签风格</span> <span class="dark:text-white">标签风格</span>
<el-radio-group v-model="markValue" size="small" @change="onChange"> <el-radio-group v-model="markValue" size="small" @change="onChange">
<el-radio label="card">卡片</el-radio> <el-radio label="card">卡片</el-radio>
<el-radio label="smart">灵动</el-radio> <el-radio label="smart">灵动</el-radio>

View File

@@ -1,12 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from "vue";
import Search from "../search/index.vue"; import Search from "../search/index.vue";
import Notice from "../notice/index.vue"; import Notice from "../notice/index.vue";
import { ref, watch, nextTick } from "vue";
import SidebarItem from "./sidebarItem.vue"; import SidebarItem from "./sidebarItem.vue";
import avatars from "/@/assets/avatars.jpg"; import avatars from "/@/assets/avatars.jpg";
import { useNav } from "/@/layout/hooks/useNav"; import { useNav } from "/@/layout/hooks/useNav";
import screenfull from "../screenfull/index.vue";
import { deviceDetection } from "@pureadmin/utils";
import { useTranslationLang } from "../../hooks/useTranslationLang"; import { useTranslationLang } from "../../hooks/useTranslationLang";
import { usePermissionStoreHook } from "/@/store/modules/permission"; import { usePermissionStoreHook } from "/@/store/modules/permission";
import globalization from "/@/assets/svg/globalization.svg?component"; import globalization from "/@/assets/svg/globalization.svg?component";
@@ -28,6 +26,10 @@ const {
getDropdownItemClass getDropdownItemClass
} = useNav(); } = useNav();
nextTick(() => {
menuRef.value?.handleResize();
});
watch( watch(
() => route.path, () => route.path,
() => { () => {
@@ -62,18 +64,16 @@ watch(
<Search /> <Search />
<!-- 通知 --> <!-- 通知 -->
<Notice id="header-notice" /> <Notice id="header-notice" />
<!-- 全屏 -->
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
<!-- 国际化 --> <!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click"> <el-dropdown id="header-translation" trigger="click">
<globalization <globalization
class="navbar-bg-hover w-40px h-48px p-11px cursor-pointer outline-none" class="navbar-bg-hover w-[40px] h-[48px] p-[11px] cursor-pointer outline-none"
/> />
<template #dropdown> <template #dropdown>
<el-dropdown-menu class="translation"> <el-dropdown-menu class="translation">
<el-dropdown-item <el-dropdown-item
:style="getDropdownItemStyle(locale, 'zh')" :style="getDropdownItemStyle(locale, 'zh')"
:class="['!dark:color-white', getDropdownItemClass(locale, 'zh')]" :class="['dark:!text-white', getDropdownItemClass(locale, 'zh')]"
@click="translationCh" @click="translationCh"
> >
<span class="check-zh" v-show="locale === 'zh'"> <span class="check-zh" v-show="locale === 'zh'">
@@ -83,7 +83,7 @@ watch(
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:style="getDropdownItemStyle(locale, 'en')" :style="getDropdownItemStyle(locale, 'en')"
:class="['!dark:color-white', getDropdownItemClass(locale, 'en')]" :class="['dark:!text-white', getDropdownItemClass(locale, 'en')]"
@click="translationEn" @click="translationEn"
> >
<span class="check-en" v-show="locale === 'en'"> <span class="check-en" v-show="locale === 'en'">
@@ -98,7 +98,7 @@ watch(
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover"> <span class="el-dropdown-link navbar-bg-hover">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" /> <img v-if="avatars" :src="avatars" :style="avatarsStyle" />
<p v-if="username" class="dark:color-white">{{ username }}</p> <p v-if="username" class="dark:text-white">{{ username }}</p>
</span> </span>
<template #dropdown> <template #dropdown>
<el-dropdown-menu class="logout"> <el-dropdown-menu class="logout">
@@ -113,7 +113,7 @@ watch(
</template> </template>
</el-dropdown> </el-dropdown>
<span <span
class="el-icon-setting navbar-bg-hover" class="set-icon navbar-bg-hover"
:title="t('buttons.hssystemSet')" :title="t('buttons.hssystemSet')"
@click="onPanel" @click="onPanel"
> >

View File

@@ -28,7 +28,7 @@ const toggleClick = () => {
> >
<IconifyIconOffline <IconifyIconOffline
:icon="props.isActive ? 'menu-fold' : 'menu-unfold'" :icon="props.isActive ? 'menu-fold' : 'menu-unfold'"
class="cursor-pointer inline-block align-middle color-primary hover:color-primary !dark:hover:color-white w-16px h-16px ml-4 mb-1" class="cursor-pointer inline-block align-middle text-primary hover:text-primary dark:hover:!text-white w-[16px] h-[16px] ml-4 mb-1"
@click="toggleClick" @click="toggleClick"
/> />
</el-tooltip> </el-tooltip>

View File

@@ -51,6 +51,12 @@ const { title } = useNav();
margin-top: 5px; margin-top: 5px;
.sidebar-title { .sidebar-title {
display: block;
width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left;
color: #1890ff; color: #1890ff;
font-weight: 600; font-weight: 600;
font-size: 20px; font-size: 20px;

View File

@@ -4,9 +4,7 @@ import Notice from "../notice/index.vue";
import avatars from "/@/assets/avatars.jpg"; import avatars from "/@/assets/avatars.jpg";
import { useNav } from "/@/layout/hooks/useNav"; import { useNav } from "/@/layout/hooks/useNav";
import { transformI18n } from "/@/plugins/i18n"; import { transformI18n } from "/@/plugins/i18n";
import screenfull from "../screenfull/index.vue"; import { ref, toRaw, watch, onMounted, nextTick } from "vue";
import { deviceDetection } from "@pureadmin/utils";
import { ref, toRaw, watch, onMounted } from "vue";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks"; import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
import { getParentPaths, findRouteByPath } from "/@/router/utils"; import { getParentPaths, findRouteByPath } from "/@/router/utils";
import { useTranslationLang } from "../../hooks/useTranslationLang"; import { useTranslationLang } from "../../hooks/useTranslationLang";
@@ -45,8 +43,12 @@ onMounted(() => {
getDefaultActive(route.path); getDefaultActive(route.path);
}); });
nextTick(() => {
menuRef.value?.handleResize();
});
watch( watch(
() => route.path, () => [route.path, usePermissionStoreHook().wholeMenus],
() => { () => {
getDefaultActive(route.path); getDefaultActive(route.path);
} }
@@ -94,18 +96,16 @@ watch(
<Search /> <Search />
<!-- 通知 --> <!-- 通知 -->
<Notice id="header-notice" /> <Notice id="header-notice" />
<!-- 全屏 -->
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
<!-- 国际化 --> <!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click"> <el-dropdown id="header-translation" trigger="click">
<globalization <globalization
class="navbar-bg-hover w-40px h-48px p-11px cursor-pointer outline-none" class="navbar-bg-hover w-[40px] h-[48px] p-[11px] cursor-pointer outline-none"
/> />
<template #dropdown> <template #dropdown>
<el-dropdown-menu class="translation"> <el-dropdown-menu class="translation">
<el-dropdown-item <el-dropdown-item
:style="getDropdownItemStyle(locale, 'zh')" :style="getDropdownItemStyle(locale, 'zh')"
:class="['!dark:color-white', getDropdownItemClass(locale, 'zh')]" :class="['dark:!text-white', getDropdownItemClass(locale, 'zh')]"
@click="translationCh" @click="translationCh"
> >
<span class="check-zh" v-show="locale === 'zh'"> <span class="check-zh" v-show="locale === 'zh'">
@@ -115,7 +115,7 @@ watch(
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item <el-dropdown-item
:style="getDropdownItemStyle(locale, 'en')" :style="getDropdownItemStyle(locale, 'en')"
:class="['!dark:color-white', getDropdownItemClass(locale, 'en')]" :class="['dark:!text-white', getDropdownItemClass(locale, 'en')]"
@click="translationEn" @click="translationEn"
> >
<span class="check-en" v-show="locale === 'en'"> <span class="check-en" v-show="locale === 'en'">
@@ -130,7 +130,7 @@ watch(
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover"> <span class="el-dropdown-link navbar-bg-hover">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" /> <img v-if="avatars" :src="avatars" :style="avatarsStyle" />
<p v-if="username" class="dark:color-white">{{ username }}</p> <p v-if="username" class="dark:text-white">{{ username }}</p>
</span> </span>
<template #dropdown> <template #dropdown>
<el-dropdown-menu class="logout"> <el-dropdown-menu class="logout">
@@ -145,7 +145,7 @@ watch(
</template> </template>
</el-dropdown> </el-dropdown>
<span <span
class="el-icon-setting navbar-bg-hover" class="set-icon navbar-bg-hover"
:title="t('buttons.hssystemSet')" :title="t('buttons.hssystemSet')"
@click="onPanel" @click="onPanel"
> >

View File

@@ -24,7 +24,7 @@ const toggleClick = () => {
> >
<IconifyIconOffline <IconifyIconOffline
:icon="props.isActive ? 'menu-fold' : 'menu-unfold'" :icon="props.isActive ? 'menu-fold' : 'menu-unfold'"
class="inline-block align-middle hover:color-primary !dark:hover:color-white" class="inline-block align-middle hover:text-primary dark:hover:!text-white"
/> />
</div> </div>
</template> </template>

View File

@@ -27,7 +27,7 @@ const menuData = computed(() => {
: usePermissionStoreHook().wholeMenus; : usePermissionStoreHook().wholeMenus;
}); });
function getSubMenuData(path) { function getSubMenuData(path: string) {
// path的上级路由组成的数组 // path的上级路由组成的数组
const parentPathArr = getParentPaths( const parentPathArr = getParentPaths(
path, path,
@@ -41,6 +41,7 @@ function getSubMenuData(path) {
if (!parenetRoute?.children) return; if (!parenetRoute?.children) return;
subMenuData.value = parenetRoute?.children; subMenuData.value = parenetRoute?.children;
} }
getSubMenuData(route.path); getSubMenuData(route.path);
onBeforeMount(() => { onBeforeMount(() => {
@@ -50,7 +51,7 @@ onBeforeMount(() => {
}); });
watch( watch(
() => route.path, () => [route.path, usePermissionStoreHook().wholeMenus],
() => { () => {
getSubMenuData(route.path); getSubMenuData(route.path);
menuSelect(route.path, routers); menuSelect(route.path, routers);

View File

@@ -121,21 +121,6 @@
} }
} }
.right-button {
display: flex;
font-size: 16px;
li {
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 38px;
border-right: 1px solid #ccc;
cursor: pointer;
}
}
/* 右键菜单 */ /* 右键菜单 */
.contextmenu { .contextmenu {
margin: 0; margin: 0;
@@ -196,6 +181,9 @@
margin-right: 10px; margin-right: 10px;
} }
:deep(.el-dropdown-menu__item--divided) {
margin: 1px 0;
}
.el-dropdown-menu__item--divided::before { .el-dropdown-menu__item--divided::before {
margin: 0; margin: 0;
} }
@@ -223,7 +211,8 @@
} }
.arrow-left, .arrow-left,
.arrow-right { .arrow-right,
.arrow-down {
width: 40px; width: 40px;
height: 38px; height: 38px;
color: var(--el-text-color-primary); color: var(--el-text-color-primary);
@@ -248,7 +237,7 @@
.arrow-right { .arrow-right {
box-shadow: -5px 0 5px -6px #ccc; box-shadow: -5px 0 5px -6px #ccc;
border-right: 1px solid #ccc; border-right: 0.5px solid #ccc;
&:hover { &:hover {
cursor: e-resize; cursor: e-resize;
@@ -305,8 +294,3 @@
background: var(--el-color-primary); background: var(--el-color-primary);
animation: scheduleOutWidth 400ms ease-in; animation: scheduleOutWidth 400ms ease-in;
} }
/* 刷新按钮动画效果 */
.refresh-button {
animation: rotate 600ms linear infinite;
}

View File

@@ -1,16 +1,15 @@
<script setup lang="ts"> <script setup lang="ts">
import { $t } from "/@/plugins/i18n";
import { emitter } from "/@/utils/mitt"; import { emitter } from "/@/utils/mitt";
import { RouteConfigs } from "../../types"; import { RouteConfigs } from "../../types";
import { useTags } from "../../hooks/useTag"; import { useTags } from "../../hooks/useTag";
import { routerArrays } from "/@/layout/types"; import { routerArrays } from "/@/layout/types";
import { isEqual, isEmpty } from "lodash-unified"; import { isEqual, isEmpty } from "lodash-unified";
import { toggleClass, removeClass } from "@pureadmin/utils";
import { useResizeObserver, useDebounceFn } from "@vueuse/core";
import { useSettingStoreHook } from "/@/store/modules/settings"; import { useSettingStoreHook } from "/@/store/modules/settings";
import { ref, watch, unref, nextTick, onBeforeMount } from "vue";
import { handleAliveRoute, delAliveRoutes } from "/@/router/utils"; import { handleAliveRoute, delAliveRoutes } from "/@/router/utils";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags"; import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
import { usePermissionStoreHook } from "/@/store/modules/permission"; import { useResizeObserver, useDebounceFn, useFullscreen } from "@vueuse/core";
import { ref, watch, unref, toRaw, nextTick, onBeforeMount } from "vue";
const { const {
route, route,
@@ -24,6 +23,7 @@ const {
buttonLeft, buttonLeft,
showModel, showModel,
translateX, translateX,
pureSetting,
activeIndex, activeIndex,
getTabStyle, getTabStyle,
iconIsActive, iconIsActive,
@@ -35,12 +35,15 @@ const {
onMounted, onMounted,
onMouseenter, onMouseenter,
onMouseleave, onMouseleave,
transformI18n transformI18n,
onContentFullScreen
} = useTags(); } = useTags();
const tabDom = ref(); const tabDom = ref();
const containerDom = ref(); const containerDom = ref();
const scrollbarDom = ref(); const scrollbarDom = ref();
let isShowArrow = ref(false);
const { isFullscreen, toggle } = useFullscreen();
const dynamicTagView = () => { const dynamicTagView = () => {
const index = multiTags.value.findIndex(item => { const index = multiTags.value.findIndex(item => {
@@ -67,6 +70,9 @@ const moveToView = (index: number): void => {
: 0; : 0;
// 已有标签页总长度(包含溢出部分) // 已有标签页总长度(包含溢出部分)
const tabDomWidth = tabDom.value ? tabDom.value?.offsetWidth : 0; const tabDomWidth = tabDom.value ? tabDom.value?.offsetWidth : 0;
scrollbarDomWidth <= tabDomWidth
? (isShowArrow.value = true)
: (isShowArrow.value = false);
if (tabDomWidth < scrollbarDomWidth || tabItemElOffsetLeft === 0) { if (tabDomWidth < scrollbarDomWidth || tabItemElOffsetLeft === 0) {
translateX.value = 0; translateX.value = 0;
} else if (tabItemElOffsetLeft < -translateX.value) { } else if (tabItemElOffsetLeft < -translateX.value) {
@@ -144,16 +150,11 @@ function dynamicRouteTag(value: string, parentPath: string): void {
/** 刷新路由 */ /** 刷新路由 */
function onFresh() { function onFresh() {
const refreshButton = "refresh-button";
toggleClass(true, refreshButton, document.querySelector(".rotate"));
const { fullPath, query } = unref(route); const { fullPath, query } = unref(route);
router.replace({ router.replace({
path: "/redirect" + fullPath, path: "/redirect" + fullPath,
query: query query: query
}); });
setTimeout(() => {
removeClass(document.querySelector(".rotate"), refreshButton);
}, 600);
} }
function deleteDynamicTag(obj: any, current: any, tag?: string) { function deleteDynamicTag(obj: any, current: any, tag?: string) {
@@ -276,9 +277,34 @@ function onClickDrop(key, item, selectRoute?: RouteConfigs) {
startIndex: 1, startIndex: 1,
length: multiTags.value.length length: multiTags.value.length
}); });
usePermissionStoreHook().clearAllCachePage();
router.push("/welcome"); router.push("/welcome");
break; break;
case 6:
// 整体页面全屏
toggle();
setTimeout(() => {
if (isFullscreen.value) {
tagsViews[6].icon = "exit-fullscreen";
tagsViews[6].text = $t("buttons.hswholeExitFullScreen");
} else {
tagsViews[6].icon = "fullscreen";
tagsViews[6].text = $t("buttons.hswholeFullScreen");
}
}, 100);
break;
case 7:
// 内容区全屏
onContentFullScreen();
setTimeout(() => {
if (pureSetting.hiddenSideBar) {
tagsViews[7].icon = "exit-fullscreen";
tagsViews[7].text = $t("buttons.hscontentExitFullScreen");
} else {
tagsViews[7].icon = "fullscreen";
tagsViews[7].text = $t("buttons.hscontentFullScreen");
}
}, 100);
break;
} }
setTimeout(() => { setTimeout(() => {
showMenuModel(route.fullPath, route.query); showMenuModel(route.fullPath, route.query);
@@ -469,9 +495,9 @@ onMounted(() => {
<template> <template>
<div ref="containerDom" class="tags-view" v-if="!showTags"> <div ref="containerDom" class="tags-view" v-if="!showTags">
<div class="arrow-left"> <span v-show="isShowArrow" class="arrow-left">
<IconifyIconOffline icon="arrow-left-s-line" @click="handleScroll(200)" /> <IconifyIconOffline icon="arrow-left-s-line" @click="handleScroll(200)" />
</div> </span>
<div ref="scrollbarDom" class="scroll-container"> <div ref="scrollbarDom" class="scroll-container">
<div class="tab" ref="tabDom" :style="getTabStyle"> <div class="tab" ref="tabDom" :style="getTabStyle">
<div <div
@@ -492,7 +518,7 @@ onMounted(() => {
> >
<router-link <router-link
:to="item.path" :to="item.path"
class="!dark:color-text_color_primary !dark:hover:color-primary" class="dark:!text-text_color_primary dark:hover:!text-primary"
> >
{{ transformI18n(item.meta.title) }} {{ transformI18n(item.meta.title) }}
</router-link> </router-link>
@@ -514,7 +540,7 @@ onMounted(() => {
</div> </div>
</div> </div>
</div> </div>
<span class="arrow-right"> <span v-show="isShowArrow" class="arrow-right">
<IconifyIconOffline <IconifyIconOffline
icon="arrow-right-s-line" icon="arrow-right-s-line"
@click="handleScroll(-200)" @click="handleScroll(-200)"
@@ -529,59 +555,41 @@ onMounted(() => {
class="contextmenu" class="contextmenu"
> >
<div <div
v-for="(item, key) in tagsViews" v-for="(item, key) in tagsViews.slice(0, 6)"
:key="key" :key="key"
style="display: flex; align-items: center" style="display: flex; align-items: center"
> >
<li v-if="item.show" @click="selectTag(key, item)"> <li v-if="item.show" @click="selectTag(key, item)">
<component :is="toRaw(item.icon)" :key="key" /> <IconifyIconOffline :icon="item.icon" />
{{ transformI18n(item.text) }} {{ transformI18n(item.text) }}
</li> </li>
</div> </div>
</ul> </ul>
</transition> </transition>
<!-- 右侧功能按钮 --> <!-- 右侧功能按钮 -->
<ul class="right-button"> <el-dropdown
<li> trigger="click"
<span placement="bottom-end"
:title="transformI18n('buttons.hsrefreshRoute')" @command="handleCommand"
class="el-icon-refresh-right rotate" >
@click="onFresh" <span class="arrow-down">
> <IconifyIconOffline icon="arrow-down" class="dark:text-white" />
<IconifyIconOffline icon="refresh-right" /> </span>
</span> <template #dropdown>
</li> <el-dropdown-menu>
<li> <el-dropdown-item
<el-dropdown v-for="(item, key) in tagsViews"
trigger="click" :key="key"
placement="bottom-end" :command="{ key, item }"
@command="handleCommand" :divided="item.divided"
> :disabled="item.disabled"
<IconifyIconOffline icon="arrow-down" class="dark:color-white" /> >
<template #dropdown> <IconifyIconOffline :icon="item.icon" />
<el-dropdown-menu> {{ transformI18n(item.text) }}
<el-dropdown-item </el-dropdown-item>
v-for="(item, key) in tagsViews" </el-dropdown-menu>
:key="key" </template>
:command="{ key, item }" </el-dropdown>
:divided="item.divided"
:disabled="item.disabled"
>
<component
:is="toRaw(item.icon)"
:key="key"
style="margin-right: 6px"
/>
{{ transformI18n(item.text) }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</li>
<li>
<slot />
</li>
</ul>
</div> </div>
</template> </template>

View File

@@ -1,27 +1,26 @@
import { computed } from "vue"; import { computed } from "vue";
import { router } from "/@/router";
import { getConfig } from "/@/config"; import { getConfig } from "/@/config";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { emitter } from "/@/utils/mitt"; import { emitter } from "/@/utils/mitt";
import { routeMetaType } from "../types"; import { routeMetaType } from "../types";
import type { StorageConfigs } from "/#/index"; import { useGlobal } from "@pureadmin/utils";
import { routerArrays } from "/@/layout/types";
import { transformI18n } from "/@/plugins/i18n"; import { transformI18n } from "/@/plugins/i18n";
import { router, remainingPaths } from "/@/router";
import { useAppStoreHook } from "/@/store/modules/app"; import { useAppStoreHook } from "/@/store/modules/app";
import { remainingPaths, resetRouter } from "/@/router";
import { i18nChangeLanguage } from "@wangeditor/editor"; import { i18nChangeLanguage } from "@wangeditor/editor";
import { storageSession, useGlobal } from "@pureadmin/utils"; import { useUserStoreHook } from "/@/store/modules/user";
import { useEpThemeStoreHook } from "/@/store/modules/epTheme"; import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
const errorInfo = "当前路由配置不正确,请检查配置"; const errorInfo = "当前路由配置不正确,请检查配置";
export function useNav() { export function useNav() {
const pureApp = useAppStoreHook(); const pureApp = useAppStoreHook();
const routers = useRouter().options.routes; const routers = useRouter().options.routes;
/** 用户名 */ /** 用户名 */
const username: string = const username = computed(() => {
storageSession.getItem<StorageConfigs>("info")?.username; return useUserStoreHook()?.username;
});
/** 设置国际化选中后的样式 */ /** 设置国际化选中后的样式 */
const getDropdownItemStyle = computed(() => { const getDropdownItemStyle = computed(() => {
@@ -35,12 +34,12 @@ export function useNav() {
const getDropdownItemClass = computed(() => { const getDropdownItemClass = computed(() => {
return (locale, t) => { return (locale, t) => {
return locale === t ? "" : "!dark:hover:color-primary"; return locale === t ? "" : "dark:hover:!text-primary";
}; };
}); });
const avatarsStyle = computed(() => { const avatarsStyle = computed(() => {
return username ? { marginRight: "10px" } : ""; return username.value ? { marginRight: "10px" } : "";
}); });
const isCollapse = computed(() => { const isCollapse = computed(() => {
@@ -69,10 +68,7 @@ export function useNav() {
/** 退出登录 */ /** 退出登录 */
function logout() { function logout() {
useMultiTagsStoreHook().handleTags("equal", [...routerArrays]); useUserStoreHook().logOut();
storageSession.removeItem("info");
router.push("/login");
resetRouter();
} }
function backHome() { function backHome() {

View File

@@ -14,20 +14,15 @@ import type { StorageConfigs } from "/#/index";
import { useEventListener } from "@vueuse/core"; import { useEventListener } from "@vueuse/core";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { transformI18n, $t } from "/@/plugins/i18n"; import { transformI18n, $t } from "/@/plugins/i18n";
import { useSettingStoreHook } from "/@/store/modules/settings";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags"; import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
import { storageLocal, toggleClass, hasClass } from "@pureadmin/utils"; import { storageLocal, toggleClass, hasClass } from "@pureadmin/utils";
import close from "/@/assets/svg/close.svg?component";
import refresh from "/@/assets/svg/refresh.svg?component";
import closeAll from "/@/assets/svg/close_all.svg?component";
import closeLeft from "/@/assets/svg/close_left.svg?component";
import closeOther from "/@/assets/svg/close_other.svg?component";
import closeRight from "/@/assets/svg/close_right.svg?component";
export function useTags() { export function useTags() {
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const instance = getCurrentInstance(); const instance = getCurrentInstance();
const pureSetting = useSettingStoreHook();
const buttonTop = ref(0); const buttonTop = ref(0);
const buttonLeft = ref(0); const buttonLeft = ref(0);
@@ -53,46 +48,60 @@ export function useTags() {
const tagsViews = reactive<Array<tagsViewsType>>([ const tagsViews = reactive<Array<tagsViewsType>>([
{ {
icon: refresh, icon: "refresh-right",
text: $t("buttons.hsreload"), text: $t("buttons.hsreload"),
divided: false, divided: false,
disabled: false, disabled: false,
show: true show: true
}, },
{ {
icon: close, icon: "close",
text: $t("buttons.hscloseCurrentTab"), text: $t("buttons.hscloseCurrentTab"),
divided: false, divided: false,
disabled: multiTags.value.length > 1 ? false : true, disabled: multiTags.value.length > 1 ? false : true,
show: true show: true
}, },
{ {
icon: closeLeft, icon: "close-left-tags",
text: $t("buttons.hscloseLeftTabs"), text: $t("buttons.hscloseLeftTabs"),
divided: true, divided: true,
disabled: multiTags.value.length > 1 ? false : true, disabled: multiTags.value.length > 1 ? false : true,
show: true show: true
}, },
{ {
icon: closeRight, icon: "close-right-tags",
text: $t("buttons.hscloseRightTabs"), text: $t("buttons.hscloseRightTabs"),
divided: false, divided: false,
disabled: multiTags.value.length > 1 ? false : true, disabled: multiTags.value.length > 1 ? false : true,
show: true show: true
}, },
{ {
icon: closeOther, icon: "close-other-tags",
text: $t("buttons.hscloseOtherTabs"), text: $t("buttons.hscloseOtherTabs"),
divided: true, divided: true,
disabled: multiTags.value.length > 2 ? false : true, disabled: multiTags.value.length > 2 ? false : true,
show: true show: true
}, },
{ {
icon: closeAll, icon: "close-all-tags",
text: $t("buttons.hscloseAllTabs"), text: $t("buttons.hscloseAllTabs"),
divided: false, divided: false,
disabled: multiTags.value.length > 1 ? false : true, disabled: multiTags.value.length > 1 ? false : true,
show: true show: true
},
{
icon: "fullscreen",
text: $t("buttons.hswholeFullScreen"),
divided: true,
disabled: false,
show: true
},
{
icon: "fullscreen",
text: $t("buttons.hscontentFullScreen"),
divided: false,
disabled: false,
show: true
} }
]); ]);
@@ -172,6 +181,12 @@ export function useTags() {
} }
} }
function onContentFullScreen() {
pureSetting.hiddenSideBar
? pureSetting.changeSetting({ key: "hiddenSideBar", value: false })
: pureSetting.changeSetting({ key: "hiddenSideBar", value: true });
}
onMounted(() => { onMounted(() => {
if (!showModel.value) { if (!showModel.value) {
const configure = storageLocal.getItem<StorageConfigs>( const configure = storageLocal.getItem<StorageConfigs>(
@@ -201,6 +216,7 @@ export function useTags() {
buttonTop, buttonTop,
buttonLeft, buttonLeft,
translateX, translateX,
pureSetting,
activeIndex, activeIndex,
getTabStyle, getTabStyle,
iconIsActive, iconIsActive,
@@ -213,6 +229,7 @@ export function useTags() {
onMounted, onMounted,
onMouseenter, onMouseenter,
onMouseleave, onMouseleave,
transformI18n transformI18n,
onContentFullScreen
}; };
} }

View File

@@ -7,16 +7,13 @@ import { useSettingStoreHook } from "/@/store/modules/settings";
import { deviceDetection, useDark, useGlobal } from "@pureadmin/utils"; import { deviceDetection, useDark, useGlobal } from "@pureadmin/utils";
import { h, reactive, computed, onMounted, defineComponent } from "vue"; import { h, reactive, computed, onMounted, defineComponent } from "vue";
import backTop from "/@/assets/svg/back_top.svg?component";
import fullScreen from "/@/assets/svg/full_screen.svg?component";
import exitScreen from "/@/assets/svg/exit_screen.svg?component";
import navbar from "./components/navbar.vue"; import navbar from "./components/navbar.vue";
import tag from "./components/tag/index.vue"; import tag from "./components/tag/index.vue";
import appMain from "./components/appMain.vue"; import appMain from "./components/appMain.vue";
import setting from "./components/setting/index.vue"; import setting from "./components/setting/index.vue";
import Vertical from "./components/sidebar/vertical.vue"; import Vertical from "./components/sidebar/vertical.vue";
import Horizontal from "./components/sidebar/horizontal.vue"; import Horizontal from "./components/sidebar/horizontal.vue";
import backTop from "/@/assets/svg/back_top.svg?component";
const { isDark } = useDark(); const { isDark } = useDark();
const { layout } = useLayout(); const { layout } = useLayout();
@@ -102,12 +99,6 @@ onMounted(() => {
} }
}); });
function onFullScreen() {
pureSetting.hiddenSideBar
? pureSetting.changeSetting({ key: "hiddenSideBar", value: false })
: pureSetting.changeSetting({ key: "hiddenSideBar", value: true });
}
const layoutHeader = defineComponent({ const layoutHeader = defineComponent({
render() { render() {
return h( return h(
@@ -127,31 +118,11 @@ const layoutHeader = defineComponent({
!pureSetting.hiddenSideBar && !pureSetting.hiddenSideBar &&
(layout.value.includes("vertical") || layout.value.includes("mix")) (layout.value.includes("vertical") || layout.value.includes("mix"))
? h(navbar) ? h(navbar)
: h("div"), : null,
!pureSetting.hiddenSideBar && layout.value.includes("horizontal") !pureSetting.hiddenSideBar && layout.value.includes("horizontal")
? h(Horizontal) ? h(Horizontal)
: h("div"), : null,
h( h(tag)
tag,
{},
{
default: () => [
h(
"span",
{
onClick: onFullScreen
},
{
default: () => [
!pureSetting.hiddenSideBar
? h(fullScreen, { class: "dark:color-white" })
: h(exitScreen, { class: "dark:color-white" })
]
}
)
]
}
)
] ]
} }
); );
@@ -226,10 +197,6 @@ const layoutHeader = defineComponent({
} }
} }
.main-hidden {
margin-left: 0 !important;
}
.app-mask { .app-mask {
background: #000; background: #000;
opacity: 0.3; opacity: 0.3;

View File

@@ -1,4 +1,3 @@
import { Component } from "vue";
export const routerArrays: Array<RouteConfigs> = [ export const routerArrays: Array<RouteConfigs> = [
{ {
path: "/welcome", path: "/welcome",
@@ -15,7 +14,7 @@ export type routeMetaType = {
icon?: string; icon?: string;
showLink?: boolean; showLink?: boolean;
savedPosition?: boolean; savedPosition?: boolean;
authority?: Array<string>; auths?: Array<string>;
}; };
export type RouteConfigs = { export type RouteConfigs = {
@@ -33,7 +32,7 @@ export type multiTagsType = {
}; };
export type tagsViewsType = { export type tagsViewsType = {
icon: Component; icon: string;
text: string; text: string;
divided: boolean; divided: boolean;
disabled: boolean; disabled: boolean;

View File

@@ -14,7 +14,6 @@ import { injectResponsiveStorage } from "/@/utils/responsive";
import Table from "@pureadmin/table"; import Table from "@pureadmin/table";
import PureDescriptions from "@pureadmin/descriptions"; import PureDescriptions from "@pureadmin/descriptions";
import "uno.css";
import "animate.css"; import "animate.css";
// 引入重置样式 // 引入重置样式
import "./style/reset.scss"; import "./style/reset.scss";
@@ -48,6 +47,10 @@ app.component("IconifyIconOffline", IconifyIconOffline);
app.component("IconifyIconOnline", IconifyIconOnline); app.component("IconifyIconOnline", IconifyIconOnline);
app.component("FontIcon", FontIcon); app.component("FontIcon", FontIcon);
// 全局注册按钮级别权限组件
import { Auth } from "/@/components/ReAuth";
app.component("Auth", Auth);
getServerConfig(app).then(async config => { getServerConfig(app).then(async config => {
app.use(router); app.use(router);
await router.isReady(); await router.isReady();

View File

@@ -58,7 +58,7 @@ export function transformI18n(message: any = "") {
} }
} }
// 此函数只是配合i18n Ally插件来进行国际化智能提示并无实际意义只对提示起作用如果不需要国际化可删除 /** 此函数只是配合i18n Ally插件来进行国际化智能提示并无实际意义只对提示起作用如果不需要国际化可删除 */
export const $t = (key: string) => key; export const $t = (key: string) => key;
export const i18n: I18n = createI18n({ export const i18n: I18n = createI18n({

View File

@@ -2,8 +2,8 @@ import { getConfig } from "/@/config";
import { toRouteType } from "./types"; import { toRouteType } from "./types";
import NProgress from "/@/utils/progress"; import NProgress from "/@/utils/progress";
import { findIndex } from "lodash-unified"; import { findIndex } from "lodash-unified";
import type { StorageConfigs } from "/#/index";
import { transformI18n } from "/@/plugins/i18n"; import { transformI18n } from "/@/plugins/i18n";
import { sessionKey, type DataInfo } from "/@/utils/auth";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags"; import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
import { usePermissionStoreHook } from "/@/store/modules/permission"; import { usePermissionStoreHook } from "/@/store/modules/permission";
import { import {
@@ -15,6 +15,7 @@ import {
import { import {
ascending, ascending,
initRouter, initRouter,
isOneOfArray,
getHistoryMode, getHistoryMode,
findRouteByPath, findRouteByPath,
handleAliveRoute, handleAliveRoute,
@@ -43,7 +44,7 @@ import remainingRouter from "./modules/remaining";
import componentsRouter from "./modules/components"; import componentsRouter from "./modules/components";
import formDesignRouter from "./modules/formdesign"; import formDesignRouter from "./modules/formdesign";
// 原始静态路由(未做任何处理) /** 原始静态路由(未做任何处理) */
const routes = [ const routes = [
pptRouter, pptRouter,
homeRouter, homeRouter,
@@ -60,22 +61,22 @@ const routes = [
formDesignRouter formDesignRouter
]; ];
// 导出处理后的静态路由(三级及以上的路由全部拍成二级) /** 导出处理后的静态路由(三级及以上的路由全部拍成二级) */
export const constantRoutes: Array<RouteRecordRaw> = formatTwoStageRoutes( export const constantRoutes: Array<RouteRecordRaw> = formatTwoStageRoutes(
formatFlatteningRoutes(buildHierarchyTree(ascending(routes))) formatFlatteningRoutes(buildHierarchyTree(ascending(routes)))
); );
// 用于渲染菜单,保持原始层级 /** 用于渲染菜单,保持原始层级 */
export const constantMenus: Array<RouteComponent> = ascending(routes).concat( export const constantMenus: Array<RouteComponent> = ascending(routes).concat(
...remainingRouter ...remainingRouter
); );
// 不参与菜单的路由 /** 不参与菜单的路由 */
export const remainingPaths = Object.keys(remainingRouter).map(v => { export const remainingPaths = Object.keys(remainingRouter).map(v => {
return remainingRouter[v].path; return remainingRouter[v].path;
}); });
// 创建路由实例 /** 创建路由实例 */
export const router: Router = createRouter({ export const router: Router = createRouter({
history: getHistoryMode(), history: getHistoryMode(),
routes: constantRoutes.concat(...(remainingRouter as any)), routes: constantRoutes.concat(...(remainingRouter as any)),
@@ -95,7 +96,7 @@ export const router: Router = createRouter({
} }
}); });
// 重置路由 /** 重置路由 */
export function resetRouter() { export function resetRouter() {
router.getRoutes().forEach(route => { router.getRoutes().forEach(route => {
const { name, meta } = route; const { name, meta } = route;
@@ -106,9 +107,10 @@ export function resetRouter() {
); );
} }
}); });
usePermissionStoreHook().clearAllCachePage();
} }
// 路由白名单 /** 路由白名单 */
const whiteList = ["/login"]; const whiteList = ["/login"];
router.beforeEach((to: toRouteType, _from, next) => { router.beforeEach((to: toRouteType, _from, next) => {
@@ -120,10 +122,10 @@ router.beforeEach((to: toRouteType, _from, next) => {
handleAliveRoute(newMatched); handleAliveRoute(newMatched);
} }
} }
const name = storageSession.getItem<StorageConfigs>("info"); const userInfo = storageSession.getItem<DataInfo<number>>(sessionKey);
NProgress.start(); NProgress.start();
const externalLink = isUrl(to?.name as string); const externalLink = isUrl(to?.name as string);
if (!externalLink) if (!externalLink) {
to.matched.some(item => { to.matched.some(item => {
if (!item.meta.title) return ""; if (!item.meta.title) return "";
const Title = getConfig().Title; const Title = getConfig().Title;
@@ -131,7 +133,12 @@ router.beforeEach((to: toRouteType, _from, next) => {
document.title = `${transformI18n(item.meta.title)} | ${Title}`; document.title = `${transformI18n(item.meta.title)} | ${Title}`;
else document.title = transformI18n(item.meta.title); else document.title = transformI18n(item.meta.title);
}); });
if (name) { }
if (userInfo) {
// 无权限跳转403页面
if (to.meta?.roles && !isOneOfArray(to.meta?.roles, userInfo?.roles)) {
next({ path: "/error/403" });
}
if (_from?.name) { if (_from?.name) {
// name为超链接 // name为超链接
if (externalLink) { if (externalLink) {
@@ -142,8 +149,11 @@ router.beforeEach((to: toRouteType, _from, next) => {
} }
} else { } else {
// 刷新 // 刷新
if (usePermissionStoreHook().wholeMenus.length === 0) if (
initRouter(name.username).then((router: Router) => { usePermissionStoreHook().wholeMenus.length === 0 &&
to.path !== "/login"
)
initRouter().then((router: Router) => {
if (!useMultiTagsStoreHook().getMultiTagsCache) { if (!useMultiTagsStoreHook().getMultiTagsCache) {
const { path } = to; const { path } = to;
const index = findIndex(remainingRouter, v => { const index = findIndex(remainingRouter, v => {

View File

@@ -26,6 +26,14 @@ const ableRouter: RouteConfigsTable = {
title: $t("menus.hsPrint") title: $t("menus.hsPrint")
} }
}, },
{
path: "/able/download",
name: "Download",
component: () => import("/@/views/able/download.vue"),
meta: {
title: $t("menus.hsDownload")
}
},
{ {
path: "/able/iconSelect", path: "/able/iconSelect",
name: "IconSelect", name: "IconSelect",
@@ -145,6 +153,14 @@ const ableRouter: RouteConfigsTable = {
meta: { meta: {
title: $t("menus.hsExecl") title: $t("menus.hsExecl")
} }
},
{
path: "/able/infiniteScroll",
name: "InfiniteScroll",
component: () => import("/@/views/able/infinite-scroll.vue"),
meta: {
title: $t("menus.hsInfiniteScroll")
}
} }
] ]
}; };

View File

@@ -101,6 +101,22 @@ const componentsRouter: RouteConfigsTable = {
meta: { meta: {
title: $t("menus.hscontextmenu") title: $t("menus.hscontextmenu")
} }
},
{
path: "/components/typeit",
name: "Typeit",
component: () => import("/@/views/components/typeit/index.vue"),
meta: {
title: $t("menus.hstypeit")
}
},
{
path: "/components/json-editor",
name: "JsonEditor",
component: () => import("/@/views/components/json-editor/index.vue"),
meta: {
title: $t("menus.hsjsoneditor")
}
} }
] ]
}; };

View File

@@ -6,7 +6,7 @@ const errorRouter: RouteConfigsTable = {
redirect: "/error/403", redirect: "/error/403",
meta: { meta: {
icon: "information-line", icon: "information-line",
title: $t("menus.hserror"), title: $t("menus.hsabnormal"),
rank: 9 rank: 9
}, },
children: [ children: [

View File

@@ -2,6 +2,7 @@ import { RouteLocationNormalized } from "vue-router";
export interface toRouteType extends RouteLocationNormalized { export interface toRouteType extends RouteLocationNormalized {
meta: { meta: {
roles: Array<string>;
keepAlive?: boolean; keepAlive?: boolean;
dynamicLevel?: string; dynamicLevel?: string;
}; };

View File

@@ -9,10 +9,16 @@ import {
import { router } from "./index"; import { router } from "./index";
import { isProxy, toRaw } from "vue"; import { isProxy, toRaw } from "vue";
import { loadEnv } from "../../build"; import { loadEnv } from "../../build";
import { cloneDeep } from "lodash-unified";
import { useTimeoutFn } from "@vueuse/core"; import { useTimeoutFn } from "@vueuse/core";
import { RouteConfigs } from "/@/layout/types"; import { RouteConfigs } from "/@/layout/types";
import { buildHierarchyTree } from "@pureadmin/utils"; import {
isString,
storageSession,
buildHierarchyTree,
isIncludeAllChildren
} from "@pureadmin/utils";
import { cloneDeep, intersection } from "lodash-unified";
import { sessionKey, type DataInfo } from "/@/utils/auth";
import { usePermissionStoreHook } from "/@/store/modules/permission"; import { usePermissionStoreHook } from "/@/store/modules/permission";
const IFrame = () => import("/@/layout/frameView.vue"); const IFrame = () => import("/@/layout/frameView.vue");
// https://cn.vitejs.dev/guide/features.html#glob-import // https://cn.vitejs.dev/guide/features.html#glob-import
@@ -21,7 +27,7 @@ const modulesRoutes = import.meta.glob("/src/views/**/*.{vue,tsx}");
// 动态路由 // 动态路由
import { getAsyncRoutes } from "/@/api/routes"; import { getAsyncRoutes } from "/@/api/routes";
// 按照路由中meta下的rank等级升序来排序路由 /** 按照路由中meta下的rank等级升序来排序路由 */
function ascending(arr: any[]) { function ascending(arr: any[]) {
arr.forEach(v => { arr.forEach(v => {
if (v?.meta?.rank === null) v.meta.rank = undefined; if (v?.meta?.rank === null) v.meta.rank = undefined;
@@ -38,7 +44,7 @@ function ascending(arr: any[]) {
); );
} }
// 过滤meta中showLink为false的路由 /** 过滤meta中showLink为false的菜单 */
function filterTree(data: RouteComponent[]) { function filterTree(data: RouteComponent[]) {
const newTree = cloneDeep(data).filter( const newTree = cloneDeep(data).filter(
(v: { meta: { showLink: boolean } }) => v.meta?.showLink !== false (v: { meta: { showLink: boolean } }) => v.meta?.showLink !== false
@@ -49,7 +55,38 @@ function filterTree(data: RouteComponent[]) {
return newTree; return newTree;
} }
// 批量删除缓存路由(keepalive) /** 过滤children长度为0的的目录当目录下没有菜单时会过滤此目录目录没有赋予roles权限当目录下只要有一个菜单有显示权限那么此目录就会显示 */
function filterChildrenTree(data: RouteComponent[]) {
const newTree = cloneDeep(data).filter((v: any) => v?.children?.length !== 0);
newTree.forEach(
(v: { children }) => v.children && (v.children = filterTree(v.children))
);
return newTree;
}
/** 判断两个数组彼此是否存在相同值 */
function isOneOfArray(a: Array<string>, b: Array<string>) {
return Array.isArray(a) && Array.isArray(b)
? intersection(a, b).length > 0
? true
: false
: true;
}
/** 从sessionStorage里取出当前登陆用户的角色roles过滤无权限的菜单 */
function filterNoPermissionTree(data: RouteComponent[]) {
const currentRoles =
storageSession.getItem<DataInfo<number>>(sessionKey).roles ?? [];
const newTree = cloneDeep(data).filter((v: any) =>
isOneOfArray(v.meta?.roles, currentRoles)
);
newTree.forEach(
(v: any) => v.children && (v.children = filterNoPermissionTree(v.children))
);
return filterChildrenTree(newTree);
}
/** 批量删除缓存路由(keepalive) */
function delAliveRoutes(delAliveRouteList: Array<RouteConfigs>) { function delAliveRoutes(delAliveRouteList: Array<RouteConfigs>) {
delAliveRouteList.forEach(route => { delAliveRouteList.forEach(route => {
usePermissionStoreHook().cacheOperate({ usePermissionStoreHook().cacheOperate({
@@ -59,7 +96,7 @@ function delAliveRoutes(delAliveRouteList: Array<RouteConfigs>) {
}); });
} }
// 通过path获取父级路径 /** 通过path获取父级路径 */
function getParentPaths(path: string, routes: RouteRecordRaw[]) { function getParentPaths(path: string, routes: RouteRecordRaw[]) {
// 深度遍历查找 // 深度遍历查找
function dfs(routes: RouteRecordRaw[], path: string, parents: string[]) { function dfs(routes: RouteRecordRaw[], path: string, parents: string[]) {
@@ -83,7 +120,7 @@ function getParentPaths(path: string, routes: RouteRecordRaw[]) {
return dfs(routes, path, []); return dfs(routes, path, []);
} }
// 查找对应path的路由信息 /** 查找对应path的路由信息 */
function findRouteByPath(path: string, routes: RouteRecordRaw[]) { function findRouteByPath(path: string, routes: RouteRecordRaw[]) {
let res = routes.find((item: { path: string }) => item.path == path); let res = routes.find((item: { path: string }) => item.path == path);
if (res) { if (res) {
@@ -114,14 +151,15 @@ function addPathMatch() {
} }
} }
// 初始化路由 /** 初始化路由 */
function initRouter(name: string) { function initRouter() {
return new Promise(resolve => { return new Promise(resolve => {
getAsyncRoutes({ name }).then(({ info }) => { getAsyncRoutes().then(({ data }) => {
if (info.length === 0) { if (data.length === 0) {
usePermissionStoreHook().changeSetting(info); usePermissionStoreHook().handleWholeMenus(data);
resolve(router);
} else { } else {
formatFlatteningRoutes(addAsyncRoutes(info)).map( formatFlatteningRoutes(addAsyncRoutes(data)).map(
(v: RouteRecordRaw) => { (v: RouteRecordRaw) => {
// 防止重复添加路由 // 防止重复添加路由
if ( if (
@@ -144,7 +182,7 @@ function initRouter(name: string) {
resolve(router); resolve(router);
} }
); );
usePermissionStoreHook().changeSetting(info); usePermissionStoreHook().handleWholeMenus(data);
} }
addPathMatch(); addPathMatch();
}); });
@@ -195,7 +233,7 @@ function formatTwoStageRoutes(routesList: RouteRecordRaw[]) {
return newRoutesList; return newRoutesList;
} }
// 处理缓存路由(添加、删除、刷新) /** 处理缓存路由(添加、删除、刷新) */
function handleAliveRoute(matched: RouteRecordNormalized[], mode?: string) { function handleAliveRoute(matched: RouteRecordNormalized[], mode?: string) {
switch (mode) { switch (mode) {
case "add": case "add":
@@ -222,7 +260,7 @@ function handleAliveRoute(matched: RouteRecordNormalized[], mode?: string) {
} }
} }
// 过滤后端传来的动态路由 重新生成规范路由 /** 过滤后端传来的动态路由 重新生成规范路由 */
function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) { function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
if (!arrRoutes || !arrRoutes.length) return; if (!arrRoutes || !arrRoutes.length) return;
const modulesRoutesKeys = Object.keys(modulesRoutes); const modulesRoutesKeys = Object.keys(modulesRoutes);
@@ -232,9 +270,9 @@ function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
// 父级的redirect属性取值如果子级存在且父级的redirect属性不存在默认取第一个子级的path如果子级存在且父级的redirect属性存在取存在的redirect属性会覆盖默认值 // 父级的redirect属性取值如果子级存在且父级的redirect属性不存在默认取第一个子级的path如果子级存在且父级的redirect属性存在取存在的redirect属性会覆盖默认值
if (v?.children && v.children.length && !v.redirect) if (v?.children && v.children.length && !v.redirect)
v.redirect = v.children[0].path; v.redirect = v.children[0].path;
// 父级的name属性取值如果子级存在且父级的name属性不存在默认取第一个子级的name如果子级存在且父级的name属性存在取存在的name属性会覆盖默认值 // 父级的name属性取值如果子级存在且父级的name属性不存在默认取第一个子级的name如果子级存在且父级的name属性存在取存在的name属性会覆盖默认值注意测试中发现父级的name不能和子级name重复如果重复会造成重定向无效跳转404所以这里给父级的name起名的时候后面会自动加上`Parent`,避免重复)
if (v?.children && v.children.length && !v.name) if (v?.children && v.children.length && !v.name)
v.name = v.children[0].name; v.name = (v.children[0].name as string) + "Parent";
if (v.meta?.frameSrc) { if (v.meta?.frameSrc) {
v.component = IFrame; v.component = IFrame;
} else { } else {
@@ -251,7 +289,7 @@ function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
return arrRoutes; return arrRoutes;
} }
// 获取路由历史模式 https://next.router.vuejs.org/zh/guide/essentials/history-mode.html /** 获取路由历史模式 https://next.router.vuejs.org/zh/guide/essentials/history-mode.html */
function getHistoryMode(): RouterHistory { function getHistoryMode(): RouterHistory {
const routerHistory = loadEnv().VITE_ROUTER_HISTORY; const routerHistory = loadEnv().VITE_ROUTER_HISTORY;
// len为1 代表只有历史模式 为2 代表历史模式中存在base参数 https://next.router.vuejs.org/zh/api/#%E5%8F%82%E6%95%B0-1 // len为1 代表只有历史模式 为2 代表历史模式中存在base参数 https://next.router.vuejs.org/zh/api/#%E5%8F%82%E6%95%B0-1
@@ -275,30 +313,29 @@ function getHistoryMode(): RouterHistory {
} }
} }
// 是否有权限 /** 获取当前页面按钮级别的权限 */
function hasPermissions(value: Array<string>): boolean { function getAuths(): Array<string> {
if (value && value instanceof Array && value.length > 0) { return router.currentRoute.value.meta.auths as Array<string>;
const roles = usePermissionStoreHook().buttonAuth; }
const permissionRoles = value;
const hasPermission = roles.some(role => { /** 是否有按钮级别的权限 */
return permissionRoles.includes(role); function hasAuth(value: string | Array<string>): boolean {
}); if (!value) return false;
/** 从当前路由的`meta`字段里获取按钮级别的所有自定义`code`值 */
if (!hasPermission) { const metaAuths = getAuths();
return false; const isAuths = isString(value)
} ? metaAuths.includes(value)
return true; : isIncludeAllChildren(value, metaAuths);
} else { return isAuths ? true : false;
return false;
}
} }
export { export {
hasAuth,
getAuths,
ascending, ascending,
filterTree, filterTree,
initRouter, initRouter,
hasPermissions, isOneOfArray,
getHistoryMode, getHistoryMode,
addAsyncRoutes, addAsyncRoutes,
delAliveRoutes, delAliveRoutes,
@@ -306,5 +343,6 @@ export {
findRouteByPath, findRouteByPath,
handleAliveRoute, handleAliveRoute,
formatTwoStageRoutes, formatTwoStageRoutes,
formatFlatteningRoutes formatFlatteningRoutes,
filterNoPermissionTree
}; };

View File

@@ -18,7 +18,7 @@ export const useEpThemeStore = defineStore({
getEpThemeColor() { getEpThemeColor() {
return this.epThemeColor; return this.epThemeColor;
}, },
// 用于mix导航模式下hamburger-svg的fill属性 /** 用于mix导航模式下hamburger-svg的fill属性 */
fill() { fill() {
if (this.epTheme === "light") { if (this.epTheme === "light") {
return "#409eff"; return "#409eff";
@@ -34,6 +34,7 @@ export const useEpThemeStore = defineStore({
const layout = storageLocal.getItem<StorageConfigs>("responsive-layout"); const layout = storageLocal.getItem<StorageConfigs>("responsive-layout");
this.epTheme = layout?.theme; this.epTheme = layout?.theme;
this.epThemeColor = newColor; this.epThemeColor = newColor;
if (!layout) return;
layout.epThemeColor = newColor; layout.epThemeColor = newColor;
storageLocal.setItem("responsive-layout", layout); storageLocal.setItem("responsive-layout", layout);
} }

View File

@@ -2,9 +2,7 @@ import { defineStore } from "pinia";
import { store } from "/@/store"; import { store } from "/@/store";
import { cacheType } from "./types"; import { cacheType } from "./types";
import { constantMenus } from "/@/router"; import { constantMenus } from "/@/router";
import { cloneDeep } from "lodash-unified"; import { ascending, filterTree, filterNoPermissionTree } from "/@/router/utils";
import { RouteConfigs } from "/@/layout/types";
import { ascending, filterTree } from "/@/router/utils";
export const usePermissionStore = defineStore({ export const usePermissionStore = defineStore({
id: "pure-permission", id: "pure-permission",
@@ -13,40 +11,15 @@ export const usePermissionStore = defineStore({
constantMenus, constantMenus,
// 整体路由生成的菜单(静态、动态) // 整体路由生成的菜单(静态、动态)
wholeMenus: [], wholeMenus: [],
// 深拷贝一个菜单树,与导航菜单不突出
menusTree: [],
buttonAuth: [],
// 缓存页面keepAlive // 缓存页面keepAlive
cachePageList: [] cachePageList: []
}), }),
actions: { actions: {
// 获取异步路由菜单 /** 组装整体路由生成的菜单 */
asyncActionRoutes(routes) { handleWholeMenus(routes: any[]) {
if (this.wholeMenus.length > 0) return; this.wholeMenus = filterNoPermissionTree(
this.wholeMenus = filterTree(
ascending(this.constantMenus.concat(routes))
);
this.menusTree = cloneDeep(
filterTree(ascending(this.constantMenus.concat(routes))) filterTree(ascending(this.constantMenus.concat(routes)))
); );
const getButtonAuth = (arrRoutes: Array<RouteConfigs>) => {
if (!arrRoutes || !arrRoutes.length) return;
arrRoutes.forEach((v: RouteConfigs) => {
if (v.meta && v.meta.authority) {
this.buttonAuth.push(...v.meta.authority);
}
if (v.children) {
getButtonAuth(v.children);
}
});
};
getButtonAuth(this.wholeMenus);
},
async changeSetting(routes) {
await this.asyncActionRoutes(routes);
}, },
cacheOperate({ mode, name }: cacheType) { cacheOperate({ mode, name }: cacheType) {
switch (mode) { switch (mode) {
@@ -61,8 +34,9 @@ export const usePermissionStore = defineStore({
break; break;
} }
}, },
// 清空缓存页面 /** 清空缓存页面 */
clearAllCachePage() { clearAllCachePage() {
this.wholeMenus = [];
this.cachePageList = []; this.cachePageList = [];
} }
} }

View File

@@ -37,8 +37,8 @@ export type setType = {
}; };
export type userType = { export type userType = {
token: string; username?: string;
name?: string; roles?: Array<string>;
verifyCode?: string; verifyCode?: string;
currentPage?: number; currentPage?: number;
}; };

View File

@@ -1,55 +1,56 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { store } from "/@/store"; import { store } from "/@/store";
import { userType } from "./types"; import { userType } from "./types";
import { router } from "/@/router";
import { routerArrays } from "/@/layout/types"; import { routerArrays } from "/@/layout/types";
import { router, resetRouter } from "/@/router";
import { storageSession } from "@pureadmin/utils"; import { storageSession } from "@pureadmin/utils";
import { getLogin, refreshToken } from "/@/api/user"; import { getLogin, refreshTokenApi } from "/@/api/user";
import { getToken, setToken, removeToken } from "/@/utils/auth"; import { UserResult, RefreshTokenResult } from "/@/api/user";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags"; import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
import {
const data = getToken(); type DataInfo,
let token = ""; setToken,
let name = ""; removeToken,
if (data) { sessionKey
const dataJson = JSON.parse(data); } from "/@/utils/auth";
if (dataJson) {
token = dataJson?.accessToken;
name = dataJson?.name ?? "admin";
}
}
export const useUserStore = defineStore({ export const useUserStore = defineStore({
id: "pure-user", id: "pure-user",
state: (): userType => ({ state: (): userType => ({
token, username:
name, storageSession.getItem<DataInfo<number>>(sessionKey)?.username ?? "",
// 页面级别权限
roles: storageSession.getItem<DataInfo<number>>(sessionKey)?.roles ?? [],
// 前端生成的验证码(按实际需求替换) // 前端生成的验证码(按实际需求替换)
verifyCode: "", verifyCode: "",
// 登录显示组件判断 0登录 1手机登录 2二维码登录 3注册 4忘记密码默认0登录 // 判断登录页面显示哪个组件0登录默认1手机登录2二维码登录3注册4忘记密码
currentPage: 0 currentPage: 0
}), }),
actions: { actions: {
SET_TOKEN(token) { /** 存储用户名 */
this.token = token; SET_USERNAME(username: string) {
this.username = username;
}, },
SET_NAME(name) { /** 存储角色 */
this.name = name; SET_ROLES(roles: Array<string>) {
this.roles = roles;
}, },
SET_VERIFYCODE(verifyCode) { /** 存储前端生成的验证码 */
SET_VERIFYCODE(verifyCode: string) {
this.verifyCode = verifyCode; this.verifyCode = verifyCode;
}, },
SET_CURRENTPAGE(value) { /** 存储登录页面显示哪个组件 */
SET_CURRENTPAGE(value: number) {
this.currentPage = value; this.currentPage = value;
}, },
// 登入 /** 登入 */
async loginByUsername(data) { async loginByUsername(data) {
return new Promise<void>((resolve, reject) => { return new Promise<UserResult>((resolve, reject) => {
getLogin(data) getLogin(data)
.then(data => { .then(data => {
if (data) { if (data) {
setToken(data); setToken(data.data);
resolve(); resolve(data);
} }
}) })
.catch(error => { .catch(error => {
@@ -57,22 +58,28 @@ export const useUserStore = defineStore({
}); });
}); });
}, },
// 登出 清空缓存 /** 前端登出(不调用接口) */
logOut() { logOut() {
this.token = ""; this.username = "";
this.name = ""; this.roles = [];
removeToken(); removeToken();
storageSession.clear();
useMultiTagsStoreHook().handleTags("equal", routerArrays);
router.push("/login"); router.push("/login");
useMultiTagsStoreHook().handleTags("equal", [...routerArrays]);
resetRouter();
}, },
// 刷新token /** 刷新`token` */
async refreshToken(data) { async handRefreshToken(data) {
return refreshToken(data).then(data => { return new Promise<RefreshTokenResult>((resolve, reject) => {
if (data) { refreshTokenApi(data)
setToken(data); .then(data => {
return data; if (data) {
} setToken(data.data);
resolve(data);
}
})
.catch(error => {
reject(error);
});
}); });
} }
} }

View File

@@ -38,17 +38,12 @@ html.dark {
.arrow-left, .arrow-left,
.arrow-right { .arrow-right {
box-shadow: none; box-shadow: none;
border-right: 1px solid $border-style;
} }
.arrow-right { .arrow-right {
border-left: 1px solid $border-style; border-left: 1px solid $border-style;
} }
.arrow-left,
.arrow-right,
.right-button li {
border-right: 1px solid $border-style;
}
} }
/* vxe-table */ /* vxe-table */
@@ -129,7 +124,8 @@ html.dark {
} }
.vxe-modal--title, .vxe-modal--title,
.vxe-button--content { .vxe-button--content,
.vxe-modal--header-title {
color: var(--el-text-color-primary); color: var(--el-text-color-primary);
} }
@@ -137,6 +133,10 @@ html.dark {
background: var(--el-color-primary) !important; background: var(--el-color-primary) !important;
} }
.vxe-button {
background-color: transparent;
}
/* 项目配置面板 */ /* 项目配置面板 */
.right-panel-items { .right-panel-items {
.el-divider__text { .el-divider__text {

View File

@@ -33,20 +33,20 @@
} }
.is-dark { .is-dark {
z-index: 99999 !important; z-index: 9999 !important;
} }
/* 重置buttoniconmargin */ /* 重置 el-buttoniconmargin */
.reset-margin [class*="el-icon"] + span { .reset-margin [class*="el-icon"] + span {
margin-left: 2px !important; margin-left: 2px !important;
} }
/* 自定义popover的类名 */ /* 自定义 popover 的类名 */
.pure-popper { .pure-popper {
padding: 0 !important; padding: 0 !important;
} }
/* nprogress适配ep的primary */ /* nprogress 适配 element-plus 的主题色 */
#nprogress { #nprogress {
& .bar { & .bar {
background-color: var(--el-color-primary) !important; background-color: var(--el-color-primary) !important;

View File

@@ -3,37 +3,13 @@
@import "./element-plus.scss"; @import "./element-plus.scss";
@import "./sidebar.scss"; @import "./sidebar.scss";
@import "./dark.scss"; @import "./dark.scss";
@import "./tailwind.css";
/* 自定义全局 CssVar */
:root { :root {
--pure-transition-duration: 0.016s; --pure-transition-duration: 0.016s;
} }
body {
width: 100%;
height: 100%;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizelegibility;
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
"Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}
html {
width: 100%;
height: 100%;
box-sizing: border-box;
}
#app {
width: 100%;
height: 100%;
}
/* 头部用户信息样式重置 */
.hidden {
display: none !important;
}
/* 灰色模式 */ /* 灰色模式 */
.html-grey { .html-grey {
filter: grayscale(100%); filter: grayscale(100%);
@@ -44,15 +20,7 @@ html {
filter: invert(80%); filter: invert(80%);
} }
.pc-spacing { /* 重置 vxe-table 中 pager 样式 */
margin: 10px;
}
.mobile-spacing {
margin: 0;
}
/* 重置vxe-table中pager样式 */
.vxe-pager .vxe-pager--num-btn:not(.is--disabled).is--active { .vxe-pager .vxe-pager--num-btn:not(.is--disabled).is--active {
color: #fff !important; color: #fff !important;
} }

View File

@@ -1,67 +1,49 @@
/*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
*/
*, *,
::before, ::before,
::after { ::after {
box-sizing: border-box; /* 1 */ box-sizing: border-box;
border-width: 0; /* 2 */ border-width: 0;
border-style: solid; /* 2 */ border-style: solid;
border-color: currentColor; /* 2 */ border-color: currentColor;
} }
/* #app {
1. Use a consistent sensible line-height in all browsers. width: 100%;
2. Prevent adjustments of font size after orientation changes in iOS. height: 100%;
3. Use a more readable tab size. }
4. Use the user's configured `sans` font-family by default.
*/
html { html {
line-height: 1.5; /* 1 */ line-height: 1.5;
-webkit-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%;
-moz-tab-size: 4; /* 3 */ -moz-tab-size: 4;
tab-size: 4; /* 3 */ tab-size: 4;
width: 100%;
height: 100%;
box-sizing: border-box;
}
body {
margin: 0;
line-height: inherit;
width: 100%;
height: 100%;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizelegibility;
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
"Microsoft YaHei", "微软雅黑", Arial, sans-serif; "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
} }
/*
1. Remove the margin in all browsers.
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
*/
body {
margin: 0; /* 1 */
line-height: inherit; /* 2 */
}
/*
1. Add the correct height in Firefox.
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
3. Ensure horizontal rules are visible by default.
*/
hr { hr {
height: 0; /* 1 */ height: 0;
color: inherit; /* 2 */ color: inherit;
border-top-width: 1px; /* 3 */ border-top-width: 1px;
} }
/*
Add the correct text decoration in Chrome, Edge, and Safari.
*/
abbr:where([title]) { abbr:where([title]) {
text-decoration: underline dotted; text-decoration: underline dotted;
} }
/*
Remove the default font size and weight for headings.
*/
h1, h1,
h2, h2,
h3, h3,
@@ -72,50 +54,29 @@ h6 {
font-weight: inherit; font-weight: inherit;
} }
/*
Reset links to optimize for opt-in styling instead of opt-out.
*/
a { a {
color: inherit; color: inherit;
text-decoration: inherit; text-decoration: inherit;
} }
/*
Add the correct font weight in Edge and Safari.
*/
b, b,
strong { strong {
font-weight: bolder; font-weight: bolder;
} }
/*
1. Use the user's configured `mono` font family by default.
2. Correct the odd `em` font sizing in all browsers.
*/
code, code,
kbd, kbd,
samp, samp,
pre { pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
"Liberation Mono", "Courier New", monospace; /* 1 */ "Liberation Mono", "Courier New", monospace;
font-size: 1em; /* 2 */ font-size: 1em;
} }
/*
Add the correct font size in all browsers.
*/
small { small {
font-size: 80%; font-size: 80%;
} }
/*
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
*/
sub, sub,
sup { sup {
font-size: 75%; font-size: 75%;
@@ -132,133 +93,73 @@ sup {
top: -0.5em; top: -0.5em;
} }
/*
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
3. Remove gaps between table borders by default.
*/
table { table {
text-indent: 0; /* 1 */ text-indent: 0;
border-color: inherit; /* 2 */ border-color: inherit;
border-collapse: collapse; /* 3 */ border-collapse: collapse;
} }
/*
1. Change the font styles in all browsers.
2. Remove the margin in Firefox and Safari.
3. Remove default padding in all browsers.
*/
button, button,
input, input,
optgroup, optgroup,
select, select,
textarea { textarea {
font-family: inherit; /* 1 */ font-family: inherit;
font-size: 100%; /* 1 */ font-size: 100%;
line-height: inherit; /* 1 */ line-height: inherit;
color: inherit; /* 1 */ color: inherit;
margin: 0; /* 2 */ margin: 0;
padding: 0; /* 3 */ padding: 0;
} }
/*
Remove the inheritance of text transform in Edge and Firefox.
*/
button, button,
select { select {
text-transform: none; text-transform: none;
} }
/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Remove default button styles.
*/
button, button,
[type="button"], [type="button"],
[type="reset"], [type="reset"],
[type="submit"] { [type="submit"] {
-webkit-appearance: button; /* 1 */ -webkit-appearance: button;
background-color: transparent; /* 2 */ background-image: none;
background-image: none; /* 2 */
} }
/*
Use the modern Firefox focus style for all focusable elements.
*/
:-moz-focusring { :-moz-focusring {
outline: auto; outline: auto;
} }
/*
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
*/
:-moz-ui-invalid { :-moz-ui-invalid {
box-shadow: none; box-shadow: none;
} }
/*
Add the correct vertical alignment in Chrome and Firefox.
*/
progress { progress {
vertical-align: baseline; vertical-align: baseline;
} }
/*
Correct the cursor style of increment and decrement buttons in Safari.
*/
::-webkit-inner-spin-button, ::-webkit-inner-spin-button,
::-webkit-outer-spin-button { ::-webkit-outer-spin-button {
height: auto; height: auto;
} }
/*
1. Correct the odd appearance in Chrome and Safari.
2. Correct the outline style in Safari.
*/
[type="search"] { [type="search"] {
-webkit-appearance: textfield; /* 1 */ -webkit-appearance: textfield;
outline-offset: -2px; /* 2 */ outline-offset: -2px;
} }
/*
Remove the inner padding in Chrome and Safari on macOS.
*/
::-webkit-search-decoration { ::-webkit-search-decoration {
-webkit-appearance: none; -webkit-appearance: none;
} }
/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button { ::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */ -webkit-appearance: button;
font: inherit; /* 2 */ font: inherit;
} }
/*
Add the correct display in Chrome and Safari.
*/
summary { summary {
display: list-item; display: list-item;
} }
/*
Removes the default spacing and border for appropriate elements.
*/
blockquote, blockquote,
dl, dl,
dd, dd,
@@ -292,47 +193,25 @@ menu {
padding: 0; padding: 0;
} }
/*
Prevent resizing textareas horizontally by default.
*/
textarea { textarea {
resize: vertical; resize: vertical;
} }
/*
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
2. Set the default placeholder color to the user's configured gray 400 color.
*/
input::placeholder, input::placeholder,
textarea::placeholder { textarea::placeholder {
opacity: 1; /* 1 */ opacity: 1;
color: #9ca3af; /* 2 */ color: #9ca3af;
} }
/*
Set the default cursor for buttons.
*/
button, button,
[role="button"] { [role="button"] {
cursor: pointer; cursor: pointer;
} }
/*
Make sure disabled buttons don't get the pointer cursor.
*/
:disabled { :disabled {
cursor: default; cursor: default;
} }
/*
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
This can trigger a poorly considered lint error in some tools but is included by design.
*/
img, img,
svg, svg,
video, video,
@@ -341,24 +220,16 @@ audio,
iframe, iframe,
embed, embed,
object { object {
display: block; /* 1 */ display: block;
vertical-align: middle; /* 2 */ vertical-align: middle;
} }
/*
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
*/
img, img,
video { video {
max-width: 100%; max-width: 100%;
height: auto; height: auto;
} }
/*
Ensure the default browser behavior of the `hidden` attribute.
*/
[hidden] { [hidden] {
display: none; display: none;
} }

View File

@@ -1,6 +1,5 @@
@mixin merge-style( /* $sideBarWidth: vertical 模式下主体内容距离网页文档左侧的距离 */
/* vertical模式下主体内容距离网页文档左侧的距离 */ $sideBarWidth @mixin merge-style($sideBarWidth) {
) {
$menuActiveText: #7a80b4; $menuActiveText: #7a80b4;
@media screen and (min-width: 150px) and (max-width: 420px) { @media screen and (min-width: 150px) and (max-width: 420px) {
@@ -23,10 +22,19 @@
margin-right: 5px; margin-right: 5px;
} }
.set-icon {
height: 48px;
width: 40px;
display: flex;
cursor: pointer;
align-items: center;
justify-content: center;
}
.main-container { .main-container {
height: 100vh; height: 100vh;
min-height: 100%; min-height: 100%;
/* main-content属性动画 */ /* main-content 属性动画 */
transition: margin-left var(--pure-transition-duration); transition: margin-left var(--pure-transition-duration);
margin-left: $sideBarWidth; margin-left: $sideBarWidth;
position: relative; position: relative;
@@ -44,7 +52,7 @@
right: 0; right: 0;
z-index: 998; z-index: 998;
width: calc(100% - 210px); width: calc(100% - 210px);
/* fixed-header属性左上角动画 */ /* fixed-header 属性左上角动画 */
transition: width var(--pure-transition-duration); transition: width var(--pure-transition-duration);
} }
@@ -229,10 +237,10 @@
.screen-full, .screen-full,
/* 国际化 */ /* 国际化 */
.globalization, .globalization,
/* */ /* */
.el-dropdown-link, .el-dropdown-link,
/* 设置 */ /* 设置 */
.el-icon-setting { .set-icon {
&:hover { &:hover {
background: $menuHover; background: $menuHover;
} }
@@ -271,15 +279,6 @@
border-radius: 50%; border-radius: 50%;
} }
} }
.el-icon-setting {
height: 48px;
width: 40px;
padding: 12px;
display: flex;
cursor: pointer;
align-items: center;
}
} }
.el-menu { .el-menu {
@@ -324,7 +323,7 @@
} }
} }
/* vertical菜单折叠 */ /* vertical 菜单折叠 */
.el-menu--vertical { .el-menu--vertical {
.el-menu--popup { .el-menu--popup {
background-color: $subMenuBg !important; background-color: $subMenuBg !important;
@@ -398,7 +397,7 @@
} }
} }
/* horizontal菜单 */ /* horizontal 菜单 */
.el-menu--horizontal { .el-menu--horizontal {
& > .el-sub-menu .el-sub-menu__icon-arrow { & > .el-sub-menu .el-sub-menu__icon-arrow {
position: static !important; position: static !important;
@@ -422,7 +421,7 @@
} }
} }
/* 无子菜单时激活border-bottom */ /* 无子菜单时激活 border-bottom */
.router-link-exact-active > .submenu-title-noDropdown { .router-link-exact-active > .submenu-title-noDropdown {
height: 60px; height: 60px;
border-bottom: 2px solid var(--el-menu-active-color); border-bottom: 2px solid var(--el-menu-active-color);
@@ -592,10 +591,10 @@ body[layout="vertical"] {
.screen-full, .screen-full,
/* 国际化 */ /* 国际化 */
.globalization, .globalization,
/* */ /* */
.el-dropdown-link, .el-dropdown-link,
/* 设置 */ /* 设置 */
.el-icon-setting { .set-icon {
&:hover { &:hover {
background: #f6f6f6; background: #f6f6f6;
} }

21
src/style/tailwind.css Normal file
View File

@@ -0,0 +1,21 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
.flex-c {
@apply flex justify-center items-center;
}
.flex-ac {
@apply flex justify-around items-center;
}
.flex-bc {
@apply flex justify-between items-center;
}
.navbar-bg-hover {
@apply dark:text-white dark:hover:!bg-[#242424];
}
}

View File

@@ -1,43 +1,72 @@
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { storageSession } from "@pureadmin/utils";
import { useUserStoreHook } from "/@/store/modules/user"; import { useUserStoreHook } from "/@/store/modules/user";
const TokenKey = "authorized-token"; export interface DataInfo<T> {
/** token */
type paramsMapType = {
name: string;
expires: number;
accessToken: string; accessToken: string;
}; /** `accessToken`的过期时间(时间戳) */
expires: T;
// 获取token /** 用于调用刷新accessToken的接口时所需的token */
export function getToken() { refreshToken: string;
// 此处与TokenKey相同此写法解决初始化时Cookies中不存在TokenKey报错 /** 用户名 */
return Cookies.get("authorized-token"); username?: string;
/** 当前登陆用户的角色 */
roles?: Array<string>;
} }
// 设置token以及过期时间cookies、sessionStorage各一份 export const sessionKey = "user-info";
// 后端需要将用户信息和token以及过期时间都返回给前端过期时间主要用于刷新token export const TokenKey = "authorized-token";
export function setToken(data) {
const { accessToken, expires, name } = data; /** 获取`token` */
// 提取关键信息进行存储 export function getToken(): DataInfo<number> {
const paramsMap: paramsMapType = { // 此处与`TokenKey`相同,此写法解决初始化时`Cookies`中不存在`TokenKey`报错
name, return Cookies.get(TokenKey)
expires: Date.now() + parseInt(expires), ? JSON.parse(Cookies.get(TokenKey))
accessToken : storageSession.getItem(sessionKey);
}; }
const dataString = JSON.stringify(paramsMap);
useUserStoreHook().SET_TOKEN(accessToken); /**
useUserStoreHook().SET_NAME(name); * @description 设置`token`以及一些必要信息并采用无感刷新`token`方案
* 无感刷新:后端返回`accessToken`(访问接口使用的`token`)、`refreshToken`(用于调用刷新`accessToken`的接口时所需的`token``refreshToken`的过期时间比如30天应大于`accessToken`的过期时间比如2小时、`expires``accessToken`的过期时间)
* 将`accessToken`、`expires`这两条信息放在key值为authorized-token的cookie里过期自动销毁
* 将`username`、`roles`、`refreshToken`、`expires`这四条信息放在key值为`user-info`的sessionStorage里浏览器关闭自动销毁
*/
export function setToken(data: DataInfo<Date>) {
let expires = 0;
const { accessToken, refreshToken } = data;
expires = new Date(data.expires).getTime();
const cookieString = JSON.stringify({ accessToken, expires });
expires > 0 expires > 0
? Cookies.set(TokenKey, dataString, { ? Cookies.set(TokenKey, cookieString, {
expires: expires / 86400000 expires: (expires - Date.now()) / 86400000
}) })
: Cookies.set(TokenKey, dataString); : Cookies.set(TokenKey, cookieString);
sessionStorage.setItem(TokenKey, dataString);
function setSessionKey(username: string, roles: Array<string>) {
useUserStoreHook().SET_USERNAME(username);
useUserStoreHook().SET_ROLES(roles);
storageSession.setItem(sessionKey, {
refreshToken,
expires,
username,
roles
});
}
if (data.username && data.roles) {
const { username, roles } = data;
setSessionKey(username, roles);
} else {
const { username, roles } =
storageSession.getItem<DataInfo<number>>(sessionKey);
setSessionKey(username, roles);
}
} }
// 删除token /** 删除`token`以及key值为`user-info`的session信息 */
export function removeToken() { export function removeToken() {
Cookies.remove(TokenKey); Cookies.remove(TokenKey);
sessionStorage.removeItem(TokenKey); sessionStorage.removeItem(sessionKey);
} }

View File

@@ -1,12 +1,15 @@
import Axios, { AxiosInstance, AxiosRequestConfig } from "axios"; import Axios, {
AxiosInstance,
AxiosRequestConfig,
CustomParamsSerializer
} from "axios";
import { import {
resultType,
PureHttpError, PureHttpError,
RequestMethods, RequestMethods,
PureHttpResponse, PureHttpResponse,
PureHttpRequestConfig PureHttpRequestConfig
} from "./types.d"; } from "./types.d";
import qs from "qs"; import { stringify } from "qs";
import NProgress from "../progress"; import NProgress from "../progress";
// import { loadEnv } from "@build/index"; // import { loadEnv } from "@build/index";
import { getToken } from "/@/utils/auth"; import { getToken } from "/@/utils/auth";
@@ -21,7 +24,7 @@ const defaultConfig: AxiosRequestConfig = {
// process.env.NODE_ENV === "production" // process.env.NODE_ENV === "production"
// ? VITE_PROXY_DOMAIN_REAL // ? VITE_PROXY_DOMAIN_REAL
// : VITE_PROXY_DOMAIN, // : VITE_PROXY_DOMAIN,
// 当前使用mock模拟请求将baseURL制空如果你的环境用到了http请求请删除下面的baseURL启用上面的baseURL并将11行、16行代码注释取消 // 当前使用mock模拟请求将baseURL制空如果你的环境用到了http请求请删除下面的baseURL启用上面的baseURL并将第14行、19行代码注释取消
baseURL: "", baseURL: "",
timeout: 10000, timeout: 10000,
headers: { headers: {
@@ -29,8 +32,10 @@ const defaultConfig: AxiosRequestConfig = {
"Content-Type": "application/json", "Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest" "X-Requested-With": "XMLHttpRequest"
}, },
// 数组格式参数序列化 // 数组格式参数序列化https://github.com/axios/axios/issues/5142
paramsSerializer: params => qs.stringify(params, { indices: false }) paramsSerializer: {
serialize: stringify as unknown as CustomParamsSerializer
}
}; };
class PureHttp { class PureHttp {
@@ -38,16 +43,16 @@ class PureHttp {
this.httpInterceptorsRequest(); this.httpInterceptorsRequest();
this.httpInterceptorsResponse(); this.httpInterceptorsResponse();
} }
// 初始化配置对象 /** 初始化配置对象 */
private static initConfig: PureHttpRequestConfig = {}; private static initConfig: PureHttpRequestConfig = {};
// 保存当前Axios实例对象 /** 保存当前Axios实例对象 */
private static axiosInstance: AxiosInstance = Axios.create(defaultConfig); private static axiosInstance: AxiosInstance = Axios.create(defaultConfig);
// 请求拦截 /** 请求拦截 */
private httpInterceptorsRequest(): void { private httpInterceptorsRequest(): void {
PureHttp.axiosInstance.interceptors.request.use( PureHttp.axiosInstance.interceptors.request.use(
(config: PureHttpRequestConfig) => { async (config: PureHttpRequestConfig) => {
const $config = config; const $config = config;
// 开启进度条动画 // 开启进度条动画
NProgress.start(); NProgress.start();
@@ -60,26 +65,33 @@ class PureHttp {
PureHttp.initConfig.beforeRequestCallback($config); PureHttp.initConfig.beforeRequestCallback($config);
return $config; return $config;
} }
const token = getToken(); /** 请求白名单放置一些不需要token的接口通过设置请求白名单防止token过期后再请求造成的死循环问题 */
if (token) { const whiteList = ["/refreshToken", "/login"];
const data = JSON.parse(token); return whiteList.some(v => config.url.indexOf(v) > -1)
const now = new Date().getTime(); ? config
const expired = parseInt(data.expires) - now <= 0; : new Promise(resolve => {
if (expired) { const data = getToken();
// token过期刷新 if (data) {
useUserStoreHook() const now = new Date().getTime();
.refreshToken(data) const expired = parseInt(data.expires) - now <= 0;
.then((res: resultType) => { if (expired) {
config.headers["Authorization"] = "Bearer " + res.accessToken; // token过期刷新
return $config; useUserStoreHook()
}); .handRefreshToken({ refreshToken: data.refreshToken })
} else { .then(res => {
config.headers["Authorization"] = "Bearer " + data.accessToken; config.headers["Authorization"] =
return $config; "Bearer " + res.data.accessToken;
} resolve($config);
} else { });
return $config; } else {
} config.headers["Authorization"] =
"Bearer " + data.accessToken;
resolve($config);
}
} else {
resolve($config);
}
});
}, },
error => { error => {
return Promise.reject(error); return Promise.reject(error);
@@ -87,7 +99,7 @@ class PureHttp {
); );
} }
// 响应拦截 /** 响应拦截 */
private httpInterceptorsResponse(): void { private httpInterceptorsResponse(): void {
const instance = PureHttp.axiosInstance; const instance = PureHttp.axiosInstance;
instance.interceptors.response.use( instance.interceptors.response.use(
@@ -117,7 +129,7 @@ class PureHttp {
); );
} }
// 通用请求工具函数 /** 通用请求工具函数 */
public request<T>( public request<T>(
method: RequestMethods, method: RequestMethods,
url: string, url: string,
@@ -144,7 +156,7 @@ class PureHttp {
}); });
} }
// 单独抽离的post工具函数 /** 单独抽离的post工具函数 */
public post<T, P>( public post<T, P>(
url: string, url: string,
params?: T, params?: T,
@@ -153,7 +165,7 @@ class PureHttp {
return this.request<P>("post", url, params, config); return this.request<P>("post", url, params, config);
} }
// 单独抽离的get工具函数 /** 单独抽离的get工具函数 */
public get<T, P>( public get<T, P>(
url: string, url: string,
params?: T, params?: T,

View File

@@ -37,8 +37,8 @@ function handleAnchorClick(e, link) {
</span> </span>
</div> </div>
</template> </template>
<div class="w-400px"> <div class="w-[400px]">
<Anchor class="float-left mt-200px" @click="handleAnchorClick"> <Anchor class="float-left mt-[200px]" @click="handleAnchorClick">
<AnchorLink href="one" title="测试one" /> <AnchorLink href="one" title="测试one" />
<AnchorLink href="two" title="测试two" /> <AnchorLink href="two" title="测试two" />
<AnchorLink href="three" title="测试three" /> <AnchorLink href="three" title="测试three" />
@@ -47,21 +47,21 @@ function handleAnchorClick(e, link) {
<el-scrollbar class="float-right overflow-auto" height="600px"> <el-scrollbar class="float-right overflow-auto" height="600px">
<header <header
id="one" id="one"
class="w-200px h-600px text-cyan-50 flex justify-center items-center text-4xl" class="w-[200px] h-[600px] text-cyan-50 flex justify-center items-center text-4xl"
style="background: #409eff" style="background: #409eff"
> >
测试one 测试one
</header> </header>
<header <header
id="two" id="two"
class="w-200px h-600px text-cyan-50 flex justify-center items-center text-4xl" class="w-[200px] h-[600px] text-cyan-50 flex justify-center items-center text-4xl"
style="background: #67c23a" style="background: #67c23a"
> >
测试two 测试two
</header> </header>
<header <header
id="three" id="three"
class="w-200px h-600px text-cyan-50 flex justify-center items-center text-4xl" class="w-[200px] h-[600px] text-cyan-50 flex justify-center items-center text-4xl"
style="background: #f56c6c" style="background: #f56c6c"
> >
测试three 测试three

View File

@@ -149,7 +149,7 @@ const onLoadData = treeNode => {
<div> <div>
<span>线性样式</span> <span>线性样式</span>
<TreeSelect <TreeSelect
class="w-200px" class="w-[200px]"
v-model:value="value1" v-model:value="value1"
show-search show-search
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
@@ -169,7 +169,7 @@ const onLoadData = treeNode => {
<div> <div>
<span>虚拟滚动</span> <span>虚拟滚动</span>
<TreeSelect <TreeSelect
class="w-200px mt-6" class="w-[200px] mt-6"
v-model:value="checkedKeys" v-model:value="checkedKeys"
tree-checkable tree-checkable
tree-default-expand-all tree-default-expand-all
@@ -190,7 +190,7 @@ const onLoadData = treeNode => {
<div> <div>
<span>可勾选</span> <span>可勾选</span>
<TreeSelect <TreeSelect
class="w-200px" class="w-[200px]"
v-model:value="value2" v-model:value="value2"
:tree-data="treeData2" :tree-data="treeData2"
tree-checkable tree-checkable
@@ -203,7 +203,7 @@ const onLoadData = treeNode => {
<div> <div>
<span>异步加载</span> <span>异步加载</span>
<TreeSelect <TreeSelect
class="w-200px" class="w-[200px]"
v-model:value="value3" v-model:value="value3"
tree-data-simple-mode tree-data-simple-mode
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"

Some files were not shown because too many files have changed in this diff Show More