Compare commits

..

49 Commits

Author SHA1 Message Date
xiaoxian521
504b45783f release: update 3.6.3 2022-11-01 16:18:12 +08:00
xiaoxian521
27bc135bd2 fix: 修复当token过期后,如果页面有多个请求会重复刷新token 2022-11-01 16:06:22 +08:00
xiaoxian521
4d91d2017c perf: 优化代码 2022-10-31 10:22:01 +08:00
xiaoxian521
523c979488 docs: update 2022-10-28 15:57:11 +08:00
xiaoxian521
d2bba801d9 chore: update 2022-10-28 14:07:47 +08:00
一万
ceb1ec6e6d feat: add danmaku demo (#362)
* feat: add danmaku demo

* fix: /@/改为@/

* fix: update
2022-10-28 12:27:59 +08:00
xiaoxian521
aa83ea83fa feat: 静态资源分类打包 2022-10-27 15:51:59 +08:00
xiaoxian521
4a7d5d6573 style: update 2022-10-27 14:40:43 +08:00
xiaoxian521
b69db2ff2c fix: 修复tailwindcss最新版新增的collapse属性与平台class类名冲突 2022-10-27 14:33:36 +08:00
xiaoxian521
c288d438dc release: update 3.6.2 2022-10-27 12:58:44 +08:00
xiaoxian521
94f72cd6d9 refactor: 使用@/别名替换/@/别名 2022-10-27 12:43:01 +08:00
xiaoxian521
307944cdb5 release: update 3.6.1 2022-10-27 02:42:33 +08:00
xiaoxian521
f5a75356df feat: 打包构建添加可选 gzipbrotli 压缩模式 2022-10-27 02:35:56 +08:00
xiaoxian521
54ebd19875 feat: 添加打包是否启动cdn替换本地库配置,默认false不启动 2022-10-26 19:44:44 +08:00
xiaoxian521
303fc25af3 fix: 修复路由中父级name不应和子级name重复,会造成重定向跳转404问题 2022-10-26 11:09:33 +08:00
xiaoxian521
a455072d7a chore: update axios latest 2022-10-26 00:16:34 +08:00
xiaoxian521
2bbf04b191 chore: update 2022-10-25 17:36:35 +08:00
xiaoxian521
e4c33a7d22 fix: 修复title过长显示样式问题 2022-10-25 15:50:18 +08:00
xiaoxian521
6765ce8644 workflow: update 2022-10-25 13:33:31 +08:00
xiaoxian521
2d639c8f48 release: update 3.6.0 2022-10-25 13:07:18 +08:00
RealityBoy
6ef4cf9fb6 refactor: permission (#357)
* refactor: permission

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

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

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

* chore: update

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

* fix: update
2022-09-17 11:52:46 +08:00
xiaoxian521
4d1a9ea8e7 chore: update 2022-09-15 14:41:46 +08:00
xiaoxian521
af25f6ca6e chore: update extensions.json 2022-09-13 17:55:46 +08:00
xiaoxian521
2231b88f6d chore: update 2022-09-12 23:10:59 +08:00
xiaoxian521
685d7beb11 chore: 优化样式 2022-09-11 19:46:53 +08:00
xiaoxian521
f14889ef56 perf: 使用/** */替换//注释,对编辑器的智能提示更友好 2022-09-11 16:46:01 +08:00
xiaoxian521
fafbdc7c69 perf: 从tailwind.css中移除不常用的@apply 2022-09-11 11:32:10 +08:00
178 changed files with 3616 additions and 2259 deletions

View File

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

View File

@@ -12,3 +12,11 @@ VITE_PROXY_DOMAIN_REAL = ""
# 是否为打包后的文件提供传统浏览器兼容性支持 支持 true 不支持 false
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

@@ -4,7 +4,7 @@ permissions:
on:
push:
branches:
- gitee
- master
jobs:
deploy:
concurrency: ci-${{ github.ref }}

View File

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

View File

@@ -1,3 +1,63 @@
# 3.6.3 (2022-11-01)
### 🎫 Feat
- Static resource classification and packaging
- Add danmaku component `demo`
### 🐞 Bug fixes
- Fix the `collapse` property added in the latest version of `tailwindcss` conflicts with the platform `class` class name
- Fix that when the `token` expires, if the page has multiple requests, the `token` will be refreshed repeatedly
# 3.6.2 (2022-10-27)
### ✔️ refactor
- Replace `/@/` alias with `@/` alias
# 3.6.1 (2022-10-27)
### 🎫 Feat
- Add whether to start `cdn` for packaging to replace the local library configuration, the default `false` does not start
- Added optional `gzip` and `brotli` compression modes for packaging builds
### 🐞 Bug fixes
- Fix `title` too long display style problem
- Fix the parent `name` in the route should not be repeated with the child `name`, which will cause redirection to jump `404` problem
### 🍏 Perf
- Upgrade `axios` to the latest version
# 3.6.0 (2022-10-25)
### 🎫 Feat
- Add file download `demo`
- Add typewriter component `demo`
- Added `json` editor `demo`
### ✔️ refactor
- Refactor the permission module, adopt the most commonly used `RBAC` (Role-Based Access List): role-based permission control (User -> Role -> Permission), and update the page permission and button permission `demo` example, button Permissions support three operation modes (judging permissions in component mode, judging permissions in function mode, and judging permissions in instruction mode)
### 🐞 Bug fixes
- Fixed the theme not being emptied when clearing the cache and returning to the login page
- Fix `menu` display problem in production environment in `horizontal` mode
- Fixed the problem that the `mix` mixed mode navigation might not be displayed in the left menu of the production environment
- After the `token` expires, calling the refresh `token` interface will cause an infinite loop
### 🍏 Perf
- Removed uncommon `@apply` from `tailwind.css`
- Replace `//` comments with `/** */`, which is more friendly to the editor's intellisense
- Optimize the login enter event
- Simplified some functions, eliminated useless functions, and optimized page loading speed
# 3.5.0 (2022-9-10)
### 🎫 Feat

View File

@@ -1,3 +1,63 @@
# 3.6.3 (2022-11-01)
### 🎫 Feat
- Static resource classification and packaging
- Add danmaku component `demo`
### 🐞 Bug fixes
- Fix the `collapse` property added in the latest version of `tailwindcss` conflicts with the platform `class` class name
- Fix that when the `token` expires, if the page has multiple requests, the `token` will be refreshed repeatedly
# 3.6.2 (2022-10-27)
### ✔️ refactor
- Replace `/@/` alias with `@/` alias
# 3.6.1 (2022-10-27)
### 🎫 Feat
- Add whether to start `cdn` for packaging to replace the local library configuration, the default `false` does not start
- Added optional `gzip` and `brotli` compression modes for packaging builds
### 🐞 Bug fixes
- Fix `title` too long display style problem
- Fix the parent `name` in the route should not be repeated with the child `name`, which will cause redirection to jump `404` problem
### 🍏 Perf
- Upgrade `axios` to the latest version
# 3.6.0 (2022-10-25)
### 🎫 Feat
- Add file download `demo`
- Add typewriter component `demo`
- Added `json` editor `demo`
### ✔️ refactor
- Refactor the permission module, adopt the most commonly used `RBAC` (Role-Based Access List): role-based permission control (User -> Role -> Permission), and update the page permission and button permission `demo` example, button Permissions support three operation modes (judging permissions in component mode, judging permissions in function mode, and judging permissions in instruction mode)
### 🐞 Bug fixes
- Fixed the theme not being emptied when clearing the cache and returning to the login page
- Fix `menu` display problem in production environment in `horizontal` mode
- Fixed the problem that the `mix` mixed mode navigation might not be displayed in the left menu of the production environment
- After the `token` expires, calling the refresh `token` interface will cause an infinite loop
### 🍏 Perf
- Removed uncommon `@apply` from `tailwind.css`
- Replace `//` comments with `/** */`, which is more friendly to the editor's intellisense
- Optimize the login enter event
- Simplified some functions, eliminated useless functions, and optimized page loading speed
# 3.5.0 (2022-9-10)
### 🎫 Feat

View File

@@ -1,3 +1,63 @@
# 3.6.3 (2022-11-01)
### 🎫 Feat
- 静态资源分类打包
- 添加弹幕组件 `demo`
### 🐞 Bug fixes
- 修复 `tailwindcss` 最新版新增的 `collapse` 属性与平台 `class` 类名冲突
- 修复当 `token` 过期后,如果页面有多个请求会重复刷新 `token`
# 3.6.2 (2022-10-27)
### ✔️ refactor
- 使用`@/`别名替换`/@/`别名
# 3.6.1 (2022-10-27)
### 🎫 Feat
- 添加打包是否启动`cdn`替换本地库配置,默认`false`不启动
- 添加打包构建可选`gzip``brotli`压缩模式
### 🐞 Bug fixes
- 修复`title`过长显示样式问题
- 修复路由中父级`name`不应和子级`name`重复,会造成重定向跳转`404`问题
### 🍏 Perf
- 升级`axios`至最新版
# 3.6.0 (2022-10-25)
### 🎫 Feat
- 添加文件下载`demo`
- 添加打字机组件`demo`
- 添加`json`编辑器`demo`
### ✔️ refactor
- 重构权限模块,采用目前最常用的`RBAC`Role-Based Access List: 基于角色的权限控制( 用户 -> 角色 -> 权限 ),并更新页面权限和按钮权限`demo`示例,按钮权限支持三种操作模式(组件方式判断权限、函数方式判断权限、指令方式判断权限)
### 🐞 Bug fixes
- 修复清空缓存并返回登录页时未清空主题
- 修复`horizontal`模式下`menu`在生产环境显示问题
- 修复`mix`混合模式导航在生产环境左侧菜单一定机率不显示的问题
- `token`过期后调用刷新`token`接口会无限循环的问题
### 🍏 Perf
-`tailwind.css`中移除不常用的`@apply`
- 使用`/** */`替换`//`注释,对编辑器的智能提示更友好
- 优化登录回车事件
- 简化了一些函数,剔除了无用函数,优化了页面加载速度
# 3.5.0 (2022-9-10)
### 🎫 Feat

View File

@@ -21,9 +21,10 @@ vue-pure-admin is a free and open source middle and back-end template. Using the
- [Click me to view foreign document site 1](https://xiaoxian521.github.io/pure-admin-doc)
- [Click me to view foreign document site 2](https://pure-admin-doc.vercel.app)
## Thin
## Thin version (offering non-internationalized and internationalized versions)
- [Click Watch Thin](https://github.com/xiaoxian521/pure-admin-thin)
- [Click me to view the non-internationalized version](https://github.com/xiaoxian521/pure-admin-thin)
- [Click me to view Internationalization version](https://github.com/xiaoxian521/pure-admin-thin/tree/i18n)
## Tauri

View File

@@ -21,9 +21,10 @@ vue-pure-admin 是一个免费开源的中后台模版。使用了最新的`vue3
- [点我查看国外文档站 1](https://xiaoxian521.github.io/pure-admin-doc)
- [点我查看国外文档站 2](https://pure-admin-doc.vercel.app)
## 精简版
## 精简版(提供非国际化、国际化两个版本选择)
- [点我查看精简版](https://github.com/xiaoxian521/pure-admin-thin)
- [点我查看非国际化精简版](https://github.com/xiaoxian521/pure-admin-thin)
- [点我查看国际化精简版](https://github.com/xiaoxian521/pure-admin-thin/tree/i18n)
## Tauri 版

67
build/cdn.ts Normal file
View File

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

63
build/compress.ts Normal file
View File

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

View File

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

View File

@@ -1,3 +1,4 @@
import { cdn } from "./cdn";
import { resolve } from "path";
import vue from "@vitejs/plugin-vue";
import { viteBuildInfo } from "./info";
@@ -5,14 +6,20 @@ import svgLoader from "vite-svg-loader";
import legacy from "@vitejs/plugin-legacy";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { viteMockServe } from "vite-plugin-mock";
import { configCompressPlugin } from "./compress";
import VueI18n from "@intlify/vite-plugin-vue-i18n";
import { visualizer } from "rollup-plugin-visualizer";
import removeConsole from "vite-plugin-remove-console";
import themePreprocessorPlugin from "@pureadmin/theme";
import { genScssMultipleScopeVars } from "/@/layout/theme";
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 lifecycle = process.env.npm_lifecycle_event;
return [
@@ -25,6 +32,8 @@ export function getPluginsList(command, VITE_LEGACY) {
}),
// jsx、tsx语法支持
vueJsx(),
VITE_CDN ? cdn : null,
configCompressPlugin(VITE_COMPRESSION),
DefineOptions(),
// 线上环境删除console
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),

View File

@@ -36,9 +36,7 @@
border-radius: 50%;
width: 2.5em;
height: 2.5em;
-webkit-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;
}
@@ -48,10 +46,7 @@
margin: 80px auto;
position: relative;
text-indent: -9999em;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
top: 0;
transform: translate(-50%, 0);
@@ -66,7 +61,6 @@
.loader:before {
left: -3.5em;
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s;
}
@@ -74,18 +68,6 @@
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 {
0%,
80%,

View File

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

View File

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

View File

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

View File

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

36
mock/login.ts Normal file
View File

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

View File

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

27
mock/refreshToken.ts Normal file
View File

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

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

View File

@@ -1,6 +1,6 @@
{
"name": "vue-pure-admin",
"version": "3.5.0",
"version": "3.6.3",
"private": true,
"scripts": {
"dev": "NODE_OPTIONS=--max-old-space-size=4096 vite",
@@ -35,21 +35,21 @@
"@pureadmin/components": "^1.1.0",
"@pureadmin/descriptions": "^1.1.0",
"@pureadmin/table": "^1.2.0",
"@pureadmin/utils": "^0.1.1",
"@vueuse/core": "^9.1.1",
"@pureadmin/utils": "^1.1.5",
"@vueuse/core": "^9.4.0",
"@vueuse/motion": "^2.0.0-beta.12",
"@vueuse/shared": "^9.1.1",
"@wangeditor/editor": "^5.1.14",
"@vueuse/shared": "^9.4.0",
"@wangeditor/editor": "^5.1.21",
"@wangeditor/editor-for-vue": "^5.1.12",
"animate.css": "^4.1.1",
"axios": "^0.27.2",
"axios": "^1.1.3",
"china-area-data": "^5.0.1",
"cropperjs": "^1.5.12",
"dayjs": "^1.11.4",
"dayjs": "^1.11.5",
"driver.js": "^0.9.8",
"echarts": "^5.3.3",
"echarts": "^5.4.0",
"el-table-infinite-scroll": "^3.0.1",
"element-plus": "^2.2.16",
"element-plus": "^2.2.18",
"element-resize-detector": "^1.2.3",
"js-cookie": "^3.0.1",
"jsbarcode": "^3.11.5",
@@ -60,32 +60,34 @@
"mockjs": "^1.1.0",
"nprogress": "^0.2.0",
"path": "^0.12.7",
"pinia": "^2.0.21",
"pinia": "^2.0.23",
"qrcode": "^1.5.1",
"qs": "^6.11.0",
"resize-observer-polyfill": "^1.5.1",
"responsive-storage": "^2.1.0",
"sortablejs": "^1.15.0",
"swiper": "^8.3.2",
"swiper": "^8.4.4",
"typeit": "^8.7.0",
"v-contextmenu": "3.0.0",
"vue": "^3.2.39",
"vue": "^3.2.40",
"vue-form-create2": "^1.2.8",
"vue-i18n": "^9.2.2",
"vue-json-pretty": "^2.1.1",
"vue-json-pretty": "^2.2.2",
"vue-pdf-embed": "^1.1.4",
"vue-router": "^4.1.5",
"vue-router": "^4.1.6",
"vue-types": "^4.2.1",
"vue-virtual-scroller": "^2.0.0-alpha.1",
"vue3-danmaku": "^1.0.0",
"vuedraggable": "^4.1.0",
"vxe-table": "^4.3.2",
"xe-utils": "^3.5.6",
"xgplayer": "^2.31.7",
"vxe-table": "^4.3.5",
"xe-utils": "^3.5.7",
"xgplayer": "^2.32.1",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@commitlint/cli": "13.1.0",
"@commitlint/config-conventional": "13.1.0",
"@faker-js/faker": "^7.4.0",
"@faker-js/faker": "^7.5.0",
"@iconify-icons/carbon": "^1.2.8",
"@iconify-icons/ep": "^1.2.7",
"@iconify-icons/fa": "^1.2.3",
@@ -95,7 +97,7 @@
"@iconify-icons/ri": "^1.2.3",
"@iconify-icons/uil": "^1.2.2",
"@iconify/vue": "^3.2.1",
"@intlify/vite-plugin-vue-i18n": "^6.0.1",
"@intlify/vite-plugin-vue-i18n": "^6.0.3",
"@pureadmin/theme": "^2.4.0",
"@types/element-resize-detector": "1.1.3",
"@types/js-cookie": "^3.0.1",
@@ -109,13 +111,13 @@
"@types/sortablejs": "^1.13.0",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"@vitejs/plugin-legacy": "^2.1.0",
"@vitejs/plugin-vue": "^3.1.0",
"@vitejs/plugin-legacy": "^2.2.0",
"@vitejs/plugin-vue": "^3.1.2",
"@vitejs/plugin-vue-jsx": "^2.0.1",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0",
"@vue/runtime-core": "^3.2.39",
"autoprefixer": "^10.4.8",
"@vue/runtime-core": "^3.2.40",
"autoprefixer": "^10.4.12",
"cloc": "^2.10.0",
"cssnano": "^5.1.13",
"eslint": "^8.8.0",
@@ -125,14 +127,14 @@
"husky": "^7.0.4",
"lint-staged": "11.1.2",
"picocolors": "^1.0.0",
"postcss": "^8.4.16",
"postcss": "^8.4.17",
"postcss-html": "^1.5.0",
"postcss-import": "^15.0.0",
"postcss-scss": "^4.0.4",
"postcss-scss": "^4.0.5",
"prettier": "^2.5.1",
"pretty-quick": "3.1.1",
"rimraf": "3.0.2",
"rollup-plugin-visualizer": "^5.8.1",
"rollup-plugin-visualizer": "^5.8.2",
"sass": "^1.53.0",
"sass-loader": "^13.0.2",
"stylelint": "^14.3.0",
@@ -141,16 +143,18 @@
"stylelint-config-recommended": "^6.0.0",
"stylelint-config-standard": "^24.0.0",
"stylelint-order": "^5.0.0",
"tailwindcss": "^3.1.8",
"tailwindcss": "^3.2.1",
"terser": "^5.15.0",
"typescript": "^4.7.4",
"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-remove-console": "^1.1.0",
"vite-svg-loader": "^3.4.0",
"vite-svg-loader": "^3.6.0",
"vue-eslint-parser": "^8.2.0",
"vue-tsc": "^0.40.7"
"vue-tsc": "^0.40.13"
},
"pnpm": {
"peerDependencyRules": {

1896
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

@@ -1,5 +1,5 @@
import { PropType } from "vue";
import { propTypes } from "/@/utils/propTypes";
import { propTypes } from "@/utils/propTypes";
export const countToProps = {
startVal: propTypes.number.def(0),
endVal: propTypes.number.def(2020),

View File

@@ -1,5 +1,5 @@
import { PropType } from "vue";
import { propTypes } from "/@/utils/propTypes";
import { propTypes } from "@/utils/propTypes";
export const reboundProps = {
delay: propTypes.number.def(1),
blur: propTypes.number.def(2),

View File

@@ -1,5 +1,5 @@
import { defineComponent, ref } from "vue";
import { propTypes } from "/@/utils/propTypes";
import { propTypes } from "@/utils/propTypes";
import "./filpper.css";
const props = {

View File

@@ -116,7 +116,8 @@ onMounted(() => {
:disabled="item.disabled"
:style="{
cursor: item.disabled === false ? 'pointer' : 'not-allowed',
color: item.disabled === false ? '' : '#00000040'
color: item.disabled === false ? '' : '#00000040',
background: 'transparent'
}"
@click="onControl(item, key)"
>

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
import { cloneDeep } from "lodash-unified";
import { ref, computed, CSSProperties, toRef, watch } from "vue";
import { IconJson } from "/@/components/ReIcon/data";
import { IconJson } from "@/components/ReIcon/data";
type ParameterCSSProperties = (item?: string) => CSSProperties | undefined;
defineOptions({

View File

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

View File

@@ -2,8 +2,8 @@
import { reactive, getCurrentInstance, onBeforeMount, onUnmounted } from "vue";
import { deviceDetection } from "@pureadmin/utils";
import AMapLoader from "@amap/amap-jsapi-loader";
import { mapJson } from "/@/api/mock";
import car from "/@/assets/car.png";
import { mapJson } from "@/api/mock";
import car from "@/assets/car.png";
export interface MapConfigureInter {
on: Fn;
@@ -92,8 +92,8 @@ onBeforeMount(() => {
// 获取模拟车辆信息
mapJson()
.then(({ info }) => {
let points: object = info.map(v => {
.then(({ data }) => {
let points: object = data.map(v => {
return {
lnglat: [v.lng, v.lat],
...v

View File

@@ -10,7 +10,7 @@ import {
import "./index.scss";
import { cloneDeep } from "lodash-unified";
import { isString } from "@pureadmin/utils";
import { propTypes } from "/@/utils/propTypes";
import { propTypes } from "@/utils/propTypes";
import { IconifyIconOffline } from "../../ReIcon";
import QRCode, { QRCodeRenderersOptions } from "qrcode";

View File

@@ -1,5 +1,5 @@
import { defineComponent, ref, computed, PropType } from "vue";
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
import { IconifyIconOffline } from "../../ReIcon";
export const loadingSvg = `
@@ -117,7 +117,7 @@ export default defineComponent({
<>
<div
{...attrs}
class="w-[99/100] mt-6 p-2 bg-white dark:bg-dark"
class="w-[99/100] mt-6 p-2 bg-bg_color"
v-loading={props.loading}
element-loading-svg={loadingSvg}
element-loading-svg-view-box="-10, -10, 50, 50"

View File

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

View File

@@ -27,7 +27,7 @@ const getConfig = (key?: string): ServerConfigs => {
return config;
};
// 获取项目动态全局配置
/** 获取项目动态全局配置 */
export const getServerConfig = async (app: App): Promise<undefined> => {
app.config.globalProperties.$config = getConfig();
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 elementResizeDetectorMaker 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({
strategy: "scroll"
@@ -14,9 +13,7 @@ export const resize: Directive = {
const width = elem.offsetWidth;
const height = elem.offsetHeight;
if (binding?.instance) {
optimizeFps(() => {
emitter.emit("resize", { detail: { width, height } });
})();
emitter.emit("resize", { detail: { width, height } });
} else {
vnode.el.dispatchEvent(
new CustomEvent("resize", { detail: { width, height } })

View File

@@ -1,2 +1,2 @@
export * from "./permission";
export * from "./auth";
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">
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 { usePermissionStoreHook } from "/@/store/modules/permission";
import { usePermissionStoreHook } from "@/store/modules/permission";
const props = defineProps({
fixedHeader: Boolean

View File

@@ -2,14 +2,11 @@
import Search from "./search/index.vue";
import Notice from "./notice/index.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 { deviceDetection } from "@pureadmin/utils";
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";
import globalization from "@/assets/svg/globalization.svg?component";
const {
layout,
@@ -50,8 +47,6 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
<Search />
<!-- 通知 -->
<Notice id="header-notice" />
<!-- 全屏 -->
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
<!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click">
<globalization
@@ -86,8 +81,11 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
</el-dropdown>
<!-- 退出登录 -->
<el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" />
<span class="el-dropdown-link navbar-bg-hover select-none">
<img
src="https://avatars.githubusercontent.com/u/44761321?v=4"
:style="avatarsStyle"
/>
<p v-if="username" class="dark:text-white">{{ username }}</p>
</span>
<template #dropdown>
@@ -103,7 +101,7 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
</template>
</el-dropdown>
<span
class="el-icon-setting navbar-bg-hover"
class="set-icon navbar-bg-hover"
:title="t('buttons.hssystemSet')"
@click="onPanel"
>
@@ -153,15 +151,6 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
border-radius: 50%;
}
}
.el-icon-setting {
height: 48px;
width: 38px;
padding: 12px;
display: flex;
cursor: pointer;
align-items: center;
}
}
.breadcrumb-container {

View File

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

View File

@@ -17,9 +17,10 @@
</template>
<script lang="ts" setup>
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";
import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
</script>
<style lang="scss" scoped>
.search-footer {
display: flex;

View File

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

View File

@@ -1,9 +1,9 @@
<script lang="ts" setup>
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
import enterOutlined from "/@/assets/svg/enter_outlined.svg?component";
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
const { t } = useI18n();

View File

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

View File

@@ -1,9 +1,9 @@
<script setup lang="ts">
import { isEqual } from "lodash-unified";
import { transformI18n } from "/@/plugins/i18n";
import { transformI18n } from "@/plugins/i18n";
import { ref, watch, onMounted, toRaw } from "vue";
import { getParentPaths, findRouteByPath } from "/@/router/utils";
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
import { getParentPaths, findRouteByPath } from "@/router/utils";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { useRoute, useRouter, RouteLocationMatched } from "vue-router";
const route = useRoute();

View File

@@ -1,15 +1,12 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import Search from "../search/index.vue";
import Notice from "../notice/index.vue";
import { ref, watch, nextTick } from "vue";
import SidebarItem from "./sidebarItem.vue";
import avatars from "/@/assets/avatars.jpg";
import { useNav } from "/@/layout/hooks/useNav";
import screenfull from "../screenfull/index.vue";
import { deviceDetection } from "@pureadmin/utils";
import { useNav } from "@/layout/hooks/useNav";
import { useTranslationLang } from "../../hooks/useTranslationLang";
import { usePermissionStoreHook } from "/@/store/modules/permission";
import globalization from "/@/assets/svg/globalization.svg?component";
import { usePermissionStoreHook } from "@/store/modules/permission";
import globalization from "@/assets/svg/globalization.svg?component";
const menuRef = ref();
@@ -28,6 +25,10 @@ const {
getDropdownItemClass
} = useNav();
nextTick(() => {
menuRef.value?.handleResize();
});
watch(
() => route.path,
() => {
@@ -62,8 +63,6 @@ watch(
<Search />
<!-- 通知 -->
<Notice id="header-notice" />
<!-- 全屏 -->
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
<!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click">
<globalization
@@ -97,7 +96,10 @@ watch(
<!-- 退出登录 -->
<el-dropdown trigger="click">
<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>
</span>
<template #dropdown>
@@ -113,7 +115,7 @@ watch(
</template>
</el-dropdown>
<span
class="el-icon-setting navbar-bg-hover"
class="set-icon navbar-bg-hover"
:title="t('buttons.hssystemSet')"
@click="onPanel"
>

View File

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

View File

@@ -1,17 +1,14 @@
<script setup lang="ts">
import Search from "../search/index.vue";
import Notice from "../notice/index.vue";
import avatars from "/@/assets/avatars.jpg";
import { useNav } from "/@/layout/hooks/useNav";
import { transformI18n } from "/@/plugins/i18n";
import screenfull from "../screenfull/index.vue";
import { deviceDetection } from "@pureadmin/utils";
import { ref, toRaw, watch, onMounted } from "vue";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
import { getParentPaths, findRouteByPath } from "/@/router/utils";
import { useNav } from "@/layout/hooks/useNav";
import { transformI18n } from "@/plugins/i18n";
import { ref, toRaw, watch, onMounted, nextTick } 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";
import { usePermissionStoreHook } from "@/store/modules/permission";
import globalization from "@/assets/svg/globalization.svg?component";
const menuRef = ref();
let defaultActive = ref(null);
@@ -45,8 +42,12 @@ onMounted(() => {
getDefaultActive(route.path);
});
nextTick(() => {
menuRef.value?.handleResize();
});
watch(
() => route.path,
() => [route.path, usePermissionStoreHook().wholeMenus],
() => {
getDefaultActive(route.path);
}
@@ -94,8 +95,6 @@ watch(
<Search />
<!-- 通知 -->
<Notice id="header-notice" />
<!-- 全屏 -->
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
<!-- 国际化 -->
<el-dropdown id="header-translation" trigger="click">
<globalization
@@ -128,8 +127,11 @@ watch(
</el-dropdown>
<!-- 退出登录 -->
<el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" />
<span class="el-dropdown-link navbar-bg-hover select-none">
<img
src="https://avatars.githubusercontent.com/u/44761321?v=4"
:style="avatarsStyle"
/>
<p v-if="username" class="dark:text-white">{{ username }}</p>
</span>
<template #dropdown>
@@ -145,7 +147,7 @@ watch(
</template>
</el-dropdown>
<span
class="el-icon-setting navbar-bg-hover"
class="set-icon navbar-bg-hover"
:title="t('buttons.hssystemSet')"
@click="onPanel"
>

View File

@@ -1,9 +1,9 @@
<script setup lang="ts">
import path from "path";
import { childrenType } from "../../types";
import { useNav } from "/@/layout/hooks/useNav";
import { transformI18n } from "/@/plugins/i18n";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
import { useNav } from "@/layout/hooks/useNav";
import { transformI18n } from "@/plugins/i18n";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { ref, toRaw, PropType, nextTick, computed, CSSProperties } from "vue";
const { layout, isCollapse } = useNav();

View File

@@ -1,15 +1,15 @@
<script setup lang="ts">
import Logo from "./logo.vue";
import { useRoute } from "vue-router";
import { emitter } from "/@/utils/mitt";
import { emitter } from "@/utils/mitt";
import SidebarItem from "./sidebarItem.vue";
import leftCollapse from "./leftCollapse.vue";
import type { StorageConfigs } from "/#/index";
import { useNav } from "/@/layout/hooks/useNav";
import { useNav } from "@/layout/hooks/useNav";
import { storageLocal } from "@pureadmin/utils";
import { ref, computed, watch, onBeforeMount } from "vue";
import { findRouteByPath, getParentPaths } from "/@/router/utils";
import { usePermissionStoreHook } from "/@/store/modules/permission";
import { findRouteByPath, getParentPaths } from "@/router/utils";
import { usePermissionStoreHook } from "@/store/modules/permission";
const route = useRoute();
const showLogo = ref(
@@ -27,7 +27,7 @@ const menuData = computed(() => {
: usePermissionStoreHook().wholeMenus;
});
function getSubMenuData(path) {
function getSubMenuData(path: string) {
// path的上级路由组成的数组
const parentPathArr = getParentPaths(
path,
@@ -41,6 +41,7 @@ function getSubMenuData(path) {
if (!parenetRoute?.children) return;
subMenuData.value = parenetRoute?.children;
}
getSubMenuData(route.path);
onBeforeMount(() => {
@@ -50,7 +51,7 @@ onBeforeMount(() => {
});
watch(
() => route.path,
() => [route.path, usePermissionStoreHook().wholeMenus],
() => {
getSubMenuData(route.path);
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 {
margin: 0;
@@ -196,6 +181,9 @@
margin-right: 10px;
}
:deep(.el-dropdown-menu__item--divided) {
margin: 1px 0;
}
.el-dropdown-menu__item--divided::before {
margin: 0;
}
@@ -223,7 +211,8 @@
}
.arrow-left,
.arrow-right {
.arrow-right,
.arrow-down {
width: 40px;
height: 38px;
color: var(--el-text-color-primary);
@@ -248,7 +237,7 @@
.arrow-right {
box-shadow: -5px 0 5px -6px #ccc;
border-right: 1px solid #ccc;
border-right: 0.5px solid #ccc;
&:hover {
cursor: e-resize;
@@ -305,8 +294,3 @@
background: var(--el-color-primary);
animation: scheduleOutWidth 400ms ease-in;
}
/* 刷新按钮动画效果 */
.refresh-button {
animation: rotate 600ms linear infinite;
}

View File

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

View File

@@ -1,11 +1,11 @@
import { ref } from "vue";
import { getConfig } from "/@/config";
import { getConfig } from "@/config";
import { find } from "lodash-unified";
import { useLayout } from "./useLayout";
import { themeColorsType } from "../types";
import { TinyColor } from "@ctrl/tinycolor";
import { useGlobal } from "@pureadmin/utils";
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
import {
darken,
lighten,

View File

@@ -2,7 +2,7 @@ import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { routerArrays } from "../types";
import { useGlobal } from "@pureadmin/utils";
import { useMultiTagsStore } from "/@/store/modules/multiTags";
import { useMultiTagsStore } from "@/store/modules/multiTags";
export function useLayout() {
const { $storage, $config } = useGlobal<GlobalPropertiesApi>();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,7 @@ import "xe-utils";
import "./index.scss";
import XEUtils from "xe-utils";
import { App, unref } from "vue";
import { i18n } from "/@/plugins/i18n";
import { i18n } from "@/plugins/i18n";
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";

View File

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

View File

@@ -1,4 +1,4 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const ableRouter: RouteConfigsTable = {
@@ -13,7 +13,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/watermark",
name: "WaterMark",
component: () => import("/@/views/able/watermark.vue"),
component: () => import("@/views/able/watermark.vue"),
meta: {
title: $t("menus.hsWatermark")
}
@@ -21,15 +21,23 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/print",
name: "Print",
component: () => import("/@/views/able/print.vue"),
component: () => import("@/views/able/print.vue"),
meta: {
title: $t("menus.hsPrint")
}
},
{
path: "/able/download",
name: "Download",
component: () => import("@/views/able/download.vue"),
meta: {
title: $t("menus.hsDownload")
}
},
{
path: "/able/iconSelect",
name: "IconSelect",
component: () => import("/@/views/able/icon-select.vue"),
component: () => import("@/views/able/icon-select.vue"),
meta: {
title: $t("menus.hsIconSelect")
}
@@ -37,7 +45,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/timeline",
name: "TimeLine",
component: () => import("/@/views/able/timeline.vue"),
component: () => import("@/views/able/timeline.vue"),
meta: {
title: $t("menus.hsTimeline")
}
@@ -45,7 +53,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/menuTree",
name: "MenuTree",
component: () => import("/@/views/able/menu-tree.vue"),
component: () => import("@/views/able/menu-tree.vue"),
meta: {
title: $t("menus.hsMenuTree")
}
@@ -53,7 +61,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/lineTree",
name: "LineTree",
component: () => import("/@/views/able/line-tree.vue"),
component: () => import("@/views/able/line-tree.vue"),
meta: {
title: $t("menus.hsLineTree")
}
@@ -61,7 +69,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/antTabs",
name: "AntTabs",
component: () => import("/@/views/able/ant-tabs.vue"),
component: () => import("@/views/able/ant-tabs.vue"),
meta: {
title: $t("menus.hsAntTabs")
}
@@ -69,7 +77,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/antAnchor",
name: "AntAnchor",
component: () => import("/@/views/able/ant-anchor.vue"),
component: () => import("@/views/able/ant-anchor.vue"),
meta: {
title: $t("menus.hsAntAnchor")
}
@@ -77,7 +85,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/antTreeSelect",
name: "AntTreeSelect",
component: () => import("/@/views/able/ant-treeSelect.vue"),
component: () => import("@/views/able/ant-treeSelect.vue"),
meta: {
title: $t("menus.hsAntTreeSelect")
}
@@ -85,7 +93,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/debounce",
name: "Debounce",
component: () => import("/@/views/able/debounce.vue"),
component: () => import("@/views/able/debounce.vue"),
meta: {
title: $t("menus.hsDebounce")
}
@@ -93,7 +101,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/barcode",
name: "BarCode",
component: () => import("/@/views/able/barcode.vue"),
component: () => import("@/views/able/barcode.vue"),
meta: {
title: $t("menus.hsBarcode")
}
@@ -101,7 +109,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/qrcode",
name: "QrCode",
component: () => import("/@/views/able/qrcode.vue"),
component: () => import("@/views/able/qrcode.vue"),
meta: {
title: $t("menus.hsQrcode")
}
@@ -109,7 +117,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/cascader",
name: "Cascader",
component: () => import("/@/views/able/cascader.vue"),
component: () => import("@/views/able/cascader.vue"),
meta: {
title: $t("menus.hsCascader")
}
@@ -117,7 +125,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/swiper",
name: "Swiper",
component: () => import("/@/views/able/swiper.vue"),
component: () => import("@/views/able/swiper.vue"),
meta: {
title: $t("menus.hsSwiper")
}
@@ -125,7 +133,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/virtualList",
name: "VirtualList",
component: () => import("/@/views/able/virtual-list/index.vue"),
component: () => import("@/views/able/virtual-list/index.vue"),
meta: {
title: $t("menus.hsVirtualList")
}
@@ -133,7 +141,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/pdf",
name: "Pdf",
component: () => import("/@/views/able/pdf.vue"),
component: () => import("@/views/able/pdf.vue"),
meta: {
title: $t("menus.hsPdf")
}
@@ -141,7 +149,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/execl",
name: "Execl",
component: () => import("/@/views/able/execl.vue"),
component: () => import("@/views/able/execl.vue"),
meta: {
title: $t("menus.hsExecl")
}
@@ -149,7 +157,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/able/infiniteScroll",
name: "InfiniteScroll",
component: () => import("/@/views/able/infinite-scroll.vue"),
component: () => import("@/views/able/infinite-scroll.vue"),
meta: {
title: $t("menus.hsInfiniteScroll")
}

View File

@@ -1,4 +1,4 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const aboutRouter: RouteConfigsTable = {
@@ -13,7 +13,7 @@ const aboutRouter: RouteConfigsTable = {
{
path: "/about/index",
name: "About",
component: () => import("/@/views/about/index.vue"),
component: () => import("@/views/about/index.vue"),
meta: {
title: $t("menus.hsAbout")
}

View File

@@ -1,4 +1,4 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const componentsRouter: RouteConfigsTable = {
@@ -13,7 +13,7 @@ const componentsRouter: RouteConfigsTable = {
{
path: "/components/video",
name: "Video",
component: () => import("/@/views/components/video/index.vue"),
component: () => import("@/views/components/video/index.vue"),
meta: {
title: $t("menus.hsvideo")
}
@@ -21,7 +21,7 @@ const componentsRouter: RouteConfigsTable = {
{
path: "/components/map",
name: "Map",
component: () => import("/@/views/components/map/index.vue"),
component: () => import("@/views/components/map/index.vue"),
meta: {
title: $t("menus.hsmap"),
keepAlive: true,
@@ -33,7 +33,7 @@ const componentsRouter: RouteConfigsTable = {
{
path: "/components/draggable",
name: "Draggable",
component: () => import("/@/views/components/draggable/index.vue"),
component: () => import("@/views/components/draggable/index.vue"),
meta: {
title: $t("menus.hsdraggable"),
transition: {
@@ -45,7 +45,7 @@ const componentsRouter: RouteConfigsTable = {
{
path: "/components/splitPane",
name: "SplitPane",
component: () => import("/@/views/components/split-pane/index.vue"),
component: () => import("@/views/components/split-pane/index.vue"),
meta: {
title: $t("menus.hssplitPane"),
extraIcon: {
@@ -57,7 +57,7 @@ const componentsRouter: RouteConfigsTable = {
{
path: "/components/button",
name: "Button",
component: () => import("/@/views/components/button/index.vue"),
component: () => import("@/views/components/button/index.vue"),
meta: {
title: $t("menus.hsbutton")
}
@@ -65,7 +65,7 @@ const componentsRouter: RouteConfigsTable = {
{
path: "/components/cropping",
name: "Cropping",
component: () => import("/@/views/components/cropping/index.vue"),
component: () => import("@/views/components/cropping/index.vue"),
meta: {
title: $t("menus.hscropping")
}
@@ -73,7 +73,7 @@ const componentsRouter: RouteConfigsTable = {
{
path: "/components/countTo",
name: "CountTo",
component: () => import("/@/views/components/count-to/index.vue"),
component: () => import("@/views/components/count-to/index.vue"),
meta: {
title: $t("menus.hscountTo")
}
@@ -81,7 +81,7 @@ const componentsRouter: RouteConfigsTable = {
{
path: "/components/selector",
name: "Selector",
component: () => import("/@/views/components/selector/index.vue"),
component: () => import("@/views/components/selector/index.vue"),
meta: {
title: $t("menus.hsselector")
}
@@ -89,7 +89,7 @@ const componentsRouter: RouteConfigsTable = {
{
path: "/components/seamlessScroll",
name: "SeamlessScroll",
component: () => import("/@/views/components/seamless-scroll/index.vue"),
component: () => import("@/views/components/seamless-scroll/index.vue"),
meta: {
title: $t("menus.hsseamless")
}
@@ -97,10 +97,34 @@ const componentsRouter: RouteConfigsTable = {
{
path: "/components/contextmenu",
name: "ContextMenu",
component: () => import("/@/views/components/contextmenu/index.vue"),
component: () => import("@/views/components/contextmenu/index.vue"),
meta: {
title: $t("menus.hscontextmenu")
}
},
{
path: "/components/typeit",
name: "Typeit",
component: () => import("@/views/components/typeit/index.vue"),
meta: {
title: $t("menus.hstypeit")
}
},
{
path: "/components/json-editor",
name: "JsonEditor",
component: () => import("@/views/components/json-editor/index.vue"),
meta: {
title: $t("menus.hsjsoneditor")
}
},
{
path: "/components/danmaku",
name: "Danmaku",
component: () => import("@/views/components/danmaku/index.vue"),
meta: {
title: $t("menus.hsdanmaku")
}
}
]
};

View File

@@ -1,4 +1,4 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const editorRouter: RouteConfigsTable = {
@@ -13,7 +13,7 @@ const editorRouter: RouteConfigsTable = {
{
path: "/editor/index",
name: "Editor",
component: () => import("/@/views/editor/index.vue"),
component: () => import("@/views/editor/index.vue"),
meta: {
title: $t("menus.hseditor"),
keepAlive: true

View File

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

View File

@@ -1,4 +1,4 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const flowChartRouter: RouteConfigsTable = {
@@ -13,7 +13,7 @@ const flowChartRouter: RouteConfigsTable = {
{
path: "/flowChart/index",
name: "FlowChart",
component: () => import("/@/views/flow-chart/index.vue"),
component: () => import("@/views/flow-chart/index.vue"),
meta: {
title: $t("menus.hsflowChart")
}

View File

@@ -1,4 +1,4 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const formDesignRouter: RouteConfigsTable = {
@@ -13,7 +13,7 @@ const formDesignRouter: RouteConfigsTable = {
{
path: "/formDesign/index",
name: "FormDesign",
component: () => import("/@/views/form-design/index.vue"),
component: () => import("@/views/form-design/index.vue"),
meta: {
title: $t("menus.hsFormDesign")
}

View File

@@ -1,4 +1,4 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const guideRouter: RouteConfigsTable = {
@@ -13,7 +13,7 @@ const guideRouter: RouteConfigsTable = {
{
path: "/guide/index",
name: "Guide",
component: () => import("/@/views/guide/index.vue"),
component: () => import("@/views/guide/index.vue"),
meta: {
title: $t("menus.hsguide")
}

View File

@@ -1,6 +1,6 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const Layout = () => import("/@/layout/index.vue");
const Layout = () => import("@/layout/index.vue");
const homeRouter: RouteConfigsTable = {
path: "/",
@@ -16,7 +16,7 @@ const homeRouter: RouteConfigsTable = {
{
path: "/welcome",
name: "Welcome",
component: () => import("/@/views/welcome/index.vue"),
component: () => import("@/views/welcome/index.vue"),
meta: {
title: $t("menus.hshome")
}

View File

@@ -1,4 +1,4 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const ableRouter: RouteConfigsTable = {
@@ -13,7 +13,7 @@ const ableRouter: RouteConfigsTable = {
{
path: "/list/card",
name: "ListCard",
component: () => import("/@/views/list/card/index.vue"),
component: () => import("@/views/list/card/index.vue"),
meta: {
icon: "card",
title: $t("menus.hsListCard"),

View File

@@ -1,4 +1,4 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const nestedRouter: RouteConfigsTable = {
@@ -20,7 +20,7 @@ const nestedRouter: RouteConfigsTable = {
children: [
{
path: "/nested/menu1/menu1-1",
component: () => import("/@/views/nested/menu1/menu1-1/index.vue"),
component: () => import("@/views/nested/menu1/menu1-1/index.vue"),
name: "Menu1-1",
meta: {
title: $t("menus.hsmenu1-1"),
@@ -38,7 +38,7 @@ const nestedRouter: RouteConfigsTable = {
{
path: "/nested/menu1/menu1-2/menu1-2-1",
component: () =>
import("/@/views/nested/menu1/menu1-2/menu1-2-1/index.vue"),
import("@/views/nested/menu1/menu1-2/menu1-2-1/index.vue"),
name: "Menu1-2-1",
meta: {
title: $t("menus.hsmenu1-2-1"),
@@ -48,7 +48,7 @@ const nestedRouter: RouteConfigsTable = {
{
path: "/nested/menu1/menu1-2/menu1-2-2",
component: () =>
import("/@/views/nested/menu1/menu1-2/menu1-2-2/index.vue"),
import("@/views/nested/menu1/menu1-2/menu1-2-2/index.vue"),
name: "Menu1-2-2",
meta: {
title: $t("menus.hsmenu1-2-2"),
@@ -63,7 +63,7 @@ const nestedRouter: RouteConfigsTable = {
},
{
path: "/nested/menu1/menu1-3",
component: () => import("/@/views/nested/menu1/menu1-3/index.vue"),
component: () => import("@/views/nested/menu1/menu1-3/index.vue"),
name: "Menu1-3",
meta: {
title: $t("menus.hsmenu1-3"),
@@ -75,7 +75,7 @@ const nestedRouter: RouteConfigsTable = {
{
path: "/nested/menu2",
name: "Menu2",
component: () => import("/@/views/nested/menu2/index.vue"),
component: () => import("@/views/nested/menu2/index.vue"),
meta: {
title: $t("menus.hsmenu2"),
keepAlive: true

View File

@@ -1,5 +1,5 @@
import type { RouteConfigsTable } from "/#/index";
const IFrame = () => import("/@/layout/frameView.vue");
const IFrame = () => import("@/layout/frameView.vue");
const pptRouter: RouteConfigsTable = {
path: "/ppt",

View File

@@ -1,12 +1,12 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const Layout = () => import("/@/layout/index.vue");
const Layout = () => import("@/layout/index.vue");
const remainingRouter: Array<RouteConfigsTable> = [
{
path: "/login",
name: "Login",
component: () => import("/@/views/login/index.vue"),
component: () => import("@/views/login/index.vue"),
meta: {
title: $t("menus.hslogin"),
showLink: false,
@@ -26,7 +26,7 @@ const remainingRouter: Array<RouteConfigsTable> = [
{
path: "/redirect/:path(.*)",
name: "Redirect",
component: () => import("/@/layout/redirect.vue")
component: () => import("@/layout/redirect.vue")
}
]
},
@@ -34,7 +34,7 @@ const remainingRouter: Array<RouteConfigsTable> = [
{
path: "/empty",
name: "Empty",
component: () => import("/@/views/empty/index.vue"),
component: () => import("@/views/empty/index.vue"),
meta: {
title: $t("menus.hsempty"),
showLink: false,

View File

@@ -1,4 +1,4 @@
import { $t } from "/@/plugins/i18n";
import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const resultRouter: RouteConfigsTable = {
@@ -13,7 +13,7 @@ const resultRouter: RouteConfigsTable = {
{
path: "/result/success",
name: "Success",
component: () => import("/@/views/result/success.vue"),
component: () => import("@/views/result/success.vue"),
meta: {
title: $t("menus.hsSuccess")
}
@@ -21,7 +21,7 @@ const resultRouter: RouteConfigsTable = {
{
path: "/result/fail",
name: "Fail",
component: () => import("/@/views/result/fail.vue"),
component: () => import("@/views/result/fail.vue"),
meta: {
title: $t("menus.hsFail")
}

View File

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

View File

@@ -9,19 +9,25 @@ import {
import { router } from "./index";
import { isProxy, toRaw } from "vue";
import { loadEnv } from "../../build";
import { cloneDeep } from "lodash-unified";
import { useTimeoutFn } from "@vueuse/core";
import { RouteConfigs } from "/@/layout/types";
import { buildHierarchyTree } from "@pureadmin/utils";
import { usePermissionStoreHook } from "/@/store/modules/permission";
const IFrame = () => import("/@/layout/frameView.vue");
import { RouteConfigs } from "@/layout/types";
import {
isString,
storageSession,
buildHierarchyTree,
isIncludeAllChildren
} from "@pureadmin/utils";
import { cloneDeep, intersection } from "lodash-unified";
import { sessionKey, type DataInfo } from "@/utils/auth";
import { usePermissionStoreHook } from "@/store/modules/permission";
const IFrame = () => import("@/layout/frameView.vue");
// https://cn.vitejs.dev/guide/features.html#glob-import
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[]) {
arr.forEach(v => {
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[]) {
const newTree = cloneDeep(data).filter(
(v: { meta: { showLink: boolean } }) => v.meta?.showLink !== false
@@ -49,7 +55,38 @@ function filterTree(data: RouteComponent[]) {
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>) {
delAliveRouteList.forEach(route => {
usePermissionStoreHook().cacheOperate({
@@ -59,7 +96,7 @@ function delAliveRoutes(delAliveRouteList: Array<RouteConfigs>) {
});
}
// 通过path获取父级路径
/** 通过path获取父级路径 */
function getParentPaths(path: string, routes: RouteRecordRaw[]) {
// 深度遍历查找
function dfs(routes: RouteRecordRaw[], path: string, parents: string[]) {
@@ -83,7 +120,7 @@ function getParentPaths(path: string, routes: RouteRecordRaw[]) {
return dfs(routes, path, []);
}
// 查找对应path的路由信息
/** 查找对应path的路由信息 */
function findRouteByPath(path: string, routes: RouteRecordRaw[]) {
let res = routes.find((item: { path: string }) => item.path == path);
if (res) {
@@ -114,14 +151,15 @@ function addPathMatch() {
}
}
// 初始化路由
function initRouter(name: string) {
/** 初始化路由 */
function initRouter() {
return new Promise(resolve => {
getAsyncRoutes({ name }).then(({ info }) => {
if (info.length === 0) {
usePermissionStoreHook().changeSetting(info);
getAsyncRoutes().then(({ data }) => {
if (data.length === 0) {
usePermissionStoreHook().handleWholeMenus(data);
resolve(router);
} else {
formatFlatteningRoutes(addAsyncRoutes(info)).map(
formatFlatteningRoutes(addAsyncRoutes(data)).map(
(v: RouteRecordRaw) => {
// 防止重复添加路由
if (
@@ -144,7 +182,7 @@ function initRouter(name: string) {
resolve(router);
}
);
usePermissionStoreHook().changeSetting(info);
usePermissionStoreHook().handleWholeMenus(data);
}
addPathMatch();
});
@@ -195,7 +233,7 @@ function formatTwoStageRoutes(routesList: RouteRecordRaw[]) {
return newRoutesList;
}
// 处理缓存路由(添加、删除、刷新)
/** 处理缓存路由(添加、删除、刷新) */
function handleAliveRoute(matched: RouteRecordNormalized[], mode?: string) {
switch (mode) {
case "add":
@@ -222,7 +260,7 @@ function handleAliveRoute(matched: RouteRecordNormalized[], mode?: string) {
}
}
// 过滤后端传来的动态路由 重新生成规范路由
/** 过滤后端传来的动态路由 重新生成规范路由 */
function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
if (!arrRoutes || !arrRoutes.length) return;
const modulesRoutesKeys = Object.keys(modulesRoutes);
@@ -232,9 +270,9 @@ function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
// 父级的redirect属性取值如果子级存在且父级的redirect属性不存在默认取第一个子级的path如果子级存在且父级的redirect属性存在取存在的redirect属性会覆盖默认值
if (v?.children && v.children.length && !v.redirect)
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)
v.name = v.children[0].name;
v.name = (v.children[0].name as string) + "Parent";
if (v.meta?.frameSrc) {
v.component = IFrame;
} else {
@@ -251,7 +289,7 @@ function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
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 {
const routerHistory = loadEnv().VITE_ROUTER_HISTORY;
// 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 {
if (value && value instanceof Array && value.length > 0) {
const roles = usePermissionStoreHook().buttonAuth;
const permissionRoles = value;
/** 获取当前页面按钮级别的权限 */
function getAuths(): Array<string> {
return router.currentRoute.value.meta.auths as Array<string>;
}
const hasPermission = roles.some(role => {
return permissionRoles.includes(role);
});
if (!hasPermission) {
return false;
}
return true;
} else {
return false;
}
/** 是否有按钮级别的权限 */
function hasAuth(value: string | Array<string>): boolean {
if (!value) return false;
/** 从当前路由的`meta`字段里获取按钮级别的所有自定义`code`值 */
const metaAuths = getAuths();
const isAuths = isString(value)
? metaAuths.includes(value)
: isIncludeAllChildren(value, metaAuths);
return isAuths ? true : false;
}
export {
hasAuth,
getAuths,
ascending,
filterTree,
initRouter,
hasPermissions,
isOneOfArray,
getHistoryMode,
addAsyncRoutes,
delAliveRoutes,
@@ -306,5 +343,6 @@ export {
findRouteByPath,
handleAliveRoute,
formatTwoStageRoutes,
formatFlatteningRoutes
formatFlatteningRoutes,
filterNoPermissionTree
};

View File

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

View File

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

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