Compare commits

...

22 Commits

Author SHA1 Message Date
xiaoxian521
1bafbeaab7 release: update 3.6.4 2022-11-10 12:28:10 +08:00
xiaoxian521
9a802296c7 perf: 优化路由守卫 2022-11-08 18:17:33 +08:00
xiaoxian521
e183ea75a0 feat: 菜单图标 icon 支持使用在线图标 2022-11-08 12:10:54 +08:00
xiaoxian521
969775c7cf perf: 优化代码 2022-11-08 01:25:44 +08:00
xiaoxian521
841c5bd53a release: update 3.6.3 2022-11-01 16:29:32 +08:00
xiaoxian521
761b0e5ec2 feat: 提交非国际化版本代码 2022-10-28 15:32:31 +08:00
xiaoxian521
b811256830 feat: 静态资源分类打包 2022-10-27 15:51:06 +08:00
xiaoxian521
6019739c16 chore: 同步完整版代码 2022-10-27 14:51:32 +08:00
xiaoxian521
0dd1c67280 release: update 3.6.2 2022-10-27 13:18:27 +08:00
xiaoxian521
7d419c3b35 refactor: 使用@/别名替换/@/别名 2022-10-27 13:17:56 +08:00
xiaoxian521
6ceb37624f release: update 3.6.1 2022-10-27 02:46:26 +08:00
xiaoxian521
fdf12660c1 feat: 打包构建添加可选 gzipbrotli 压缩模式 2022-10-27 02:19:23 +08:00
xiaoxian521
49cdcf216f feat: 添加打包是否启动cdn替换本地库配置,默认false不启动 2022-10-26 19:51:06 +08:00
xiaoxian521
936070c9ce chore: 同步完整版代码 2022-10-26 11:25:45 +08:00
xiaoxian521
f14077bc6f release: update 3.6.0 2022-10-25 17:51:21 +08:00
xiaoxian521
1003a31b4d chore: update 2022-10-22 11:55:15 +08:00
xiaoxian521
cc8a07d25b chore: update @pureadmin/utils latest 2022-10-19 17:08:05 +08:00
xiaoxian521
24db509381 chore: 同步完整版 2022-10-19 14:09:42 +08:00
xiaoxian521
43069ac127 chore: update extensions.json 2022-09-13 17:56:41 +08:00
xiaoxian521
f7ba97c73e chore: 优化样式 2022-09-11 19:54:00 +08:00
xiaoxian521
ee65ec9f72 perf: 使用/** */替换//注释,对编辑器的智能提示更友好 2022-09-11 16:46:21 +08:00
xiaoxian521
230af57c3e perf: 从tailwind.css中移除不常用的@apply 2022-09-11 11:35:13 +08:00
109 changed files with 2181 additions and 2755 deletions

View File

@@ -4,11 +4,5 @@ VITE_PORT = 8848
# 开发环境读取配置文件路径 # 开发环境读取配置文件路径
VITE_PUBLIC_PATH = / VITE_PUBLIC_PATH = /
# 开发环境代理
VITE_PROXY_DOMAIN = /api
# 开发环境路由历史模式 # 开发环境路由历史模式
VITE_ROUTER_HISTORY = "hash" VITE_ROUTER_HISTORY = "hash"
# 开发环境后端地址
VITE_PROXY_DOMAIN_REAL = "http://127.0.0.1:3000"

View File

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

View File

@@ -7,8 +7,13 @@ VITE_PUBLIC_PATH = /
# 线上环境路由历史模式 # 线上环境路由历史模式
VITE_ROUTER_HISTORY = "hash" VITE_ROUTER_HISTORY = "hash"
# 线上环境后端地址
VITE_PROXY_DOMAIN_REAL = ""
# 是否为打包后的文件提供传统浏览器兼容性支持 支持 true 不支持 false # 是否为打包后的文件提供传统浏览器兼容性支持 支持 true 不支持 false
VITE_LEGACY = false VITE_LEGACY = false
# 是否在打包时使用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"

View File

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

View File

@@ -27,13 +27,5 @@
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll.eslint": true "source.fixAll.eslint": true
}, },
"i18n-ally.localesPaths": "locales",
"i18n-ally.keystyle": "nested",
"i18n-ally.sortKeys": true,
"i18n-ally.namespace": true,
"i18n-ally.enabledParsers": ["yaml", "js"],
"i18n-ally.sourceLanguage": "en",
"i18n-ally.displayLanguage": "zh-CN",
"i18n-ally.enabledFrameworks": ["vue"],
"iconify.excludes": ["el"] "iconify.excludes": ["el"]
} }

View File

