Compare commits
91 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc3b199860 | ||
|
|
4407dd5d10 | ||
|
|
b3cbdd6e87 | ||
|
|
b5f0ca52ce | ||
|
|
6110be29a1 | ||
|
|
d53496e495 | ||
|
|
1bafbeaab7 | ||
|
|
9a802296c7 | ||
|
|
e183ea75a0 | ||
|
|
969775c7cf | ||
|
|
841c5bd53a | ||
|
|
761b0e5ec2 | ||
|
|
b811256830 | ||
|
|
6019739c16 | ||
|
|
0dd1c67280 | ||
|
|
7d419c3b35 | ||
|
|
6ceb37624f | ||
|
|
fdf12660c1 | ||
|
|
49cdcf216f | ||
|
|
936070c9ce | ||
|
|
f14077bc6f | ||
|
|
1003a31b4d | ||
|
|
cc8a07d25b | ||
|
|
24db509381 | ||
|
|
43069ac127 | ||
|
|
f7ba97c73e | ||
|
|
ee65ec9f72 | ||
|
|
230af57c3e | ||
|
|
cdaa4cdba8 | ||
|
|
496947b524 | ||
|
|
d48058c28f | ||
|
|
820f724d5b | ||
|
|
63e2ddc171 | ||
|
|
60cdaf4697 | ||
|
|
d3cabb0f33 | ||
|
|
97193a71a6 | ||
|
|
f8694e953c | ||
|
|
55f97fce96 | ||
|
|
29144aba44 | ||
|
|
9a448143ae | ||
|
|
a85a2f9022 | ||
|
|
20fee1418c | ||
|
|
2888f8c4f1 | ||
|
|
c07e60e114 | ||
|
|
13427998f3 | ||
|
|
46355bf5bb | ||
|
|
d9b62a9e62 | ||
|
|
6911688ba6 | ||
|
|
45c08d779d | ||
|
|
41b35588c5 | ||
|
|
0a9eb30549 | ||
|
|
a7119c1cbe | ||
|
|
5a463ccfe7 | ||
|
|
73e98814e2 | ||
|
|
77049fdbd7 | ||
|
|
736f1c27cd | ||
|
|
2bac78478c | ||
|
|
bc8a0f3b35 | ||
|
|
53e19f7971 | ||
|
|
abc43dad6e | ||
|
|
f80fbbed20 | ||
|
|
12c2365a26 | ||
|
|
8a926c509f | ||
|
|
e87c38a9d2 | ||
|
|
340a79d286 | ||
|
|
45743a7c74 | ||
|
|
6887d4b1b8 | ||
|
|
b850783ca7 | ||
|
|
05e55ae9a1 | ||
|
|
f5b387231a | ||
|
|
79ebfb9284 | ||
|
|
51fd06c6a1 | ||
|
|
4bb8647990 | ||
|
|
a43d5ce865 | ||
|
|
aea8605a60 | ||
|
|
eb9d1e8238 | ||
|
|
138e0fd2e4 | ||
|
|
526023e0b0 | ||
|
|
885cbf2d9f | ||
|
|
e161102495 | ||
|
|
5300781d05 | ||
|
|
2e7e2ee3ce | ||
|
|
aa165ff70b | ||
|
|
b77ba43572 | ||
|
|
7cc69ac52d | ||
|
|
1b93ce989c | ||
|
|
9e5fe5edbc | ||
|
|
248fbf26ed | ||
|
|
d943550e10 | ||
|
|
3a7832b7fe | ||
|
|
ad3f964c32 |
@@ -1,14 +1,8 @@
|
|||||||
# 项目本地运行端口号
|
# 平台本地运行端口号
|
||||||
VITE_PORT = 8848
|
VITE_PORT = 8848
|
||||||
|
|
||||||
# 开发环境读取配置文件路径
|
# 开发环境读取配置文件路径
|
||||||
VITE_PUBLIC_PATH = /
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
# 开发环境代理
|
# 开发环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
VITE_PROXY_DOMAIN = /api
|
|
||||||
|
|
||||||
# 开发环境路由历史模式
|
|
||||||
VITE_ROUTER_HISTORY = "hash"
|
VITE_ROUTER_HISTORY = "hash"
|
||||||
|
|
||||||
# 开发环境后端地址
|
|
||||||
VITE_PROXY_DOMAIN_REAL = "http://127.0.0.1:3000"
|
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
# 线上环境项目打包路径
|
# 线上环境平台打包路径
|
||||||
VITE_PUBLIC_PATH = /
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
# 线上环境路由历史模式
|
# 线上环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
VITE_ROUTER_HISTORY = "hash"
|
VITE_ROUTER_HISTORY = "hash"
|
||||||
|
|
||||||
# 线上环境后端地址
|
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
|
||||||
VITE_PROXY_DOMAIN_REAL = ""
|
VITE_CDN = false
|
||||||
|
|
||||||
# 是否为打包后的文件提供传统浏览器兼容性支持 支持 true 不支持 false
|
# 是否启用gzip压缩或brotli压缩(分两种情况,删除原始文件和不删除原始文件)
|
||||||
VITE_LEGACY = false
|
# 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
# 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
VITE_COMPRESSION = "none"
|
||||||
16
.env.staging
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# 预发布也需要生产环境的行为
|
||||||
|
# https://cn.vitejs.dev/guide/env-and-mode.html#modes
|
||||||
|
NODE_ENV=production
|
||||||
|
|
||||||
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
|
# 预发布环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
|
VITE_ROUTER_HISTORY = "hash"
|
||||||
|
|
||||||
|
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
|
||||||
|
VITE_CDN = true
|
||||||
|
|
||||||
|
# 是否启用gzip压缩或brotli压缩(分两种情况,删除原始文件和不删除原始文件)
|
||||||
|
# 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
# 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
VITE_COMPRESSION = "both-clear"
|
||||||
@@ -1,4 +1,11 @@
|
|||||||
public
|
public
|
||||||
dist
|
dist
|
||||||
*.d.ts
|
*.d.ts
|
||||||
package.json
|
/src/assets
|
||||||
|
package.json
|
||||||
|
.eslintrc.js
|
||||||
|
.prettierrc.js
|
||||||
|
commitlint.config.js
|
||||||
|
postcss.config.js
|
||||||
|
tailwind.config.js
|
||||||
|
stylelint.config.js
|
||||||
41
.eslintrc.js
@@ -37,7 +37,7 @@ module.exports = {
|
|||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"@vue/typescript/recommended",
|
"@vue/typescript/recommended",
|
||||||
"@vue/prettier",
|
"@vue/prettier",
|
||||||
"@vue/prettier/@typescript-eslint"
|
"@vue/eslint-config-typescript"
|
||||||
],
|
],
|
||||||
parser: "vue-eslint-parser",
|
parser: "vue-eslint-parser",
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
@@ -49,7 +49,34 @@ module.exports = {
|
|||||||
jsx: true
|
jsx: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ["*.ts", "*.vue"],
|
||||||
|
rules: {
|
||||||
|
"no-undef": "off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["*.vue"],
|
||||||
|
parser: "vue-eslint-parser",
|
||||||
|
parserOptions: {
|
||||||
|
parser: "@typescript-eslint/parser",
|
||||||
|
extraFileExtensions: [".vue"],
|
||||||
|
ecmaVersion: "latest",
|
||||||
|
ecmaFeatures: {
|
||||||
|
jsx: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
"no-undef": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
rules: {
|
rules: {
|
||||||
|
"vue/no-v-html": "off",
|
||||||
|
"vue/require-default-prop": "off",
|
||||||
|
"vue/require-explicit-emits": "off",
|
||||||
|
"vue/multi-word-component-names": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "off", // any
|
"@typescript-eslint/no-explicit-any": "off", // any
|
||||||
"no-debugger": "off",
|
"no-debugger": "off",
|
||||||
"@typescript-eslint/explicit-module-boundary-types": "off", // setup()
|
"@typescript-eslint/explicit-module-boundary-types": "off", // setup()
|
||||||
@@ -57,6 +84,18 @@ module.exports = {
|
|||||||
"@typescript-eslint/ban-ts-comment": "off",
|
"@typescript-eslint/ban-ts-comment": "off",
|
||||||
"@typescript-eslint/no-empty-function": "off",
|
"@typescript-eslint/no-empty-function": "off",
|
||||||
"@typescript-eslint/no-non-null-assertion": "off",
|
"@typescript-eslint/no-non-null-assertion": "off",
|
||||||
|
"vue/html-self-closing": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
html: {
|
||||||
|
void: "always",
|
||||||
|
normal: "always",
|
||||||
|
component: "always"
|
||||||
|
},
|
||||||
|
svg: "always",
|
||||||
|
math: "always"
|
||||||
|
}
|
||||||
|
],
|
||||||
"@typescript-eslint/no-unused-vars": [
|
"@typescript-eslint/no-unused-vars": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
|
|||||||
2
.gitignore
vendored
@@ -4,6 +4,7 @@ dist
|
|||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
report.html
|
||||||
|
|
||||||
yarn.lock
|
yarn.lock
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
@@ -17,3 +18,4 @@ tests/**/coverage/
|
|||||||
*.ntvs*
|
*.ntvs*
|
||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
|
tsconfig.tsbuildinfo
|
||||||
@@ -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
@@ -0,0 +1,3 @@
|
|||||||
|
shamefully-hoist=true
|
||||||
|
strict-peer-dependencies=false
|
||||||
|
shell-emulator=true
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
bracketSpacing: true,
|
bracketSpacing: true,
|
||||||
jsxBracketSameLine: true,
|
|
||||||
singleQuote: false,
|
singleQuote: false,
|
||||||
arrowParens: "avoid",
|
arrowParens: "avoid",
|
||||||
trailingComma: "none"
|
trailingComma: "none"
|
||||||
|
|||||||
11
.vscode/extensions.json
vendored
@@ -1,16 +1,17 @@
|
|||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"johnsoncodehk.vscode-typescript-vue-plugin",
|
"christian-kohler.path-intellisense",
|
||||||
"voorjaar.windicss-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",
|
||||||
"johnsoncodehk.volar",
|
"redhat.vscode-yaml",
|
||||||
"lokalise.i18n-ally",
|
"csstools.postcss",
|
||||||
"mikestead.dotenv",
|
"mikestead.dotenv",
|
||||||
"eamodio.gitlens",
|
"eamodio.gitlens",
|
||||||
"antfu.iconify"
|
"antfu.iconify",
|
||||||
|
"Vue.volar"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
16
.vscode/settings.json
vendored
@@ -1,15 +1,12 @@
|
|||||||
{
|
{
|
||||||
"editor.formatOnType": true,
|
"editor.formatOnType": true,
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"javascript.updateImportsOnFileMove.enabled": "always",
|
|
||||||
"[vue]": {
|
"[vue]": {
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
},
|
},
|
||||||
"[javascript]": {
|
|
||||||
"editor.defaultFormatter": "vscode.typescript-language-features"
|
|
||||||
},
|
|
||||||
"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",
|
||||||
@@ -30,14 +27,5 @@
|
|||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true
|
"source.fixAll.eslint": true
|
||||||
},
|
},
|
||||||
"typescript.tsdk": "node_modules/typescript/lib",
|
"iconify.excludes": ["el"]
|
||||||
"i18n-ally.localesPaths": ["src/plugins/i18n"],
|
|
||||||
"i18n-ally.keystyle": "nested",
|
|
||||||
"i18n-ally.sortKeys": true,
|
|
||||||
"i18n-ally.namespace": true,
|
|
||||||
"i18n-ally.pathMatcher": "{locale}/{namespaces}.{ext}",
|
|
||||||
"i18n-ally.enabledParsers": ["ts"],
|
|
||||||
"i18n-ally.sourceLanguage": "en",
|
|
||||||
"i18n-ally.displayLanguage": "zh-CN",
|
|
||||||
"i18n-ally.enabledFrameworks": ["vue", "react"]
|
|
||||||
}
|
}
|
||||||
|
|||||||
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2021 啝裳
|
Copyright (c) 2022 啝裳
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<h1>vue-pure-admin Lite Edition</h1>
|
<h1>vue-pure-admin Lite Edition(no i18n version)</h1>
|
||||||
|
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
|
|
||||||
@@ -6,11 +6,17 @@
|
|||||||
|
|
||||||
## introduce
|
## introduce
|
||||||
|
|
||||||
The lite version is based on the shelf extracted from https://github.com/xiaoxian521/vue-pure-admin, which contains the main functions and is more suitable for actual project development
|
The Lite version is based on the shelf extracted from [vue-pure-admin](https://github.com/xiaoxian521/vue-pure-admin), including the main functions, which is more suitable for actual project development, and the packaged size is lower than ` 3MB`, and will permanently sync the full version of the code. After enabling `brotli` compression and `cdn` to replace the native library mode, the package size is less than `500kb`
|
||||||
|
|
||||||
|
## Supporting Video
|
||||||
|
|
||||||
|
- [Click Watch Tutorial](https://www.bilibili.com/video/BV1534y1S7HV)
|
||||||
|
- [Click Watch UI Design](https://www.bilibili.com/video/BV17g411T7rq)
|
||||||
|
|
||||||
## Docs
|
## Docs
|
||||||
|
|
||||||
<https://pure-admin-doc.vercel.app/>
|
- [Click me to view the domestic documentation site](https://yiming_chang.gitee.io/pure-admin-doc)
|
||||||
|
- [Click me to view foreign document site](https://xiaoxian521.github.io/pure-admin-doc)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -32,6 +38,10 @@ I think you should fork the project first to develop, so that you can pull the u
|
|||||||
|
|
||||||
bilibili: https://www.bilibili.com/video/BV1534y1S7HV/
|
bilibili: https://www.bilibili.com/video/BV1534y1S7HV/
|
||||||
|
|
||||||
## ⚠️ Note
|
## ⚠️ Attention
|
||||||
|
|
||||||
The lite version does not accept any issues and prs. If you have any questions, please go to the full version https://github.com/xiaoxian521/vue-pure-admin/issues/new/choose to mention it, thank you! ! !
|
- The Lite version does not accept any issues and prs. If you have any questions, please go to the full version https://github.com/xiaoxian521/vue-pure-admin/issues/new/choose to mention, thank you! ! !
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
In principle, no fees and copyrights are charged, and you can use it with confidence, but if you need secondary open source, please contact the author for permission!
|
||||||
|
|||||||
35
README.md
@@ -1,4 +1,4 @@
|
|||||||
<h1>vue-pure-admin精简版</h1>
|
<h1>vue-pure-admin精简版(非国际化版本)</h1>
|
||||||
|
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
|
|
||||||
@@ -6,16 +6,21 @@
|
|||||||
|
|
||||||
## 介绍
|
## 介绍
|
||||||
|
|
||||||
精简版是基于 https://github.com/xiaoxian521/vue-pure-admin 提炼出的架子,包含主体功能,更适合实际项目开发
|
精简版是基于 [vue-pure-admin](https://github.com/xiaoxian521/vue-pure-admin) 提炼出的架子,包含主体功能,更适合实际项目开发,打包后的大小低于 `3MB`,并且会永久同步完整版的代码。开启 `brotli` 压缩和 `cdn` 替换本地库模式后,打包大小低于 `500kb`
|
||||||
|
|
||||||
|
## 版本选择
|
||||||
|
|
||||||
|
当前是非国际化版本哦,如果您需要国际化版本 [请点击](https://github.com/xiaoxian521/pure-admin-thin/tree/i18n)
|
||||||
|
|
||||||
## 配套视频
|
## 配套视频
|
||||||
|
|
||||||
教程:<https://www.bilibili.com/video/BV1534y1S7HV/>
|
- [点我查看教程](https://www.bilibili.com/video/BV1534y1S7HV)
|
||||||
UI 设计:<https://www.bilibili.com/video/BV17g411T7rq/>
|
- [点我查看 UI 设计](https://www.bilibili.com/video/BV17g411T7rq)
|
||||||
|
|
||||||
## 配套文档
|
## 配套文档
|
||||||
|
|
||||||
<https://pure-admin-doc.vercel.app/>
|
- [点我查看国内文档站](https://yiming_chang.gitee.io/pure-admin-doc)
|
||||||
|
- [点我查看国外文档站](https://xiaoxian521.github.io/pure-admin-doc)
|
||||||
|
|
||||||
## 维护者
|
## 维护者
|
||||||
|
|
||||||
@@ -23,15 +28,15 @@ UI 设计:<https://www.bilibili.com/video/BV17g411T7rq/>
|
|||||||
|
|
||||||
## 捐赠
|
## 捐赠
|
||||||
|
|
||||||
如果你觉得这个项目对你有帮助,你可以帮作者买一杯咖啡表示支持
|
如果你觉得这个项目对您有帮助,可以帮作者买一杯果汁 🍹 表示支持
|
||||||
|
|
||||||
<img src="http://yiming_chang.gitee.io/manages/pay.jpg" width="150px" height="150px" />
|
<img src="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/f69bf13c5b854ed5b699807cafa0e3ce~tplv-k3u1fbpfcp-zoom-in-crop-mark:1304:0:0:0.awebp?" width="150px" height="150px" />
|
||||||
|
|
||||||
## 付费咨询、需求定制
|
## QQ 交流群
|
||||||
|
|
||||||
作者精力有限,需要提供技术服务的可扫下面的二维码加微信,添加请备注来意
|
一群已满,下面是二群,群里严禁 `黄` 、 `赌` 、 `毒` 、 `vpn` 等违法行为!
|
||||||
|
|
||||||
<img src="http://yiming_chang.gitee.io/manages/wechat.jpg" width="150px" height="150px" />
|
<img src="http://yiming_chang.gitee.io/pure-admin-doc/img/support/qq.png" width="150px" height="225px" />
|
||||||
|
|
||||||
## 用法
|
## 用法
|
||||||
|
|
||||||
@@ -47,8 +52,14 @@ pnpm add 包名
|
|||||||
|
|
||||||
pnpm remove 包名
|
pnpm remove 包名
|
||||||
|
|
||||||
我认为你应该先 fork 项目去开发,以便我更新时你可以同步拉取更新!!!
|
我认为你应该先 `fork` 项目去开发,以便我更新时您可以同步拉取更新!!!
|
||||||
|
|
||||||
## ⚠️ 注意
|
## ⚠️ 注意
|
||||||
|
|
||||||
精简版不接受任何 issues 和 pr,如果有问题请到完整版 https://github.com/xiaoxian521/vue-pure-admin/issues/new/choose 去提,谢谢!!!
|
- 精简版不接受任何 `issues` 和 `pr`,如果有问题请到完整版 [issues](https://github.com/xiaoxian521/vue-pure-admin/issues/new/choose) 去提,谢谢!!!
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
原则上不收取任何费用及版权,可以放心使用,不过如需二次开源(比如用此平台二次开发并开源)请联系作者获取许可!
|
||||||
|
|
||||||
|
[MIT © xiaoxian521-2020](./LICENSE)
|
||||||
|
|||||||
62
build/cdn.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import { Plugin as importToCDN } from "vite-plugin-cdn-import";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 打包时采用`cdn`模式,仅限外网使用(默认不采用,如果需要采用cdn模式,请在 .env.production 文件,将 VITE_CDN 设置成true)
|
||||||
|
* 平台采用国内cdn:https://www.bootcdn.cn,当然你也可以选择 https://unpkg.com 或者 https://www.jsdelivr.com
|
||||||
|
* 提醒:mockjs不能用cdn模式引入,会报错。正确的方式是,生产环境删除mockjs,使用真实的后端请求
|
||||||
|
* 注意:上面提到的仅限外网使用也不是完全肯定的,如果你们公司内网部署的有相关js、css文件,也可以将下面配置对应改一下,整一套内网版cdn
|
||||||
|
*/
|
||||||
|
export const cdn = importToCDN({
|
||||||
|
//(prodUrl解释: name: 对应下面modules的name,version: 自动读取本地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"
|
||||||
|
},
|
||||||
|
// 项目中没有直接安装vue-demi,但是pinia用到了,所以需要在引入pinia前引入vue-demi(https://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
@@ -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;
|
||||||
|
};
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
// 处理环境变量
|
/** 处理环境变量 */
|
||||||
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_REAL: "",
|
|
||||||
VITE_ROUTER_HISTORY: "",
|
VITE_ROUTER_HISTORY: "",
|
||||||
VITE_LEGACY: false
|
VITE_CDN: false,
|
||||||
|
VITE_COMPRESSION: "none"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const envName of Object.keys(envConf)) {
|
for (const envName of Object.keys(envConf)) {
|
||||||
@@ -28,14 +27,9 @@ const warpperEnv = (envConf: Recordable): ViteEnv => {
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 跨域代理重写
|
/** 获取环境变量 */
|
||||||
const regExps = (value: string, reg: string): string => {
|
|
||||||
return value.replace(new RegExp(reg, "g"), "");
|
|
||||||
};
|
|
||||||
|
|
||||||
// 环境变量
|
|
||||||
const loadEnv = (): ViteEnv => {
|
const loadEnv = (): ViteEnv => {
|
||||||
return import.meta.env;
|
return import.meta.env;
|
||||||
};
|
};
|
||||||
|
|
||||||
export { warpperEnv, regExps, loadEnv };
|
export { warpperEnv, loadEnv };
|
||||||
|
|||||||
50
build/info.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import type { Plugin } from "vite";
|
||||||
|
import dayjs, { Dayjs } from "dayjs";
|
||||||
|
import duration from "dayjs/plugin/duration";
|
||||||
|
import { green, blue, bold } from "picocolors";
|
||||||
|
import { getPackageSize } from "@pureadmin/utils";
|
||||||
|
dayjs.extend(duration);
|
||||||
|
|
||||||
|
export function viteBuildInfo(): Plugin {
|
||||||
|
let config: { command: string };
|
||||||
|
let startTime: Dayjs;
|
||||||
|
let endTime: Dayjs;
|
||||||
|
return {
|
||||||
|
name: "vite:buildInfo",
|
||||||
|
configResolved(resolvedConfig: { command: string }) {
|
||||||
|
config = resolvedConfig;
|
||||||
|
},
|
||||||
|
buildStart() {
|
||||||
|
console.log(
|
||||||
|
bold(
|
||||||
|
green(
|
||||||
|
`👏欢迎使用${blue(
|
||||||
|
"[vue-pure-admin]"
|
||||||
|
)},如果您感觉不错,记得点击后面链接给个star哦💖 https://github.com/xiaoxian521/vue-pure-admin`
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (config.command === "build") {
|
||||||
|
startTime = dayjs(new Date());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
closeBundle() {
|
||||||
|
if (config.command === "build") {
|
||||||
|
endTime = dayjs(new Date());
|
||||||
|
getPackageSize({
|
||||||
|
callback: (size: string) => {
|
||||||
|
console.log(
|
||||||
|
bold(
|
||||||
|
green(
|
||||||
|
`🎉恭喜打包完成(总用时${dayjs
|
||||||
|
.duration(endTime.diff(startTime))
|
||||||
|
.format("mm分ss秒")},打包后的大小为${size})`
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
25
build/optimize.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* 此文件作用于 `vite.config.ts` 的 `optimizeDeps.include` 依赖预构建配置项
|
||||||
|
* 依赖预构建,`vite` 启动时会将下面 include 里的模块,编译成 esm 格式并缓存到 node_modules/.vite 文件夹,页面加载到对应模块时如果浏览器有缓存就读取浏览器缓存,如果没有会读取本地缓存并按需加载
|
||||||
|
* 尤其当您禁用浏览器缓存时(这种情况只应该发生在调试阶段)必须将对应模块加入到 include里,否则会遇到开发环境切换页面卡顿的问题(vite 会认为它是一个新的依赖包会重新加载并强制刷新页面),因为它既无法使用浏览器缓存,又没有在本地 node_modules/.vite 里缓存
|
||||||
|
* 温馨提示:如果您使用的第三方库是全局引入,也就是引入到 src/main.ts 文件里,就不需要再添加到 include 里了,因为 vite 会自动将它们缓存到 node_modules/.vite
|
||||||
|
*/
|
||||||
|
export const include = [
|
||||||
|
"qs",
|
||||||
|
"mitt",
|
||||||
|
"dayjs",
|
||||||
|
"axios",
|
||||||
|
"pinia",
|
||||||
|
"lodash",
|
||||||
|
"echarts",
|
||||||
|
"xe-utils",
|
||||||
|
"vxe-table",
|
||||||
|
"js-cookie",
|
||||||
|
"lodash-es",
|
||||||
|
"@vueuse/core",
|
||||||
|
"lodash-unified",
|
||||||
|
"@ctrl/tinycolor",
|
||||||
|
"@pureadmin/utils",
|
||||||
|
"responsive-storage",
|
||||||
|
"element-resize-detector"
|
||||||
|
];
|
||||||
65
build/plugins.ts
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import { cdn } from "./cdn";
|
||||||
|
import vue from "@vitejs/plugin-vue";
|
||||||
|
import { viteBuildInfo } from "./info";
|
||||||
|
import svgLoader from "vite-svg-loader";
|
||||||
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||||
|
import VueMacros from "unplugin-vue-macros/vite";
|
||||||
|
import { viteMockServe } from "vite-plugin-mock";
|
||||||
|
import { configCompressPlugin } from "./compress";
|
||||||
|
// import ElementPlus from "unplugin-element-plus/vite";
|
||||||
|
import { visualizer } from "rollup-plugin-visualizer";
|
||||||
|
import removeConsole from "vite-plugin-remove-console";
|
||||||
|
import themePreprocessorPlugin from "@pureadmin/theme";
|
||||||
|
import { genScssMultipleScopeVars } from "../src/layout/theme";
|
||||||
|
|
||||||
|
export function getPluginsList(
|
||||||
|
command: string,
|
||||||
|
VITE_CDN: boolean,
|
||||||
|
VITE_COMPRESSION: ViteCompression
|
||||||
|
) {
|
||||||
|
const prodMock = true;
|
||||||
|
const lifecycle = process.env.npm_lifecycle_event;
|
||||||
|
return [
|
||||||
|
vue(),
|
||||||
|
// jsx、tsx语法支持
|
||||||
|
vueJsx(),
|
||||||
|
VITE_CDN ? cdn : null,
|
||||||
|
configCompressPlugin(VITE_COMPRESSION),
|
||||||
|
VueMacros(),
|
||||||
|
// 线上环境删除console
|
||||||
|
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),
|
||||||
|
viteBuildInfo(),
|
||||||
|
// 自定义主题
|
||||||
|
themePreprocessorPlugin({
|
||||||
|
scss: {
|
||||||
|
multipleScopeVars: genScssMultipleScopeVars(),
|
||||||
|
// 在生产模式是否抽取独立的主题css文件,extract为true以下属性有效
|
||||||
|
extract: true,
|
||||||
|
// 会选取defaultScopeName对应的主题css文件在html添加link
|
||||||
|
themeLinkTagId: "head",
|
||||||
|
// "head"||"head-prepend" || "body" ||"body-prepend"
|
||||||
|
themeLinkTagInjectTo: "head",
|
||||||
|
// 是否对抽取的css文件内对应scopeName的权重类名移除
|
||||||
|
removeCssScopeName: false
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// svg组件化支持
|
||||||
|
svgLoader(),
|
||||||
|
// ElementPlus({}),
|
||||||
|
// mock支持
|
||||||
|
viteMockServe({
|
||||||
|
mockPath: "mock",
|
||||||
|
localEnabled: command === "serve",
|
||||||
|
prodEnabled: command !== "serve" && prodMock,
|
||||||
|
injectCode: `
|
||||||
|
import { setupProdMockServer } from './mockProdServer';
|
||||||
|
setupProdMockServer();
|
||||||
|
`,
|
||||||
|
logger: false
|
||||||
|
}),
|
||||||
|
// 打包分析
|
||||||
|
lifecycle === "report"
|
||||||
|
? visualizer({ open: true, brotliSize: true, filename: "report.html" })
|
||||||
|
: null
|
||||||
|
];
|
||||||
|
}
|
||||||
42
index.html
@@ -2,10 +2,14 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" href="/favicon.ico" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||||
<link rel="stylesheet" href="/iconfont.css" />
|
<meta name="renderer" content="webkit" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
|
||||||
|
/>
|
||||||
<title>pure-admin-thin</title>
|
<title>pure-admin-thin</title>
|
||||||
|
<link rel="icon" href="/favicon.ico" />
|
||||||
<script>
|
<script>
|
||||||
window.process = {};
|
window.process = {};
|
||||||
</script>
|
</script>
|
||||||
@@ -14,20 +18,16 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<style>
|
<style>
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
html,
|
html,
|
||||||
body {
|
body,
|
||||||
|
#app {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
position: relative;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-family: "Reggae One", cursive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.loader,
|
.loader,
|
||||||
@@ -36,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,11 +46,10 @@
|
|||||||
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;
|
||||||
|
transform: translate(-50%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.loader:before,
|
.loader:before,
|
||||||
@@ -64,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,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%,
|
||||||
@@ -96,7 +80,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div class="loader">Loading...</div>
|
<div class="loader"></div>
|
||||||
</div>
|
</div>
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,62 +1,49 @@
|
|||||||
// 根据角色动态生成路由
|
// 模拟后端动态生成路由
|
||||||
import { MockMethod } from "vite-plugin-mock";
|
import { MockMethod } from "vite-plugin-mock";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* roles:页面级别权限,这里模拟二种 "admin"、"common"
|
||||||
|
* admin:管理员角色
|
||||||
|
* common:普通角色
|
||||||
|
*/
|
||||||
|
|
||||||
const permissionRouter = {
|
const permissionRouter = {
|
||||||
path: "/permission",
|
path: "/permission",
|
||||||
name: "permission",
|
|
||||||
redirect: "/permission/page/index",
|
|
||||||
meta: {
|
meta: {
|
||||||
title: "menus.permission",
|
title: "权限管理",
|
||||||
icon: "lollipop",
|
icon: "lollipop",
|
||||||
i18n: true,
|
rank: 10
|
||||||
showLink: true,
|
|
||||||
rank: 3
|
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "/permission/page/index",
|
path: "/permission/page/index",
|
||||||
name: "permissionPage",
|
name: "PermissionPage",
|
||||||
meta: {
|
meta: {
|
||||||
title: "menus.permissionPage",
|
title: "页面权限",
|
||||||
i18n: true,
|
roles: ["admin", "common"]
|
||||||
showLink: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/permission/button/index",
|
path: "/permission/button/index",
|
||||||
name: "permissionButton",
|
name: "PermissionButton",
|
||||||
meta: {
|
meta: {
|
||||||
title: "menus.permissionButton",
|
title: "按钮权限",
|
||||||
i18n: true,
|
roles: ["admin", "common"],
|
||||||
showLink: true,
|
auths: ["btn_add", "btn_edit", "btn_delete"]
|
||||||
authority: []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
// 添加不同按钮权限到/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: [permissionRouter]
|
||||||
info: [setDifAuthority("v-admin", permissionRouter)]
|
};
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
code: 0,
|
|
||||||
info: [setDifAuthority("v-test", permissionRouter)]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
] as MockMethod[];
|
] as MockMethod[];
|
||||||
|
|||||||
36
mock/login.ts
Normal 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[];
|
||||||
27
mock/refreshToken.ts
Normal 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.newAdmin",
|
||||||
|
refreshToken: "eyJhbGciOiJIUzUxMiJ9.newAdminRefresh",
|
||||||
|
// `expires`选择这种日期格式是为了方便调试,后端直接设置时间戳或许更方便(每次都应该递增)。如果后端返回的是时间戳格式,前端开发请来到这个目录`src/utils/auth.ts`,把第`38`行的代码换成expires = data.expires即可。
|
||||||
|
expires: "2023/10/30 23:59:59"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
data: {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
] as MockMethod[];
|
||||||
160
package.json
@@ -1,20 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "pure-admin-thin",
|
"name": "pure-admin-thin",
|
||||||
"version": "2.8.5",
|
"version": "3.8.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
|
||||||
"node": ">= 16",
|
|
||||||
"pnpm": ">= 6"
|
|
||||||
},
|
|
||||||
"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 vite build",
|
"build": "rimraf dist && NODE_OPTIONS=--max-old-space-size=8192 vite build",
|
||||||
|
"build:staging": "rimraf dist && vite build --mode staging",
|
||||||
|
"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",
|
||||||
|
"svgo": "svgo -f src/assets/svg -o src/assets/svg",
|
||||||
|
"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",
|
||||||
@@ -28,87 +29,106 @@
|
|||||||
"not op_mini all"
|
"not op_mini all"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ctrl/tinycolor": "^3.4.0",
|
"@ctrl/tinycolor": "^3.4.1",
|
||||||
"@fortawesome/fontawesome-svg-core": "^1.2.36",
|
"@pureadmin/descriptions": "^1.1.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^5.15.4",
|
"@pureadmin/table": "^1.8.0",
|
||||||
"@fortawesome/vue-fontawesome": "^3.0.0-5",
|
"@pureadmin/utils": "^1.6.7",
|
||||||
"@vueuse/core": "^7.5.3",
|
"@vueuse/core": "^9.6.0",
|
||||||
"@vueuse/motion": "^2.0.0-beta.9",
|
"@vueuse/motion": "2.0.0-beta.12",
|
||||||
"@vueuse/shared": "^7.5.3",
|
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"axios": "^0.25.0",
|
"axios": "^1.2.0",
|
||||||
"css-color-function": "^1.3.3",
|
"dayjs": "^1.11.6",
|
||||||
"dayjs": "^1.10.7",
|
"echarts": "^5.4.0",
|
||||||
"element-plus": "1.3.0-beta.1",
|
"element-plus": "^2.2.25",
|
||||||
"element-resize-detector": "^1.2.3",
|
"element-resize-detector": "^1.2.4",
|
||||||
"font-awesome": "^4.7.0",
|
|
||||||
"js-cookie": "^3.0.1",
|
"js-cookie": "^3.0.1",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
|
"lodash-unified": "^1.0.2",
|
||||||
"mitt": "^3.0.0",
|
"mitt": "^3.0.0",
|
||||||
"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.9",
|
"pinia": "^2.0.26",
|
||||||
"qs": "^6.10.2",
|
"qs": "^6.11.0",
|
||||||
"remixicon": "^2.5.0",
|
"responsive-storage": "^2.1.0",
|
||||||
"resize-observer-polyfill": "^1.5.1",
|
"vue": "^3.2.45",
|
||||||
"responsive-storage": "^1.0.11",
|
"vue-router": "^4.1.6",
|
||||||
"rgb-hex": "^4.0.0",
|
"vue-types": "^4.2.1",
|
||||||
"vue": "^3.2.27",
|
"vxe-table": "^4.3.6",
|
||||||
"vue-i18n": "^9.2.0-beta.26",
|
"xe-utils": "^3.5.7"
|
||||||
"vue-router": "^4.0.12",
|
|
||||||
"vue-types": "^4.1.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "13.1.0",
|
"@commitlint/cli": "13.1.0",
|
||||||
"@commitlint/config-conventional": "13.1.0",
|
"@commitlint/config-conventional": "13.1.0",
|
||||||
"@iconify-icons/ep": "^1.1.3",
|
"@iconify-icons/ep": "^1.2.7",
|
||||||
"@iconify/vue": "^3.1.2",
|
"@iconify-icons/ri": "^1.2.3",
|
||||||
|
"@iconify/vue": "^4.0.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",
|
||||||
"@types/mockjs": "1.0.3",
|
"@types/lodash": "^4.14.180",
|
||||||
"@types/node": "14.14.14",
|
"@types/lodash-es": "^4.17.6",
|
||||||
|
"@types/mockjs": "^1.0.7",
|
||||||
|
"@types/node": "^18.11.9",
|
||||||
"@types/nprogress": "0.2.0",
|
"@types/nprogress": "0.2.0",
|
||||||
"@types/qs": "^6.9.7",
|
"@types/qs": "^6.9.7",
|
||||||
"@typescript-eslint/eslint-plugin": "4.31.0",
|
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
||||||
"@typescript-eslint/parser": "4.31.0",
|
"@typescript-eslint/parser": "^5.42.1",
|
||||||
"@vitejs/plugin-legacy": "^1.6.4",
|
"@vitejs/plugin-legacy": "^2.3.1",
|
||||||
"@vitejs/plugin-vue": "^2.0.1",
|
"@vitejs/plugin-vue": "^3.2.0",
|
||||||
"@vitejs/plugin-vue-jsx": "^1.3.3",
|
"@vitejs/plugin-vue-jsx": "^2.1.1",
|
||||||
"@vue/eslint-config-prettier": "6.0.0",
|
"@vue/eslint-config-prettier": "^7.0.0",
|
||||||
"@vue/eslint-config-typescript": "7.0.0",
|
"@vue/eslint-config-typescript": "^11.0.2",
|
||||||
"@zougt/vite-plugin-theme-preprocessor": "^1.4.4",
|
"autoprefixer": "^10.4.13",
|
||||||
"autoprefixer": "10.2.4",
|
"cloc": "^2.10.0",
|
||||||
"cross-env": "7.0.3",
|
"cssnano": "^5.1.14",
|
||||||
"eslint": "7.30.0",
|
"eslint": "^8.8.0",
|
||||||
"eslint-plugin-prettier": "3.4.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"eslint-plugin-vue": "7.17.0",
|
"eslint-plugin-vue": "^9.7.0",
|
||||||
"husky": "7.0.2",
|
"font-awesome": "^4.7.0",
|
||||||
|
"husky": "^7.0.4",
|
||||||
"lint-staged": "11.1.2",
|
"lint-staged": "11.1.2",
|
||||||
"postcss": "8.2.6",
|
"picocolors": "^1.0.0",
|
||||||
"postcss-import": "14.0.0",
|
"postcss": "^8.4.18",
|
||||||
"prettier": "2.3.2",
|
"postcss-html": "^1.5.0",
|
||||||
|
"postcss-import": "^15.0.0",
|
||||||
|
"postcss-scss": "^4.0.5",
|
||||||
|
"prettier": "^2.5.1",
|
||||||
"pretty-quick": "3.1.1",
|
"pretty-quick": "3.1.1",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
"sass": "^1.45.0",
|
"rollup-plugin-visualizer": "^5.8.3",
|
||||||
"sass-loader": "^12.3.0",
|
"sass": "^1.56.1",
|
||||||
"stylelint": "13.13.1",
|
"sass-loader": "^13.2.0",
|
||||||
"stylelint-config-prettier": "8.0.2",
|
"stylelint": "^14.3.0",
|
||||||
"stylelint-config-standard": "22.0.0",
|
"stylelint-config-html": "^1.0.0",
|
||||||
"stylelint-order": "4.1.0",
|
"stylelint-config-prettier": "^9.0.3",
|
||||||
"typescript": "^4.5.5",
|
"stylelint-config-recommended": "^9.0.0",
|
||||||
"unplugin-element-plus": "^0.2.0",
|
"stylelint-config-standard": "^29.0.0",
|
||||||
"vite": "^2.7.13",
|
"stylelint-order": "^5.0.0",
|
||||||
"vite-plugin-live-reload": "^2.1.0",
|
"svgo": "^3.0.2",
|
||||||
|
"tailwindcss": "^3.2.4",
|
||||||
|
"terser": "^5.15.1",
|
||||||
|
"typescript": "^4.9.3",
|
||||||
|
"unplugin-vue-macros": "^1.0.3",
|
||||||
|
"vite": "3.1.8",
|
||||||
|
"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": "^0.0.6",
|
"vite-plugin-remove-console": "^1.3.0",
|
||||||
"vite-plugin-style-import": "^1.4.1",
|
"vite-svg-loader": "^3.6.0",
|
||||||
"vite-plugin-windicss": "^1.6.3",
|
"vue-eslint-parser": "^9.1.0",
|
||||||
"vite-svg-loader": "2.2.0",
|
"vue-tsc": "^1.0.9"
|
||||||
"vue-eslint-parser": "7.10.0",
|
|
||||||
"windicss": "^3.4.3"
|
|
||||||
},
|
},
|
||||||
"repository": "git@github.com:xiaoxian521/vue-pure-admin.git",
|
"pnpm": {
|
||||||
|
"peerDependencyRules": {
|
||||||
|
"ignoreMissing": [
|
||||||
|
"rollup",
|
||||||
|
"webpack"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"repository": "git@github.com:xiaoxian521/pure-admin-thin.git",
|
||||||
"author": "xiaoxian521",
|
"author": "xiaoxian521",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
|||||||
5271
pnpm-lock.yaml
generated
@@ -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: {} } : {})
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
@font-face {
|
|
||||||
font-family: "iconfont"; /* project id 1098500 */
|
|
||||||
src: url("//at.alicdn.com/t/font_1098500_3d6un9zwltz.eot");
|
|
||||||
src: url("//at.alicdn.com/t/font_1098500_3d6un9zwltz.eot?#iefix")
|
|
||||||
format("embedded-opentype"),
|
|
||||||
url("//at.alicdn.com/t/font_1098500_3d6un9zwltz.woff2") format("woff2"),
|
|
||||||
url("//at.alicdn.com/t/font_1098500_3d6un9zwltz.woff") format("woff"),
|
|
||||||
url("//at.alicdn.com/t/font_1098500_3d6un9zwltz.ttf") format("truetype"),
|
|
||||||
url("//at.alicdn.com/t/font_1098500_3d6un9zwltz.svg#iconfont") format("svg");
|
|
||||||
}
|
|
||||||
|
|
||||||
.iconfont {
|
|
||||||
font-family: "iconfont" !important;
|
|
||||||
font-size: 16px;
|
|
||||||
font-style: normal;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
{
|
{
|
||||||
"Version": "2.8.5",
|
"Version": "3.8.6",
|
||||||
"Title": "PureAdmin",
|
"Title": "PureAdmin",
|
||||||
"FixedHeader": true,
|
"FixedHeader": true,
|
||||||
"HiddenSideBar": false,
|
"HiddenSideBar": false,
|
||||||
"MultiTagsCache": false,
|
"MultiTagsCache": false,
|
||||||
"KeepAlive": true,
|
"KeepAlive": true,
|
||||||
"Locale": "zh",
|
|
||||||
"Layout": "vertical",
|
"Layout": "vertical",
|
||||||
"Theme": "default",
|
"Theme": "default",
|
||||||
"DarkMode": false,
|
"DarkMode": false,
|
||||||
@@ -16,12 +15,5 @@
|
|||||||
"EpThemeColor": "#409EFF",
|
"EpThemeColor": "#409EFF",
|
||||||
"ShowLogo": true,
|
"ShowLogo": true,
|
||||||
"ShowModel": "smart",
|
"ShowModel": "smart",
|
||||||
"MapConfigure": {
|
"MenuArrowIconNoTransition": true
|
||||||
"amapKey": "97b3248d1553172e81f168cf94ea667e",
|
|
||||||
"options": {
|
|
||||||
"resizeEnable": true,
|
|
||||||
"center": [113.6401, 34.72468],
|
|
||||||
"zoom": 12
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import { ElConfigProvider } from "element-plus";
|
import { ElConfigProvider } from "element-plus";
|
||||||
import zhCn from "element-plus/lib/locale/lang/zh-cn";
|
import zhCn from "element-plus/lib/locale/lang/zh-cn";
|
||||||
import en from "element-plus/lib/locale/lang/en";
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "app",
|
name: "app",
|
||||||
components: {
|
components: {
|
||||||
@@ -16,7 +15,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
currentLocale() {
|
currentLocale() {
|
||||||
return this.$storage.locale?.locale === "zh" ? zhCn : en;
|
return zhCn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import { http } from "../utils/http";
|
import { http } from "@/utils/http";
|
||||||
|
|
||||||
export const getAsyncRoutes = (params?: object) => {
|
type Result = {
|
||||||
return http.request("get", "/getAsyncRoutes", { params });
|
success: boolean;
|
||||||
|
data: Array<any>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAsyncRoutes = () => {
|
||||||
|
return http.request<Result>("get", "/getAsyncRoutes");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,26 +1,39 @@
|
|||||||
import { http } from "../utils/http";
|
import { http } from "@/utils/http";
|
||||||
|
|
||||||
interface userType extends Promise<any> {
|
export type UserResult = {
|
||||||
svg?: string;
|
success: boolean;
|
||||||
code?: number;
|
data: {
|
||||||
info?: object;
|
/** 用户名 */
|
||||||
}
|
username: string;
|
||||||
|
/** 当前登陆用户的角色 */
|
||||||
// 获取验证码
|
roles: Array<string>;
|
||||||
export const getVerify = (): userType => {
|
/** `token` */
|
||||||
return http.request("get", "/captcha");
|
accessToken: string;
|
||||||
|
/** 用于调用刷新`accessToken`的接口时所需的`token` */
|
||||||
|
refreshToken: string;
|
||||||
|
/** `accessToken`的过期时间(格式'xxxx/xx/xx xx:xx:xx') */
|
||||||
|
expires: Date;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// 登录
|
export type RefreshTokenResult = {
|
||||||
export const getLogin = (data: object) => {
|
success: boolean;
|
||||||
return http.request("post", "/login", { data });
|
data: {
|
||||||
|
/** `token` */
|
||||||
|
accessToken: string;
|
||||||
|
/** 用于调用刷新`accessToken`的接口时所需的`token` */
|
||||||
|
refreshToken: string;
|
||||||
|
/** `accessToken`的过期时间(格式'xxxx/xx/xx xx:xx:xx') */
|
||||||
|
expires: Date;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// 刷新token
|
/** 登录 */
|
||||||
export const refreshToken = (data: object) => {
|
export const getLogin = (data?: object) => {
|
||||||
return http.request("post", "/refreshToken", { data });
|
return http.request<UserResult>("post", "/login", { data });
|
||||||
};
|
};
|
||||||
|
|
||||||
// export const searchVague = (data: object) => {
|
/** 刷新token */
|
||||||
// return http.request("post", "/searchVague", { data });
|
export const refreshTokenApi = (data?: object) => {
|
||||||
// };
|
return http.request<RefreshTokenResult>("post", "/refreshToken", { data });
|
||||||
|
};
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 680 KiB |
|
Before Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -1 +1 @@
|
|||||||
<svg t="1636193306629" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1847" width="32" height="32"><path d="M410.558481 0.10861C410.558481 211.083075 109.682285 361.860579 109.682285 633.656511c0 174.943176 134.703259 316.787527 300.876196 316.787527s300.876197-141.817198 300.876197-316.787527C711.407525 361.751969 410.558481 210.974465 410.558481 0.10861z" fill="#386BF3" p-id="1848"></path><path d="M613.468671 73.664572c0 211.055922-300.876197 361.914883-300.876196 633.547901 0 174.943176 134.703259 316.787527 300.876196 316.787527s300.876197-141.817198 300.876197-316.787527c-0.054305-271.633018-300.876197-422.491979-300.876197-633.547901z" fill="#C3D2FB" p-id="1849"></path><path d="M312.592475 707.212473c0-183.713414 137.635722-312.171612 226.72288-441.390078 81.701694 106.111739 172.119322 218.740063 172.119323 367.725506a309.755045 309.755045 0 0 1-291.074166 316.516003 323.114046 323.114046 0 0 1-107.768037-242.851431z" fill="#303F5B" p-id="1850"></path></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="icon" viewBox="0 0 1024 1024"><path fill="#386BF3" d="M410.558.109c0 210.974-300.876 361.752-300.876 633.548 0 174.943 134.704 316.787 300.876 316.787s300.877-141.817 300.877-316.787C711.408 361.752 410.558 210.974 410.558.109z"/><path fill="#C3D2FB" d="M613.469 73.665c0 211.055-300.877 361.914-300.877 633.547C312.592 882.156 447.296 1024 613.47 1024s300.876-141.817 300.876-316.788C914.29 435.58 613.469 284.72 613.469 73.665z"/><path fill="#303F5B" d="M312.592 707.212c0-183.713 137.636-312.171 226.723-441.39 81.702 106.112 172.12 218.74 172.12 367.726A309.755 309.755 0 0 1 420.36 950.064a323.114 323.114 0 0 1-107.769-242.852z"/></svg>
|
||||||
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 712 B |
1
src/assets/login/illustration.svg
Normal file
|
After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 17 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" width="500" height="380" viewBox="0 0 896 529.1129" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M832.06729,623.22778s-26.37759,9.89441-38.806,32.94348S787.06,706.69574,787.06,706.69574s26.37759-9.89447,38.806-32.94348S832.06729,623.22778,832.06729,623.22778Z" transform="translate(-158 -185.8871)" fill="#3f3d56"/><path d="M867.5,657.59637s-8.64182,26.814-31.0802,40.31373-50.17651,8.57293-50.17651,8.57293,8.64175-26.81408,31.08017-40.31378S867.5,657.59637,867.5,657.59637Z" transform="translate(-158 -185.8871)" fill="#5392f0"/><rect y="527.1129" width="896" height="2" fill="#2f2e41"/><path d="M519.87238,620.97461a95.44448,95.44448,0,0,1-35.748-14.44629L485.306,604.915a93.36283,93.36283,0,0,0,34.999,14.10547c18.93164,3.40137,47.26075,1.73144,74.707-25.52735,53.41358-53.04785,104.39307-58.39062,104.90186-58.43847l.18652,1.99219c-.50146.04687-50.76806,5.31738-103.67822,57.86621-21.61328,21.46386-43.792,27.40234-61.71777,27.40234A83.49962,83.49962,0,0,1,519.87238,620.97461Z" transform="translate(-158 -185.8871)" fill="#2f2e41"/><circle cx="515.15271" cy="381.1129" r="12" fill="#2f2e41"/><circle cx="430.15271" cy="437.1129" r="12" fill="#2f2e41"/><path d="M841.5,714s-17.46191-5.41315-52.26129-10.84192L790,692.5c6-60-34-150-34-150a401.561,401.561,0,0,1,21.4693,139.0246C772.13214,672.2124,761.82056,662.16638,742,656c0,0,25.77765,22.106,33.15918,45.10175a997.84042,997.84042,0,0,0-102.02258-8.21589L682,672.5l-17,17s-7-51-22-53l11,50s-13-10-16-9l7.39746,14.79486c-49.819-.51654-109.08453,1.7356-177.76581,8.95227L476,682l-17,17s-7-51-22-53l11,50s-13-10-16-9l8.64288,17.28583Q406.9763,708.2897,370.5,714Z" transform="translate(-158 -185.8871)" fill="#3f3d56"/><path d="M565.64813,230.37817c-10.89964,11.74783,17.59745,40.25959,17.59745,40.25959s-57.70662,9.73051-53.12783,9.14083,2.20622-49.13151,2.20622-49.13151S576.54777,218.63035,565.64813,230.37817Z" transform="translate(-158 -185.8871)" fill="#a0616a"/><path d="M605.81236,356.10945l-50.139,25.6141-27.22969,15.6059s-32.09862,40.43116-38.08709,64.39234,25.92963,68.247,29.54371,72.82286a54.36088,54.36088,0,0,1,4.98908,7.42355c1.24727,1.85589,12.02944-.541,23.80342-3.06554S547.13,518.93875,547.13,518.93875s-15.02732-38.39505-16.14686-39.25912c-1.04554-.807-4.60093-7.44631-2.04309-10.35234a25.94993,25.94993,0,0,0,5.44489-8.89825,30.09064,30.09064,0,0,1,4.18709-7.94151s45.361-36.83645,59.52776-49.37835,51.82952-4.65839,51.82952-4.65839-17.78167,68.20027-22.22979,72.80616-4.929,8.70085-2.91535,16.50759,28.28157.39078,28.28157.39078L662.766,461.6996s15.74879-34.2925,24.29946-69.67451c4.27533-17.691-3.88828-28.23462-13.12073-34.35549a41.39094,41.39094,0,0,0-30.02983-5.97766l-46.34848,8.1308,32.14706-13.84923Z" transform="translate(-158 -185.8871)" fill="#2f2e41"/><path d="M420.87777,290.19133,361.02366,271.685s-24.179-31.16689-12.78824-36.6669,25.65172,26.94419,25.65172,26.94419l41.686,2.69751Z" transform="translate(-158 -185.8871)" fill="#a0616a"/><path d="M672.49431,257.78673l53.2121-33.06768s15.49333-36.27612,3.0807-38.71059-17.98787,32.56435-17.98787,32.56435l-39.64232,13.17143Z" transform="translate(-158 -185.8871)" fill="#a0616a"/><path d="M682.45318,220.40023l1.01427,39.19147-89.68779,16.025c13.19231,28.22441,9.84118,60.34675,43.04725,74.4259L524.9027,404.78717c4.9871-43.03806-15.81748-75.456-35.263-115.75876-23.68547-8.58589-51.19594-2.29078-80.33649,10.34619l-5.237-40.66416,123.87841-8.896,20.34848,7.77932,21.81842-9.17677C602.17891,238.88953,648.22076,220.77584,682.45318,220.40023Z" transform="translate(-158 -185.8871)" fill="#5392f0"/><path d="M626.64006,486.51727c-2.72,2.36681-5.25213,21.84984-5.34982,28.92023s9.21178,8.89624,14.29855,9.2494,4.47816,3.45631,7.83678,6.04854,14.39625,2.179,28.89019-2.71238-9.75274-20.92568-11.86409-21.662-11-22.78156-11-22.78156S629.36,484.15046,626.64006,486.51727Z" transform="translate(-158 -185.8871)" fill="#2f2e41"/><path d="M547.368,531.00717c3.23089,1.60043,10.61681,19.80614,12.50274,26.62107s-6.65716,10.93994-11.48848,12.5704-3.45631,4.47816-6.04855,7.83678-13.3744,5.75546-28.63472,4.696,4.13258-22.71391,5.98847-23.96118,4.86893-24.82526,4.86893-24.82526S544.13715,529.40674,547.368,531.00717Z" transform="translate(-158 -185.8871)" fill="#2f2e41"/><circle cx="389.47074" cy="35.42904" r="23.99585" fill="#a0616a"/><path d="M519.73448,218.90923a22.82668,22.82668,0,0,1-.83378-18.59281c2.35891-5.8153,7.59174-11.65569,18.87309-13.4,24.61387-3.80572,37.71267,13.43543,37.02452,19.07449s-3.99294,19.27051-3.99294,19.27051,1.47587-12.90619-4.85883-13.362-30.90178-2.37835-37.12217,4.145a14.23268,14.23268,0,0,0-3.71042,13.82977Z" transform="translate(-158 -185.8871)" fill="#2f2e41"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 11 KiB |
1
src/assets/status/403.svg
Normal file
|
After Width: | Height: | Size: 10 KiB |
1
src/assets/status/404.svg
Normal file
|
After Width: | Height: | Size: 11 KiB |
1
src/assets/status/500.svg
Normal file
|
After Width: | Height: | Size: 13 KiB |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M2.88 18.054a35.897 35.897 0 0 1 8.531-16.32.8.8 0 0 1 1.178 0c.166.18.304.332.413.455a35.897 35.897 0 0 1 8.118 15.865c-2.141.451-4.34.747-6.584.874l-2.089 4.178a.5.5 0 0 1-.894 0l-2.089-4.178a44.019 44.019 0 0 1-6.584-.874zm6.698-1.123l1.157.066L12 19.527l1.265-2.53 1.157-.066a42.137 42.137 0 0 0 4.227-.454A33.913 33.913 0 0 0 12 4.09a33.913 33.913 0 0 0-6.649 12.387c1.395.222 2.805.374 4.227.454zM12 15a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M2.88 18.054a35.897 35.897 0 0 1 8.531-16.32.8.8 0 0 1 1.178 0c.166.18.304.332.413.455a35.897 35.897 0 0 1 8.118 15.865c-2.141.451-4.34.747-6.584.874l-2.089 4.178a.5.5 0 0 1-.894 0l-2.089-4.178a44.019 44.019 0 0 1-6.584-.874zm6.698-1.123 1.157.066L12 19.527l1.265-2.53 1.157-.066a42.137 42.137 0 0 0 4.227-.454A33.913 33.913 0 0 0 12 4.09a33.913 33.913 0 0 0-6.649 12.387c1.395.222 2.805.374 4.227.454zM12 15a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/></svg>
|
||||||
|
Before Width: | Height: | Size: 608 B After Width: | Height: | Size: 588 B |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.38 2.019a7.5 7.5 0 1 0 10.6 10.6C21.662 17.854 17.316 22 12.001 22 6.477 22 2 17.523 2 12c0-5.315 4.146-9.661 9.38-9.981z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.38 2.019a7.5 7.5 0 1 0 10.6 10.6C21.662 17.854 17.316 22 12.001 22 6.477 22 2 17.523 2 12c0-5.315 4.146-9.661 9.38-9.981z"/></svg>
|
||||||
|
Before Width: | Height: | Size: 263 B After Width: | Height: | Size: 263 B |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85 1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></svg>
|
||||||
|
Before Width: | Height: | Size: 480 B After Width: | Height: | Size: 480 B |
1
src/assets/svg/enter_outlined.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" class="iconify iconify--ant-design" viewBox="0 0 1024 1024"><path fill="currentColor" d="M864 170h-60c-4.4 0-8 3.6-8 8v518H310v-73c0-6.7-7.8-10.5-13-6.3l-141.9 112a8 8 0 0 0 0 12.6l141.9 112c5.3 4.2 13 .4 13-6.3v-75h498c35.3 0 64-28.7 64-64V178c0-4.4-3.6-8-8-8z"/></svg>
|
||||||
|
After Width: | Height: | Size: 352 B |
@@ -1 +1 @@
|
|||||||
<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" class="re-screen" color="#00000073" preserveAspectRatio="xMidYMid meet" viewBox="0 0 16 16"><g fill="currentColor"><path d="M3.5 4H1V3h2V1h1v2.5l-.5.5zM13 3V1h-1v2.5l.5.5H15V3h-2zm-1 9.5V15h1v-2h2v-1h-2.5l-.5.5zM1 12v1h2v2h1v-2.5l-.5-.5H1zm11-1.5l-.5.5h-7l-.5-.5v-5l.5-.5h7l.5.5v5zM10 7H6v2h4V7z"></path></g></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" aria-hidden="true" class="re-screen" color="#00000073" viewBox="0 0 16 16"><path fill="currentColor" d="M3.5 4H1V3h2V1h1v2.5l-.5.5zM13 3V1h-1v2.5l.5.5H15V3h-2zm-1 9.5V15h1v-2h2v-1h-2.5l-.5.5zM1 12v1h2v2h1v-2.5l-.5-.5H1zm11-1.5-.5.5h-7l-.5-.5v-5l.5-.5h7l.5.5v5zM10 7H6v2h4V7z"/></svg>
|
||||||
|
Before Width: | Height: | Size: 452 B After Width: | Height: | Size: 348 B |
@@ -1 +1 @@
|
|||||||
<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" class="re-screen" color="#00000073" preserveAspectRatio="xMidYMid meet" viewBox="0 0 16 16"><g fill="currentColor"><path d="M3 12h10V4H3v8zm2-6h6v4H5V6zM2 6H1V2.5l.5-.5H5v1H2v3zm13-3.5V6h-1V3h-3V2h3.5l.5.5zM14 10h1v3.5l-.5.5H11v-1h3v-3zM2 13h3v1H1.5l-.5-.5V10h1v3z"></path></g></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" aria-hidden="true" class="re-screen" color="#00000073" viewBox="0 0 16 16"><path fill="currentColor" d="M3 12h10V4H3v8zm2-6h6v4H5V6zM2 6H1V2.5l.5-.5H5v1H2v3zm13-3.5V6h-1V3h-3V2h3.5l.5.5zM14 10h1v3.5l-.5.5H11v-1h3v-3zM2 13h3v1H1.5l-.5-.5V10h1v3z"/></svg>
|
||||||
|
Before Width: | Height: | Size: 421 B After Width: | Height: | Size: 318 B |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="globalization" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 512 512"><path d="M478.33 433.6l-90-218a22 22 0 0 0-40.67 0l-90 218a22 22 0 1 0 40.67 16.79L316.66 406h102.67l18.33 44.39A22 22 0 0 0 458 464a22 22 0 0 0 20.32-30.4zM334.83 362L368 281.65L401.17 362z" fill="currentColor"></path><path d="M267.84 342.92a22 22 0 0 0-4.89-30.7c-.2-.15-15-11.13-36.49-34.73c39.65-53.68 62.11-114.75 71.27-143.49H330a22 22 0 0 0 0-44H214V70a22 22 0 0 0-44 0v20H54a22 22 0 0 0 0 44h197.25c-9.52 26.95-27.05 69.5-53.79 108.36c-31.41-41.68-43.08-68.65-43.17-68.87a22 22 0 0 0-40.58 17c.58 1.38 14.55 34.23 52.86 83.93c.92 1.19 1.83 2.35 2.74 3.51c-39.24 44.35-77.74 71.86-93.85 80.74a22 22 0 1 0 21.07 38.63c2.16-1.18 48.6-26.89 101.63-85.59c22.52 24.08 38 35.44 38.93 36.1a22 22 0 0 0 30.75-4.9z" fill="currentColor"></path></svg>
|
|
||||||
|
Before Width: | Height: | Size: 965 B |
1
src/assets/svg/keyboard_esc.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" class="iconify iconify--mdi" viewBox="0 0 24 24"><path fill="currentColor" d="M1 7h6v2H3v2h4v2H3v2h4v2H1V7m10 0h4v2h-4v2h2a2 2 0 0 1 2 2v2c0 1.11-.89 2-2 2H9v-2h4v-2h-2a2 2 0 0 1-2-2V9c0-1.1.9-2 2-2m8 0h2a2 2 0 0 1 2 2v1h-2V9h-2v6h2v-1h2v1c0 1.11-.89 2-2 2h-2a2 2 0 0 1-2-2V9c0-1.1.9-2 2-2Z"/></svg>
|
||||||
|
After Width: | Height: | Size: 381 B |
@@ -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 |
5
src/components/ReAuth/index.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import auth from "./src/auth";
|
||||||
|
|
||||||
|
const Auth = auth;
|
||||||
|
|
||||||
|
export { Auth };
|
||||||
20
src/components/ReAuth/src/auth.tsx
Normal 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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1,103 +1,12 @@
|
|||||||
import { App, defineComponent } from "vue";
|
|
||||||
import icon from "./src/Icon.vue";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
|
||||||
import iconifyIconOffline from "./src/iconifyIconOffline";
|
import iconifyIconOffline from "./src/iconifyIconOffline";
|
||||||
import iconifyIconOnline from "./src/iconifyIconOnline";
|
import iconifyIconOnline from "./src/iconifyIconOnline";
|
||||||
|
import fontIcon from "./src/iconfont";
|
||||||
|
|
||||||
/**
|
/** 本地图标组件 */
|
||||||
* find icon component
|
const IconifyIconOffline = iconifyIconOffline;
|
||||||
* @param icon icon图标
|
/** 在线图标组件 */
|
||||||
* @returns component
|
const IconifyIconOnline = iconifyIconOnline;
|
||||||
*/
|
/** iconfont组件 */
|
||||||
export function findIconReg(icon: string) {
|
const FontIcon = fontIcon;
|
||||||
// fontawesome4
|
|
||||||
const fa4Reg = /^fa-/;
|
|
||||||
// fontawesome5+
|
|
||||||
const fa5Reg = /^FA-/;
|
|
||||||
// iconfont
|
|
||||||
const iFReg = /^IF-/;
|
|
||||||
// remixicon
|
|
||||||
const riReg = /^RI-/;
|
|
||||||
// typeof icon === "function" 属于SVG
|
|
||||||
if (fa5Reg.test(icon)) {
|
|
||||||
const text = icon.split(fa5Reg)[1];
|
|
||||||
return findIcon(
|
|
||||||
text.slice(0, text.indexOf(" ") == -1 ? text.length : text.indexOf(" ")),
|
|
||||||
"FA",
|
|
||||||
text.slice(text.indexOf(" ") + 1, text.length)
|
|
||||||
);
|
|
||||||
} else if (fa4Reg.test(icon)) {
|
|
||||||
return findIcon(icon.split(fa4Reg)[1], "fa");
|
|
||||||
} else if (iFReg.test(icon)) {
|
|
||||||
return findIcon(icon.split(iFReg)[1], "IF");
|
|
||||||
} else if (typeof icon === "function") {
|
|
||||||
return findIcon(icon, "SVG");
|
|
||||||
} else if (riReg.test(icon)) {
|
|
||||||
return findIcon(icon.split(riReg)[1], "RI");
|
|
||||||
} else {
|
|
||||||
return findIcon(icon, "EL");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 支持fontawesome、iconfont、remixicon、element-plus/icons、自定义svg
|
export { IconifyIconOffline, IconifyIconOnline, FontIcon };
|
||||||
export function findIcon(icon: String, type = "EL", property?: string) {
|
|
||||||
if (type === "FA") {
|
|
||||||
return defineComponent({
|
|
||||||
name: "FaIcon",
|
|
||||||
setup() {
|
|
||||||
return { icon, property };
|
|
||||||
},
|
|
||||||
components: { FontAwesomeIcon },
|
|
||||||
template: `<font-awesome-icon :icon="icon" v-bind:[property]="true" />`
|
|
||||||
});
|
|
||||||
} else if (type === "fa") {
|
|
||||||
return defineComponent({
|
|
||||||
name: "faIcon",
|
|
||||||
data() {
|
|
||||||
return { icon: `fa ${icon}` };
|
|
||||||
},
|
|
||||||
template: `<i :class="icon" />`
|
|
||||||
});
|
|
||||||
} else if (type === "IF") {
|
|
||||||
return defineComponent({
|
|
||||||
name: "IfIcon",
|
|
||||||
data() {
|
|
||||||
return { icon: `iconfont ${icon}` };
|
|
||||||
},
|
|
||||||
template: `<i :class="icon" />`
|
|
||||||
});
|
|
||||||
} else if (type === "RI") {
|
|
||||||
return defineComponent({
|
|
||||||
name: "RiIcon",
|
|
||||||
data() {
|
|
||||||
return { icon: `ri-${icon}` };
|
|
||||||
},
|
|
||||||
template: `<i :class="icon" />`
|
|
||||||
});
|
|
||||||
} else if (type === "EL") {
|
|
||||||
return defineComponent({
|
|
||||||
name: "ElIcon",
|
|
||||||
data() {
|
|
||||||
return { icon };
|
|
||||||
},
|
|
||||||
template: `<IconifyIconOffline :icon="icon" />`
|
|
||||||
});
|
|
||||||
} else if (type === "SVG") {
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const Icon = Object.assign(icon, {
|
|
||||||
install(app: App) {
|
|
||||||
app.component(icon.name, icon);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export const IconifyIconOffline = iconifyIconOffline;
|
|
||||||
export const IconifyIconOnline = iconifyIconOnline;
|
|
||||||
|
|
||||||
export default {
|
|
||||||
Icon,
|
|
||||||
IconifyIconOffline,
|
|
||||||
IconifyIconOnline
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
export default {
|
|
||||||
name: "Icon"
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref, computed } from "vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
content: {
|
|
||||||
type: String,
|
|
||||||
default: ""
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
type: Number,
|
|
||||||
default: 18
|
|
||||||
},
|
|
||||||
width: {
|
|
||||||
type: Number,
|
|
||||||
default: 20
|
|
||||||
},
|
|
||||||
height: {
|
|
||||||
type: Number,
|
|
||||||
default: 20
|
|
||||||
},
|
|
||||||
color: {
|
|
||||||
type: String,
|
|
||||||
default: ""
|
|
||||||
},
|
|
||||||
svg: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(e: "click"): void;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
let text = ref("");
|
|
||||||
|
|
||||||
let className = computed(() => {
|
|
||||||
if (props.content.indexOf("fa-") > -1) {
|
|
||||||
return props.content.indexOf("fa ") === 0
|
|
||||||
? props.content
|
|
||||||
: ["fa", props.content];
|
|
||||||
} else if (props.content.indexOf("el-icon-") > -1) {
|
|
||||||
return props.content;
|
|
||||||
} else if (props.content.indexOf("#") > -1) {
|
|
||||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
|
||||||
text.value = props.content;
|
|
||||||
return "iconfont";
|
|
||||||
} else {
|
|
||||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
|
||||||
text.value = props.content;
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let iconStyle = computed(() => {
|
|
||||||
return (
|
|
||||||
"font-size: " +
|
|
||||||
props.size +
|
|
||||||
"px; color: " +
|
|
||||||
props.color +
|
|
||||||
"; width: " +
|
|
||||||
props.width +
|
|
||||||
"px; height: " +
|
|
||||||
props.height +
|
|
||||||
"px; font-style: normal;"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
const clickHandle = () => {
|
|
||||||
emit("click");
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<i
|
|
||||||
v-if="!props.svg"
|
|
||||||
:class="className"
|
|
||||||
:style="iconStyle"
|
|
||||||
v-html="text"
|
|
||||||
@click="clickHandle"
|
|
||||||
></i>
|
|
||||||
<svg
|
|
||||||
class="icon-svg"
|
|
||||||
v-if="props.svg"
|
|
||||||
aria-hidden="true"
|
|
||||||
:style="iconStyle"
|
|
||||||
@click="clickHandle"
|
|
||||||
>
|
|
||||||
<use :xlink:href="`#${props.content}`" />
|
|
||||||
</svg>
|
|
||||||
</template>
|
|
||||||
51
src/components/ReIcon/src/hooks.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { iconType } from "./types";
|
||||||
|
import { h, defineComponent, Component } from "vue";
|
||||||
|
import { IconifyIconOnline, IconifyIconOffline, FontIcon } from "../index";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支持 `iconfont`、自定义 `svg` 以及 `iconify` 中所有的图标
|
||||||
|
* @see 点击查看文档图标篇 {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/icon/}
|
||||||
|
* @param icon 必传 图标
|
||||||
|
* @param attrs 可选 iconType 属性
|
||||||
|
* @returns Component
|
||||||
|
*/
|
||||||
|
export function useRenderIcon(icon: any, attrs?: iconType): Component {
|
||||||
|
// iconfont
|
||||||
|
const ifReg = /^IF-/;
|
||||||
|
// typeof icon === "function" 属于SVG
|
||||||
|
if (ifReg.test(icon)) {
|
||||||
|
// iconfont
|
||||||
|
const name = icon.split(ifReg)[1];
|
||||||
|
const iconName = name.slice(
|
||||||
|
0,
|
||||||
|
name.indexOf(" ") == -1 ? name.length : name.indexOf(" ")
|
||||||
|
);
|
||||||
|
const iconType = name.slice(name.indexOf(" ") + 1, name.length);
|
||||||
|
return defineComponent({
|
||||||
|
name: "FontIcon",
|
||||||
|
render() {
|
||||||
|
return h(FontIcon, {
|
||||||
|
icon: iconName,
|
||||||
|
iconType,
|
||||||
|
...attrs
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (typeof icon === "function" || typeof icon?.render === "function") {
|
||||||
|
// svg
|
||||||
|
return icon;
|
||||||
|
} else {
|
||||||
|
// 通过是否存在 : 符号来判断是在线还是本地图标,存在即是在线图标,反之
|
||||||
|
return defineComponent({
|
||||||
|
name: "Icon",
|
||||||
|
render() {
|
||||||
|
const IconifyIcon =
|
||||||
|
icon && icon.includes(":") ? IconifyIconOnline : IconifyIconOffline;
|
||||||
|
return h(IconifyIcon, {
|
||||||
|
icon: icon,
|
||||||
|
...attrs
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/components/ReIcon/src/iconfont.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { h, defineComponent } from "vue";
|
||||||
|
|
||||||
|
// 封装iconfont组件,默认`font-class`引用模式,支持`unicode`引用、`font-class`引用、`symbol`引用 (https://www.iconfont.cn/help/detail?spm=a313x.7781069.1998910419.20&helptype=code)
|
||||||
|
export default defineComponent({
|
||||||
|
name: "FontIcon",
|
||||||
|
props: {
|
||||||
|
icon: {
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
const attrs = this.$attrs;
|
||||||
|
if (Object.keys(attrs).includes("uni") || attrs?.iconType === "uni") {
|
||||||
|
return h(
|
||||||
|
"i",
|
||||||
|
{
|
||||||
|
class: "iconfont",
|
||||||
|
...attrs
|
||||||
|
},
|
||||||
|
this.icon
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
Object.keys(attrs).includes("svg") ||
|
||||||
|
attrs?.iconType === "svg"
|
||||||
|
) {
|
||||||
|
return h(
|
||||||
|
"svg",
|
||||||
|
{
|
||||||
|
class: "icon-svg",
|
||||||
|
"aria-hidden": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => [
|
||||||
|
h("use", {
|
||||||
|
"xlink:href": `#${this.icon}`
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return h("i", {
|
||||||
|
class: `iconfont ${this.icon}`,
|
||||||
|
...attrs
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1,54 +1,75 @@
|
|||||||
import { h, defineComponent } from "vue";
|
import { h, defineComponent } from "vue";
|
||||||
import { Icon as IconifyIcon, addIcon } from "@iconify/vue/dist/offline";
|
import { Icon as IconifyIcon, addIcon } from "@iconify/vue/dist/offline";
|
||||||
|
|
||||||
|
// element-plus icon
|
||||||
import Check from "@iconify-icons/ep/check";
|
import Check from "@iconify-icons/ep/check";
|
||||||
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 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 Position from "@iconify-icons/ep/position";
|
|
||||||
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";
|
||||||
import Guide from "@iconify-icons/ep/guide";
|
import Search from "@iconify-icons/ep/search";
|
||||||
import User from "@iconify-icons/ep/user";
|
import EpArrowDown from "@iconify-icons/ep/arrow-down";
|
||||||
import Iphone from "@iconify-icons/ep/iphone";
|
import ArrowUp from "@iconify-icons/ep/arrow-up";
|
||||||
import Location from "@iconify-icons/ep/location";
|
import ArrowRight from "@iconify-icons/ep/arrow-right";
|
||||||
import Tickets from "@iconify-icons/ep/tickets";
|
import ArrowLeft from "@iconify-icons/ep/arrow-left";
|
||||||
import OfficeBuilding from "@iconify-icons/ep/office-building";
|
|
||||||
import Notebook from "@iconify-icons/ep/notebook";
|
|
||||||
addIcon("check", Check);
|
addIcon("check", Check);
|
||||||
addIcon("menu", Menu);
|
|
||||||
addIcon("home-filled", HomeFilled);
|
addIcon("home-filled", HomeFilled);
|
||||||
addIcon("set-up", SetUp);
|
|
||||||
addIcon("edit", Edit);
|
|
||||||
addIcon("setting", Setting);
|
|
||||||
addIcon("lollipop", Lollipop);
|
addIcon("lollipop", Lollipop);
|
||||||
addIcon("link", Link);
|
|
||||||
addIcon("position", Position);
|
|
||||||
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);
|
||||||
addIcon("guide", Guide);
|
addIcon("search", Search);
|
||||||
addIcon("user", User);
|
addIcon("ep-arrow-down", EpArrowDown);
|
||||||
addIcon("iphone", Iphone);
|
addIcon("ep-arrow-up", ArrowUp);
|
||||||
addIcon("location", Location);
|
addIcon("ep-arrow-right", ArrowRight);
|
||||||
addIcon("tickets", Tickets);
|
addIcon("ep-arrow-left", ArrowLeft);
|
||||||
addIcon("office-building", OfficeBuilding);
|
|
||||||
addIcon("notebook", Notebook);
|
|
||||||
|
|
||||||
// Iconify Icon在Vue里离线使用(用于内网环境)
|
// remixicon
|
||||||
// https://docs.iconify.design/icon-components/vue/offline.html
|
import ArrowRightSLine from "@iconify-icons/ri/arrow-right-s-line";
|
||||||
|
import ArrowLeftSLine from "@iconify-icons/ri/arrow-left-s-line";
|
||||||
|
import LogoutCircleRLine from "@iconify-icons/ri/logout-circle-r-line";
|
||||||
|
import InformationLine from "@iconify-icons/ri/information-line";
|
||||||
|
import ArrowUpLine from "@iconify-icons/ri/arrow-up-line";
|
||||||
|
import ArrowDownLine from "@iconify-icons/ri/arrow-down-line";
|
||||||
|
import Bookmark2Line from "@iconify-icons/ri/bookmark-2-line";
|
||||||
|
import User from "@iconify-icons/ri/user-3-fill";
|
||||||
|
import Lock from "@iconify-icons/ri/lock-fill";
|
||||||
|
import MenuUnfold from "@iconify-icons/ri/menu-unfold-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-left-s-line", ArrowLeftSLine);
|
||||||
|
addIcon("logout-circle-r-line", LogoutCircleRLine);
|
||||||
|
addIcon("information-line", InformationLine);
|
||||||
|
addIcon("arrow-up-line", ArrowUpLine);
|
||||||
|
addIcon("arrow-down-line", ArrowDownLine);
|
||||||
|
addIcon("bookmark-2-line", Bookmark2Line);
|
||||||
|
addIcon("user", User);
|
||||||
|
addIcon("lock", Lock);
|
||||||
|
addIcon("menu-unfold", MenuUnfold);
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Iconify Icon在Vue里本地使用(用于内网环境)https://docs.iconify.design/icon-components/vue/offline.html
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "IconifyIcon",
|
name: "IconifyIconOffline",
|
||||||
components: { IconifyIcon },
|
components: { IconifyIcon },
|
||||||
props: {
|
props: {
|
||||||
icon: {
|
icon: {
|
||||||
@@ -57,10 +78,15 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
|
const attrs = this.$attrs;
|
||||||
return h(
|
return h(
|
||||||
IconifyIcon,
|
IconifyIcon,
|
||||||
{
|
{
|
||||||
icon: `${this.icon}`
|
icon: `${this.icon}`,
|
||||||
|
style: attrs?.style
|
||||||
|
? Object.assign(attrs.style, { outline: "none" })
|
||||||
|
: { outline: "none" },
|
||||||
|
...attrs
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
default: () => []
|
default: () => []
|
||||||
|
|||||||
@@ -2,25 +2,25 @@ import { h, defineComponent } from "vue";
|
|||||||
import { Icon as IconifyIcon } from "@iconify/vue";
|
import { Icon as IconifyIcon } from "@iconify/vue";
|
||||||
|
|
||||||
// Iconify Icon在Vue里在线使用(用于外网环境)
|
// Iconify Icon在Vue里在线使用(用于外网环境)
|
||||||
// https://docs.iconify.design/icon-components/vue/offline.html
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "IconifyIcon",
|
name: "IconifyIconOnline",
|
||||||
components: { IconifyIcon },
|
components: { IconifyIcon },
|
||||||
props: {
|
props: {
|
||||||
icon: {
|
icon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ""
|
default: ""
|
||||||
},
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
default: "ep:"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
|
const attrs = this.$attrs;
|
||||||
return h(
|
return h(
|
||||||
IconifyIcon,
|
IconifyIcon,
|
||||||
{
|
{
|
||||||
icon: `${this.type}${this.icon}`
|
icon: `${this.icon}`,
|
||||||
|
style: attrs?.style
|
||||||
|
? Object.assign(attrs.style, { outline: "none" })
|
||||||
|
: { outline: "none" },
|
||||||
|
...attrs
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
default: () => []
|
default: () => []
|
||||||
|
|||||||
19
src/components/ReIcon/src/types.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
export interface iconType {
|
||||||
|
// iconify (https://docs.iconify.design/icon-components/vue/#properties)
|
||||||
|
inline?: boolean;
|
||||||
|
width?: string | number;
|
||||||
|
height?: string | number;
|
||||||
|
horizontalFlip?: boolean;
|
||||||
|
verticalFlip?: boolean;
|
||||||
|
flip?: string;
|
||||||
|
rotate?: number | string;
|
||||||
|
color?: string;
|
||||||
|
horizontalAlign?: boolean;
|
||||||
|
verticalAlign?: boolean;
|
||||||
|
align?: string;
|
||||||
|
onLoad?: Function;
|
||||||
|
includes?: Function;
|
||||||
|
|
||||||
|
// all icon
|
||||||
|
style?: object;
|
||||||
|
}
|
||||||
@@ -27,11 +27,10 @@ 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({
|
||||||
baseURL: "",
|
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${VITE_PUBLIC_PATH}serverConfig.json`
|
url: `${VITE_PUBLIC_PATH}serverConfig.json`
|
||||||
})
|
})
|
||||||
@@ -44,8 +43,6 @@ export const getServerConfig = async (app: App): Promise<undefined> => {
|
|||||||
// 设置全局配置
|
// 设置全局配置
|
||||||
setConfig($config);
|
setConfig($config);
|
||||||
}
|
}
|
||||||
// 设置全局baseURL
|
|
||||||
app.config.globalProperties.$baseUrl = $config.baseURL;
|
|
||||||
return $config;
|
return $config;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
13
src/directives/auth/index.ts
Normal 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']\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import { Directive } from "vue";
|
import { Directive, type DirectiveBinding, type VNode } from "vue";
|
||||||
import type { DirectiveBinding, 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 { emitter } from "/@/utils/mitt";
|
import { emitter } from "@/utils/mitt";
|
||||||
|
|
||||||
const erd: Erd = elementResizeDetectorMaker({
|
const erd: Erd = elementResizeDetectorMaker({
|
||||||
strategy: "scroll"
|
strategy: "scroll"
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export * from "./permission";
|
export * from "./auth";
|
||||||
export * from "./elResizeDetector";
|
export * from "./elResizeDetector";
|
||||||
|
|||||||
@@ -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']\"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,24 +1,18 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import { useGlobal } from "@pureadmin/utils";
|
||||||
h,
|
import backTop from "@/assets/svg/back_top.svg?component";
|
||||||
ref,
|
import { h, computed, Transition, defineComponent } from "vue";
|
||||||
computed,
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||||
Transition,
|
|
||||||
defineComponent,
|
|
||||||
getCurrentInstance
|
|
||||||
} from "vue";
|
|
||||||
import { RouterView } from "vue-router";
|
|
||||||
import backTop from "/@/assets/svg/back_top.svg?component";
|
|
||||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
fixedHeader: Boolean
|
fixedHeader: Boolean
|
||||||
});
|
});
|
||||||
const keepAlive: Boolean = ref(
|
|
||||||
getCurrentInstance().appContext.config.globalProperties.$config?.KeepAlive
|
const { $storage, $config } = useGlobal<GlobalPropertiesApi>();
|
||||||
);
|
|
||||||
const instance =
|
const keepAlive = computed(() => {
|
||||||
getCurrentInstance().appContext.app.config.globalProperties.$storage;
|
return $config?.KeepAlive;
|
||||||
|
});
|
||||||
|
|
||||||
const transitions = computed(() => {
|
const transitions = computed(() => {
|
||||||
return route => {
|
return route => {
|
||||||
@@ -27,11 +21,11 @@ const transitions = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const hideTabs = computed(() => {
|
const hideTabs = computed(() => {
|
||||||
return instance?.configure.hideTabs;
|
return $storage?.configure.hideTabs;
|
||||||
});
|
});
|
||||||
|
|
||||||
const layout = computed(() => {
|
const layout = computed(() => {
|
||||||
return instance?.layout.layout === "vertical";
|
return $storage?.layout.layout === "vertical";
|
||||||
});
|
});
|
||||||
|
|
||||||
const getSectionStyle = computed(() => {
|
const getSectionStyle = computed(() => {
|
||||||
|
|||||||
@@ -1,138 +1,74 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from "vue";
|
import Search from "./search/index.vue";
|
||||||
import { useI18n } from "vue-i18n";
|
|
||||||
import { emitter } from "/@/utils/mitt";
|
|
||||||
import Notice from "./notice/index.vue";
|
import Notice from "./notice/index.vue";
|
||||||
import avatars from "/@/assets/avatars.jpg";
|
import mixNav from "./sidebar/mixNav.vue";
|
||||||
import { transformI18n } from "/@/plugins/i18n";
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
import Hamburger from "./sidebar/hamBurger.vue";
|
|
||||||
import { useRouter, useRoute } from "vue-router";
|
|
||||||
import { storageSession } from "/@/utils/storage";
|
|
||||||
import Breadcrumb from "./sidebar/breadCrumb.vue";
|
import Breadcrumb from "./sidebar/breadCrumb.vue";
|
||||||
import { useAppStoreHook } from "/@/store/modules/app";
|
import topCollapse from "./sidebar/topCollapse.vue";
|
||||||
import { unref, watch, getCurrentInstance } from "vue";
|
|
||||||
import { deviceDetection } from "/@/utils/deviceDetection";
|
|
||||||
import screenfull from "../components/screenfull/index.vue";
|
|
||||||
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
|
|
||||||
import globalization from "/@/assets/svg/globalization.svg?component";
|
|
||||||
|
|
||||||
const instance =
|
const {
|
||||||
getCurrentInstance().appContext.config.globalProperties.$storage;
|
layout,
|
||||||
const pureApp = useAppStoreHook();
|
device,
|
||||||
const router = useRouter();
|
logout,
|
||||||
const route = useRoute();
|
onPanel,
|
||||||
let usename = storageSession.getItem("info")?.username;
|
pureApp,
|
||||||
const { locale } = useI18n();
|
username,
|
||||||
|
avatarsStyle,
|
||||||
const getDropdownItemStyle = computed(() => {
|
toggleSideBar
|
||||||
return t => {
|
} = useNav();
|
||||||
return {
|
|
||||||
background: locale.value === t ? useEpThemeStoreHook().epThemeColor : "",
|
|
||||||
color: locale.value === t ? "#f4f4f5" : "#000"
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => locale.value,
|
|
||||||
() => {
|
|
||||||
//@ts-ignore
|
|
||||||
document.title = transformI18n(
|
|
||||||
//@ts-ignore
|
|
||||||
unref(route.meta.title),
|
|
||||||
unref(route.meta.i18n)
|
|
||||||
); // 动态title
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// 退出登录
|
|
||||||
const logout = (): void => {
|
|
||||||
storageSession.removeItem("info");
|
|
||||||
router.push("/login");
|
|
||||||
};
|
|
||||||
|
|
||||||
function onPanel() {
|
|
||||||
emitter.emit("openPanel");
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleSideBar() {
|
|
||||||
pureApp.toggleSideBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 简体中文
|
|
||||||
function translationCh() {
|
|
||||||
instance.locale = { locale: "zh" };
|
|
||||||
locale.value = "zh";
|
|
||||||
}
|
|
||||||
|
|
||||||
// English
|
|
||||||
function translationEn() {
|
|
||||||
instance.locale = { locale: "en" };
|
|
||||||
locale.value = "en";
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="navbar">
|
<div
|
||||||
<Hamburger
|
class="navbar bg-[#fff] shadow-sm shadow-[rgba(0, 21, 41, 0.08)] dark:shadow-[#0d0d0d]"
|
||||||
:is-active="pureApp.sidebar.opened"
|
>
|
||||||
|
<topCollapse
|
||||||
|
v-if="device === 'mobile'"
|
||||||
class="hamburger-container"
|
class="hamburger-container"
|
||||||
|
:is-active="pureApp.sidebar.opened"
|
||||||
@toggleClick="toggleSideBar"
|
@toggleClick="toggleSideBar"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Breadcrumb class="breadcrumb-container" />
|
<Breadcrumb
|
||||||
|
v-if="layout !== 'mix' && device !== 'mobile'"
|
||||||
|
class="breadcrumb-container"
|
||||||
|
/>
|
||||||
|
|
||||||
<div class="vertical-header-right">
|
<mixNav v-if="layout === 'mix'" />
|
||||||
|
|
||||||
|
<div v-if="layout === 'vertical'" class="vertical-header-right">
|
||||||
|
<!-- 菜单搜索 -->
|
||||||
|
<Search />
|
||||||
<!-- 通知 -->
|
<!-- 通知 -->
|
||||||
<Notice id="header-notice" />
|
<Notice id="header-notice" />
|
||||||
<!-- 全屏 -->
|
<!-- 退出登录 -->
|
||||||
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
|
|
||||||
<!-- 国际化 -->
|
|
||||||
<el-dropdown id="header-translation" trigger="click">
|
|
||||||
<globalization />
|
|
||||||
<template #dropdown>
|
|
||||||
<el-dropdown-menu class="translation">
|
|
||||||
<el-dropdown-item
|
|
||||||
:style="getDropdownItemStyle('zh')"
|
|
||||||
@click="translationCh"
|
|
||||||
><IconifyIconOffline
|
|
||||||
class="check-zh"
|
|
||||||
v-show="locale === 'zh'"
|
|
||||||
icon="check"
|
|
||||||
/>简体中文</el-dropdown-item
|
|
||||||
>
|
|
||||||
<el-dropdown-item
|
|
||||||
:style="getDropdownItemStyle('en')"
|
|
||||||
@click="translationEn"
|
|
||||||
><el-icon class="check-en" v-show="locale === 'en'"
|
|
||||||
><IconifyIconOffline icon="check" /></el-icon
|
|
||||||
>English</el-dropdown-item
|
|
||||||
>
|
|
||||||
</el-dropdown-menu>
|
|
||||||
</template>
|
|
||||||
</el-dropdown>
|
|
||||||
<!-- 退出登陆 -->
|
|
||||||
<el-dropdown trigger="click">
|
<el-dropdown trigger="click">
|
||||||
<span class="el-dropdown-link">
|
<span class="el-dropdown-link navbar-bg-hover select-none">
|
||||||
<img :src="avatars" />
|
<img
|
||||||
<p>{{ usename }}</p>
|
src="https://avatars.githubusercontent.com/u/44761321?v=4"
|
||||||
|
:style="avatarsStyle"
|
||||||
|
/>
|
||||||
|
<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">
|
||||||
<el-dropdown-item @click="logout">
|
<el-dropdown-item @click="logout">
|
||||||
<i class="ri-logout-circle-r-line"></i
|
<IconifyIconOffline
|
||||||
>{{ $t("buttons.hsLoginOut") }}</el-dropdown-item
|
icon="logout-circle-r-line"
|
||||||
>
|
style="margin: 5px"
|
||||||
|
/>
|
||||||
|
退出系统
|
||||||
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
<el-icon
|
<span
|
||||||
class="el-icon-setting"
|
class="set-icon navbar-bg-hover"
|
||||||
:title="$t('buttons.hssystemSet')"
|
title="打开项目配置"
|
||||||
@click="onPanel"
|
@click="onPanel"
|
||||||
>
|
>
|
||||||
<IconifyIconOffline icon="setting" />
|
<IconifyIconOffline icon="setting" />
|
||||||
</el-icon>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -142,16 +78,12 @@ function translationEn() {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #fff;
|
|
||||||
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
|
||||||
|
|
||||||
.hamburger-container {
|
.hamburger-container {
|
||||||
line-height: 48px;
|
line-height: 48px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
float: left;
|
float: left;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background 0.3s;
|
|
||||||
-webkit-tap-highlight-color: transparent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.vertical-header-right {
|
.vertical-header-right {
|
||||||
@@ -162,33 +94,7 @@ function translationEn() {
|
|||||||
color: #000000d9;
|
color: #000000d9;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
|
||||||
:deep(.dropdown-badge) {
|
|
||||||
&:hover {
|
|
||||||
background: #f6f6f6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.screen-full {
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: #f6f6f6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.globalization {
|
|
||||||
height: 48px;
|
|
||||||
width: 40px;
|
|
||||||
padding: 11px;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: #f6f6f6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-dropdown-link {
|
.el-dropdown-link {
|
||||||
width: 100px;
|
|
||||||
height: 48px;
|
height: 48px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -197,10 +103,6 @@ function translationEn() {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: #000000d9;
|
color: #000000d9;
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: #f6f6f6;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
p {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
@@ -211,61 +113,21 @@ function translationEn() {
|
|||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-icon-setting {
|
|
||||||
height: 48px;
|
|
||||||
width: 38px;
|
|
||||||
padding: 12px;
|
|
||||||
display: flex;
|
|
||||||
cursor: pointer;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: #f6f6f6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.breadcrumb-container {
|
.breadcrumb-container {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
margin-left: 16px;
|
||||||
}
|
|
||||||
|
|
||||||
.translation {
|
|
||||||
.el-dropdown-menu__item {
|
|
||||||
padding: 5px 40px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-dropdown-menu__item:focus,
|
|
||||||
.el-dropdown-menu__item:not(.is-disabled):hover {
|
|
||||||
color: #606266;
|
|
||||||
background: #f0f0f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.check-zh {
|
|
||||||
position: absolute;
|
|
||||||
left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.check-en {
|
|
||||||
position: absolute;
|
|
||||||
left: 20px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.logout {
|
.logout {
|
||||||
max-width: 120px;
|
max-width: 120px;
|
||||||
|
|
||||||
.el-dropdown-menu__item {
|
::v-deep(.el-dropdown-menu__item) {
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-dropdown-menu__item:focus,
|
|
||||||
.el-dropdown-menu__item:not(.is-disabled):hover {
|
|
||||||
color: #606266;
|
|
||||||
background: #f0f0f0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ export const noticesData: TabItem[] = [
|
|||||||
{
|
{
|
||||||
avatar: "",
|
avatar: "",
|
||||||
title: "任务名称",
|
title: "任务名称",
|
||||||
description: "任务需要在 2021-11-16 20:00 前启动",
|
description: "任务需要在 2022-11-16 20:00 前启动",
|
||||||
datetime: "",
|
datetime: "",
|
||||||
extra: "未开始",
|
extra: "未开始",
|
||||||
status: "info",
|
status: "info",
|
||||||
@@ -118,7 +118,7 @@ export const noticesData: TabItem[] = [
|
|||||||
avatar: "",
|
avatar: "",
|
||||||
title: "第三方紧急代码变更",
|
title: "第三方紧急代码变更",
|
||||||
description:
|
description:
|
||||||
"一拳提交于 2021-11-16,需在 2021-11-18 前完成代码变更任务",
|
"一拳提交于 2022-11-16,需在 2022-11-18 前完成代码变更任务",
|
||||||
datetime: "",
|
datetime: "",
|
||||||
extra: "马上到期",
|
extra: "马上到期",
|
||||||
status: "danger",
|
status: "danger",
|
||||||
@@ -127,7 +127,7 @@ export const noticesData: TabItem[] = [
|
|||||||
{
|
{
|
||||||
avatar: "",
|
avatar: "",
|
||||||
title: "信息安全考试",
|
title: "信息安全考试",
|
||||||
description: "指派小仙于 2021-12-12 前完成更新并发布",
|
description: "指派小仙于 2022-12-12 前完成更新并发布",
|
||||||
datetime: "",
|
datetime: "",
|
||||||
extra: "已耗时 8 天",
|
extra: "已耗时 8 天",
|
||||||
status: "warning",
|
status: "warning",
|
||||||
|
|||||||
@@ -1,33 +1,31 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import NoticeList from "./noticeList.vue";
|
|
||||||
import { noticesData } from "./data";
|
import { noticesData } from "./data";
|
||||||
|
import NoticeList from "./noticeList.vue";
|
||||||
|
|
||||||
const activeName = ref(noticesData[0].name);
|
const noticesNum = ref(0);
|
||||||
const notices = ref(noticesData);
|
const notices = ref(noticesData);
|
||||||
|
const activeKey = ref(noticesData[0].key);
|
||||||
|
|
||||||
let noticesNum = ref(0);
|
notices.value.map(v => (noticesNum.value += v.list.length));
|
||||||
notices.value.forEach(notice => {
|
|
||||||
noticesNum.value += notice.list.length;
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-dropdown trigger="click" placement="bottom-end">
|
<el-dropdown trigger="click" placement="bottom-end">
|
||||||
<span class="dropdown-badge">
|
<span class="dropdown-badge navbar-bg-hover select-none">
|
||||||
<el-badge :value="noticesNum" :max="99">
|
<el-badge :value="noticesNum" :max="99">
|
||||||
<el-icon class="header-notice-icon"
|
<span class="header-notice-icon">
|
||||||
><IconifyIconOffline icon="bell"
|
<IconifyIconOffline icon="bell" />
|
||||||
/></el-icon>
|
</span>
|
||||||
</el-badge>
|
</el-badge>
|
||||||
</span>
|
</span>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-tabs v-model="activeName" class="dropdown-tabs">
|
<el-tabs :stretch="true" v-model="activeKey" class="dropdown-tabs">
|
||||||
<template v-for="item in notices" :key="item.key">
|
<template v-for="item in notices" :key="item.key">
|
||||||
<el-tab-pane
|
<el-tab-pane
|
||||||
:label="`${item.name}(${item.list.length})`"
|
:label="`${item.name}(${item.list.length})`"
|
||||||
:name="item.name"
|
:name="`${item.key}`"
|
||||||
>
|
>
|
||||||
<el-scrollbar max-height="330px">
|
<el-scrollbar max-height="330px">
|
||||||
<div class="noticeList-container">
|
<div class="noticeList-container">
|
||||||
@@ -57,26 +55,28 @@ notices.value.forEach(notice => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-tabs {
|
.dropdown-tabs {
|
||||||
width: 336px;
|
width: 330px;
|
||||||
background-color: #fff;
|
|
||||||
box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
|
.noticeList-container {
|
||||||
border-radius: 4px;
|
padding: 15px 24px 0 24px;
|
||||||
|
}
|
||||||
|
|
||||||
:deep(.el-tabs__header) {
|
:deep(.el-tabs__header) {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-tabs__nav-scroll) {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.el-tabs__nav-wrap)::after {
|
:deep(.el-tabs__nav-wrap)::after {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.noticeList-container) {
|
// 如果上面的 notices 长度大于 3 请注释掉下面代码
|
||||||
padding: 15px 24px 0 24px;
|
:deep(.el-tabs__nav-wrap) {
|
||||||
|
padding: 0 36px 0 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果上面的 notices 长度大于 3 请注释掉下面代码
|
||||||
|
:deep(.el-tabs__active-bar) {
|
||||||
|
margin: 0 36px 0 36px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const titleRef = ref(null);
|
const titleRef = ref(null);
|
||||||
const descriptionRef = ref(null);
|
|
||||||
const titleTooltip = ref(false);
|
const titleTooltip = ref(false);
|
||||||
|
const descriptionRef = ref(null);
|
||||||
const descriptionTooltip = ref(false);
|
const descriptionTooltip = ref(false);
|
||||||
|
|
||||||
function hoverTitle() {
|
function hoverTitle() {
|
||||||
@@ -24,11 +24,11 @@ function hoverTitle() {
|
|||||||
|
|
||||||
function hoverDescription(event, description) {
|
function hoverDescription(event, description) {
|
||||||
// currentWidth 为文本在页面中所占的宽度,创建标签,加入到页面,获取currentWidth ,最后在移除
|
// currentWidth 为文本在页面中所占的宽度,创建标签,加入到页面,获取currentWidth ,最后在移除
|
||||||
let tempTag = document.createElement("span");
|
const tempTag = document.createElement("span");
|
||||||
tempTag.innerText = description;
|
tempTag.innerText = description;
|
||||||
tempTag.className = "getDescriptionWidth";
|
tempTag.className = "getDescriptionWidth";
|
||||||
document.querySelector("body").appendChild(tempTag);
|
document.querySelector("body").appendChild(tempTag);
|
||||||
let currentWidth = (
|
const currentWidth = (
|
||||||
document.querySelector(".getDescriptionWidth") as HTMLSpanElement
|
document.querySelector(".getDescriptionWidth") as HTMLSpanElement
|
||||||
).offsetWidth;
|
).offsetWidth;
|
||||||
document.querySelector(".getDescriptionWidth").remove();
|
document.querySelector(".getDescriptionWidth").remove();
|
||||||
@@ -44,15 +44,17 @@ function hoverDescription(event, description) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="notice-container">
|
<div
|
||||||
|
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"
|
||||||
:size="30"
|
:size="30"
|
||||||
:src="props.noticeItem.avatar"
|
:src="props.noticeItem.avatar"
|
||||||
class="notice-container-avatar"
|
class="notice-container-avatar"
|
||||||
></el-avatar>
|
/>
|
||||||
<div class="notice-container-text">
|
<div class="notice-container-text">
|
||||||
<div class="notice-text-title">
|
<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"
|
||||||
@@ -72,7 +74,8 @@ function hoverDescription(event, description) {
|
|||||||
:type="props.noticeItem?.status"
|
:type="props.noticeItem?.status"
|
||||||
size="small"
|
size="small"
|
||||||
class="notice-title-extra"
|
class="notice-title-extra"
|
||||||
>{{ props.noticeItem?.extra }}
|
>
|
||||||
|
{{ props.noticeItem?.extra }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -90,7 +93,7 @@ function hoverDescription(event, description) {
|
|||||||
{{ props.noticeItem.description }}
|
{{ props.noticeItem.description }}
|
||||||
</div>
|
</div>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<div class="notice-text-datetime">
|
<div class="notice-text-datetime text-[#00000073] dark:text-white">
|
||||||
{{ props.noticeItem.datetime }}
|
{{ props.noticeItem.datetime }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -108,7 +111,7 @@ function hoverDescription(event, description) {
|
|||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 12px 0;
|
padding: 12px 0;
|
||||||
border-bottom: 1px solid #f0f0f0;
|
// border-bottom: 1px solid #f0f0f0;
|
||||||
|
|
||||||
.notice-container-avatar {
|
.notice-container-avatar {
|
||||||
margin-right: 16px;
|
margin-right: 16px;
|
||||||
@@ -127,7 +130,6 @@ function hoverDescription(event, description) {
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 1.5715;
|
line-height: 1.5715;
|
||||||
color: rgba(0, 0, 0, 0.85);
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
.notice-title-content {
|
.notice-title-content {
|
||||||
@@ -149,7 +151,6 @@ function hoverDescription(event, description) {
|
|||||||
.notice-text-datetime {
|
.notice-text-datetime {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 1.5715;
|
line-height: 1.5715;
|
||||||
color: rgba(0, 0, 0, 0.45);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.notice-text-description {
|
.notice-text-description {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PropType } from "vue";
|
import { PropType } from "vue";
|
||||||
import NoticeItem from "./noticeItem.vue";
|
|
||||||
import { ListItem } from "./data";
|
import { ListItem } from "./data";
|
||||||
|
import NoticeItem from "./noticeItem.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
list: {
|
list: {
|
||||||
@@ -17,7 +17,7 @@ const props = defineProps({
|
|||||||
v-for="(item, index) in props.list"
|
v-for="(item, index) in props.list"
|
||||||
:noticeItem="item"
|
:noticeItem="item"
|
||||||
:key="index"
|
:key="index"
|
||||||
></NoticeItem>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<el-empty v-else description="暂无数据"></el-empty>
|
<el-empty v-else description="暂无数据" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { onClickOutside } from "@vueuse/core";
|
import { onClickOutside } from "@vueuse/core";
|
||||||
import { emitter } from "/@/utils/mitt";
|
import { emitter } from "@/utils/mitt";
|
||||||
|
|
||||||
let show = ref<Boolean>(false);
|
const show = ref<Boolean>(false);
|
||||||
const target = ref(null);
|
const target = ref(null);
|
||||||
onClickOutside(target, event => {
|
onClickOutside(target, (event: any) => {
|
||||||
if (event.clientX > target.value.offsetLeft) return;
|
if (event.clientX > target.value.offsetLeft) return;
|
||||||
show.value = false;
|
show.value = false;
|
||||||
});
|
});
|
||||||
@@ -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">
|
<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>
|
<h4 class="dark:text-white">项目配置</h4>
|
||||||
<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 style="border-bottom: 1px solid #dcdfe6"></div>
|
<div
|
||||||
|
class="border-b-[1px] border-solid border-[#dcdfe6] dark:border-[#303030]"
|
||||||
|
/>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -54,7 +60,7 @@ emitter.on("openPanel", () => {
|
|||||||
|
|
||||||
.right-panel {
|
.right-panel {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 300px;
|
max-width: 315px;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -62,7 +68,7 @@ emitter.on("openPanel", () => {
|
|||||||
box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.05);
|
box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.05);
|
||||||
transition: all 0.25s cubic-bezier(0.7, 0.3, 0.1, 1);
|
transition: all 0.25s cubic-bezier(0.7, 0.3, 0.1, 1);
|
||||||
transform: translate(100%);
|
transform: translate(100%);
|
||||||
background: #fff;
|
// background: #fff;
|
||||||
z-index: 40000;
|
z-index: 40000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,8 +111,8 @@ emitter.on("openPanel", () => {
|
|||||||
|
|
||||||
.right-panel-items {
|
.right-panel-items {
|
||||||
margin-top: 60px;
|
margin-top: 60px;
|
||||||
height: 100vh;
|
height: calc(100vh - 60px);
|
||||||
overflow: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-configuration {
|
.project-configuration {
|
||||||
@@ -119,13 +125,13 @@ 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;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: red;
|
color: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,17 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useFullscreen } from "@vueuse/core";
|
import { useFullscreen } from "@vueuse/core";
|
||||||
|
|
||||||
const { isFullscreen, toggle } = useFullscreen();
|
const { isFullscreen, toggle } = useFullscreen();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="screen-full" @click="toggle">
|
<div
|
||||||
<i
|
class="screen-full w-[36px] h-[48px] flex-ac cursor-pointer navbar-bg-hover"
|
||||||
:title="
|
@click="toggle"
|
||||||
isFullscreen
|
>
|
||||||
? $t('buttons.hsexitfullscreen')
|
<FontIcon
|
||||||
: $t('buttons.hsfullscreen')
|
:title="isFullscreen ? '退出全屏' : '全屏'"
|
||||||
"
|
:icon="isFullscreen ? 'team-iconexit-fullscreen' : 'team-iconfullscreen'"
|
||||||
:class="
|
/>
|
||||||
isFullscreen
|
|
||||||
? 'iconfont team-iconexit-fullscreen'
|
|
||||||
: 'iconfont team-iconfullscreen'
|
|
||||||
"
|
|
||||||
></i>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.screen-full {
|
|
||||||
width: 36px;
|
|
||||||
height: 48px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-around;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
42
src/layout/components/search/components/SearchFooter.vue
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<template>
|
||||||
|
<div class="search-footer text-[#333] dark:text-white">
|
||||||
|
<span class="search-footer-item">
|
||||||
|
<enterOutlined class="icon" />
|
||||||
|
确认
|
||||||
|
</span>
|
||||||
|
<span class="search-footer-item">
|
||||||
|
<IconifyIconOffline icon="arrow-up-line" class="icon" />
|
||||||
|
<IconifyIconOffline icon="arrow-down-line" class="icon" />
|
||||||
|
切换
|
||||||
|
</span>
|
||||||
|
<span class="search-footer-item">
|
||||||
|
<mdiKeyboardEsc class="icon" />
|
||||||
|
关闭
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import mdiKeyboardEsc from "@/assets/svg/keyboard_esc.svg?component";
|
||||||
|
import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.search-footer {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.search-footer-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
padding: 2px;
|
||||||
|
margin-right: 3px;
|
||||||
|
font-size: 20px;
|
||||||
|
box-shadow: inset 0 -2px #cdcde6, inset 0 0 1px 1px #fff,
|
||||||
|
0 1px 2px 1px #1e235a66;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
172
src/layout/components/search/components/SearchModal.vue
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useRouter } from "vue-router";
|
||||||
|
import { cloneDeep } from "lodash-unified";
|
||||||
|
import SearchResult from "./SearchResult.vue";
|
||||||
|
import SearchFooter from "./SearchFooter.vue";
|
||||||
|
import { deleteChildren } from "@/utils/tree";
|
||||||
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
|
import { useDebounceFn, onKeyStroke } from "@vueuse/core";
|
||||||
|
import { ref, watch, computed, nextTick, shallowRef } from "vue";
|
||||||
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
/** 弹窗显隐 */
|
||||||
|
value: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: "update:value", val: boolean): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { device } = useNav();
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
const props = withDefaults(defineProps<Props>(), {});
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const keyword = ref("");
|
||||||
|
const activePath = ref("");
|
||||||
|
const inputRef = ref<HTMLInputElement | null>(null);
|
||||||
|
const resultOptions = shallowRef([]);
|
||||||
|
const handleSearch = useDebounceFn(search, 300);
|
||||||
|
|
||||||
|
/** 菜单树形结构 */
|
||||||
|
const menusData = computed(() => {
|
||||||
|
return deleteChildren(cloneDeep(usePermissionStoreHook().wholeMenus));
|
||||||
|
});
|
||||||
|
|
||||||
|
const show = computed({
|
||||||
|
get() {
|
||||||
|
return props.value;
|
||||||
|
},
|
||||||
|
set(val: boolean) {
|
||||||
|
emit("update:value", val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(show, async val => {
|
||||||
|
if (val) {
|
||||||
|
/** 自动聚焦 */
|
||||||
|
await nextTick();
|
||||||
|
inputRef.value?.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 将菜单树形结构扁平化为一维数组,用于菜单查询 */
|
||||||
|
function flatTree(arr) {
|
||||||
|
const res = [];
|
||||||
|
function deep(arr) {
|
||||||
|
arr.forEach(item => {
|
||||||
|
res.push(item);
|
||||||
|
item.children && deep(item.children);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
deep(arr);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询 */
|
||||||
|
function search() {
|
||||||
|
const flatMenusData = flatTree(menusData.value);
|
||||||
|
resultOptions.value = flatMenusData.filter(
|
||||||
|
menu =>
|
||||||
|
keyword.value &&
|
||||||
|
menu.meta?.title
|
||||||
|
.toLocaleLowerCase()
|
||||||
|
.includes(keyword.value.toLocaleLowerCase().trim())
|
||||||
|
);
|
||||||
|
if (resultOptions.value?.length > 0) {
|
||||||
|
activePath.value = resultOptions.value[0].path;
|
||||||
|
} else {
|
||||||
|
activePath.value = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClose() {
|
||||||
|
show.value = false;
|
||||||
|
/** 延时处理防止用户看到某些操作 */
|
||||||
|
setTimeout(() => {
|
||||||
|
resultOptions.value = [];
|
||||||
|
keyword.value = "";
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** key up */
|
||||||
|
function handleUp() {
|
||||||
|
const { length } = resultOptions.value;
|
||||||
|
if (length === 0) return;
|
||||||
|
const index = resultOptions.value.findIndex(
|
||||||
|
item => item.path === activePath.value
|
||||||
|
);
|
||||||
|
if (index === 0) {
|
||||||
|
activePath.value = resultOptions.value[length - 1].path;
|
||||||
|
} else {
|
||||||
|
activePath.value = resultOptions.value[index - 1].path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** key down */
|
||||||
|
function handleDown() {
|
||||||
|
const { length } = resultOptions.value;
|
||||||
|
if (length === 0) return;
|
||||||
|
const index = resultOptions.value.findIndex(
|
||||||
|
item => item.path === activePath.value
|
||||||
|
);
|
||||||
|
if (index + 1 === length) {
|
||||||
|
activePath.value = resultOptions.value[0].path;
|
||||||
|
} else {
|
||||||
|
activePath.value = resultOptions.value[index + 1].path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** key enter */
|
||||||
|
function handleEnter() {
|
||||||
|
const { length } = resultOptions.value;
|
||||||
|
if (length === 0 || activePath.value === "") return;
|
||||||
|
router.push(activePath.value);
|
||||||
|
handleClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
onKeyStroke("Enter", handleEnter);
|
||||||
|
onKeyStroke("ArrowUp", handleUp);
|
||||||
|
onKeyStroke("ArrowDown", handleDown);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
top="5vh"
|
||||||
|
:width="device === 'mobile' ? '80vw' : '50vw'"
|
||||||
|
v-model="show"
|
||||||
|
:before-close="handleClose"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
ref="inputRef"
|
||||||
|
v-model="keyword"
|
||||||
|
clearable
|
||||||
|
placeholder="请输入关键词搜索"
|
||||||
|
@input="handleSearch"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<span class="el-input__icon">
|
||||||
|
<IconifyIconOffline icon="search" />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
<div class="search-result-container">
|
||||||
|
<el-empty v-if="resultOptions.length === 0" description="暂无搜索结果" />
|
||||||
|
<SearchResult
|
||||||
|
v-else
|
||||||
|
v-model:value="activePath"
|
||||||
|
:options="resultOptions"
|
||||||
|
@click="handleEnter"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<SearchFooter />
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.search-result-container {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
97
src/layout/components/search/components/SearchResult.vue
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from "vue";
|
||||||
|
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
|
||||||
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
|
import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
|
||||||
|
|
||||||
|
interface optionsItem {
|
||||||
|
path: string;
|
||||||
|
meta?: {
|
||||||
|
icon?: string;
|
||||||
|
title?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
value: string;
|
||||||
|
options: Array<optionsItem>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: "update:value", val: string): void;
|
||||||
|
(e: "enter"): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {});
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
|
const itemStyle = computed(() => {
|
||||||
|
return item => {
|
||||||
|
return {
|
||||||
|
background:
|
||||||
|
item?.path === active.value ? useEpThemeStoreHook().epThemeColor : "",
|
||||||
|
color: item.path === active.value ? "#fff" : "",
|
||||||
|
fontSize: item.path === active.value ? "16px" : "14px"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const active = computed({
|
||||||
|
get() {
|
||||||
|
return props.value;
|
||||||
|
},
|
||||||
|
set(val: string) {
|
||||||
|
emit("update:value", val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 鼠标移入 */
|
||||||
|
async function handleMouse(item) {
|
||||||
|
active.value = item.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleTo() {
|
||||||
|
emit("enter");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="result">
|
||||||
|
<template v-for="item in options" :key="item.path">
|
||||||
|
<div
|
||||||
|
class="result-item dark:bg-[#1d1d1d]"
|
||||||
|
:style="itemStyle(item)"
|
||||||
|
@click="handleTo"
|
||||||
|
@mouseenter="handleMouse(item)"
|
||||||
|
>
|
||||||
|
<component :is="useRenderIcon(item.meta?.icon ?? 'bookmark-2-line')" />
|
||||||
|
<span class="result-item-title">{{ item.meta?.title }}</span>
|
||||||
|
<enterOutlined />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.result {
|
||||||
|
padding-bottom: 12px;
|
||||||
|
|
||||||
|
&-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 56px;
|
||||||
|
margin-top: 8px;
|
||||||
|
padding: 14px;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
border: 0.1px solid #ccc;
|
||||||
|
transition: all 0.3s;
|
||||||
|
|
||||||
|
&-title {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
3
src/layout/components/search/components/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import SearchModal from "./SearchModal.vue";
|
||||||
|
|
||||||
|
export { SearchModal };
|
||||||
18
src/layout/components/search/index.vue
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { SearchModal } from "./components";
|
||||||
|
import { useBoolean } from "../../hooks/useBoolean";
|
||||||
|
const { bool: show, toggle } = useBoolean();
|
||||||
|
function handleSearch() {
|
||||||
|
toggle();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="search-container w-[40px] h-[48px] flex-c cursor-pointer navbar-bg-hover"
|
||||||
|
@click="handleSearch"
|
||||||
|
>
|
||||||
|
<IconifyIconOffline icon="search" />
|
||||||
|
</div>
|
||||||
|
<SearchModal v-model:value="show" />
|
||||||
|
</template>
|
||||||
@@ -1,184 +1,160 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import {
|
||||||
reactive,
|
|
||||||
ref,
|
ref,
|
||||||
unref,
|
unref,
|
||||||
watch,
|
watch,
|
||||||
|
reactive,
|
||||||
computed,
|
computed,
|
||||||
nextTick,
|
nextTick,
|
||||||
useCssModule,
|
useCssModule
|
||||||
getCurrentInstance
|
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import rgbHex from "rgb-hex";
|
import { getConfig } from "@/config";
|
||||||
import { find } from "lodash-es";
|
|
||||||
import { getConfig } from "/@/config";
|
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import panel from "../panel/index.vue";
|
import panel from "../panel/index.vue";
|
||||||
import { emitter } from "/@/utils/mitt";
|
import { emitter } from "@/utils/mitt";
|
||||||
import { templateRef } from "@vueuse/core";
|
import { resetRouter } from "@/router";
|
||||||
import { debounce } from "/@/utils/debounce";
|
import { removeToken } from "@/utils/auth";
|
||||||
import { themeColorsType } from "../../types";
|
import { routerArrays } from "@/layout/types";
|
||||||
import { useAppStoreHook } from "/@/store/modules/app";
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
import { shadeBgColor } from "../../theme/element-plus";
|
import { useAppStoreHook } from "@/store/modules/app";
|
||||||
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
|
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
||||||
import { storageLocal, storageSession } from "/@/utils/storage";
|
import { useDataThemeChange } from "@/layout/hooks/useDataThemeChange";
|
||||||
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
import {
|
||||||
import { createNewStyle, writeNewStyle } from "../../theme/element-plus";
|
useDark,
|
||||||
import { toggleTheme } from "@zougt/vite-plugin-theme-preprocessor/dist/browser-utils";
|
debounce,
|
||||||
|
useGlobal,
|
||||||
|
storageLocal,
|
||||||
|
storageSession
|
||||||
|
} from "@pureadmin/utils";
|
||||||
|
import { toggleTheme } from "@pureadmin/theme/dist/browser-utils";
|
||||||
|
|
||||||
import dayIcon from "/@/assets/svg/day.svg?component";
|
import dayIcon from "@/assets/svg/day.svg?component";
|
||||||
import darkIcon from "/@/assets/svg/dark.svg?component";
|
import darkIcon from "@/assets/svg/dark.svg?component";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const { device } = useNav();
|
||||||
|
const { isDark } = useDark();
|
||||||
const { isSelect } = useCssModule();
|
const { isSelect } = useCssModule();
|
||||||
const body = document.documentElement as HTMLElement;
|
const { $storage } = useGlobal<GlobalPropertiesApi>();
|
||||||
const instance =
|
|
||||||
getCurrentInstance().appContext.app.config.globalProperties.$storage;
|
|
||||||
|
|
||||||
const instanceConfig =
|
const mixRef = ref();
|
||||||
getCurrentInstance().appContext.app.config.globalProperties.$config;
|
const verticalRef = ref();
|
||||||
|
const horizontalRef = ref();
|
||||||
|
|
||||||
let themeColors = ref<Array<themeColorsType>>([
|
const {
|
||||||
// 道奇蓝(默认)
|
body,
|
||||||
{ rgb: "27, 42, 71", themeColor: "default" },
|
dataTheme,
|
||||||
// 亮白色
|
layoutTheme,
|
||||||
{ rgb: "255, 255, 255", themeColor: "light" },
|
themeColors,
|
||||||
// 猩红色
|
dataThemeChange,
|
||||||
{ rgb: "245, 34, 45", themeColor: "dusk" },
|
setEpThemeColor,
|
||||||
// 橙红色
|
setLayoutThemeColor
|
||||||
{ rgb: "250, 84, 28", themeColor: "volcano" },
|
} = useDataThemeChange();
|
||||||
// 金色
|
|
||||||
{ rgb: "250, 219, 20", themeColor: "yellow" },
|
|
||||||
// 绿宝石
|
|
||||||
{ rgb: "19, 194, 194", themeColor: "mingQing" },
|
|
||||||
// 酸橙绿
|
|
||||||
{ rgb: "82, 196, 26", themeColor: "auroraGreen" },
|
|
||||||
// 深粉色
|
|
||||||
{ rgb: "235, 47, 150", themeColor: "pink" },
|
|
||||||
// 深紫罗兰色
|
|
||||||
{ rgb: "114, 46, 209", themeColor: "saucePurple" }
|
|
||||||
]);
|
|
||||||
|
|
||||||
const verticalRef = templateRef<HTMLElement | null>("verticalRef", null);
|
/* body添加layout属性,作用于src/style/sidebar.scss */
|
||||||
const horizontalRef = templateRef<HTMLElement | null>("horizontalRef", null);
|
|
||||||
|
|
||||||
let layoutTheme =
|
|
||||||
ref(storageLocal.getItem("responsive-layout")) ||
|
|
||||||
ref({
|
|
||||||
layout: instanceConfig?.Layout ?? "vertical",
|
|
||||||
theme: instanceConfig?.Theme ?? "default"
|
|
||||||
});
|
|
||||||
|
|
||||||
// body添加layout属性,作用于src/style/sidebar.scss
|
|
||||||
if (unref(layoutTheme)) {
|
if (unref(layoutTheme)) {
|
||||||
let layout = unref(layoutTheme).layout;
|
const layout = unref(layoutTheme).layout;
|
||||||
let theme = unref(layoutTheme).theme;
|
const theme = unref(layoutTheme).theme;
|
||||||
toggleTheme({
|
toggleTheme({
|
||||||
scopeName: `layout-theme-${theme}`
|
scopeName: `layout-theme-${theme}`
|
||||||
});
|
});
|
||||||
setLayoutModel(layout);
|
setLayoutModel(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 默认灵动模式
|
/** 默认灵动模式 */
|
||||||
const markValue = ref(instance.configure?.showModel ?? "smart");
|
const markValue = ref($storage.configure?.showModel ?? "smart");
|
||||||
|
|
||||||
const logoVal = ref(instance.configure?.showLogo ?? true);
|
const logoVal = ref($storage.configure?.showLogo ?? true);
|
||||||
|
|
||||||
const epThemeColor = ref(useEpThemeStoreHook().getEpThemeColor);
|
|
||||||
|
|
||||||
const settings = reactive({
|
const settings = reactive({
|
||||||
greyVal: instance.configure.grey,
|
greyVal: $storage.configure.grey,
|
||||||
weakVal: instance.configure.weak,
|
weakVal: $storage.configure.weak,
|
||||||
tabsVal: instance.configure.hideTabs,
|
tabsVal: $storage.configure.hideTabs,
|
||||||
showLogo: instance.configure.showLogo,
|
showLogo: $storage.configure.showLogo,
|
||||||
showModel: instance.configure.showModel,
|
showModel: $storage.configure.showModel,
|
||||||
multiTagsCache: instance.configure.multiTagsCache
|
multiTagsCache: $storage.configure.multiTagsCache
|
||||||
});
|
});
|
||||||
|
|
||||||
const getThemeColorStyle = computed(() => {
|
const getThemeColorStyle = computed(() => {
|
||||||
return rgb => {
|
return color => {
|
||||||
return { background: `rgb(${rgb})` };
|
return { background: color };
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
function changeStorageConfigure(key, val) {
|
/** 当网页为暗黑模式时不显示亮白色切换选项 */
|
||||||
const storageConfigure = instance.configure;
|
const showThemeColors = computed(() => {
|
||||||
|
return themeColor => {
|
||||||
|
return themeColor === "light" && isDark.value ? false : true;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
function storageConfigureChange<T>(key: string, val: T): void {
|
||||||
|
const storageConfigure = $storage.configure;
|
||||||
storageConfigure[key] = val;
|
storageConfigure[key] = val;
|
||||||
instance.configure = storageConfigure;
|
$storage.configure = storageConfigure;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) {
|
function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) {
|
||||||
const targetEl = target || document.body;
|
const targetEl = target || document.body;
|
||||||
let { className } = targetEl;
|
let { className } = targetEl;
|
||||||
className = className.replace(clsName, "");
|
className = className.replace(clsName, "").trim();
|
||||||
targetEl.className = flag ? `${className} ${clsName} ` : className;
|
targetEl.className = flag ? `${className} ${clsName} ` : className;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 灰色模式设置
|
/** 灰色模式设置 */
|
||||||
const greyChange = (value): void => {
|
const greyChange = (value): void => {
|
||||||
toggleClass(settings.greyVal, "html-grey", document.querySelector("html"));
|
toggleClass(settings.greyVal, "html-grey", document.querySelector("html"));
|
||||||
changeStorageConfigure("grey", value);
|
storageConfigureChange("grey", value);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 色弱模式设置
|
/** 色弱模式设置 */
|
||||||
const weekChange = (value): void => {
|
const weekChange = (value): void => {
|
||||||
toggleClass(
|
toggleClass(
|
||||||
settings.weakVal,
|
settings.weakVal,
|
||||||
"html-weakness",
|
"html-weakness",
|
||||||
document.querySelector("html")
|
document.querySelector("html")
|
||||||
);
|
);
|
||||||
changeStorageConfigure("weak", value);
|
storageConfigureChange("weak", value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const tagsChange = () => {
|
const tagsChange = () => {
|
||||||
let showVal = settings.tabsVal;
|
const showVal = settings.tabsVal;
|
||||||
changeStorageConfigure("hideTabs", showVal);
|
storageConfigureChange("hideTabs", showVal);
|
||||||
emitter.emit("tagViewsChange", showVal);
|
emitter.emit("tagViewsChange", showVal as unknown as string);
|
||||||
};
|
};
|
||||||
|
|
||||||
const multiTagsCacheChange = () => {
|
const multiTagsCacheChange = () => {
|
||||||
let multiTagsCache = settings.multiTagsCache;
|
const multiTagsCache = settings.multiTagsCache;
|
||||||
changeStorageConfigure("multiTagsCache", multiTagsCache);
|
storageConfigureChange("multiTagsCache", multiTagsCache);
|
||||||
useMultiTagsStoreHook().multiTagsCacheChange(multiTagsCache);
|
useMultiTagsStoreHook().multiTagsCacheChange(multiTagsCache);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 清空缓存并返回登录页
|
/** 清空缓存并返回登录页 */
|
||||||
function onReset() {
|
function onReset() {
|
||||||
toggleClass(getConfig().Grey, "html-grey", document.querySelector("html"));
|
removeToken();
|
||||||
toggleClass(
|
|
||||||
getConfig().Weak,
|
|
||||||
"html-weakness",
|
|
||||||
document.querySelector("html")
|
|
||||||
);
|
|
||||||
useMultiTagsStoreHook().handleTags("equal", [
|
|
||||||
{
|
|
||||||
path: "/welcome",
|
|
||||||
parentPath: "/",
|
|
||||||
meta: {
|
|
||||||
title: "menus.hshome",
|
|
||||||
icon: "home-filled",
|
|
||||||
i18n: true,
|
|
||||||
showLink: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
useMultiTagsStoreHook().multiTagsCacheChange(getConfig().MultiTagsCache);
|
|
||||||
useEpThemeStoreHook().setEpThemeColor(getConfig().EpThemeColor);
|
|
||||||
storageLocal.clear();
|
storageLocal.clear();
|
||||||
storageSession.clear();
|
storageSession.clear();
|
||||||
|
const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig();
|
||||||
|
useAppStoreHook().setLayout(Layout);
|
||||||
|
setEpThemeColor(EpThemeColor);
|
||||||
|
useMultiTagsStoreHook().multiTagsCacheChange(MultiTagsCache);
|
||||||
|
toggleClass(Grey, "html-grey", document.querySelector("html"));
|
||||||
|
toggleClass(Weak, "html-weakness", document.querySelector("html"));
|
||||||
router.push("/login");
|
router.push("/login");
|
||||||
|
useMultiTagsStoreHook().handleTags("equal", [...routerArrays]);
|
||||||
|
resetRouter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChange(label) {
|
function onChange(label) {
|
||||||
changeStorageConfigure("showModel", label);
|
storageConfigureChange("showModel", label);
|
||||||
emitter.emit("tagViewsShowModel", label);
|
emitter.emit("tagViewsShowModel", label);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 侧边栏Logo
|
/** 侧边栏Logo */
|
||||||
function logoChange() {
|
function logoChange() {
|
||||||
unref(logoVal)
|
unref(logoVal)
|
||||||
? changeStorageConfigure("showLogo", true)
|
? storageConfigureChange("showLogo", true)
|
||||||
: changeStorageConfigure("showLogo", false);
|
: storageConfigureChange("showLogo", false);
|
||||||
emitter.emit("logoChange", unref(logoVal));
|
emitter.emit("logoChange", unref(logoVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,20 +164,29 @@ function setFalse(Doms): any {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(instance, ({ layout }) => {
|
watch($storage, ({ layout }) => {
|
||||||
|
/* 设置wangeditorV5主题色 */
|
||||||
|
body.style.setProperty("--w-e-toolbar-active-color", layout["epThemeColor"]);
|
||||||
switch (layout["layout"]) {
|
switch (layout["layout"]) {
|
||||||
case "vertical":
|
case "vertical":
|
||||||
toggleClass(true, isSelect, unref(verticalRef));
|
toggleClass(true, isSelect, unref(verticalRef));
|
||||||
debounce(setFalse([horizontalRef]), 50);
|
debounce(setFalse([horizontalRef]), 50);
|
||||||
|
debounce(setFalse([mixRef]), 50);
|
||||||
break;
|
break;
|
||||||
case "horizontal":
|
case "horizontal":
|
||||||
toggleClass(true, isSelect, unref(horizontalRef));
|
toggleClass(true, isSelect, unref(horizontalRef));
|
||||||
debounce(setFalse([verticalRef]), 50);
|
debounce(setFalse([verticalRef]), 50);
|
||||||
|
debounce(setFalse([mixRef]), 50);
|
||||||
|
break;
|
||||||
|
case "mix":
|
||||||
|
toggleClass(true, isSelect, unref(mixRef));
|
||||||
|
debounce(setFalse([verticalRef]), 50);
|
||||||
|
debounce(setFalse([horizontalRef]), 50);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 主题色 激活选择项
|
/** 主题色 激活选择项 */
|
||||||
const getThemeColor = computed(() => {
|
const getThemeColor = computed(() => {
|
||||||
return current => {
|
return current => {
|
||||||
if (
|
if (
|
||||||
@@ -220,83 +205,27 @@ const getThemeColor = computed(() => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// 设置导航模式
|
/** 设置导航模式 */
|
||||||
function setLayoutModel(layout: string) {
|
function setLayoutModel(layout: string) {
|
||||||
layoutTheme.value.layout = layout;
|
layoutTheme.value.layout = layout;
|
||||||
window.document.body.setAttribute("layout", layout);
|
window.document.body.setAttribute("layout", layout);
|
||||||
instance.layout = {
|
$storage.layout = {
|
||||||
layout,
|
layout,
|
||||||
theme: layoutTheme.value.theme,
|
theme: layoutTheme.value.theme,
|
||||||
darkMode: instance.layout.darkMode,
|
darkMode: $storage.layout?.darkMode,
|
||||||
sidebarStatus: instance.layout.sidebarStatus,
|
sidebarStatus: $storage.layout?.sidebarStatus,
|
||||||
epThemeColor: instance.layout.epThemeColor
|
epThemeColor: $storage.layout?.epThemeColor
|
||||||
};
|
};
|
||||||
useAppStoreHook().setLayout(layout);
|
useAppStoreHook().setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 存放夜间主题切换前的导航主题色
|
/* 初始化项目配置 */
|
||||||
let tempLayoutThemeColor;
|
|
||||||
|
|
||||||
// 设置导航主题色
|
|
||||||
function setLayoutThemeColor(theme: string) {
|
|
||||||
tempLayoutThemeColor = instance.layout.theme;
|
|
||||||
layoutTheme.value.theme = theme;
|
|
||||||
toggleTheme({
|
|
||||||
scopeName: `layout-theme-${theme}`
|
|
||||||
});
|
|
||||||
instance.layout = {
|
|
||||||
layout: useAppStoreHook().layout,
|
|
||||||
theme,
|
|
||||||
darkMode: dataTheme.value,
|
|
||||||
sidebarStatus: instance.layout.sidebarStatus,
|
|
||||||
epThemeColor: instance.layout.epThemeColor
|
|
||||||
};
|
|
||||||
|
|
||||||
if (theme === "default" || theme === "light") {
|
|
||||||
setEpThemeColor(getConfig().EpThemeColor);
|
|
||||||
} else {
|
|
||||||
const colors = find(themeColors.value, { themeColor: theme });
|
|
||||||
const color = "#" + rgbHex(colors.rgb);
|
|
||||||
setEpThemeColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置ep主题色
|
|
||||||
const setEpThemeColor = (color: string) => {
|
|
||||||
writeNewStyle(createNewStyle(color));
|
|
||||||
useEpThemeStoreHook().setEpThemeColor(color);
|
|
||||||
body.style.setProperty("--el-color-primary-active", shadeBgColor(color));
|
|
||||||
};
|
|
||||||
|
|
||||||
let dataTheme = ref<boolean>(instance.layout.darkMode);
|
|
||||||
|
|
||||||
// 日间、夜间主题切换
|
|
||||||
function dataThemeChange() {
|
|
||||||
if (dataTheme.value) {
|
|
||||||
body.setAttribute("data-theme", "dark");
|
|
||||||
setLayoutThemeColor("light");
|
|
||||||
} else {
|
|
||||||
body.setAttribute("data-theme", "");
|
|
||||||
tempLayoutThemeColor && setLayoutThemeColor(tempLayoutThemeColor);
|
|
||||||
instance.layout = {
|
|
||||||
layout: useAppStoreHook().layout,
|
|
||||||
theme: instance.layout.theme,
|
|
||||||
darkMode: dataTheme.value,
|
|
||||||
sidebarStatus: instance.layout.sidebarStatus,
|
|
||||||
epThemeColor: instance.layout.epThemeColor
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//初始化项目配置
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
settings.greyVal &&
|
settings.greyVal &&
|
||||||
document.querySelector("html")?.setAttribute("class", "html-grey");
|
document.querySelector("html")?.setAttribute("class", "html-grey");
|
||||||
settings.weakVal &&
|
settings.weakVal &&
|
||||||
document.querySelector("html")?.setAttribute("class", "html-weakness");
|
document.querySelector("html")?.setAttribute("class", "html-weakness");
|
||||||
settings.tabsVal && tagsChange();
|
settings.tabsVal && tagsChange();
|
||||||
|
|
||||||
writeNewStyle(createNewStyle(epThemeColor.value));
|
|
||||||
dataThemeChange();
|
dataThemeChange();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -311,40 +240,61 @@ nextTick(() => {
|
|||||||
:active-icon="dayIcon"
|
:active-icon="dayIcon"
|
||||||
:inactive-icon="darkIcon"
|
:inactive-icon="darkIcon"
|
||||||
@change="dataThemeChange"
|
@change="dataThemeChange"
|
||||||
>
|
/>
|
||||||
</el-switch>
|
|
||||||
|
|
||||||
<el-divider>导航栏模式</el-divider>
|
<el-divider>导航栏模式</el-divider>
|
||||||
<ul class="pure-theme">
|
<ul class="pure-theme">
|
||||||
<el-tooltip class="item" content="左侧菜单模式" placement="bottom">
|
<el-tooltip class="item" content="左侧模式" placement="bottom">
|
||||||
<li
|
<li
|
||||||
:class="layoutTheme.layout === 'vertical' ? $style.isSelect : ''"
|
:class="layoutTheme.layout === 'vertical' ? $style.isSelect : ''"
|
||||||
ref="verticalRef"
|
ref="verticalRef"
|
||||||
@click="setLayoutModel('vertical')"
|
@click="setLayoutModel('vertical')"
|
||||||
>
|
>
|
||||||
<div></div>
|
<div />
|
||||||
<div></div>
|
<div />
|
||||||
</li>
|
</li>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
<el-tooltip class="item" content="顶部菜单模式" placement="bottom">
|
<el-tooltip
|
||||||
|
v-if="device !== 'mobile'"
|
||||||
|
class="item"
|
||||||
|
content="顶部模式"
|
||||||
|
placement="bottom"
|
||||||
|
>
|
||||||
<li
|
<li
|
||||||
:class="layoutTheme.layout === 'horizontal' ? $style.isSelect : ''"
|
:class="layoutTheme.layout === 'horizontal' ? $style.isSelect : ''"
|
||||||
ref="horizontalRef"
|
ref="horizontalRef"
|
||||||
@click="setLayoutModel('horizontal')"
|
@click="setLayoutModel('horizontal')"
|
||||||
>
|
>
|
||||||
<div></div>
|
<div />
|
||||||
<div></div>
|
<div />
|
||||||
|
</li>
|
||||||
|
</el-tooltip>
|
||||||
|
|
||||||
|
<el-tooltip
|
||||||
|
v-if="device !== 'mobile'"
|
||||||
|
class="item"
|
||||||
|
content="混合模式"
|
||||||
|
placement="bottom"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
:class="layoutTheme.layout === 'mix' ? $style.isSelect : ''"
|
||||||
|
ref="mixRef"
|
||||||
|
@click="setLayoutModel('mix')"
|
||||||
|
>
|
||||||
|
<div />
|
||||||
|
<div />
|
||||||
</li>
|
</li>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<el-divider v-show="!dataTheme">主题色</el-divider>
|
<el-divider>主题色</el-divider>
|
||||||
<ul class="theme-color" v-show="!dataTheme">
|
<ul class="theme-color">
|
||||||
<li
|
<li
|
||||||
v-for="(item, index) in themeColors"
|
v-for="(item, index) in themeColors"
|
||||||
:key="index"
|
:key="index"
|
||||||
:style="getThemeColorStyle(item.rgb)"
|
v-show="showThemeColors(item.themeColor)"
|
||||||
|
:style="getThemeColorStyle(item.color)"
|
||||||
@click="setLayoutThemeColor(item.themeColor)"
|
@click="setLayoutThemeColor(item.themeColor)"
|
||||||
>
|
>
|
||||||
<el-icon
|
<el-icon
|
||||||
@@ -359,8 +309,8 @@ nextTick(() => {
|
|||||||
|
|
||||||
<el-divider>界面显示</el-divider>
|
<el-divider>界面显示</el-divider>
|
||||||
<ul class="setting">
|
<ul class="setting">
|
||||||
<li v-show="!dataTheme">
|
<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
|
||||||
@@ -368,11 +318,10 @@ nextTick(() => {
|
|||||||
active-text="开"
|
active-text="开"
|
||||||
inactive-text="关"
|
inactive-text="关"
|
||||||
@change="greyChange"
|
@change="greyChange"
|
||||||
>
|
/>
|
||||||
</el-switch>
|
|
||||||
</li>
|
</li>
|
||||||
<li v-show="!dataTheme">
|
<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
|
||||||
@@ -380,11 +329,10 @@ nextTick(() => {
|
|||||||
active-text="开"
|
active-text="开"
|
||||||
inactive-text="关"
|
inactive-text="关"
|
||||||
@change="weekChange"
|
@change="weekChange"
|
||||||
>
|
/>
|
||||||
</el-switch>
|
|
||||||
</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
|
||||||
@@ -392,11 +340,10 @@ nextTick(() => {
|
|||||||
active-text="开"
|
active-text="开"
|
||||||
inactive-text="关"
|
inactive-text="关"
|
||||||
@change="tagsChange"
|
@change="tagsChange"
|
||||||
>
|
/>
|
||||||
</el-switch>
|
|
||||||
</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
|
||||||
@@ -406,11 +353,10 @@ nextTick(() => {
|
|||||||
active-text="开"
|
active-text="开"
|
||||||
inactive-text="关"
|
inactive-text="关"
|
||||||
@change="logoChange"
|
@change="logoChange"
|
||||||
>
|
/>
|
||||||
</el-switch>
|
|
||||||
</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
|
||||||
@@ -418,12 +364,11 @@ nextTick(() => {
|
|||||||
active-text="开"
|
active-text="开"
|
||||||
inactive-text="关"
|
inactive-text="关"
|
||||||
@change="multiTagsCacheChange"
|
@change="multiTagsCacheChange"
|
||||||
>
|
/>
|
||||||
</el-switch>
|
|
||||||
</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>
|
||||||
@@ -437,9 +382,14 @@ nextTick(() => {
|
|||||||
style="width: 90%; margin: 24px 15px"
|
style="width: 90%; margin: 24px 15px"
|
||||||
@click="onReset"
|
@click="onReset"
|
||||||
>
|
>
|
||||||
<i class="fa fa-sign-out"></i>
|
<IconifyIconOffline
|
||||||
清空缓存并返回登录页</el-button
|
icon="fa-sign-out"
|
||||||
>
|
width="15"
|
||||||
|
height="15"
|
||||||
|
style="margin-right: 4px"
|
||||||
|
/>
|
||||||
|
清空缓存并返回登录页
|
||||||
|
</el-button>
|
||||||
</panel>
|
</panel>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -477,15 +427,14 @@ nextTick(() => {
|
|||||||
.pure-theme {
|
.pure-theme {
|
||||||
margin-top: 25px;
|
margin-top: 25px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100px;
|
height: 50px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
|
|
||||||
li {
|
li {
|
||||||
margin: 10px;
|
width: 18%;
|
||||||
width: 36%;
|
height: 45px;
|
||||||
height: 70px;
|
|
||||||
background: #f0f2f5;
|
background: #f0f2f5;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -523,6 +472,27 @@ nextTick(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:nth-child(3) {
|
||||||
|
div {
|
||||||
|
&:nth-child(1) {
|
||||||
|
width: 100%;
|
||||||
|
height: 30%;
|
||||||
|
background: #1b2a47;
|
||||||
|
box-shadow: 0 0 1px #888;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:nth-child(2) {
|
||||||
|
width: 30%;
|
||||||
|
height: 70%;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 0 1px #888;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,36 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from "vue";
|
import { isEqual } from "@pureadmin/utils";
|
||||||
import { isEqual } from "lodash-es";
|
import { ref, watch, onMounted, toRaw } from "vue";
|
||||||
import { transformI18n } from "/@/plugins/i18n";
|
import { getParentPaths, findRouteByPath } from "@/router/utils";
|
||||||
import { getParentPaths, findRouteByPath } from "/@/router/utils";
|
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
||||||
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
|
||||||
import { useRoute, useRouter, RouteLocationMatched } from "vue-router";
|
import { useRoute, useRouter, RouteLocationMatched } from "vue-router";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const levelList = ref([]);
|
const levelList = ref([]);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const routes = router.options.routes;
|
const routes: any = router.options.routes;
|
||||||
const multiTags = useMultiTagsStoreHook().multiTags;
|
const multiTags: any = useMultiTagsStoreHook().multiTags;
|
||||||
|
|
||||||
const isDashboard = (route: RouteLocationMatched): boolean | string => {
|
const isDashboard = (route: RouteLocationMatched): boolean | string => {
|
||||||
const name = route && (route.name as string);
|
const name = route && (route.name as string);
|
||||||
if (!name) {
|
if (!name) return false;
|
||||||
return false;
|
return name.trim().toLocaleLowerCase() === "Welcome".toLocaleLowerCase();
|
||||||
}
|
|
||||||
return name.trim().toLocaleLowerCase() === "welcome".toLocaleLowerCase();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getBreadcrumb = (): void => {
|
const getBreadcrumb = (): void => {
|
||||||
// 当前路由信息
|
// 当前路由信息
|
||||||
let currentRoute;
|
let currentRoute;
|
||||||
|
|
||||||
if (Object.keys(route.query).length > 0) {
|
if (Object.keys(route.query).length > 0) {
|
||||||
multiTags.forEach(item => {
|
multiTags.forEach(item => {
|
||||||
if (isEqual(route.query, item?.query)) {
|
if (isEqual(route.query, item?.query)) {
|
||||||
currentRoute = item;
|
currentRoute = toRaw(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (Object.keys(route.params).length > 0) {
|
||||||
|
multiTags.forEach(item => {
|
||||||
|
if (isEqual(route.params, item?.params)) {
|
||||||
|
currentRoute = toRaw(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -38,91 +42,66 @@ const getBreadcrumb = (): void => {
|
|||||||
let matched = [];
|
let matched = [];
|
||||||
// 获取每个父级路径对应的路由信息
|
// 获取每个父级路径对应的路由信息
|
||||||
parentRoutes.forEach(path => {
|
parentRoutes.forEach(path => {
|
||||||
if (path !== "/") {
|
if (path !== "/") matched.push(findRouteByPath(path, routes));
|
||||||
matched.push(findRouteByPath(path, routes));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
if (router.currentRoute.value.meta?.refreshRedirect) {
|
|
||||||
matched.unshift(
|
|
||||||
findRouteByPath(
|
|
||||||
router.currentRoute.value.meta.refreshRedirect as string,
|
|
||||||
routes
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// 过滤与子级相同标题的父级路由
|
|
||||||
matched = matched.filter(item => {
|
|
||||||
return !item.redirect || (item.redirect && item.children.length !== 1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (currentRoute?.path !== "/welcome") {
|
|
||||||
matched.push(currentRoute);
|
|
||||||
}
|
|
||||||
|
|
||||||
const first = matched[0];
|
if (currentRoute?.path !== "/welcome") matched.push(currentRoute);
|
||||||
if (!isDashboard(first)) {
|
|
||||||
|
if (!isDashboard(matched[0])) {
|
||||||
matched = [
|
matched = [
|
||||||
{
|
{
|
||||||
path: "/welcome",
|
path: "/welcome",
|
||||||
parentPath: "/",
|
parentPath: "/",
|
||||||
meta: { title: "menus.hshome", i18n: true }
|
meta: { title: "首页" }
|
||||||
} as unknown as RouteLocationMatched
|
} as unknown as RouteLocationMatched
|
||||||
].concat(matched);
|
].concat(matched);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matched.forEach((item, index) => {
|
||||||
|
if (currentRoute?.query || currentRoute?.params) return;
|
||||||
|
if (item?.children) {
|
||||||
|
item.children.forEach(v => {
|
||||||
|
if (v?.meta?.title === item?.meta?.title) {
|
||||||
|
matched.splice(index, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
levelList.value = matched.filter(
|
levelList.value = matched.filter(
|
||||||
item => item?.meta && item?.meta.title !== false
|
item => item?.meta && item?.meta.title !== false
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
getBreadcrumb();
|
const handleLink = (item: RouteLocationMatched): void => {
|
||||||
|
const { redirect, path } = item;
|
||||||
|
if (redirect) {
|
||||||
|
router.push(redirect as any);
|
||||||
|
} else {
|
||||||
|
router.push(path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getBreadcrumb();
|
||||||
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => route.path,
|
() => route.path,
|
||||||
() => getBreadcrumb()
|
() => {
|
||||||
);
|
getBreadcrumb();
|
||||||
|
|
||||||
watch(
|
|
||||||
() => route.query,
|
|
||||||
() => getBreadcrumb()
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleLink = (item: RouteLocationMatched): any => {
|
|
||||||
const { redirect, path } = item;
|
|
||||||
if (redirect) {
|
|
||||||
router.push(redirect.toString());
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
router.push(path);
|
);
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-breadcrumb class="app-breadcrumb" separator="/">
|
<el-breadcrumb class="!leading-[50px] select-none" separator="/">
|
||||||
<transition-group appear name="breadcrumb">
|
<transition-group appear name="breadcrumb">
|
||||||
<el-breadcrumb-item v-for="(item, index) in levelList" :key="item.path">
|
<el-breadcrumb-item v-for="item in levelList" :key="item.path">
|
||||||
<span
|
<a @click.prevent="handleLink(item)">
|
||||||
v-if="item.redirect === 'noRedirect' || index == levelList.length - 1"
|
{{ item.meta.title }}
|
||||||
class="no-redirect"
|
|
||||||
>{{ transformI18n(item.meta.title, item.meta.i18n) }}</span
|
|
||||||
>
|
|
||||||
<a v-else @click.prevent="handleLink(item)">
|
|
||||||
{{ transformI18n(item.meta.title, item.meta.i18n) }}
|
|
||||||
</a>
|
</a>
|
||||||
</el-breadcrumb-item>
|
</el-breadcrumb-item>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</el-breadcrumb>
|
</el-breadcrumb>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.app-breadcrumb.el-breadcrumb {
|
|
||||||
display: inline-block;
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: 50px;
|
|
||||||
|
|
||||||
.no-redirect {
|
|
||||||
color: #97a8be;
|
|
||||||
cursor: text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { ref } from "vue";
|
|
||||||
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
|
|
||||||
export interface Props {
|
|
||||||
isActive: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
|
||||||
isActive: false
|
|
||||||
});
|
|
||||||
|
|
||||||
const fillColor = ref<string>("");
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(e: "toggleClick"): void;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const toggleClick = () => {
|
|
||||||
emit("toggleClick");
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div
|
|
||||||
:class="classes.container"
|
|
||||||
:title="props.isActive ? '点击折叠' : '点击展开'"
|
|
||||||
@click="toggleClick"
|
|
||||||
@mouseenter="fillColor = useEpThemeStoreHook().epThemeColor"
|
|
||||||
@mouseleave="fillColor = ''"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
:fill="fillColor"
|
|
||||||
:class="['hamburger', props.isActive ? 'is-active' : '']"
|
|
||||||
viewBox="0 0 1024 1024"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="64"
|
|
||||||
height="64"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 0 0 0-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0 0 14.4 7z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style module="classes" scoped>
|
|
||||||
.container {
|
|
||||||
padding: 0 15px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.hamburger {
|
|
||||||
display: inline-block;
|
|
||||||
vertical-align: middle;
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.is-active {
|
|
||||||
transform: rotate(180deg);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,144 +1,50 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import Search from "../search/index.vue";
|
||||||
computed,
|
|
||||||
unref,
|
|
||||||
watch,
|
|
||||||
nextTick,
|
|
||||||
onMounted,
|
|
||||||
getCurrentInstance
|
|
||||||
} from "vue";
|
|
||||||
import { useI18n } from "vue-i18n";
|
|
||||||
import { emitter } from "/@/utils/mitt";
|
|
||||||
import Notice from "../notice/index.vue";
|
import Notice from "../notice/index.vue";
|
||||||
import { templateRef } from "@vueuse/core";
|
import { ref, watch, nextTick } from "vue";
|
||||||
import SidebarItem from "./sidebarItem.vue";
|
import SidebarItem from "./sidebarItem.vue";
|
||||||
import avatars from "/@/assets/avatars.jpg";
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
import { algorithm } from "/@/utils/algorithm";
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||||
import screenfull from "../screenfull/index.vue";
|
|
||||||
import { useRoute, useRouter } from "vue-router";
|
|
||||||
import { storageSession } from "/@/utils/storage";
|
|
||||||
import Icon from "/@/components/ReIcon/src/Icon.vue";
|
|
||||||
import { deviceDetection } from "/@/utils/deviceDetection";
|
|
||||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
|
||||||
import globalization from "/@/assets/svg/globalization.svg?component";
|
|
||||||
|
|
||||||
const instance =
|
const menuRef = ref();
|
||||||
getCurrentInstance().appContext.config.globalProperties.$storage;
|
|
||||||
|
|
||||||
const title =
|
const {
|
||||||
getCurrentInstance().appContext.config.globalProperties.$config?.Title;
|
route,
|
||||||
|
title,
|
||||||
|
routers,
|
||||||
|
logout,
|
||||||
|
backHome,
|
||||||
|
onPanel,
|
||||||
|
menuSelect,
|
||||||
|
username,
|
||||||
|
avatarsStyle
|
||||||
|
} = useNav();
|
||||||
|
|
||||||
const menuRef = templateRef<ElRef | null>("menu", null);
|
nextTick(() => {
|
||||||
const route = useRoute();
|
menuRef.value?.handleResize();
|
||||||
const router = useRouter();
|
|
||||||
const routers = useRouter().options.routes;
|
|
||||||
let usename = storageSession.getItem("info")?.username;
|
|
||||||
const { locale, t } = useI18n();
|
|
||||||
|
|
||||||
const getDropdownItemStyle = computed(() => {
|
|
||||||
return t => {
|
|
||||||
return {
|
|
||||||
background: locale.value === t ? "#1b2a47" : "",
|
|
||||||
color: locale.value === t ? "#f4f4f5" : "#000"
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => locale.value,
|
() => route.path,
|
||||||
() => {
|
() => {
|
||||||
//@ts-ignore
|
menuSelect(route.path, routers);
|
||||||
// 动态title
|
|
||||||
document.title = t(unref(route.meta.title));
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// 退出登录
|
|
||||||
const logout = (): void => {
|
|
||||||
storageSession.removeItem("info");
|
|
||||||
router.push("/login");
|
|
||||||
};
|
|
||||||
|
|
||||||
function onPanel() {
|
|
||||||
emitter.emit("openPanel");
|
|
||||||
}
|
|
||||||
|
|
||||||
const activeMenu = computed((): string => {
|
|
||||||
const { meta, path } = route;
|
|
||||||
if (meta.activeMenu) {
|
|
||||||
// @ts-ignore
|
|
||||||
return meta.activeMenu;
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
});
|
|
||||||
|
|
||||||
const menuSelect = (indexPath: string): void => {
|
|
||||||
let parentPath = "";
|
|
||||||
let parentPathIndex = indexPath.lastIndexOf("/");
|
|
||||||
if (parentPathIndex > 0) {
|
|
||||||
parentPath = indexPath.slice(0, parentPathIndex);
|
|
||||||
}
|
|
||||||
// 找到当前路由的信息
|
|
||||||
function findCurrentRoute(routes) {
|
|
||||||
return routes.map(item => {
|
|
||||||
if (item.path === indexPath) {
|
|
||||||
// 切换左侧菜单 通知标签页
|
|
||||||
emitter.emit("changLayoutRoute", {
|
|
||||||
indexPath,
|
|
||||||
parentPath
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (item.children) findCurrentRoute(item.children);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
findCurrentRoute(algorithm.increaseIndexes(routers));
|
|
||||||
};
|
|
||||||
|
|
||||||
function backHome() {
|
|
||||||
router.push("/welcome");
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleResize() {
|
|
||||||
// @ts-ignore
|
|
||||||
menuRef.value.handleResize();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 简体中文
|
|
||||||
function translationCh() {
|
|
||||||
instance.locale = { locale: "zh" };
|
|
||||||
locale.value = "zh";
|
|
||||||
handleResize();
|
|
||||||
}
|
|
||||||
|
|
||||||
// English
|
|
||||||
function translationEn() {
|
|
||||||
instance.locale = { locale: "en" };
|
|
||||||
locale.value = "en";
|
|
||||||
handleResize();
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
nextTick(() => {
|
|
||||||
handleResize();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="horizontal-header">
|
<div class="horizontal-header">
|
||||||
<div class="horizontal-header-left" @click="backHome">
|
<div class="horizontal-header-left" @click="backHome">
|
||||||
<Icon svg :width="35" :height="35" content="team-iconlogo" />
|
<FontIcon icon="team-iconlogo" svg style="width: 35px; height: 35px" />
|
||||||
<h4>{{ title }}</h4>
|
<h4>{{ title }}</h4>
|
||||||
</div>
|
</div>
|
||||||
<el-menu
|
<el-menu
|
||||||
ref="menu"
|
|
||||||
:default-active="activeMenu"
|
|
||||||
unique-opened
|
|
||||||
router
|
router
|
||||||
class="horizontal-header-menu"
|
ref="menuRef"
|
||||||
mode="horizontal"
|
mode="horizontal"
|
||||||
@select="menuSelect"
|
class="horizontal-header-menu"
|
||||||
|
:default-active="route.path"
|
||||||
|
@select="indexPath => menuSelect(indexPath, routers)"
|
||||||
>
|
>
|
||||||
<sidebar-item
|
<sidebar-item
|
||||||
v-for="route in usePermissionStoreHook().wholeMenus"
|
v-for="route in usePermissionStoreHook().wholeMenus"
|
||||||
@@ -148,94 +54,50 @@ onMounted(() => {
|
|||||||
/>
|
/>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
<div class="horizontal-header-right">
|
<div class="horizontal-header-right">
|
||||||
|
<!-- 菜单搜索 -->
|
||||||
|
<Search />
|
||||||
<!-- 通知 -->
|
<!-- 通知 -->
|
||||||
<Notice id="header-notice" />
|
<Notice id="header-notice" />
|
||||||
<!-- 全屏 -->
|
<!-- 退出登录 -->
|
||||||
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
|
|
||||||
<!-- 国际化 -->
|
|
||||||
<el-dropdown id="header-translation" trigger="click">
|
|
||||||
<globalization />
|
|
||||||
<template #dropdown>
|
|
||||||
<el-dropdown-menu class="translation">
|
|
||||||
<el-dropdown-item
|
|
||||||
:style="getDropdownItemStyle('zh')"
|
|
||||||
@click="translationCh"
|
|
||||||
><el-icon class="check-zh" v-show="locale === 'zh'"
|
|
||||||
><IconifyIconOffline icon="check" /></el-icon
|
|
||||||
>简体中文</el-dropdown-item
|
|
||||||
>
|
|
||||||
<el-dropdown-item
|
|
||||||
:style="getDropdownItemStyle('en')"
|
|
||||||
@click="translationEn"
|
|
||||||
><el-icon class="check-en" v-show="locale === 'en'"
|
|
||||||
><IconifyIconOffline icon="check" /></el-icon
|
|
||||||
>English</el-dropdown-item
|
|
||||||
>
|
|
||||||
</el-dropdown-menu>
|
|
||||||
</template>
|
|
||||||
</el-dropdown>
|
|
||||||
<!-- 退出登陆 -->
|
|
||||||
<el-dropdown trigger="click">
|
<el-dropdown trigger="click">
|
||||||
<span class="el-dropdown-link">
|
<span class="el-dropdown-link navbar-bg-hover">
|
||||||
<img :src="avatars" />
|
<img
|
||||||
<p>{{ usename }}</p>
|
src="https://avatars.githubusercontent.com/u/44761321?v=4"
|
||||||
|
:style="avatarsStyle"
|
||||||
|
/>
|
||||||
|
<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">
|
||||||
<el-dropdown-item @click="logout">
|
<el-dropdown-item @click="logout">
|
||||||
<i class="ri-logout-circle-r-line"></i
|
<IconifyIconOffline
|
||||||
>{{ $t("buttons.hsLoginOut") }}</el-dropdown-item
|
icon="logout-circle-r-line"
|
||||||
>
|
style="margin: 5px"
|
||||||
|
/>
|
||||||
|
退出系统
|
||||||
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
<el-icon
|
<span
|
||||||
class="el-icon-setting"
|
class="set-icon navbar-bg-hover"
|
||||||
:title="$t('buttons.hssystemSet')"
|
title="打开项目配置"
|
||||||
@click="onPanel"
|
@click="onPanel"
|
||||||
>
|
>
|
||||||
<IconifyIconOffline icon="setting" />
|
<IconifyIconOffline icon="setting" />
|
||||||
</el-icon>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.translation {
|
|
||||||
.el-dropdown-menu__item {
|
|
||||||
padding: 5px 40px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-dropdown-menu__item:focus,
|
|
||||||
.el-dropdown-menu__item:not(.is-disabled):hover {
|
|
||||||
color: #606266;
|
|
||||||
background: #f0f0f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.check-zh {
|
|
||||||
position: absolute;
|
|
||||||
left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.check-en {
|
|
||||||
position: absolute;
|
|
||||||
left: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.logout {
|
.logout {
|
||||||
max-width: 120px;
|
max-width: 120px;
|
||||||
|
|
||||||
.el-dropdown-menu__item {
|
::v-deep(.el-dropdown-menu__item) {
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-dropdown-menu__item:focus,
|
|
||||||
.el-dropdown-menu__item:not(.is-disabled):hover {
|
|
||||||
color: #606266;
|
|
||||||
background: #f0f0f0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
47
src/layout/components/sidebar/leftCollapse.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useDark } from "@pureadmin/utils";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
isActive: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
isActive: false
|
||||||
|
});
|
||||||
|
const { isDark } = useDark();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: "toggleClick"): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const toggleClick = () => {
|
||||||
|
emit("toggleClick");
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="container">
|
||||||
|
<el-tooltip
|
||||||
|
placement="right"
|
||||||
|
:effect="isDark ? 'dark' : 'light'"
|
||||||
|
:content="props.isActive ? '点击折叠' : '点击展开'"
|
||||||
|
>
|
||||||
|
<IconifyIconOffline
|
||||||
|
:icon="props.isActive ? 'menu-fold' : 'menu-unfold'"
|
||||||
|
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"
|
||||||
|
/>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.container {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
box-shadow: 0 0 6px -2px var(--el-color-primary);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getCurrentInstance } from "vue";
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
import Icon from "/@/components/ReIcon/src/Icon.vue";
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
collapse: Boolean
|
collapse: Boolean
|
||||||
});
|
});
|
||||||
|
|
||||||
const title =
|
const { title } = useNav();
|
||||||
getCurrentInstance().appContext.config.globalProperties.$config?.Title;
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="sidebar-logo-container" :class="{ collapse: props.collapse }">
|
<div class="sidebar-logo-container" :class="{ collapses: props.collapse }">
|
||||||
<transition name="sidebarLogoFade">
|
<transition name="sidebarLogoFade">
|
||||||
<router-link
|
<router-link
|
||||||
v-if="props.collapse"
|
v-if="props.collapse"
|
||||||
@@ -19,7 +18,7 @@ const title =
|
|||||||
class="sidebar-logo-link"
|
class="sidebar-logo-link"
|
||||||
to="/"
|
to="/"
|
||||||
>
|
>
|
||||||
<Icon svg :width="35" :height="35" content="team-iconlogo" />
|
<FontIcon icon="team-iconlogo" svg style="width: 35px; height: 35px" />
|
||||||
<span class="sidebar-title">{{ title }}</span>
|
<span class="sidebar-title">{{ title }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
<router-link
|
<router-link
|
||||||
@@ -29,7 +28,7 @@ const title =
|
|||||||
class="sidebar-logo-link"
|
class="sidebar-logo-link"
|
||||||
to="/"
|
to="/"
|
||||||
>
|
>
|
||||||
<Icon svg :width="35" :height="35" content="team-iconlogo" />
|
<FontIcon icon="team-iconlogo" svg style="width: 35px; height: 35px" />
|
||||||
<span class="sidebar-title">{{ title }}</span>
|
<span class="sidebar-title">{{ title }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</transition>
|
</transition>
|
||||||
@@ -52,6 +51,12 @@ const title =
|
|||||||
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;
|
||||||
@@ -60,7 +65,7 @@ const title =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.collapse {
|
.collapses {
|
||||||
.sidebar-logo {
|
.sidebar-logo {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
134
src/layout/components/sidebar/mixNav.vue
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import Search from "../search/index.vue";
|
||||||
|
import Notice from "../notice/index.vue";
|
||||||
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
|
import { ref, toRaw, watch, onMounted, nextTick } from "vue";
|
||||||
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
|
import { getParentPaths, findRouteByPath } from "@/router/utils";
|
||||||
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||||
|
|
||||||
|
const menuRef = ref();
|
||||||
|
const defaultActive = ref(null);
|
||||||
|
|
||||||
|
const {
|
||||||
|
route,
|
||||||
|
device,
|
||||||
|
routers,
|
||||||
|
logout,
|
||||||
|
onPanel,
|
||||||
|
menuSelect,
|
||||||
|
resolvePath,
|
||||||
|
username,
|
||||||
|
avatarsStyle
|
||||||
|
} = useNav();
|
||||||
|
|
||||||
|
function getDefaultActive(routePath) {
|
||||||
|
const wholeMenus = usePermissionStoreHook().wholeMenus;
|
||||||
|
/** 当前路由的父级路径 */
|
||||||
|
const parentRoutes = getParentPaths(routePath, wholeMenus)[0];
|
||||||
|
defaultActive.value = findRouteByPath(
|
||||||
|
parentRoutes,
|
||||||
|
wholeMenus
|
||||||
|
)?.children[0]?.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getDefaultActive(route.path);
|
||||||
|
});
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
menuRef.value?.handleResize();
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [route.path, usePermissionStoreHook().wholeMenus],
|
||||||
|
() => {
|
||||||
|
getDefaultActive(route.path);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div v-if="device !== 'mobile'" class="horizontal-header">
|
||||||
|
<el-menu
|
||||||
|
router
|
||||||
|
ref="menuRef"
|
||||||
|
mode="horizontal"
|
||||||
|
class="horizontal-header-menu"
|
||||||
|
:default-active="defaultActive"
|
||||||
|
@select="indexPath => menuSelect(indexPath, routers)"
|
||||||
|
>
|
||||||
|
<el-menu-item
|
||||||
|
v-for="route in usePermissionStoreHook().wholeMenus"
|
||||||
|
:key="route.path"
|
||||||
|
:index="resolvePath(route) || route.redirect"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<div
|
||||||
|
v-if="toRaw(route.meta.icon)"
|
||||||
|
:class="['sub-menu-icon', route.meta.icon]"
|
||||||
|
>
|
||||||
|
<component
|
||||||
|
:is="useRenderIcon(route.meta && toRaw(route.meta.icon))"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<span class="select-none">{{ route.meta.title }}</span>
|
||||||
|
<FontIcon
|
||||||
|
v-if="route.meta.extraIcon"
|
||||||
|
width="30px"
|
||||||
|
height="30px"
|
||||||
|
style="position: absolute; right: 10px"
|
||||||
|
:icon="route.meta.extraIcon.name"
|
||||||
|
:svg="route.meta.extraIcon.svg ? true : false"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-menu-item>
|
||||||
|
</el-menu>
|
||||||
|
<div class="horizontal-header-right">
|
||||||
|
<!-- 菜单搜索 -->
|
||||||
|
<Search />
|
||||||
|
<!-- 通知 -->
|
||||||
|
<Notice id="header-notice" />
|
||||||
|
<!-- 退出登录 -->
|
||||||
|
<el-dropdown trigger="click">
|
||||||
|
<span class="el-dropdown-link navbar-bg-hover select-none">
|
||||||
|
<img
|
||||||
|
src="https://avatars.githubusercontent.com/u/44761321?v=4"
|
||||||
|
:style="avatarsStyle"
|
||||||
|
/>
|
||||||
|
<p v-if="username" class="dark:text-white">{{ username }}</p>
|
||||||
|
</span>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu class="logout">
|
||||||
|
<el-dropdown-item @click="logout">
|
||||||
|
<IconifyIconOffline
|
||||||
|
icon="logout-circle-r-line"
|
||||||
|
style="margin: 5px"
|
||||||
|
/>
|
||||||
|
退出系统
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
<span
|
||||||
|
class="set-icon navbar-bg-hover"
|
||||||
|
title="打开项目配置"
|
||||||
|
@click="onPanel"
|
||||||
|
>
|
||||||
|
<IconifyIconOffline icon="setting" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.logout {
|
||||||
|
max-width: 120px;
|
||||||
|
|
||||||
|
::v-deep(.el-dropdown-menu__item) {
|
||||||
|
min-width: 100%;
|
||||||
|
display: inline-flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,22 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
|
||||||
ref,
|
|
||||||
PropType,
|
|
||||||
nextTick,
|
|
||||||
computed,
|
|
||||||
CSSProperties,
|
|
||||||
getCurrentInstance
|
|
||||||
} from "vue";
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { getConfig } from "@/config";
|
||||||
import { childrenType } from "../../types";
|
import { childrenType } from "../../types";
|
||||||
import { transformI18n } from "/@/plugins/i18n";
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
import { findIconReg } from "/@/components/ReIcon";
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
import Icon from "/@/components/ReIcon/src/Icon.vue";
|
import { ref, toRaw, PropType, nextTick, computed, CSSProperties } from "vue";
|
||||||
import { useAppStoreHook } from "/@/store/modules/app";
|
|
||||||
|
|
||||||
const instance = getCurrentInstance().appContext.app.config.globalProperties;
|
const { layout, isCollapse } = useNav();
|
||||||
const menuMode = instance.$storage.layout?.layout === "vertical";
|
|
||||||
const pureApp = useAppStoreHook();
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
item: {
|
item: {
|
||||||
@@ -32,6 +22,19 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getExtraIconStyle = computed((): CSSProperties => {
|
||||||
|
if (!isCollapse.value) {
|
||||||
|
return {
|
||||||
|
position: "absolute",
|
||||||
|
right: "10px"
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
position: "static"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const getNoDropdownStyle = computed((): CSSProperties => {
|
const getNoDropdownStyle = computed((): CSSProperties => {
|
||||||
return {
|
return {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
@@ -41,7 +44,7 @@ const getNoDropdownStyle = computed((): CSSProperties => {
|
|||||||
|
|
||||||
const getDivStyle = computed((): CSSProperties => {
|
const getDivStyle = computed((): CSSProperties => {
|
||||||
return {
|
return {
|
||||||
width: pureApp.sidebar.opened ? "" : "100%",
|
width: !isCollapse.value ? "" : "100%",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
@@ -49,9 +52,8 @@ const getDivStyle = computed((): CSSProperties => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const getMenuTextStyle = computed((): CSSProperties => {
|
const getMenuTextStyle = computed(() => {
|
||||||
return {
|
return {
|
||||||
width: pureApp.sidebar.opened ? "125px" : "",
|
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
outline: "none"
|
outline: "none"
|
||||||
@@ -60,20 +62,24 @@ const getMenuTextStyle = computed((): CSSProperties => {
|
|||||||
|
|
||||||
const getSubTextStyle = computed((): CSSProperties => {
|
const getSubTextStyle = computed((): CSSProperties => {
|
||||||
return {
|
return {
|
||||||
width: pureApp.sidebar.opened ? "125px" : "",
|
width: !isCollapse.value ? "210px" : "",
|
||||||
display: "inline-block",
|
display: "inline-block",
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
textOverflow: "ellipsis"
|
textOverflow: "ellipsis"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const getSpanStyle = computed((): CSSProperties => {
|
const getSpanStyle = computed(() => {
|
||||||
return {
|
return {
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
textOverflow: "ellipsis"
|
textOverflow: "ellipsis"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const expandCloseIcon = computed(() => {
|
||||||
|
return getConfig()?.MenuArrowIconNoTransition ? "expand-close-icon" : "";
|
||||||
|
});
|
||||||
|
|
||||||
const onlyOneChild: childrenType = ref(null);
|
const onlyOneChild: childrenType = ref(null);
|
||||||
// 存放菜单是否存在showTooltip属性标识
|
// 存放菜单是否存在showTooltip属性标识
|
||||||
const hoverMenuMap = new WeakMap();
|
const hoverMenuMap = new WeakMap();
|
||||||
@@ -93,7 +99,6 @@ function hoverMenu(key) {
|
|||||||
: Object.assign(key, {
|
: Object.assign(key, {
|
||||||
showTooltip: false
|
showTooltip: false
|
||||||
});
|
});
|
||||||
|
|
||||||
hoverMenuMap.set(key, true);
|
hoverMenuMap.set(key, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -107,6 +112,10 @@ function hasOneShowingChild(
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (showingChildren[0]?.meta?.showParent) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (showingChildren.length === 1) {
|
if (showingChildren.length === 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -120,8 +129,8 @@ function hasOneShowingChild(
|
|||||||
|
|
||||||
function resolvePath(routePath) {
|
function resolvePath(routePath) {
|
||||||
const httpReg = /^http(s?):\/\//;
|
const httpReg = /^http(s?):\/\//;
|
||||||
if (httpReg.test(routePath)) {
|
if (httpReg.test(routePath) || httpReg.test(props.basePath)) {
|
||||||
return props.basePath + "/" + routePath;
|
return routePath || props.basePath;
|
||||||
} else {
|
} else {
|
||||||
return path.resolve(props.basePath, routePath);
|
return path.resolve(props.basePath, routePath);
|
||||||
}
|
}
|
||||||
@@ -140,21 +149,43 @@ function resolvePath(routePath) {
|
|||||||
:class="{ 'submenu-title-noDropdown': !isNest }"
|
:class="{ 'submenu-title-noDropdown': !isNest }"
|
||||||
:style="getNoDropdownStyle"
|
:style="getNoDropdownStyle"
|
||||||
>
|
>
|
||||||
<el-icon v-show="props.item.meta.icon">
|
<div class="sub-menu-icon" v-if="toRaw(props.item.meta.icon)">
|
||||||
<component
|
<component
|
||||||
:is="
|
:is="
|
||||||
findIconReg(
|
useRenderIcon(
|
||||||
onlyOneChild.meta.icon ||
|
toRaw(onlyOneChild.meta.icon) ||
|
||||||
(props.item.meta && props.item.meta.icon)
|
(props.item.meta && toRaw(props.item.meta.icon))
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
></component>
|
/>
|
||||||
</el-icon>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
isCollapse &&
|
||||||
|
layout === 'vertical' &&
|
||||||
|
props.item?.pathList?.length === 1
|
||||||
|
"
|
||||||
|
:style="getDivStyle"
|
||||||
|
>
|
||||||
|
<span :style="getMenuTextStyle">
|
||||||
|
{{ onlyOneChild.meta.title }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
isCollapse && layout === 'mix' && props.item?.pathList?.length === 2
|
||||||
|
"
|
||||||
|
:style="getDivStyle"
|
||||||
|
>
|
||||||
|
<span :style="getMenuTextStyle">
|
||||||
|
{{ onlyOneChild.meta.title }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div :style="getDivStyle">
|
<div :style="getDivStyle">
|
||||||
<span v-if="!menuMode">{{
|
<span v-if="layout === 'horizontal'">
|
||||||
transformI18n(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
|
{{ onlyOneChild.meta.title }}
|
||||||
}}</span>
|
</span>
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
v-else
|
v-else
|
||||||
placement="top"
|
placement="top"
|
||||||
@@ -162,24 +193,23 @@ function resolvePath(routePath) {
|
|||||||
:disabled="!onlyOneChild.showTooltip"
|
:disabled="!onlyOneChild.showTooltip"
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
{{
|
{{ onlyOneChild.meta.title }}
|
||||||
transformI18n(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
|
|
||||||
}}
|
|
||||||
</template>
|
</template>
|
||||||
<span
|
<span
|
||||||
ref="menuTextRef"
|
ref="menuTextRef"
|
||||||
:style="getMenuTextStyle"
|
:style="getMenuTextStyle"
|
||||||
@mouseover="hoverMenu(onlyOneChild)"
|
@mouseover="hoverMenu(onlyOneChild)"
|
||||||
>
|
>
|
||||||
{{
|
{{ onlyOneChild.meta.title }}
|
||||||
transformI18n(onlyOneChild.meta.title, onlyOneChild.meta.i18n)
|
|
||||||
}}
|
|
||||||
</span>
|
</span>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<Icon
|
<FontIcon
|
||||||
v-if="onlyOneChild.meta.extraIcon"
|
v-if="onlyOneChild.meta.extraIcon"
|
||||||
|
width="30px"
|
||||||
|
height="30px"
|
||||||
|
:style="getExtraIconStyle"
|
||||||
|
:icon="onlyOneChild.meta.extraIcon.name"
|
||||||
:svg="onlyOneChild.meta.extraIcon.svg ? true : false"
|
:svg="onlyOneChild.meta.extraIcon.svg ? true : false"
|
||||||
:content="`${onlyOneChild.meta.extraIcon.name}`"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -190,25 +220,28 @@ function resolvePath(routePath) {
|
|||||||
v-else
|
v-else
|
||||||
ref="subMenu"
|
ref="subMenu"
|
||||||
:index="resolvePath(props.item.path)"
|
:index="resolvePath(props.item.path)"
|
||||||
popper-append-to-body
|
v-bind:[expandCloseIcon]="useRenderIcon('ep-arrow-down')"
|
||||||
|
:expand-open-icon="useRenderIcon('ep-arrow-up')"
|
||||||
|
:collapse-close-icon="useRenderIcon('ep-arrow-right')"
|
||||||
|
:collapse-open-icon="useRenderIcon('ep-arrow-left')"
|
||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<el-icon v-show="props.item.meta.icon" :class="props.item.meta.icon">
|
<div v-if="toRaw(props.item.meta.icon)" class="sub-menu-icon">
|
||||||
<component
|
<component
|
||||||
:is="findIconReg(props.item.meta && props.item.meta.icon)"
|
:is="useRenderIcon(props.item.meta && toRaw(props.item.meta.icon))"
|
||||||
></component>
|
/>
|
||||||
</el-icon>
|
</div>
|
||||||
<span v-if="!menuMode">{{
|
<span v-if="layout === 'horizontal'">
|
||||||
transformI18n(props.item.meta.title, props.item.meta.i18n)
|
{{ props.item.meta.title }}
|
||||||
}}</span>
|
</span>
|
||||||
<el-tooltip
|
<el-tooltip
|
||||||
v-else
|
v-else
|
||||||
placement="top"
|
placement="top"
|
||||||
:offset="-10"
|
:offset="-10"
|
||||||
:disabled="!pureApp.sidebar.opened || !props.item.showTooltip"
|
:disabled="!isCollapse || !props.item.showTooltip"
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
{{ transformI18n(props.item.meta.title, props.item.meta.i18n) }}
|
{{ props.item.meta.title }}
|
||||||
</template>
|
</template>
|
||||||
<div
|
<div
|
||||||
ref="menuTextRef"
|
ref="menuTextRef"
|
||||||
@@ -216,14 +249,17 @@ function resolvePath(routePath) {
|
|||||||
@mouseover="hoverMenu(props.item)"
|
@mouseover="hoverMenu(props.item)"
|
||||||
>
|
>
|
||||||
<span :style="getSpanStyle">
|
<span :style="getSpanStyle">
|
||||||
{{ transformI18n(props.item.meta.title, props.item.meta.i18n) }}
|
{{ props.item.meta.title }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<Icon
|
<FontIcon
|
||||||
v-if="props.item.meta.extraIcon"
|
v-if="props.item.meta.extraIcon"
|
||||||
|
width="30px"
|
||||||
|
height="30px"
|
||||||
|
style="position: absolute; right: 10px"
|
||||||
|
:icon="props.item.meta.extraIcon.name"
|
||||||
:svg="props.item.meta.extraIcon.svg ? true : false"
|
:svg="props.item.meta.extraIcon.svg ? true : false"
|
||||||
:content="`${props.item.meta.extraIcon.name}`"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<sidebar-item
|
<sidebar-item
|
||||||
|
|||||||
30
src/layout/components/sidebar/topCollapse.vue
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
interface Props {
|
||||||
|
isActive: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
isActive: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: "toggleClick"): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const toggleClick = () => {
|
||||||
|
emit("toggleClick");
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="px-3 mr-1 navbar-bg-hover"
|
||||||
|
:title="props.isActive ? '点击折叠' : '点击展开'"
|
||||||
|
@click="toggleClick"
|
||||||
|
>
|
||||||
|
<IconifyIconOffline
|
||||||
|
:icon="props.isActive ? 'menu-fold' : 'menu-unfold'"
|
||||||
|
class="inline-block align-middle hover:text-primary dark:hover:!text-white"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||