Compare commits

...

10 Commits

Author SHA1 Message Date
xiaoxian521
6f65e67872 release: update 3.9.7 2022-12-26 14:51:38 +08:00
xiaoxian521
c79862a6c8 chore: update 2022-12-23 18:41:27 +08:00
xiaoxian521
799643a283 docs: update README.md 2022-12-21 11:53:54 +08:00
xiaoxian521
707200c71d release: update 3.9.6 2022-12-19 13:45:28 +08:00
xiaoxian521
bc548d500c chore: update @pureadmin/theme latest 2022-12-15 12:41:02 +08:00
xiaoxian521
4d57c9e3d7 release: update 3.9.5 2022-12-13 14:37:56 +08:00
xiaoxian521
1bcf391513 fix: 修复暗黑主题样式问题 2022-12-09 20:35:50 +08:00
xiaoxian521
30af2b78fe chore: update 2022-12-09 12:45:47 +08:00
xiaoxian521
0b1bd19179 fix: 修复动态路由 rank 问题 2022-12-07 17:22:07 +08:00
xiaoxian521
4ccf200059 perf: 优化路由 rank,当rank 不存在时,根据顺序自动创建,首页路由永远在第一位 2022-12-06 21:18:12 +08:00
34 changed files with 956 additions and 1001 deletions

View File