@@ -1,4 +1,4 @@
<h1>vue-pure-admin Lite Edition</h1> <h1>vue-pure-admin Lite Editionno i18n version</h1>
[![license](https://img.shields.io/github/license/xiaoxian521/vue-pure-admin.svg)](LICENSE) [![license](https://img.shields.io/github/license/xiaoxian521/vue-pure-admin.svg)](LICENSE)
@@ -6,7 +6,7 @@
## introduce ## introduce
The lite version is based on the shelf extracted from [vue-pure-admin](https://github.com/xiaoxian521/vue-pure-admin), which contains the main functions and is more suitable for actual project development, the packaged size is only `3MB`, and will permanently sync the full version of the code 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 ## Supporting Video
@@ -15,9 +15,8 @@ The lite version is based on the shelf extracted from [vue-pure-admin](https://g
## Docs ## Docs
- [Click me to view the domestic documentation site](http://yiming_chang.gitee.io/pure-admin-doc) - [Click me to view the domestic documentation site](https://yiming_chang.gitee.io/pure-admin-doc)
- [Click me to view foreign document site 1](https://xiaoxian521.github.io/pure-admin-doc) - [Click me to view foreign document site](https://xiaoxian521.github.io/pure-admin-doc)
- [Click me to view foreign document site 2](https://pure-admin-doc.vercel.app)
## Usage ## Usage
@@ -42,7 +41,6 @@ bilibili: https://www.bilibili.com/video/BV1534y1S7HV/
## ⚠️ Attention ## ⚠️ 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, 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! ! !
- Don't use the `delete-i18n` branch code, this branch is just for you to completely delete the internationalized references, it won't sync the code! ! ! [Completely remove the internationalization tutorial](https://www.bilibili.com/video/BV1Ru411B7k3/), please be sure to use the code from the `main` branch! ! !
## License ## License

View File

@@ -1,4 +1,4 @@
<h1>vue-pure-admin精简版</h1> <h1>vue-pure-admin精简版(非国际化版本)</h1>
[![license](https://img.shields.io/github/license/xiaoxian521/vue-pure-admin.svg)](LICENSE) [![license](https://img.shields.io/github/license/xiaoxian521/vue-pure-admin.svg)](LICENSE)
@@ -6,7 +6,7 @@
## 介绍 ## 介绍
精简版是基于 [vue-pure-admin](https://github.com/xiaoxian521/vue-pure-admin) 提炼出的架子,包含主体功能,更适合实际项目开发,打包后的大小 `3MB`,并且会永久同步完整版的代码 精简版是基于 [vue-pure-admin](https://github.com/xiaoxian521/vue-pure-admin) 提炼出的架子,包含主体功能,更适合实际项目开发,打包后的大小低于 `3MB`,并且会永久同步完整版的代码。开启 `brotli` 压缩和 `cdn` 替换本地库模式后,打包大小低于 `500kb`
## 配套视频 ## 配套视频
@@ -15,9 +15,8 @@
## 配套文档 ## 配套文档
- [点我查看国内文档站](http://yiming_chang.gitee.io/pure-admin-doc) - [点我查看国内文档站](https://yiming_chang.gitee.io/pure-admin-doc)
- [点我查看国外文档站 1](https://xiaoxian521.github.io/pure-admin-doc) - [点我查看国外文档站](https://xiaoxian521.github.io/pure-admin-doc)
- [点我查看国外文档站 2](https://pure-admin-doc.vercel.app)
## 维护者 ## 维护者
@@ -54,7 +53,6 @@ pnpm remove 包名
## ⚠️ 注意 ## ⚠️ 注意
- 精简版不接受任何 `issues``pr`,如果有问题请到完整版 [issues](https://github.com/xiaoxian521/vue-pure-admin/issues/new/choose) 去提,谢谢!!! - 精简版不接受任何 `issues``pr`,如果有问题请到完整版 [issues](https://github.com/xiaoxian521/vue-pure-admin/issues/new/choose) 去提,谢谢!!!
- 不要使用 `delete-i18n` 分支代码,这个分支只是给你们完全删除国际化的参考,不会同步代码的!!! [完全删除国际化教程](https://www.bilibili.com/video/BV1Ru411B7k3/) ,请务必使用 `main` 分支的代码!!!
## 许可证 ## 许可证

62
build/cdn.ts Normal file
View File

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

63
build/compress.ts Normal file
View File

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

View File

@@ -1,13 +1,13 @@
// 处理环境变量 /** 处理环境变量 */
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_LEGACY: false,
VITE_CDN: false,
VITE_COMPRESSION: "none"
}; };
for (const envName of Object.keys(envConf)) { for (const envName of Object.keys(envConf)) {
@@ -28,14 +28,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 };

View File

@@ -1,31 +1,32 @@
import { resolve } from "path"; import { cdn } from "./cdn";
import vue from "@vitejs/plugin-vue"; import vue from "@vitejs/plugin-vue";
import { viteBuildInfo } from "./info"; import { viteBuildInfo } from "./info";
import svgLoader from "vite-svg-loader"; import svgLoader from "vite-svg-loader";
import legacy from "@vitejs/plugin-legacy"; import legacy from "@vitejs/plugin-legacy";
import vueJsx from "@vitejs/plugin-vue-jsx"; import vueJsx from "@vitejs/plugin-vue-jsx";
import { viteMockServe } from "vite-plugin-mock"; import { viteMockServe } from "vite-plugin-mock";
import VueI18n from "@intlify/vite-plugin-vue-i18n"; import { configCompressPlugin } from "./compress";
// import ElementPlus from "unplugin-element-plus/vite"; // import ElementPlus from "unplugin-element-plus/vite";
import { visualizer } from "rollup-plugin-visualizer"; import { visualizer } from "rollup-plugin-visualizer";
import removeConsole from "vite-plugin-remove-console"; import removeConsole from "vite-plugin-remove-console";
import themePreprocessorPlugin from "@pureadmin/theme"; import themePreprocessorPlugin from "@pureadmin/theme";
import { genScssMultipleScopeVars } from "/@/layout/theme";
import DefineOptions from "unplugin-vue-define-options/vite"; import DefineOptions from "unplugin-vue-define-options/vite";
import { genScssMultipleScopeVars } from "../src/layout/theme";
export function getPluginsList(command, VITE_LEGACY) { export function getPluginsList(
command: string,
VITE_LEGACY: boolean,
VITE_CDN: boolean,
VITE_COMPRESSION: ViteCompression
) {
const prodMock = true; const prodMock = true;
const lifecycle = process.env.npm_lifecycle_event; const lifecycle = process.env.npm_lifecycle_event;
return [ return [
vue(), vue(),
// https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
VueI18n({
runtimeOnly: true,
compositionOnly: true,
include: [resolve("locales/**")]
}),
// jsx、tsx语法支持 // jsx、tsx语法支持
vueJsx(), vueJsx(),
VITE_CDN ? cdn : null,
configCompressPlugin(VITE_COMPRESSION),
DefineOptions(), DefineOptions(),
// 线上环境删除console // 线上环境删除console
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }), removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),

View File

@@ -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,10 +46,7 @@
margin: 80px auto; margin: 80px auto;
position: relative; position: relative;
text-indent: -9999em; text-indent: -9999em;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0); transform: translateZ(0);
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s; animation-delay: -0.16s;
top: 0; top: 0;
transform: translate(-50%, 0); transform: translate(-50%, 0);
@@ -66,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;
} }
@@ -74,18 +68,6 @@
left: 3.5em; left: 3.5em;
} }
@-webkit-keyframes loadAnimation {
0%,
80%,
100% {
box-shadow: 0 2.5em 0 -1.3em;
}
40% {
box-shadow: 0 2.5em 0 0;
}
}
@keyframes loadAnimation { @keyframes loadAnimation {
0%, 0%,
80%, 80%,

View File

@@ -1,39 +0,0 @@
buttons:
hsLoginOut: LoginOut
hsfullscreen: FullScreen
hsexitfullscreen: ExitFullscreen
hsrefreshRoute: RefreshRoute
hslogin: Login
hsadd: Add
hsmark: Mark/Cancel
hssave: Save
hssearch: Search
hsexpendAll: Expand All
hscollapseAll: Collapse All
hssystemSet: Open ProjectConfig
hsdelete: Delete
hsreload: Reload
hscloseCurrentTab: Close CurrentTab
hscloseLeftTabs: Close LeftTabs
hscloseRightTabs: Close RightTabs
hscloseOtherTabs: Close OtherTabs
hscloseAllTabs: Close AllTabs
menus:
hshome: Home
hslogin: Login
hserror: Error Page
hsfourZeroFour: "404"
hsfourZeroOne: "403"
hsFive: "500"
permission: Permission Manage
permissionPage: Page Permission
permissionButton: Button Permission
status:
hsLoad: Loading...
login:
username: Username
password: Password
login: Login
usernameReg: Please enter username
passwordReg: Please enter password
passwordRuleReg: The password format should be any combination of 8-18 digits

View File

@@ -1,39 +0,0 @@
buttons:
hsLoginOut: 退出系统
hsfullscreen: 全屏
hsexitfullscreen: 退出全屏
hsrefreshRoute: 刷新路由
hslogin: 登录
hsadd: 新增
hsmark: 标记/取消
hssave: 保存
hssearch: 搜索
hsexpendAll: 全部展开
hscollapseAll: 全部折叠
hssystemSet: 打开项目配置
hsdelete: 删除
hsreload: 重新加载
hscloseCurrentTab: 关闭当前标签页
hscloseLeftTabs: 关闭左侧标签页
hscloseRightTabs: 关闭右侧标签页
hscloseOtherTabs: 关闭其他标签页
hscloseAllTabs: 关闭全部标签页
menus:
hshome: 首页
hslogin: 登录
hserror: 错误页面
hsfourZeroFour: "404"
hsfourZeroOne: "403"
hsFive: "500"
permission: 权限管理
permissionPage: 页面权限
permissionButton: 按钮权限
status:
hsLoad: 加载中...
login:
username: 账号
password: 密码
login: 登录
usernameReg: 请输入账号
passwordReg: 请输入密码
passwordRuleReg: 密码格式应为8-18位数字、字母、符号的任意两种组合

View File

@@ -1,54 +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",
meta: { meta: {
title: "menus.permission", title: "权限管理",
icon: "lollipop", icon: "lollipop",
rank: 7 rank: 10
}, },
children: [ children: [
{ {
path: "/permission/page/index", path: "/permission/page/index",
name: "PermissionPage", name: "PermissionPage",
meta: { meta: {
title: "menus.permissionPage" title: "页面权限",
roles: ["admin", "common"]
} }
}, },
{ {
path: "/permission/button/index", path: "/permission/button/index",
name: "PermissionButton", name: "PermissionButton",
meta: { meta: {
title: "menus.permissionButton", title: "按钮权限",
authority: [] roles: ["admin", "common"],
auths: ["btn_add", "btn_edit", "btn_delete"]
} }
} }
] ]
}; };
// 添加不同按钮权限到/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
View File

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

27
mock/refreshToken.ts Normal file
View File

@@ -0,0 +1,27 @@
import { MockMethod } from "vite-plugin-mock";
// 模拟刷新token接口
export default [
{
url: "/refreshToken",
method: "post",
response: ({ body }) => {
if (body.refreshToken) {
return {
success: true,
data: {
accessToken: "eyJhbGciOiJIUzUxMiJ9.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[];

View File

@@ -1,6 +1,6 @@
{ {
"name": "pure-admin-thin", "name": "pure-admin-thin",
"version": "3.5.0", "version": "3.6.3",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "NODE_OPTIONS=--max-old-space-size=4096 vite", "dev": "NODE_OPTIONS=--max-old-space-size=4096 vite",
@@ -12,7 +12,7 @@
"preview:build": "pnpm build && vite preview", "preview:build": "pnpm build && vite preview",
"typecheck": "tsc --noEmit && vue-tsc --noEmit --skipLibCheck", "typecheck": "tsc --noEmit && vue-tsc --noEmit --skipLibCheck",
"cloc": "NODE_OPTIONS=--max-old-space-size=4096 cloc . --exclude-dir=node_modules --exclude-lang=YAML", "cloc": "NODE_OPTIONS=--max-old-space-size=4096 cloc . --exclude-dir=node_modules --exclude-lang=YAML",
"clean:cache": "rm -rf node_modules && rm -rf .eslintcache && pnpm install", "clean:cache": "rm -rf node_modules && rm -rf .eslintcache && npm cache clean --force && pnpm install",
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock,build}/**/*.{vue,js,ts,tsx}\" --fix", "lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock,build}/**/*.{vue,js,ts,tsx}\" --fix",
"lint:prettier": "prettier --write \"src/**/*.{js,ts,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/",
@@ -32,12 +32,12 @@
"@pureadmin/components": "^1.1.0", "@pureadmin/components": "^1.1.0",
"@pureadmin/descriptions": "^1.1.0", "@pureadmin/descriptions": "^1.1.0",
"@pureadmin/table": "^1.2.0", "@pureadmin/table": "^1.2.0",
"@pureadmin/utils": "^0.1.1", "@pureadmin/utils": "^1.1.5",
"@vueuse/core": "^9.1.1", "@vueuse/core": "^9.4.0",
"@vueuse/motion": "^2.0.0-beta.12", "@vueuse/motion": "^2.0.0-beta.12",
"@vueuse/shared": "^9.1.1", "@vueuse/shared": "^9.4.0",
"animate.css": "^4.1.1", "animate.css": "^4.1.1",
"axios": "^0.27.2", "axios": "^1.1.3",
"dayjs": "^1.11.4", "dayjs": "^1.11.4",
"echarts": "^5.3.3", "echarts": "^5.3.3",
"element-plus": "^2.2.16", "element-plus": "^2.2.16",
@@ -54,9 +54,8 @@
"qs": "^6.11.0", "qs": "^6.11.0",
"resize-observer-polyfill": "^1.5.1", "resize-observer-polyfill": "^1.5.1",
"responsive-storage": "^2.1.0", "responsive-storage": "^2.1.0",
"vue": "^3.2.39", "vue": "^3.2.40",
"vue-i18n": "^9.2.2", "vue-router": "^4.1.6",
"vue-router": "^4.1.5",
"vue-types": "^4.2.1", "vue-types": "^4.2.1",
"vxe-table": "^4.3.2", "vxe-table": "^4.3.2",
"xe-utils": "^3.5.6" "xe-utils": "^3.5.6"
@@ -67,7 +66,6 @@
"@iconify-icons/ep": "^1.2.7", "@iconify-icons/ep": "^1.2.7",
"@iconify-icons/ri": "^1.2.3", "@iconify-icons/ri": "^1.2.3",
"@iconify/vue": "^3.2.1", "@iconify/vue": "^3.2.1",
"@intlify/vite-plugin-vue-i18n": "^6.0.1",
"@pureadmin/theme": "^2.4.0", "@pureadmin/theme": "^2.4.0",
"@types/element-resize-detector": "1.1.3", "@types/element-resize-detector": "1.1.3",
"@types/js-cookie": "^3.0.1", "@types/js-cookie": "^3.0.1",
@@ -76,19 +74,18 @@
"@types/mockjs": "1.0.3", "@types/mockjs": "1.0.3",
"@types/node": "14.14.14", "@types/node": "14.14.14",
"@types/nprogress": "0.2.0", "@types/nprogress": "0.2.0",
"@types/qrcode": "^1.5.0",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
"@typescript-eslint/eslint-plugin": "^5.10.2", "@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2", "@typescript-eslint/parser": "^5.10.2",
"@vitejs/plugin-legacy": "^2.1.0", "@vitejs/plugin-legacy": "^2.2.0",
"@vitejs/plugin-vue": "^3.1.0", "@vitejs/plugin-vue": "^3.1.2",
"@vitejs/plugin-vue-jsx": "^2.0.1", "@vitejs/plugin-vue-jsx": "^2.0.1",
"@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0", "@vue/eslint-config-typescript": "^10.0.0",
"@vue/runtime-core": "^3.2.39", "@vue/runtime-core": "^3.2.40",
"autoprefixer": "^10.4.8", "autoprefixer": "^10.4.13",
"cloc": "^2.10.0", "cloc": "^2.10.0",
"cssnano": "^5.1.13", "cssnano": "^5.1.14",
"eslint": "^8.8.0", "eslint": "^8.8.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.4.1", "eslint-plugin-vue": "^8.4.1",
@@ -96,14 +93,14 @@
"husky": "^7.0.4", "husky": "^7.0.4",
"lint-staged": "11.1.2", "lint-staged": "11.1.2",
"picocolors": "^1.0.0", "picocolors": "^1.0.0",
"postcss": "^8.4.16", "postcss": "^8.4.18",
"postcss-html": "^1.5.0", "postcss-html": "^1.5.0",
"postcss-import": "^15.0.0", "postcss-import": "^15.0.0",
"postcss-scss": "^4.0.4", "postcss-scss": "^4.0.5",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"pretty-quick": "3.1.1", "pretty-quick": "3.1.1",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"rollup-plugin-visualizer": "^5.8.1", "rollup-plugin-visualizer": "^5.8.3",
"sass": "^1.53.0", "sass": "^1.53.0",
"sass-loader": "^13.0.2", "sass-loader": "^13.0.2",
"stylelint": "^14.3.0", "stylelint": "^14.3.0",
@@ -112,16 +109,18 @@
"stylelint-config-recommended": "^6.0.0", "stylelint-config-recommended": "^6.0.0",
"stylelint-config-standard": "^24.0.0", "stylelint-config-standard": "^24.0.0",
"stylelint-order": "^5.0.0", "stylelint-order": "^5.0.0",
"tailwindcss": "^3.1.8", "tailwindcss": "^3.2.3",
"terser": "^5.15.0", "terser": "^5.15.1",
"typescript": "^4.7.4", "typescript": "^4.7.4",
"unplugin-vue-define-options": "0.7.3", "unplugin-vue-define-options": "0.7.3",
"vite": "^3.1.0", "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": "^1.1.0", "vite-plugin-remove-console": "^1.2.0",
"vite-svg-loader": "^3.4.0", "vite-svg-loader": "^3.6.0",
"vue-eslint-parser": "^8.2.0", "vue-eslint-parser": "^8.2.0",
"vue-tsc": "^0.40.7" "vue-tsc": "^0.40.13"
}, },
"pnpm": { "pnpm": {
"peerDependencyRules": { "peerDependencyRules": {

1989
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,10 @@
{ {
"Version": "3.5.0", "Version": "3.6.3",
"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,

View File

@@ -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;
} }
} }
}); });

View File

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

View File

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

Before

Width:  |  Height:  |  Size: 395 B

View File

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

Before

Width:  |  Height:  |  Size: 279 B

View File

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

Before

Width:  |  Height:  |  Size: 647 B

View File

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

Before

Width:  |  Height:  |  Size: 284 B

View File

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

Before

Width:  |  Height:  |  Size: 693 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" 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

View File

Before

Width:  |  Height:  |  Size: 477 B

After

Width:  |  Height:  |  Size: 477 B

View File

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

Before

Width:  |  Height:  |  Size: 561 B

View File

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

View File

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

View File

@@ -2,7 +2,7 @@ import iconifyIconOffline from "./src/iconifyIconOffline";
import iconifyIconOnline from "./src/iconifyIconOnline"; import iconifyIconOnline from "./src/iconifyIconOnline";
import fontIcon from "./src/iconfont"; import fontIcon from "./src/iconfont";
/** 离线图标组件 */ /** 本地图标组件 */
const IconifyIconOffline = iconifyIconOffline; const IconifyIconOffline = iconifyIconOffline;
/** 在线图标组件 */ /** 在线图标组件 */
const IconifyIconOnline = iconifyIconOnline; const IconifyIconOnline = iconifyIconOnline;

View File

@@ -3,7 +3,8 @@ import { h, defineComponent, Component } from "vue";
import { IconifyIconOnline, IconifyIconOffline, FontIcon } from "../index"; import { IconifyIconOnline, IconifyIconOffline, FontIcon } from "../index";
/** /**
* 支持fontawesome4、5+、iconfont、remixicon、element-plus的icons、自定义svg * 支持 `iconfont`、自定义 `svg` 以及 `iconify` 中所有的图标
* @see 点击查看文档图标篇 {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/icon/}
* @param icon 必传 图标 * @param icon 必传 图标
* @param attrs 可选 iconType 属性 * @param attrs 可选 iconType 属性
* @returns Component * @returns Component
@@ -34,11 +35,12 @@ export function useRenderIcon(icon: any, attrs?: iconType): Component {
// svg // svg
return icon; return icon;
} else { } else {
// 通过是否存在 : 符号来判断是在线还是本地图标,存在即是在线图标,反之
return defineComponent({ return defineComponent({
name: "Icon", name: "Icon",
render() { render() {
const IconifyIcon = const IconifyIcon =
attrs && attrs["online"] ? IconifyIconOnline : IconifyIconOffline; icon && icon.includes(":") ? IconifyIconOnline : IconifyIconOffline;
return h(IconifyIcon, { return h(IconifyIcon, {
icon: icon, icon: icon,
...attrs ...attrs

View File

@@ -4,19 +4,17 @@ import { Icon as IconifyIcon, addIcon } from "@iconify/vue/dist/offline";
// element-plus icon // element-plus icon
import Check from "@iconify-icons/ep/check"; import Check from "@iconify-icons/ep/check";
import HomeFilled from "@iconify-icons/ep/home-filled"; import HomeFilled from "@iconify-icons/ep/home-filled";
import Setting from "@iconify-icons/ep/setting";
import Lollipop from "@iconify-icons/ep/lollipop"; import Lollipop from "@iconify-icons/ep/lollipop";
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 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 Search from "@iconify-icons/ep/search"; import Search from "@iconify-icons/ep/search";
addIcon("check", Check); addIcon("check", Check);
addIcon("home-filled", HomeFilled); addIcon("home-filled", HomeFilled);
addIcon("setting", Setting);
addIcon("lollipop", Lollipop); addIcon("lollipop", Lollipop);
addIcon("refresh-right", RefreshRight); addIcon("refresh-right", RefreshRight);
addIcon("arrow-down", ArrowDown); addIcon("close", Close);
addIcon("close-bold", CloseBold); addIcon("close-bold", CloseBold);
addIcon("bell", Bell); addIcon("bell", Bell);
addIcon("search", Search); addIcon("search", Search);
@@ -33,6 +31,14 @@ import User from "@iconify-icons/ri/user-3-fill";
import Lock from "@iconify-icons/ri/lock-fill"; import Lock from "@iconify-icons/ri/lock-fill";
import MenuUnfold from "@iconify-icons/ri/menu-unfold-fill"; import MenuUnfold from "@iconify-icons/ri/menu-unfold-fill";
import MenuFold from "@iconify-icons/ri/menu-fold-fill"; import MenuFold from "@iconify-icons/ri/menu-fold-fill";
import Setting from "@iconify-icons/ri/settings-3-line";
import ArrowDown from "@iconify-icons/ri/arrow-down-s-line";
import CloseLeftTags from "@iconify-icons/ri/text-direction-r";
import CloseRightTags from "@iconify-icons/ri/text-direction-l";
import CloseOtherTags from "@iconify-icons/ri/text-spacing";
import CloseAllTags from "@iconify-icons/ri/subtract-line";
import Fullscreen from "@iconify-icons/ri/fullscreen-fill";
import ExitFullscreen from "@iconify-icons/ri/fullscreen-exit-fill";
addIcon("arrow-right-s-line", ArrowRightSLine); addIcon("arrow-right-s-line", ArrowRightSLine);
addIcon("arrow-left-s-line", ArrowLeftSLine); addIcon("arrow-left-s-line", ArrowLeftSLine);
addIcon("logout-circle-r-line", LogoutCircleRLine); addIcon("logout-circle-r-line", LogoutCircleRLine);
@@ -44,8 +50,16 @@ addIcon("user", User);
addIcon("lock", Lock); addIcon("lock", Lock);
addIcon("menu-unfold", MenuUnfold); addIcon("menu-unfold", MenuUnfold);
addIcon("menu-fold", MenuFold); addIcon("menu-fold", MenuFold);
addIcon("setting", Setting);
addIcon("arrow-down", ArrowDown);
addIcon("close-left-tags", CloseLeftTags);
addIcon("close-right-tags", CloseRightTags);
addIcon("close-other-tags", CloseOtherTags);
addIcon("close-all-tags", CloseAllTags);
addIcon("fullscreen", Fullscreen);
addIcon("exit-fullscreen", ExitFullscreen);
// Iconify Icon在Vue里离线使用用于内网环境https://docs.iconify.design/icon-components/vue/offline.html // Iconify Icon在Vue里本地使用用于内网环境https://docs.iconify.design/icon-components/vue/offline.html
export default defineComponent({ export default defineComponent({
name: "IconifyIconOffline", name: "IconifyIconOffline",
components: { IconifyIcon }, components: { IconifyIcon },

View File

@@ -11,7 +11,6 @@ export interface iconType {
horizontalAlign?: boolean; horizontalAlign?: boolean;
verticalAlign?: boolean; verticalAlign?: boolean;
align?: string; align?: string;
online?: boolean;
onLoad?: Function; onLoad?: Function;
includes?: Function; includes?: Function;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,8 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { useGlobal } from "@pureadmin/utils"; import { useGlobal } from "@pureadmin/utils";
import backTop from "/@/assets/svg/back_top.svg?component"; import backTop from "@/assets/svg/back_top.svg?component";
import { h, computed, Transition, defineComponent } from "vue"; import { h, computed, Transition, defineComponent } from "vue";
import { usePermissionStoreHook } from "/@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";
const props = defineProps({ const props = defineProps({
fixedHeader: Boolean fixedHeader: Boolean

View File

@@ -2,14 +2,9 @@
import Search from "./search/index.vue"; import Search from "./search/index.vue";
import Notice from "./notice/index.vue"; import Notice from "./notice/index.vue";
import mixNav from "./sidebar/mixNav.vue"; import mixNav from "./sidebar/mixNav.vue";
import avatars from "/@/assets/avatars.jpg"; import { useNav } from "@/layout/hooks/useNav";
import { useNav } from "/@/layout/hooks/useNav";
import Breadcrumb from "./sidebar/breadCrumb.vue"; import Breadcrumb from "./sidebar/breadCrumb.vue";
import { deviceDetection } from "@pureadmin/utils";
import topCollapse from "./sidebar/topCollapse.vue"; import topCollapse from "./sidebar/topCollapse.vue";
import screenfull from "../components/screenfull/index.vue";
import { useTranslationLang } from "../hooks/useTranslationLang";
import globalization from "/@/assets/svg/globalization.svg?component";
const { const {
layout, layout,
@@ -19,12 +14,8 @@ const {
pureApp, pureApp,
username, username,
avatarsStyle, avatarsStyle,
toggleSideBar, toggleSideBar
getDropdownItemStyle,
getDropdownItemClass
} = useNav(); } = useNav();
const { t, locale, translationCh, translationEn } = useTranslationLang();
</script> </script>
<template> <template>
@@ -50,44 +41,13 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
<Search /> <Search />
<!-- 通知 --> <!-- 通知 -->
<Notice id="header-notice" /> <Notice id="header-notice" />
<!-- 全屏 -->
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
<!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click">
<globalization
class="navbar-bg-hover w-[40px] h-[48px] p-[11px] cursor-pointer outline-none"
/>
<template #dropdown>
<el-dropdown-menu class="translation">
<el-dropdown-item
:style="getDropdownItemStyle(locale, 'zh')"
:class="['dark:!text-white', getDropdownItemClass(locale, 'zh')]"
@click="translationCh"
>
<IconifyIconOffline
class="check-zh"
v-show="locale === 'zh'"
icon="check"
/>
简体中文
</el-dropdown-item>
<el-dropdown-item
:style="getDropdownItemStyle(locale, 'en')"
:class="['dark:!text-white', getDropdownItemClass(locale, 'en')]"
@click="translationEn"
>
<span class="check-en" v-show="locale === 'en'">
<IconifyIconOffline icon="check" />
</span>
English
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<!-- 退出登录 --> <!-- 退出登录 -->
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover"> <span class="el-dropdown-link navbar-bg-hover select-none">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" /> <img
src="https://avatars.githubusercontent.com/u/44761321?v=4"
:style="avatarsStyle"
/>
<p v-if="username" class="dark:text-white">{{ username }}</p> <p v-if="username" class="dark:text-white">{{ username }}</p>
</span> </span>
<template #dropdown> <template #dropdown>
@@ -97,14 +57,14 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
icon="logout-circle-r-line" icon="logout-circle-r-line"
style="margin: 5px" style="margin: 5px"
/> />
{{ t("buttons.hsLoginOut") }} 退出系统
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
<span <span
class="el-icon-setting navbar-bg-hover" class="set-icon navbar-bg-hover"
:title="t('buttons.hssystemSet')" title="打开项目配置"
@click="onPanel" @click="onPanel"
> >
<IconifyIconOffline icon="setting" /> <IconifyIconOffline icon="setting" />
@@ -153,15 +113,6 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
border-radius: 50%; border-radius: 50%;
} }
} }
.el-icon-setting {
height: 48px;
width: 38px;
padding: 12px;
display: flex;
cursor: pointer;
align-items: center;
}
} }
.breadcrumb-container { .breadcrumb-container {
@@ -170,22 +121,6 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
} }
} }
.translation {
::v-deep(.el-dropdown-menu__item) {
padding: 5px 40px;
}
.check-zh {
position: absolute;
left: 20px;
}
.check-en {
position: absolute;
left: 20px;
}
}
.logout { .logout {
max-width: 120px; max-width: 120px;

View File

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

View File

@@ -1,8 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { useI18n } from "vue-i18n";
import { useFullscreen } from "@vueuse/core"; import { useFullscreen } from "@vueuse/core";
const { t } = useI18n();
const { isFullscreen, toggle } = useFullscreen(); const { isFullscreen, toggle } = useFullscreen();
</script> </script>
@@ -12,9 +10,7 @@ const { isFullscreen, toggle } = useFullscreen();
@click="toggle" @click="toggle"
> >
<FontIcon <FontIcon
:title=" :title="isFullscreen ? '退出全屏' : '全屏'"
isFullscreen ? t('buttons.hsexitfullscreen') : t('buttons.hsfullscreen')
"
:icon="isFullscreen ? 'team-iconexit-fullscreen' : 'team-iconfullscreen'" :icon="isFullscreen ? 'team-iconexit-fullscreen' : 'team-iconfullscreen'"
/> />
</div> </div>

View File

@@ -17,8 +17,8 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import enterOutlined from "/@/assets/svg/enter_outlined.svg?component"; import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
import mdiKeyboardEsc from "/@/assets/svg/mdi_keyboard_esc.svg?component"; import mdiKeyboardEsc from "@/assets/svg/keyboard_esc.svg?component";
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.search-footer { .search-footer {

View File

@@ -1,13 +1,13 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { cloneDeep } from "lodash-unified";
import SearchResult from "./SearchResult.vue"; import SearchResult from "./SearchResult.vue";
import SearchFooter from "./SearchFooter.vue"; import SearchFooter from "./SearchFooter.vue";
import { useNav } from "/@/layout/hooks/useNav"; import { useNav } from "@/layout/hooks/useNav";
import { transformI18n } from "/@/plugins/i18n";
import { deleteChildren } from "@pureadmin/utils"; import { deleteChildren } from "@pureadmin/utils";
import { useDebounceFn, onKeyStroke } from "@vueuse/core"; import { useDebounceFn, onKeyStroke } from "@vueuse/core";
import { ref, watch, computed, nextTick, shallowRef } from "vue"; import { ref, watch, computed, nextTick, shallowRef } from "vue";
import { usePermissionStoreHook } from "/@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";
interface Props { interface Props {
/** 弹窗显隐 */ /** 弹窗显隐 */
@@ -31,7 +31,7 @@ const handleSearch = useDebounceFn(search, 300);
/** 菜单树形结构 */ /** 菜单树形结构 */
const menusData = computed(() => { const menusData = computed(() => {
return deleteChildren(usePermissionStoreHook().menusTree); return deleteChildren(cloneDeep(usePermissionStoreHook().wholeMenus));
}); });
const show = computed({ const show = computed({
@@ -70,7 +70,7 @@ function search() {
resultOptions.value = flatMenusData.filter( resultOptions.value = flatMenusData.filter(
menu => menu =>
keyword.value && keyword.value &&
transformI18n(menu.meta?.title) menu.meta?.title
.toLocaleLowerCase() .toLocaleLowerCase()
.includes(keyword.value.toLocaleLowerCase().trim()) .includes(keyword.value.toLocaleLowerCase().trim())
); );

View File

@@ -1,11 +1,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed } from "vue"; import { computed } from "vue";
import { useI18n } from "vue-i18n"; import { useEpThemeStoreHook } from "@/store/modules/epTheme";
import { useEpThemeStoreHook } from "/@/store/modules/epTheme"; import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks"; import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
import enterOutlined from "/@/assets/svg/enter_outlined.svg?component";
const { t } = useI18n();
interface optionsItem { interface optionsItem {
path: string; path: string;
@@ -68,7 +65,7 @@ function handleTo() {
@mouseenter="handleMouse(item)" @mouseenter="handleMouse(item)"
> >
<component :is="useRenderIcon(item.meta?.icon ?? 'bookmark-2-line')" /> <component :is="useRenderIcon(item.meta?.icon ?? 'bookmark-2-line')" />
<span class="result-item-title">{{ t(item.meta?.title) }}</span> <span class="result-item-title">{{ item.meta?.title }}</span>
<enterOutlined /> <enterOutlined />
</div> </div>
</template> </template>

View File

@@ -8,17 +8,18 @@ import {
nextTick, nextTick,
useCssModule useCssModule
} from "vue"; } from "vue";
import { getConfig } from "/@/config"; 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 { resetRouter } from "/@/router"; import { resetRouter } from "@/router";
import { templateRef } from "@vueuse/core"; import { templateRef } from "@vueuse/core";
import { routerArrays } from "/@/layout/types"; import { removeToken } from "@/utils/auth";
import { useNav } from "/@/layout/hooks/useNav"; import { routerArrays } from "@/layout/types";
import { useAppStoreHook } from "/@/store/modules/app"; import { useNav } from "@/layout/hooks/useNav";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags"; import { useAppStoreHook } from "@/store/modules/app";
import { useDataThemeChange } from "/@/layout/hooks/useDataThemeChange"; import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { useDataThemeChange } from "@/layout/hooks/useDataThemeChange";
import { import {
useDark, useDark,
debounce, debounce,
@@ -28,8 +29,8 @@ import {
} from "@pureadmin/utils"; } from "@pureadmin/utils";
import { toggleTheme } from "@pureadmin/theme/dist/browser-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 { device } = useNav();
@@ -131,16 +132,17 @@ const multiTagsCacheChange = () => {
/** 清空缓存并返回登录页 */ /** 清空缓存并返回登录页 */
function onReset() { function onReset() {
router.push("/login"); removeToken();
storageLocal.clear();
storageSession.clear();
const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig(); const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig();
useAppStoreHook().setLayout(Layout); useAppStoreHook().setLayout(Layout);
setEpThemeColor(EpThemeColor); setEpThemeColor(EpThemeColor);
useMultiTagsStoreHook().multiTagsCacheChange(MultiTagsCache); useMultiTagsStoreHook().multiTagsCacheChange(MultiTagsCache);
toggleClass(Grey, "html-grey", document.querySelector("html")); toggleClass(Grey, "html-grey", document.querySelector("html"));
toggleClass(Weak, "html-weakness", document.querySelector("html")); toggleClass(Weak, "html-weakness", document.querySelector("html"));
router.push("/login");
useMultiTagsStoreHook().handleTags("equal", [...routerArrays]); useMultiTagsStoreHook().handleTags("equal", [...routerArrays]);
storageLocal.clear();
storageSession.clear();
resetRouter(); resetRouter();
} }

View File

@@ -1,9 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { isEqual } from "lodash-unified"; import { isEqual } from "lodash-unified";
import { transformI18n } from "/@/plugins/i18n";
import { ref, watch, onMounted, toRaw } from "vue"; import { ref, watch, onMounted, toRaw } from "vue";
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();
@@ -53,7 +52,7 @@ const getBreadcrumb = (): void => {
{ {
path: "/welcome", path: "/welcome",
parentPath: "/", parentPath: "/",
meta: { title: "menus.hshome" } meta: { title: "首页" }
} as unknown as RouteLocationMatched } as unknown as RouteLocationMatched
].concat(matched); ].concat(matched);
} }
@@ -100,7 +99,7 @@ watch(
<transition-group appear name="breadcrumb"> <transition-group appear name="breadcrumb">
<el-breadcrumb-item v-for="item in levelList" :key="item.path"> <el-breadcrumb-item v-for="item in levelList" :key="item.path">
<a @click.prevent="handleLink(item)"> <a @click.prevent="handleLink(item)">
{{ transformI18n(item.meta.title) }} {{ item.meta.title }}
</a> </a>
</el-breadcrumb-item> </el-breadcrumb-item>
</transition-group> </transition-group>

View File

@@ -1,21 +1,15 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from "vue";
import Search from "../search/index.vue"; import Search from "../search/index.vue";
import Notice from "../notice/index.vue"; import Notice from "../notice/index.vue";
import { ref, watch, nextTick } from "vue";
import SidebarItem from "./sidebarItem.vue"; import SidebarItem from "./sidebarItem.vue";
import avatars from "/@/assets/avatars.jpg"; import { useNav } from "@/layout/hooks/useNav";
import { useNav } from "/@/layout/hooks/useNav"; import { usePermissionStoreHook } from "@/store/modules/permission";
import screenfull from "../screenfull/index.vue";
import { deviceDetection } from "@pureadmin/utils";
import { useTranslationLang } from "../../hooks/useTranslationLang";
import { usePermissionStoreHook } from "/@/store/modules/permission";
import globalization from "/@/assets/svg/globalization.svg?component";
const menuRef = ref(); const menuRef = ref();
const { t, route, locale, translationCh, translationEn } =
useTranslationLang(menuRef);
const { const {
route,
title, title,
routers, routers,
logout, logout,
@@ -23,11 +17,13 @@ const {
onPanel, onPanel,
menuSelect, menuSelect,
username, username,
avatarsStyle, avatarsStyle
getDropdownItemStyle,
getDropdownItemClass
} = useNav(); } = useNav();
nextTick(() => {
menuRef.value?.handleResize();
});
watch( watch(
() => route.path, () => route.path,
() => { () => {
@@ -62,42 +58,13 @@ watch(
<Search /> <Search />
<!-- 通知 --> <!-- 通知 -->
<Notice id="header-notice" /> <Notice id="header-notice" />
<!-- 全屏 -->
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
<!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click">
<globalization
class="navbar-bg-hover w-[40px] h-[48px] p-[11px] cursor-pointer outline-none"
/>
<template #dropdown>
<el-dropdown-menu class="translation">
<el-dropdown-item
:style="getDropdownItemStyle(locale, 'zh')"
:class="['dark:!text-white', getDropdownItemClass(locale, 'zh')]"
@click="translationCh"
>
<span class="check-zh" v-show="locale === 'zh'">
<IconifyIconOffline icon="check" />
</span>
简体中文
</el-dropdown-item>
<el-dropdown-item
:style="getDropdownItemStyle(locale, 'en')"
:class="['dark:!text-white', getDropdownItemClass(locale, 'en')]"
@click="translationEn"
>
<span class="check-en" v-show="locale === 'en'">
<IconifyIconOffline icon="check" />
</span>
English
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<!-- 退出登录 --> <!-- 退出登录 -->
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover"> <span class="el-dropdown-link navbar-bg-hover">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" /> <img
src="https://avatars.githubusercontent.com/u/44761321?v=4"
:style="avatarsStyle"
/>
<p v-if="username" class="dark:text-white">{{ username }}</p> <p v-if="username" class="dark:text-white">{{ username }}</p>
</span> </span>
<template #dropdown> <template #dropdown>
@@ -107,14 +74,14 @@ watch(
icon="logout-circle-r-line" icon="logout-circle-r-line"
style="margin: 5px" style="margin: 5px"
/> />
{{ t("buttons.hsLoginOut") }} 退出系统
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
<span <span
class="el-icon-setting navbar-bg-hover" class="set-icon navbar-bg-hover"
:title="t('buttons.hssystemSet')" title="打开项目配置"
@click="onPanel" @click="onPanel"
> >
<IconifyIconOffline icon="setting" /> <IconifyIconOffline icon="setting" />
@@ -124,22 +91,6 @@ watch(
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.translation {
::v-deep(.el-dropdown-menu__item) {
padding: 5px 40px;
}
.check-zh {
position: absolute;
left: 20px;
}
.check-en {
position: absolute;
left: 20px;
}
}
.logout { .logout {
max-width: 120px; max-width: 120px;

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { useNav } from "/@/layout/hooks/useNav"; import { useNav } from "@/layout/hooks/useNav";
const props = defineProps({ const props = defineProps({
collapse: Boolean collapse: Boolean
@@ -9,7 +9,7 @@ const { title } = useNav();
</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"
@@ -51,6 +51,12 @@ const { title } = useNav();
margin-top: 5px; margin-top: 5px;
.sidebar-title { .sidebar-title {
display: block;
width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left;
color: #1890ff; color: #1890ff;
font-weight: 600; font-weight: 600;
font-size: 20px; font-size: 20px;
@@ -59,7 +65,7 @@ const { title } = useNav();
} }
} }
.collapse { .collapses {
.sidebar-logo { .sidebar-logo {
margin-right: 0; margin-right: 0;
} }

View File

@@ -1,24 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
import Search from "../search/index.vue"; import Search from "../search/index.vue";
import Notice from "../notice/index.vue"; import Notice from "../notice/index.vue";
import avatars from "/@/assets/avatars.jpg"; import { useNav } from "@/layout/hooks/useNav";
import { useNav } from "/@/layout/hooks/useNav"; import { ref, toRaw, watch, onMounted, nextTick } from "vue";
import { transformI18n } from "/@/plugins/i18n"; import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import screenfull from "../screenfull/index.vue"; import { getParentPaths, findRouteByPath } from "@/router/utils";
import { deviceDetection } from "@pureadmin/utils"; import { usePermissionStoreHook } from "@/store/modules/permission";
import { ref, toRaw, watch, onMounted } from "vue";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
import { getParentPaths, findRouteByPath } from "/@/router/utils";
import { useTranslationLang } from "../../hooks/useTranslationLang";
import { usePermissionStoreHook } from "/@/store/modules/permission";
import globalization from "/@/assets/svg/globalization.svg?component";
const menuRef = ref(); const menuRef = ref();
let defaultActive = ref(null); let defaultActive = ref(null);
const { t, route, locale, translationCh, translationEn } =
useTranslationLang(menuRef);
const { const {
route,
device, device,
routers, routers,
logout, logout,
@@ -26,9 +19,7 @@ const {
menuSelect, menuSelect,
resolvePath, resolvePath,
username, username,
avatarsStyle, avatarsStyle
getDropdownItemStyle,
getDropdownItemClass
} = useNav(); } = useNav();
function getDefaultActive(routePath) { function getDefaultActive(routePath) {
@@ -45,8 +36,12 @@ onMounted(() => {
getDefaultActive(route.path); getDefaultActive(route.path);
}); });
nextTick(() => {
menuRef.value?.handleResize();
});
watch( watch(
() => route.path, () => [route.path, usePermissionStoreHook().wholeMenus],
() => { () => {
getDefaultActive(route.path); getDefaultActive(route.path);
} }
@@ -77,7 +72,7 @@ watch(
:is="useRenderIcon(route.meta && toRaw(route.meta.icon))" :is="useRenderIcon(route.meta && toRaw(route.meta.icon))"
/> />
</div> </div>
<span class="select-none">{{ transformI18n(route.meta.title) }}</span> <span class="select-none">{{ route.meta.title }}</span>
<FontIcon <FontIcon
v-if="route.meta.extraIcon" v-if="route.meta.extraIcon"
width="30px" width="30px"
@@ -94,42 +89,13 @@ watch(
<Search /> <Search />
<!-- 通知 --> <!-- 通知 -->
<Notice id="header-notice" /> <Notice id="header-notice" />
<!-- 全屏 -->
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
<!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click">
<globalization
class="navbar-bg-hover w-[40px] h-[48px] p-[11px] cursor-pointer outline-none"
/>
<template #dropdown>
<el-dropdown-menu class="translation">
<el-dropdown-item
:style="getDropdownItemStyle(locale, 'zh')"
:class="['dark:!text-white', getDropdownItemClass(locale, 'zh')]"
@click="translationCh"
>
<span class="check-zh" v-show="locale === 'zh'">
<IconifyIconOffline icon="check" />
</span>
简体中文
</el-dropdown-item>
<el-dropdown-item
:style="getDropdownItemStyle(locale, 'en')"
:class="['dark:!text-white', getDropdownItemClass(locale, 'en')]"
@click="translationEn"
>
<span class="check-en" v-show="locale === 'en'">
<IconifyIconOffline icon="check" />
</span>
English
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<!-- 退出登录 --> <!-- 退出登录 -->
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover"> <span class="el-dropdown-link navbar-bg-hover select-none">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" /> <img
src="https://avatars.githubusercontent.com/u/44761321?v=4"
:style="avatarsStyle"
/>
<p v-if="username" class="dark:text-white">{{ username }}</p> <p v-if="username" class="dark:text-white">{{ username }}</p>
</span> </span>
<template #dropdown> <template #dropdown>
@@ -139,14 +105,14 @@ watch(
icon="logout-circle-r-line" icon="logout-circle-r-line"
style="margin: 5px" style="margin: 5px"
/> />
{{ t("buttons.hsLoginOut") }} 退出系统
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
<span <span
class="el-icon-setting navbar-bg-hover" class="set-icon navbar-bg-hover"
:title="t('buttons.hssystemSet')" title="打开项目配置"
@click="onPanel" @click="onPanel"
> >
<IconifyIconOffline icon="setting" /> <IconifyIconOffline icon="setting" />
@@ -156,22 +122,6 @@ watch(
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.translation {
::v-deep(.el-dropdown-menu__item) {
padding: 5px 40px;
}
.check-zh {
position: absolute;
left: 20px;
}
.check-en {
position: absolute;
left: 20px;
}
}
.logout { .logout {
max-width: 120px; max-width: 120px;

View File

@@ -1,9 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import path from "path"; import path from "path";
import { childrenType } from "../../types"; import { childrenType } from "../../types";
import { useNav } from "/@/layout/hooks/useNav"; import { useNav } from "@/layout/hooks/useNav";
import { transformI18n } from "/@/plugins/i18n"; import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
import { ref, toRaw, PropType, nextTick, computed, CSSProperties } from "vue"; import { ref, toRaw, PropType, nextTick, computed, CSSProperties } from "vue";
const { layout, isCollapse } = useNav(); const { layout, isCollapse } = useNav();
@@ -164,7 +163,7 @@ function resolvePath(routePath) {
:style="getDivStyle" :style="getDivStyle"
> >
<span :style="getMenuTextStyle"> <span :style="getMenuTextStyle">
{{ transformI18n(onlyOneChild.meta.title) }} {{ onlyOneChild.meta.title }}
</span> </span>
</div> </div>
<div <div
@@ -174,13 +173,13 @@ function resolvePath(routePath) {
:style="getDivStyle" :style="getDivStyle"
> >
<span :style="getMenuTextStyle"> <span :style="getMenuTextStyle">
{{ transformI18n(onlyOneChild.meta.title) }} {{ onlyOneChild.meta.title }}
</span> </span>
</div> </div>
<template #title> <template #title>
<div :style="getDivStyle"> <div :style="getDivStyle">
<span v-if="layout === 'horizontal'"> <span v-if="layout === 'horizontal'">
{{ transformI18n(onlyOneChild.meta.title) }} {{ onlyOneChild.meta.title }}
</span> </span>
<el-tooltip <el-tooltip
v-else v-else
@@ -189,14 +188,14 @@ function resolvePath(routePath) {
:disabled="!onlyOneChild.showTooltip" :disabled="!onlyOneChild.showTooltip"
> >
<template #content> <template #content>
{{ transformI18n(onlyOneChild.meta.title) }} {{ onlyOneChild.meta.title }}
</template> </template>
<span <span
ref="menuTextRef" ref="menuTextRef"
:style="getMenuTextStyle" :style="getMenuTextStyle"
@mouseover="hoverMenu(onlyOneChild)" @mouseover="hoverMenu(onlyOneChild)"
> >
{{ transformI18n(onlyOneChild.meta.title) }} {{ onlyOneChild.meta.title }}
</span> </span>
</el-tooltip> </el-tooltip>
<FontIcon <FontIcon
@@ -220,7 +219,7 @@ function resolvePath(routePath) {
/> />
</div> </div>
<span v-if="layout === 'horizontal'"> <span v-if="layout === 'horizontal'">
{{ transformI18n(props.item.meta.title) }} {{ props.item.meta.title }}
</span> </span>
<el-tooltip <el-tooltip
v-else v-else
@@ -229,7 +228,7 @@ function resolvePath(routePath) {
:disabled="!isCollapse || !props.item.showTooltip" :disabled="!isCollapse || !props.item.showTooltip"
> >
<template #content> <template #content>
{{ transformI18n(props.item.meta.title) }} {{ props.item.meta.title }}
</template> </template>
<div <div
ref="menuTextRef" ref="menuTextRef"
@@ -237,7 +236,7 @@ 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.title }}
</span> </span>
</div> </div>
</el-tooltip> </el-tooltip>

View File

@@ -1,15 +1,15 @@
<script setup lang="ts"> <script setup lang="ts">
import Logo from "./logo.vue"; import Logo from "./logo.vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { emitter } from "/@/utils/mitt"; import { emitter } from "@/utils/mitt";
import SidebarItem from "./sidebarItem.vue"; import SidebarItem from "./sidebarItem.vue";
import leftCollapse from "./leftCollapse.vue"; import leftCollapse from "./leftCollapse.vue";
import type { StorageConfigs } from "/#/index"; import type { StorageConfigs } from "/#/index";
import { useNav } from "/@/layout/hooks/useNav"; import { useNav } from "@/layout/hooks/useNav";
import { storageLocal } from "@pureadmin/utils"; import { storageLocal } from "@pureadmin/utils";
import { ref, computed, watch, onBeforeMount } from "vue"; import { ref, computed, watch, onBeforeMount } from "vue";
import { findRouteByPath, getParentPaths } from "/@/router/utils"; import { findRouteByPath, getParentPaths } from "@/router/utils";
import { usePermissionStoreHook } from "/@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";
const route = useRoute(); const route = useRoute();
const showLogo = ref( const showLogo = ref(
@@ -27,7 +27,7 @@ const menuData = computed(() => {
: usePermissionStoreHook().wholeMenus; : usePermissionStoreHook().wholeMenus;
}); });
function getSubMenuData(path) { function getSubMenuData(path: string) {
// path的上级路由组成的数组 // path的上级路由组成的数组
const parentPathArr = getParentPaths( const parentPathArr = getParentPaths(
path, path,
@@ -41,6 +41,7 @@ function getSubMenuData(path) {
if (!parenetRoute?.children) return; if (!parenetRoute?.children) return;
subMenuData.value = parenetRoute?.children; subMenuData.value = parenetRoute?.children;
} }
getSubMenuData(route.path); getSubMenuData(route.path);
onBeforeMount(() => { onBeforeMount(() => {
@@ -50,7 +51,7 @@ onBeforeMount(() => {
}); });
watch( watch(
() => route.path, () => [route.path, usePermissionStoreHook().wholeMenus],
() => { () => {
getSubMenuData(route.path); getSubMenuData(route.path);
menuSelect(route.path, routers); menuSelect(route.path, routers);

View File

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

View File

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

View File

@@ -1,5 +1,4 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { ref, unref, onMounted, nextTick } from "vue"; import { ref, unref, onMounted, nextTick } from "vue";
@@ -7,7 +6,6 @@ defineOptions({
name: "FrameView" name: "FrameView"
}); });
const { t } = useI18n();
const loading = ref(true); const loading = ref(true);
const currentRoute = useRoute(); const currentRoute = useRoute();
const frameSrc = ref<string>(""); const frameSrc = ref<string>("");
@@ -45,11 +43,7 @@ onMounted(() => {
</script> </script>
<template> <template>
<div <div class="frame" v-loading="loading" element-loading-text="加载中...">
class="frame"
v-loading="loading"
:element-loading-text="t('status.hsLoad')"
>
<iframe :src="frameSrc" class="frame-iframe" ref="frameRef" /> <iframe :src="frameSrc" class="frame-iframe" ref="frameRef" />
</div> </div>
</template> </template>

View File

@@ -1,11 +1,11 @@
import { ref } from "vue"; import { ref } from "vue";
import { getConfig } from "/@/config"; import { getConfig } from "@/config";
import { find } from "lodash-unified"; import { find } from "lodash-unified";
import { useLayout } from "./useLayout"; import { useLayout } from "./useLayout";
import { themeColorsType } from "../types"; import { themeColorsType } from "../types";
import { TinyColor } from "@ctrl/tinycolor"; import { TinyColor } from "@ctrl/tinycolor";
import { useGlobal } from "@pureadmin/utils"; import { useGlobal } from "@pureadmin/utils";
import { useEpThemeStoreHook } from "/@/store/modules/epTheme"; import { useEpThemeStoreHook } from "@/store/modules/epTheme";
import { import {
darken, darken,
lighten, lighten,
@@ -69,7 +69,7 @@ export function useDataThemeChange() {
return new TinyColor(color).shade(10).toString(); return new TinyColor(color).shade(10).toString();
}; };
/** 设置ep主题色 */ /** 设置 `element-plus` 主题色 */
const setEpThemeColor = (color: string) => { const setEpThemeColor = (color: string) => {
useEpThemeStoreHook().setEpThemeColor(color); useEpThemeStoreHook().setEpThemeColor(color);
body.style.setProperty("--el-color-primary-active", shadeBgColor(color)); body.style.setProperty("--el-color-primary-active", shadeBgColor(color));

View File

@@ -1,8 +1,7 @@
import { computed } from "vue"; import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { routerArrays } from "../types"; import { routerArrays } from "../types";
import { useGlobal } from "@pureadmin/utils"; import { useGlobal } from "@pureadmin/utils";
import { useMultiTagsStore } from "/@/store/modules/multiTags"; import { useMultiTagsStore } from "@/store/modules/multiTags";
export function useLayout() { export function useLayout() {
const { $storage, $config } = useGlobal<GlobalPropertiesApi>(); const { $storage, $config } = useGlobal<GlobalPropertiesApi>();
@@ -15,11 +14,6 @@ export function useLayout() {
) { ) {
$storage.tags = routerArrays; $storage.tags = routerArrays;
} }
/** 国际化 */
if (!$storage.locale) {
$storage.locale = { locale: $config?.Locale ?? "zh" };
useI18n().locale.value = $config?.Locale ?? "zh";
}
/** 导航 */ /** 导航 */
if (!$storage.layout) { if (!$storage.layout) {
$storage.layout = { $storage.layout = {

View File

@@ -1,45 +1,27 @@
import { computed } from "vue"; import { computed } from "vue";
import { router } from "/@/router"; import { getConfig } from "@/config";
import { getConfig } from "/@/config"; import { emitter } from "@/utils/mitt";
import { useRouter } from "vue-router";
import { emitter } from "/@/utils/mitt";
import { routeMetaType } from "../types"; import { routeMetaType } from "../types";
import type { StorageConfigs } from "/#/index"; import { useGlobal } from "@pureadmin/utils";
import { routerArrays } from "/@/layout/types"; import { useRouter, useRoute } from "vue-router";
import { transformI18n } from "/@/plugins/i18n"; import { router, remainingPaths } from "@/router";
import { useAppStoreHook } from "/@/store/modules/app"; import { useAppStoreHook } from "@/store/modules/app";
import { remainingPaths, resetRouter } from "/@/router"; import { useUserStoreHook } from "@/store/modules/user";
import { storageSession, useGlobal } from "@pureadmin/utils";
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
const errorInfo = "当前路由配置不正确,请检查配置"; const errorInfo = "当前路由配置不正确,请检查配置";
export function useNav() { export function useNav() {
const route = useRoute();
const pureApp = useAppStoreHook(); const pureApp = useAppStoreHook();
const routers = useRouter().options.routes; const routers = useRouter().options.routes;
/** 用户名 */ /** 用户名 */
const username: string = const username = computed(() => {
storageSession.getItem<StorageConfigs>("info")?.username; return useUserStoreHook()?.username;
/** 设置国际化选中后的样式 */
const getDropdownItemStyle = computed(() => {
return (locale, t) => {
return {
background: locale === t ? useEpThemeStoreHook().epThemeColor : "",
color: locale === t ? "#f4f4f5" : "#000"
};
};
});
const getDropdownItemClass = computed(() => {
return (locale, t) => {
return locale === t ? "" : "dark:hover:!text-primary";
};
}); });
const avatarsStyle = computed(() => { const avatarsStyle = computed(() => {
return username ? { marginRight: "10px" } : ""; return username.value ? { marginRight: "10px" } : "";
}); });
const isCollapse = computed(() => { const isCollapse = computed(() => {
@@ -62,16 +44,13 @@ export function useNav() {
/** 动态title */ /** 动态title */
function changeTitle(meta: routeMetaType) { function changeTitle(meta: routeMetaType) {
const Title = getConfig().Title; const Title = getConfig().Title;
if (Title) document.title = `${transformI18n(meta.title)} | ${Title}`; if (Title) document.title = `${meta.title} | ${Title}`;
else document.title = transformI18n(meta.title); else document.title = meta.title;
} }
/** 退出登录 */ /** 退出登录 */
function logout() { function logout() {
useMultiTagsStoreHook().handleTags("equal", [...routerArrays]); useUserStoreHook().logOut();
storageSession.removeItem("info");
router.push("/login");
resetRouter();
} }
function backHome() { function backHome() {
@@ -136,6 +115,7 @@ export function useNav() {
} }
return { return {
route,
title, title,
device, device,
layout, layout,
@@ -152,8 +132,6 @@ export function useNav() {
isCollapse, isCollapse,
pureApp, pureApp,
username, username,
avatarsStyle, avatarsStyle
getDropdownItemStyle,
getDropdownItemClass
}; };
} }

View File

@@ -13,21 +13,15 @@ import { isEqual } from "lodash-unified";
import type { StorageConfigs } from "/#/index"; import type { StorageConfigs } from "/#/index";
import { useEventListener } from "@vueuse/core"; import { useEventListener } from "@vueuse/core";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { transformI18n, $t } from "/@/plugins/i18n"; import { useSettingStoreHook } from "@/store/modules/settings";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags"; import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { storageLocal, toggleClass, hasClass } from "@pureadmin/utils"; import { storageLocal, toggleClass, hasClass } from "@pureadmin/utils";
import close from "/@/assets/svg/close.svg?component";
import refresh from "/@/assets/svg/refresh.svg?component";
import closeAll from "/@/assets/svg/close_all.svg?component";
import closeLeft from "/@/assets/svg/close_left.svg?component";
import closeOther from "/@/assets/svg/close_other.svg?component";
import closeRight from "/@/assets/svg/close_right.svg?component";
export function useTags() { export function useTags() {
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const instance = getCurrentInstance(); const instance = getCurrentInstance();
const pureSetting = useSettingStoreHook();
const buttonTop = ref(0); const buttonTop = ref(0);
const buttonLeft = ref(0); const buttonLeft = ref(0);
@@ -53,46 +47,60 @@ export function useTags() {
const tagsViews = reactive<Array<tagsViewsType>>([ const tagsViews = reactive<Array<tagsViewsType>>([
{ {
icon: refresh, icon: "refresh-right",
text: $t("buttons.hsreload"), text: "重新加载",
divided: false, divided: false,
disabled: false, disabled: false,
show: true show: true
}, },
{ {
icon: close, icon: "close",
text: $t("buttons.hscloseCurrentTab"), text: "关闭当前标签页",
divided: false, divided: false,
disabled: multiTags.value.length > 1 ? false : true, disabled: multiTags.value.length > 1 ? false : true,
show: true show: true
}, },
{ {
icon: closeLeft, icon: "close-left-tags",
text: $t("buttons.hscloseLeftTabs"), text: "关闭左侧标签页",
divided: true, divided: true,
disabled: multiTags.value.length > 1 ? false : true, disabled: multiTags.value.length > 1 ? false : true,
show: true show: true
}, },
{ {
icon: closeRight, icon: "close-right-tags",
text: $t("buttons.hscloseRightTabs"), text: "关闭右侧标签页",
divided: false, divided: false,
disabled: multiTags.value.length > 1 ? false : true, disabled: multiTags.value.length > 1 ? false : true,
show: true show: true
}, },
{ {
icon: closeOther, icon: "close-other-tags",
text: $t("buttons.hscloseOtherTabs"), text: "关闭其他标签页",
divided: true, divided: true,
disabled: multiTags.value.length > 2 ? false : true, disabled: multiTags.value.length > 2 ? false : true,
show: true show: true
}, },
{ {
icon: closeAll, icon: "close-all-tags",
text: $t("buttons.hscloseAllTabs"), text: "关闭全部标签页",
divided: false, divided: false,
disabled: multiTags.value.length > 1 ? false : true, disabled: multiTags.value.length > 1 ? false : true,
show: true show: true
},
{
icon: "fullscreen",
text: "整体页面全屏",
divided: true,
disabled: false,
show: true
},
{
icon: "fullscreen",
text: "内容区全屏",
divided: false,
disabled: false,
show: true
} }
]); ]);
@@ -172,6 +180,12 @@ export function useTags() {
} }
} }
function onContentFullScreen() {
pureSetting.hiddenSideBar
? pureSetting.changeSetting({ key: "hiddenSideBar", value: false })
: pureSetting.changeSetting({ key: "hiddenSideBar", value: true });
}
onMounted(() => { onMounted(() => {
if (!showModel.value) { if (!showModel.value) {
const configure = storageLocal.getItem<StorageConfigs>( const configure = storageLocal.getItem<StorageConfigs>(
@@ -201,6 +215,7 @@ export function useTags() {
buttonTop, buttonTop,
buttonLeft, buttonLeft,
translateX, translateX,
pureSetting,
activeIndex, activeIndex,
getTabStyle, getTabStyle,
iconIsActive, iconIsActive,
@@ -208,11 +223,10 @@ export function useTags() {
currentSelect, currentSelect,
scheduleIsActive, scheduleIsActive,
getContextMenuStyle, getContextMenuStyle,
$t,
closeMenu, closeMenu,
onMounted, onMounted,
onMouseenter, onMouseenter,
onMouseleave, onMouseleave,
transformI18n onContentFullScreen
}; };
} }

View File

@@ -1,37 +0,0 @@
import { useNav } from "./useNav";
import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
import { watch, type Ref } from "vue";
export function useTranslationLang(ref?: Ref) {
const { $storage, changeTitle, handleResize } = useNav();
const { locale, t } = useI18n();
const route = useRoute();
function translationCh() {
$storage.locale = { locale: "zh" };
locale.value = "zh";
ref && handleResize(ref.value);
}
function translationEn() {
$storage.locale = { locale: "en" };
locale.value = "en";
ref && handleResize(ref.value);
}
watch(
() => locale.value,
() => {
changeTitle(route.meta);
}
);
return {
t,
route,
locale,
translationCh,
translationEn
};
}

View File

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

View File

@@ -20,7 +20,6 @@ const themeColors = {
menuHover: "#4091f7", menuHover: "#4091f7",
subMenuBg: "#0f0303", subMenuBg: "#0f0303",
subMenuActiveBg: "#4091f7", subMenuActiveBg: "#4091f7",
navTextColor: "#fff",
menuText: "rgb(254 254 254 / 65%)", menuText: "rgb(254 254 254 / 65%)",
sidebarLogo: "#002140", sidebarLogo: "#002140",
menuTitleHover: "#fff", menuTitleHover: "#fff",
@@ -33,7 +32,6 @@ const themeColors = {
menuHover: "#e0ebf6", menuHover: "#e0ebf6",
subMenuBg: "#fff", subMenuBg: "#fff",
subMenuActiveBg: "#e0ebf6", subMenuActiveBg: "#e0ebf6",
navTextColor: "#7a80b4",
menuText: "#7a80b4", menuText: "#7a80b4",
sidebarLogo: "#fff", sidebarLogo: "#fff",
menuTitleHover: "#000", menuTitleHover: "#000",
@@ -46,7 +44,6 @@ const themeColors = {
menuHover: "#e13c39", menuHover: "#e13c39",
subMenuBg: "#000", subMenuBg: "#000",
subMenuActiveBg: "#e13c39", subMenuActiveBg: "#e13c39",
navTextColor: "#red",
menuText: "rgb(254 254 254 / 65.1%)", menuText: "rgb(254 254 254 / 65.1%)",
sidebarLogo: "#42090c", sidebarLogo: "#42090c",
menuTitleHover: "#fff", menuTitleHover: "#fff",
@@ -59,7 +56,6 @@ const themeColors = {
menuHover: "#e85f33", menuHover: "#e85f33",
subMenuBg: "#0f0603", subMenuBg: "#0f0603",
subMenuActiveBg: "#e85f33", subMenuActiveBg: "#e85f33",
navTextColor: "#fff",
menuText: "rgb(254 254 254 / 65%)", menuText: "rgb(254 254 254 / 65%)",
sidebarLogo: "#441708", sidebarLogo: "#441708",
menuTitleHover: "#fff", menuTitleHover: "#fff",
@@ -72,7 +68,6 @@ const themeColors = {
menuHover: "#f6da4d", menuHover: "#f6da4d",
subMenuBg: "#0f0603", subMenuBg: "#0f0603",
subMenuActiveBg: "#f6da4d", subMenuActiveBg: "#f6da4d",
navTextColor: "#fff",
menuText: "rgb(254 254 254 / 65%)", menuText: "rgb(254 254 254 / 65%)",
sidebarLogo: "#443b05", sidebarLogo: "#443b05",
menuTitleHover: "#fff", menuTitleHover: "#fff",
@@ -85,7 +80,6 @@ const themeColors = {
menuHover: "#59bfc1", menuHover: "#59bfc1",
subMenuBg: "#000", subMenuBg: "#000",
subMenuActiveBg: "#59bfc1", subMenuActiveBg: "#59bfc1",
navTextColor: "#7a80b4",
menuText: "#7a80b4", menuText: "#7a80b4",
sidebarLogo: "#053434", sidebarLogo: "#053434",
menuTitleHover: "#fff", menuTitleHover: "#fff",
@@ -98,7 +92,6 @@ const themeColors = {
menuHover: "#60ac80", menuHover: "#60ac80",
subMenuBg: "#000", subMenuBg: "#000",
subMenuActiveBg: "#60ac80", subMenuActiveBg: "#60ac80",
navTextColor: "#7a80b4",
menuText: "#7a80b4", menuText: "#7a80b4",
sidebarLogo: "#112f21", sidebarLogo: "#112f21",
menuTitleHover: "#fff", menuTitleHover: "#fff",
@@ -111,7 +104,6 @@ const themeColors = {
menuHover: "#d84493", menuHover: "#d84493",
subMenuBg: "#000", subMenuBg: "#000",
subMenuActiveBg: "#d84493", subMenuActiveBg: "#d84493",
navTextColor: "#7a80b4",
menuText: "#7a80b4", menuText: "#7a80b4",
sidebarLogo: "#3f0d29", sidebarLogo: "#3f0d29",
menuTitleHover: "#fff", menuTitleHover: "#fff",
@@ -124,7 +116,6 @@ const themeColors = {
menuHover: "#693ac9", menuHover: "#693ac9",
subMenuBg: "#000", subMenuBg: "#000",
subMenuActiveBg: "#693ac9", subMenuActiveBg: "#693ac9",
navTextColor: "#7a80b4",
menuText: "#7a80b4", menuText: "#7a80b4",
sidebarLogo: "#1f0c38", sidebarLogo: "#1f0c38",
menuTitleHover: "#fff", menuTitleHover: "#fff",
@@ -147,7 +138,6 @@ export const genScssMultipleScopeVars = (): MultipleScopeVarsItem[] => {
$menuHover: ${themeColors[key].menuHover} !default; $menuHover: ${themeColors[key].menuHover} !default;
$subMenuBg: ${themeColors[key].subMenuBg} !default; $subMenuBg: ${themeColors[key].subMenuBg} !default;
$subMenuActiveBg: ${themeColors[key].subMenuActiveBg} !default; $subMenuActiveBg: ${themeColors[key].subMenuActiveBg} !default;
$navTextColor: ${themeColors[key].navTextColor} !default;
$menuText: ${themeColors[key].menuText} !default; $menuText: ${themeColors[key].menuText} !default;
$sidebarLogo: ${themeColors[key].sidebarLogo} !default; $sidebarLogo: ${themeColors[key].sidebarLogo} !default;
$menuTitleHover: ${themeColors[key].menuTitleHover} !default; $menuTitleHover: ${themeColors[key].menuTitleHover} !default;

View File

@@ -1,10 +1,9 @@
import { Component } from "vue";
export const routerArrays: Array<RouteConfigs> = [ export const routerArrays: Array<RouteConfigs> = [
{ {
path: "/welcome", path: "/welcome",
parentPath: "/", parentPath: "/",
meta: { meta: {
title: "menus.hshome", title: "首页",
icon: "home-filled" icon: "home-filled"
} }
} }
@@ -15,7 +14,7 @@ export type routeMetaType = {
icon?: string; icon?: string;
showLink?: boolean; showLink?: boolean;
savedPosition?: boolean; savedPosition?: boolean;
authority?: Array<string>; auths?: Array<string>;
}; };
export type RouteConfigs = { export type RouteConfigs = {
@@ -33,7 +32,7 @@ export type multiTagsType = {
}; };
export type tagsViewsType = { export type tagsViewsType = {
icon: Component; icon: string;
text: string; text: string;
divided: boolean; divided: boolean;
disabled: boolean; disabled: boolean;

View File

@@ -1,14 +1,13 @@
import App from "./App.vue"; import App from "./App.vue";
import router from "./router"; import router from "./router";
import { setupStore } from "/@/store"; import { setupStore } from "@/store";
import ElementPlus from "element-plus"; import ElementPlus from "element-plus";
import { getServerConfig } from "./config"; import { getServerConfig } from "./config";
import { createApp, Directive } from "vue"; import { createApp, Directive } from "vue";
import { useI18n } from "../src/plugins/i18n";
import { MotionPlugin } from "@vueuse/motion"; import { MotionPlugin } from "@vueuse/motion";
// import { useEcharts } from "/@/plugins/echarts"; // import { useEcharts } from "@/plugins/echarts";
// import { useTable } from "../src/plugins/vxe-table"; // import { useTable } from "@/plugins/vxe-table";
import { injectResponsiveStorage } from "/@/utils/responsive"; import { injectResponsiveStorage } from "@/utils/responsive";
// import Table from "@pureadmin/table"; // import Table from "@pureadmin/table";
// import PureDescriptions from "@pureadmin/descriptions"; // import PureDescriptions from "@pureadmin/descriptions";
@@ -29,7 +28,7 @@ import "./assets/iconfont/iconfont.css";
const app = createApp(App); const app = createApp(App);
// 自定义指令 // 自定义指令
import * as directives from "/@/directives"; import * as directives from "@/directives";
Object.keys(directives).forEach(key => { Object.keys(directives).forEach(key => {
app.directive(key, (directives as { [key: string]: Directive })[key]); app.directive(key, (directives as { [key: string]: Directive })[key]);
}); });
@@ -44,12 +43,16 @@ app.component("IconifyIconOffline", IconifyIconOffline);
app.component("IconifyIconOnline", IconifyIconOnline); app.component("IconifyIconOnline", IconifyIconOnline);
app.component("FontIcon", FontIcon); app.component("FontIcon", FontIcon);
// 全局注册按钮级别权限组件
import { Auth } from "@/components/ReAuth";
app.component("Auth", Auth);
getServerConfig(app).then(async config => { getServerConfig(app).then(async config => {
app.use(router); app.use(router);
await router.isReady(); await router.isReady();
injectResponsiveStorage(app, config); injectResponsiveStorage(app, config);
setupStore(app); setupStore(app);
app.use(MotionPlugin).use(useI18n).use(ElementPlus); app.use(MotionPlugin).use(ElementPlus);
// .use(useEcharts); // .use(useEcharts);
// .use(Table); // .use(Table);
// .use(PureDescriptions); // .use(PureDescriptions);

View File

@@ -1,74 +0,0 @@
// 多组件库的国际化和本地项目国际化兼容
import { App, WritableComputedRef } from "vue";
import type { StorageConfigs } from "/#/index";
import { storageLocal } from "@pureadmin/utils";
import { type I18n, createI18n } from "vue-i18n";
// element-plus国际化
import enLocale from "element-plus/lib/locale/lang/en";
import zhLocale from "element-plus/lib/locale/lang/zh-cn";
function siphonI18n(prefix = "zh-CN") {
return Object.fromEntries(
Object.entries(
import.meta.glob("../../locales/*.y(a)?ml", { eager: true })
).map(([key, value]: any) => {
const matched = key.match(/([A-Za-z0-9-_]+)\./i)[1];
return [matched, value.default];
})
)[prefix];
}
export const localesConfigs = {
zh: {
...siphonI18n("zh-CN"),
...zhLocale
},
en: {
...siphonI18n("en"),
...enLocale
}
};
/**
* 国际化转换工具函数自动读取根目录locales文件夹下文件进行国际化匹配
* @param message message
* @returns 转化后的message
*/
export function transformI18n(message: any = "") {
if (!message) {
return "";
}
// 处理存储动态路由的title,格式 {zh:"",en:""}
if (typeof message === "object") {
const locale: string | WritableComputedRef<string> | any =
i18n.global.locale;
return message[locale?.value];
}
const key = message.match(/(\S*)\./)?.[1];
if (key && Object.keys(siphonI18n("zh-CN")).includes(key)) {
return i18n.global.t.call(i18n.global.locale, message);
} else if (!key && Object.keys(siphonI18n("zh-CN")).includes(message)) {
// 兼容非嵌套形式的国际化写法
return i18n.global.t.call(i18n.global.locale, message);
} else {
return message;
}
}
// 此函数只是配合i18n Ally插件来进行国际化智能提示并无实际意义只对提示起作用如果不需要国际化可删除
export const $t = (key: string) => key;
export const i18n: I18n = createI18n({
legacy: false,
locale:
storageLocal.getItem<StorageConfigs>("responsive-locale")?.locale ?? "zh",
fallbackLocale: "en",
messages: localesConfigs
});
export function useI18n(app: App) {
app.use(i18n);
}

View File

@@ -1,11 +1,7 @@
import "xe-utils"; import "xe-utils";
import "./index.scss"; import "./index.scss";
import XEUtils from "xe-utils"; import { App } from "vue";
import { App, unref } from "vue";
import { i18n } from "/@/plugins/i18n";
import "font-awesome/css/font-awesome.min.css"; import "font-awesome/css/font-awesome.min.css";
import zh from "vxe-table/lib/locale/lang/zh-CN";
import en from "vxe-table/lib/locale/lang/en-US";
import { import {
// 核心 // 核心
@@ -60,18 +56,6 @@ VXETable.setup({
}, },
input: { input: {
clearable: true clearable: true
},
i18n: (key, args) => {
return unref(i18n.global.locale) === "zh"
? XEUtils.toFormatString(XEUtils.get(zh, key), args)
: XEUtils.toFormatString(XEUtils.get(en, key), args);
},
translate(key) {
const NAMESPACED = ["el.", "buttons."];
if (key && NAMESPACED.findIndex(v => key.includes(v)) !== -1) {
return i18n.global.t.call(i18n.global.locale, key);
}
return key;
} }
}); });

View File

@@ -1,11 +1,10 @@
import { getConfig } from "/@/config"; import { getConfig } from "@/config";
import { toRouteType } from "./types"; import { toRouteType } from "./types";
import NProgress from "/@/utils/progress"; import NProgress from "@/utils/progress";
import { findIndex } from "lodash-unified"; import { findIndex } from "lodash-unified";
import type { StorageConfigs } from "/#/index"; import { sessionKey, type DataInfo } from "@/utils/auth";
import { transformI18n } from "/@/plugins/i18n"; import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags"; import { usePermissionStoreHook } from "@/store/modules/permission";
import { usePermissionStoreHook } from "/@/store/modules/permission";
import { import {
Router, Router,
createRouter, createRouter,
@@ -15,6 +14,7 @@ import {
import { import {
ascending, ascending,
initRouter, initRouter,
isOneOfArray,
getHistoryMode, getHistoryMode,
findRouteByPath, findRouteByPath,
handleAliveRoute, handleAliveRoute,
@@ -32,25 +32,25 @@ import homeRouter from "./modules/home";
import errorRouter from "./modules/error"; import errorRouter from "./modules/error";
import remainingRouter from "./modules/remaining"; import remainingRouter from "./modules/remaining";
// 原始静态路由(未做任何处理) /** 原始静态路由(未做任何处理) */
const routes = [homeRouter, errorRouter]; const routes = [homeRouter, errorRouter];
// 导出处理后的静态路由(三级及以上的路由全部拍成二级) /** 导出处理后的静态路由(三级及以上的路由全部拍成二级) */
export const constantRoutes: Array<RouteRecordRaw> = formatTwoStageRoutes( export const constantRoutes: Array<RouteRecordRaw> = formatTwoStageRoutes(
formatFlatteningRoutes(buildHierarchyTree(ascending(routes))) formatFlatteningRoutes(buildHierarchyTree(ascending(routes)))
); );
// 用于渲染菜单,保持原始层级 /** 用于渲染菜单,保持原始层级 */
export const constantMenus: Array<RouteComponent> = ascending(routes).concat( export const constantMenus: Array<RouteComponent> = ascending(routes).concat(
...remainingRouter ...remainingRouter
); );
// 不参与菜单的路由 /** 不参与菜单的路由 */
export const remainingPaths = Object.keys(remainingRouter).map(v => { export const remainingPaths = Object.keys(remainingRouter).map(v => {
return remainingRouter[v].path; return remainingRouter[v].path;
}); });
// 创建路由实例 /** 创建路由实例 */
export const router: Router = createRouter({ export const router: Router = createRouter({
history: getHistoryMode(), history: getHistoryMode(),
routes: constantRoutes.concat(...(remainingRouter as any)), routes: constantRoutes.concat(...(remainingRouter as any)),
@@ -70,7 +70,7 @@ export const router: Router = createRouter({
} }
}); });
// 重置路由 /** 重置路由 */
export function resetRouter() { export function resetRouter() {
router.getRoutes().forEach(route => { router.getRoutes().forEach(route => {
const { name, meta } = route; const { name, meta } = route;
@@ -84,7 +84,7 @@ export function resetRouter() {
usePermissionStoreHook().clearAllCachePage(); usePermissionStoreHook().clearAllCachePage();
} }
// 路由白名单 /** 路由白名单 */
const whiteList = ["/login"]; const whiteList = ["/login"];
router.beforeEach((to: toRouteType, _from, next) => { router.beforeEach((to: toRouteType, _from, next) => {
@@ -96,30 +96,41 @@ router.beforeEach((to: toRouteType, _from, next) => {
handleAliveRoute(newMatched); handleAliveRoute(newMatched);
} }
} }
const name = storageSession.getItem<StorageConfigs>("info"); const userInfo = storageSession.getItem<DataInfo<number>>(sessionKey);
NProgress.start(); NProgress.start();
const externalLink = isUrl(to?.name as string); const externalLink = isUrl(to?.name as string);
if (!externalLink) if (!externalLink) {
to.matched.some(item => { to.matched.some(item => {
if (!item.meta.title) return ""; if (!item.meta.title) return "";
const Title = getConfig().Title; const Title = getConfig().Title;
if (Title) if (Title) document.title = `${item.meta.title} | ${Title}`;
document.title = `${transformI18n(item.meta.title)} | ${Title}`; else document.title = item.meta.title as string;
else document.title = transformI18n(item.meta.title);
}); });
if (name) { }
/** 如果已经登录并存在登录信息后不能跳转到路由白名单,而是继续保持在当前页面 */
function toCorrectRoute() {
whiteList.includes(to.fullPath) ? next(_from.fullPath) : next();
}
if (userInfo) {
// 无权限跳转403页面
if (to.meta?.roles && !isOneOfArray(to.meta?.roles, userInfo?.roles)) {
next({ path: "/error/403" });
}
if (_from?.name) { if (_from?.name) {
// name为超链接 // name为超链接
if (externalLink) { if (externalLink) {
openLink(to?.name as string); openLink(to?.name as string);
NProgress.done(); NProgress.done();
} else { } else {
next(); toCorrectRoute();
} }
} else { } else {
// 刷新 // 刷新
if (usePermissionStoreHook().wholeMenus.length === 0) if (
initRouter(name.username).then((router: Router) => { usePermissionStoreHook().wholeMenus.length === 0 &&
to.path !== "/login"
)
initRouter().then((router: Router) => {
if (!useMultiTagsStoreHook().getMultiTagsCache) { if (!useMultiTagsStoreHook().getMultiTagsCache) {
const { path } = to; const { path } = to;
const index = findIndex(remainingRouter, v => { const index = findIndex(remainingRouter, v => {
@@ -141,7 +152,7 @@ router.beforeEach((to: toRouteType, _from, next) => {
} }
router.push(to.fullPath); router.push(to.fullPath);
}); });
next(); toCorrectRoute();
} }
} else { } else {
if (to.path !== "/login") { if (to.path !== "/login") {

View File

@@ -1,4 +1,3 @@
import { $t } from "/@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import type { RouteConfigsTable } from "/#/index";
const errorRouter: RouteConfigsTable = { const errorRouter: RouteConfigsTable = {
@@ -6,32 +5,32 @@ const errorRouter: RouteConfigsTable = {
redirect: "/error/403", redirect: "/error/403",
meta: { meta: {
icon: "information-line", icon: "information-line",
title: $t("menus.hserror"), title: "异常页面",
rank: 9 rank: 9
}, },
children: [ children: [
{ {
path: "/error/403", path: "/error/403",
name: "403", name: "403",
component: () => import("/@/views/error/403.vue"), component: () => import("@/views/error/403.vue"),
meta: { meta: {
title: $t("menus.hsfourZeroOne") title: "403"
} }
}, },
{ {
path: "/error/404", path: "/error/404",
name: "404", name: "404",
component: () => import("/@/views/error/404.vue"), component: () => import("@/views/error/404.vue"),
meta: { meta: {
title: $t("menus.hsfourZeroFour") title: "404"
} }
}, },
{ {
path: "/error/500", path: "/error/500",
name: "500", name: "500",
component: () => import("/@/views/error/500.vue"), component: () => import("@/views/error/500.vue"),
meta: { meta: {
title: $t("menus.hsFive") title: "500"
} }
} }
] ]

View File

@@ -1,6 +1,5 @@
import { $t } from "/@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import type { RouteConfigsTable } from "/#/index";
const Layout = () => import("/@/layout/index.vue"); const Layout = () => import("@/layout/index.vue");
const homeRouter: RouteConfigsTable = { const homeRouter: RouteConfigsTable = {
path: "/", path: "/",
@@ -9,16 +8,16 @@ const homeRouter: RouteConfigsTable = {
redirect: "/welcome", redirect: "/welcome",
meta: { meta: {
icon: "home-filled", icon: "home-filled",
title: $t("menus.hshome"), title: "首页",
rank: 0 rank: 0
}, },
children: [ children: [
{ {
path: "/welcome", path: "/welcome",
name: "Welcome", name: "Welcome",
component: () => import("/@/views/welcome/index.vue"), component: () => import("@/views/welcome/index.vue"),
meta: { meta: {
title: $t("menus.hshome") title: "首页"
} }
} }
] ]

View File

@@ -1,14 +1,13 @@
import { $t } from "/@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import type { RouteConfigsTable } from "/#/index";
const Layout = () => import("/@/layout/index.vue"); const Layout = () => import("@/layout/index.vue");
const remainingRouter: Array<RouteConfigsTable> = [ const remainingRouter: Array<RouteConfigsTable> = [
{ {
path: "/login", path: "/login",
name: "Login", name: "Login",
component: () => import("/@/views/login/index.vue"), component: () => import("@/views/login/index.vue"),
meta: { meta: {
title: $t("menus.hslogin"), title: "登录",
showLink: false, showLink: false,
rank: 101 rank: 101
} }
@@ -18,7 +17,7 @@ const remainingRouter: Array<RouteConfigsTable> = [
component: Layout, component: Layout,
meta: { meta: {
icon: "home-filled", icon: "home-filled",
title: $t("menus.hshome"), title: "首页",
showLink: false, showLink: false,
rank: 104 rank: 104
}, },
@@ -26,7 +25,7 @@ const remainingRouter: Array<RouteConfigsTable> = [
{ {
path: "/redirect/:path(.*)", path: "/redirect/:path(.*)",
name: "Redirect", name: "Redirect",
component: () => import("/@/layout/redirect.vue") component: () => import("@/layout/redirect.vue")
} }
] ]
} }

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
import { store } from "/@/store"; import { store } from "@/store";
import { appType } from "./types"; import { appType } from "./types";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { getConfig } from "/@/config"; import { getConfig } from "@/config";
import type { StorageConfigs } from "/#/index"; import type { StorageConfigs } from "/#/index";
import { deviceDetection, storageLocal } from "@pureadmin/utils"; import { deviceDetection, storageLocal } from "@pureadmin/utils";

View File

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

View File

@@ -1,8 +1,8 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { store } from "/@/store"; import { store } from "@/store";
import { isEqual } from "lodash-unified"; import { isEqual } from "lodash-unified";
import type { StorageConfigs } from "/#/index"; import type { StorageConfigs } from "/#/index";
import { routerArrays } from "/@/layout/types"; import { routerArrays } from "@/layout/types";
import { multiType, positionType } from "./types"; import { multiType, positionType } from "./types";
import { isUrl, storageLocal } from "@pureadmin/utils"; import { isUrl, storageLocal } from "@pureadmin/utils";

View File

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

View File

@@ -1,7 +1,7 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { store } from "/@/store"; import { store } from "@/store";
import { setType } from "./types"; import { setType } from "./types";
import { getConfig } from "/@/config"; import { getConfig } from "@/config";
export const useSettingStore = defineStore({ export const useSettingStore = defineStore({
id: "pure-setting", id: "pure-setting",

View File

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

View File

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

View File

@@ -36,17 +36,12 @@ html.dark {
.arrow-left, .arrow-left,
.arrow-right { .arrow-right {
box-shadow: none; box-shadow: none;
border-right: 1px solid $border-style;
} }
.arrow-right { .arrow-right {
border-left: 1px solid $border-style; border-left: 1px solid $border-style;
} }
.arrow-left,
.arrow-right,
.right-button li {
border-right: 1px solid $border-style;
}
} }
/* vxe-table */ /* vxe-table */

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,14 +3,6 @@
@tailwind utilities; @tailwind utilities;
@layer components { @layer components {
.bg-dark {
@apply bg-bg_color;
}
.wh-full {
@apply w-full h-full;
}
.flex-c { .flex-c {
@apply flex justify-center items-center; @apply flex justify-center items-center;
} }

View File

@@ -1,5 +0,0 @@
### 注意
- [文档](https://pure-admin-utils-docs.vercel.app/)
- [npm](https://www.npmjs.com/package/@pureadmin/utils)
- vue-pure-admin 从 3.3.0 版本之后(不包括 3.3.0 版本),大部分工具和 hooks 都集成到了[@pureadmin/utils](https://pure-admin-utils-docs.vercel.app/)

View File

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

View File

@@ -1,25 +0,0 @@
## 用法
### Get 请求
```
import { http } from "/@/utils/http";
// params传参
http.request('get', '/xxx', { params: param });
// url拼接传参
http.request('get', '/xxx?message=' + msg);
```
### Post 请求
```
import { http } from "/@/utils/http";
// params传参
http.request('post', '/xxx', { params: param });
// data传参
http.request('post', '/xxx', { data: param });
```

View File

@@ -1,36 +1,32 @@
import Axios, { AxiosInstance, AxiosRequestConfig } from "axios"; import Axios, {
AxiosInstance,
AxiosRequestConfig,
CustomParamsSerializer
} from "axios";
import { import {
resultType,
PureHttpError, PureHttpError,
RequestMethods, RequestMethods,
PureHttpResponse, PureHttpResponse,
PureHttpRequestConfig PureHttpRequestConfig
} from "./types.d"; } from "./types.d";
import qs from "qs"; import { stringify } from "qs";
import NProgress from "../progress"; import NProgress from "../progress";
// import { loadEnv } from "@build/index"; import { getToken, formatToken } from "@/utils/auth";
import { getToken } from "/@/utils/auth"; import { useUserStoreHook } from "@/store/modules/user";
import { useUserStoreHook } from "/@/store/modules/user";
// 加载环境变量 VITE_PROXY_DOMAIN开发环境 VITE_PROXY_DOMAIN_REAL打包后的线上环境
// const { VITE_PROXY_DOMAIN, VITE_PROXY_DOMAIN_REAL } = loadEnv();
// 相关配置请参考www.axios-js.com/zh-cn/docs/#axios-request-config-1 // 相关配置请参考www.axios-js.com/zh-cn/docs/#axios-request-config-1
const defaultConfig: AxiosRequestConfig = { const defaultConfig: AxiosRequestConfig = {
// baseURL: // 请求超时时间
// process.env.NODE_ENV === "production"
// ? VITE_PROXY_DOMAIN_REAL
// : VITE_PROXY_DOMAIN,
// 当前使用mock模拟请求将baseURL制空如果你的环境用到了http请求请删除下面的baseURL启用上面的baseURL并将11行、16行代码注释取消
baseURL: "",
timeout: 10000, timeout: 10000,
headers: { headers: {
Accept: "application/json, text/plain, */*", Accept: "application/json, text/plain, */*",
"Content-Type": "application/json", "Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest" "X-Requested-With": "XMLHttpRequest"
}, },
// 数组格式参数序列化 // 数组格式参数序列化https://github.com/axios/axios/issues/5142
paramsSerializer: params => qs.stringify(params, { indices: false }) paramsSerializer: {
serialize: stringify as unknown as CustomParamsSerializer
}
}; };
class PureHttp { class PureHttp {
@@ -38,48 +34,80 @@ class PureHttp {
this.httpInterceptorsRequest(); this.httpInterceptorsRequest();
this.httpInterceptorsResponse(); this.httpInterceptorsResponse();
} }
// 初始化配置对象
/** token过期后暂存待执行的请求 */
private static requests = [];
/** 防止重复刷新token */
private static isRefreshing = false;
/** 初始化配置对象 */
private static initConfig: PureHttpRequestConfig = {}; private static initConfig: PureHttpRequestConfig = {};
// 保存当前Axios实例对象 /** 保存当前Axios实例对象 */
private static axiosInstance: AxiosInstance = Axios.create(defaultConfig); private static axiosInstance: AxiosInstance = Axios.create(defaultConfig);
// 请求拦截 /** 重连原始请求 */
private static retryOriginalRequest(config: PureHttpRequestConfig) {
return new Promise(resolve => {
PureHttp.requests.push((token: string) => {
config.headers["Authorization"] = formatToken(token);
resolve(config);
});
});
}
/** 请求拦截 */
private httpInterceptorsRequest(): void { private httpInterceptorsRequest(): void {
PureHttp.axiosInstance.interceptors.request.use( PureHttp.axiosInstance.interceptors.request.use(
(config: PureHttpRequestConfig) => { async (config: PureHttpRequestConfig) => {
const $config = config;
// 开启进度条动画 // 开启进度条动画
NProgress.start(); NProgress.start();
// 优先判断post/get等方法是否传入回掉否则执行初始化设置等回掉 // 优先判断post/get等方法是否传入回掉否则执行初始化设置等回掉
if (typeof config.beforeRequestCallback === "function") { if (typeof config.beforeRequestCallback === "function") {
config.beforeRequestCallback($config); config.beforeRequestCallback(config);
return $config; return config;
} }
if (PureHttp.initConfig.beforeRequestCallback) { if (PureHttp.initConfig.beforeRequestCallback) {
PureHttp.initConfig.beforeRequestCallback($config); PureHttp.initConfig.beforeRequestCallback(config);
return $config; return config;
}
const token = getToken();
if (token) {
const data = JSON.parse(token);
const now = new Date().getTime();
const expired = parseInt(data.expires) - now <= 0;
if (expired) {
// token过期刷新
useUserStoreHook()
.refreshToken(data)
.then((res: resultType) => {
config.headers["Authorization"] = "Bearer " + res.accessToken;
return $config;
});
} else {
config.headers["Authorization"] = "Bearer " + data.accessToken;
return $config;
}
} else {
return $config;
} }
/** 请求白名单放置一些不需要token的接口通过设置请求白名单防止token过期后再请求造成的死循环问题 */
const whiteList = ["/refreshToken", "/login"];
return whiteList.some(v => config.url.indexOf(v) > -1)
? config
: new Promise(resolve => {
const data = getToken();
if (data) {
const now = new Date().getTime();
const expired = parseInt(data.expires) - now <= 0;
if (expired) {
if (!PureHttp.isRefreshing) {
PureHttp.isRefreshing = true;
// token过期刷新
useUserStoreHook()
.handRefreshToken({ refreshToken: data.refreshToken })
.then(res => {
const token = res.data.accessToken;
config.headers["Authorization"] = formatToken(token);
PureHttp.requests.forEach(cb => cb(token));
PureHttp.requests = [];
})
.finally(() => {
PureHttp.isRefreshing = false;
});
}
resolve(PureHttp.retryOriginalRequest(config));
} else {
config.headers["Authorization"] = formatToken(
data.accessToken
);
resolve(config);
}
} else {
resolve(config);
}
});
}, },
error => { error => {
return Promise.reject(error); return Promise.reject(error);
@@ -87,7 +115,7 @@ class PureHttp {
); );
} }
// 响应拦截 /** 响应拦截 */
private httpInterceptorsResponse(): void { private httpInterceptorsResponse(): void {
const instance = PureHttp.axiosInstance; const instance = PureHttp.axiosInstance;
instance.interceptors.response.use( instance.interceptors.response.use(
@@ -117,7 +145,7 @@ class PureHttp {
); );
} }
// 通用请求工具函数 /** 通用请求工具函数 */
public request<T>( public request<T>(
method: RequestMethods, method: RequestMethods,
url: string, url: string,
@@ -144,7 +172,7 @@ class PureHttp {
}); });
} }
// 单独抽离的post工具函数 /** 单独抽离的post工具函数 */
public post<T, P>( public post<T, P>(
url: string, url: string,
params?: T, params?: T,
@@ -153,7 +181,7 @@ class PureHttp {
return this.request<P>("post", url, params, config); return this.request<P>("post", url, params, config);
} }
// 单独抽离的get工具函数 /** 单独抽离的get工具函数 */
public get<T, P>( public get<T, P>(
url: string, url: string,
params?: T, params?: T,

View File

@@ -1,17 +1,13 @@
// 响应式storage // 响应式storage
import { App } from "vue"; import { App } from "vue";
import Storage from "responsive-storage"; import Storage from "responsive-storage";
import { routerArrays } from "/@/layout/types"; import { routerArrays } from "@/layout/types";
const nameSpace = "responsive-"; const nameSpace = "responsive-";
export const injectResponsiveStorage = (app: App, config: ServerConfigs) => { export const injectResponsiveStorage = (app: App, config: ServerConfigs) => {
const configObj = Object.assign( const configObj = Object.assign(
{ {
// 国际化 默认中文zh
locale: Storage.getData("locale", nameSpace) ?? {
locale: config.Locale ?? "zh"
},
// layout模式以及主题 // layout模式以及主题
layout: Storage.getData("layout", nameSpace) ?? { layout: Storage.getData("layout", nameSpace) ?? {
layout: config.Layout ?? "vertical", layout: config.Layout ?? "vertical",

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import noAccess from "/@/assets/status/403.svg?component"; import noAccess from "@/assets/status/403.svg?component";
defineOptions({ defineOptions({
name: "403" name: "403"
@@ -11,7 +11,7 @@ defineOptions({
<noAccess /> <noAccess />
<div class="ml-12"> <div class="ml-12">
<p <p
class="font-medium text-4xl mb-4" class="font-medium text-4xl mb-4 dark:text-white"
v-motion v-motion
:initial="{ :initial="{
opacity: 0, opacity: 0,

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import noExist from "/@/assets/status/404.svg?component"; import noExist from "@/assets/status/404.svg?component";
defineOptions({ defineOptions({
name: "404" name: "404"
@@ -11,7 +11,7 @@ defineOptions({
<noExist /> <noExist />
<div class="ml-12"> <div class="ml-12">
<p <p
class="font-medium text-4xl mb-4" class="font-medium text-4xl mb-4 dark:text-white"
v-motion v-motion
:initial="{ :initial="{
opacity: 0, opacity: 0,

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import noServer from "/@/assets/status/500.svg?component"; import noServer from "@/assets/status/500.svg?component";
defineOptions({ defineOptions({
name: "500" name: "500"
@@ -11,7 +11,7 @@ defineOptions({
<noServer /> <noServer />
<div class="ml-12"> <div class="ml-12">
<p <p
class="font-medium text-4xl mb-4" class="font-medium text-4xl mb-4 dark:text-white"
v-motion v-motion
:initial="{ :initial="{
opacity: 0, opacity: 0,

View File

@@ -1,24 +1,20 @@
<script setup lang="ts"> <script setup lang="ts">
import { useI18n } from "vue-i18n";
import Motion from "./utils/motion"; import Motion from "./utils/motion";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { loginRules } from "./utils/rule"; import { loginRules } from "./utils/rule";
import { ref, reactive, toRaw } from "vue"; import { initRouter } from "@/router/utils";
import { initRouter } from "/@/router/utils"; import { useNav } from "@/layout/hooks/useNav";
import { useNav } from "/@/layout/hooks/useNav";
import { message } from "@pureadmin/components"; import { message } from "@pureadmin/components";
import type { FormInstance } from "element-plus"; import type { FormInstance } from "element-plus";
import { storageSession } from "@pureadmin/utils"; import { useLayout } from "@/layout/hooks/useLayout";
import { $t, transformI18n } from "/@/plugins/i18n"; import { useUserStoreHook } from "@/store/modules/user";
import { useLayout } from "/@/layout/hooks/useLayout";
import { bg, avatar, illustration } from "./utils/static"; import { bg, avatar, illustration } from "./utils/static";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks"; import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { useTranslationLang } from "/@/layout/hooks/useTranslationLang"; import { ref, reactive, toRaw, onMounted, onBeforeUnmount } from "vue";
import { useDataThemeChange } from "/@/layout/hooks/useDataThemeChange"; import { useDataThemeChange } from "@/layout/hooks/useDataThemeChange";
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";
import globalization from "/@/assets/svg/globalization.svg?component";
defineOptions({ defineOptions({
name: "Login" name: "Login"
@@ -30,10 +26,9 @@ const ruleFormRef = ref<FormInstance>();
const { initStorage } = useLayout(); const { initStorage } = useLayout();
initStorage(); initStorage();
const { t } = useI18n();
const { dataTheme, dataThemeChange } = useDataThemeChange(); const { dataTheme, dataThemeChange } = useDataThemeChange();
const { title, getDropdownItemStyle, getDropdownItemClass } = useNav(); dataThemeChange();
const { locale, translationCh, translationEn } = useTranslationLang(); const { title } = useNav();
const ruleForm = reactive({ const ruleForm = reactive({
username: "admin", username: "admin",
@@ -45,17 +40,17 @@ const onLogin = async (formEl: FormInstance | undefined) => {
if (!formEl) return; if (!formEl) return;
await formEl.validate((valid, fields) => { await formEl.validate((valid, fields) => {
if (valid) { if (valid) {
// 模拟请求,需根据实际开发进行修改 useUserStoreHook()
setTimeout(() => { .loginByUsername({ username: ruleForm.username, password: "admin123" })
loading.value = false; .then(res => {
storageSession.setItem("info", { if (res.success) {
username: "admin", // 获取后端路由
accessToken: "eyJhbGciOiJIUzUxMiJ9.test" initRouter().then(() => {
message.success("登录成功");
router.push("/");
});
}
}); });
initRouter("admin").then(() => {});
message.success("登录成功");
router.push("/");
}, 2000);
} else { } else {
loading.value = false; loading.value = false;
return fields; return fields;
@@ -63,11 +58,24 @@ const onLogin = async (formEl: FormInstance | undefined) => {
}); });
}; };
dataThemeChange(); /** 使用公共函数,避免`removeEventListener`失效 */
function onkeypress({ code }: KeyboardEvent) {
if (code === "Enter") {
onLogin(ruleFormRef.value);
}
}
onMounted(() => {
window.document.addEventListener("keypress", onkeypress);
});
onBeforeUnmount(() => {
window.document.removeEventListener("keypress", onkeypress);
});
</script> </script>
<template> <template>
<div class="wh-full select-none"> <div class="select-none">
<img :src="bg" class="wave" /> <img :src="bg" class="wave" />
<div class="flex-c absolute right-5 top-3"> <div class="flex-c absolute right-5 top-3">
<!-- 主题 --> <!-- 主题 -->
@@ -78,38 +86,6 @@ dataThemeChange();
:inactive-icon="darkIcon" :inactive-icon="darkIcon"
@change="dataThemeChange" @change="dataThemeChange"
/> />
<!-- 国际化 -->
<el-dropdown trigger="click">
<globalization
class="hover:text-primary hover:!bg-[transparent] w-[20px] h-[20px] ml-1.5 cursor-pointer outline-none duration-300"
/>
<template #dropdown>
<el-dropdown-menu class="translation">
<el-dropdown-item
:style="getDropdownItemStyle(locale, 'zh')"
:class="['dark:!text-white', getDropdownItemClass(locale, 'zh')]"
@click="translationCh"
>
<IconifyIconOffline
class="check-zh"
v-show="locale === 'zh'"
icon="check"
/>
简体中文
</el-dropdown-item>
<el-dropdown-item
:style="getDropdownItemStyle(locale, 'en')"
:class="['dark:!text-white', getDropdownItemClass(locale, 'en')]"
@click="translationEn"
>
<span class="check-en" v-show="locale === 'en'">
<IconifyIconOffline icon="check" />
</span>
English
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div> </div>
<div class="login-container"> <div class="login-container">
<div class="img"> <div class="img">
@@ -127,14 +103,13 @@ dataThemeChange();
:model="ruleForm" :model="ruleForm"
:rules="loginRules" :rules="loginRules"
size="large" size="large"
@keyup.enter="onLogin(ruleFormRef)"
> >
<Motion :delay="100"> <Motion :delay="100">
<el-form-item <el-form-item
:rules="[ :rules="[
{ {
required: true, required: true,
message: transformI18n($t('login.usernameReg')), message: '请输入账号',
trigger: 'blur' trigger: 'blur'
} }
]" ]"
@@ -143,7 +118,7 @@ dataThemeChange();
<el-input <el-input
clearable clearable
v-model="ruleForm.username" v-model="ruleForm.username"
:placeholder="t('login.username')" placeholder="账号"
:prefix-icon="useRenderIcon('user')" :prefix-icon="useRenderIcon('user')"
/> />
</el-form-item> </el-form-item>
@@ -155,7 +130,7 @@ dataThemeChange();
clearable clearable
show-password show-password
v-model="ruleForm.password" v-model="ruleForm.password"
:placeholder="t('login.password')" placeholder="密码"
:prefix-icon="useRenderIcon('lock')" :prefix-icon="useRenderIcon('lock')"
/> />
</el-form-item> </el-form-item>
@@ -169,7 +144,7 @@ dataThemeChange();
:loading="loading" :loading="loading"
@click="onLogin(ruleFormRef)" @click="onLogin(ruleFormRef)"
> >
{{ t("login.login") }} 登录
</el-button> </el-button>
</Motion> </Motion>
</el-form> </el-form>
@@ -180,27 +155,11 @@ dataThemeChange();
</template> </template>
<style scoped> <style scoped>
@import url("/@/style/login.css"); @import url("@/style/login.css");
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
:deep(.el-input-group__append, .el-input-group__prepend) { :deep(.el-input-group__append, .el-input-group__prepend) {
padding: 0; padding: 0;
} }
.translation {
::v-deep(.el-dropdown-menu__item) {
padding: 5px 40px;
}
.check-zh {
position: absolute;
left: 20px;
}
.check-en {
position: absolute;
left: 20px;
}
}
</style> </style>

View File

@@ -1,6 +1,5 @@
import { reactive } from "vue"; import { reactive } from "vue";
import type { FormRules } from "element-plus"; import type { FormRules } from "element-plus";
import { $t, transformI18n } from "/@/plugins/i18n";
/** 密码正则密码格式应为8-18位数字、字母、符号的任意两种组合 */ /** 密码正则密码格式应为8-18位数字、字母、符号的任意两种组合 */
export const REGEXP_PWD = export const REGEXP_PWD =
@@ -12,9 +11,11 @@ const loginRules = reactive(<FormRules>{
{ {
validator: (rule, value, callback) => { validator: (rule, value, callback) => {
if (value === "") { if (value === "") {
callback(new Error(transformI18n($t("login.passwordReg")))); callback(new Error("请输入密码"));
} else if (!REGEXP_PWD.test(value)) { } else if (!REGEXP_PWD.test(value)) {
callback(new Error(transformI18n($t("login.passwordRuleReg")))); callback(
new Error("密码格式应为8-18位数字、字母、符号的任意两种组合")
);
} else { } else {
callback(); callback();
} }

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