mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-12-14 22:30:31 +08:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51fd06c6a1 | ||
|
|
4bb8647990 | ||
|
|
a43d5ce865 | ||
|
|
aea8605a60 | ||
|
|
eb9d1e8238 | ||
|
|
138e0fd2e4 | ||
|
|
526023e0b0 | ||
|
|
885cbf2d9f | ||
|
|
e161102495 | ||
|
|
5300781d05 | ||
|
|
2e7e2ee3ce | ||
|
|
aa165ff70b | ||
|
|
b77ba43572 | ||
|
|
7cc69ac52d | ||
|
|
1b93ce989c | ||
|
|
9e5fe5edbc |
@@ -37,7 +37,7 @@ module.exports = {
|
|||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"@vue/typescript/recommended",
|
"@vue/typescript/recommended",
|
||||||
"@vue/prettier",
|
"@vue/prettier",
|
||||||
"@vue/prettier/@typescript-eslint"
|
"@vue/eslint-config-typescript"
|
||||||
],
|
],
|
||||||
parser: "vue-eslint-parser",
|
parser: "vue-eslint-parser",
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
@@ -50,6 +50,10 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
|
"vue/no-v-html": "off",
|
||||||
|
"vue/require-default-prop": "off",
|
||||||
|
"vue/require-explicit-emits": "off",
|
||||||
|
"vue/multi-word-component-names": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "off", // any
|
"@typescript-eslint/no-explicit-any": "off", // any
|
||||||
"no-debugger": "off",
|
"no-debugger": "off",
|
||||||
"@typescript-eslint/explicit-module-boundary-types": "off", // setup()
|
"@typescript-eslint/explicit-module-boundary-types": "off", // setup()
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ dist
|
|||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
yarn.lock
|
yarn.lock
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
bracketSpacing: true,
|
bracketSpacing: true,
|
||||||
jsxBracketSameLine: true,
|
|
||||||
singleQuote: false,
|
singleQuote: false,
|
||||||
arrowParens: "avoid",
|
arrowParens: "avoid",
|
||||||
trailingComma: "none"
|
trailingComma: "none"
|
||||||
|
|||||||
@@ -40,3 +40,7 @@ bilibili: https://www.bilibili.com/video/BV1534y1S7HV/
|
|||||||
## ⚠️ Note
|
## ⚠️ Note
|
||||||
|
|
||||||
The lite version does not accept any issues and prs. If you have any questions, please go to the full version https://github.com/xiaoxian521/vue-pure-admin/issues/new/choose to mention it, thank you! ! !
|
The lite version does not accept any issues and prs. If you have any questions, please go to the full version https://github.com/xiaoxian521/vue-pure-admin/issues/new/choose to mention it, thank you! ! !
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
In principle, no fees and copyrights are charged, and you can use it with confidence, but if you need secondary open source, please contact the author for permission!
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -27,11 +27,11 @@
|
|||||||
|
|
||||||
<img src="http://yiming_chang.gitee.io/manages/pay.jpg" width="150px" height="150px" />
|
<img src="http://yiming_chang.gitee.io/manages/pay.jpg" width="150px" height="150px" />
|
||||||
|
|
||||||
## 付费咨询、需求定制
|
## QQ 交流群
|
||||||
|
|
||||||
作者精力有限,需要提供技术服务的可扫下面的二维码加微信,添加请备注来意
|
群里严禁`黄`、`赌`、`毒`、`vpn`等违法行为!
|
||||||
|
|
||||||
<img src="http://yiming_chang.gitee.io/manages/wechat.jpg" width="150px" height="150px" />
|
<img src="http://yiming_chang.gitee.io/manages/qq.jpg" width="150px" height="225px" />
|
||||||
|
|
||||||
## 用法
|
## 用法
|
||||||
|
|
||||||
@@ -52,3 +52,7 @@ pnpm remove 包名
|
|||||||
## ⚠️ 注意
|
## ⚠️ 注意
|
||||||
|
|
||||||
精简版不接受任何 issues 和 pr,如果有问题请到完整版 https://github.com/xiaoxian521/vue-pure-admin/issues/new/choose 去提,谢谢!!!
|
精简版不接受任何 issues 和 pr,如果有问题请到完整版 https://github.com/xiaoxian521/vue-pure-admin/issues/new/choose 去提,谢谢!!!
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
原则上不收取任何费用及版权,可以放心使用,不过如需二次开源(比如用此平台二次开发并开源)请联系作者获取许可!
|
||||||
|
|||||||
85
build/info.ts
Normal file
85
build/info.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import { readdir, stat } from "fs";
|
||||||
|
import type { Plugin } from "vite";
|
||||||
|
import dayjs, { Dayjs } from "dayjs";
|
||||||
|
import { sum } from "lodash-unified";
|
||||||
|
import duration from "dayjs/plugin/duration";
|
||||||
|
import { green, blue, bold } from "picocolors";
|
||||||
|
dayjs.extend(duration);
|
||||||
|
|
||||||
|
const staticPath = "dist";
|
||||||
|
const fileListTotal: number[] = [];
|
||||||
|
|
||||||
|
const recursiveDirectory = (folder: string, callback: Function): void => {
|
||||||
|
readdir(folder, (err, files: string[]) => {
|
||||||
|
if (err) throw err;
|
||||||
|
let count = 0;
|
||||||
|
const checkEnd = () => {
|
||||||
|
++count == files.length && callback();
|
||||||
|
};
|
||||||
|
files.forEach((item: string) => {
|
||||||
|
stat(folder + "/" + item, async (err, stats) => {
|
||||||
|
if (err) throw err;
|
||||||
|
if (stats.isFile()) {
|
||||||
|
fileListTotal.push(stats.size);
|
||||||
|
checkEnd();
|
||||||
|
} else if (stats.isDirectory()) {
|
||||||
|
recursiveDirectory(`${staticPath}/${item}/`, checkEnd);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
files.length === 0 && callback();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatBytes = (a: number, b?: number): string => {
|
||||||
|
if (0 == a) return "0 Bytes";
|
||||||
|
const c = 1024,
|
||||||
|
d = b || 2,
|
||||||
|
e = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
||||||
|
f = Math.floor(Math.log(a) / Math.log(c));
|
||||||
|
return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f];
|
||||||
|
};
|
||||||
|
|
||||||
|
export function viteBuildInfo(): Plugin {
|
||||||
|
let config: { command: string };
|
||||||
|
let startTime: Dayjs;
|
||||||
|
let endTime: Dayjs;
|
||||||
|
return {
|
||||||
|
name: "vite:buildInfo",
|
||||||
|
configResolved(resolvedConfig: { command: string }) {
|
||||||
|
config = resolvedConfig;
|
||||||
|
},
|
||||||
|
buildStart() {
|
||||||
|
if (config.command === "build") {
|
||||||
|
startTime = dayjs(new Date());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
closeBundle() {
|
||||||
|
if (config.command === "build") {
|
||||||
|
console.log(
|
||||||
|
bold(
|
||||||
|
green(
|
||||||
|
`👏欢迎使用${blue(
|
||||||
|
"[vue-pure-admin]"
|
||||||
|
)},如果您感觉不错,记得点击后面链接给个star哦💖 https://github.com/xiaoxian521/vue-pure-admin`
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
endTime = dayjs(new Date());
|
||||||
|
recursiveDirectory(staticPath, () => {
|
||||||
|
console.log(
|
||||||
|
bold(
|
||||||
|
green(
|
||||||
|
`恭喜打包完成🎉(总用时${dayjs
|
||||||
|
.duration(endTime.diff(startTime))
|
||||||
|
.format("mm分ss秒")},打包后的大小为${formatBytes(
|
||||||
|
sum(fileListTotal)
|
||||||
|
)})`
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
|
import { viteBuildInfo } from "./info";
|
||||||
import svgLoader from "vite-svg-loader";
|
import svgLoader from "vite-svg-loader";
|
||||||
import legacy from "@vitejs/plugin-legacy";
|
import legacy from "@vitejs/plugin-legacy";
|
||||||
import vueJsx from "@vitejs/plugin-vue-jsx";
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||||
@@ -6,11 +7,13 @@ import WindiCSS from "vite-plugin-windicss";
|
|||||||
import { viteMockServe } from "vite-plugin-mock";
|
import { viteMockServe } from "vite-plugin-mock";
|
||||||
import liveReload from "vite-plugin-live-reload";
|
import liveReload from "vite-plugin-live-reload";
|
||||||
import ElementPlus from "unplugin-element-plus/vite";
|
import ElementPlus from "unplugin-element-plus/vite";
|
||||||
|
import { visualizer } from "rollup-plugin-visualizer";
|
||||||
import removeConsole from "vite-plugin-remove-console";
|
import removeConsole from "vite-plugin-remove-console";
|
||||||
import themePreprocessorPlugin from "@zougt/vite-plugin-theme-preprocessor";
|
import themePreprocessorPlugin from "@zougt/vite-plugin-theme-preprocessor";
|
||||||
|
|
||||||
export function getPluginsList(command, VITE_LEGACY) {
|
export function getPluginsList(command, VITE_LEGACY) {
|
||||||
const prodMock = true;
|
const prodMock = true;
|
||||||
|
const lifecycle = process.env.npm_lifecycle_event;
|
||||||
return [
|
return [
|
||||||
vue(),
|
vue(),
|
||||||
// jsx、tsx语法支持
|
// jsx、tsx语法支持
|
||||||
@@ -18,6 +21,7 @@ export function getPluginsList(command, VITE_LEGACY) {
|
|||||||
WindiCSS(),
|
WindiCSS(),
|
||||||
// 线上环境删除console
|
// 线上环境删除console
|
||||||
removeConsole(),
|
removeConsole(),
|
||||||
|
viteBuildInfo(),
|
||||||
// 修改layout文件夹下的文件时自动重载浏览器 解决 https://github.com/xiaoxian521/vue-pure-admin/issues/170
|
// 修改layout文件夹下的文件时自动重载浏览器 解决 https://github.com/xiaoxian521/vue-pure-admin/issues/170
|
||||||
liveReload(["src/layout/**/*", "src/router/**/*"]),
|
liveReload(["src/layout/**/*", "src/router/**/*"]),
|
||||||
// 自定义主题
|
// 自定义主题
|
||||||
@@ -97,6 +101,10 @@ export function getPluginsList(command, VITE_LEGACY) {
|
|||||||
targets: ["ie >= 11"],
|
targets: ["ie >= 11"],
|
||||||
additionalLegacyPolyfills: ["regenerator-runtime/runtime"]
|
additionalLegacyPolyfills: ["regenerator-runtime/runtime"]
|
||||||
})
|
})
|
||||||
|
: null,
|
||||||
|
// 打包分析
|
||||||
|
lifecycle === "report"
|
||||||
|
? visualizer({ open: true, brotliSize: true, filename: "report.html" })
|
||||||
: null
|
: null
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
14
index.html
14
index.html
@@ -13,20 +13,16 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<style>
|
<style>
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
html,
|
html,
|
||||||
body {
|
body,
|
||||||
|
#app {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
position: relative;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
font-family: "Reggae One", cursive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.loader,
|
.loader,
|
||||||
@@ -52,6 +48,8 @@
|
|||||||
transform: translateZ(0);
|
transform: translateZ(0);
|
||||||
-webkit-animation-delay: -0.16s;
|
-webkit-animation-delay: -0.16s;
|
||||||
animation-delay: -0.16s;
|
animation-delay: -0.16s;
|
||||||
|
top: 0;
|
||||||
|
transform: translate(-50%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.loader:before,
|
.loader:before,
|
||||||
@@ -95,7 +93,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div class="loader">Loading...</div>
|
<div class="loader"></div>
|
||||||
</div>
|
</div>
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
64
package.json
64
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pure-admin-thin",
|
"name": "pure-admin-thin",
|
||||||
"version": "2.9.0",
|
"version": "3.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16",
|
"node": ">= 16",
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
"dev": "cross-env --max_old_space_size=4096 vite",
|
"dev": "cross-env --max_old_space_size=4096 vite",
|
||||||
"serve": "pnpm dev",
|
"serve": "pnpm dev",
|
||||||
"build": "rimraf dist && cross-env vite build",
|
"build": "rimraf dist && cross-env vite build",
|
||||||
|
"report": "rimraf dist && cross-env vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"preview:build": "pnpm build && vite preview",
|
"preview:build": "pnpm build && vite preview",
|
||||||
"clean:cache": "rm -rf node_modules && rm -rf .eslintcache && pnpm install",
|
"clean:cache": "rm -rf node_modules && rm -rf .eslintcache && pnpm install",
|
||||||
@@ -29,16 +30,18 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ctrl/tinycolor": "^3.4.0",
|
"@ctrl/tinycolor": "^3.4.0",
|
||||||
"@vueuse/core": "^7.5.5",
|
"@vueuse/core": "^7.6.2",
|
||||||
"@vueuse/motion": "^2.0.0-beta.9",
|
"@vueuse/motion": "^2.0.0-beta.9",
|
||||||
"@vueuse/shared": "^7.5.5",
|
"@vueuse/shared": "^7.6.2",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"axios": "^0.25.0",
|
"axios": "^0.25.0",
|
||||||
"css-color-function": "^1.3.3",
|
"css-color-function": "^1.3.3",
|
||||||
"element-plus": "1.3.0-beta.1",
|
"dayjs": "^1.10.7",
|
||||||
|
"element-plus": "^2.0.3",
|
||||||
"element-resize-detector": "^1.2.3",
|
"element-resize-detector": "^1.2.3",
|
||||||
"js-cookie": "^3.0.1",
|
"js-cookie": "^3.0.1",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
|
"lodash-unified": "^1.0.2",
|
||||||
"mitt": "^3.0.0",
|
"mitt": "^3.0.0",
|
||||||
"mockjs": "^1.1.0",
|
"mockjs": "^1.1.0",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
@@ -48,9 +51,9 @@
|
|||||||
"resize-observer-polyfill": "^1.5.1",
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"responsive-storage": "^1.0.11",
|
"responsive-storage": "^1.0.11",
|
||||||
"rgb-hex": "^4.0.0",
|
"rgb-hex": "^4.0.0",
|
||||||
"vue": "^3.2.29",
|
"vue": "^3.2.31",
|
||||||
"vue-i18n": "^9.2.0-beta.30",
|
"vue-i18n": "^9.2.0-beta.30",
|
||||||
"vue-router": "^4.0.12",
|
"vue-router": "^4.0.13",
|
||||||
"vue-types": "^4.1.1"
|
"vue-types": "^4.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -63,47 +66,54 @@
|
|||||||
"@iconify/vue": "^3.1.3",
|
"@iconify/vue": "^3.1.3",
|
||||||
"@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-es": "^4.17.6",
|
||||||
"@types/mockjs": "1.0.3",
|
"@types/mockjs": "1.0.3",
|
||||||
"@types/node": "14.14.14",
|
"@types/node": "14.14.14",
|
||||||
"@types/nprogress": "0.2.0",
|
"@types/nprogress": "0.2.0",
|
||||||
"@types/qs": "^6.9.7",
|
"@types/qs": "^6.9.7",
|
||||||
"@typescript-eslint/eslint-plugin": "4.31.0",
|
"@typescript-eslint/eslint-plugin": "^5.10.2",
|
||||||
"@typescript-eslint/parser": "4.31.0",
|
"@typescript-eslint/parser": "^5.10.2",
|
||||||
"@vitejs/plugin-legacy": "^1.6.4",
|
"@vitejs/plugin-legacy": "^1.7.1",
|
||||||
"@vitejs/plugin-vue": "^2.1.0",
|
"@vitejs/plugin-vue": "^2.2.4",
|
||||||
"@vitejs/plugin-vue-jsx": "^1.3.3",
|
"@vitejs/plugin-vue-jsx": "^1.3.8",
|
||||||
"@vue/eslint-config-prettier": "6.0.0",
|
"@vue/eslint-config-prettier": "^7.0.0",
|
||||||
"@vue/eslint-config-typescript": "7.0.0",
|
"@vue/eslint-config-typescript": "^10.0.0",
|
||||||
"@zougt/vite-plugin-theme-preprocessor": "^1.4.4",
|
"@zougt/vite-plugin-theme-preprocessor": "^1.4.4",
|
||||||
"autoprefixer": "^10.4.2",
|
"autoprefixer": "^10.4.2",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"eslint": "7.30.0",
|
"eslint": "^8.8.0",
|
||||||
"eslint-plugin-prettier": "3.4.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"eslint-plugin-vue": "7.17.0",
|
"eslint-plugin-vue": "^8.4.1",
|
||||||
"husky": "7.0.2",
|
"husky": "7.0.2",
|
||||||
"lint-staged": "11.1.2",
|
"lint-staged": "11.1.2",
|
||||||
"postcss": "8.2.6",
|
"picocolors": "^1.0.0",
|
||||||
|
"postcss": "^8.4.6",
|
||||||
|
"postcss-html": "^1.3.0",
|
||||||
"postcss-import": "14.0.0",
|
"postcss-import": "14.0.0",
|
||||||
"prettier": "2.3.2",
|
"postcss-scss": "^4.0.3",
|
||||||
|
"prettier": "^2.5.1",
|
||||||
"pretty-quick": "3.1.1",
|
"pretty-quick": "3.1.1",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
|
"rollup-plugin-visualizer": "^5.6.0",
|
||||||
"sass": "^1.49.0",
|
"sass": "^1.49.0",
|
||||||
"sass-loader": "^12.4.0",
|
"sass-loader": "^12.4.0",
|
||||||
"stylelint": "13.13.1",
|
"stylelint": "^14.3.0",
|
||||||
"stylelint-config-prettier": "8.0.2",
|
"stylelint-config-html": "^1.0.0",
|
||||||
"stylelint-config-standard": "22.0.0",
|
"stylelint-config-prettier": "^9.0.3",
|
||||||
"stylelint-order": "4.1.0",
|
"stylelint-config-recommended": "^6.0.0",
|
||||||
|
"stylelint-config-standard": "^24.0.0",
|
||||||
|
"stylelint-order": "^5.0.0",
|
||||||
"typescript": "^4.5.5",
|
"typescript": "^4.5.5",
|
||||||
"unplugin-element-plus": "^0.2.0",
|
"unplugin-element-plus": "^0.2.0",
|
||||||
"vite": "^2.7.13",
|
"vite": "^2.8.6",
|
||||||
"vite-plugin-live-reload": "^2.1.0",
|
"vite-plugin-live-reload": "^2.1.0",
|
||||||
"vite-plugin-mock": "^2.9.6",
|
"vite-plugin-mock": "^2.9.6",
|
||||||
"vite-plugin-remove-console": "^0.0.6",
|
"vite-plugin-remove-console": "^0.0.6",
|
||||||
"vite-plugin-style-import": "^1.4.1",
|
"vite-plugin-style-import": "1.4.1",
|
||||||
"vite-plugin-windicss": "^1.6.3",
|
"vite-plugin-windicss": "^1.8.2",
|
||||||
"vite-svg-loader": "2.2.0",
|
"vite-svg-loader": "2.2.0",
|
||||||
"vue-eslint-parser": "7.10.0",
|
"vue-eslint-parser": "^8.2.0",
|
||||||
"windicss": "^3.4.3"
|
"windicss": "^3.5.1"
|
||||||
},
|
},
|
||||||
"repository": "git@github.com:xiaoxian521/vue-pure-admin.git",
|
"repository": "git@github.com:xiaoxian521/vue-pure-admin.git",
|
||||||
"author": "xiaoxian521",
|
"author": "xiaoxian521",
|
||||||
|
|||||||
2456
pnpm-lock.yaml
generated
2456
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"Version": "2.9.0",
|
"Version": "3.1.0",
|
||||||
"Title": "PureAdmin",
|
"Title": "PureAdmin",
|
||||||
"FixedHeader": true,
|
"FixedHeader": true,
|
||||||
"HiddenSideBar": false,
|
"HiddenSideBar": false,
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
|
import { iconType } from "./types";
|
||||||
import { h, defineComponent, Component } from "vue";
|
import { h, defineComponent, Component } from "vue";
|
||||||
import { IconifyIconOffline, FontIcon } from "../index";
|
import { IconifyIconOffline, FontIcon } from "../index";
|
||||||
|
|
||||||
// 支持fontawesome4、5+、iconfont、remixicon、element-plus的icons、自定义svg
|
/**
|
||||||
export function useRenderIcon(icon: string): Component {
|
* 支持fontawesome4、5+、iconfont、remixicon、element-plus的icons、自定义svg
|
||||||
|
* @param icon 必传 string 图标
|
||||||
|
* @param attrs 可选 iconType 属性
|
||||||
|
* @returns Component
|
||||||
|
*/
|
||||||
|
export function useRenderIcon(icon: string, attrs?: iconType): Component {
|
||||||
// iconfont
|
// iconfont
|
||||||
const ifReg = /^IF-/;
|
const ifReg = /^IF-/;
|
||||||
// typeof icon === "function" 属于SVG
|
// typeof icon === "function" 属于SVG
|
||||||
@@ -19,7 +25,8 @@ export function useRenderIcon(icon: string): Component {
|
|||||||
render() {
|
render() {
|
||||||
return h(FontIcon, {
|
return h(FontIcon, {
|
||||||
icon: iconName,
|
icon: iconName,
|
||||||
iconType
|
iconType,
|
||||||
|
...attrs
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -31,7 +38,8 @@ export function useRenderIcon(icon: string): Component {
|
|||||||
name: "Icon",
|
name: "Icon",
|
||||||
render() {
|
render() {
|
||||||
return h(IconifyIconOffline, {
|
return h(IconifyIconOffline, {
|
||||||
icon: icon
|
icon: icon,
|
||||||
|
...attrs
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ addIcon("notebook", Notebook);
|
|||||||
import arrowRightSLine from "@iconify-icons/ri/arrow-right-s-line";
|
import arrowRightSLine from "@iconify-icons/ri/arrow-right-s-line";
|
||||||
import arrowLeftSLine from "@iconify-icons/ri/arrow-left-s-line";
|
import arrowLeftSLine from "@iconify-icons/ri/arrow-left-s-line";
|
||||||
import logoutCircleRLine from "@iconify-icons/ri/logout-circle-r-line";
|
import logoutCircleRLine from "@iconify-icons/ri/logout-circle-r-line";
|
||||||
|
import nodeTree from "@iconify-icons/ri/node-tree";
|
||||||
addIcon("arrow-right-s-line", arrowRightSLine);
|
addIcon("arrow-right-s-line", arrowRightSLine);
|
||||||
addIcon("arrow-left-s-line", arrowLeftSLine);
|
addIcon("arrow-left-s-line", arrowLeftSLine);
|
||||||
addIcon("logout-circle-r-line", logoutCircleRLine);
|
addIcon("logout-circle-r-line", logoutCircleRLine);
|
||||||
|
addIcon("node-tree", nodeTree);
|
||||||
|
|
||||||
// Font Awesome 4
|
// Font Awesome 4
|
||||||
import faUser from "@iconify-icons/fa/user";
|
import faUser from "@iconify-icons/fa/user";
|
||||||
|
|||||||
18
src/components/ReIcon/src/types.ts
Normal file
18
src/components/ReIcon/src/types.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
export interface iconType {
|
||||||
|
// iconify (https://docs.iconify.design/icon-components/vue/#properties)
|
||||||
|
inline?: boolean;
|
||||||
|
width?: string | number;
|
||||||
|
height?: string | number;
|
||||||
|
horizontalFlip?: boolean;
|
||||||
|
verticalFlip?: boolean;
|
||||||
|
flip?: string;
|
||||||
|
rotate?: number | string;
|
||||||
|
color?: string;
|
||||||
|
horizontalAlign?: boolean;
|
||||||
|
verticalAlign?: boolean;
|
||||||
|
align?: string;
|
||||||
|
onLoad?: Function;
|
||||||
|
|
||||||
|
// all icon
|
||||||
|
style?: object;
|
||||||
|
}
|
||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
defineComponent,
|
defineComponent,
|
||||||
getCurrentInstance
|
getCurrentInstance
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import { RouterView } from "vue-router";
|
|
||||||
import backTop from "/@/assets/svg/back_top.svg?component";
|
import backTop from "/@/assets/svg/back_top.svg?component";
|
||||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||||
|
|
||||||
|
|||||||
@@ -1,71 +1,43 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from "vue";
|
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { emitter } from "/@/utils/mitt";
|
import { useNav } from "../hooks/nav";
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
import Notice from "./notice/index.vue";
|
import Notice from "./notice/index.vue";
|
||||||
|
import mixNav from "./sidebar/mixNav.vue";
|
||||||
import avatars from "/@/assets/avatars.jpg";
|
import avatars from "/@/assets/avatars.jpg";
|
||||||
import { transformI18n } from "/@/plugins/i18n";
|
|
||||||
import Hamburger from "./sidebar/hamBurger.vue";
|
import Hamburger from "./sidebar/hamBurger.vue";
|
||||||
import { useRouter, useRoute } from "vue-router";
|
import { watch, getCurrentInstance } from "vue";
|
||||||
import { storageSession } from "/@/utils/storage";
|
|
||||||
import Breadcrumb from "./sidebar/breadCrumb.vue";
|
import Breadcrumb from "./sidebar/breadCrumb.vue";
|
||||||
import { useAppStoreHook } from "/@/store/modules/app";
|
|
||||||
import { unref, watch, getCurrentInstance } from "vue";
|
|
||||||
import { deviceDetection } from "/@/utils/deviceDetection";
|
import { deviceDetection } from "/@/utils/deviceDetection";
|
||||||
import screenfull from "../components/screenfull/index.vue";
|
import screenfull from "../components/screenfull/index.vue";
|
||||||
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
|
|
||||||
import globalization from "/@/assets/svg/globalization.svg?component";
|
import globalization from "/@/assets/svg/globalization.svg?component";
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const { locale } = useI18n();
|
||||||
const instance =
|
const instance =
|
||||||
getCurrentInstance().appContext.config.globalProperties.$storage;
|
getCurrentInstance().appContext.config.globalProperties.$storage;
|
||||||
const pureApp = useAppStoreHook();
|
const {
|
||||||
const router = useRouter();
|
logout,
|
||||||
const route = useRoute();
|
onPanel,
|
||||||
let usename = storageSession.getItem("info")?.username;
|
changeTitle,
|
||||||
const { locale } = useI18n();
|
toggleSideBar,
|
||||||
|
pureApp,
|
||||||
const getDropdownItemStyle = computed(() => {
|
usename,
|
||||||
return t => {
|
getDropdownItemStyle
|
||||||
return {
|
} = useNav();
|
||||||
background: locale.value === t ? useEpThemeStoreHook().epThemeColor : "",
|
|
||||||
color: locale.value === t ? "#f4f4f5" : "#000"
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => locale.value,
|
() => locale.value,
|
||||||
() => {
|
() => {
|
||||||
//@ts-ignore
|
changeTitle(route.meta);
|
||||||
document.title = transformI18n(
|
|
||||||
//@ts-ignore
|
|
||||||
unref(route.meta.title),
|
|
||||||
unref(route.meta.i18n)
|
|
||||||
); // 动态title
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// 退出登录
|
|
||||||
const logout = (): void => {
|
|
||||||
storageSession.removeItem("info");
|
|
||||||
router.push("/login");
|
|
||||||
};
|
|
||||||
|
|
||||||
function onPanel() {
|
|
||||||
emitter.emit("openPanel");
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleSideBar() {
|
|
||||||
pureApp.toggleSideBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 简体中文
|
|
||||||
function translationCh() {
|
function translationCh() {
|
||||||
instance.locale = { locale: "zh" };
|
instance.locale = { locale: "zh" };
|
||||||
locale.value = "zh";
|
locale.value = "zh";
|
||||||
}
|
}
|
||||||
|
|
||||||
// English
|
|
||||||
function translationEn() {
|
function translationEn() {
|
||||||
instance.locale = { locale: "en" };
|
instance.locale = { locale: "en" };
|
||||||
locale.value = "en";
|
locale.value = "en";
|
||||||
@@ -75,14 +47,17 @@ function translationEn() {
|
|||||||
<template>
|
<template>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<Hamburger
|
<Hamburger
|
||||||
|
v-if="pureApp.layout !== 'mix'"
|
||||||
:is-active="pureApp.sidebar.opened"
|
:is-active="pureApp.sidebar.opened"
|
||||||
class="hamburger-container"
|
class="hamburger-container"
|
||||||
@toggleClick="toggleSideBar"
|
@toggleClick="toggleSideBar"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Breadcrumb class="breadcrumb-container" />
|
<Breadcrumb v-if="pureApp.layout !== 'mix'" class="breadcrumb-container" />
|
||||||
|
|
||||||
<div class="vertical-header-right">
|
<mixNav v-if="pureApp.layout === 'mix'" />
|
||||||
|
|
||||||
|
<div v-if="pureApp.layout === 'vertical'" class="vertical-header-right">
|
||||||
<!-- 通知 -->
|
<!-- 通知 -->
|
||||||
<Notice id="header-notice" />
|
<Notice id="header-notice" />
|
||||||
<!-- 全屏 -->
|
<!-- 全屏 -->
|
||||||
@@ -93,7 +68,7 @@ function translationEn() {
|
|||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu class="translation">
|
<el-dropdown-menu class="translation">
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
:style="getDropdownItemStyle('zh')"
|
:style="getDropdownItemStyle(locale, 'zh')"
|
||||||
@click="translationCh"
|
@click="translationCh"
|
||||||
><IconifyIconOffline
|
><IconifyIconOffline
|
||||||
class="check-zh"
|
class="check-zh"
|
||||||
@@ -102,7 +77,7 @@ function translationEn() {
|
|||||||
/>简体中文</el-dropdown-item
|
/>简体中文</el-dropdown-item
|
||||||
>
|
>
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
:style="getDropdownItemStyle('en')"
|
:style="getDropdownItemStyle(locale, 'en')"
|
||||||
@click="translationEn"
|
@click="translationEn"
|
||||||
><el-icon class="check-en" v-show="locale === 'en'"
|
><el-icon class="check-en" v-show="locale === 'en'"
|
||||||
><IconifyIconOffline icon="check" /></el-icon
|
><IconifyIconOffline icon="check" /></el-icon
|
||||||
@@ -234,14 +209,8 @@ function translationEn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.translation {
|
.translation {
|
||||||
.el-dropdown-menu__item {
|
::v-deep(.el-dropdown-menu__item) {
|
||||||
padding: 5px 40px !important;
|
padding: 5px 40px;
|
||||||
}
|
|
||||||
|
|
||||||
.el-dropdown-menu__item:focus,
|
|
||||||
.el-dropdown-menu__item:not(.is-disabled):hover {
|
|
||||||
color: #606266;
|
|
||||||
background: #f0f0f0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.check-zh {
|
.check-zh {
|
||||||
@@ -258,16 +227,10 @@ function translationEn() {
|
|||||||
.logout {
|
.logout {
|
||||||
max-width: 120px;
|
max-width: 120px;
|
||||||
|
|
||||||
.el-dropdown-menu__item {
|
::v-deep(.el-dropdown-menu__item) {
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-dropdown-menu__item:focus,
|
|
||||||
.el-dropdown-menu__item:not(.is-disabled):hover {
|
|
||||||
color: #606266;
|
|
||||||
background: #f0f0f0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ emitter.on("openPanel", () => {
|
|||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: red;
|
color: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
getCurrentInstance
|
getCurrentInstance
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import rgbHex from "rgb-hex";
|
import rgbHex from "rgb-hex";
|
||||||
import { find } from "lodash-es";
|
import { find } from "lodash-unified";
|
||||||
import { getConfig } from "/@/config";
|
import { getConfig } from "/@/config";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import panel from "../panel/index.vue";
|
import panel from "../panel/index.vue";
|
||||||
@@ -61,6 +61,7 @@ let themeColors = ref<Array<themeColorsType>>([
|
|||||||
|
|
||||||
const verticalRef = templateRef<HTMLElement | null>("verticalRef", null);
|
const verticalRef = templateRef<HTMLElement | null>("verticalRef", null);
|
||||||
const horizontalRef = templateRef<HTMLElement | null>("horizontalRef", null);
|
const horizontalRef = templateRef<HTMLElement | null>("horizontalRef", null);
|
||||||
|
const mixRef = templateRef<HTMLElement | null>("mixRef", null);
|
||||||
|
|
||||||
let layoutTheme =
|
let layoutTheme =
|
||||||
ref(storageLocal.getItem("responsive-layout")) ||
|
ref(storageLocal.getItem("responsive-layout")) ||
|
||||||
@@ -101,7 +102,7 @@ const getThemeColorStyle = computed(() => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
function changeStorageConfigure(key, val) {
|
function storageConfigureChange<T>(key: string, val: T): void {
|
||||||
const storageConfigure = instance.configure;
|
const storageConfigure = instance.configure;
|
||||||
storageConfigure[key] = val;
|
storageConfigure[key] = val;
|
||||||
instance.configure = storageConfigure;
|
instance.configure = storageConfigure;
|
||||||
@@ -110,14 +111,14 @@ function changeStorageConfigure(key, val) {
|
|||||||
function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) {
|
function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) {
|
||||||
const targetEl = target || document.body;
|
const targetEl = target || document.body;
|
||||||
let { className } = targetEl;
|
let { className } = targetEl;
|
||||||
className = className.replace(clsName, "");
|
className = className.replace(clsName, "").trim();
|
||||||
targetEl.className = flag ? `${className} ${clsName} ` : className;
|
targetEl.className = flag ? `${className} ${clsName} ` : className;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 灰色模式设置
|
// 灰色模式设置
|
||||||
const greyChange = (value): void => {
|
const greyChange = (value): void => {
|
||||||
toggleClass(settings.greyVal, "html-grey", document.querySelector("html"));
|
toggleClass(settings.greyVal, "html-grey", document.querySelector("html"));
|
||||||
changeStorageConfigure("grey", value);
|
storageConfigureChange("grey", value);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 色弱模式设置
|
// 色弱模式设置
|
||||||
@@ -127,29 +128,30 @@ const weekChange = (value): void => {
|
|||||||
"html-weakness",
|
"html-weakness",
|
||||||
document.querySelector("html")
|
document.querySelector("html")
|
||||||
);
|
);
|
||||||
changeStorageConfigure("weak", value);
|
storageConfigureChange("weak", value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const tagsChange = () => {
|
const tagsChange = () => {
|
||||||
let showVal = settings.tabsVal;
|
let showVal = settings.tabsVal;
|
||||||
changeStorageConfigure("hideTabs", showVal);
|
storageConfigureChange("hideTabs", showVal);
|
||||||
emitter.emit("tagViewsChange", showVal);
|
emitter.emit("tagViewsChange", showVal);
|
||||||
};
|
};
|
||||||
|
|
||||||
const multiTagsCacheChange = () => {
|
const multiTagsCacheChange = () => {
|
||||||
let multiTagsCache = settings.multiTagsCache;
|
let multiTagsCache = settings.multiTagsCache;
|
||||||
changeStorageConfigure("multiTagsCache", multiTagsCache);
|
storageConfigureChange("multiTagsCache", multiTagsCache);
|
||||||
useMultiTagsStoreHook().multiTagsCacheChange(multiTagsCache);
|
useMultiTagsStoreHook().multiTagsCacheChange(multiTagsCache);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 清空缓存并返回登录页
|
// 清空缓存并返回登录页
|
||||||
function onReset() {
|
function onReset() {
|
||||||
toggleClass(getConfig().Grey, "html-grey", document.querySelector("html"));
|
router.push("/login");
|
||||||
toggleClass(
|
const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig();
|
||||||
getConfig().Weak,
|
useAppStoreHook().setLayout(Layout);
|
||||||
"html-weakness",
|
useEpThemeStoreHook().setEpThemeColor(EpThemeColor);
|
||||||
document.querySelector("html")
|
useMultiTagsStoreHook().multiTagsCacheChange(MultiTagsCache);
|
||||||
);
|
toggleClass(Grey, "html-grey", document.querySelector("html"));
|
||||||
|
toggleClass(Weak, "html-weakness", document.querySelector("html"));
|
||||||
useMultiTagsStoreHook().handleTags("equal", [
|
useMultiTagsStoreHook().handleTags("equal", [
|
||||||
{
|
{
|
||||||
path: "/welcome",
|
path: "/welcome",
|
||||||
@@ -161,23 +163,20 @@ function onReset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
useMultiTagsStoreHook().multiTagsCacheChange(getConfig().MultiTagsCache);
|
|
||||||
useEpThemeStoreHook().setEpThemeColor(getConfig().EpThemeColor);
|
|
||||||
storageLocal.clear();
|
storageLocal.clear();
|
||||||
storageSession.clear();
|
storageSession.clear();
|
||||||
router.push("/login");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChange(label) {
|
function onChange(label) {
|
||||||
changeStorageConfigure("showModel", label);
|
storageConfigureChange("showModel", label);
|
||||||
emitter.emit("tagViewsShowModel", label);
|
emitter.emit("tagViewsShowModel", label);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 侧边栏Logo
|
// 侧边栏Logo
|
||||||
function logoChange() {
|
function logoChange() {
|
||||||
unref(logoVal)
|
unref(logoVal)
|
||||||
? changeStorageConfigure("showLogo", true)
|
? storageConfigureChange("showLogo", true)
|
||||||
: changeStorageConfigure("showLogo", false);
|
: storageConfigureChange("showLogo", false);
|
||||||
emitter.emit("logoChange", unref(logoVal));
|
emitter.emit("logoChange", unref(logoVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,10 +191,17 @@ watch(instance, ({ layout }) => {
|
|||||||
case "vertical":
|
case "vertical":
|
||||||
toggleClass(true, isSelect, unref(verticalRef));
|
toggleClass(true, isSelect, unref(verticalRef));
|
||||||
debounce(setFalse([horizontalRef]), 50);
|
debounce(setFalse([horizontalRef]), 50);
|
||||||
|
debounce(setFalse([mixRef]), 50);
|
||||||
break;
|
break;
|
||||||
case "horizontal":
|
case "horizontal":
|
||||||
toggleClass(true, isSelect, unref(horizontalRef));
|
toggleClass(true, isSelect, unref(horizontalRef));
|
||||||
debounce(setFalse([verticalRef]), 50);
|
debounce(setFalse([verticalRef]), 50);
|
||||||
|
debounce(setFalse([mixRef]), 50);
|
||||||
|
break;
|
||||||
|
case "mix":
|
||||||
|
toggleClass(true, isSelect, unref(mixRef));
|
||||||
|
debounce(setFalse([verticalRef]), 50);
|
||||||
|
debounce(setFalse([horizontalRef]), 50);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -315,7 +321,7 @@ nextTick(() => {
|
|||||||
|
|
||||||
<el-divider>导航栏模式</el-divider>
|
<el-divider>导航栏模式</el-divider>
|
||||||
<ul class="pure-theme">
|
<ul class="pure-theme">
|
||||||
<el-tooltip class="item" content="左侧菜单模式" placement="bottom">
|
<el-tooltip class="item" content="左侧模式" placement="bottom">
|
||||||
<li
|
<li
|
||||||
:class="layoutTheme.layout === 'vertical' ? $style.isSelect : ''"
|
:class="layoutTheme.layout === 'vertical' ? $style.isSelect : ''"
|
||||||
ref="verticalRef"
|
ref="verticalRef"
|
||||||
@@ -326,7 +332,7 @@ nextTick(() => {
|
|||||||
</li>
|
</li>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
<el-tooltip class="item" content="顶部菜单模式" placement="bottom">
|
<el-tooltip class="item" content="顶部模式" placement="bottom">
|
||||||
<li
|
<li
|
||||||
:class="layoutTheme.layout === 'horizontal' ? $style.isSelect : ''"
|
:class="layoutTheme.layout === 'horizontal' ? $style.isSelect : ''"
|
||||||
ref="horizontalRef"
|
ref="horizontalRef"
|
||||||
@@ -336,6 +342,17 @@ nextTick(() => {
|
|||||||
<div></div>
|
<div></div>
|
||||||
</li>
|
</li>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
|
<el-tooltip class="item" content="混合模式" placement="bottom">
|
||||||
|
<li
|
||||||
|
:class="layoutTheme.layout === 'mix' ? $style.isSelect : ''"
|
||||||
|
ref="mixRef"
|
||||||
|
@click="setLayoutModel('mix')"
|
||||||
|
>
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
</li>
|
||||||
|
</el-tooltip>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<el-divider v-show="!dataTheme">主题色</el-divider>
|
<el-divider v-show="!dataTheme">主题色</el-divider>
|
||||||
@@ -481,15 +498,14 @@ nextTick(() => {
|
|||||||
.pure-theme {
|
.pure-theme {
|
||||||
margin-top: 25px;
|
margin-top: 25px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100px;
|
height: 50px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
|
|
||||||
li {
|
li {
|
||||||
margin: 10px;
|
width: 18%;
|
||||||
width: 36%;
|
height: 45px;
|
||||||
height: 70px;
|
|
||||||
background: #f0f2f5;
|
background: #f0f2f5;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -527,6 +543,27 @@ nextTick(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:nth-child(3) {
|
||||||
|
div {
|
||||||
|
&:nth-child(1) {
|
||||||
|
width: 100%;
|
||||||
|
height: 30%;
|
||||||
|
background: #1b2a47;
|
||||||
|
box-shadow: 0 0 1px #888;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:nth-child(2) {
|
||||||
|
width: 30%;
|
||||||
|
height: 70%;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 0 1px #888;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import { isEqual } from "lodash-es";
|
import { isEqual } from "lodash-unified";
|
||||||
import { transformI18n } from "/@/plugins/i18n";
|
import { transformI18n } from "/@/plugins/i18n";
|
||||||
import { getParentPaths, findRouteByPath } from "/@/router/utils";
|
import { getParentPaths, findRouteByPath } from "/@/router/utils";
|
||||||
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
||||||
|
|||||||
@@ -1,126 +1,68 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
|
||||||
computed,
|
|
||||||
unref,
|
|
||||||
watch,
|
|
||||||
nextTick,
|
|
||||||
onMounted,
|
|
||||||
getCurrentInstance
|
|
||||||
} from "vue";
|
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { emitter } from "/@/utils/mitt";
|
import { useNav } from "../../hooks/nav";
|
||||||
import Notice from "../notice/index.vue";
|
import Notice from "../notice/index.vue";
|
||||||
import { templateRef } from "@vueuse/core";
|
import { templateRef } from "@vueuse/core";
|
||||||
import SidebarItem from "./sidebarItem.vue";
|
import SidebarItem from "./sidebarItem.vue";
|
||||||
import avatars from "/@/assets/avatars.jpg";
|
import avatars from "/@/assets/avatars.jpg";
|
||||||
import screenfull from "../screenfull/index.vue";
|
import screenfull from "../screenfull/index.vue";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { storageSession } from "/@/utils/storage";
|
|
||||||
import { deviceDetection } from "/@/utils/deviceDetection";
|
import { deviceDetection } from "/@/utils/deviceDetection";
|
||||||
|
import { watch, nextTick, onMounted, getCurrentInstance } from "vue";
|
||||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||||
import globalization from "/@/assets/svg/globalization.svg?component";
|
import globalization from "/@/assets/svg/globalization.svg?component";
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const { locale } = useI18n();
|
||||||
|
const routers = useRouter().options.routes;
|
||||||
|
const menuRef = templateRef<ElRef | null>("menu", null);
|
||||||
const instance =
|
const instance =
|
||||||
getCurrentInstance().appContext.config.globalProperties.$storage;
|
getCurrentInstance().appContext.config.globalProperties.$storage;
|
||||||
|
|
||||||
const title =
|
const title =
|
||||||
getCurrentInstance().appContext.config.globalProperties.$config?.Title;
|
getCurrentInstance().appContext.config.globalProperties.$config?.Title;
|
||||||
|
|
||||||
const menuRef = templateRef<ElRef | null>("menu", null);
|
const {
|
||||||
const route = useRoute();
|
logout,
|
||||||
const router = useRouter();
|
backHome,
|
||||||
const routers = useRouter().options.routes;
|
onPanel,
|
||||||
let usename = storageSession.getItem("info")?.username;
|
changeTitle,
|
||||||
const { locale, t } = useI18n();
|
handleResize,
|
||||||
|
menuSelect,
|
||||||
|
usename,
|
||||||
|
getDropdownItemStyle
|
||||||
|
} = useNav();
|
||||||
|
|
||||||
const getDropdownItemStyle = computed(() => {
|
onMounted(() => {
|
||||||
return t => {
|
nextTick(() => {
|
||||||
return {
|
handleResize(menuRef.value);
|
||||||
background: locale.value === t ? "#1b2a47" : "",
|
});
|
||||||
color: locale.value === t ? "#f4f4f5" : "#000"
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => locale.value,
|
() => locale.value,
|
||||||
() => {
|
() => {
|
||||||
//@ts-ignore
|
changeTitle(route.meta);
|
||||||
// 动态title
|
|
||||||
document.title = t(unref(route.meta.title));
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// 退出登录
|
watch(
|
||||||
const logout = (): void => {
|
() => route.path,
|
||||||
storageSession.removeItem("info");
|
() => {
|
||||||
router.push("/login");
|
menuSelect(route.path, routers);
|
||||||
};
|
|
||||||
|
|
||||||
function onPanel() {
|
|
||||||
emitter.emit("openPanel");
|
|
||||||
}
|
|
||||||
|
|
||||||
const activeMenu = computed((): string => {
|
|
||||||
const { meta, path } = route;
|
|
||||||
if (meta.activeMenu) {
|
|
||||||
// @ts-ignore
|
|
||||||
return meta.activeMenu;
|
|
||||||
}
|
}
|
||||||
return path;
|
);
|
||||||
});
|
|
||||||
|
|
||||||
const menuSelect = (indexPath: string): void => {
|
|
||||||
let parentPath = "";
|
|
||||||
let parentPathIndex = indexPath.lastIndexOf("/");
|
|
||||||
if (parentPathIndex > 0) {
|
|
||||||
parentPath = indexPath.slice(0, parentPathIndex);
|
|
||||||
}
|
|
||||||
// 找到当前路由的信息
|
|
||||||
function findCurrentRoute(routes) {
|
|
||||||
return routes.map(item => {
|
|
||||||
if (item.path === indexPath) {
|
|
||||||
// 切换左侧菜单 通知标签页
|
|
||||||
emitter.emit("changLayoutRoute", {
|
|
||||||
indexPath,
|
|
||||||
parentPath
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (item.children) findCurrentRoute(item.children);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
findCurrentRoute(routers);
|
|
||||||
};
|
|
||||||
|
|
||||||
function backHome() {
|
|
||||||
router.push("/welcome");
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleResize() {
|
|
||||||
// @ts-ignore
|
|
||||||
menuRef.value.handleResize();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 简体中文
|
|
||||||
function translationCh() {
|
function translationCh() {
|
||||||
instance.locale = { locale: "zh" };
|
instance.locale = { locale: "zh" };
|
||||||
locale.value = "zh";
|
locale.value = "zh";
|
||||||
handleResize();
|
handleResize(menuRef.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// English
|
|
||||||
function translationEn() {
|
function translationEn() {
|
||||||
instance.locale = { locale: "en" };
|
instance.locale = { locale: "en" };
|
||||||
locale.value = "en";
|
locale.value = "en";
|
||||||
handleResize();
|
handleResize(menuRef.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
nextTick(() => {
|
|
||||||
handleResize();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -135,12 +77,11 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<el-menu
|
<el-menu
|
||||||
ref="menu"
|
ref="menu"
|
||||||
:default-active="activeMenu"
|
|
||||||
unique-opened
|
|
||||||
router
|
|
||||||
class="horizontal-header-menu"
|
class="horizontal-header-menu"
|
||||||
mode="horizontal"
|
mode="horizontal"
|
||||||
@select="menuSelect"
|
:default-active="route.path"
|
||||||
|
router
|
||||||
|
@select="indexPath => menuSelect(indexPath, routers)"
|
||||||
>
|
>
|
||||||
<sidebar-item
|
<sidebar-item
|
||||||
v-for="route in usePermissionStoreHook().wholeMenus"
|
v-for="route in usePermissionStoreHook().wholeMenus"
|
||||||
@@ -160,14 +101,14 @@ onMounted(() => {
|
|||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu class="translation">
|
<el-dropdown-menu class="translation">
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
:style="getDropdownItemStyle('zh')"
|
:style="getDropdownItemStyle(locale, 'zh')"
|
||||||
@click="translationCh"
|
@click="translationCh"
|
||||||
><el-icon class="check-zh" v-show="locale === 'zh'"
|
><el-icon class="check-zh" v-show="locale === 'zh'"
|
||||||
><IconifyIconOffline icon="check" /></el-icon
|
><IconifyIconOffline icon="check" /></el-icon
|
||||||
>简体中文</el-dropdown-item
|
>简体中文</el-dropdown-item
|
||||||
>
|
>
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
:style="getDropdownItemStyle('en')"
|
:style="getDropdownItemStyle(locale, 'en')"
|
||||||
@click="translationEn"
|
@click="translationEn"
|
||||||
><el-icon class="check-en" v-show="locale === 'en'"
|
><el-icon class="check-en" v-show="locale === 'en'"
|
||||||
><IconifyIconOffline icon="check" /></el-icon
|
><IconifyIconOffline icon="check" /></el-icon
|
||||||
@@ -207,14 +148,8 @@ onMounted(() => {
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.translation {
|
.translation {
|
||||||
.el-dropdown-menu__item {
|
::v-deep(.el-dropdown-menu__item) {
|
||||||
padding: 5px 40px !important;
|
padding: 5px 40px;
|
||||||
}
|
|
||||||
|
|
||||||
.el-dropdown-menu__item:focus,
|
|
||||||
.el-dropdown-menu__item:not(.is-disabled):hover {
|
|
||||||
color: #606266;
|
|
||||||
background: #f0f0f0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.check-zh {
|
.check-zh {
|
||||||
@@ -231,16 +166,10 @@ onMounted(() => {
|
|||||||
.logout {
|
.logout {
|
||||||
max-width: 120px;
|
max-width: 120px;
|
||||||
|
|
||||||
.el-dropdown-menu__item {
|
::v-deep(.el-dropdown-menu__item) {
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-dropdown-menu__item:focus,
|
|
||||||
.el-dropdown-menu__item:not(.is-disabled):hover {
|
|
||||||
color: #606266;
|
|
||||||
background: #f0f0f0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
239
src/layout/components/sidebar/mixNav.vue
Normal file
239
src/layout/components/sidebar/mixNav.vue
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
import Notice from "../notice/index.vue";
|
||||||
|
import { useNav } from "../../hooks/nav";
|
||||||
|
import { templateRef } from "@vueuse/core";
|
||||||
|
import avatars from "/@/assets/avatars.jpg";
|
||||||
|
import { transformI18n } from "/@/plugins/i18n";
|
||||||
|
import screenfull from "../screenfull/index.vue";
|
||||||
|
import { useRoute, useRouter } from "vue-router";
|
||||||
|
import { deviceDetection } from "/@/utils/deviceDetection";
|
||||||
|
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
|
||||||
|
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
|
||||||
|
import { getParentPaths, findRouteByPath } from "/@/router/utils";
|
||||||
|
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||||
|
import globalization from "/@/assets/svg/globalization.svg?component";
|
||||||
|
import { ref, watch, nextTick, onMounted, getCurrentInstance } from "vue";
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const { locale } = useI18n();
|
||||||
|
const routers = useRouter().options.routes;
|
||||||
|
const menuRef = templateRef<ElRef | null>("menu", null);
|
||||||
|
const instance =
|
||||||
|
getCurrentInstance().appContext.config.globalProperties.$storage;
|
||||||
|
|
||||||
|
const {
|
||||||
|
logout,
|
||||||
|
onPanel,
|
||||||
|
changeTitle,
|
||||||
|
toggleSideBar,
|
||||||
|
handleResize,
|
||||||
|
menuSelect,
|
||||||
|
resolvePath,
|
||||||
|
pureApp,
|
||||||
|
usename,
|
||||||
|
getDropdownItemStyle
|
||||||
|
} = useNav();
|
||||||
|
|
||||||
|
let defaultActive = ref(null);
|
||||||
|
|
||||||
|
function getDefaultActive(routePath) {
|
||||||
|
const wholeMenus = usePermissionStoreHook().wholeMenus;
|
||||||
|
// 当前路由的父级路径
|
||||||
|
const parentRoutes = getParentPaths(routePath, wholeMenus)[0];
|
||||||
|
defaultActive.value = findRouteByPath(
|
||||||
|
parentRoutes,
|
||||||
|
wholeMenus
|
||||||
|
)?.children[0]?.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getDefaultActive(route.path);
|
||||||
|
nextTick(() => {
|
||||||
|
handleResize(menuRef.value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => locale.value,
|
||||||
|
() => {
|
||||||
|
changeTitle(route.meta);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => route.path,
|
||||||
|
() => {
|
||||||
|
getDefaultActive(route.path);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
function translationCh() {
|
||||||
|
instance.locale = { locale: "zh" };
|
||||||
|
locale.value = "zh";
|
||||||
|
handleResize(menuRef.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function translationEn() {
|
||||||
|
instance.locale = { locale: "en" };
|
||||||
|
locale.value = "en";
|
||||||
|
handleResize(menuRef.value);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="horizontal-header">
|
||||||
|
<div
|
||||||
|
:class="classes.container"
|
||||||
|
:title="pureApp.sidebar.opened ? '点击折叠' : '点击展开'"
|
||||||
|
@click="toggleSideBar"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
:fill="useEpThemeStoreHook().fill"
|
||||||
|
:class="[
|
||||||
|
'hamburger',
|
||||||
|
pureApp.sidebar.opened ? 'is-active-hamburger' : ''
|
||||||
|
]"
|
||||||
|
viewBox="0 0 1024 1024"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="64"
|
||||||
|
height="64"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 0 0 0-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0 0 14.4 7z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<el-menu
|
||||||
|
ref="menu"
|
||||||
|
class="horizontal-header-menu"
|
||||||
|
mode="horizontal"
|
||||||
|
:default-active="defaultActive"
|
||||||
|
router
|
||||||
|
@select="indexPath => menuSelect(indexPath, routers)"
|
||||||
|
>
|
||||||
|
<el-menu-item
|
||||||
|
v-for="route in usePermissionStoreHook().wholeMenus"
|
||||||
|
:key="route.path"
|
||||||
|
:index="resolvePath(route) || route.redirect"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<el-icon v-show="route.meta.icon" :class="route.meta.icon">
|
||||||
|
<component
|
||||||
|
:is="useRenderIcon(route.meta && route.meta.icon)"
|
||||||
|
></component>
|
||||||
|
</el-icon>
|
||||||
|
<span>{{ transformI18n(route.meta.title, route.meta.i18n) }}</span>
|
||||||
|
<FontIcon
|
||||||
|
v-if="route.meta.extraIcon"
|
||||||
|
width="30px"
|
||||||
|
height="30px"
|
||||||
|
style="position: absolute; right: 10px"
|
||||||
|
:icon="route.meta.extraIcon.name"
|
||||||
|
:svg="route.meta.extraIcon.svg ? true : false"
|
||||||
|
></FontIcon>
|
||||||
|
</template>
|
||||||
|
</el-menu-item>
|
||||||
|
</el-menu>
|
||||||
|
<div class="horizontal-header-right">
|
||||||
|
<!-- 通知 -->
|
||||||
|
<Notice id="header-notice" />
|
||||||
|
<!-- 全屏 -->
|
||||||
|
<screenfull id="header-screenfull" v-show="!deviceDetection()" />
|
||||||
|
<!-- 国际化 -->
|
||||||
|
<el-dropdown id="header-translation" trigger="click">
|
||||||
|
<globalization />
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu class="translation">
|
||||||
|
<el-dropdown-item
|
||||||
|
:style="getDropdownItemStyle(locale, 'zh')"
|
||||||
|
@click="translationCh"
|
||||||
|
><el-icon class="check-zh" v-show="locale === 'zh'"
|
||||||
|
><IconifyIconOffline icon="check" /></el-icon
|
||||||
|
>简体中文</el-dropdown-item
|
||||||
|
>
|
||||||
|
<el-dropdown-item
|
||||||
|
:style="getDropdownItemStyle(locale, 'en')"
|
||||||
|
@click="translationEn"
|
||||||
|
><el-icon class="check-en" v-show="locale === 'en'"
|
||||||
|
><IconifyIconOffline icon="check" /></el-icon
|
||||||
|
>English</el-dropdown-item
|
||||||
|
>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
<!-- 退出登陆 -->
|
||||||
|
<el-dropdown trigger="click">
|
||||||
|
<span class="el-dropdown-link">
|
||||||
|
<img :src="avatars" />
|
||||||
|
<p>{{ usename }}</p>
|
||||||
|
</span>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu class="logout">
|
||||||
|
<el-dropdown-item @click="logout">
|
||||||
|
<IconifyIconOffline
|
||||||
|
icon="logout-circle-r-line"
|
||||||
|
style="margin: 5px"
|
||||||
|
/>
|
||||||
|
{{ $t("buttons.hsLoginOut") }}</el-dropdown-item
|
||||||
|
>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
<el-icon
|
||||||
|
class="el-icon-setting"
|
||||||
|
:title="$t('buttons.hssystemSet')"
|
||||||
|
@click="onPanel"
|
||||||
|
>
|
||||||
|
<IconifyIconOffline icon="setting" />
|
||||||
|
</el-icon>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style module="classes" scoped>
|
||||||
|
.container {
|
||||||
|
padding: 0 15px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.hamburger {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-active-hamburger {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.translation {
|
||||||
|
::v-deep(.el-dropdown-menu__item) {
|
||||||
|
padding: 5px 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.check-zh {
|
||||||
|
position: absolute;
|
||||||
|
left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.check-en {
|
||||||
|
position: absolute;
|
||||||
|
left: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.logout {
|
||||||
|
max-width: 120px;
|
||||||
|
|
||||||
|
::v-deep(.el-dropdown-menu__item) {
|
||||||
|
min-width: 100%;
|
||||||
|
display: inline-flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,21 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import { ref, PropType, nextTick, computed, CSSProperties } from "vue";
|
||||||
ref,
|
|
||||||
PropType,
|
|
||||||
nextTick,
|
|
||||||
computed,
|
|
||||||
CSSProperties,
|
|
||||||
getCurrentInstance
|
|
||||||
} from "vue";
|
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { useNav } from "../../hooks/nav";
|
||||||
import { childrenType } from "../../types";
|
import { childrenType } from "../../types";
|
||||||
import { transformI18n } from "/@/plugins/i18n";
|
import { transformI18n } from "/@/plugins/i18n";
|
||||||
import { useAppStoreHook } from "/@/store/modules/app";
|
import { useAppStoreHook } from "/@/store/modules/app";
|
||||||
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
|
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
|
||||||
|
|
||||||
const instance = getCurrentInstance().appContext.app.config.globalProperties;
|
const { pureApp } = useNav();
|
||||||
const menuMode = instance.$storage.layout?.layout === "vertical";
|
const menuMode = ["vertical", "mix"].includes(pureApp.layout);
|
||||||
const pureApp = useAppStoreHook();
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
item: {
|
item: {
|
||||||
@@ -31,6 +24,19 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getExtraIconStyle = computed((): CSSProperties => {
|
||||||
|
if (useAppStoreHook().getSidebarStatus) {
|
||||||
|
return {
|
||||||
|
position: "absolute",
|
||||||
|
right: "10px"
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
position: "static"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const getNoDropdownStyle = computed((): CSSProperties => {
|
const getNoDropdownStyle = computed((): CSSProperties => {
|
||||||
return {
|
return {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
@@ -92,7 +98,6 @@ function hoverMenu(key) {
|
|||||||
: Object.assign(key, {
|
: Object.assign(key, {
|
||||||
showTooltip: false
|
showTooltip: false
|
||||||
});
|
});
|
||||||
|
|
||||||
hoverMenuMap.set(key, true);
|
hoverMenuMap.set(key, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -106,6 +111,10 @@ function hasOneShowingChild(
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (showingChildren[0]?.meta?.showParent) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (showingChildren.length === 1) {
|
if (showingChildren.length === 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -119,8 +128,8 @@ function hasOneShowingChild(
|
|||||||
|
|
||||||
function resolvePath(routePath) {
|
function resolvePath(routePath) {
|
||||||
const httpReg = /^http(s?):\/\//;
|
const httpReg = /^http(s?):\/\//;
|
||||||
if (httpReg.test(routePath)) {
|
if (httpReg.test(routePath) || httpReg.test(props.basePath)) {
|
||||||
return props.basePath + "/" + routePath;
|
return routePath || props.basePath;
|
||||||
} else {
|
} else {
|
||||||
return path.resolve(props.basePath, routePath);
|
return path.resolve(props.basePath, routePath);
|
||||||
}
|
}
|
||||||
@@ -149,6 +158,18 @@ function resolvePath(routePath) {
|
|||||||
"
|
"
|
||||||
></component>
|
></component>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
!pureApp.sidebar.opened &&
|
||||||
|
pureApp.layout === 'mix' &&
|
||||||
|
props.item?.pathList?.length === 2
|
||||||
|
"
|
||||||
|
:style="getDivStyle"
|
||||||
|
>
|
||||||
|
<span :style="getMenuTextStyle">
|
||||||
|
{{ transformI18n(onlyOneChild.meta.title, onlyOneChild.meta.i18n) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div :style="getDivStyle">
|
<div :style="getDivStyle">
|
||||||
<span v-if="!menuMode">{{
|
<span v-if="!menuMode">{{
|
||||||
@@ -177,6 +198,9 @@ function resolvePath(routePath) {
|
|||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<FontIcon
|
<FontIcon
|
||||||
v-if="onlyOneChild.meta.extraIcon"
|
v-if="onlyOneChild.meta.extraIcon"
|
||||||
|
width="30px"
|
||||||
|
height="30px"
|
||||||
|
:style="getExtraIconStyle"
|
||||||
:icon="onlyOneChild.meta.extraIcon.name"
|
:icon="onlyOneChild.meta.extraIcon.name"
|
||||||
:svg="onlyOneChild.meta.extraIcon.svg ? true : false"
|
:svg="onlyOneChild.meta.extraIcon.svg ? true : false"
|
||||||
></FontIcon>
|
></FontIcon>
|
||||||
@@ -221,6 +245,9 @@ function resolvePath(routePath) {
|
|||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<FontIcon
|
<FontIcon
|
||||||
v-if="props.item.meta.extraIcon"
|
v-if="props.item.meta.extraIcon"
|
||||||
|
width="30px"
|
||||||
|
height="30px"
|
||||||
|
style="position: absolute; right: 10px"
|
||||||
:icon="props.item.meta.extraIcon.name"
|
:icon="props.item.meta.extraIcon.name"
|
||||||
:svg="props.item.meta.extraIcon.svg ? true : false"
|
:svg="props.item.meta.extraIcon.svg ? true : false"
|
||||||
></FontIcon>
|
></FontIcon>
|
||||||
|
|||||||
@@ -1,60 +1,59 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Logo from "./logo.vue";
|
import Logo from "./logo.vue";
|
||||||
import { emitter } from "/@/utils/mitt";
|
import { emitter } from "/@/utils/mitt";
|
||||||
|
import { useNav } from "../../hooks/nav";
|
||||||
import SidebarItem from "./sidebarItem.vue";
|
import SidebarItem from "./sidebarItem.vue";
|
||||||
import { storageLocal } from "/@/utils/storage";
|
import { storageLocal } from "/@/utils/storage";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { computed, ref, onBeforeMount } from "vue";
|
import { ref, computed, watch, onBeforeMount } from "vue";
|
||||||
import { useAppStoreHook } from "/@/store/modules/app";
|
import { findRouteByPath, getParentPaths } from "/@/router/utils";
|
||||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const pureApp = useAppStoreHook();
|
const routers = useRouter().options.routes;
|
||||||
const router = useRouter().options.routes;
|
|
||||||
const showLogo = ref(
|
const showLogo = ref(
|
||||||
storageLocal.getItem("responsive-configure")?.showLogo ?? true
|
storageLocal.getItem("responsive-configure")?.showLogo ?? true
|
||||||
);
|
);
|
||||||
const isCollapse = computed(() => {
|
|
||||||
return !pureApp.getSidebarStatus;
|
const { pureApp, isCollapse, menuSelect } = useNav();
|
||||||
});
|
|
||||||
const activeMenu = computed((): string => {
|
let subMenuData = ref([]);
|
||||||
const { meta, path } = route;
|
|
||||||
if (meta.activeMenu) {
|
const menuData = computed(() => {
|
||||||
// @ts-ignore
|
return pureApp.layout === "mix"
|
||||||
return meta.activeMenu;
|
? subMenuData.value
|
||||||
}
|
: usePermissionStoreHook().wholeMenus;
|
||||||
return path;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const menuSelect = (indexPath: string): void => {
|
function getSubMenuData(path) {
|
||||||
let parentPath = "";
|
// path的上级路由组成的数组
|
||||||
let parentPathIndex = indexPath.lastIndexOf("/");
|
const parentPathArr = getParentPaths(
|
||||||
if (parentPathIndex > 0) {
|
path,
|
||||||
parentPath = indexPath.slice(0, parentPathIndex);
|
usePermissionStoreHook().wholeMenus
|
||||||
}
|
);
|
||||||
// 找到当前路由的信息
|
// 当前路由的父级路由信息
|
||||||
// eslint-disable-next-line no-inner-declarations
|
const parenetRoute = findRouteByPath(
|
||||||
function findCurrentRoute(routes) {
|
parentPathArr[0] || path,
|
||||||
return routes.map(item => {
|
usePermissionStoreHook().wholeMenus
|
||||||
if (item.path === indexPath) {
|
);
|
||||||
// 切换左侧菜单 通知标签页
|
if (!parenetRoute?.children) return;
|
||||||
emitter.emit("changLayoutRoute", {
|
subMenuData.value = parenetRoute?.children;
|
||||||
indexPath,
|
}
|
||||||
parentPath
|
getSubMenuData(route.path);
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (item.children) findCurrentRoute(item.children);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
findCurrentRoute(router);
|
|
||||||
};
|
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
emitter.on("logoChange", key => {
|
emitter.on("logoChange", key => {
|
||||||
showLogo.value = key;
|
showLogo.value = key;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => route.path,
|
||||||
|
() => {
|
||||||
|
getSubMenuData(route.path);
|
||||||
|
menuSelect(route.path, routers);
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -62,21 +61,21 @@ onBeforeMount(() => {
|
|||||||
<Logo v-if="showLogo" :collapse="isCollapse" />
|
<Logo v-if="showLogo" :collapse="isCollapse" />
|
||||||
<el-scrollbar wrap-class="scrollbar-wrapper">
|
<el-scrollbar wrap-class="scrollbar-wrapper">
|
||||||
<el-menu
|
<el-menu
|
||||||
:default-active="activeMenu"
|
:default-active="route.path"
|
||||||
:collapse="isCollapse"
|
:collapse="isCollapse"
|
||||||
unique-opened
|
unique-opened
|
||||||
router
|
router
|
||||||
:collapse-transition="false"
|
:collapse-transition="false"
|
||||||
mode="vertical"
|
mode="vertical"
|
||||||
class="outer-most"
|
class="outer-most"
|
||||||
@select="menuSelect"
|
@select="indexPath => menuSelect(indexPath, routers)"
|
||||||
>
|
>
|
||||||
<sidebar-item
|
<sidebar-item
|
||||||
v-for="route in usePermissionStoreHook().wholeMenus"
|
v-for="routes in menuData"
|
||||||
:key="route.path"
|
:key="routes.path"
|
||||||
:item="route"
|
:item="routes"
|
||||||
class="outer-most"
|
class="outer-most"
|
||||||
:base-path="route.path"
|
:base-path="routes.path"
|
||||||
/>
|
/>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
|
|||||||
@@ -18,36 +18,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@-webkit-keyframes rotate {
|
|
||||||
from {
|
|
||||||
-webkit-transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
to {
|
|
||||||
-webkit-transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@-moz-keyframes rotate {
|
|
||||||
from {
|
|
||||||
-moz-transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
to {
|
|
||||||
-moz-transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@-o-keyframes rotate {
|
|
||||||
from {
|
|
||||||
-o-transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
to {
|
|
||||||
-o-transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes rotate {
|
@keyframes rotate {
|
||||||
from {
|
from {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
@@ -80,7 +50,7 @@
|
|||||||
|
|
||||||
.scroll-item {
|
.scroll-item {
|
||||||
border-radius: 3px 3px 0 0;
|
border-radius: 3px 3px 0 0;
|
||||||
padding: 0 6px 0 6px;
|
padding: 0 6px;
|
||||||
box-shadow: 0 0 1px #888;
|
box-shadow: 0 0 1px #888;
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
@@ -92,7 +62,7 @@
|
|||||||
|
|
||||||
.el-icon-close {
|
.el-icon-close {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
color: #1890ff;
|
color: var(--el-color-primary);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
@@ -123,7 +93,7 @@
|
|||||||
a {
|
a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #666;
|
color: #666;
|
||||||
padding: 0 4px 0 4px;
|
padding: 0 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scroll-container {
|
.scroll-container {
|
||||||
@@ -190,7 +160,8 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #eee;
|
background: var(--el-color-primary-light-9);
|
||||||
|
color: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
@@ -236,7 +207,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.scroll-item.is-active {
|
.scroll-item.is-active {
|
||||||
background-color: #eaf4fe;
|
background-color: var(--el-color-primary-light-9);
|
||||||
position: relative;
|
position: relative;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|
||||||
@@ -249,7 +220,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #1890ff;
|
color: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,10 +259,10 @@
|
|||||||
|
|
||||||
/* 卡片模式下鼠标移入显示蓝色边框 */
|
/* 卡片模式下鼠标移入显示蓝色边框 */
|
||||||
.card-in {
|
.card-in {
|
||||||
color: #1890ff;
|
color: var(--el-color-primary);
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #1890ff;
|
color: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +283,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
background: #1890ff;
|
background: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 灵动模式下鼠标移入显示蓝色进度条 */
|
/* 灵动模式下鼠标移入显示蓝色进度条 */
|
||||||
@@ -322,7 +293,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
background: #1890ff;
|
background: var(--el-color-primary);
|
||||||
animation: scheduleInWidth 400ms ease-in;
|
animation: scheduleInWidth 400ms ease-in;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,14 +304,11 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
background: #1890ff;
|
background: var(--el-color-primary);
|
||||||
animation: scheduleOutWidth 400ms ease-in;
|
animation: scheduleOutWidth 400ms ease-in;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 刷新按钮动画效果 */
|
/* 刷新按钮动画效果 */
|
||||||
.refresh-button {
|
.refresh-button {
|
||||||
-webkit-animation: rotate 600ms linear infinite;
|
|
||||||
-moz-animation: rotate 600ms linear infinite;
|
|
||||||
-o-animation: rotate 600ms linear infinite;
|
|
||||||
animation: rotate 600ms linear infinite;
|
animation: rotate 600ms linear infinite;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import closeRight from "/@/assets/svg/close_right.svg?component";
|
|||||||
|
|
||||||
import { emitter } from "/@/utils/mitt";
|
import { emitter } from "/@/utils/mitt";
|
||||||
import { $t as t } from "/@/plugins/i18n";
|
import { $t as t } from "/@/plugins/i18n";
|
||||||
import { isEqual, isEmpty } from "lodash-es";
|
|
||||||
import { transformI18n } from "/@/plugins/i18n";
|
import { transformI18n } from "/@/plugins/i18n";
|
||||||
import { storageLocal } from "/@/utils/storage";
|
import { storageLocal } from "/@/utils/storage";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
|
import { isEqual, isEmpty } from "lodash-unified";
|
||||||
import { RouteConfigs, tagsViewsType } from "../../types";
|
import { RouteConfigs, tagsViewsType } from "../../types";
|
||||||
import { useSettingStoreHook } from "/@/store/modules/settings";
|
import { useSettingStoreHook } from "/@/store/modules/settings";
|
||||||
import { handleAliveRoute, delAliveRoutes } from "/@/router/utils";
|
import { handleAliveRoute, delAliveRoutes } from "/@/router/utils";
|
||||||
@@ -106,7 +106,11 @@ const iconIsActive = computed(() => {
|
|||||||
|
|
||||||
const dynamicTagView = () => {
|
const dynamicTagView = () => {
|
||||||
const index = multiTags.value.findIndex(item => {
|
const index = multiTags.value.findIndex(item => {
|
||||||
return item.path === route.path;
|
if (item?.query) {
|
||||||
|
return isEqual(route?.query, item?.query);
|
||||||
|
} else {
|
||||||
|
return item.path === route.path;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
moveToView(index);
|
moveToView(index);
|
||||||
};
|
};
|
||||||
@@ -423,6 +427,11 @@ function onClickDrop(key, item, selectRoute?: RouteConfigs) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleCommand(command: object) {
|
||||||
|
const { key, item } = command;
|
||||||
|
onClickDrop(key, item);
|
||||||
|
}
|
||||||
|
|
||||||
// 触发右键中菜单的点击事件
|
// 触发右键中菜单的点击事件
|
||||||
function selectTag(key, item) {
|
function selectTag(key, item) {
|
||||||
onClickDrop(key, item, currentSelect.value);
|
onClickDrop(key, item, currentSelect.value);
|
||||||
@@ -709,7 +718,11 @@ const getContextMenuStyle = computed((): CSSProperties => {
|
|||||||
</el-icon>
|
</el-icon>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<el-dropdown trigger="click" placement="bottom-end">
|
<el-dropdown
|
||||||
|
trigger="click"
|
||||||
|
placement="bottom-end"
|
||||||
|
@command="handleCommand"
|
||||||
|
>
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<IconifyIconOffline icon="arrow-down" />
|
<IconifyIconOffline icon="arrow-down" />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
@@ -718,11 +731,15 @@ const getContextMenuStyle = computed((): CSSProperties => {
|
|||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
v-for="(item, key) in tagsViews"
|
v-for="(item, key) in tagsViews"
|
||||||
:key="key"
|
:key="key"
|
||||||
|
:command="{ key, item }"
|
||||||
:divided="item.divided"
|
:divided="item.divided"
|
||||||
:disabled="item.disabled"
|
:disabled="item.disabled"
|
||||||
@click="onClickDrop(key, item)"
|
|
||||||
>
|
>
|
||||||
<component :is="item.icon" :key="key" />
|
<component
|
||||||
|
:is="item.icon"
|
||||||
|
:key="key"
|
||||||
|
style="margin-right: 6px"
|
||||||
|
/>
|
||||||
{{ $t(item.text) }}
|
{{ $t(item.text) }}
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
|
|||||||
63
src/layout/frameView.vue
Normal file
63
src/layout/frameView.vue
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<template>
|
||||||
|
<div class="frame" v-loading="loading">
|
||||||
|
<iframe :src="frameSrc" class="frame-iframe" ref="frameRef"></iframe>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
|
import { ref, unref, onMounted, nextTick } from "vue";
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const currentRoute = useRoute();
|
||||||
|
const frameSrc = ref<string>("");
|
||||||
|
const frameRef = ref<HTMLElement | null>(null);
|
||||||
|
|
||||||
|
if (unref(currentRoute.meta)?.frameSrc) {
|
||||||
|
frameSrc.value = unref(currentRoute.meta)?.frameSrc as string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideLoading() {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
nextTick(() => {
|
||||||
|
const iframe = unref(frameRef);
|
||||||
|
if (!iframe) return;
|
||||||
|
const _frame = iframe as any;
|
||||||
|
if (_frame.attachEvent) {
|
||||||
|
_frame.attachEvent("onload", () => {
|
||||||
|
hideLoading();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
iframe.onload = () => {
|
||||||
|
hideLoading();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loading.value = true;
|
||||||
|
init();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.frame {
|
||||||
|
height: 100vh;
|
||||||
|
z-index: 998;
|
||||||
|
|
||||||
|
.frame-iframe {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
margin: 0 !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
117
src/layout/hooks/nav.ts
Normal file
117
src/layout/hooks/nav.ts
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
import { computed } from "vue";
|
||||||
|
import { router } from "/@/router";
|
||||||
|
import { emitter } from "/@/utils/mitt";
|
||||||
|
import { routeMetaType } from "../types";
|
||||||
|
import { transformI18n } from "/@/plugins/i18n";
|
||||||
|
import { storageSession } from "/@/utils/storage";
|
||||||
|
import { useAppStoreHook } from "/@/store/modules/app";
|
||||||
|
import { remainingPaths } from "/@/router/modules/index";
|
||||||
|
import { Title } from "../../../public/serverConfig.json";
|
||||||
|
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
|
||||||
|
|
||||||
|
export function useNav() {
|
||||||
|
const pureApp = useAppStoreHook();
|
||||||
|
// 用户名
|
||||||
|
const usename: string = storageSession.getItem("info")?.username;
|
||||||
|
|
||||||
|
// 设置国际化选中后的样式
|
||||||
|
const getDropdownItemStyle = computed(() => {
|
||||||
|
return (locale, t) => {
|
||||||
|
return {
|
||||||
|
background: locale === t ? useEpThemeStoreHook().epThemeColor : "",
|
||||||
|
color: locale === t ? "#f4f4f5" : "#000"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const isCollapse = computed(() => {
|
||||||
|
return !pureApp.getSidebarStatus;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 动态title
|
||||||
|
function changeTitle(meta: routeMetaType) {
|
||||||
|
if (Title)
|
||||||
|
document.title = `${transformI18n(meta.title, meta.i18n)} | ${Title}`;
|
||||||
|
else document.title = transformI18n(meta.title, meta.i18n);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 退出登录
|
||||||
|
function logout() {
|
||||||
|
storageSession.removeItem("info");
|
||||||
|
router.push("/login");
|
||||||
|
}
|
||||||
|
|
||||||
|
function backHome() {
|
||||||
|
router.push("/welcome");
|
||||||
|
}
|
||||||
|
|
||||||
|
function onPanel() {
|
||||||
|
emitter.emit("openPanel");
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleSideBar() {
|
||||||
|
pureApp.toggleSideBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleResize(menuRef) {
|
||||||
|
menuRef.handleResize();
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolvePath(route) {
|
||||||
|
const httpReg = /^http(s?):\/\//;
|
||||||
|
const routeChildPath = route.children[0]?.path;
|
||||||
|
if (httpReg.test(routeChildPath)) {
|
||||||
|
return route.path + "/" + routeChildPath;
|
||||||
|
} else {
|
||||||
|
return routeChildPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function menuSelect(indexPath: string, routers): void {
|
||||||
|
if (isRemaining(indexPath)) return;
|
||||||
|
let parentPath = "";
|
||||||
|
const parentPathIndex = indexPath.lastIndexOf("/");
|
||||||
|
if (parentPathIndex > 0) {
|
||||||
|
parentPath = indexPath.slice(0, parentPathIndex);
|
||||||
|
}
|
||||||
|
// 找到当前路由的信息
|
||||||
|
function findCurrentRoute(indexPath: string, routes) {
|
||||||
|
return routes.map(item => {
|
||||||
|
if (item.path === indexPath) {
|
||||||
|
if (item.redirect) {
|
||||||
|
findCurrentRoute(item.redirect, item.children);
|
||||||
|
} else {
|
||||||
|
// 切换左侧菜单 通知标签页
|
||||||
|
emitter.emit("changLayoutRoute", {
|
||||||
|
indexPath,
|
||||||
|
parentPath
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (item.children) findCurrentRoute(indexPath, item.children);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
findCurrentRoute(indexPath, routers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断路径是否参与菜单
|
||||||
|
function isRemaining(path: string): boolean {
|
||||||
|
return remainingPaths.includes(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
logout,
|
||||||
|
backHome,
|
||||||
|
onPanel,
|
||||||
|
changeTitle,
|
||||||
|
toggleSideBar,
|
||||||
|
menuSelect,
|
||||||
|
handleResize,
|
||||||
|
resolvePath,
|
||||||
|
isCollapse,
|
||||||
|
pureApp,
|
||||||
|
usename,
|
||||||
|
getDropdownItemStyle
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -171,7 +171,8 @@ const layoutHeader = defineComponent({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
default: () => [
|
default: () => [
|
||||||
!pureSetting.hiddenSideBar && layout.value.includes("vertical")
|
!pureSetting.hiddenSideBar &&
|
||||||
|
(layout.value.includes("vertical") || layout.value.includes("mix"))
|
||||||
? h(navbar)
|
? h(navbar)
|
||||||
: h("div"),
|
: h("div"),
|
||||||
!pureSetting.hiddenSideBar && layout.value.includes("horizontal")
|
!pureSetting.hiddenSideBar && layout.value.includes("horizontal")
|
||||||
@@ -213,7 +214,10 @@ const layoutHeader = defineComponent({
|
|||||||
@click="useAppStoreHook().toggleSideBar()"
|
@click="useAppStoreHook().toggleSideBar()"
|
||||||
/>
|
/>
|
||||||
<Vertical
|
<Vertical
|
||||||
v-show="!pureSetting.hiddenSideBar && layout.includes('vertical')"
|
v-show="
|
||||||
|
!pureSetting.hiddenSideBar &&
|
||||||
|
(layout.includes('vertical') || layout.includes('mix'))
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
:class="[
|
:class="[
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
<template>
|
|
||||||
<router-view>
|
|
||||||
<template #default="{ Component, route }">
|
|
||||||
<transition appear name="fade-transform" mode="out-in">
|
|
||||||
<component :is="Component" :key="route.fullPath" />
|
|
||||||
</transition>
|
|
||||||
</template>
|
|
||||||
</router-view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
export default {
|
|
||||||
name: "layoutParentView"
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -19,7 +19,7 @@ $subMenuBg: #0f0303 !default;
|
|||||||
/* 有无子集的激活菜单背景 */
|
/* 有无子集的激活菜单背景 */
|
||||||
$subMenuActiveBg: #4091f7 !default;
|
$subMenuActiveBg: #4091f7 !default;
|
||||||
$navTextColor: #fff !default;
|
$navTextColor: #fff !default;
|
||||||
$menuText: rgba(254, 254, 254, 0.65) !default;
|
$menuText: rgb(254 254 254 / 65%) !default;
|
||||||
|
|
||||||
/* logo背景颜色 */
|
/* logo背景颜色 */
|
||||||
$sidebarLogo: #002140 !default;
|
$sidebarLogo: #002140 !default;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ $menuHover: #e13c39;
|
|||||||
$subMenuBg: #000;
|
$subMenuBg: #000;
|
||||||
$subMenuActiveBg: #e13c39;
|
$subMenuActiveBg: #e13c39;
|
||||||
$navTextColor: red;
|
$navTextColor: red;
|
||||||
$menuText: rgba(254, 254, 254, 0.651);
|
$menuText: rgb(254 254 254 / 65.1%);
|
||||||
$sidebarLogo: #42090c;
|
$sidebarLogo: #42090c;
|
||||||
$menuTitleHover: #fff;
|
$menuTitleHover: #fff;
|
||||||
$menuActiveBefore: #e13c39;
|
$menuActiveBefore: #e13c39;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ $menuHover: #e85f33;
|
|||||||
$subMenuBg: #0f0603;
|
$subMenuBg: #0f0603;
|
||||||
$subMenuActiveBg: #e85f33;
|
$subMenuActiveBg: #e85f33;
|
||||||
$navTextColor: #fff;
|
$navTextColor: #fff;
|
||||||
$menuText: rgba(254, 254, 254, 0.65);
|
$menuText: rgb(254 254 254 / 65%);
|
||||||
$sidebarLogo: #441708;
|
$sidebarLogo: #441708;
|
||||||
$menuTitleHover: #fff;
|
$menuTitleHover: #fff;
|
||||||
$menuActiveBefore: #e85f33;
|
$menuActiveBefore: #e85f33;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ $menuHover: #f6da4d;
|
|||||||
$subMenuBg: #0f0603;
|
$subMenuBg: #0f0603;
|
||||||
$subMenuActiveBg: #f6da4d;
|
$subMenuActiveBg: #f6da4d;
|
||||||
$navTextColor: #fff;
|
$navTextColor: #fff;
|
||||||
$menuText: rgba(254, 254, 254, 0.65);
|
$menuText: rgb(254 254 254 / 65%);
|
||||||
$sidebarLogo: #443b05;
|
$sidebarLogo: #443b05;
|
||||||
$menuTitleHover: #fff;
|
$menuTitleHover: #fff;
|
||||||
$menuActiveBefore: #f6da4d;
|
$menuActiveBefore: #f6da4d;
|
||||||
|
|||||||
@@ -11,18 +11,20 @@ export const routerArrays: Array<RouteConfigs> = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export type routeMetaType = {
|
||||||
|
title?: string;
|
||||||
|
i18n?: boolean;
|
||||||
|
icon?: string;
|
||||||
|
showLink?: boolean;
|
||||||
|
savedPosition?: boolean;
|
||||||
|
authority?: Array<string>;
|
||||||
|
};
|
||||||
|
|
||||||
export type RouteConfigs = {
|
export type RouteConfigs = {
|
||||||
path?: string;
|
path?: string;
|
||||||
parentPath?: string;
|
parentPath?: string;
|
||||||
query?: object;
|
query?: object;
|
||||||
meta?: {
|
meta?: routeMetaType;
|
||||||
title?: string;
|
|
||||||
i18n?: boolean;
|
|
||||||
icon?: string;
|
|
||||||
showLink?: boolean;
|
|
||||||
savedPosition?: boolean;
|
|
||||||
authority?: Array<string>;
|
|
||||||
};
|
|
||||||
children?: RouteConfigs[];
|
children?: RouteConfigs[];
|
||||||
name?: string;
|
name?: string;
|
||||||
};
|
};
|
||||||
@@ -65,12 +67,15 @@ export type childrenType = {
|
|||||||
icon?: string;
|
icon?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
i18n?: boolean;
|
i18n?: boolean;
|
||||||
|
showParent?: boolean;
|
||||||
extraIcon?: {
|
extraIcon?: {
|
||||||
svg?: boolean;
|
svg?: boolean;
|
||||||
name?: string;
|
name?: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
showTooltip?: boolean;
|
showTooltip?: boolean;
|
||||||
|
parentId?: number;
|
||||||
|
pathList?: number[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type themeColorsType = {
|
export type themeColorsType = {
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ app.component("IconifyIconOnline", IconifyIconOnline);
|
|||||||
app.component("FontIcon", FontIcon);
|
app.component("FontIcon", FontIcon);
|
||||||
|
|
||||||
getServerConfig(app).then(async config => {
|
getServerConfig(app).then(async config => {
|
||||||
|
app.use(router);
|
||||||
|
await router.isReady();
|
||||||
injectResponsiveStorage(app, config);
|
injectResponsiveStorage(app, config);
|
||||||
setupStore(app);
|
setupStore(app);
|
||||||
app.use(router).use(MotionPlugin).use(useElementPlus).use(usI18n);
|
app.use(MotionPlugin).use(useElementPlus).use(usI18n);
|
||||||
await router.isReady();
|
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// 多组件库的国际化和本地项目国际化兼容
|
// 多组件库的国际化和本地项目国际化兼容
|
||||||
import { App } from "vue";
|
import { App } from "vue";
|
||||||
import { set } from "lodash-es";
|
import { set } from "lodash-unified";
|
||||||
import { createI18n } from "vue-i18n";
|
import { createI18n } from "vue-i18n";
|
||||||
import { localesConfigs } from "./config";
|
import { localesConfigs } from "./config";
|
||||||
import { storageLocal } from "/@/utils/storage";
|
import { storageLocal } from "/@/utils/storage";
|
||||||
@@ -11,7 +11,10 @@ import { storageLocal } from "/@/utils/storage";
|
|||||||
* @param isI18n 如果true,获取对应的消息,否则返回本身
|
* @param isI18n 如果true,获取对应的消息,否则返回本身
|
||||||
* @returns message
|
* @returns message
|
||||||
*/
|
*/
|
||||||
export function transformI18n(message: string | object = "", isI18n = false) {
|
export function transformI18n(
|
||||||
|
message: string | unknown | object = "",
|
||||||
|
isI18n: boolean | unknown = false
|
||||||
|
) {
|
||||||
if (!message) {
|
if (!message) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
|
import { isUrl } from "/@/utils/is";
|
||||||
import { toRouteType } from "./types";
|
import { toRouteType } from "./types";
|
||||||
import { openLink } from "/@/utils/link";
|
import { openLink } from "/@/utils/link";
|
||||||
import NProgress from "/@/utils/progress";
|
import NProgress from "/@/utils/progress";
|
||||||
import { constantRoutes } from "./modules";
|
import { constantRoutes } from "./modules";
|
||||||
import { split, findIndex } from "lodash-es";
|
import { findIndex } from "lodash-unified";
|
||||||
import { transformI18n } from "/@/plugins/i18n";
|
import { transformI18n } from "/@/plugins/i18n";
|
||||||
import remainingRouter from "./modules/remaining";
|
import remainingRouter from "./modules/remaining";
|
||||||
import { storageSession } from "/@/utils/storage";
|
import { storageSession } from "/@/utils/storage";
|
||||||
|
import { Title } from "../../public/serverConfig.json";
|
||||||
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
import { useMultiTagsStoreHook } from "/@/store/modules/multiTags";
|
||||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||||
import { Router, RouteMeta, createRouter, RouteRecordName } from "vue-router";
|
import { Router, RouteMeta, createRouter, RouteRecordName } from "vue-router";
|
||||||
@@ -51,21 +53,22 @@ router.beforeEach((to: toRouteType, _from, next) => {
|
|||||||
}
|
}
|
||||||
const name = storageSession.getItem("info");
|
const name = storageSession.getItem("info");
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
const externalLink = to?.redirectedFrom?.fullPath;
|
const externalLink = isUrl(to?.name);
|
||||||
if (!externalLink)
|
if (!externalLink)
|
||||||
to.matched.some(item => {
|
to.matched.some(item => {
|
||||||
item.meta.title
|
if (!item.meta.title) return "";
|
||||||
? (document.title = transformI18n(
|
if (Title)
|
||||||
item.meta.title as string,
|
document.title = `${transformI18n(
|
||||||
item.meta?.i18n as boolean
|
item.meta.title,
|
||||||
))
|
item.meta?.i18n
|
||||||
: "";
|
)} | ${Title}`;
|
||||||
|
else document.title = transformI18n(item.meta.title, item.meta?.i18n);
|
||||||
});
|
});
|
||||||
if (name) {
|
if (name) {
|
||||||
if (_from?.name) {
|
if (_from?.name) {
|
||||||
// 如果路由包含http 则是超链接 反之是普通路由
|
// name为超链接
|
||||||
if (externalLink && externalLink.includes("http")) {
|
if (externalLink) {
|
||||||
openLink(`http${split(externalLink, "http")[1]}`);
|
openLink(to?.name);
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { $t } from "/@/plugins/i18n";
|
import { $t } from "/@/plugins/i18n";
|
||||||
import Layout from "/@/layout/index.vue";
|
const Layout = () => import("/@/layout/index.vue");
|
||||||
|
|
||||||
const errorRouter = {
|
const errorRouter = {
|
||||||
path: "/error",
|
path: "/error",
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { $t } from "/@/plugins/i18n";
|
import { $t } from "/@/plugins/i18n";
|
||||||
import Layout from "/@/layout/index.vue";
|
const Layout = () => import("/@/layout/index.vue");
|
||||||
|
|
||||||
const externalLink = {
|
const externalLink = {
|
||||||
path: "/external",
|
path: "/externals",
|
||||||
name: "external",
|
|
||||||
component: Layout,
|
component: Layout,
|
||||||
meta: {
|
meta: {
|
||||||
icon: "link",
|
icon: "link",
|
||||||
@@ -13,11 +12,11 @@ const externalLink = {
|
|||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "https://github.com/xiaoxian521/vue-pure-admin",
|
path: "/external",
|
||||||
|
name: "https://pure-admin-doc.vercel.app",
|
||||||
meta: {
|
meta: {
|
||||||
title: $t("menus.externalLink"),
|
title: $t("menus.externalLink"),
|
||||||
i18n: true,
|
i18n: true
|
||||||
rank: 191
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { $t } from "/@/plugins/i18n";
|
import { $t } from "/@/plugins/i18n";
|
||||||
import Layout from "/@/layout/index.vue";
|
const Layout = () => import("/@/layout/index.vue");
|
||||||
|
|
||||||
const homeRouter = {
|
const homeRouter = {
|
||||||
path: "/",
|
path: "/",
|
||||||
|
|||||||
@@ -10,16 +10,22 @@ import {
|
|||||||
formatTwoStageRoutes,
|
formatTwoStageRoutes,
|
||||||
formatFlatteningRoutes
|
formatFlatteningRoutes
|
||||||
} from "../utils";
|
} from "../utils";
|
||||||
|
import { buildHierarchyTree } from "/@/utils/tree";
|
||||||
|
|
||||||
// 原始静态路由(未做任何处理)
|
// 原始静态路由(未做任何处理)
|
||||||
const routes = [homeRouter, errorRouter, externalLink];
|
const routes = [homeRouter, errorRouter, externalLink];
|
||||||
|
|
||||||
// 导出处理后的静态路由(三级及以上的路由全部拍成二级)
|
// 导出处理后的静态路由(三级及以上的路由全部拍成二级)
|
||||||
export const constantRoutes: Array<RouteRecordRaw> = formatTwoStageRoutes(
|
export const constantRoutes: Array<RouteRecordRaw> = formatTwoStageRoutes(
|
||||||
formatFlatteningRoutes(ascending(routes))
|
formatFlatteningRoutes(buildHierarchyTree(ascending(routes)))
|
||||||
);
|
);
|
||||||
|
|
||||||
// 用于渲染菜单,保持原始层级
|
// 用于渲染菜单,保持原始层级
|
||||||
export const constantMenus: Array<RouteComponent> = ascending(routes).concat(
|
export const constantMenus: Array<RouteComponent> = ascending(routes).concat(
|
||||||
...remainingRouter
|
...remainingRouter
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 不参与菜单的路由
|
||||||
|
export const remainingPaths = Object.keys(remainingRouter).map(v => {
|
||||||
|
return remainingRouter[v].path;
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { $t } from "/@/plugins/i18n";
|
import { $t } from "/@/plugins/i18n";
|
||||||
import Layout from "/@/layout/index.vue";
|
const Layout = () => import("/@/layout/index.vue");
|
||||||
|
|
||||||
const remainingRouter = [
|
const remainingRouter = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ import {
|
|||||||
} from "vue-router";
|
} from "vue-router";
|
||||||
import { router } from "./index";
|
import { router } from "./index";
|
||||||
import { loadEnv } from "../../build";
|
import { loadEnv } from "../../build";
|
||||||
import Layout from "/@/layout/index.vue";
|
|
||||||
import { useTimeoutFn } from "@vueuse/core";
|
import { useTimeoutFn } from "@vueuse/core";
|
||||||
import { RouteConfigs } from "/@/layout/types";
|
import { RouteConfigs } from "/@/layout/types";
|
||||||
|
import { buildHierarchyTree } from "/@/utils/tree";
|
||||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||||
|
const Layout = () => import("/@/layout/index.vue");
|
||||||
|
const IFrame = () => import("/@/layout/frameView.vue");
|
||||||
// https://cn.vitejs.dev/guide/features.html#glob-import
|
// https://cn.vitejs.dev/guide/features.html#glob-import
|
||||||
const modulesRoutes = import.meta.glob("/src/views/**/*.{vue,tsx}");
|
const modulesRoutes = import.meta.glob("/src/views/**/*.{vue,tsx}");
|
||||||
|
|
||||||
@@ -125,6 +127,10 @@ function initRouter(name: string) {
|
|||||||
// 最终路由进行升序
|
// 最终路由进行升序
|
||||||
ascending(router.options.routes[0].children);
|
ascending(router.options.routes[0].children);
|
||||||
if (!router.hasRoute(v?.name)) router.addRoute(v);
|
if (!router.hasRoute(v?.name)) router.addRoute(v);
|
||||||
|
const flattenRouters = router
|
||||||
|
.getRoutes()
|
||||||
|
.find(n => n.path === "/");
|
||||||
|
router.addRoute(flattenRouters);
|
||||||
}
|
}
|
||||||
resolve(router);
|
resolve(router);
|
||||||
}
|
}
|
||||||
@@ -146,14 +152,15 @@ function initRouter(name: string) {
|
|||||||
*/
|
*/
|
||||||
function formatFlatteningRoutes(routesList: RouteRecordRaw[]) {
|
function formatFlatteningRoutes(routesList: RouteRecordRaw[]) {
|
||||||
if (routesList.length === 0) return routesList;
|
if (routesList.length === 0) return routesList;
|
||||||
for (let i = 0; i < routesList.length; i++) {
|
let hierarchyList = buildHierarchyTree(routesList);
|
||||||
if (routesList[i].children) {
|
for (let i = 0; i < hierarchyList.length; i++) {
|
||||||
routesList = routesList
|
if (hierarchyList[i].children) {
|
||||||
|
hierarchyList = hierarchyList
|
||||||
.slice(0, i + 1)
|
.slice(0, i + 1)
|
||||||
.concat(routesList[i].children, routesList.slice(i + 1));
|
.concat(hierarchyList[i].children, hierarchyList.slice(i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return routesList;
|
return hierarchyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -216,6 +223,8 @@ function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
|
|||||||
arrRoutes.forEach((v: RouteRecordRaw) => {
|
arrRoutes.forEach((v: RouteRecordRaw) => {
|
||||||
if (v.redirect) {
|
if (v.redirect) {
|
||||||
v.component = Layout;
|
v.component = Layout;
|
||||||
|
} else if (v.meta?.frameSrc) {
|
||||||
|
v.component = IFrame;
|
||||||
} else {
|
} else {
|
||||||
const index = modulesRoutesKeys.findIndex(ev => ev.includes(v.path));
|
const index = modulesRoutesKeys.findIndex(ev => ev.includes(v.path));
|
||||||
v.component = modulesRoutes[modulesRoutesKeys[index]];
|
v.component = modulesRoutes[modulesRoutesKeys[index]];
|
||||||
|
|||||||
@@ -8,16 +8,29 @@ export const useEpThemeStore = defineStore({
|
|||||||
state: () => ({
|
state: () => ({
|
||||||
epThemeColor:
|
epThemeColor:
|
||||||
storageLocal.getItem("responsive-layout")?.epThemeColor ??
|
storageLocal.getItem("responsive-layout")?.epThemeColor ??
|
||||||
getConfig().EpThemeColor
|
getConfig().EpThemeColor,
|
||||||
|
epTheme:
|
||||||
|
storageLocal.getItem("responsive-layout")?.theme ?? getConfig().Theme
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getEpThemeColor() {
|
getEpThemeColor() {
|
||||||
return this.epThemeColor;
|
return this.epThemeColor;
|
||||||
|
},
|
||||||
|
// 用于mix导航模式下hamburger-svg的fill属性
|
||||||
|
fill() {
|
||||||
|
if (this.epTheme === "light") {
|
||||||
|
return "#409eff";
|
||||||
|
} else if (this.epTheme === "yellow") {
|
||||||
|
return "#d25f00";
|
||||||
|
} else {
|
||||||
|
return "#fff";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setEpThemeColor(newColor) {
|
setEpThemeColor(newColor) {
|
||||||
const layout = storageLocal.getItem("responsive-layout");
|
const layout = storageLocal.getItem("responsive-layout");
|
||||||
|
this.epTheme = layout?.theme;
|
||||||
this.epThemeColor = newColor;
|
this.epThemeColor = newColor;
|
||||||
layout.epThemeColor = newColor;
|
layout.epThemeColor = newColor;
|
||||||
storageLocal.setItem("responsive-layout", layout);
|
storageLocal.setItem("responsive-layout", layout);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { store } from "/@/store";
|
import { store } from "/@/store";
|
||||||
import { isEqual } from "lodash-es";
|
import { isUrl } from "/@/utils/is";
|
||||||
|
import { isEqual } from "lodash-unified";
|
||||||
import { storageLocal } from "/@/utils/storage";
|
import { storageLocal } from "/@/utils/storage";
|
||||||
import { multiType, positionType } from "./types";
|
import { multiType, positionType } from "./types";
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ export const useMultiTagsStore = defineStore({
|
|||||||
case "push":
|
case "push":
|
||||||
{
|
{
|
||||||
const tagVal = value as multiType;
|
const tagVal = value as multiType;
|
||||||
|
if (isUrl(tagVal?.name)) return;
|
||||||
const tagPath = tagVal?.path;
|
const tagPath = tagVal?.path;
|
||||||
// 判断tag是否已存在
|
// 判断tag是否已存在
|
||||||
const tagHasExits = this.multiTags.some(tag => {
|
const tagHasExits = this.multiTags.some(tag => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { store } from "/@/store";
|
import { store } from "/@/store";
|
||||||
import { cacheType } from "./types";
|
import { cacheType } from "./types";
|
||||||
import { cloneDeep } from "lodash-es";
|
import { cloneDeep } from "lodash-unified";
|
||||||
import { RouteConfigs } from "/@/layout/types";
|
import { RouteConfigs } from "/@/layout/types";
|
||||||
import { constantMenus } from "/@/router/modules";
|
import { constantMenus } from "/@/router/modules";
|
||||||
import { ascending, filterTree } from "/@/router/utils";
|
import { ascending, filterTree } from "/@/router/utils";
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.el-overlay {
|
.el-overlay {
|
||||||
background-color: rgba(0, 0, 0, 0.05) !important;
|
background-color: rgb(0 0 0 / 5%) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-drawer {
|
.el-drawer {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.el-dropdown-menu {
|
.el-dropdown-menu {
|
||||||
padding: 2px 0 2px 0 !important;
|
padding: 2px 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-range-separator {
|
.el-range-separator {
|
||||||
@@ -38,14 +38,16 @@
|
|||||||
|
|
||||||
/* 动态改变cssvar 用于主题切换 https://github.com/element-plus/element-plus/issues/4856#issuecomment-1000174357 */
|
/* 动态改变cssvar 用于主题切换 https://github.com/element-plus/element-plus/issues/4856#issuecomment-1000174357 */
|
||||||
.el-button--primary {
|
.el-button--primary {
|
||||||
--el-button-bg-color: var(--el-color-primary) !important;
|
|
||||||
--el-button-border-color: var(--el-color-primary) !important;
|
|
||||||
--el-button-hover-bg-color: var(--el-color-primary-light-2) !important;
|
|
||||||
--el-button-hover-border-color: var(--el-color-primary-light-2) !important;
|
|
||||||
--el-button-active-bg-color: var(--el-color-primary-active) !important;
|
--el-button-active-bg-color: var(--el-color-primary-active) !important;
|
||||||
--el-button-active-border-color: var(--el-color-primary-active) !important;
|
--el-button-active-border-color: var(--el-color-primary-active) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* button--primary plain */
|
||||||
|
.el-button--primary.is-plain {
|
||||||
|
--el-button-active-bg-color: var(--el-color-primary) !important;
|
||||||
|
--el-button-active-border-color: var(--el-color-primary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* nprogress适配ep的primary */
|
/* nprogress适配ep的primary */
|
||||||
#nprogress {
|
#nprogress {
|
||||||
& .bar {
|
& .bar {
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ body {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizelegibility;
|
||||||
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB,
|
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
|
||||||
Microsoft YaHei, Arial, sans-serif;
|
"Microsoft YaHei", "微软雅黑", Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
@@ -22,6 +22,11 @@ html {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#app {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
@@ -74,19 +79,11 @@ ul {
|
|||||||
/* 灰色模式 */
|
/* 灰色模式 */
|
||||||
.html-grey {
|
.html-grey {
|
||||||
filter: grayscale(100%);
|
filter: grayscale(100%);
|
||||||
-webkit-filter: grayscale(100%);
|
|
||||||
-moz-filter: grayscale(100%);
|
|
||||||
-ms-filter: grayscale(100%);
|
|
||||||
-o-filter: grayscale(100%);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 色弱模式 */
|
/* 色弱模式 */
|
||||||
.html-weakness {
|
.html-weakness {
|
||||||
filter: invert(80%);
|
filter: invert(80%);
|
||||||
-webkit-filter: invert(80%);
|
|
||||||
-moz-filter: invert(80%);
|
|
||||||
-ms-filter: invert(80%);
|
|
||||||
-o-filter: invert(80%);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.pc-spacing {
|
.pc-spacing {
|
||||||
|
|||||||
@@ -23,16 +23,6 @@
|
|||||||
margin-left: $sideBarWidth;
|
margin-left: $sideBarWidth;
|
||||||
position: relative;
|
position: relative;
|
||||||
background: #f0f2f5;
|
background: #f0f2f5;
|
||||||
@media screen and (min-width: 150px) and (max-width: 420px) {
|
|
||||||
.app-main .el-scrollbar__view:first-child {
|
|
||||||
overflow-y: hidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media screen and (min-width: 420px) {
|
|
||||||
.app-main .el-scrollbar__view:first-child {
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.fixed-header {
|
.fixed-header {
|
||||||
@@ -306,6 +296,10 @@
|
|||||||
height: 48px;
|
height: 48px;
|
||||||
line-height: 48px;
|
line-height: 48px;
|
||||||
background: $menuBg;
|
background: $menuBg;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
position: static !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.is-active > .el-sub-menu__title,
|
.is-active > .el-sub-menu__title,
|
||||||
@@ -498,9 +492,7 @@
|
|||||||
background-color: $menuActiveBefore;
|
background-color: $menuActiveBefore;
|
||||||
content: "";
|
content: "";
|
||||||
clear: both;
|
clear: both;
|
||||||
-webkit-transition: all 0.2s ease-in-out;
|
|
||||||
transition: all 0.2s ease-in-out;
|
transition: all 0.2s ease-in-out;
|
||||||
-webkit-transform: translateY(0);
|
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,9 +505,7 @@
|
|||||||
background-color: $menuActiveBefore;
|
background-color: $menuActiveBefore;
|
||||||
content: "";
|
content: "";
|
||||||
clear: both;
|
clear: both;
|
||||||
-webkit-transition: all 0.2s ease-in-out;
|
|
||||||
transition: all 0.2s ease-in-out;
|
transition: all 0.2s ease-in-out;
|
||||||
-webkit-transform: translateY(0);
|
|
||||||
transform: translateY(0);
|
transform: translateY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,7 +516,6 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
height: 0;
|
height: 0;
|
||||||
width: 3px;
|
width: 3px;
|
||||||
-webkit-transform: translateY(-50%);
|
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
top: 50%;
|
top: 50%;
|
||||||
}
|
}
|
||||||
@@ -600,16 +589,6 @@ body[layout="vertical"] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-sub-menu {
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
& > .el-sub-menu__title {
|
|
||||||
.el-sub-menu__icon-arrow {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 菜单折叠 */
|
/* 菜单折叠 */
|
||||||
.el-menu--collapse {
|
.el-menu--collapse {
|
||||||
.el-sub-menu {
|
.el-sub-menu {
|
||||||
@@ -649,3 +628,64 @@ body[layout="horizontal"] {
|
|||||||
transition: none !important;
|
transition: none !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body[layout="mix"] {
|
||||||
|
$sideBarWidth: 210px;
|
||||||
|
@include merge-style($sideBarWidth);
|
||||||
|
|
||||||
|
.el-menu {
|
||||||
|
--el-menu-hover-bg-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hideSidebar {
|
||||||
|
.fixed-header {
|
||||||
|
width: calc(100% - 54px);
|
||||||
|
transition: width 0.28s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-container {
|
||||||
|
width: 54px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-container {
|
||||||
|
margin-left: 54px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submenu-title-noDropdown {
|
||||||
|
padding: 0 !important;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.el-tooltip {
|
||||||
|
padding: 0 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 菜单折叠 */
|
||||||
|
.el-menu--collapse {
|
||||||
|
.el-sub-menu {
|
||||||
|
& > .el-sub-menu__title {
|
||||||
|
& > span {
|
||||||
|
height: 0;
|
||||||
|
width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
visibility: hidden;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 无子菜单 */
|
||||||
|
.el-menu-item [class^="el-icon"] {
|
||||||
|
right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-sub-menu__title [class^="el-icon"] {
|
||||||
|
right: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submenu-title-noDropdown {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
resultType,
|
resultType,
|
||||||
PureHttpError,
|
PureHttpError,
|
||||||
RequestMethods,
|
RequestMethods,
|
||||||
PureHttpResoponse,
|
PureHttpResponse,
|
||||||
PureHttpRequestConfig
|
PureHttpRequestConfig
|
||||||
} from "./types.d";
|
} from "./types.d";
|
||||||
import qs from "qs";
|
import qs from "qs";
|
||||||
@@ -91,7 +91,7 @@ class PureHttp {
|
|||||||
private httpInterceptorsResponse(): void {
|
private httpInterceptorsResponse(): void {
|
||||||
const instance = PureHttp.axiosInstance;
|
const instance = PureHttp.axiosInstance;
|
||||||
instance.interceptors.response.use(
|
instance.interceptors.response.use(
|
||||||
(response: PureHttpResoponse) => {
|
(response: PureHttpResponse) => {
|
||||||
const $config = response.config;
|
const $config = response.config;
|
||||||
// 关闭进度条动画
|
// 关闭进度条动画
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
@@ -145,21 +145,21 @@ class PureHttp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 单独抽离的post工具函数
|
// 单独抽离的post工具函数
|
||||||
public post<T>(
|
public post<T, P>(
|
||||||
url: string,
|
url: string,
|
||||||
params?: T,
|
params?: T,
|
||||||
config?: PureHttpRequestConfig
|
config?: PureHttpRequestConfig
|
||||||
): Promise<T> {
|
): Promise<P> {
|
||||||
return this.request<T>("post", url, params, config);
|
return this.request<P>("post", url, params, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 单独抽离的get工具函数
|
// 单独抽离的get工具函数
|
||||||
public get<T>(
|
public get<T, P>(
|
||||||
url: string,
|
url: string,
|
||||||
params?: T,
|
params?: T,
|
||||||
config?: PureHttpRequestConfig
|
config?: PureHttpRequestConfig
|
||||||
): Promise<T> {
|
): Promise<P> {
|
||||||
return this.request<T>("get", url, params, config);
|
return this.request<P>("get", url, params, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
src/utils/http/types.d.ts
vendored
16
src/utils/http/types.d.ts
vendored
@@ -18,13 +18,13 @@ export interface PureHttpError extends AxiosError {
|
|||||||
isCancelRequest?: boolean;
|
isCancelRequest?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PureHttpResoponse extends AxiosResponse {
|
export interface PureHttpResponse extends AxiosResponse {
|
||||||
config: PureHttpRequestConfig;
|
config: PureHttpRequestConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PureHttpRequestConfig extends AxiosRequestConfig {
|
export interface PureHttpRequestConfig extends AxiosRequestConfig {
|
||||||
beforeRequestCallback?: (request: PureHttpRequestConfig) => void;
|
beforeRequestCallback?: (request: PureHttpRequestConfig) => void;
|
||||||
beforeResponseCallback?: (response: PureHttpResoponse) => void;
|
beforeResponseCallback?: (response: PureHttpResponse) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class PureHttp {
|
export default class PureHttp {
|
||||||
@@ -34,6 +34,14 @@ export default class PureHttp {
|
|||||||
param?: AxiosRequestConfig,
|
param?: AxiosRequestConfig,
|
||||||
axiosConfig?: PureHttpRequestConfig
|
axiosConfig?: PureHttpRequestConfig
|
||||||
): Promise<T>;
|
): Promise<T>;
|
||||||
post<T>(url: string, params?: T, config?: PureHttpRequestConfig): Promise<T>;
|
post<T, P>(
|
||||||
get<T>(url: string, params?: T, config?: PureHttpRequestConfig): Promise<T>;
|
url: string,
|
||||||
|
params?: T,
|
||||||
|
config?: PureHttpRequestConfig
|
||||||
|
): Promise<P>;
|
||||||
|
get<T, P>(
|
||||||
|
url: string,
|
||||||
|
params?: T,
|
||||||
|
config?: PureHttpRequestConfig
|
||||||
|
): Promise<P>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,8 +94,9 @@ export const isServer = typeof window === "undefined";
|
|||||||
|
|
||||||
export const isClient = !isServer;
|
export const isClient = !isServer;
|
||||||
|
|
||||||
export function isUrl(path: string): boolean {
|
export function isUrl<T>(path: T): boolean {
|
||||||
const reg =
|
const reg =
|
||||||
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
|
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
|
||||||
|
// @ts-expect-error
|
||||||
return reg.test(path);
|
return reg.test(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export const openLink = (link: string) => {
|
export const openLink = <T>(link: T): void => {
|
||||||
const $a: HTMLElement = document.createElement("a");
|
const $a: HTMLElement = document.createElement("a");
|
||||||
|
// @ts-expect-error
|
||||||
$a.setAttribute("href", link);
|
$a.setAttribute("href", link);
|
||||||
$a.setAttribute("target", "_blank");
|
$a.setAttribute("target", "_blank");
|
||||||
$a.setAttribute("rel", "noreferrer noopener");
|
$a.setAttribute("rel", "noreferrer noopener");
|
||||||
|
|||||||
54
src/utils/loaders/index.ts
Normal file
54
src/utils/loaders/index.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
interface ProxyLoader {
|
||||||
|
loadCss(src: string): any;
|
||||||
|
loadScript(src: string): Promise<any>;
|
||||||
|
loadScriptConcurrent(src: Array<string>): Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
class loaderProxy implements ProxyLoader {
|
||||||
|
constructor() {}
|
||||||
|
|
||||||
|
protected scriptLoaderCache: Array<string> = [];
|
||||||
|
|
||||||
|
public loadCss = (src: string): any => {
|
||||||
|
const element: HTMLLinkElement = document.createElement("link");
|
||||||
|
element.rel = "stylesheet";
|
||||||
|
element.href = src;
|
||||||
|
document.body.appendChild(element);
|
||||||
|
};
|
||||||
|
|
||||||
|
public loadScript = async (src: string): Promise<any> => {
|
||||||
|
if (this.scriptLoaderCache.includes(src)) {
|
||||||
|
return src;
|
||||||
|
} else {
|
||||||
|
const element: HTMLScriptElement = document.createElement("script");
|
||||||
|
element.src = src;
|
||||||
|
document.body.appendChild(element);
|
||||||
|
element.onload = () => {
|
||||||
|
return this.scriptLoaderCache.push(src);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public loadScriptConcurrent = async (
|
||||||
|
srcList: Array<string>
|
||||||
|
): Promise<any> => {
|
||||||
|
if (Array.isArray(srcList)) {
|
||||||
|
const len: number = srcList.length;
|
||||||
|
if (len > 0) {
|
||||||
|
let count = 0;
|
||||||
|
srcList.map(src => {
|
||||||
|
if (src) {
|
||||||
|
this.loadScript(src).then(() => {
|
||||||
|
count++;
|
||||||
|
if (count === len) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const loader = new loaderProxy();
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import type { FunctionArgs } from "@vueuse/core";
|
||||||
|
|
||||||
export const hasClass = (ele: RefType<any>, cls: string): any => {
|
export const hasClass = (ele: RefType<any>, cls: string): any => {
|
||||||
return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
|
return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
|
||||||
};
|
};
|
||||||
@@ -40,3 +42,16 @@ export const toggleClass = (
|
|||||||
className = className.replace(clsName, "");
|
className = className.replace(clsName, "");
|
||||||
targetEl.className = flag ? `${className} ${clsName} ` : className;
|
targetEl.className = flag ? `${className} ${clsName} ` : className;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function useRafThrottle<T extends FunctionArgs>(fn: T): T {
|
||||||
|
let locked = false;
|
||||||
|
// @ts-ignore
|
||||||
|
return function (...args) {
|
||||||
|
if (locked) return;
|
||||||
|
locked = true;
|
||||||
|
window.requestAnimationFrame(() => {
|
||||||
|
fn.apply(this, args);
|
||||||
|
locked = false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
226
src/utils/print.ts
Normal file
226
src/utils/print.ts
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
interface PrintFunction {
|
||||||
|
extendOptions: Function;
|
||||||
|
getStyle: Function;
|
||||||
|
setDomHeight: Function;
|
||||||
|
toPrint: Function;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Print = function (dom, options?: object): PrintFunction {
|
||||||
|
options = options || {};
|
||||||
|
// @ts-expect-error
|
||||||
|
if (!(this instanceof Print)) return new Print(dom, options);
|
||||||
|
this.conf = {
|
||||||
|
styleStr: "",
|
||||||
|
// Elements that need to dynamically get and set the height
|
||||||
|
setDomHeightArr: [],
|
||||||
|
// Echart dom List
|
||||||
|
echartDomArr: [],
|
||||||
|
// Callback before printing
|
||||||
|
printBeforeFn: null,
|
||||||
|
// Callback after printing
|
||||||
|
printDoneCallBack: null
|
||||||
|
};
|
||||||
|
for (const key in this.conf) {
|
||||||
|
// eslint-disable-next-line no-prototype-builtins
|
||||||
|
if (key && options.hasOwnProperty(key)) {
|
||||||
|
this.conf[key] = options[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof dom === "string") {
|
||||||
|
this.dom = document.querySelector(dom);
|
||||||
|
} else {
|
||||||
|
this.dom = this.isDOM(dom) ? dom : dom.$el;
|
||||||
|
}
|
||||||
|
if (this.conf.setDomHeightArr && this.conf.setDomHeightArr.length) {
|
||||||
|
this.setDomHeight(this.conf.setDomHeightArr);
|
||||||
|
}
|
||||||
|
this.init();
|
||||||
|
};
|
||||||
|
|
||||||
|
Print.prototype = {
|
||||||
|
/**
|
||||||
|
* init
|
||||||
|
*/
|
||||||
|
init: function (): void {
|
||||||
|
const content = this.getStyle() + this.getHtml();
|
||||||
|
this.writeIframe(content);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Configuration property extension
|
||||||
|
* @param {Object} obj
|
||||||
|
* @param {Object} obj2
|
||||||
|
*/
|
||||||
|
extendOptions: function <T>(obj, obj2: T): T {
|
||||||
|
for (const k in obj2) {
|
||||||
|
obj[k] = obj2[k];
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
Copy all styles of the original page
|
||||||
|
*/
|
||||||
|
getStyle: function (): string {
|
||||||
|
let str = "";
|
||||||
|
const styles: NodeListOf<Element> = document.querySelectorAll("style,link");
|
||||||
|
for (let i = 0; i < styles.length; i++) {
|
||||||
|
str += styles[i].outerHTML;
|
||||||
|
}
|
||||||
|
str += `<style>.no-print{display:none;}${this.conf.styleStr}</style>`;
|
||||||
|
return str;
|
||||||
|
},
|
||||||
|
// form assignment
|
||||||
|
getHtml: function (): Element {
|
||||||
|
const inputs = document.querySelectorAll("input");
|
||||||
|
const selects = document.querySelectorAll("select");
|
||||||
|
const textareas = document.querySelectorAll("textarea");
|
||||||
|
for (let k = 0; k < inputs.length; k++) {
|
||||||
|
if (inputs[k].type == "checkbox" || inputs[k].type == "radio") {
|
||||||
|
if (inputs[k].checked == true) {
|
||||||
|
inputs[k].setAttribute("checked", "checked");
|
||||||
|
} else {
|
||||||
|
inputs[k].removeAttribute("checked");
|
||||||
|
}
|
||||||
|
} else if (inputs[k].type == "text") {
|
||||||
|
inputs[k].setAttribute("value", inputs[k].value);
|
||||||
|
} else {
|
||||||
|
inputs[k].setAttribute("value", inputs[k].value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let k2 = 0; k2 < textareas.length; k2++) {
|
||||||
|
if (textareas[k2].type == "textarea") {
|
||||||
|
textareas[k2].innerHTML = textareas[k2].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let k3 = 0; k3 < selects.length; k3++) {
|
||||||
|
if (selects[k3].type == "select-one") {
|
||||||
|
const child = selects[k3].children;
|
||||||
|
for (const i in child) {
|
||||||
|
if (child[i].tagName == "OPTION") {
|
||||||
|
// @ts-ignore
|
||||||
|
if (child[i].selected == true) {
|
||||||
|
child[i].setAttribute("selected", "selected");
|
||||||
|
} else {
|
||||||
|
child[i].removeAttribute("selected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.dom.outerHTML;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
create iframe
|
||||||
|
*/
|
||||||
|
writeIframe: function (content) {
|
||||||
|
let w: Document | Window;
|
||||||
|
let doc: Document;
|
||||||
|
const iframe: HTMLIFrameElement = document.createElement("iframe");
|
||||||
|
const f: HTMLIFrameElement = document.body.appendChild(iframe);
|
||||||
|
iframe.id = "myIframe";
|
||||||
|
iframe.setAttribute(
|
||||||
|
"style",
|
||||||
|
"position:absolute;width:0;height:0;top:-10px;left:-10px;"
|
||||||
|
);
|
||||||
|
// eslint-disable-next-line prefer-const
|
||||||
|
w = f.contentWindow || f.contentDocument;
|
||||||
|
// eslint-disable-next-line prefer-const
|
||||||
|
doc = f.contentDocument || f.contentWindow.document;
|
||||||
|
doc.open();
|
||||||
|
doc.write(content);
|
||||||
|
doc.close();
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||||
|
const _this = this;
|
||||||
|
iframe.onload = function (): void {
|
||||||
|
// Before popping, callback
|
||||||
|
if (_this.conf.printBeforeFn) {
|
||||||
|
_this.conf.printBeforeFn({ doc });
|
||||||
|
}
|
||||||
|
|
||||||
|
_this.drawEchartImg(doc).then(() => {
|
||||||
|
_this.toPrint(w);
|
||||||
|
setTimeout(function () {
|
||||||
|
document.body.removeChild(iframe);
|
||||||
|
// After popup, callback
|
||||||
|
if (_this.conf.printDoneCallBack) {
|
||||||
|
_this.conf.printDoneCallBack();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* echarts printing
|
||||||
|
* @param {Object} doc iframe window
|
||||||
|
*/
|
||||||
|
drawEchartImg(doc): Promise<void> {
|
||||||
|
return new Promise<void>(resolve => {
|
||||||
|
if (this.conf.echartDomArr && this.conf.echartDomArr.length > 0) {
|
||||||
|
this.conf.echartDomArr.forEach(e => {
|
||||||
|
const dom = doc.querySelector("#" + e.$el.id);
|
||||||
|
const img = new Image();
|
||||||
|
const w = dom.offsetWidth + "px";
|
||||||
|
const H = dom.offsetHeight + "px";
|
||||||
|
|
||||||
|
img.style.width = w;
|
||||||
|
img.style.height = H;
|
||||||
|
img.src = e.imgSrc;
|
||||||
|
dom.innerHTML = "";
|
||||||
|
dom.appendChild(img);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
Print
|
||||||
|
*/
|
||||||
|
toPrint: function (frameWindow): void {
|
||||||
|
try {
|
||||||
|
setTimeout(function () {
|
||||||
|
frameWindow.focus();
|
||||||
|
try {
|
||||||
|
if (!frameWindow.document.execCommand("print", false, null)) {
|
||||||
|
frameWindow.print();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
frameWindow.print();
|
||||||
|
}
|
||||||
|
frameWindow.close();
|
||||||
|
}, 10);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isDOM:
|
||||||
|
typeof HTMLElement === "object"
|
||||||
|
? function (obj) {
|
||||||
|
return obj instanceof HTMLElement;
|
||||||
|
}
|
||||||
|
: function (obj) {
|
||||||
|
return (
|
||||||
|
obj &&
|
||||||
|
typeof obj === "object" &&
|
||||||
|
obj.nodeType === 1 &&
|
||||||
|
typeof obj.nodeName === "string"
|
||||||
|
);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Set the height of the specified dom element by getting the existing height of the dom element and setting
|
||||||
|
* @param {Array} arr
|
||||||
|
*/
|
||||||
|
setDomHeight(arr) {
|
||||||
|
if (arr && arr.length) {
|
||||||
|
arr.forEach(name => {
|
||||||
|
const domArr = document.querySelectorAll(name);
|
||||||
|
domArr.forEach(dom => {
|
||||||
|
dom.style.height = dom.offsetHeight + "px";
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Print;
|
||||||
35
src/utils/resize/index.ts
Normal file
35
src/utils/resize/index.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import ResizeObserver from "resize-observer-polyfill";
|
||||||
|
|
||||||
|
const isServer = typeof window === "undefined";
|
||||||
|
|
||||||
|
const resizeHandler = (entries: any[]): void => {
|
||||||
|
for (const entry of entries) {
|
||||||
|
const listeners = entry.target.__resizeListeners__ || [];
|
||||||
|
if (listeners.length) {
|
||||||
|
listeners.forEach((fn: () => any) => {
|
||||||
|
fn();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const addResizeListener = (element: any, fn: () => any): any => {
|
||||||
|
if (isServer) return;
|
||||||
|
if (!element.__resizeListeners__) {
|
||||||
|
element.__resizeListeners__ = [];
|
||||||
|
element.__ro__ = new ResizeObserver(resizeHandler);
|
||||||
|
element.__ro__.observe(element);
|
||||||
|
}
|
||||||
|
element.__resizeListeners__.push(fn);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const removeResizeListener = (element: any, fn: () => any): any => {
|
||||||
|
if (!element || !element.__resizeListeners__) return;
|
||||||
|
element.__resizeListeners__.splice(
|
||||||
|
element.__resizeListeners__.indexOf(fn),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
if (!element.__resizeListeners__.length) {
|
||||||
|
element.__ro__.disconnect();
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -20,7 +20,7 @@ export const injectResponsiveStorage = (app: App, config: ServerConfigs) => {
|
|||||||
theme: config.Theme ?? "default",
|
theme: config.Theme ?? "default",
|
||||||
darkMode: config.DarkMode ?? false,
|
darkMode: config.DarkMode ?? false,
|
||||||
sidebarStatus: config.SidebarStatus ?? true,
|
sidebarStatus: config.SidebarStatus ?? true,
|
||||||
epThemeColor: config.EpThemeColor ?? "409EFF"
|
epThemeColor: config.EpThemeColor ?? "#409EFF"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
configure: {
|
configure: {
|
||||||
|
|||||||
67
src/utils/tree.ts
Normal file
67
src/utils/tree.ts
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
* 提取菜单树中的每一项uniqueId
|
||||||
|
* @param {Array} {menuTree 菜单树}
|
||||||
|
* @param {return}} expandedPaths 每一项uniqueId组成的数组
|
||||||
|
*/
|
||||||
|
const expandedPaths = [];
|
||||||
|
export function extractPathList(menuTree) {
|
||||||
|
if (!Array.isArray(menuTree)) {
|
||||||
|
console.warn("menuTree must be an array");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!menuTree || menuTree.length === 0) return;
|
||||||
|
for (const node of menuTree) {
|
||||||
|
const hasChildren = node.children && node.children.length > 0;
|
||||||
|
if (hasChildren) {
|
||||||
|
extractPathList(node.children);
|
||||||
|
}
|
||||||
|
expandedPaths.push(node.uniqueId);
|
||||||
|
}
|
||||||
|
return expandedPaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果父级下children的length为1,删除children并自动组建唯一uniqueId
|
||||||
|
* @param {Array} {menuTree 菜单树}
|
||||||
|
* @param {Array} {pathList 每一项的id组成的数组}
|
||||||
|
* @param {return}}
|
||||||
|
*/
|
||||||
|
export function deleteChildren(menuTree, pathList = []) {
|
||||||
|
if (!Array.isArray(menuTree)) {
|
||||||
|
console.warn("menuTree must be an array");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!menuTree || menuTree.length === 0) return;
|
||||||
|
for (const [key, node] of menuTree.entries()) {
|
||||||
|
if (node.children && node.children.length === 1) delete node.children;
|
||||||
|
node.id = key;
|
||||||
|
node.parentId = pathList.length ? pathList[pathList.length - 1] : null;
|
||||||
|
node.pathList = [...pathList, node.id];
|
||||||
|
node.uniqueId =
|
||||||
|
node.pathList.length > 1 ? node.pathList.join("-") : node.pathList[0];
|
||||||
|
const hasChildren = node.children && node.children.length > 0;
|
||||||
|
if (hasChildren) {
|
||||||
|
deleteChildren(node.children, node.pathList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return menuTree;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建层级关系
|
||||||
|
export function buildHierarchyTree(menuTree, pathList = []) {
|
||||||
|
if (!Array.isArray(menuTree)) {
|
||||||
|
console.warn("menuTree must be an array");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!menuTree || menuTree.length === 0) return;
|
||||||
|
for (const [key, node] of menuTree.entries()) {
|
||||||
|
node.id = key;
|
||||||
|
node.parentId = pathList.length ? pathList[pathList.length - 1] : null;
|
||||||
|
node.pathList = [...pathList, node.id];
|
||||||
|
const hasChildren = node.children && node.children.length > 0;
|
||||||
|
if (hasChildren) {
|
||||||
|
buildHierarchyTree(node.children, node.pathList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return menuTree;
|
||||||
|
}
|
||||||
116
src/utils/watermark.ts
Normal file
116
src/utils/watermark.ts
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
import {
|
||||||
|
ref,
|
||||||
|
Ref,
|
||||||
|
unref,
|
||||||
|
shallowRef,
|
||||||
|
onBeforeUnmount,
|
||||||
|
getCurrentInstance
|
||||||
|
} from "vue";
|
||||||
|
import { isDef } from "/@/utils/is";
|
||||||
|
import { useRafThrottle } from "/@/utils/operate";
|
||||||
|
import { addResizeListener, removeResizeListener } from "/@/utils/resize";
|
||||||
|
|
||||||
|
const domSymbol = Symbol("watermark-dom");
|
||||||
|
|
||||||
|
type attr = {
|
||||||
|
font?: string;
|
||||||
|
fillStyle?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function useWatermark(
|
||||||
|
appendEl: Ref<HTMLElement | null> = ref(document.body) as Ref<HTMLElement>
|
||||||
|
) {
|
||||||
|
const func = useRafThrottle(function () {
|
||||||
|
const el = unref(appendEl);
|
||||||
|
if (!el) return;
|
||||||
|
const { clientHeight: height, clientWidth: width } = el;
|
||||||
|
updateWatermark({ height, width });
|
||||||
|
});
|
||||||
|
const id = domSymbol.toString();
|
||||||
|
const watermarkEl = shallowRef<HTMLElement>();
|
||||||
|
|
||||||
|
const clear = () => {
|
||||||
|
const domId = unref(watermarkEl);
|
||||||
|
watermarkEl.value = undefined;
|
||||||
|
const el = unref(appendEl);
|
||||||
|
if (!el) return;
|
||||||
|
domId && el.removeChild(domId);
|
||||||
|
removeResizeListener(el, func);
|
||||||
|
};
|
||||||
|
|
||||||
|
function createBase64(str: string, attr?: attr) {
|
||||||
|
const can = document.createElement("canvas");
|
||||||
|
const width = 300;
|
||||||
|
const height = 240;
|
||||||
|
Object.assign(can, { width, height });
|
||||||
|
|
||||||
|
const cans = can.getContext("2d");
|
||||||
|
if (cans) {
|
||||||
|
cans.rotate((-20 * Math.PI) / 120);
|
||||||
|
cans.font = attr?.font ?? "15px Reggae One";
|
||||||
|
cans.fillStyle = attr?.fillStyle ?? "rgba(0, 0, 0, 0.15)";
|
||||||
|
cans.textAlign = "left";
|
||||||
|
cans.textBaseline = "middle";
|
||||||
|
cans.fillText(str, width / 20, height);
|
||||||
|
}
|
||||||
|
return can.toDataURL("image/png");
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateWatermark(
|
||||||
|
options: {
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
str?: string;
|
||||||
|
attr?: attr;
|
||||||
|
} = {}
|
||||||
|
) {
|
||||||
|
const el = unref(watermarkEl);
|
||||||
|
if (!el) return;
|
||||||
|
if (isDef(options.width)) {
|
||||||
|
el.style.width = `${options.width}px`;
|
||||||
|
}
|
||||||
|
if (isDef(options.height)) {
|
||||||
|
el.style.height = `${options.height}px`;
|
||||||
|
}
|
||||||
|
if (isDef(options.str)) {
|
||||||
|
el.style.background = `url(${createBase64(
|
||||||
|
options.str,
|
||||||
|
options.attr
|
||||||
|
)}) left top repeat`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const createWatermark = (str: string, attr?: attr) => {
|
||||||
|
if (unref(watermarkEl)) {
|
||||||
|
updateWatermark({ str, attr });
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
const div = document.createElement("div");
|
||||||
|
watermarkEl.value = div;
|
||||||
|
div.id = id;
|
||||||
|
div.style.pointerEvents = "none";
|
||||||
|
div.style.top = "0px";
|
||||||
|
div.style.left = "0px";
|
||||||
|
div.style.position = "absolute";
|
||||||
|
div.style.zIndex = "100000";
|
||||||
|
const el = unref(appendEl);
|
||||||
|
if (!el) return id;
|
||||||
|
const { clientHeight: height, clientWidth: width } = el;
|
||||||
|
updateWatermark({ str, width, height, attr });
|
||||||
|
el.appendChild(div);
|
||||||
|
return id;
|
||||||
|
};
|
||||||
|
|
||||||
|
function setWatermark(str: string, attr?: attr) {
|
||||||
|
createWatermark(str, attr);
|
||||||
|
addResizeListener(document.documentElement, func);
|
||||||
|
const instance = getCurrentInstance();
|
||||||
|
if (instance) {
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
clear();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { setWatermark, clear };
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ export default {
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, unref } from "vue";
|
import { ref, unref } from "vue";
|
||||||
import { storageSession } from "/@/utils/storage";
|
import { storageSession } from "/@/utils/storage";
|
||||||
|
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
|
||||||
|
|
||||||
let purview = ref<string>(storageSession.getItem("info").username);
|
let purview = ref<string>(storageSession.getItem("info").username);
|
||||||
|
|
||||||
@@ -36,6 +37,11 @@ function changRole() {
|
|||||||
查看左侧菜单变化(系统管理),模拟后台根据不同角色返回对应路由
|
查看左侧菜单变化(系统管理),模拟后台根据不同角色返回对应路由
|
||||||
</p>
|
</p>
|
||||||
</h4>
|
</h4>
|
||||||
<el-button type="primary" @click="changRole">切换角色</el-button>
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="changRole"
|
||||||
|
:icon="useRenderIcon('user', { color: '#fff' })"
|
||||||
|
>切换角色</el-button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
root: true,
|
||||||
plugins: ["stylelint-order"],
|
plugins: ["stylelint-order"],
|
||||||
|
customSyntax: "postcss-html",
|
||||||
extends: ["stylelint-config-standard", "stylelint-config-prettier"],
|
extends: ["stylelint-config-standard", "stylelint-config-prettier"],
|
||||||
rules: {
|
rules: {
|
||||||
|
"selector-class-pattern": null,
|
||||||
"selector-pseudo-class-no-unknown": [
|
"selector-pseudo-class-no-unknown": [
|
||||||
true,
|
true,
|
||||||
{
|
{
|
||||||
ignorePseudoClasses: ["deep"]
|
ignorePseudoClasses: ["global"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"selector-pseudo-element-no-unknown": [
|
"selector-pseudo-element-no-unknown": [
|
||||||
true,
|
true,
|
||||||
{
|
{
|
||||||
ignorePseudoElements: ["v-deep", ":deep"]
|
ignorePseudoElements: ["v-deep"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"at-rule-no-unknown": [
|
"at-rule-no-unknown": [
|
||||||
@@ -65,5 +67,26 @@ module.exports = {
|
|||||||
{ severity: "warning" }
|
{ severity: "warning" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
ignoreFiles: ["**/*.js", "**/*.jsx", "**/*.tsx", "**/*.ts", "**/*.json"]
|
ignoreFiles: ["**/*.js", "**/*.jsx", "**/*.tsx", "**/*.ts", "**/*.json"],
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ["*.vue", "**/*.vue", "*.html", "**/*.html"],
|
||||||
|
extends: ["stylelint-config-recommended", "stylelint-config-html"],
|
||||||
|
rules: {
|
||||||
|
"keyframes-name-pattern": null,
|
||||||
|
"selector-pseudo-class-no-unknown": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
ignorePseudoClasses: ["deep", "global"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"selector-pseudo-element-no-unknown": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
ignorePseudoElements: ["v-deep", "v-global", "v-slotted"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
9
types/global.d.ts
vendored
9
types/global.d.ts
vendored
@@ -16,6 +16,15 @@ declare module "vue" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
const __APP_INFO__: {
|
||||||
|
pkg: {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
dependencies: Recordable<string>;
|
||||||
|
devDependencies: Recordable<string>;
|
||||||
|
};
|
||||||
|
lastBuildTime: string;
|
||||||
|
};
|
||||||
interface Window {
|
interface Window {
|
||||||
// Global vue app instance
|
// Global vue app instance
|
||||||
__APP__: App<Element>;
|
__APP__: App<Element>;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import dayjs from "dayjs";
|
||||||
import { resolve } from "path";
|
import { resolve } from "path";
|
||||||
|
import pkg from "./package.json";
|
||||||
import { warpperEnv, regExps } from "./build";
|
import { warpperEnv, regExps } from "./build";
|
||||||
import { getPluginsList } from "./build/plugins";
|
import { getPluginsList } from "./build/plugins";
|
||||||
import { UserConfigExport, ConfigEnv, loadEnv } from "vite";
|
import { UserConfigExport, ConfigEnv, loadEnv } from "vite";
|
||||||
@@ -19,6 +21,12 @@ const alias: Record<string, string> = {
|
|||||||
"vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js"
|
"vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { dependencies, devDependencies, name, version } = pkg;
|
||||||
|
const __APP_INFO__ = {
|
||||||
|
pkg: { dependencies, devDependencies, name, version },
|
||||||
|
lastBuildTime: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
};
|
||||||
|
|
||||||
export default ({ command, mode }: ConfigEnv): UserConfigExport => {
|
export default ({ command, mode }: ConfigEnv): UserConfigExport => {
|
||||||
const {
|
const {
|
||||||
VITE_PORT,
|
VITE_PORT,
|
||||||
@@ -90,7 +98,8 @@ export default ({ command, mode }: ConfigEnv): UserConfigExport => {
|
|||||||
chunkSizeWarningLimit: 2000
|
chunkSizeWarningLimit: 2000
|
||||||
},
|
},
|
||||||
define: {
|
define: {
|
||||||
__INTLIFY_PROD_DEVTOOLS__: false
|
__INTLIFY_PROD_DEVTOOLS__: false,
|
||||||
|
__APP_INFO__: JSON.stringify(__APP_INFO__)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user