@@ -26,17 +26,15 @@
[xiaoxian521](https://github.com/xiaoxian521) [xiaoxian521](https://github.com/xiaoxian521)
## 捐赠 ## 支持
如果你觉得这个项目对您有帮助,可以帮作者买一杯果汁 🍹 表示支持 如果你觉得这个项目对您有帮助,可以帮作者买一杯果汁 🍹 表示支持
<img src="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/f69bf13c5b854ed5b699807cafa0e3ce~tplv-k3u1fbpfcp-zoom-in-crop-mark:1304:0:0:0.awebp?" width="150px" height="150px" /> <img src="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/f69bf13c5b854ed5b699807cafa0e3ce~tplv-k3u1fbpfcp-zoom-in-crop-mark:1304:0:0:0.awebp?" width="150px" height="150px" />
## QQ 交流群 ## `QQ` 交流群
一群已满,下面是二群,群里严禁 `黄``赌``毒``vpn` 等违法行为! [点击去加入](https://yiming_chang.gitee.io/pure-admin-doc/pages/support/#qq-%E4%BA%A4%E6%B5%81%E7%BE%A4)
<img src="http://yiming_chang.gitee.io/pure-admin-doc/img/support/qq.png" width="150px" height="225px" />
## 用法 ## 用法

View File

@@ -7,7 +7,7 @@ import { Plugin as importToCDN } from "vite-plugin-cdn-import";
* 注意上面提到的仅限外网使用也不是完全肯定的如果你们公司内网部署的有相关js、css文件也可以将下面配置对应改一下整一套内网版cdn * 注意上面提到的仅限外网使用也不是完全肯定的如果你们公司内网部署的有相关js、css文件也可以将下面配置对应改一下整一套内网版cdn
*/ */
export const cdn = importToCDN({ export const cdn = importToCDN({
//prodUrl解释 name: 对应下面modules的nameversion: 自动读取本地package.json中dependencies依赖中对应包的版本号path: 对应下面modules的path //prodUrl解释 name: 对应下面modules的nameversion: 自动读取本地package.json中dependencies依赖中对应包的版本号path: 对应下面modules的path当然也可写完整路径会替换prodUrl
prodUrl: "https://cdn.bootcdn.net/ajax/libs/{name}/{version}/{path}", prodUrl: "https://cdn.bootcdn.net/ajax/libs/{name}/{version}/{path}",
modules: [ modules: [
{ {
@@ -51,12 +51,6 @@ export const cdn = importToCDN({
name: "echarts", name: "echarts",
var: "echarts", var: "echarts",
path: "echarts.min.js" path: "echarts.min.js"
},
{
name: "lodash",
var: "lodash",
// 可写`完整路径`,会替换`prodUrl`
path: "https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"
} }
] ]
}); });

View File

@@ -27,9 +27,4 @@ const warpperEnv = (envConf: Recordable): ViteEnv => {
return ret; return ret;
}; };
/** 获取环境变量 */ export { warpperEnv };
const loadEnv = (): ViteEnv => {
return import.meta.env;
};
export { warpperEnv, loadEnv };

View File

@@ -10,13 +10,9 @@ const include = [
"dayjs", "dayjs",
"axios", "axios",
"pinia", "pinia",
"lodash",
"echarts", "echarts",
"js-cookie", "js-cookie",
"lodash-es",
"@vueuse/core", "@vueuse/core",
"lodash-unified",
"@ctrl/tinycolor",
"@pureadmin/utils", "@pureadmin/utils",
"responsive-storage", "responsive-storage",
"element-resize-detector" "element-resize-detector"

View File

@@ -33,14 +33,7 @@ export function getPluginsList(
themePreprocessorPlugin({ themePreprocessorPlugin({
scss: { scss: {
multipleScopeVars: genScssMultipleScopeVars(), multipleScopeVars: genScssMultipleScopeVars(),
// 在生产模式是否抽取独立的主题css文件extract为true以下属性有效 extract: true
extract: true,
// 会选取defaultScopeName对应的主题css文件在html添加link
themeLinkTagId: "head",
// "head"||"head-prepend" || "body" ||"body-prepend"
themeLinkTagInjectTo: "head",
// 是否对抽取的css文件内对应scopeName的权重类名移除
removeCssScopeName: false
} }
}), }),
// svg组件化支持 // svg组件化支持

View File

@@ -1,6 +1,6 @@
{ {
"name": "pure-admin-thin", "name": "pure-admin-thin",
"version": "3.9.4", "version": "3.9.7",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "NODE_OPTIONS=--max-old-space-size=4096 vite", "dev": "NODE_OPTIONS=--max-old-space-size=4096 vite",
@@ -29,27 +29,23 @@
"not op_mini all" "not op_mini all"
], ],
"dependencies": { "dependencies": {
"@ctrl/tinycolor": "^3.4.1",
"@pureadmin/descriptions": "^1.1.0", "@pureadmin/descriptions": "^1.1.0",
"@pureadmin/table": "^1.8.3", "@pureadmin/table": "^1.9.0",
"@pureadmin/utils": "^1.7.4", "@pureadmin/utils": "^1.8.5",
"@vueuse/core": "^9.6.0", "@vueuse/core": "^9.6.0",
"@vueuse/motion": "2.0.0-beta.12", "@vueuse/motion": "2.0.0-beta.12",
"animate.css": "^4.1.1", "animate.css": "^4.1.1",
"axios": "^1.2.0", "axios": "^1.2.0",
"dayjs": "^1.11.6", "dayjs": "^1.11.6",
"echarts": "^5.4.0", "echarts": "^5.4.0",
"element-plus": "^2.2.26", "element-plus": "^2.2.27",
"element-resize-detector": "^1.2.4", "element-resize-detector": "^1.2.4",
"js-cookie": "^3.0.1", "js-cookie": "^3.0.1",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"lodash-unified": "^1.0.2",
"mitt": "^3.0.0", "mitt": "^3.0.0",
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"path": "^0.12.7", "path": "^0.12.7",
"pinia": "^2.0.27", "pinia": "^2.0.28",
"qs": "^6.11.0", "qs": "^6.11.0",
"responsive-storage": "^2.1.0", "responsive-storage": "^2.1.0",
"vue": "^3.2.45", "vue": "^3.2.45",
@@ -62,20 +58,17 @@
"@iconify-icons/ep": "^1.2.7", "@iconify-icons/ep": "^1.2.7",
"@iconify-icons/ri": "^1.2.3", "@iconify-icons/ri": "^1.2.3",
"@iconify/vue": "^4.0.0", "@iconify/vue": "^4.0.0",
"@pureadmin/theme": "^2.4.0", "@pureadmin/theme": "^3.0.0",
"@types/element-resize-detector": "1.1.3", "@types/element-resize-detector": "1.1.3",
"@types/js-cookie": "^3.0.1", "@types/js-cookie": "^3.0.1",
"@types/lodash": "^4.14.180",
"@types/lodash-es": "^4.17.6",
"@types/mockjs": "^1.0.7", "@types/mockjs": "^1.0.7",
"@types/node": "^18.11.9", "@types/node": "^18.11.9",
"@types/nprogress": "0.2.0", "@types/nprogress": "0.2.0",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
"@typescript-eslint/eslint-plugin": "^5.42.1", "@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1", "@typescript-eslint/parser": "^5.42.1",
"@vitejs/plugin-legacy": "^2.3.1", "@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue": "^3.2.0", "@vitejs/plugin-vue-jsx": "^3.0.0",
"@vitejs/plugin-vue-jsx": "^2.1.1",
"@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^11.0.2", "@vue/eslint-config-typescript": "^11.0.2",
"autoprefixer": "^10.4.13", "autoprefixer": "^10.4.13",
@@ -105,10 +98,10 @@
"stylelint-order": "^5.0.0", "stylelint-order": "^5.0.0",
"svgo": "^3.0.2", "svgo": "^3.0.2",
"tailwindcss": "^3.2.4", "tailwindcss": "^3.2.4",
"terser": "^5.15.1", "terser": "^5.16.1",
"typescript": "^4.9.3", "typescript": "^4.9.3",
"unplugin-vue-define-options": "^1.0.0", "unplugin-vue-define-options": "^1.1.1",
"vite": "3.1.8", "vite": "^4.0.3",
"vite-plugin-cdn-import": "^0.3.5", "vite-plugin-cdn-import": "^0.3.5",
"vite-plugin-compression": "^0.5.1", "vite-plugin-compression": "^0.5.1",
"vite-plugin-mock": "^2.9.6", "vite-plugin-mock": "^2.9.6",

1696
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
{ {
"Version": "3.9.4", "Version": "3.9.7",
"Title": "PureAdmin", "Title": "PureAdmin",
"FixedHeader": true, "FixedHeader": true,
"HiddenSideBar": false, "HiddenSideBar": false,
@@ -16,6 +16,6 @@
"ShowLogo": true, "ShowLogo": true,
"ShowModel": "smart", "ShowModel": "smart",
"MenuArrowIconNoTransition": true, "MenuArrowIconNoTransition": true,
"CachingAsyncRoutes": true, "CachingAsyncRoutes": false,
"TooltipEffect": "light" "TooltipEffect": "light"
} }

View File

@@ -1,9 +1,8 @@
import { App } from "vue"; import { App } from "vue";
import axios from "axios"; import axios from "axios";
import { loadEnv } from "@build/index";
let config: object = {}; let config: object = {};
const { VITE_PUBLIC_PATH } = loadEnv(); const { VITE_PUBLIC_PATH } = import.meta.env;
const setConfig = (cfg?: unknown) => { const setConfig = (cfg?: unknown) => {
config = Object.assign(config, cfg); config = Object.assign(config, cfg);

View File

@@ -5,7 +5,7 @@ export const auth: Directive = {
mounted(el: HTMLElement, binding: DirectiveBinding) { mounted(el: HTMLElement, binding: DirectiveBinding) {
const { value } = binding; const { value } = binding;
if (value) { if (value) {
!hasAuth(value) && el.parentNode.removeChild(el); !hasAuth(value) && el.parentNode?.removeChild(el);
} else { } else {
throw new Error("need auths! Like v-auth=\"['btn.add','btn.edit']\""); throw new Error("need auths! Like v-auth=\"['btn.add','btn.edit']\"");
} }

View File

@@ -70,14 +70,8 @@ notices.value.map(v => (noticesNum.value += v.list.length));
height: 1px; height: 1px;
} }
// 如果上面的 notices 长度大于 3 请注释掉下面代码
:deep(.el-tabs__nav-wrap) { :deep(.el-tabs__nav-wrap) {
padding: 0 36px 0 36px; padding: 0 36px 0 36px;
} }
// 如果上面的 notices 长度大于 3 请注释掉下面代码
:deep(.el-tabs__active-bar) {
margin: 0 36px 0 36px;
}
} }
</style> </style>

View File

@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { cloneDeep } from "lodash-unified"; import { cloneDeep } from "@pureadmin/utils";
import SearchResult from "./SearchResult.vue"; import SearchResult from "./SearchResult.vue";
import SearchFooter from "./SearchFooter.vue"; import SearchFooter from "./SearchFooter.vue";
import { deleteChildren } from "@/utils/tree"; import { deleteChildren } from "@/utils/tree";

View File

@@ -132,8 +132,8 @@ const multiTagsCacheChange = () => {
/** 清空缓存并返回登录页 */ /** 清空缓存并返回登录页 */
function onReset() { function onReset() {
removeToken(); removeToken();
storageLocal.clear(); storageLocal().clear();
storageSession.clear(); storageSession().clear();
const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig(); const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig();
useAppStoreHook().setLayout(Layout); useAppStoreHook().setLayout(Layout);
setEpThemeColor(EpThemeColor); setEpThemeColor(EpThemeColor);

View File

@@ -99,6 +99,7 @@ watch(
:deep(.el-loading-mask) { :deep(.el-loading-mask) {
opacity: 0.45; opacity: 0.45;
} }
.logout { .logout {
max-width: 120px; max-width: 120px;

View File

@@ -131,6 +131,7 @@ watch(
:deep(.el-loading-mask) { :deep(.el-loading-mask) {
opacity: 0.45; opacity: 0.45;
} }
.logout { .logout {
max-width: 120px; max-width: 120px;

View File

@@ -143,7 +143,8 @@ function resolvePath(routePath) {
if (httpReg.test(routePath) || httpReg.test(props.basePath)) { if (httpReg.test(routePath) || httpReg.test(props.basePath)) {
return routePath || props.basePath; return routePath || props.basePath;
} else { } else {
return path.resolve(props.basePath, routePath); // 使用path.posix.resolve替代path.resolve 避免windows环境下使用electron出现盘符问题
return path.posix.resolve(props.basePath, routePath);
} }
} }
</script> </script>

View File

@@ -12,7 +12,8 @@ import { usePermissionStoreHook } from "@/store/modules/permission";
const route = useRoute(); const route = useRoute();
const showLogo = ref( const showLogo = ref(
storageLocal.getItem<StorageConfigs>("responsive-configure")?.showLogo ?? true storageLocal().getItem<StorageConfigs>("responsive-configure")?.showLogo ??
true
); );
const { routers, device, pureApp, isCollapse, menuSelect, toggleSideBar } = const { routers, device, pureApp, isCollapse, menuSelect, toggleSideBar } =

View File

@@ -3,7 +3,7 @@ import { emitter } from "@/utils/mitt";
import { RouteConfigs } from "../../types"; import { RouteConfigs } from "../../types";
import { useTags } from "../../hooks/useTag"; import { useTags } from "../../hooks/useTag";
import { routerArrays } from "@/layout/types"; import { routerArrays } from "@/layout/types";
import { isEqual, isEmpty } from "lodash-unified"; import { isEqual, isAllEmpty } from "@pureadmin/utils";
import { useSettingStoreHook } from "@/store/modules/settings"; import { useSettingStoreHook } from "@/store/modules/settings";
import { ref, watch, unref, nextTick, onBeforeMount } from "vue"; import { ref, watch, unref, nextTick, onBeforeMount } from "vue";
import { handleAliveRoute, delAliveRoutes } from "@/router/utils"; import { handleAliveRoute, delAliveRoutes } from "@/router/utils";
@@ -347,7 +347,7 @@ function showMenuModel(
const allRoute = multiTags.value; const allRoute = multiTags.value;
const routeLength = multiTags.value.length; const routeLength = multiTags.value.length;
let currentIndex = -1; let currentIndex = -1;
if (isEmpty(query)) { if (isAllEmpty(query)) {
currentIndex = allRoute.findIndex(v => v.path === currentPath); currentIndex = allRoute.findIndex(v => v.path === currentPath);
} else { } else {
currentIndex = allRoute.findIndex(v => isEqual(v.query, query)); currentIndex = allRoute.findIndex(v => isEqual(v.query, query));

View File

@@ -1,9 +1,7 @@
import { ref } from "vue"; import { ref } from "vue";
import { getConfig } from "@/config"; import { getConfig } from "@/config";
import { find } from "lodash-unified";
import { useLayout } from "./useLayout"; import { useLayout } from "./useLayout";
import { themeColorsType } from "../types"; import { themeColorsType } from "../types";
import { TinyColor } from "@ctrl/tinycolor";
import { useGlobal } from "@pureadmin/utils"; import { useGlobal } from "@pureadmin/utils";
import { useEpThemeStoreHook } from "@/store/modules/epTheme"; import { useEpThemeStoreHook } from "@/store/modules/epTheme";
import { import {
@@ -56,35 +54,27 @@ export function useDataThemeChange() {
if (theme === "default" || theme === "light") { if (theme === "default" || theme === "light") {
setEpThemeColor(getConfig().EpThemeColor); setEpThemeColor(getConfig().EpThemeColor);
} else { } else {
const colors = find(themeColors.value, { themeColor: theme }); const colors = themeColors.value.find(v => v.themeColor === theme);
setEpThemeColor(colors.color); setEpThemeColor(colors.color);
} }
} }
/** function setPropertyPrimary(mode: string, i: number, color: string) {
* @description 自动计算hover和active颜色 document.documentElement.style.setProperty(
* @see {@link https://element-plus.org/zh-CN/component/button.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A2%9C%E8%89%B2} `--el-color-primary-${mode}-${i}`,
*/ dataTheme.value ? darken(color, i / 10) : lighten(color, i / 10)
const shadeBgColor = (color: string): string => { );
return new TinyColor(color).shade(10).toString(); }
};
/** 设置 `element-plus` 主题色 */ /** 设置 `element-plus` 主题色 */
const setEpThemeColor = (color: string) => { const setEpThemeColor = (color: string) => {
useEpThemeStoreHook().setEpThemeColor(color); useEpThemeStoreHook().setEpThemeColor(color);
body.style.setProperty("--el-color-primary-active", shadeBgColor(color));
document.documentElement.style.setProperty("--el-color-primary", color); document.documentElement.style.setProperty("--el-color-primary", color);
for (let i = 1; i <= 9; i++) {
document.documentElement.style.setProperty(
`--el-color-primary-light-${i}`,
lighten(color, i / 10)
);
}
for (let i = 1; i <= 2; i++) { for (let i = 1; i <= 2; i++) {
document.documentElement.style.setProperty( setPropertyPrimary("dark", i, color);
`--el-color-primary-dark-${i}`, }
darken(color, i / 10) for (let i = 1; i <= 9; i++) {
); setPropertyPrimary("light", i, color);
} }
}; };

View File

@@ -40,13 +40,13 @@ export function useTags() {
/** 显示模式,默认灵动模式 */ /** 显示模式,默认灵动模式 */
const showModel = ref( const showModel = ref(
storageLocal.getItem<StorageConfigs>("responsive-configure")?.showModel || storageLocal().getItem<StorageConfigs>("responsive-configure")?.showModel ||
"smart" "smart"
); );
/** 是否隐藏标签页,默认显示 */ /** 是否隐藏标签页,默认显示 */
const showTags = const showTags =
ref( ref(
storageLocal.getItem<StorageConfigs>("responsive-configure").hideTabs storageLocal().getItem<StorageConfigs>("responsive-configure").hideTabs
) ?? ref("false"); ) ?? ref("false");
const multiTags: any = computed(() => { const multiTags: any = computed(() => {
return useMultiTagsStoreHook().multiTags; return useMultiTagsStoreHook().multiTags;
@@ -194,11 +194,11 @@ export function useTags() {
onMounted(() => { onMounted(() => {
if (!showModel.value) { if (!showModel.value) {
const configure = storageLocal.getItem<StorageConfigs>( const configure = storageLocal().getItem<StorageConfigs>(
"responsive-configure" "responsive-configure"
); );
configure.showModel = "card"; configure.showModel = "card";
storageLocal.setItem("responsive-configure", configure); storageLocal().setItem("responsive-configure", configure);
} }
}); });

View File

@@ -2,10 +2,7 @@
* @description ⚠️:此文件仅供主题插件使用,请不要在此文件中导出别的工具函数(仅在页面加载前运行) * @description ⚠️:此文件仅供主题插件使用,请不要在此文件中导出别的工具函数(仅在页面加载前运行)
*/ */
type MultipleScopeVarsItem = { import { type multipleScopeVarsOptions } from "@pureadmin/theme";
scopeName: string;
varsContent: string;
};
/** 预设主题色 */ /** 预设主题色 */
const themeColors = { const themeColors = {
@@ -113,8 +110,8 @@ const themeColors = {
/** /**
* @description 将预设主题色处理成主题插件所需格式 * @description 将预设主题色处理成主题插件所需格式
*/ */
export const genScssMultipleScopeVars = (): MultipleScopeVarsItem[] => { export const genScssMultipleScopeVars = (): multipleScopeVarsOptions[] => {
const result = [] as MultipleScopeVarsItem[]; const result = [] as multipleScopeVarsOptions[];
Object.keys(themeColors).forEach(key => { Object.keys(themeColors).forEach(key => {
result.push({ result.push({
scopeName: `layout-theme-${key}`, scopeName: `layout-theme-${key}`,
@@ -129,7 +126,7 @@ export const genScssMultipleScopeVars = (): MultipleScopeVarsItem[] => {
$menuTitleHover: ${themeColors[key].menuTitleHover} !default; $menuTitleHover: ${themeColors[key].menuTitleHover} !default;
$menuActiveBefore: ${themeColors[key].menuActiveBefore} !default; $menuActiveBefore: ${themeColors[key].menuActiveBefore} !default;
` `
} as MultipleScopeVarsItem); } as multipleScopeVarsOptions);
}); });
return result; return result;
}; };

View File

@@ -15,6 +15,8 @@ import { injectResponsiveStorage } from "@/utils/responsive";
import "./style/reset.scss"; import "./style/reset.scss";
// 导入公共样式 // 导入公共样式
import "./style/index.scss"; import "./style/index.scss";
// 一定要在main.ts中导入tailwind.css防止vite每次hmr都会请求src/style/index.scss整体css文件导致热更新慢的问题
import "./style/tailwind.css";
import "element-plus/dist/index.css"; import "element-plus/dist/index.css";
// 导入字体图标 // 导入字体图标
import "./assets/iconfont/iconfont.js"; import "./assets/iconfont/iconfont.js";

View File

@@ -1,7 +1,6 @@
// import "@/utils/sso"; // import "@/utils/sso";
import { getConfig } from "@/config"; import { getConfig } from "@/config";
import NProgress from "@/utils/progress"; import NProgress from "@/utils/progress";
import { findIndex } from "lodash-unified";
import { sessionKey, type DataInfo } from "@/utils/auth"; import { sessionKey, type DataInfo } from "@/utils/auth";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags"; import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { usePermissionStoreHook } from "@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";
@@ -105,7 +104,7 @@ router.beforeEach((to: toRouteType, _from, next) => {
handleAliveRoute(newMatched); handleAliveRoute(newMatched);
} }
} }
const userInfo = storageSession.getItem<DataInfo<number>>(sessionKey); const userInfo = storageSession().getItem<DataInfo<number>>(sessionKey);
NProgress.start(); NProgress.start();
const externalLink = isUrl(to?.name as string); const externalLink = isUrl(to?.name as string);
if (!externalLink) { if (!externalLink) {
@@ -142,14 +141,10 @@ router.beforeEach((to: toRouteType, _from, next) => {
initRouter().then((router: Router) => { initRouter().then((router: Router) => {
if (!useMultiTagsStoreHook().getMultiTagsCache) { if (!useMultiTagsStoreHook().getMultiTagsCache) {
const { path } = to; const { path } = to;
const index = findIndex(remainingRouter, v => { const route = findRouteByPath(
return v.path == path; path,
}); router.options.routes[0].children
const routes: any = );
index === -1
? router.options.routes[0].children
: router.options.routes;
const route = findRouteByPath(path, routes);
// query、params模式路由传参数的标签页不在此处处理 // query、params模式路由传参数的标签页不在此处处理
if (route && route.meta?.title) { if (route && route.meta?.title) {
useMultiTagsStoreHook().handleTags("push", { useMultiTagsStoreHook().handleTags("push", {

View File

@@ -4,6 +4,7 @@ export default {
meta: { meta: {
icon: "informationLine", icon: "informationLine",
title: "异常页面", title: "异常页面",
// showLink: false,
rank: 9 rank: 9
}, },
children: [ children: [

View File

@@ -8,17 +8,18 @@ import {
} from "vue-router"; } from "vue-router";
import { router } from "./index"; import { router } from "./index";
import { isProxy, toRaw } from "vue"; import { isProxy, toRaw } from "vue";
import { loadEnv } from "../../build";
import { useTimeoutFn } from "@vueuse/core"; import { useTimeoutFn } from "@vueuse/core";
import { RouteConfigs } from "@/layout/types"; import { RouteConfigs } from "@/layout/types";
import { import {
isString, isString,
cloneDeep,
isAllEmpty,
intersection,
storageSession, storageSession,
isIncludeAllChildren isIncludeAllChildren
} from "@pureadmin/utils"; } from "@pureadmin/utils";
import { getConfig } from "@/config"; import { getConfig } from "@/config";
import { buildHierarchyTree } from "@/utils/tree"; import { buildHierarchyTree } from "@/utils/tree";
import { cloneDeep, intersection } from "lodash-unified";
import { sessionKey, type DataInfo } from "@/utils/auth"; import { sessionKey, type DataInfo } from "@/utils/auth";
import { usePermissionStoreHook } from "@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";
const IFrame = () => import("@/layout/frameView.vue"); const IFrame = () => import("@/layout/frameView.vue");
@@ -28,19 +29,25 @@ const modulesRoutes = import.meta.glob("/src/views/**/*.{vue,tsx}");
// 动态路由 // 动态路由
import { getAsyncRoutes } from "@/api/routes"; import { getAsyncRoutes } from "@/api/routes";
function handRank(routeInfo: any) {
const { name, path, parentId, meta } = routeInfo;
return isAllEmpty(parentId)
? isAllEmpty(meta?.rank) ||
(meta?.rank === 0 && name !== "Home" && path !== "/")
? true
: false
: false;
}
/** 按照路由中meta下的rank等级升序来排序路由 */ /** 按照路由中meta下的rank等级升序来排序路由 */
function ascending(arr: any[]) { function ascending(arr: any[]) {
arr.forEach(v => { arr.forEach((v, index) => {
if (v?.meta?.rank === null) v.meta.rank = undefined; // 当rank不存在时根据顺序自动创建首页路由永远在第一位
if (v?.meta?.rank === 0) { if (handRank(v)) v.meta.rank = index + 2;
if (v.name !== "Home" && v.path !== "/") {
console.warn("rank only the home page can be 0");
}
}
}); });
return arr.sort( return arr.sort(
(a: { meta: { rank: number } }, b: { meta: { rank: number } }) => { (a: { meta: { rank: number } }, b: { meta: { rank: number } }) => {
return a?.meta?.rank - b?.meta?.rank; return a?.meta.rank - b?.meta.rank;
} }
); );
} }
@@ -77,7 +84,7 @@ function isOneOfArray(a: Array<string>, b: Array<string>) {
/** 从sessionStorage里取出当前登陆用户的角色roles过滤无权限的菜单 */ /** 从sessionStorage里取出当前登陆用户的角色roles过滤无权限的菜单 */
function filterNoPermissionTree(data: RouteComponent[]) { function filterNoPermissionTree(data: RouteComponent[]) {
const currentRoles = const currentRoles =
storageSession.getItem<DataInfo<number>>(sessionKey)?.roles ?? []; storageSession().getItem<DataInfo<number>>(sessionKey)?.roles ?? [];
const newTree = cloneDeep(data).filter((v: any) => const newTree = cloneDeep(data).filter((v: any) =>
isOneOfArray(v.meta?.roles, currentRoles) isOneOfArray(v.meta?.roles, currentRoles)
); );
@@ -189,7 +196,7 @@ function initRouter() {
if (getConfig()?.CachingAsyncRoutes) { if (getConfig()?.CachingAsyncRoutes) {
// 开启动态路由缓存本地sessionStorage // 开启动态路由缓存本地sessionStorage
const key = "async-routes"; const key = "async-routes";
const asyncRouteList = storageSession.getItem(key) as any; const asyncRouteList = storageSession().getItem(key) as any;
if (asyncRouteList && asyncRouteList?.length > 0) { if (asyncRouteList && asyncRouteList?.length > 0) {
return new Promise(resolve => { return new Promise(resolve => {
handleAsyncRoutes(asyncRouteList); handleAsyncRoutes(asyncRouteList);
@@ -199,7 +206,7 @@ function initRouter() {
return new Promise(resolve => { return new Promise(resolve => {
getAsyncRoutes().then(({ data }) => { getAsyncRoutes().then(({ data }) => {
handleAsyncRoutes(cloneDeep(data)); handleAsyncRoutes(cloneDeep(data));
storageSession.setItem(key, data); storageSession().setItem(key, data);
resolve(router); resolve(router);
}); });
}); });
@@ -252,7 +259,7 @@ function formatTwoStageRoutes(routesList: RouteRecordRaw[]) {
children: [] children: []
}); });
} else { } else {
newRoutesList[0].children.push({ ...v }); newRoutesList[0]?.children.push({ ...v });
} }
}); });
return newRoutesList; return newRoutesList;
@@ -316,7 +323,7 @@ function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
/** 获取路由历史模式 https://next.router.vuejs.org/zh/guide/essentials/history-mode.html */ /** 获取路由历史模式 https://next.router.vuejs.org/zh/guide/essentials/history-mode.html */
function getHistoryMode(): RouterHistory { function getHistoryMode(): RouterHistory {
const routerHistory = loadEnv().VITE_ROUTER_HISTORY; const routerHistory = import.meta.env.VITE_ROUTER_HISTORY;
// len为1 代表只有历史模式 为2 代表历史模式中存在base参数 https://next.router.vuejs.org/zh/api/#%E5%8F%82%E6%95%B0-1 // len为1 代表只有历史模式 为2 代表历史模式中存在base参数 https://next.router.vuejs.org/zh/api/#%E5%8F%82%E6%95%B0-1
const historyMode = routerHistory.split(","); const historyMode = routerHistory.split(",");
const leftMode = historyMode[0]; const leftMode = historyMode[0];
@@ -348,6 +355,7 @@ function hasAuth(value: string | Array<string>): boolean {
if (!value) return false; if (!value) return false;
/** 从当前路由的`meta`字段里获取按钮级别的所有自定义`code`值 */ /** 从当前路由的`meta`字段里获取按钮级别的所有自定义`code`值 */
const metaAuths = getAuths(); const metaAuths = getAuths();
if (!metaAuths) return false;
const isAuths = isString(value) const isAuths = isString(value)
? metaAuths.includes(value) ? metaAuths.includes(value)
: isIncludeAllChildren(value, metaAuths); : isIncludeAllChildren(value, metaAuths);

View File

@@ -9,14 +9,14 @@ export const useAppStore = defineStore({
state: (): appType => ({ state: (): appType => ({
sidebar: { sidebar: {
opened: opened:
storageLocal.getItem<StorageConfigs>("responsive-layout") storageLocal().getItem<StorageConfigs>("responsive-layout")
?.sidebarStatus ?? getConfig().SidebarStatus, ?.sidebarStatus ?? getConfig().SidebarStatus,
withoutAnimation: false, withoutAnimation: false,
isClickCollapse: false isClickCollapse: false
}, },
// 这里的layout用于监听容器拖拉后恢复对应的导航模式 // 这里的layout用于监听容器拖拉后恢复对应的导航模式
layout: layout:
storageLocal.getItem<StorageConfigs>("responsive-layout")?.layout ?? storageLocal().getItem<StorageConfigs>("responsive-layout")?.layout ??
getConfig().Layout, getConfig().Layout,
device: deviceDetection() ? "mobile" : "desktop" device: deviceDetection() ? "mobile" : "desktop"
}), }),
@@ -30,7 +30,8 @@ export const useAppStore = defineStore({
}, },
actions: { actions: {
TOGGLE_SIDEBAR(opened?: boolean, resize?: string) { TOGGLE_SIDEBAR(opened?: boolean, resize?: string) {
const layout = storageLocal.getItem<StorageConfigs>("responsive-layout"); const layout =
storageLocal().getItem<StorageConfigs>("responsive-layout");
if (opened && resize) { if (opened && resize) {
this.sidebar.withoutAnimation = true; this.sidebar.withoutAnimation = true;
this.sidebar.opened = true; this.sidebar.opened = true;
@@ -45,7 +46,7 @@ export const useAppStore = defineStore({
this.sidebar.isClickCollapse = !this.sidebar.opened; this.sidebar.isClickCollapse = !this.sidebar.opened;
layout.sidebarStatus = this.sidebar.opened; layout.sidebarStatus = this.sidebar.opened;
} }
storageLocal.setItem("responsive-layout", layout); storageLocal().setItem("responsive-layout", layout);
}, },
async toggleSideBar(opened?: boolean, resize?: string) { async toggleSideBar(opened?: boolean, resize?: string) {
await this.TOGGLE_SIDEBAR(opened, resize); await this.TOGGLE_SIDEBAR(opened, resize);

View File

@@ -7,10 +7,10 @@ export const useEpThemeStore = defineStore({
id: "pure-epTheme", id: "pure-epTheme",
state: () => ({ state: () => ({
epThemeColor: epThemeColor:
storageLocal.getItem<StorageConfigs>("responsive-layout")?.epThemeColor ?? storageLocal().getItem<StorageConfigs>("responsive-layout")
getConfig().EpThemeColor, ?.epThemeColor ?? getConfig().EpThemeColor,
epTheme: epTheme:
storageLocal.getItem<StorageConfigs>("responsive-layout")?.theme ?? storageLocal().getItem<StorageConfigs>("responsive-layout")?.theme ??
getConfig().Theme getConfig().Theme
}), }),
getters: { getters: {
@@ -30,12 +30,13 @@ export const useEpThemeStore = defineStore({
}, },
actions: { actions: {
setEpThemeColor(newColor: string): void { setEpThemeColor(newColor: string): void {
const layout = storageLocal.getItem<StorageConfigs>("responsive-layout"); const layout =
storageLocal().getItem<StorageConfigs>("responsive-layout");
this.epTheme = layout?.theme; this.epTheme = layout?.theme;
this.epThemeColor = newColor; this.epThemeColor = newColor;
if (!layout) return; if (!layout) return;
layout.epThemeColor = newColor; layout.epThemeColor = newColor;
storageLocal.setItem("responsive-layout", layout); storageLocal().setItem("responsive-layout", layout);
} }
} }
}); });

View File

@@ -9,12 +9,13 @@ export const useMultiTagsStore = defineStore({
id: "pure-multiTags", id: "pure-multiTags",
state: () => ({ state: () => ({
// 存储标签页信息(路由信息) // 存储标签页信息(路由信息)
multiTags: storageLocal.getItem<StorageConfigs>("responsive-configure") multiTags: storageLocal().getItem<StorageConfigs>("responsive-configure")
?.multiTagsCache ?.multiTagsCache
? storageLocal.getItem<StorageConfigs>("responsive-tags") ? storageLocal().getItem<StorageConfigs>("responsive-tags")
: [...routerArrays], : [...routerArrays],
multiTagsCache: storageLocal.getItem<StorageConfigs>("responsive-configure") multiTagsCache: storageLocal().getItem<StorageConfigs>(
?.multiTagsCache "responsive-configure"
)?.multiTagsCache
}), }),
getters: { getters: {
getMultiTagsCache() { getMultiTagsCache() {
@@ -25,14 +26,14 @@ export const useMultiTagsStore = defineStore({
multiTagsCacheChange(multiTagsCache: boolean) { multiTagsCacheChange(multiTagsCache: boolean) {
this.multiTagsCache = multiTagsCache; this.multiTagsCache = multiTagsCache;
if (multiTagsCache) { if (multiTagsCache) {
storageLocal.setItem("responsive-tags", this.multiTags); storageLocal().setItem("responsive-tags", this.multiTags);
} else { } else {
storageLocal.removeItem("responsive-tags"); storageLocal().removeItem("responsive-tags");
} }
}, },
tagsCache(multiTags) { tagsCache(multiTags) {
this.getMultiTagsCache && this.getMultiTagsCache &&
storageLocal.setItem("responsive-tags", multiTags); storageLocal().setItem("responsive-tags", multiTags);
}, },
handleTags<T>( handleTags<T>(
mode: string, mode: string,

View File

@@ -14,9 +14,9 @@ export const useUserStore = defineStore({
state: (): userType => ({ state: (): userType => ({
// 用户名 // 用户名
username: username:
storageSession.getItem<DataInfo<number>>(sessionKey)?.username ?? "", storageSession().getItem<DataInfo<number>>(sessionKey)?.username ?? "",
// 页面级别权限 // 页面级别权限
roles: storageSession.getItem<DataInfo<number>>(sessionKey)?.roles ?? [] roles: storageSession().getItem<DataInfo<number>>(sessionKey)?.roles ?? []
}), }),
actions: { actions: {
/** 存储用户名 */ /** 存储用户名 */

View File

@@ -1,4 +1,4 @@
@import "element-plus/theme-chalk/src/dark/css-vars.scss"; @use "element-plus/theme-chalk/src/dark/css-vars.scss" as *;
/* 暗黑模式适配 */ /* 暗黑模式适配 */
html.dark { html.dark {

View File

@@ -3,7 +3,6 @@
@import "./element-plus.scss"; @import "./element-plus.scss";
@import "./sidebar.scss"; @import "./sidebar.scss";
@import "./dark.scss"; @import "./dark.scss";
@import "./tailwind.css";
/* 自定义全局 CssVar */ /* 自定义全局 CssVar */
:root { :root {

View File

@@ -23,7 +23,7 @@ export function getToken(): DataInfo<number> {
// 此处与`TokenKey`相同,此写法解决初始化时`Cookies`中不存在`TokenKey`报错 // 此处与`TokenKey`相同,此写法解决初始化时`Cookies`中不存在`TokenKey`报错
return Cookies.get(TokenKey) return Cookies.get(TokenKey)
? JSON.parse(Cookies.get(TokenKey)) ? JSON.parse(Cookies.get(TokenKey))
: storageSession.getItem(sessionKey); : storageSession().getItem(sessionKey);
} }
/** /**
@@ -47,7 +47,7 @@ export function setToken(data: DataInfo<Date>) {
function setSessionKey(username: string, roles: Array<string>) { function setSessionKey(username: string, roles: Array<string>) {
useUserStoreHook().SET_USERNAME(username); useUserStoreHook().SET_USERNAME(username);
useUserStoreHook().SET_ROLES(roles); useUserStoreHook().SET_ROLES(roles);
storageSession.setItem(sessionKey, { storageSession().setItem(sessionKey, {
refreshToken, refreshToken,
expires, expires,
username, username,
@@ -60,9 +60,9 @@ export function setToken(data: DataInfo<Date>) {
setSessionKey(username, roles); setSessionKey(username, roles);
} else { } else {
const username = const username =
storageSession.getItem<DataInfo<number>>(sessionKey)?.username ?? ""; storageSession().getItem<DataInfo<number>>(sessionKey)?.username ?? "";
const roles = const roles =
storageSession.getItem<DataInfo<number>>(sessionKey)?.roles ?? []; storageSession().getItem<DataInfo<number>>(sessionKey)?.roles ?? [];
setSessionKey(username, roles); setSessionKey(username, roles);
} }
} }

View File

@@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { initRouter } from "@/router/utils"; import { initRouter } from "@/router/utils";
import { storageSession } from "@pureadmin/utils";
import { type CSSProperties, ref, computed } from "vue"; import { type CSSProperties, ref, computed } from "vue";
import { useUserStoreHook } from "@/store/modules/user"; import { useUserStoreHook } from "@/store/modules/user";
import { usePermissionStoreHook } from "@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";
@@ -33,7 +34,7 @@ function onChange() {
.loginByUsername({ username: username.value, password: "admin123" }) .loginByUsername({ username: username.value, password: "admin123" })
.then(res => { .then(res => {
if (res.success) { if (res.success) {
sessionStorage.removeItem("async-routes"); storageSession().removeItem("async-routes");
usePermissionStoreHook().clearAllCachePage(); usePermissionStoreHook().clearAllCachePage();
initRouter(); initRouter();
} }

View File

@@ -8,6 +8,3 @@ declare module "*.scss" {
const scss: Record<string, string>; const scss: Record<string, string>;
export default scss; export default scss;
} }
declare module "@pureadmin/theme";
declare module "@pureadmin/theme/dist/browser-utils";