release: update 5.1.0
4
.browserslistrc
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
> 1%
|
||||||
|
last 2 versions
|
||||||
|
not dead
|
||||||
|
not ie 11
|
@ -2,7 +2,7 @@
|
|||||||
VITE_PORT = 8848
|
VITE_PORT = 8848
|
||||||
|
|
||||||
# 开发环境读取配置文件路径
|
# 开发环境读取配置文件路径
|
||||||
VITE_PUBLIC_PATH = ./
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
# 开发环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
# 开发环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
VITE_ROUTER_HISTORY = "hash"
|
VITE_ROUTER_HISTORY = "hash"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# 线上环境平台打包路径
|
# 线上环境平台打包路径
|
||||||
VITE_PUBLIC_PATH = ./
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
# 线上环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
# 线上环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
VITE_ROUTER_HISTORY = "hash"
|
VITE_ROUTER_HISTORY = "hash"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# https://cn.vitejs.dev/guide/env-and-mode.html#modes
|
# https://cn.vitejs.dev/guide/env-and-mode.html#modes
|
||||||
# NODE_ENV = development
|
# NODE_ENV = development
|
||||||
|
|
||||||
VITE_PUBLIC_PATH = ./
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
# 预发布环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
# 预发布环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
VITE_ROUTER_HISTORY = "hash"
|
VITE_ROUTER_HISTORY = "hash"
|
||||||
|
@ -3,9 +3,9 @@ dist
|
|||||||
*.d.ts
|
*.d.ts
|
||||||
/src/assets
|
/src/assets
|
||||||
package.json
|
package.json
|
||||||
.eslintrc.js
|
eslint.config.js
|
||||||
.prettierrc.js
|
.prettierrc.js
|
||||||
commitlint.config.js
|
commitlint.config.js
|
||||||
postcss.config.js
|
postcss.config.js
|
||||||
tailwind.config.js
|
tailwind.config.ts
|
||||||
stylelint.config.js
|
stylelint.config.js
|
1
.gitignore
vendored
@ -5,6 +5,7 @@ dist-ssr
|
|||||||
*.local
|
*.local
|
||||||
.eslintcache
|
.eslintcache
|
||||||
report.html
|
report.html
|
||||||
|
vite.config.*.timestamp*
|
||||||
|
|
||||||
yarn.lock
|
yarn.lock
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
|
@ -3,4 +3,6 @@
|
|||||||
# shellcheck source=./_/husky.sh
|
# shellcheck source=./_/husky.sh
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
npx --no-install commitlint --edit "$1"
|
PATH="/usr/local/bin:$PATH"
|
||||||
|
|
||||||
|
npx --no-install commitlint --edit "$1"
|
@ -1,8 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
"*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"],
|
|
||||||
"{!(package)*.json}": ["prettier --write--parser json"],
|
|
||||||
"package.json": ["prettier --write"],
|
|
||||||
"*.vue": ["eslint --fix", "prettier --write", "stylelint --fix"],
|
|
||||||
"*.{vue,css,scss,postcss,less}": ["stylelint --fix", "prettier --write"],
|
|
||||||
"*.md": ["prettier --write"]
|
|
||||||
};
|
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
[ -n "$CI" ] && exit 0
|
[ -n "$CI" ] && exit 0
|
||||||
|
|
||||||
# Format and submit code according to lintstagedrc.js configuration
|
PATH="/usr/local/bin:$PATH"
|
||||||
npm run lint:lint-staged
|
|
||||||
|
|
||||||
npm run lint:pretty
|
# Perform lint check on files in the staging area through .lintstagedrc configuration
|
||||||
|
pnpm exec lint-staged
|
16
.lintstagedrc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"*.{js,jsx,ts,tsx}": [
|
||||||
|
"prettier --cache --ignore-unknown --write",
|
||||||
|
"eslint --cache --fix"
|
||||||
|
],
|
||||||
|
"{!(package)*.json,*.code-snippets,.!({browserslist,nvm})*rc}": [
|
||||||
|
"prettier --cache --write--parser json"
|
||||||
|
],
|
||||||
|
"package.json": ["prettier --cache --write"],
|
||||||
|
"*.vue": ["prettier --write", "eslint --cache --fix", "stylelint --fix"],
|
||||||
|
"*.{css,scss,html}": [
|
||||||
|
"prettier --cache --ignore-unknown --write",
|
||||||
|
"stylelint --fix"
|
||||||
|
],
|
||||||
|
"*.md": ["prettier --cache --ignore-unknown --write"]
|
||||||
|
}
|
@ -1,4 +1,7 @@
|
|||||||
module.exports = {
|
// @ts-check
|
||||||
|
|
||||||
|
/** @type {import("prettier").Config} */
|
||||||
|
export default {
|
||||||
bracketSpacing: true,
|
bracketSpacing: true,
|
||||||
singleQuote: false,
|
singleQuote: false,
|
||||||
arrowParens: "avoid",
|
arrowParens: "avoid",
|
||||||
|
2
.vscode/settings.json
vendored
@ -25,7 +25,7 @@
|
|||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
},
|
},
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true
|
"source.fixAll.eslint": "explicit"
|
||||||
},
|
},
|
||||||
"iconify.excludes": ["el"]
|
"iconify.excludes": ["el"]
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
FROM node:16-alpine as build-stage
|
FROM node:18-alpine as build-stage
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN corepack enable
|
RUN corepack enable
|
||||||
RUN corepack prepare pnpm@7.32.1 --activate
|
RUN corepack prepare pnpm@8.6.10 --activate
|
||||||
|
|
||||||
RUN npm config set registry https://registry.npmmirror.com
|
RUN npm config set registry https://registry.npmmirror.com
|
||||||
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
/** 处理环境变量 */
|
|
||||||
const warpperEnv = (envConf: Recordable): ViteEnv => {
|
|
||||||
/** 此处为默认值 */
|
|
||||||
const ret: ViteEnv = {
|
|
||||||
VITE_PORT: 8848,
|
|
||||||
VITE_PUBLIC_PATH: "",
|
|
||||||
VITE_ROUTER_HISTORY: "",
|
|
||||||
VITE_CDN: false,
|
|
||||||
VITE_HIDE_HOME: "false",
|
|
||||||
VITE_COMPRESSION: "none"
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const envName of Object.keys(envConf)) {
|
|
||||||
let realName = envConf[envName].replace(/\\n/g, "\n");
|
|
||||||
realName =
|
|
||||||
realName === "true" ? true : realName === "false" ? false : realName;
|
|
||||||
|
|
||||||
if (envName === "VITE_PORT") {
|
|
||||||
realName = Number(realName);
|
|
||||||
}
|
|
||||||
ret[envName] = realName;
|
|
||||||
if (typeof realName === "string") {
|
|
||||||
process.env[envName] = realName;
|
|
||||||
} else if (typeof realName === "object") {
|
|
||||||
process.env[envName] = JSON.stringify(realName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
export { warpperEnv };
|
|
@ -1,10 +1,21 @@
|
|||||||
import type { Plugin } from "vite";
|
import type { Plugin } from "vite";
|
||||||
import dayjs, { Dayjs } from "dayjs";
|
import { getPackageSize } from "./utils";
|
||||||
import utils from "@pureadmin/utils";
|
import dayjs, { type Dayjs } from "dayjs";
|
||||||
import duration from "dayjs/plugin/duration";
|
import duration from "dayjs/plugin/duration";
|
||||||
import { green, blue, bold } from "picocolors";
|
import gradientString from "gradient-string";
|
||||||
|
import boxen, { type Options as BoxenOptions } from "boxen";
|
||||||
dayjs.extend(duration);
|
dayjs.extend(duration);
|
||||||
|
|
||||||
|
const welcomeMessage = gradientString("cyan", "magenta").multiline(
|
||||||
|
`Hello! 欢迎使用 vue-pure-admin\n我们为您精心准备了下面两个贴心的保姆级文档\nhttps://yiming_chang.gitee.io/pure-admin-doc\nhttps://pure-admin-utils.netlify.app`
|
||||||
|
);
|
||||||
|
|
||||||
|
const boxenOptions: BoxenOptions = {
|
||||||
|
padding: 0.5,
|
||||||
|
borderColor: "cyan",
|
||||||
|
borderStyle: "round"
|
||||||
|
};
|
||||||
|
|
||||||
export function viteBuildInfo(): Plugin {
|
export function viteBuildInfo(): Plugin {
|
||||||
let config: { command: string };
|
let config: { command: string };
|
||||||
let startTime: Dayjs;
|
let startTime: Dayjs;
|
||||||
@ -17,15 +28,7 @@ export function viteBuildInfo(): Plugin {
|
|||||||
outDir = resolvedConfig.build?.outDir ?? "dist";
|
outDir = resolvedConfig.build?.outDir ?? "dist";
|
||||||
},
|
},
|
||||||
buildStart() {
|
buildStart() {
|
||||||
console.log(
|
console.log(boxen(welcomeMessage, boxenOptions));
|
||||||
bold(
|
|
||||||
green(
|
|
||||||
`👏欢迎使用${blue(
|
|
||||||
"[vue-pure-admin]"
|
|
||||||
)},如果您感觉不错,记得点击后面链接给个star哦💖 https://github.com/pure-admin/vue-pure-admin`
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if (config.command === "build") {
|
if (config.command === "build") {
|
||||||
startTime = dayjs(new Date());
|
startTime = dayjs(new Date());
|
||||||
}
|
}
|
||||||
@ -33,16 +36,17 @@ export function viteBuildInfo(): Plugin {
|
|||||||
closeBundle() {
|
closeBundle() {
|
||||||
if (config.command === "build") {
|
if (config.command === "build") {
|
||||||
endTime = dayjs(new Date());
|
endTime = dayjs(new Date());
|
||||||
utils.getPackageSize({
|
getPackageSize({
|
||||||
folder: outDir,
|
folder: outDir,
|
||||||
callback: (size: string) => {
|
callback: (size: string) => {
|
||||||
console.log(
|
console.log(
|
||||||
bold(
|
boxen(
|
||||||
green(
|
gradientString("cyan", "magenta").multiline(
|
||||||
`🎉恭喜打包完成(总用时${dayjs
|
`🎉 恭喜打包完成(总用时${dayjs
|
||||||
.duration(endTime.diff(startTime))
|
.duration(endTime.diff(startTime))
|
||||||
.format("mm分ss秒")},打包后的大小为${size})`
|
.format("mm分ss秒")},打包后的大小为${size})`
|
||||||
)
|
),
|
||||||
|
boxenOptions
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,11 @@ const include = [
|
|||||||
"dayjs",
|
"dayjs",
|
||||||
"axios",
|
"axios",
|
||||||
"pinia",
|
"pinia",
|
||||||
|
"vue-types",
|
||||||
"js-cookie",
|
"js-cookie",
|
||||||
"sortablejs",
|
"vue-tippy",
|
||||||
"pinyin-pro",
|
"pinyin-pro",
|
||||||
|
"sortablejs",
|
||||||
"@vueuse/core",
|
"@vueuse/core",
|
||||||
"@pureadmin/utils",
|
"@pureadmin/utils",
|
||||||
"responsive-storage"
|
"responsive-storage"
|
||||||
|
@ -2,31 +2,39 @@ import { cdn } from "./cdn";
|
|||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import { viteBuildInfo } from "./info";
|
import { viteBuildInfo } from "./info";
|
||||||
import svgLoader from "vite-svg-loader";
|
import svgLoader from "vite-svg-loader";
|
||||||
|
import type { PluginOption } from "vite";
|
||||||
import vueJsx from "@vitejs/plugin-vue-jsx";
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||||
import { viteMockServe } from "vite-plugin-mock";
|
|
||||||
import { configCompressPlugin } from "./compress";
|
import { configCompressPlugin } from "./compress";
|
||||||
// import ElementPlus from "unplugin-element-plus/vite";
|
import removeNoMatch from "vite-plugin-router-warn";
|
||||||
import { visualizer } from "rollup-plugin-visualizer";
|
import { visualizer } from "rollup-plugin-visualizer";
|
||||||
import removeConsole from "vite-plugin-remove-console";
|
import removeConsole from "vite-plugin-remove-console";
|
||||||
import themePreprocessorPlugin from "@pureadmin/theme";
|
import { themePreprocessorPlugin } from "@pureadmin/theme";
|
||||||
import { genScssMultipleScopeVars } from "../src/layout/theme";
|
import { genScssMultipleScopeVars } from "../src/layout/theme";
|
||||||
|
import { vitePluginFakeServer } from "vite-plugin-fake-server";
|
||||||
|
|
||||||
export function getPluginsList(
|
export function getPluginsList(
|
||||||
command: string,
|
|
||||||
VITE_CDN: boolean,
|
VITE_CDN: boolean,
|
||||||
VITE_COMPRESSION: ViteCompression
|
VITE_COMPRESSION: ViteCompression
|
||||||
) {
|
): PluginOption[] {
|
||||||
const prodMock = true;
|
|
||||||
const lifecycle = process.env.npm_lifecycle_event;
|
const lifecycle = process.env.npm_lifecycle_event;
|
||||||
return [
|
return [
|
||||||
vue(),
|
vue(),
|
||||||
// jsx、tsx语法支持
|
// jsx、tsx语法支持
|
||||||
vueJsx(),
|
vueJsx(),
|
||||||
VITE_CDN ? cdn : null,
|
|
||||||
configCompressPlugin(VITE_COMPRESSION),
|
|
||||||
// 线上环境删除console
|
|
||||||
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),
|
|
||||||
viteBuildInfo(),
|
viteBuildInfo(),
|
||||||
|
/**
|
||||||
|
* 开发环境下移除非必要的vue-router动态路由警告No match found for location with path
|
||||||
|
* 非必要具体看 https://github.com/vuejs/router/issues/521 和 https://github.com/vuejs/router/issues/359
|
||||||
|
* vite-plugin-router-warn只在开发环境下启用,只处理vue-router文件并且只在服务启动或重启时运行一次,性能消耗可忽略不计
|
||||||
|
*/
|
||||||
|
removeNoMatch(),
|
||||||
|
// mock支持
|
||||||
|
vitePluginFakeServer({
|
||||||
|
logger: false,
|
||||||
|
include: "mock",
|
||||||
|
infixName: false,
|
||||||
|
enableProd: true
|
||||||
|
}),
|
||||||
// 自定义主题
|
// 自定义主题
|
||||||
themePreprocessorPlugin({
|
themePreprocessorPlugin({
|
||||||
scss: {
|
scss: {
|
||||||
@ -36,21 +44,13 @@ export function getPluginsList(
|
|||||||
}),
|
}),
|
||||||
// svg组件化支持
|
// svg组件化支持
|
||||||
svgLoader(),
|
svgLoader(),
|
||||||
// ElementPlus({}),
|
VITE_CDN ? cdn : null,
|
||||||
// mock支持
|
configCompressPlugin(VITE_COMPRESSION),
|
||||||
viteMockServe({
|
// 线上环境删除console
|
||||||
mockPath: "mock",
|
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),
|
||||||
localEnabled: command === "serve",
|
|
||||||
prodEnabled: command !== "serve" && prodMock,
|
|
||||||
injectCode: `
|
|
||||||
import { setupProdMockServer } from './mockProdServer';
|
|
||||||
setupProdMockServer();
|
|
||||||
`,
|
|
||||||
logger: false
|
|
||||||
}),
|
|
||||||
// 打包分析
|
// 打包分析
|
||||||
lifecycle === "report"
|
lifecycle === "report"
|
||||||
? visualizer({ open: true, brotliSize: true, filename: "report.html" })
|
? visualizer({ open: true, brotliSize: true, filename: "report.html" })
|
||||||
: null
|
: (null as any)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
110
build/utils.ts
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
import dayjs from "dayjs";
|
||||||
|
import { readdir, stat } from "node:fs";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { dirname, resolve } from "node:path";
|
||||||
|
import { sum, formatBytes } from "@pureadmin/utils";
|
||||||
|
import {
|
||||||
|
name,
|
||||||
|
version,
|
||||||
|
engines,
|
||||||
|
dependencies,
|
||||||
|
devDependencies
|
||||||
|
} from "../package.json";
|
||||||
|
|
||||||
|
/** 启动`node`进程时所在工作目录的绝对路径 */
|
||||||
|
const root: string = process.cwd();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 根据可选的路径片段生成一个新的绝对路径
|
||||||
|
* @param dir 路径片段,默认`build`
|
||||||
|
* @param metaUrl 模块的完整`url`,如果在`build`目录外调用必传`import.meta.url`
|
||||||
|
*/
|
||||||
|
const pathResolve = (dir = ".", metaUrl = import.meta.url) => {
|
||||||
|
// 当前文件目录的绝对路径
|
||||||
|
const currentFileDir = dirname(fileURLToPath(metaUrl));
|
||||||
|
// build 目录的绝对路径
|
||||||
|
const buildDir = resolve(currentFileDir, "build");
|
||||||
|
// 解析的绝对路径
|
||||||
|
const resolvedPath = resolve(currentFileDir, dir);
|
||||||
|
// 检查解析的绝对路径是否在 build 目录内
|
||||||
|
if (resolvedPath.startsWith(buildDir)) {
|
||||||
|
// 在 build 目录内,返回当前文件路径
|
||||||
|
return fileURLToPath(metaUrl);
|
||||||
|
}
|
||||||
|
// 不在 build 目录内,返回解析后的绝对路径
|
||||||
|
return resolvedPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 设置别名 */
|
||||||
|
const alias: Record<string, string> = {
|
||||||
|
"@": pathResolve("../src"),
|
||||||
|
"@build": pathResolve()
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 平台的名称、版本、运行所需的`node`和`pnpm`版本、依赖、最后构建时间的类型提示 */
|
||||||
|
const __APP_INFO__ = {
|
||||||
|
pkg: { name, version, engines, dependencies, devDependencies },
|
||||||
|
lastBuildTime: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss")
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 处理环境变量 */
|
||||||
|
const warpperEnv = (envConf: Recordable): ViteEnv => {
|
||||||
|
// 默认值
|
||||||
|
const ret: ViteEnv = {
|
||||||
|
VITE_PORT: 8848,
|
||||||
|
VITE_PUBLIC_PATH: "",
|
||||||
|
VITE_ROUTER_HISTORY: "",
|
||||||
|
VITE_CDN: false,
|
||||||
|
VITE_HIDE_HOME: "false",
|
||||||
|
VITE_COMPRESSION: "none"
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const envName of Object.keys(envConf)) {
|
||||||
|
let realName = envConf[envName].replace(/\\n/g, "\n");
|
||||||
|
realName =
|
||||||
|
realName === "true" ? true : realName === "false" ? false : realName;
|
||||||
|
|
||||||
|
if (envName === "VITE_PORT") {
|
||||||
|
realName = Number(realName);
|
||||||
|
}
|
||||||
|
ret[envName] = realName;
|
||||||
|
if (typeof realName === "string") {
|
||||||
|
process.env[envName] = realName;
|
||||||
|
} else if (typeof realName === "object") {
|
||||||
|
process.env[envName] = JSON.stringify(realName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
const fileListTotal: number[] = [];
|
||||||
|
|
||||||
|
/** 获取指定文件夹中所有文件的总大小 */
|
||||||
|
const getPackageSize = options => {
|
||||||
|
const { folder = "dist", callback, format = true } = options;
|
||||||
|
readdir(folder, (err, files: string[]) => {
|
||||||
|
if (err) throw err;
|
||||||
|
let count = 0;
|
||||||
|
const checkEnd = () => {
|
||||||
|
++count == files.length &&
|
||||||
|
callback(format ? formatBytes(sum(fileListTotal)) : sum(fileListTotal));
|
||||||
|
};
|
||||||
|
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()) {
|
||||||
|
getPackageSize({
|
||||||
|
folder: `${folder}/${item}/`,
|
||||||
|
callback: checkEnd
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
files.length === 0 && callback(0);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export { root, pathResolve, alias, __APP_INFO__, warpperEnv, getPackageSize };
|
@ -1,4 +1,7 @@
|
|||||||
module.exports = {
|
// @ts-check
|
||||||
|
|
||||||
|
/** @type {import("@commitlint/types").UserConfig} */
|
||||||
|
export default {
|
||||||
ignores: [commit => commit.includes("init")],
|
ignores: [commit => commit.includes("init")],
|
||||||
extends: ["@commitlint/config-conventional"],
|
extends: ["@commitlint/config-conventional"],
|
||||||
rules: {
|
rules: {
|
||||||
|
174
eslint.config.js
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
import js from "@eslint/js";
|
||||||
|
import pluginVue from "eslint-plugin-vue";
|
||||||
|
import * as parserVue from "vue-eslint-parser";
|
||||||
|
import configPrettier from "eslint-config-prettier";
|
||||||
|
import pluginPrettier from "eslint-plugin-prettier";
|
||||||
|
import { defineFlatConfig } from "eslint-define-config";
|
||||||
|
import * as parserTypeScript from "@typescript-eslint/parser";
|
||||||
|
import pluginTypeScript from "@typescript-eslint/eslint-plugin";
|
||||||
|
|
||||||
|
export default defineFlatConfig([
|
||||||
|
{
|
||||||
|
...js.configs.recommended,
|
||||||
|
ignores: ["src/assets/**", "src/**/iconfont/**"],
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
// index.d.ts
|
||||||
|
RefType: "readonly",
|
||||||
|
EmitType: "readonly",
|
||||||
|
TargetContext: "readonly",
|
||||||
|
ComponentRef: "readonly",
|
||||||
|
ElRef: "readonly",
|
||||||
|
ForDataType: "readonly",
|
||||||
|
AnyFunction: "readonly",
|
||||||
|
PropType: "readonly",
|
||||||
|
Writable: "readonly",
|
||||||
|
Nullable: "readonly",
|
||||||
|
NonNullable: "readonly",
|
||||||
|
Recordable: "readonly",
|
||||||
|
ReadonlyRecordable: "readonly",
|
||||||
|
Indexable: "readonly",
|
||||||
|
DeepPartial: "readonly",
|
||||||
|
Without: "readonly",
|
||||||
|
Exclusive: "readonly",
|
||||||
|
TimeoutHandle: "readonly",
|
||||||
|
IntervalHandle: "readonly",
|
||||||
|
Effect: "readonly",
|
||||||
|
ChangeEvent: "readonly",
|
||||||
|
WheelEvent: "readonly",
|
||||||
|
ImportMetaEnv: "readonly",
|
||||||
|
Fn: "readonly",
|
||||||
|
PromiseFn: "readonly",
|
||||||
|
ComponentElRef: "readonly",
|
||||||
|
parseInt: "readonly",
|
||||||
|
parseFloat: "readonly"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
prettier: pluginPrettier
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...configPrettier.rules,
|
||||||
|
...pluginPrettier.configs.recommended.rules,
|
||||||
|
"no-debugger": "off",
|
||||||
|
"no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
argsIgnorePattern: "^_",
|
||||||
|
varsIgnorePattern: "^_"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"prettier/prettier": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
endOfLine: "auto"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/*.?([cm])ts", "**/*.?([cm])tsx"],
|
||||||
|
languageOptions: {
|
||||||
|
parser: parserTypeScript,
|
||||||
|
parserOptions: {
|
||||||
|
sourceType: "module"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
"@typescript-eslint": pluginTypeScript
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...pluginTypeScript.configs.strict.rules,
|
||||||
|
"@typescript-eslint/ban-types": "off",
|
||||||
|
"@typescript-eslint/no-redeclare": "error",
|
||||||
|
"@typescript-eslint/ban-ts-comment": "off",
|
||||||
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"@typescript-eslint/prefer-as-const": "warn",
|
||||||
|
"@typescript-eslint/no-empty-function": "off",
|
||||||
|
"@typescript-eslint/no-non-null-assertion": "off",
|
||||||
|
"@typescript-eslint/no-import-type-side-effects": "error",
|
||||||
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||||
|
"@typescript-eslint/consistent-type-imports": [
|
||||||
|
"error",
|
||||||
|
{ disallowTypeAnnotations: false, fixStyle: "inline-type-imports" }
|
||||||
|
],
|
||||||
|
"@typescript-eslint/prefer-literal-enum-member": [
|
||||||
|
"error",
|
||||||
|
{ allowBitwiseExpressions: true }
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
argsIgnorePattern: "^_",
|
||||||
|
varsIgnorePattern: "^_"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/*.d.ts"],
|
||||||
|
rules: {
|
||||||
|
"eslint-comments/no-unlimited-disable": "off",
|
||||||
|
"import/no-duplicates": "off",
|
||||||
|
"unused-imports/no-unused-vars": "off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/*.?([cm])js"],
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-require-imports": "off",
|
||||||
|
"@typescript-eslint/no-var-requires": "off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/*.vue"],
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
$: "readonly",
|
||||||
|
$$: "readonly",
|
||||||
|
$computed: "readonly",
|
||||||
|
$customRef: "readonly",
|
||||||
|
$ref: "readonly",
|
||||||
|
$shallowRef: "readonly",
|
||||||
|
$toRef: "readonly"
|
||||||
|
},
|
||||||
|
parser: parserVue,
|
||||||
|
parserOptions: {
|
||||||
|
ecmaFeatures: {
|
||||||
|
jsx: true
|
||||||
|
},
|
||||||
|
extraFileExtensions: [".vue"],
|
||||||
|
parser: "@typescript-eslint/parser",
|
||||||
|
sourceType: "module"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
vue: pluginVue
|
||||||
|
},
|
||||||
|
processor: pluginVue.processors[".vue"],
|
||||||
|
rules: {
|
||||||
|
...pluginVue.configs.base.rules,
|
||||||
|
...pluginVue.configs["vue3-essential"].rules,
|
||||||
|
...pluginVue.configs["vue3-recommended"].rules,
|
||||||
|
"no-undef": "off",
|
||||||
|
"no-unused-vars": "off",
|
||||||
|
"vue/no-v-html": "off",
|
||||||
|
"vue/require-default-prop": "off",
|
||||||
|
"vue/require-explicit-emits": "off",
|
||||||
|
"vue/multi-word-component-names": "off",
|
||||||
|
"vue/no-setup-props-reactivity-loss": "off",
|
||||||
|
"vue/html-self-closing": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
html: {
|
||||||
|
void: "always",
|
||||||
|
normal: "always",
|
||||||
|
component: "always"
|
||||||
|
},
|
||||||
|
svg: "always",
|
||||||
|
math: "always"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
@ -1,5 +1,5 @@
|
|||||||
// 模拟后端动态生成路由
|
// 模拟后端动态生成路由
|
||||||
import { MockMethod } from "vite-plugin-mock";
|
import { defineFakeRoute } from "vite-plugin-fake-server/client";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* roles:页面级别权限,这里模拟二种 "admin"、"common"
|
* roles:页面级别权限,这里模拟二种 "admin"、"common"
|
||||||
@ -11,7 +11,7 @@ const permissionRouter = {
|
|||||||
path: "/permission",
|
path: "/permission",
|
||||||
meta: {
|
meta: {
|
||||||
title: "权限管理",
|
title: "权限管理",
|
||||||
icon: "lollipop",
|
icon: "ep:lollipop",
|
||||||
rank: 10
|
rank: 10
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
@ -29,15 +29,19 @@ const permissionRouter = {
|
|||||||
meta: {
|
meta: {
|
||||||
title: "按钮权限",
|
title: "按钮权限",
|
||||||
roles: ["admin", "common"],
|
roles: ["admin", "common"],
|
||||||
auths: ["btn_add", "btn_edit", "btn_delete"]
|
auths: [
|
||||||
|
"permission:btn:add",
|
||||||
|
"permission:btn:edit",
|
||||||
|
"permission:btn:delete"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export default [
|
export default defineFakeRoute([
|
||||||
{
|
{
|
||||||
url: "/getAsyncRoutes",
|
url: "/get-async-routes",
|
||||||
method: "get",
|
method: "get",
|
||||||
response: () => {
|
response: () => {
|
||||||
return {
|
return {
|
||||||
@ -46,4 +50,4 @@ export default [
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
] as MockMethod[];
|
]);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// 根据角色动态生成路由
|
// 根据角色动态生成路由
|
||||||
import { MockMethod } from "vite-plugin-mock";
|
import { defineFakeRoute } from "vite-plugin-fake-server/client";
|
||||||
|
|
||||||
export default [
|
export default defineFakeRoute([
|
||||||
{
|
{
|
||||||
url: "/login",
|
url: "/login",
|
||||||
method: "post",
|
method: "post",
|
||||||
@ -15,7 +15,7 @@ export default [
|
|||||||
roles: ["admin"],
|
roles: ["admin"],
|
||||||
accessToken: "eyJhbGciOiJIUzUxMiJ9.admin",
|
accessToken: "eyJhbGciOiJIUzUxMiJ9.admin",
|
||||||
refreshToken: "eyJhbGciOiJIUzUxMiJ9.adminRefresh",
|
refreshToken: "eyJhbGciOiJIUzUxMiJ9.adminRefresh",
|
||||||
expires: "2023/10/30 00:00:00"
|
expires: "2030/10/30 00:00:00"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@ -27,10 +27,10 @@ export default [
|
|||||||
roles: ["common"],
|
roles: ["common"],
|
||||||
accessToken: "eyJhbGciOiJIUzUxMiJ9.common",
|
accessToken: "eyJhbGciOiJIUzUxMiJ9.common",
|
||||||
refreshToken: "eyJhbGciOiJIUzUxMiJ9.commonRefresh",
|
refreshToken: "eyJhbGciOiJIUzUxMiJ9.commonRefresh",
|
||||||
expires: "2023/10/30 00:00:00"
|
expires: "2030/10/30 00:00:00"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
] as MockMethod[];
|
]);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { MockMethod } from "vite-plugin-mock";
|
import { defineFakeRoute } from "vite-plugin-fake-server/client";
|
||||||
|
|
||||||
// 模拟刷新token接口
|
// 模拟刷新token接口
|
||||||
export default [
|
export default defineFakeRoute([
|
||||||
{
|
{
|
||||||
url: "/refreshToken",
|
url: "/refresh-token",
|
||||||
method: "post",
|
method: "post",
|
||||||
response: ({ body }) => {
|
response: ({ body }) => {
|
||||||
if (body.refreshToken) {
|
if (body.refreshToken) {
|
||||||
@ -13,7 +13,7 @@ export default [
|
|||||||
accessToken: "eyJhbGciOiJIUzUxMiJ9.newAdmin",
|
accessToken: "eyJhbGciOiJIUzUxMiJ9.newAdmin",
|
||||||
refreshToken: "eyJhbGciOiJIUzUxMiJ9.newAdminRefresh",
|
refreshToken: "eyJhbGciOiJIUzUxMiJ9.newAdminRefresh",
|
||||||
// `expires`选择这种日期格式是为了方便调试,后端直接设置时间戳或许更方便(每次都应该递增)。如果后端返回的是时间戳格式,前端开发请来到这个目录`src/utils/auth.ts`,把第`38`行的代码换成expires = data.expires即可。
|
// `expires`选择这种日期格式是为了方便调试,后端直接设置时间戳或许更方便(每次都应该递增)。如果后端返回的是时间戳格式,前端开发请来到这个目录`src/utils/auth.ts`,把第`38`行的代码换成expires = data.expires即可。
|
||||||
expires: "2023/10/30 23:59:59"
|
expires: "2030/10/30 23:59:59"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@ -24,4 +24,4 @@ export default [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
] as MockMethod[];
|
]);
|
||||||
|
206
package.json
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "pure-admin-thin",
|
"name": "pure-admin-thin",
|
||||||
"version": "4.5.0",
|
"version": "5.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "NODE_OPTIONS=--max-old-space-size=4096 vite",
|
"dev": "NODE_OPTIONS=--max-old-space-size=4096 vite",
|
||||||
"serve": "pnpm dev",
|
"serve": "pnpm dev",
|
||||||
@ -11,125 +12,140 @@
|
|||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"preview:build": "pnpm build && vite preview",
|
"preview:build": "pnpm build && vite preview",
|
||||||
"typecheck": "tsc --noEmit && vue-tsc --noEmit --skipLibCheck",
|
"typecheck": "tsc --noEmit && vue-tsc --noEmit --skipLibCheck",
|
||||||
"svgo": "svgo -f src/assets/svg -o src/assets/svg",
|
"svgo": "svgo -f . -r",
|
||||||
"cloc": "NODE_OPTIONS=--max-old-space-size=4096 cloc . --exclude-dir=node_modules --exclude-lang=YAML",
|
"cloc": "NODE_OPTIONS=--max-old-space-size=4096 cloc . --exclude-dir=node_modules --exclude-lang=YAML",
|
||||||
"clean:cache": "rimraf node_modules && rimraf .eslintcache && pnpm install",
|
"clean:cache": "rimraf .eslintcache && rimraf pnpm-lock.yaml && rimraf node_modules && pnpm store prune && pnpm install",
|
||||||
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock,build}/**/*.{vue,js,ts,tsx}\" --fix",
|
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock,build}/**/*.{vue,js,ts,tsx}\" --fix",
|
||||||
"lint:prettier": "prettier --write \"src/**/*.{js,ts,json,tsx,css,scss,vue,html,md}\"",
|
"lint:prettier": "prettier --write \"src/**/*.{js,ts,json,tsx,css,scss,vue,html,md}\"",
|
||||||
"lint:stylelint": "stylelint \"**/*.{html,vue,css,scss}\" --fix --cache --cache-location node_modules/.cache/stylelint/",
|
"lint:stylelint": "stylelint --cache --fix \"**/*.{html,vue,css,scss}\" --cache-location node_modules/.cache/stylelint/",
|
||||||
"lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
|
|
||||||
"lint:pretty": "pretty-quick --staged",
|
|
||||||
"lint": "pnpm lint:eslint && pnpm lint:prettier && pnpm lint:stylelint",
|
"lint": "pnpm lint:eslint && pnpm lint:prettier && pnpm lint:stylelint",
|
||||||
"prepare": "husky install",
|
"prepare": "husky",
|
||||||
"preinstall": "npx only-allow pnpm"
|
"preinstall": "npx only-allow pnpm"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"keywords": [
|
||||||
"> 1%",
|
"vue-pure-admin",
|
||||||
"not ie 11",
|
"element-plus",
|
||||||
"not op_mini all"
|
"tailwindcss",
|
||||||
|
"pure-admin",
|
||||||
|
"typescript",
|
||||||
|
"pinia",
|
||||||
|
"vue3",
|
||||||
|
"vite",
|
||||||
|
"esm"
|
||||||
],
|
],
|
||||||
|
"homepage": "https://github.com/pure-admin/pure-admin-thin",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/pure-admin/pure-admin-thin.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/pure-admin/pure-admin-thin/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"author": {
|
||||||
|
"name": "xiaoxian521",
|
||||||
|
"email": "pureadmin@163.com",
|
||||||
|
"url": "https://github.com/xiaoxian521"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pureadmin/descriptions": "^1.1.1",
|
"@pureadmin/descriptions": "^1.2.0",
|
||||||
"@pureadmin/table": "^2.3.2",
|
"@pureadmin/table": "^3.1.2",
|
||||||
"@pureadmin/utils": "^1.9.6",
|
"@pureadmin/utils": "^2.4.5",
|
||||||
"@vueuse/core": "^10.2.0",
|
"@vueuse/core": "^10.9.0",
|
||||||
"@vueuse/motion": "^2.0.0",
|
"@vueuse/motion": "^2.1.0",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.6.7",
|
||||||
"dayjs": "^1.11.8",
|
"dayjs": "^1.11.10",
|
||||||
"echarts": "^5.4.2",
|
"echarts": "^5.5.0",
|
||||||
"element-plus": "2.3.6",
|
"element-plus": "^2.6.0",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"mitt": "^3.0.0",
|
"localforage": "^1.10.0",
|
||||||
"mockjs": "^1.1.0",
|
"mint-filter": "^4.0.3",
|
||||||
|
"mitt": "^3.0.1",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
"pinia": "^2.1.4",
|
"pinia": "^2.1.7",
|
||||||
"pinyin-pro": "^3.15.2",
|
"pinyin-pro": "^3.19.6",
|
||||||
"qs": "^6.11.2",
|
"qs": "^6.11.2",
|
||||||
"responsive-storage": "^2.2.0",
|
"responsive-storage": "^2.2.0",
|
||||||
"sortablejs": "^1.15.0",
|
"sortablejs": "^1.15.2",
|
||||||
"vue": "^3.3.4",
|
"vue": "^3.4.21",
|
||||||
"vue-router": "^4.2.2",
|
"vue-i18n": "^9.10.1",
|
||||||
"vue-types": "^5.1.0"
|
"vue-router": "^4.3.0",
|
||||||
|
"vue-tippy": "^6.4.1",
|
||||||
|
"vue-types": "^5.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^17.6.6",
|
"@commitlint/cli": "^18.6.1",
|
||||||
"@commitlint/config-conventional": "^17.6.6",
|
"@commitlint/config-conventional": "^18.6.2",
|
||||||
|
"@commitlint/types": "^18.6.1",
|
||||||
|
"@eslint/js": "^8.57.0",
|
||||||
|
"@faker-js/faker": "^8.4.1",
|
||||||
"@iconify-icons/ep": "^1.2.12",
|
"@iconify-icons/ep": "^1.2.12",
|
||||||
"@iconify-icons/ri": "^1.2.9",
|
"@iconify-icons/ri": "^1.2.10",
|
||||||
"@iconify/vue": "^4.1.1",
|
"@iconify/vue": "^4.1.1",
|
||||||
"@pureadmin/theme": "^3.1.0",
|
"@intlify/unplugin-vue-i18n": "^2.0.0",
|
||||||
"@types/js-cookie": "^3.0.3",
|
"@pureadmin/theme": "^3.2.0",
|
||||||
"@types/mockjs": "^1.0.7",
|
"@types/gradient-string": "^1.1.5",
|
||||||
"@types/node": "^20.3.1",
|
"@types/js-cookie": "^3.0.6",
|
||||||
"@types/nprogress": "0.2.0",
|
"@types/node": "^20.11.24",
|
||||||
"@types/qs": "^6.9.7",
|
"@types/nprogress": "^0.2.3",
|
||||||
"@types/sortablejs": "^1.15.1",
|
"@types/qs": "^6.9.12",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
"@types/sortablejs": "^1.15.8",
|
||||||
"@typescript-eslint/parser": "^5.60.0",
|
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
||||||
"@vitejs/plugin-vue": "^4.2.3",
|
"@typescript-eslint/parser": "^7.1.1",
|
||||||
"@vitejs/plugin-vue-jsx": "^3.0.1",
|
"@vitejs/plugin-vue": "^5.0.4",
|
||||||
"@vue/eslint-config-prettier": "^7.1.0",
|
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
||||||
"@vue/eslint-config-typescript": "^11.0.3",
|
"autoprefixer": "^10.4.18",
|
||||||
"autoprefixer": "^10.4.14",
|
"boxen": "^7.1.1",
|
||||||
"cloc": "^2.11.0",
|
"cloc": "^2.11.0",
|
||||||
"cssnano": "^6.0.1",
|
"cssnano": "^6.0.5",
|
||||||
"eslint": "^8.43.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-vue": "^9.15.1",
|
"eslint-define-config": "^2.1.0",
|
||||||
"husky": "^8.0.3",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
"lint-staged": "^13.2.2",
|
"eslint-plugin-vue": "^9.22.0",
|
||||||
"picocolors": "^1.0.0",
|
"gradient-string": "^2.0.2",
|
||||||
"postcss": "^8.4.24",
|
"husky": "^9.0.11",
|
||||||
"postcss-html": "^1.5.0",
|
"lint-staged": "^15.2.2",
|
||||||
"postcss-import": "^15.1.0",
|
"postcss": "^8.4.35",
|
||||||
"postcss-scss": "^4.0.6",
|
"postcss-html": "^1.6.0",
|
||||||
"prettier": "^2.8.8",
|
"postcss-import": "^16.0.1",
|
||||||
"pretty-quick": "^3.1.3",
|
"postcss-scss": "^4.0.9",
|
||||||
"rimraf": "^5.0.1",
|
"prettier": "^3.2.5",
|
||||||
"rollup-plugin-visualizer": "^5.9.2",
|
"rimraf": "^5.0.5",
|
||||||
"sass": "^1.63.6",
|
"rollup-plugin-visualizer": "^5.12.0",
|
||||||
"sass-loader": "^13.3.2",
|
"sass": "^1.71.1",
|
||||||
"stylelint": "^15.9.0",
|
"stylelint": "^16.2.1",
|
||||||
"stylelint-config-html": "^1.1.0",
|
"stylelint-config-recess-order": "^5.0.0",
|
||||||
"stylelint-config-recess-order": "^4.2.0",
|
"stylelint-config-recommended-vue": "^1.5.0",
|
||||||
"stylelint-config-recommended": "^12.0.0",
|
"stylelint-config-standard-scss": "^13.0.0",
|
||||||
"stylelint-config-recommended-scss": "^12.0.0",
|
"stylelint-prettier": "^5.0.0",
|
||||||
"stylelint-config-recommended-vue": "^1.4.0",
|
"svgo": "^3.2.0",
|
||||||
"stylelint-config-standard": "^33.0.0",
|
"tailwindcss": "^3.4.1",
|
||||||
"stylelint-config-standard-scss": "^9.0.0",
|
"typescript": "^5.3.3",
|
||||||
"stylelint-order": "^6.0.3",
|
"vite": "^5.1.5",
|
||||||
"stylelint-prettier": "^3.0.0",
|
|
||||||
"stylelint-scss": "^5.0.1",
|
|
||||||
"svgo": "^3.0.2",
|
|
||||||
"tailwindcss": "^3.3.2",
|
|
||||||
"terser": "^5.18.1",
|
|
||||||
"typescript": "5.0.4",
|
|
||||||
"vite": "^4.3.9",
|
|
||||||
"vite-plugin-cdn-import": "^0.3.5",
|
"vite-plugin-cdn-import": "^0.3.5",
|
||||||
"vite-plugin-compression": "^0.5.1",
|
"vite-plugin-compression": "^0.5.1",
|
||||||
"vite-plugin-mock": "2.9.6",
|
"vite-plugin-fake-server": "^2.1.1",
|
||||||
"vite-plugin-remove-console": "^2.1.1",
|
"vite-plugin-remove-console": "^2.2.0",
|
||||||
"vite-svg-loader": "^4.0.0",
|
"vite-plugin-router-warn": "^1.0.0",
|
||||||
"vue-eslint-parser": "^9.3.1",
|
"vite-svg-loader": "^5.1.0",
|
||||||
"vue-tsc": "^1.8.1"
|
"vue-eslint-parser": "^9.4.2",
|
||||||
|
"vue-tsc": "^1.8.27"
|
||||||
},
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0",
|
||||||
|
"pnpm": ">=8.6.10"
|
||||||
|
},
|
||||||
|
"packageManager": "pnpm@8.6.10",
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"peerDependencyRules": {
|
|
||||||
"ignoreMissing": [
|
|
||||||
"rollup",
|
|
||||||
"webpack",
|
|
||||||
"core-js"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"allowedDeprecatedVersions": {
|
"allowedDeprecatedVersions": {
|
||||||
"sourcemap-codec": "*",
|
"sourcemap-codec": "*",
|
||||||
|
"domexception": "*",
|
||||||
"w3c-hr-time": "*",
|
"w3c-hr-time": "*",
|
||||||
"stable": "*"
|
"stable": "*",
|
||||||
|
"abab": "*"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"repository": "git@github.com:pure-admin/pure-admin-thin.git",
|
|
||||||
"author": "xiaoxian521",
|
|
||||||
"license": "MIT"
|
|
||||||
}
|
}
|
||||||
|
10580
pnpm-lock.yaml
generated
@ -1,4 +1,7 @@
|
|||||||
module.exports = {
|
// @ts-check
|
||||||
|
|
||||||
|
/** @type {import('postcss-load-config').Config} */
|
||||||
|
export default {
|
||||||
plugins: {
|
plugins: {
|
||||||
"postcss-import": {},
|
"postcss-import": {},
|
||||||
"tailwindcss/nesting": {},
|
"tailwindcss/nesting": {},
|
||||||
|
@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="icon" viewBox="0 0 1024 1024"><path fill="#386BF3" d="M410.558.109c0 210.974-300.876 361.752-300.876 633.548 0 174.943 134.704 316.787 300.876 316.787s300.877-141.817 300.877-316.787C711.408 361.752 410.558 210.974 410.558.109z"/><path fill="#C3D2FB" d="M613.469 73.665c0 211.055-300.877 361.914-300.877 633.547C312.592 882.156 447.296 1024 613.47 1024s300.876-141.817 300.876-316.788C914.29 435.58 613.469 284.72 613.469 73.665z"/><path fill="#303F5B" d="M312.592 707.212c0-183.713 137.636-312.171 226.723-441.39 81.702 106.112 172.12 218.74 172.12 367.726A309.755 309.755 0 0 1 420.36 950.064a323.114 323.114 0 0 1-107.769-242.852z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="icon" viewBox="0 0 1024 1024"><path fill="#386BF3" d="M410.558.109c0 210.974-300.876 361.752-300.876 633.548 0 174.943 134.704 316.787 300.876 316.787s300.877-141.817 300.877-316.787C711.408 361.752 410.558 210.974 410.558.109"/><path fill="#C3D2FB" d="M613.469 73.665c0 211.055-300.877 361.914-300.877 633.547C312.592 882.156 447.296 1024 613.47 1024s300.876-141.817 300.876-316.788C914.29 435.58 613.469 284.72 613.469 73.665"/><path fill="#303F5B" d="M312.592 707.212c0-183.713 137.636-312.171 226.723-441.39 81.702 106.112 172.12 218.74 172.12 367.726A309.755 309.755 0 0 1 420.36 950.064a323.1 323.1 0 0 1-107.769-242.852z"/></svg>
|
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 706 B |
@ -1,22 +1,26 @@
|
|||||||
{
|
{
|
||||||
"Version": "4.5.0",
|
"Version": "5.1.0",
|
||||||
"Title": "PureAdmin",
|
"Title": "PureAdmin",
|
||||||
"FixedHeader": true,
|
"FixedHeader": true,
|
||||||
"HiddenSideBar": false,
|
"HiddenSideBar": false,
|
||||||
"MultiTagsCache": false,
|
"MultiTagsCache": false,
|
||||||
"KeepAlive": true,
|
"KeepAlive": true,
|
||||||
|
"Locale": "zh",
|
||||||
"Layout": "vertical",
|
"Layout": "vertical",
|
||||||
"Theme": "default",
|
"Theme": "light",
|
||||||
"DarkMode": false,
|
"DarkMode": false,
|
||||||
|
"OverallStyle": "light",
|
||||||
"Grey": false,
|
"Grey": false,
|
||||||
"Weak": false,
|
"Weak": false,
|
||||||
"HideTabs": false,
|
"HideTabs": false,
|
||||||
|
"HideFooter": false,
|
||||||
"SidebarStatus": true,
|
"SidebarStatus": true,
|
||||||
"EpThemeColor": "#409EFF",
|
"EpThemeColor": "#409EFF",
|
||||||
"ShowLogo": true,
|
"ShowLogo": true,
|
||||||
"ShowModel": "smart",
|
"ShowModel": "smart",
|
||||||
"MenuArrowIconNoTransition": true,
|
"MenuArrowIconNoTransition": false,
|
||||||
"CachingAsyncRoutes": false,
|
"CachingAsyncRoutes": false,
|
||||||
"TooltipEffect": "light",
|
"TooltipEffect": "light",
|
||||||
"ResponsiveStorageNameSpace": "responsive-"
|
"ResponsiveStorageNameSpace": "responsive-",
|
||||||
|
"MenuSearchHistory": 6
|
||||||
}
|
}
|
@ -8,7 +8,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import { ElConfigProvider } from "element-plus";
|
import { ElConfigProvider } from "element-plus";
|
||||||
import zhCn from "element-plus/lib/locale/lang/zh-cn";
|
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
|
||||||
import { ReDialog } from "@/components/ReDialog";
|
import { ReDialog } from "@/components/ReDialog";
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "app",
|
name: "app",
|
||||||
|
@ -6,5 +6,5 @@ type Result = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getAsyncRoutes = () => {
|
export const getAsyncRoutes = () => {
|
||||||
return http.request<Result>("get", "/getAsyncRoutes");
|
return http.request<Result>("get", "/get-async-routes");
|
||||||
};
|
};
|
||||||
|
@ -35,5 +35,5 @@ export const getLogin = (data?: object) => {
|
|||||||
|
|
||||||
/** 刷新token */
|
/** 刷新token */
|
||||||
export const refreshTokenApi = (data?: object) => {
|
export const refreshTokenApi = (data?: object) => {
|
||||||
return http.request<RefreshTokenResult>("post", "/refreshToken", { data });
|
return http.request<RefreshTokenResult>("post", "/refresh-token", { data });
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
@font-face {
|
@font-face {
|
||||||
font-family: "iconfont"; /* Project id 2208059 */
|
font-family: "iconfont"; /* Project id 2208059 */
|
||||||
src: url("iconfont.woff2?t=1671895108120") format("woff2"),
|
src:
|
||||||
|
url("iconfont.woff2?t=1671895108120") format("woff2"),
|
||||||
url("iconfont.woff?t=1671895108120") format("woff"),
|
url("iconfont.woff?t=1671895108120") format("woff"),
|
||||||
url("iconfont.ttf?t=1671895108120") format("truetype");
|
url("iconfont.ttf?t=1671895108120") format("truetype");
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="icon" viewBox="0 0 1024 1024"><path fill="#386BF3" d="M410.558.109c0 210.974-300.876 361.752-300.876 633.548 0 174.943 134.704 316.787 300.876 316.787s300.877-141.817 300.877-316.787C711.408 361.752 410.558 210.974 410.558.109z"/><path fill="#C3D2FB" d="M613.469 73.665c0 211.055-300.877 361.914-300.877 633.547C312.592 882.156 447.296 1024 613.47 1024s300.876-141.817 300.876-316.788C914.29 435.58 613.469 284.72 613.469 73.665z"/><path fill="#303F5B" d="M312.592 707.212c0-183.713 137.636-312.171 226.723-441.39 81.702 106.112 172.12 218.74 172.12 367.726A309.755 309.755 0 0 1 420.36 950.064a323.114 323.114 0 0 1-107.769-242.852z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="icon" viewBox="0 0 1024 1024"><path fill="#386BF3" d="M410.558.109c0 210.974-300.876 361.752-300.876 633.548 0 174.943 134.704 316.787 300.876 316.787s300.877-141.817 300.877-316.787C711.408 361.752 410.558 210.974 410.558.109"/><path fill="#C3D2FB" d="M613.469 73.665c0 211.055-300.877 361.914-300.877 633.547C312.592 882.156 447.296 1024 613.47 1024s300.876-141.817 300.876-316.788C914.29 435.58 613.469 284.72 613.469 73.665"/><path fill="#303F5B" d="M312.592 707.212c0-183.713 137.636-312.171 226.723-441.39 81.702 106.112 172.12 218.74 172.12 367.726A309.755 309.755 0 0 1 420.36 950.064a323.1 323.1 0 0 1-107.769-242.852z"/></svg>
|
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 706 B |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M2.88 18.054a35.897 35.897 0 0 1 8.531-16.32.8.8 0 0 1 1.178 0c.166.18.304.332.413.455a35.897 35.897 0 0 1 8.118 15.865c-2.141.451-4.34.747-6.584.874l-2.089 4.178a.5.5 0 0 1-.894 0l-2.089-4.178a44.019 44.019 0 0 1-6.584-.874zm6.698-1.123 1.157.066L12 19.527l1.265-2.53 1.157-.066a42.137 42.137 0 0 0 4.227-.454A33.913 33.913 0 0 0 12 4.09a33.913 33.913 0 0 0-6.649 12.387c1.395.222 2.805.374 4.227.454zM12 15a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M2.88 18.054a35.9 35.9 0 0 1 8.531-16.32.8.8 0 0 1 1.178 0q.25.27.413.455a35.9 35.9 0 0 1 8.118 15.865c-2.141.451-4.34.747-6.584.874l-2.089 4.178a.5.5 0 0 1-.894 0l-2.089-4.178a44 44 0 0 1-6.584-.874m6.698-1.123 1.157.066L12 19.527l1.265-2.53 1.157-.066a42 42 0 0 0 4.227-.454A33.9 33.9 0 0 0 12 4.09a33.9 33.9 0 0 0-6.649 12.387q2.093.334 4.227.454M12 15a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2"/></svg>
|
Before Width: | Height: | Size: 588 B After Width: | Height: | Size: 533 B |
@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.38 2.019a7.5 7.5 0 1 0 10.6 10.6C21.662 17.854 17.316 22 12.001 22 6.477 22 2 17.523 2 12c0-5.315 4.146-9.661 9.38-9.981z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.38 2.019a7.5 7.5 0 1 0 10.6 10.6C21.662 17.854 17.316 22 12.001 22 6.477 22 2 17.523 2 12c0-5.315 4.146-9.661 9.38-9.981"/></svg>
|
Before Width: | Height: | Size: 263 B After Width: | Height: | Size: 262 B |
@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85 1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12M11 1h2v3h-2zm0 19h2v3h-2zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414zm2.121-14.85 1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414zM23 11v2h-3v-2zM4 11v2H1v-2z"/></svg>
|
Before Width: | Height: | Size: 480 B After Width: | Height: | Size: 435 B |
@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" class="iconify iconify--ant-design" viewBox="0 0 1024 1024"><path fill="currentColor" d="M864 170h-60c-4.4 0-8 3.6-8 8v518H310v-73c0-6.7-7.8-10.5-13-6.3l-141.9 112a8 8 0 0 0 0 12.6l141.9 112c5.3 4.2 13 .4 13-6.3v-75h498c35.3 0 64-28.7 64-64V178c0-4.4-3.6-8-8-8z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" class="iconify iconify--ant-design" viewBox="0 0 1024 1024"><path fill="currentColor" d="M864 170h-60c-4.4 0-8 3.6-8 8v518H310v-73c0-6.7-7.8-10.5-13-6.3l-141.9 112a8 8 0 0 0 0 12.6l141.9 112c5.3 4.2 13 .4 13-6.3v-75h498c35.3 0 64-28.7 64-64V178c0-4.4-3.6-8-8-8"/></svg>
|
Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 351 B |
@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" aria-hidden="true" class="re-screen" color="#00000073" viewBox="0 0 16 16"><path fill="currentColor" d="M3.5 4H1V3h2V1h1v2.5l-.5.5zM13 3V1h-1v2.5l.5.5H15V3h-2zm-1 9.5V15h1v-2h2v-1h-2.5l-.5.5zM1 12v1h2v2h1v-2.5l-.5-.5H1zm11-1.5-.5.5h-7l-.5-.5v-5l.5-.5h7l.5.5v5zM10 7H6v2h4V7z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" aria-hidden="true" class="re-screen" color="#00000073" viewBox="0 0 16 16"><path fill="currentColor" d="M3.5 4H1V3h2V1h1v2.5zM13 3V1h-1v2.5l.5.5H15V3zm-1 9.5V15h1v-2h2v-1h-2.5zM1 12v1h2v2h1v-2.5l-.5-.5zm11-1.5-.5.5h-7l-.5-.5v-5l.5-.5h7l.5.5zM10 7H6v2h4z"/></svg>
|
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 327 B |
@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" aria-hidden="true" class="re-screen" color="#00000073" viewBox="0 0 16 16"><path fill="currentColor" d="M3 12h10V4H3v8zm2-6h6v4H5V6zM2 6H1V2.5l.5-.5H5v1H2v3zm13-3.5V6h-1V3h-3V2h3.5l.5.5zM14 10h1v3.5l-.5.5H11v-1h3v-3zM2 13h3v1H1.5l-.5-.5V10h1v3z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" aria-hidden="true" class="re-screen" color="#00000073" viewBox="0 0 16 16"><path fill="currentColor" d="M3 12h10V4H3zm2-6h6v4H5zM2 6H1V2.5l.5-.5H5v1H2zm13-3.5V6h-1V3h-3V2h3.5zM14 10h1v3.5l-.5.5H11v-1h3zM2 13h3v1H1.5l-.5-.5V10h1z"/></svg>
|
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 302 B |
@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" class="iconify iconify--mdi" viewBox="0 0 24 24"><path fill="currentColor" d="M1 7h6v2H3v2h4v2H3v2h4v2H1V7m10 0h4v2h-4v2h2a2 2 0 0 1 2 2v2c0 1.11-.89 2-2 2H9v-2h4v-2h-2a2 2 0 0 1-2-2V9c0-1.1.9-2 2-2m8 0h2a2 2 0 0 1 2 2v1h-2V9h-2v6h2v-1h2v1c0 1.11-.89 2-2 2h-2a2 2 0 0 1-2-2V9c0-1.1.9-2 2-2Z"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" class="iconify iconify--mdi" viewBox="0 0 24 24"><path fill="currentColor" d="M1 7h6v2H3v2h4v2H3v2h4v2H1zm10 0h4v2h-4v2h2a2 2 0 0 1 2 2v2c0 1.11-.89 2-2 2H9v-2h4v-2h-2a2 2 0 0 1-2-2V9c0-1.1.9-2 2-2m8 0h2a2 2 0 0 1 2 2v1h-2V9h-2v6h2v-1h2v1c0 1.11-.89 2-2 2h-2a2 2 0 0 1-2-2V9c0-1.1.9-2 2-2"/></svg>
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 379 B |
1
src/assets/svg/system.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" class="icon" viewBox="0 0 1024 1024"><path d="M554 849.574c0 23.365-18.635 42.307-42 42.307s-42-18.941-42-42.307V662.719c0-23.365 18.635-42.307 42-42.307v-7.051c23.365 0 42 25.993 42 49.358z"/><path d="M893 888.5c0 17.397-14.103 31.5-31.5 31.5h-700c-17.397 0-31.5-14.103-31.5-31.5s14.103-31.5 31.5-31.5h700c17.397 0 31.5 14.103 31.5 31.5m33-714.074C926 135.484 894.686 105 855.744 105H168.256C129.314 105 98 135.484 98 174.426V533h828zM98 630.988C98 669.931 129.314 702 168.256 702h687.488C894.686 702 926 669.931 926 630.988V596H98z"/></svg>
|
After Width: | Height: | Size: 605 B |
@ -27,8 +27,11 @@ const addDialog = (options: DialogOptions) => {
|
|||||||
|
|
||||||
/** 关闭弹框 */
|
/** 关闭弹框 */
|
||||||
const closeDialog = (options: DialogOptions, index: number, args?: any) => {
|
const closeDialog = (options: DialogOptions, index: number, args?: any) => {
|
||||||
dialogStore.value.splice(index, 1);
|
dialogStore.value[index].visible = false;
|
||||||
options.closeCallBack && options.closeCallBack({ options, index, args });
|
options.closeCallBack && options.closeCallBack({ options, index, args });
|
||||||
|
useTimeoutFn(() => {
|
||||||
|
dialogStore.value.splice(index, 1);
|
||||||
|
}, 200);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,7 +52,7 @@ const closeAllDialog = () => {
|
|||||||
/** 千万别忘了在下面这三处引入并注册下,放心注册,不使用`addDialog`调用就不会被挂载
|
/** 千万别忘了在下面这三处引入并注册下,放心注册,不使用`addDialog`调用就不会被挂载
|
||||||
* https://github.com/pure-admin/vue-pure-admin/blob/main/src/App.vue#L4
|
* https://github.com/pure-admin/vue-pure-admin/blob/main/src/App.vue#L4
|
||||||
* https://github.com/pure-admin/vue-pure-admin/blob/main/src/App.vue#L13
|
* https://github.com/pure-admin/vue-pure-admin/blob/main/src/App.vue#L13
|
||||||
* https://github.com/pure-admin/vue-pure-admin/blob/main/src/App.vue#L18
|
* https://github.com/pure-admin/vue-pure-admin/blob/main/src/App.vue#L20
|
||||||
*/
|
*/
|
||||||
const ReDialog = withInstall(reDialog);
|
const ReDialog = withInstall(reDialog);
|
||||||
|
|
||||||
|
@ -84,13 +84,13 @@ function handleClose(
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
class="pure-dialog"
|
|
||||||
v-for="(options, index) in dialogStore"
|
v-for="(options, index) in dialogStore"
|
||||||
:key="index"
|
:key="index"
|
||||||
v-bind="options"
|
v-bind="options"
|
||||||
v-model="options.visible"
|
v-model="options.visible"
|
||||||
|
class="pure-dialog"
|
||||||
:fullscreen="fullscreen ? true : options?.fullscreen ? true : false"
|
:fullscreen="fullscreen ? true : options?.fullscreen ? true : false"
|
||||||
@close="handleClose(options, index)"
|
@closed="handleClose(options, index)"
|
||||||
@opened="eventsCallBack('open', options, index)"
|
@opened="eventsCallBack('open', options, index)"
|
||||||
@openAutoFocus="eventsCallBack('openAutoFocus', options, index)"
|
@openAutoFocus="eventsCallBack('openAutoFocus', options, index)"
|
||||||
@closeAutoFocus="eventsCallBack('closeAutoFocus', options, index)"
|
@closeAutoFocus="eventsCallBack('closeAutoFocus', options, index)"
|
||||||
@ -116,15 +116,15 @@ function handleClose(
|
|||||||
options?.fullscreen
|
options?.fullscreen
|
||||||
? ExitFullscreen
|
? ExitFullscreen
|
||||||
: fullscreen
|
: fullscreen
|
||||||
? ExitFullscreen
|
? ExitFullscreen
|
||||||
: Fullscreen
|
: Fullscreen
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</i>
|
</i>
|
||||||
</div>
|
</div>
|
||||||
<component
|
<component
|
||||||
v-else
|
|
||||||
:is="options?.headerRenderer({ close, titleId, titleClass })"
|
:is="options?.headerRenderer({ close, titleId, titleClass })"
|
||||||
|
v-else
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<component
|
<component
|
||||||
|
@ -3,7 +3,7 @@ import type { CSSProperties, VNode, Component } from "vue";
|
|||||||
type DoneFn = (cancel?: boolean) => void;
|
type DoneFn = (cancel?: boolean) => void;
|
||||||
type EventType = "open" | "close" | "openAutoFocus" | "closeAutoFocus";
|
type EventType = "open" | "close" | "openAutoFocus" | "closeAutoFocus";
|
||||||
type ArgsType = {
|
type ArgsType = {
|
||||||
/** `cancel` 点击取消按钮、`sure` 点击确定按钮、`close` 点击右上角关闭按钮或者空白页 */
|
/** `cancel` 点击取消按钮、`sure` 点击确定按钮、`close` 点击右上角关闭按钮或空白页或按下了esc键 */
|
||||||
command: "cancel" | "sure" | "close";
|
command: "cancel" | "sure" | "close";
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ interface DialogOptions extends DialogProps {
|
|||||||
options: DialogOptions;
|
options: DialogOptions;
|
||||||
index: number;
|
index: number;
|
||||||
}) => void;
|
}) => void;
|
||||||
/** `Dialog` 关闭后的回调(只有点击右上角关闭按钮或者空白页关闭页面时才会触发) */
|
/** `Dialog` 关闭后的回调(只有点击右上角关闭按钮或空白页或按下了esc键关闭页面时才会触发) */
|
||||||
close?: ({
|
close?: ({
|
||||||
options,
|
options,
|
||||||
index
|
index
|
||||||
@ -165,7 +165,7 @@ interface DialogOptions extends DialogProps {
|
|||||||
options: DialogOptions;
|
options: DialogOptions;
|
||||||
index: number;
|
index: number;
|
||||||
}) => void;
|
}) => void;
|
||||||
/** `Dialog` 关闭后的回调。 `args` 返回的 `command` 值解析:`cancel` 点击取消按钮、`sure` 点击确定按钮、`close` 点击右上角关闭按钮或者空白页 */
|
/** `Dialog` 关闭后的回调。 `args` 返回的 `command` 值解析:`cancel` 点击取消按钮、`sure` 点击确定按钮、`close` 点击右上角关闭按钮或空白页或按下了esc键 */
|
||||||
closeCallBack?: ({
|
closeCallBack?: ({
|
||||||
options,
|
options,
|
||||||
index,
|
index,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { iconType } from "./types";
|
import type { iconType } from "./types";
|
||||||
import { h, defineComponent, Component } from "vue";
|
import { h, defineComponent, type Component } from "vue";
|
||||||
import { IconifyIconOnline, IconifyIconOffline, FontIcon } from "../index";
|
import { IconifyIconOnline, IconifyIconOffline, FontIcon } from "../index";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +33,7 @@ export function useRenderIcon(icon: any, attrs?: iconType): Component {
|
|||||||
});
|
});
|
||||||
} else if (typeof icon === "function" || typeof icon?.render === "function") {
|
} else if (typeof icon === "function" || typeof icon?.render === "function") {
|
||||||
// svg
|
// svg
|
||||||
return icon;
|
return attrs ? h(icon, { ...attrs }) : icon;
|
||||||
} else if (typeof icon === "object") {
|
} else if (typeof icon === "object") {
|
||||||
return defineComponent({
|
return defineComponent({
|
||||||
name: "OfflineIcon",
|
name: "OfflineIcon",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { h, defineComponent } from "vue";
|
import { h, defineComponent } from "vue";
|
||||||
import { Icon as IconifyIcon, addIcon } from "@iconify/vue/dist/offline";
|
import { Icon as IconifyIcon, addIcon } from "@iconify/vue/dist/offline";
|
||||||
|
|
||||||
// Iconify Icon在Vue里本地使用(用于内网环境)https://docs.iconify.design/icon-components/vue/offline.html
|
// Iconify Icon在Vue里本地使用(用于内网环境)
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "IconifyIconOffline",
|
name: "IconifyIconOffline",
|
||||||
components: { IconifyIcon },
|
components: { IconifyIcon },
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
|
// 这里存放本地图标,在 src/layout/index.vue 文件中加载,避免在首启动加载
|
||||||
import { addIcon } from "@iconify/vue/dist/offline";
|
import { addIcon } from "@iconify/vue/dist/offline";
|
||||||
|
|
||||||
/**
|
// 本地菜单图标,后端在路由的 icon 中返回对应的图标字符串并且前端在此处使用 addIcon 添加即可渲染菜单图标
|
||||||
* 这里存放本地图标,在 src/layout/index.vue 文件中加载,避免在首启动加载
|
// @iconify-icons/ep
|
||||||
*/
|
|
||||||
|
|
||||||
// 本地菜单图标,后端在路由的icon中返回对应的图标字符串并且前端在此处使用addIcon添加即可渲染菜单图标
|
|
||||||
import HomeFilled from "@iconify-icons/ep/home-filled";
|
|
||||||
import InformationLine from "@iconify-icons/ri/information-line";
|
|
||||||
import Lollipop from "@iconify-icons/ep/lollipop";
|
import Lollipop from "@iconify-icons/ep/lollipop";
|
||||||
|
import HomeFilled from "@iconify-icons/ep/home-filled";
|
||||||
addIcon("homeFilled", HomeFilled);
|
addIcon("ep:lollipop", Lollipop);
|
||||||
addIcon("informationLine", InformationLine);
|
addIcon("ep:home-filled", HomeFilled);
|
||||||
addIcon("lollipop", Lollipop);
|
// @iconify-icons/ri
|
||||||
|
import Search from "@iconify-icons/ri/search-line";
|
||||||
|
import InformationLine from "@iconify-icons/ri/information-line";
|
||||||
|
addIcon("ri:search-line", Search);
|
||||||
|
addIcon("ri:information-line", InformationLine);
|
||||||
|
@ -13,7 +13,8 @@ export interface iconType {
|
|||||||
align?: string;
|
align?: string;
|
||||||
onLoad?: Function;
|
onLoad?: Function;
|
||||||
includes?: Function;
|
includes?: Function;
|
||||||
|
// svg 需要什么SVG属性自行添加
|
||||||
// all icon
|
fill?: string;
|
||||||
|
// all icon
|
||||||
style?: object;
|
style?: object;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,10 @@ const props = {
|
|||||||
columns: {
|
columns: {
|
||||||
type: Array as PropType<TableColumnList>,
|
type: Array as PropType<TableColumnList>,
|
||||||
default: () => []
|
default: () => []
|
||||||
|
},
|
||||||
|
isExpandAll: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -37,12 +41,11 @@ export default defineComponent({
|
|||||||
props,
|
props,
|
||||||
emits: ["refresh"],
|
emits: ["refresh"],
|
||||||
setup(props, { emit, slots, attrs }) {
|
setup(props, { emit, slots, attrs }) {
|
||||||
const buttonRef = ref();
|
|
||||||
const size = ref("default");
|
const size = ref("default");
|
||||||
const isExpandAll = ref(true);
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const checkAll = ref(true);
|
const checkAll = ref(true);
|
||||||
const isIndeterminate = ref(false);
|
const isIndeterminate = ref(false);
|
||||||
|
const isExpandAll = ref(props.isExpandAll);
|
||||||
const filterColumns = cloneDeep(props?.columns).filter(column =>
|
const filterColumns = cloneDeep(props?.columns).filter(column =>
|
||||||
isBoolean(column?.hide)
|
isBoolean(column?.hide)
|
||||||
? !column.hide
|
? !column.hide
|
||||||
@ -200,11 +203,22 @@ export default defineComponent({
|
|||||||
: false;
|
: false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const rendTippyProps = (content: string) => {
|
||||||
|
// https://vue-tippy.netlify.app/props
|
||||||
|
return {
|
||||||
|
content,
|
||||||
|
offset: [0, 18],
|
||||||
|
duration: [300, 0],
|
||||||
|
followCursor: true,
|
||||||
|
hideOnClick: "toggle"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const reference = {
|
const reference = {
|
||||||
reference: () => (
|
reference: () => (
|
||||||
<SettingIcon
|
<SettingIcon
|
||||||
class={["w-[16px]", iconClass.value]}
|
class={["w-[16px]", iconClass.value]}
|
||||||
onMouseover={e => (buttonRef.value = e.currentTarget)}
|
v-tippy={rendTippyProps("列设置")}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
@ -224,45 +238,43 @@ export default defineComponent({
|
|||||||
) : null}
|
) : null}
|
||||||
{props.tableRef?.size ? (
|
{props.tableRef?.size ? (
|
||||||
<>
|
<>
|
||||||
<el-tooltip
|
<ExpandIcon
|
||||||
effect="dark"
|
class={["w-[16px]", iconClass.value]}
|
||||||
content={isExpandAll.value ? "折叠" : "展开"}
|
style={{
|
||||||
placement="top"
|
transform: isExpandAll.value ? "none" : "rotate(-90deg)"
|
||||||
>
|
}}
|
||||||
<ExpandIcon
|
v-tippy={rendTippyProps(
|
||||||
class={["w-[16px]", iconClass.value]}
|
isExpandAll.value ? "折叠" : "展开"
|
||||||
style={{
|
)}
|
||||||
transform: isExpandAll.value ? "none" : "rotate(-90deg)"
|
onClick={() => onExpand()}
|
||||||
}}
|
/>
|
||||||
onClick={() => onExpand()}
|
|
||||||
/>
|
|
||||||
</el-tooltip>
|
|
||||||
<el-divider direction="vertical" />
|
<el-divider direction="vertical" />
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
<el-tooltip effect="dark" content="刷新" placement="top">
|
<RefreshIcon
|
||||||
<RefreshIcon
|
class={[
|
||||||
class={[
|
"w-[16px]",
|
||||||
"w-[16px]",
|
iconClass.value,
|
||||||
iconClass.value,
|
loading.value ? "animate-spin" : ""
|
||||||
loading.value ? "animate-spin" : ""
|
]}
|
||||||
]}
|
v-tippy={rendTippyProps("刷新")}
|
||||||
onClick={() => onReFresh()}
|
onClick={() => onReFresh()}
|
||||||
/>
|
/>
|
||||||
</el-tooltip>
|
|
||||||
<el-divider direction="vertical" />
|
<el-divider direction="vertical" />
|
||||||
<el-tooltip effect="dark" content="密度" placement="top">
|
<el-dropdown
|
||||||
<el-dropdown v-slots={dropdown} trigger="click">
|
v-slots={dropdown}
|
||||||
<CollapseIcon class={["w-[16px]", iconClass.value]} />
|
trigger="click"
|
||||||
</el-dropdown>
|
v-tippy={rendTippyProps("密度")}
|
||||||
</el-tooltip>
|
>
|
||||||
|
<CollapseIcon class={["w-[16px]", iconClass.value]} />
|
||||||
|
</el-dropdown>
|
||||||
<el-divider direction="vertical" />
|
<el-divider direction="vertical" />
|
||||||
|
|
||||||
<el-popover
|
<el-popover
|
||||||
v-slots={reference}
|
v-slots={reference}
|
||||||
placement="bottom-start"
|
placement="bottom-start"
|
||||||
popper-style={{ padding: 0 }}
|
popper-style={{ padding: 0 }}
|
||||||
width="160"
|
width="200"
|
||||||
trigger="click"
|
trigger="click"
|
||||||
>
|
>
|
||||||
<div class={[topClass.value]}>
|
<div class={[topClass.value]}>
|
||||||
@ -279,70 +291,53 @@ export default defineComponent({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pt-[6px] pl-[11px]">
|
<div class="pt-[6px] pl-[11px]">
|
||||||
<el-checkbox-group
|
<el-scrollbar max-height="36vh">
|
||||||
v-model={checkedColumns.value}
|
<el-checkbox-group
|
||||||
onChange={value => handleCheckedColumnsChange(value)}
|
v-model={checkedColumns.value}
|
||||||
>
|
onChange={value => handleCheckedColumnsChange(value)}
|
||||||
<el-space
|
|
||||||
direction="vertical"
|
|
||||||
alignment="flex-start"
|
|
||||||
size={0}
|
|
||||||
>
|
>
|
||||||
{checkColumnList.map(item => {
|
<el-space
|
||||||
return (
|
direction="vertical"
|
||||||
<div class="flex items-center">
|
alignment="flex-start"
|
||||||
<DragIcon
|
size={0}
|
||||||
class={[
|
>
|
||||||
"drag-btn w-[16px] mr-2",
|
{checkColumnList.map(item => {
|
||||||
isFixedColumn(item)
|
return (
|
||||||
? "!cursor-no-drop"
|
<div class="flex items-center">
|
||||||
: "!cursor-grab"
|
<DragIcon
|
||||||
]}
|
class={[
|
||||||
onMouseenter={(event: {
|
"drag-btn w-[16px] mr-2",
|
||||||
preventDefault: () => void;
|
isFixedColumn(item)
|
||||||
}) => rowDrop(event)}
|
? "!cursor-no-drop"
|
||||||
/>
|
: "!cursor-grab"
|
||||||
<el-checkbox
|
]}
|
||||||
key={item}
|
onMouseenter={(event: {
|
||||||
label={item}
|
preventDefault: () => void;
|
||||||
onChange={value =>
|
}) => rowDrop(event)}
|
||||||
handleCheckColumnListChange(value, item)
|
/>
|
||||||
}
|
<el-checkbox
|
||||||
>
|
key={item}
|
||||||
<span
|
value={item}
|
||||||
title={item}
|
onChange={value =>
|
||||||
class="inline-block w-[120px] truncate hover:text-text_color_primary"
|
handleCheckColumnListChange(value, item)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{item}
|
<span
|
||||||
</span>
|
title={item}
|
||||||
</el-checkbox>
|
class="inline-block w-[120px] truncate hover:text-text_color_primary"
|
||||||
</div>
|
>
|
||||||
);
|
{item}
|
||||||
})}
|
</span>
|
||||||
</el-space>
|
</el-checkbox>
|
||||||
</el-checkbox-group>
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</el-space>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-scrollbar>
|
||||||
</div>
|
</div>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-tooltip
|
|
||||||
popper-options={{
|
|
||||||
modifiers: [
|
|
||||||
{
|
|
||||||
name: "computeStyles",
|
|
||||||
options: {
|
|
||||||
adaptive: false,
|
|
||||||
enabled: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}}
|
|
||||||
placement="top"
|
|
||||||
virtual-ref={buttonRef.value}
|
|
||||||
virtual-triggering
|
|
||||||
trigger="hover"
|
|
||||||
content="列设置"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
{slots.default({
|
{slots.default({
|
||||||
size: size.value,
|
size: size.value,
|
||||||
|
@ -1 +1 @@
|
|||||||
<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M13.79 10.21a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42l-2.5-2.5a1 1 0 0 0-.33-.21 1 1 0 0 0-.76 0 1 1 0 0 0-.33.21l-2.5 2.5a1 1 0 0 0 1.42 1.42l.79-.8v5.18l-.79-.8a1 1 0 0 0-1.42 1.42l2.5 2.5a1 1 0 0 0 .33.21.94.94 0 0 0 .76 0 1 1 0 0 0 .33-.21l2.5-2.5a1 1 0 0 0-1.42-1.42l-.79.8V9.41ZM7 4h10a1 1 0 0 0 0-2H7a1 1 0 0 0 0 2Zm10 16H7a1 1 0 0 0 0 2h10a1 1 0 0 0 0-2Z"/></svg>
|
<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M13.79 10.21a1 1 0 0 0 1.42 0 1 1 0 0 0 0-1.42l-2.5-2.5a1 1 0 0 0-.33-.21 1 1 0 0 0-.76 0 1 1 0 0 0-.33.21l-2.5 2.5a1 1 0 0 0 1.42 1.42l.79-.8v5.18l-.79-.8a1 1 0 0 0-1.42 1.42l2.5 2.5a1 1 0 0 0 .33.21.94.94 0 0 0 .76 0 1 1 0 0 0 .33-.21l2.5-2.5a1 1 0 0 0-1.42-1.42l-.79.8V9.41ZM7 4h10a1 1 0 0 0 0-2H7a1 1 0 0 0 0 2m10 16H7a1 1 0 0 0 0 2h10a1 1 0 0 0 0-2"/></svg>
|
Before Width: | Height: | Size: 441 B After Width: | Height: | Size: 439 B |
@ -1 +1 @@
|
|||||||
<svg width="32" height="32" fill="currentColor" aria-hidden="true" data-icon="holder" viewBox="64 64 896 896"><path d="M300 276.5a56 56 0 1 0 56-97 56 56 0 0 0-56 97zm0 284a56 56 0 1 0 56-97 56 56 0 0 0-56 97zM640 228a56 56 0 1 0 112 0 56 56 0 0 0-112 0zm0 284a56 56 0 1 0 112 0 56 56 0 0 0-112 0zM300 844.5a56 56 0 1 0 56-97 56 56 0 0 0-56 97zM640 796a56 56 0 1 0 112 0 56 56 0 0 0-112 0z"/></svg>
|
<svg width="32" height="32" fill="currentColor" aria-hidden="true" data-icon="holder" viewBox="64 64 896 896"><path d="M300 276.5a56 56 0 1 0 56-97 56 56 0 0 0-56 97m0 284a56 56 0 1 0 56-97 56 56 0 0 0-56 97M640 228a56 56 0 1 0 112 0 56 56 0 0 0-112 0m0 284a56 56 0 1 0 112 0 56 56 0 0 0-112 0M300 844.5a56 56 0 1 0 56-97 56 56 0 0 0-56 97M640 796a56 56 0 1 0 112 0 56 56 0 0 0-112 0"/></svg>
|
Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 392 B |
@ -1 +1 @@
|
|||||||
<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M22 4V2H2v2h9v14.17l-5.5-5.5-1.42 1.41L12 22l7.92-7.92-1.42-1.41-5.5 5.5V4h9Z"/></svg>
|
<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M22 4V2H2v2h9v14.17l-5.5-5.5-1.42 1.41L12 22l7.92-7.92-1.42-1.41-5.5 5.5V4z"/></svg>
|
Before Width: | Height: | Size: 163 B After Width: | Height: | Size: 161 B |
@ -1 +1 @@
|
|||||||
<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M3.34 17a10.018 10.018 0 0 1-.978-2.326 3 3 0 0 0 .002-5.347A9.99 9.99 0 0 1 4.865 4.99a3 3 0 0 0 4.631-2.674 9.99 9.99 0 0 1 5.007.002 3 3 0 0 0 4.632 2.672A9.99 9.99 0 0 1 20.66 7c.433.749.757 1.53.978 2.326a3 3 0 0 0-.002 5.347 9.99 9.99 0 0 1-2.501 4.337 3 3 0 0 0-4.631 2.674 9.99 9.99 0 0 1-5.007-.002 3 3 0 0 0-4.632-2.672A10.018 10.018 0 0 1 3.34 17zm5.66.196a4.993 4.993 0 0 1 2.25 2.77c.499.047 1 .048 1.499.001A4.993 4.993 0 0 1 15 17.197a4.993 4.993 0 0 1 3.525-.565c.29-.408.54-.843.748-1.298A4.993 4.993 0 0 1 18 12c0-1.26.47-2.437 1.273-3.334a8.126 8.126 0 0 0-.75-1.298A4.993 4.993 0 0 1 15 6.804a4.993 4.993 0 0 1-2.25-2.77c-.499-.047-1-.048-1.499-.001A4.993 4.993 0 0 1 9 6.803a4.993 4.993 0 0 1-3.525.565 7.99 7.99 0 0 0-.748 1.298A4.993 4.993 0 0 1 6 12a4.99 4.99 0 0 1-1.273 3.334 8.126 8.126 0 0 0 .75 1.298A4.993 4.993 0 0 1 9 17.196zM12 15a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/></svg>
|
<svg width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M3.34 17a10 10 0 0 1-.978-2.326 3 3 0 0 0 .002-5.347A10 10 0 0 1 4.865 4.99a3 3 0 0 0 4.631-2.674 10 10 0 0 1 5.007.002 3 3 0 0 0 4.632 2.672A10 10 0 0 1 20.66 7c.433.749.757 1.53.978 2.326a3 3 0 0 0-.002 5.347 10 10 0 0 1-2.501 4.337 3 3 0 0 0-4.631 2.674 10 10 0 0 1-5.007-.002 3 3 0 0 0-4.632-2.672A10 10 0 0 1 3.34 17m5.66.196a5 5 0 0 1 2.25 2.77q.75.071 1.499.001A5 5 0 0 1 15 17.197a5 5 0 0 1 3.525-.565q.435-.614.748-1.298A5 5 0 0 1 18 12c0-1.26.47-2.437 1.273-3.334a8 8 0 0 0-.75-1.298A5 5 0 0 1 15 6.804a5 5 0 0 1-2.25-2.77q-.75-.071-1.499-.001A5 5 0 0 1 9 6.803a5 5 0 0 1-3.525.565 8 8 0 0 0-.748 1.298A5 5 0 0 1 6 12a5 5 0 0 1-1.273 3.334 8 8 0 0 0 .75 1.298A5 5 0 0 1 9 17.196M12 15a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0-2a1 1 0 1 0 0-2 1 1 0 0 0 0 2"/></svg>
|
Before Width: | Height: | Size: 1011 B After Width: | Height: | Size: 840 B |
8
src/components/ReSegmented/index.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import reSegmented from "./src/index";
|
||||||
|
import { withInstall } from "@pureadmin/utils";
|
||||||
|
|
||||||
|
/** 分段控制器组件 */
|
||||||
|
export const ReSegmented = withInstall(reSegmented);
|
||||||
|
|
||||||
|
export default ReSegmented;
|
||||||
|
export type { OptionsType } from "./src/type";
|
80
src/components/ReSegmented/src/index.css
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
.pure-segmented {
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 2px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: rgba(0, 0, 0, 0.65);
|
||||||
|
background-color: rgb(0 0 0 / 4%);
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-group {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
|
justify-items: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-item-selected {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: none;
|
||||||
|
width: 0;
|
||||||
|
height: 100%;
|
||||||
|
padding: 4px 0;
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-shadow:
|
||||||
|
0 2px 8px -2px rgb(0 0 0 / 5%),
|
||||||
|
0 1px 4px -1px rgb(0 0 0 / 7%),
|
||||||
|
0 0 1px rgb(0 0 0 / 7%);
|
||||||
|
transition:
|
||||||
|
transform 0.5s cubic-bezier(0.645, 0.045, 0.355, 1),
|
||||||
|
width 0.5s cubic-bezier(0.645, 0.045, 0.355, 1);
|
||||||
|
will-change: transform, width;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-item {
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: all 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-item > div {
|
||||||
|
min-height: 28px;
|
||||||
|
line-height: 28px;
|
||||||
|
padding: 0 11px;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-item > input {
|
||||||
|
position: absolute;
|
||||||
|
inset-block-start: 0;
|
||||||
|
inset-inline-start: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-item-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-item-icon svg {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-item-disabled {
|
||||||
|
color: rgba(0, 0, 0, 0.25);
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
166
src/components/ReSegmented/src/index.tsx
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
import "./index.css";
|
||||||
|
import {
|
||||||
|
h,
|
||||||
|
ref,
|
||||||
|
toRef,
|
||||||
|
watch,
|
||||||
|
nextTick,
|
||||||
|
defineComponent,
|
||||||
|
getCurrentInstance
|
||||||
|
} from "vue";
|
||||||
|
import type { OptionsType } from "./type";
|
||||||
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
|
import { isFunction, isNumber, useDark } from "@pureadmin/utils";
|
||||||
|
|
||||||
|
const props = {
|
||||||
|
options: {
|
||||||
|
type: Array<OptionsType>,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
/** 默认选中,按照第一个索引为 `0` 的模式,可选(`modelValue`只有传`number`类型时才为响应式) */
|
||||||
|
modelValue: {
|
||||||
|
type: undefined,
|
||||||
|
require: false,
|
||||||
|
default: "0"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: "ReSegmented",
|
||||||
|
props,
|
||||||
|
emits: ["change", "update:modelValue"],
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const width = ref(0);
|
||||||
|
const translateX = ref(0);
|
||||||
|
const { isDark } = useDark();
|
||||||
|
const initStatus = ref(false);
|
||||||
|
const curMouseActive = ref(-1);
|
||||||
|
const segmentedItembg = ref("");
|
||||||
|
const instance = getCurrentInstance()!;
|
||||||
|
const curIndex = isNumber(props.modelValue)
|
||||||
|
? toRef(props, "modelValue")
|
||||||
|
: ref(0);
|
||||||
|
|
||||||
|
function handleChange({ option, index }, event: Event) {
|
||||||
|
if (option.disabled) return;
|
||||||
|
event.preventDefault();
|
||||||
|
isNumber(props.modelValue)
|
||||||
|
? emit("update:modelValue", index)
|
||||||
|
: (curIndex.value = index);
|
||||||
|
segmentedItembg.value = "";
|
||||||
|
emit("change", { index, option });
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMouseenter({ option, index }, event: Event) {
|
||||||
|
event.preventDefault();
|
||||||
|
curMouseActive.value = index;
|
||||||
|
if (option.disabled || curIndex.value === index) {
|
||||||
|
segmentedItembg.value = "";
|
||||||
|
} else {
|
||||||
|
segmentedItembg.value = isDark.value
|
||||||
|
? "#1f1f1f"
|
||||||
|
: "rgba(0, 0, 0, 0.06)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMouseleave(_, event: Event) {
|
||||||
|
event.preventDefault();
|
||||||
|
curMouseActive.value = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleInit(index = curIndex.value) {
|
||||||
|
nextTick(() => {
|
||||||
|
const curLabelRef = instance?.proxy?.$refs[`labelRef${index}`] as ElRef;
|
||||||
|
width.value = curLabelRef.clientWidth;
|
||||||
|
translateX.value = curLabelRef.offsetLeft;
|
||||||
|
initStatus.value = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => curIndex.value,
|
||||||
|
index => {
|
||||||
|
nextTick(() => {
|
||||||
|
handleInit(index);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deep: true,
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const rendLabel = () => {
|
||||||
|
return props.options.map((option, index) => {
|
||||||
|
return (
|
||||||
|
<label
|
||||||
|
ref={`labelRef${index}`}
|
||||||
|
class={[
|
||||||
|
"pure-segmented-item",
|
||||||
|
option?.disabled && "pure-segmented-item-disabled"
|
||||||
|
]}
|
||||||
|
style={{
|
||||||
|
background:
|
||||||
|
curMouseActive.value === index ? segmentedItembg.value : "",
|
||||||
|
color:
|
||||||
|
!option.disabled &&
|
||||||
|
(curIndex.value === index || curMouseActive.value === index)
|
||||||
|
? isDark.value
|
||||||
|
? "rgba(255, 255, 255, 0.85)"
|
||||||
|
: "rgba(0,0,0,.88)"
|
||||||
|
: ""
|
||||||
|
}}
|
||||||
|
onMouseenter={event => handleMouseenter({ option, index }, event)}
|
||||||
|
onMouseleave={event => handleMouseleave({ option, index }, event)}
|
||||||
|
onClick={event => handleChange({ option, index }, event)}
|
||||||
|
>
|
||||||
|
<input type="radio" name="segmented" />
|
||||||
|
<div
|
||||||
|
class="pure-segmented-item-label"
|
||||||
|
v-tippy={{
|
||||||
|
content: option?.tip,
|
||||||
|
zIndex: 41000
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{option.icon && !isFunction(option.label) ? (
|
||||||
|
<span
|
||||||
|
class="pure-segmented-item-icon"
|
||||||
|
style={{ marginRight: option.label ? "6px" : 0 }}
|
||||||
|
>
|
||||||
|
{h(
|
||||||
|
useRenderIcon(option.icon, {
|
||||||
|
...option?.iconAttrs
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
{option.label ? (
|
||||||
|
isFunction(option.label) ? (
|
||||||
|
h(option.label)
|
||||||
|
) : (
|
||||||
|
<span>{option.label}</span>
|
||||||
|
)
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return () => (
|
||||||
|
<div class="pure-segmented">
|
||||||
|
<div class="pure-segmented-group">
|
||||||
|
<div
|
||||||
|
class="pure-segmented-item-selected"
|
||||||
|
style={{
|
||||||
|
width: `${width.value}px`,
|
||||||
|
transform: `translateX(${translateX.value}px)`,
|
||||||
|
display: initStatus.value ? "block" : "none"
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
{rendLabel()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
20
src/components/ReSegmented/src/type.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import type { VNode, Component } from "vue";
|
||||||
|
import type { iconType } from "@/components/ReIcon/src/types.ts";
|
||||||
|
|
||||||
|
export interface OptionsType {
|
||||||
|
/** 文字 */
|
||||||
|
label?: string | (() => VNode | Component);
|
||||||
|
/**
|
||||||
|
* @description 图标,采用平台内置的 `useRenderIcon` 函数渲染
|
||||||
|
* @see {@link 用法参考 https://yiming_chang.gitee.io/pure-admin-doc/pages/icon/#%E9%80%9A%E7%94%A8%E5%9B%BE%E6%A0%87-userendericon-hooks }
|
||||||
|
*/
|
||||||
|
icon?: string | Component;
|
||||||
|
/** 图标属性、样式配置 */
|
||||||
|
iconAttrs?: iconType;
|
||||||
|
/** 值 */
|
||||||
|
value?: any;
|
||||||
|
/** 是否禁用 */
|
||||||
|
disabled?: boolean;
|
||||||
|
/** `tooltip` 提示 */
|
||||||
|
tip?: string;
|
||||||
|
}
|
7
src/components/ReText/index.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import reText from "./src/index.vue";
|
||||||
|
import { withInstall } from "@pureadmin/utils";
|
||||||
|
|
||||||
|
/** 支持`Tooltip`提示的文本省略组件 */
|
||||||
|
export const ReText = withInstall(reText);
|
||||||
|
|
||||||
|
export default ReText;
|
62
src/components/ReText/src/index.vue
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { h, onMounted, ref, useSlots } from "vue";
|
||||||
|
import { useTippy, type TippyOptions } from "vue-tippy";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
// 行数
|
||||||
|
lineClamp: {
|
||||||
|
type: [String, Number]
|
||||||
|
},
|
||||||
|
tippyProps: {
|
||||||
|
type: Object as PropType<TippyOptions>,
|
||||||
|
default: () => ({})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const $slots = useSlots();
|
||||||
|
|
||||||
|
const textRef = ref();
|
||||||
|
const tippyFunc = ref();
|
||||||
|
|
||||||
|
const isTextEllipsis = (el: HTMLElement) => {
|
||||||
|
if (!props.lineClamp) {
|
||||||
|
// 单行省略判断
|
||||||
|
return el.scrollWidth > el.clientWidth;
|
||||||
|
} else {
|
||||||
|
// 多行省略判断
|
||||||
|
return el.scrollHeight > el.clientHeight;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getTippyProps = () => ({
|
||||||
|
content: h($slots.content || $slots.default),
|
||||||
|
...props.tippyProps
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleHover(event: MouseEvent) {
|
||||||
|
if (isTextEllipsis(event.target as HTMLElement)) {
|
||||||
|
tippyFunc.value.setProps(getTippyProps());
|
||||||
|
tippyFunc.value.enable();
|
||||||
|
} else {
|
||||||
|
tippyFunc.value.disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
tippyFunc.value = useTippy(textRef.value?.$el, getTippyProps());
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-text
|
||||||
|
v-bind="{
|
||||||
|
truncated: !lineClamp,
|
||||||
|
lineClamp,
|
||||||
|
...$attrs
|
||||||
|
}"
|
||||||
|
ref="textRef"
|
||||||
|
@mouseover.self="handleHover"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</el-text>
|
||||||
|
</template>
|
@ -1,4 +1,4 @@
|
|||||||
import { App } from "vue";
|
import type { App } from "vue";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
let config: object = {};
|
let config: object = {};
|
||||||
@ -8,7 +8,7 @@ const setConfig = (cfg?: unknown) => {
|
|||||||
config = Object.assign(config, cfg);
|
config = Object.assign(config, cfg);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getConfig = (key?: string): ServerConfigs => {
|
const getConfig = (key?: string): PlatformConfigs => {
|
||||||
if (typeof key === "string") {
|
if (typeof key === "string") {
|
||||||
const arr = key.split(".");
|
const arr = key.split(".");
|
||||||
if (arr && arr.length) {
|
if (arr && arr.length) {
|
||||||
@ -27,11 +27,11 @@ const getConfig = (key?: string): ServerConfigs => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** 获取项目动态全局配置 */
|
/** 获取项目动态全局配置 */
|
||||||
export const getServerConfig = async (app: App): Promise<undefined> => {
|
export const getPlatformConfig = async (app: App): Promise<undefined> => {
|
||||||
app.config.globalProperties.$config = getConfig();
|
app.config.globalProperties.$config = getConfig();
|
||||||
return axios({
|
return axios({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: `${VITE_PUBLIC_PATH}serverConfig.json`
|
url: `${VITE_PUBLIC_PATH}platform-config.json`
|
||||||
})
|
})
|
||||||
.then(({ data: config }) => {
|
.then(({ data: config }) => {
|
||||||
let $config = app.config.globalProperties.$config;
|
let $config = app.config.globalProperties.$config;
|
||||||
@ -45,7 +45,7 @@ export const getServerConfig = async (app: App): Promise<undefined> => {
|
|||||||
return $config;
|
return $config;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
throw "请在public文件夹下添加serverConfig.json配置文件";
|
throw "请在public文件夹下添加platform-config.json配置文件";
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,3 +2,4 @@ export * from "./auth";
|
|||||||
export * from "./copy";
|
export * from "./copy";
|
||||||
export * from "./longpress";
|
export * from "./longpress";
|
||||||
export * from "./optimize";
|
export * from "./optimize";
|
||||||
|
export * from "./ripple";
|
||||||
|
48
src/directives/ripple/index.scss
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* stylelint-disable-next-line scss/dollar-variable-colon-space-after */
|
||||||
|
$ripple-animation-transition-in:
|
||||||
|
transform 0.4s cubic-bezier(0, 0, 0.2, 1),
|
||||||
|
opacity 0.2s cubic-bezier(0, 0, 0.2, 1) !default;
|
||||||
|
$ripple-animation-transition-out: opacity 0.5s cubic-bezier(0, 0, 0.2, 1) !default;
|
||||||
|
$ripple-animation-visible-opacity: 0.25 !default;
|
||||||
|
|
||||||
|
.v-ripple {
|
||||||
|
&__container {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
pointer-events: none;
|
||||||
|
border-radius: inherit;
|
||||||
|
contain: strict;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__animation {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
pointer-events: none;
|
||||||
|
background: currentcolor;
|
||||||
|
border-radius: 50%;
|
||||||
|
opacity: 0;
|
||||||
|
will-change: transform, opacity;
|
||||||
|
|
||||||
|
&--enter {
|
||||||
|
opacity: 0;
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--in {
|
||||||
|
opacity: $ripple-animation-visible-opacity;
|
||||||
|
transition: $ripple-animation-transition-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--out {
|
||||||
|
opacity: 0;
|
||||||
|
transition: $ripple-animation-transition-out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
234
src/directives/ripple/index.ts
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
import "./index.scss";
|
||||||
|
import { isObject } from "@pureadmin/utils";
|
||||||
|
import type { Directive, DirectiveBinding } from "vue";
|
||||||
|
|
||||||
|
interface RippleOptions {
|
||||||
|
class?: string;
|
||||||
|
center?: boolean;
|
||||||
|
circle?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RippleDirectiveBinding
|
||||||
|
extends Omit<DirectiveBinding, "modifiers" | "value"> {
|
||||||
|
value?: boolean | { class: string };
|
||||||
|
modifiers: {
|
||||||
|
center?: boolean;
|
||||||
|
circle?: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function transform(el: HTMLElement, value: string) {
|
||||||
|
el.style.transform = value;
|
||||||
|
el.style.webkitTransform = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
const calculate = (
|
||||||
|
e: PointerEvent,
|
||||||
|
el: HTMLElement,
|
||||||
|
value: RippleOptions = {}
|
||||||
|
) => {
|
||||||
|
const offset = el.getBoundingClientRect();
|
||||||
|
|
||||||
|
// 获取点击位置距离 el 的垂直和水平距离
|
||||||
|
let localX = e.clientX - offset.left;
|
||||||
|
let localY = e.clientY - offset.top;
|
||||||
|
|
||||||
|
let radius = 0;
|
||||||
|
let scale = 0.3;
|
||||||
|
// 计算点击位置到 el 顶点最远距离,即为圆的最大半径(勾股定理)
|
||||||
|
if (el._ripple?.circle) {
|
||||||
|
scale = 0.15;
|
||||||
|
radius = el.clientWidth / 2;
|
||||||
|
radius = value.center
|
||||||
|
? radius
|
||||||
|
: radius + Math.sqrt((localX - radius) ** 2 + (localY - radius) ** 2) / 4;
|
||||||
|
} else {
|
||||||
|
radius = Math.sqrt(el.clientWidth ** 2 + el.clientHeight ** 2) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 中心点坐标
|
||||||
|
const centerX = `${(el.clientWidth - radius * 2) / 2}px`;
|
||||||
|
const centerY = `${(el.clientHeight - radius * 2) / 2}px`;
|
||||||
|
|
||||||
|
// 点击位置坐标
|
||||||
|
const x = value.center ? centerX : `${localX - radius}px`;
|
||||||
|
const y = value.center ? centerY : `${localY - radius}px`;
|
||||||
|
|
||||||
|
return { radius, scale, x, y, centerX, centerY };
|
||||||
|
};
|
||||||
|
|
||||||
|
const ripples = {
|
||||||
|
show(e: PointerEvent, el: HTMLElement, value: RippleOptions = {}) {
|
||||||
|
if (!el?._ripple?.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建 ripple 元素和 ripple 父元素
|
||||||
|
const container = document.createElement("span");
|
||||||
|
const animation = document.createElement("span");
|
||||||
|
|
||||||
|
container.appendChild(animation);
|
||||||
|
container.className = "v-ripple__container";
|
||||||
|
|
||||||
|
if (value.class) {
|
||||||
|
container.className += ` ${value.class}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { radius, scale, x, y, centerX, centerY } = calculate(e, el, value);
|
||||||
|
|
||||||
|
// ripple 圆大小
|
||||||
|
const size = `${radius * 2}px`;
|
||||||
|
|
||||||
|
animation.className = "v-ripple__animation";
|
||||||
|
animation.style.width = size;
|
||||||
|
animation.style.height = size;
|
||||||
|
|
||||||
|
el.appendChild(container);
|
||||||
|
|
||||||
|
// 获取目标元素样式表
|
||||||
|
const computed = window.getComputedStyle(el);
|
||||||
|
// 防止 position 被覆盖导致 ripple 位置有问题
|
||||||
|
if (computed && computed.position === "static") {
|
||||||
|
el.style.position = "relative";
|
||||||
|
el.dataset.previousPosition = "static";
|
||||||
|
}
|
||||||
|
|
||||||
|
animation.classList.add("v-ripple__animation--enter");
|
||||||
|
animation.classList.add("v-ripple__animation--visible");
|
||||||
|
transform(
|
||||||
|
animation,
|
||||||
|
`translate(${x}, ${y}) scale3d(${scale},${scale},${scale})`
|
||||||
|
);
|
||||||
|
animation.dataset.activated = String(performance.now());
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
animation.classList.remove("v-ripple__animation--enter");
|
||||||
|
animation.classList.add("v-ripple__animation--in");
|
||||||
|
transform(animation, `translate(${centerX}, ${centerY}) scale3d(1,1,1)`);
|
||||||
|
}, 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
hide(el: HTMLElement | null) {
|
||||||
|
if (!el?._ripple?.enabled) return;
|
||||||
|
|
||||||
|
const ripples = el.getElementsByClassName("v-ripple__animation");
|
||||||
|
|
||||||
|
if (ripples.length === 0) return;
|
||||||
|
const animation = ripples[ripples.length - 1] as HTMLElement;
|
||||||
|
|
||||||
|
if (animation.dataset.isHiding) return;
|
||||||
|
else animation.dataset.isHiding = "true";
|
||||||
|
|
||||||
|
const diff = performance.now() - Number(animation.dataset.activated);
|
||||||
|
const delay = Math.max(250 - diff, 0);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
animation.classList.remove("v-ripple__animation--in");
|
||||||
|
animation.classList.add("v-ripple__animation--out");
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
const ripples = el.getElementsByClassName("v-ripple__animation");
|
||||||
|
if (ripples.length === 1 && el.dataset.previousPosition) {
|
||||||
|
el.style.position = el.dataset.previousPosition;
|
||||||
|
delete el.dataset.previousPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (animation.parentNode?.parentNode === el)
|
||||||
|
el.removeChild(animation.parentNode);
|
||||||
|
}, 300);
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function isRippleEnabled(value: any): value is true {
|
||||||
|
return typeof value === "undefined" || !!value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rippleShow(e: PointerEvent) {
|
||||||
|
const value: RippleOptions = {};
|
||||||
|
const element = e.currentTarget as HTMLElement | undefined;
|
||||||
|
|
||||||
|
if (!element?._ripple || element._ripple.touched) return;
|
||||||
|
|
||||||
|
value.center = element._ripple.centered;
|
||||||
|
if (element._ripple.class) {
|
||||||
|
value.class = element._ripple.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
ripples.show(e, element, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rippleHide(e: Event) {
|
||||||
|
const element = e.currentTarget as HTMLElement | null;
|
||||||
|
if (!element?._ripple) return;
|
||||||
|
|
||||||
|
window.setTimeout(() => {
|
||||||
|
if (element._ripple) {
|
||||||
|
element._ripple.touched = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ripples.hide(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateRipple(
|
||||||
|
el: HTMLElement,
|
||||||
|
binding: RippleDirectiveBinding,
|
||||||
|
wasEnabled: boolean
|
||||||
|
) {
|
||||||
|
const { value, modifiers } = binding;
|
||||||
|
const enabled = isRippleEnabled(value);
|
||||||
|
if (!enabled) {
|
||||||
|
ripples.hide(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
el._ripple = el._ripple ?? {};
|
||||||
|
el._ripple.enabled = enabled;
|
||||||
|
el._ripple.centered = modifiers.center;
|
||||||
|
el._ripple.circle = modifiers.circle;
|
||||||
|
if (isObject(value) && value.class) {
|
||||||
|
el._ripple.class = value.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enabled && !wasEnabled) {
|
||||||
|
el.addEventListener("pointerdown", rippleShow);
|
||||||
|
el.addEventListener("pointerup", rippleHide);
|
||||||
|
} else if (!enabled && wasEnabled) {
|
||||||
|
removeListeners(el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeListeners(el: HTMLElement) {
|
||||||
|
el.removeEventListener("pointerdown", rippleShow);
|
||||||
|
el.removeEventListener("pointerup", rippleHide);
|
||||||
|
}
|
||||||
|
|
||||||
|
function mounted(el: HTMLElement, binding: RippleDirectiveBinding) {
|
||||||
|
updateRipple(el, binding, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function unmounted(el: HTMLElement) {
|
||||||
|
delete el._ripple;
|
||||||
|
removeListeners(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updated(el: HTMLElement, binding: RippleDirectiveBinding) {
|
||||||
|
if (binding.value === binding.oldValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wasEnabled = isRippleEnabled(binding.oldValue);
|
||||||
|
updateRipple(el, binding, wasEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 指令 v-ripple
|
||||||
|
* @use 用法如下
|
||||||
|
* 1. v-ripple 代表启用基本的 ripple 功能
|
||||||
|
* 2. v-ripple="{ class: 'text-red' }" 代表自定义 ripple 颜色,支持 tailwindcss,生效样式是 color
|
||||||
|
* 3. v-ripple.center 代表从中心扩散
|
||||||
|
*/
|
||||||
|
export const Ripple: Directive = {
|
||||||
|
mounted,
|
||||||
|
unmounted,
|
||||||
|
updated
|
||||||
|
};
|
@ -1,5 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import Footer from "./footer/index.vue";
|
||||||
import { useGlobal } from "@pureadmin/utils";
|
import { useGlobal } from "@pureadmin/utils";
|
||||||
|
import KeepAliveFrame from "./keepAliveFrame/index.vue";
|
||||||
import backTop from "@/assets/svg/back_top.svg?component";
|
import backTop from "@/assets/svg/back_top.svg?component";
|
||||||
import { h, computed, Transition, defineComponent } from "vue";
|
import { h, computed, Transition, defineComponent } from "vue";
|
||||||
import { usePermissionStoreHook } from "@/store/modules/permission";
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||||
@ -10,7 +12,7 @@ const props = defineProps({
|
|||||||
|
|
||||||
const { $storage, $config } = useGlobal<GlobalPropertiesApi>();
|
const { $storage, $config } = useGlobal<GlobalPropertiesApi>();
|
||||||
|
|
||||||
const keepAlive = computed(() => {
|
const isKeepAlive = computed(() => {
|
||||||
return $config?.KeepAlive;
|
return $config?.KeepAlive;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -24,6 +26,10 @@ const hideTabs = computed(() => {
|
|||||||
return $storage?.configure.hideTabs;
|
return $storage?.configure.hideTabs;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const hideFooter = computed(() => {
|
||||||
|
return $storage?.configure.hideFooter;
|
||||||
|
});
|
||||||
|
|
||||||
const layout = computed(() => {
|
const layout = computed(() => {
|
||||||
return $storage?.layout.layout === "vertical";
|
return $storage?.layout.layout === "vertical";
|
||||||
});
|
});
|
||||||
@ -32,30 +38,40 @@ const getSectionStyle = computed(() => {
|
|||||||
return [
|
return [
|
||||||
hideTabs.value && layout ? "padding-top: 48px;" : "",
|
hideTabs.value && layout ? "padding-top: 48px;" : "",
|
||||||
!hideTabs.value && layout ? "padding-top: 85px;" : "",
|
!hideTabs.value && layout ? "padding-top: 85px;" : "",
|
||||||
hideTabs.value && !layout.value ? "padding-top: 48px" : "",
|
hideTabs.value && !layout.value ? "padding-top: 48px;" : "",
|
||||||
!hideTabs.value && !layout.value ? "padding-top: 85px;" : "",
|
!hideTabs.value && !layout.value ? "padding-top: 85px;" : "",
|
||||||
props.fixedHeader ? "" : "padding-top: 0;"
|
props.fixedHeader
|
||||||
|
? ""
|
||||||
|
: `padding-top: 0;${
|
||||||
|
hideTabs.value
|
||||||
|
? "min-height: calc(100vh - 48px);"
|
||||||
|
: "min-height: calc(100vh - 86px);"
|
||||||
|
}`
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
const transitionMain = defineComponent({
|
const transitionMain = defineComponent({
|
||||||
|
props: {
|
||||||
|
route: {
|
||||||
|
type: undefined,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
render() {
|
render() {
|
||||||
|
const transitionName =
|
||||||
|
transitions.value(this.route)?.name || "fade-transform";
|
||||||
|
const enterTransition = transitions.value(this.route)?.enterTransition;
|
||||||
|
const leaveTransition = transitions.value(this.route)?.leaveTransition;
|
||||||
return h(
|
return h(
|
||||||
Transition,
|
Transition,
|
||||||
{
|
{
|
||||||
name:
|
name: enterTransition ? "pure-classes-transition" : transitionName,
|
||||||
transitions.value(this.route) &&
|
enterActiveClass: enterTransition
|
||||||
this.route.meta.transition.enterTransition
|
? `animate__animated ${enterTransition}`
|
||||||
? "pure-classes-transition"
|
: undefined,
|
||||||
: (transitions.value(this.route) &&
|
leaveActiveClass: leaveTransition
|
||||||
this.route.meta.transition.name) ||
|
? `animate__animated ${leaveTransition}`
|
||||||
"fade-transform",
|
: undefined,
|
||||||
enterActiveClass:
|
|
||||||
transitions.value(this.route) &&
|
|
||||||
`animate__animated ${this.route.meta.transition.enterTransition}`,
|
|
||||||
leaveActiveClass:
|
|
||||||
transitions.value(this.route) &&
|
|
||||||
`animate__animated ${this.route.meta.transition.leaveTransition}`,
|
|
||||||
mode: "out-in",
|
mode: "out-in",
|
||||||
appear: true
|
appear: true
|
||||||
},
|
},
|
||||||
@ -63,12 +79,6 @@ const transitionMain = defineComponent({
|
|||||||
default: () => [this.$slots.default()]
|
default: () => [this.$slots.default()]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
|
||||||
props: {
|
|
||||||
route: {
|
|
||||||
type: undefined,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -80,51 +90,80 @@ const transitionMain = defineComponent({
|
|||||||
>
|
>
|
||||||
<router-view>
|
<router-view>
|
||||||
<template #default="{ Component, route }">
|
<template #default="{ Component, route }">
|
||||||
<el-scrollbar v-if="props.fixedHeader">
|
<KeepAliveFrame :currComp="Component" :currRoute="route">
|
||||||
<el-backtop title="回到顶部" target=".app-main .el-scrollbar__wrap">
|
<template #default="{ Comp, fullPath, frameInfo }">
|
||||||
<backTop />
|
<el-scrollbar
|
||||||
</el-backtop>
|
v-if="props.fixedHeader"
|
||||||
<transitionMain :route="route">
|
:wrap-style="{
|
||||||
<keep-alive
|
display: 'flex',
|
||||||
v-if="keepAlive"
|
'flex-wrap': 'wrap'
|
||||||
:include="usePermissionStoreHook().cachePageList"
|
}"
|
||||||
|
:view-style="{
|
||||||
|
display: 'flex',
|
||||||
|
flex: 'auto',
|
||||||
|
overflow: 'auto',
|
||||||
|
'flex-direction': 'column'
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
<component
|
<el-backtop
|
||||||
:is="Component"
|
title="回到顶部"
|
||||||
:key="route.fullPath"
|
target=".app-main .el-scrollbar__wrap"
|
||||||
class="main-content"
|
>
|
||||||
/>
|
<backTop />
|
||||||
</keep-alive>
|
</el-backtop>
|
||||||
<component
|
<div class="grow">
|
||||||
v-else
|
<transitionMain :route="route">
|
||||||
:is="Component"
|
<keep-alive
|
||||||
:key="route.fullPath"
|
v-if="isKeepAlive"
|
||||||
class="main-content"
|
:include="usePermissionStoreHook().cachePageList"
|
||||||
/>
|
>
|
||||||
</transitionMain>
|
<component
|
||||||
</el-scrollbar>
|
:is="Comp"
|
||||||
<div v-else>
|
:key="fullPath"
|
||||||
<transitionMain :route="route">
|
:frameInfo="frameInfo"
|
||||||
<keep-alive
|
class="main-content"
|
||||||
v-if="keepAlive"
|
/>
|
||||||
:include="usePermissionStoreHook().cachePageList"
|
</keep-alive>
|
||||||
>
|
<component
|
||||||
<component
|
:is="Comp"
|
||||||
:is="Component"
|
v-else
|
||||||
:key="route.fullPath"
|
:key="fullPath"
|
||||||
class="main-content"
|
:frameInfo="frameInfo"
|
||||||
/>
|
class="main-content"
|
||||||
</keep-alive>
|
/>
|
||||||
<component
|
</transitionMain>
|
||||||
v-else
|
</div>
|
||||||
:is="Component"
|
<Footer v-if="!hideFooter" />
|
||||||
:key="route.fullPath"
|
</el-scrollbar>
|
||||||
class="main-content"
|
<div v-else class="grow">
|
||||||
/>
|
<transitionMain :route="route">
|
||||||
</transitionMain>
|
<keep-alive
|
||||||
</div>
|
v-if="isKeepAlive"
|
||||||
|
:include="usePermissionStoreHook().cachePageList"
|
||||||
|
>
|
||||||
|
<component
|
||||||
|
:is="Comp"
|
||||||
|
:key="fullPath"
|
||||||
|
:frameInfo="frameInfo"
|
||||||
|
class="main-content"
|
||||||
|
/>
|
||||||
|
</keep-alive>
|
||||||
|
<component
|
||||||
|
:is="Comp"
|
||||||
|
v-else
|
||||||
|
:key="fullPath"
|
||||||
|
:frameInfo="frameInfo"
|
||||||
|
class="main-content"
|
||||||
|
/>
|
||||||
|
</transitionMain>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</KeepAliveFrame>
|
||||||
</template>
|
</template>
|
||||||
</router-view>
|
</router-view>
|
||||||
|
|
||||||
|
<!-- 页脚 -->
|
||||||
|
<Footer v-if="!hideFooter && !props.fixedHeader" />
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -138,8 +177,9 @@ const transitionMain = defineComponent({
|
|||||||
|
|
||||||
.app-main-nofixed-header {
|
.app-main-nofixed-header {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 100vh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-content {
|
.main-content {
|
||||||
|
31
src/layout/components/footer/index.vue
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { getConfig } from "@/config";
|
||||||
|
|
||||||
|
const TITLE = getConfig("Title");
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<footer
|
||||||
|
class="layout-footer text-[rgba(0,0,0,0.6)] dark:text-[rgba(220,220,242,0.8)]"
|
||||||
|
>
|
||||||
|
Copyright © 2020-present
|
||||||
|
<a
|
||||||
|
class="hover:text-primary"
|
||||||
|
href="https://github.com/pure-admin"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
{{ TITLE }}
|
||||||
|
</a>
|
||||||
|
</footer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.layout-footer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0 0 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
</style>
|
79
src/layout/components/keepAliveFrame/index.vue
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { getConfig } from "@/config";
|
||||||
|
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
||||||
|
import { type Component, shallowRef, watch, computed } from "vue";
|
||||||
|
import { type RouteRecordRaw, RouteLocationNormalizedLoaded } from "vue-router";
|
||||||
|
import { useMultiFrame } from "@/layout/components/keepAliveFrame/useMultiFrame";
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
currRoute: RouteLocationNormalizedLoaded;
|
||||||
|
currComp: Component;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const compList = shallowRef([]);
|
||||||
|
const { setMap, getMap, MAP, delMap } = useMultiFrame();
|
||||||
|
|
||||||
|
const keep = computed(() => {
|
||||||
|
return (
|
||||||
|
getConfig().KeepAlive &&
|
||||||
|
props.currRoute.meta?.keepAlive &&
|
||||||
|
!!props.currRoute.meta?.frameSrc
|
||||||
|
);
|
||||||
|
});
|
||||||
|
// 避免重新渲染 frameView
|
||||||
|
const normalComp = computed(() => !keep.value && props.currComp);
|
||||||
|
|
||||||
|
watch(useMultiTagsStoreHook().multiTags, (tags: any) => {
|
||||||
|
if (!Array.isArray(tags) || !keep.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const iframeTags = tags.filter(i => i.meta?.frameSrc);
|
||||||
|
// tags必须是小于MAP,才是做了关闭动作,因为MAP插入的顺序在tags变化后发生
|
||||||
|
if (iframeTags.length < MAP.size) {
|
||||||
|
for (const i of MAP.keys()) {
|
||||||
|
if (!tags.some(s => s.path === i)) {
|
||||||
|
delMap(i);
|
||||||
|
compList.value = getMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.currRoute.fullPath,
|
||||||
|
path => {
|
||||||
|
const multiTags = useMultiTagsStoreHook().multiTags as RouteRecordRaw[];
|
||||||
|
const iframeTags = multiTags.filter(i => i.meta?.frameSrc);
|
||||||
|
if (keep.value) {
|
||||||
|
if (iframeTags.length !== MAP.size) {
|
||||||
|
const sameKey = [...MAP.keys()].find(i => path === i);
|
||||||
|
if (!sameKey) {
|
||||||
|
// 添加缓存
|
||||||
|
setMap(path, props.currComp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MAP.size > 0) {
|
||||||
|
compList.value = getMap();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<template v-for="[fullPath, Comp] in compList" :key="fullPath">
|
||||||
|
<div v-show="fullPath === props.currRoute.fullPath" class="w-full h-full">
|
||||||
|
<slot
|
||||||
|
:fullPath="fullPath"
|
||||||
|
:Comp="Comp"
|
||||||
|
:frameInfo="{ frameSrc: currRoute.meta?.frameSrc, fullPath }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div v-show="!keep" class="w-full h-full">
|
||||||
|
<slot :Comp="normalComp" :fullPath="props.currRoute.fullPath" frameInfo />
|
||||||
|
</div>
|
||||||
|
</template>
|
25
src/layout/components/keepAliveFrame/useMultiFrame.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
const MAP = new Map();
|
||||||
|
|
||||||
|
export const useMultiFrame = () => {
|
||||||
|
function setMap(path, Comp) {
|
||||||
|
MAP.set(path, Comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMap(path?) {
|
||||||
|
if (path) {
|
||||||
|
return MAP.get(path);
|
||||||
|
}
|
||||||
|
return [...MAP.entries()];
|
||||||
|
}
|
||||||
|
|
||||||
|
function delMap(path) {
|
||||||
|
MAP.delete(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
setMap,
|
||||||
|
getMap,
|
||||||
|
delMap,
|
||||||
|
MAP
|
||||||
|
};
|
||||||
|
};
|
@ -22,9 +22,7 @@ const {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div class="navbar bg-[#fff] shadow-sm shadow-[rgba(0,21,41,0.08)]">
|
||||||
class="navbar bg-[#fff] shadow-sm shadow-[rgba(0, 21, 41, 0.08)] dark:shadow-[#0d0d0d]"
|
|
||||||
>
|
|
||||||
<topCollapse
|
<topCollapse
|
||||||
v-if="device === 'mobile'"
|
v-if="device === 'mobile'"
|
||||||
class="hamburger-container"
|
class="hamburger-container"
|
||||||
@ -41,7 +39,7 @@ const {
|
|||||||
|
|
||||||
<div v-if="layout === 'vertical'" class="vertical-header-right">
|
<div v-if="layout === 'vertical'" class="vertical-header-right">
|
||||||
<!-- 菜单搜索 -->
|
<!-- 菜单搜索 -->
|
||||||
<Search />
|
<Search id="header-search" />
|
||||||
<!-- 通知 -->
|
<!-- 通知 -->
|
||||||
<Notice id="header-notice" />
|
<Notice id="header-notice" />
|
||||||
<!-- 退出登录 -->
|
<!-- 退出登录 -->
|
||||||
|
@ -4,7 +4,7 @@ export interface ListItem {
|
|||||||
datetime: string;
|
datetime: string;
|
||||||
type: string;
|
type: string;
|
||||||
description: string;
|
description: string;
|
||||||
status?: "" | "success" | "warning" | "info" | "danger";
|
status?: "primary" | "success" | "warning" | "info" | "danger";
|
||||||
extra?: string;
|
extra?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ export const noticesData: TabItem[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "3",
|
key: "3",
|
||||||
name: "代办",
|
name: "待办",
|
||||||
list: [
|
list: [
|
||||||
{
|
{
|
||||||
avatar: "",
|
avatar: "",
|
||||||
|
@ -23,8 +23,8 @@ notices.value.map(v => (noticesNum.value += v.list.length));
|
|||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-tabs
|
<el-tabs
|
||||||
:stretch="true"
|
|
||||||
v-model="activeKey"
|
v-model="activeKey"
|
||||||
|
:stretch="true"
|
||||||
class="dropdown-tabs"
|
class="dropdown-tabs"
|
||||||
:style="{ width: notices.length === 0 ? '200px' : '330px' }"
|
:style="{ width: notices.length === 0 ? '200px' : '330px' }"
|
||||||
>
|
>
|
||||||
|
@ -15,9 +15,9 @@ const props = defineProps({
|
|||||||
<div v-if="props.list.length">
|
<div v-if="props.list.length">
|
||||||
<NoticeItem
|
<NoticeItem
|
||||||
v-for="(item, index) in props.list"
|
v-for="(item, index) in props.list"
|
||||||
:noticeItem="item"
|
|
||||||
:key="index"
|
:key="index"
|
||||||
|
:noticeItem="item"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<el-empty v-else description="暂无数据" />
|
<el-empty v-else description="暂无消息" />
|
||||||
</template>
|
</template>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
import { emitter } from "@/utils/mitt";
|
import { emitter } from "@/utils/mitt";
|
||||||
import { onClickOutside } from "@vueuse/core";
|
import { onClickOutside } from "@vueuse/core";
|
||||||
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
|
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
|
||||||
|
import { useDataThemeChange } from "@/layout/hooks/useDataThemeChange";
|
||||||
import Close from "@iconify-icons/ep/close";
|
import Close from "@iconify-icons/ep/close";
|
||||||
|
|
||||||
const target = ref(null);
|
const target = ref(null);
|
||||||
@ -9,10 +10,12 @@ const show = ref<Boolean>(false);
|
|||||||
|
|
||||||
const iconClass = computed(() => {
|
const iconClass = computed(() => {
|
||||||
return [
|
return [
|
||||||
"mr-[20px]",
|
"w-[22px]",
|
||||||
|
"h-[22px]",
|
||||||
|
"flex",
|
||||||
|
"justify-center",
|
||||||
|
"items-center",
|
||||||
"outline-none",
|
"outline-none",
|
||||||
"width-[20px]",
|
|
||||||
"height-[20px]",
|
|
||||||
"rounded-[4px]",
|
"rounded-[4px]",
|
||||||
"cursor-pointer",
|
"cursor-pointer",
|
||||||
"transition-colors",
|
"transition-colors",
|
||||||
@ -22,6 +25,8 @@ const iconClass = computed(() => {
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { onReset } = useDataThemeChange();
|
||||||
|
|
||||||
onClickOutside(target, (event: any) => {
|
onClickOutside(target, (event: any) => {
|
||||||
if (event.clientX > target.value.offsetLeft) return;
|
if (event.clientX > target.value.offsetLeft) return;
|
||||||
show.value = false;
|
show.value = false;
|
||||||
@ -40,40 +45,60 @@ onBeforeUnmount(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="{ show: show }" class="right-panel-container">
|
<div :class="{ show }">
|
||||||
<div class="right-panel-background" />
|
<div class="right-panel-background" />
|
||||||
<div ref="target" class="right-panel bg-bg_color">
|
<div ref="target" class="right-panel bg-bg_color">
|
||||||
<div class="right-panel-items">
|
<div
|
||||||
<div class="project-configuration">
|
class="project-configuration border-b-[1px] border-solid border-[var(--pure-border-color)]"
|
||||||
<h4 class="dark:text-white">项目配置</h4>
|
>
|
||||||
<span title="关闭配置" :class="iconClass">
|
<h4 class="dark:text-white">项目配置</h4>
|
||||||
<IconifyIconOffline
|
<span
|
||||||
class="dark:text-white"
|
v-tippy="{
|
||||||
width="20px"
|
content: '关闭配置',
|
||||||
height="20px"
|
placement: 'bottom-start',
|
||||||
:icon="Close"
|
zIndex: 41000
|
||||||
@click="show = !show"
|
}"
|
||||||
/>
|
:class="iconClass"
|
||||||
</span>
|
>
|
||||||
</div>
|
<IconifyIconOffline
|
||||||
<div
|
class="dark:text-white"
|
||||||
class="border-b-[1px] border-solid border-[#dcdfe6] dark:border-[#303030]"
|
width="18px"
|
||||||
/>
|
height="18px"
|
||||||
|
:icon="Close"
|
||||||
|
@click="show = !show"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<el-scrollbar>
|
||||||
<slot />
|
<slot />
|
||||||
|
</el-scrollbar>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="flex justify-end p-3 border-t-[1px] border-solid border-[var(--pure-border-color)]"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
v-tippy="{
|
||||||
|
content: '清空缓存并返回登录页',
|
||||||
|
placement: 'left-start',
|
||||||
|
zIndex: 41000
|
||||||
|
}"
|
||||||
|
type="danger"
|
||||||
|
text
|
||||||
|
bg
|
||||||
|
@click="onReset"
|
||||||
|
>
|
||||||
|
清空缓存
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
|
||||||
.showright-panel {
|
|
||||||
position: relative;
|
|
||||||
width: calc(100% - 15px);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
:deep(.el-scrollbar) {
|
||||||
|
height: calc(100vh - 110px);
|
||||||
|
}
|
||||||
|
|
||||||
.right-panel-background {
|
.right-panel-background {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -90,8 +115,7 @@ onBeforeUnmount(() => {
|
|||||||
right: 0;
|
right: 0;
|
||||||
z-index: 40000;
|
z-index: 40000;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 315px;
|
max-width: 280px;
|
||||||
height: 100vh;
|
|
||||||
box-shadow: 0 0 15px 0 rgb(0 0 0 / 5%);
|
box-shadow: 0 0 15px 0 rgb(0 0 0 / 5%);
|
||||||
transition: all 0.25s cubic-bezier(0.7, 0.3, 0.1, 1);
|
transition: all 0.25s cubic-bezier(0.7, 0.3, 0.1, 1);
|
||||||
transform: translate(100%);
|
transform: translate(100%);
|
||||||
@ -112,47 +136,10 @@ onBeforeUnmount(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.handle-button {
|
|
||||||
position: absolute;
|
|
||||||
top: 45%;
|
|
||||||
left: -48px;
|
|
||||||
z-index: 0;
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
font-size: 24px;
|
|
||||||
line-height: 48px;
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
pointer-events: auto;
|
|
||||||
cursor: pointer;
|
|
||||||
background: rgb(24 144 255);
|
|
||||||
border-radius: 6px 0 0 6px !important;
|
|
||||||
|
|
||||||
i {
|
|
||||||
font-size: 24px;
|
|
||||||
line-height: 48px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.right-panel-items {
|
|
||||||
height: calc(100vh - 60px);
|
|
||||||
margin-top: 60px;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.project-configuration {
|
.project-configuration {
|
||||||
position: fixed;
|
|
||||||
top: 15px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
width: 100%;
|
padding: 14px 20px;
|
||||||
height: 30px;
|
|
||||||
margin-left: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.el-divider--horizontal) {
|
|
||||||
width: 90%;
|
|
||||||
margin: 20px auto 0;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import ArrowUpLine from "@iconify-icons/ri/arrow-up-line";
|
|
||||||
import ArrowDownLine from "@iconify-icons/ri/arrow-down-line";
|
|
||||||
import { useNav } from "@/layout/hooks/useNav";
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
import mdiKeyboardEsc from "@/assets/svg/keyboard_esc.svg?component";
|
import mdiKeyboardEsc from "@/assets/svg/keyboard_esc.svg?component";
|
||||||
import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
|
import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
|
||||||
|
import ArrowUpLine from "@iconify-icons/ri/arrow-up-line";
|
||||||
|
import ArrowDownLine from "@iconify-icons/ri/arrow-down-line";
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{ total: number }>(), {
|
const props = withDefaults(defineProps<{ total: number }>(), {
|
||||||
total: 0
|
total: 0
|
||||||
@ -50,7 +50,9 @@ const { device } = useNav();
|
|||||||
padding: 2px;
|
padding: 2px;
|
||||||
margin-right: 3px;
|
margin-right: 3px;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
box-shadow: inset 0 -2px #cdcde6, inset 0 0 1px 1px #fff,
|
box-shadow:
|
||||||
|
inset 0 -2px #cdcde6,
|
||||||
|
inset 0 0 1px 1px #fff,
|
||||||
0 1px 2px 1px #1e235a66;
|
0 1px 2px 1px #1e235a66;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
198
src/layout/components/search/components/SearchHistory.vue
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import Sortable from "sortablejs";
|
||||||
|
import SearchHistoryItem from "./SearchHistoryItem.vue";
|
||||||
|
import type { optionsItem, dragItem, Props } from "../types";
|
||||||
|
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
|
||||||
|
import { useResizeObserver, isArray, delay } from "@pureadmin/utils";
|
||||||
|
import { ref, watch, nextTick, computed, getCurrentInstance } from "vue";
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: "update:value", val: string): void;
|
||||||
|
(e: "enter"): void;
|
||||||
|
(e: "collect", val: optionsItem): void;
|
||||||
|
(e: "delete", val: optionsItem): void;
|
||||||
|
(e: "drag", val: dragItem): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const historyRef = ref();
|
||||||
|
const innerHeight = ref();
|
||||||
|
/** 判断是否停止鼠标移入事件处理 */
|
||||||
|
const stopMouseEvent = ref(false);
|
||||||
|
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
const instance = getCurrentInstance()!;
|
||||||
|
const props = withDefaults(defineProps<Props>(), {});
|
||||||
|
|
||||||
|
const itemStyle = computed(() => {
|
||||||
|
return item => {
|
||||||
|
return {
|
||||||
|
background:
|
||||||
|
item?.path === active.value ? useEpThemeStoreHook().epThemeColor : "",
|
||||||
|
color: item.path === active.value ? "#fff" : "",
|
||||||
|
fontSize: item.path === active.value ? "16px" : "14px"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const titleStyle = computed(() => {
|
||||||
|
return {
|
||||||
|
color: useEpThemeStoreHook().epThemeColor,
|
||||||
|
fontWeight: 500
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const active = computed({
|
||||||
|
get() {
|
||||||
|
return props.value;
|
||||||
|
},
|
||||||
|
set(val: string) {
|
||||||
|
emit("update:value", val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
newValue => {
|
||||||
|
if (newValue) {
|
||||||
|
if (stopMouseEvent.value) {
|
||||||
|
delay(100).then(() => (stopMouseEvent.value = false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const historyList = computed(() => {
|
||||||
|
return props.options.filter(item => item.type === "history");
|
||||||
|
});
|
||||||
|
|
||||||
|
const collectList = computed(() => {
|
||||||
|
return props.options.filter(item => item.type === "collect");
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleCollect(item) {
|
||||||
|
emit("collect", item);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDelete(item) {
|
||||||
|
stopMouseEvent.value = true;
|
||||||
|
emit("delete", item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 鼠标移入 */
|
||||||
|
async function handleMouse(item) {
|
||||||
|
if (!stopMouseEvent.value) active.value = item.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleTo() {
|
||||||
|
emit("enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
function resizeResult() {
|
||||||
|
// el-scrollbar max-height="calc(90vh - 140px)"
|
||||||
|
innerHeight.value = window.innerHeight - window.innerHeight / 10 - 140;
|
||||||
|
}
|
||||||
|
|
||||||
|
useResizeObserver(historyRef, resizeResult);
|
||||||
|
|
||||||
|
function handleScroll(index: number) {
|
||||||
|
const curInstance = instance?.proxy?.$refs[`historyItemRef${index}`];
|
||||||
|
if (!curInstance) return 0;
|
||||||
|
const curRef = isArray(curInstance)
|
||||||
|
? (curInstance[0] as ElRef)
|
||||||
|
: (curInstance as ElRef);
|
||||||
|
const scrollTop = curRef.offsetTop + 128; // 128 两个history-item(56px+56px=112px)高度加上下margin(8px+8px=16px)
|
||||||
|
return scrollTop > innerHeight.value ? scrollTop - innerHeight.value : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleChangeIndex = (evt): void => {
|
||||||
|
emit("drag", { oldIndex: evt.oldIndex, newIndex: evt.newIndex });
|
||||||
|
};
|
||||||
|
|
||||||
|
let sortableInstance = null;
|
||||||
|
|
||||||
|
watch(
|
||||||
|
collectList,
|
||||||
|
val => {
|
||||||
|
if (val.length > 1) {
|
||||||
|
nextTick(() => {
|
||||||
|
const wrapper: HTMLElement =
|
||||||
|
document.querySelector(".collect-container");
|
||||||
|
if (!wrapper || sortableInstance) return;
|
||||||
|
sortableInstance = Sortable.create(wrapper, {
|
||||||
|
animation: 160,
|
||||||
|
onStart: event => {
|
||||||
|
event.item.style.cursor = "move";
|
||||||
|
},
|
||||||
|
onEnd: event => {
|
||||||
|
event.item.style.cursor = "pointer";
|
||||||
|
},
|
||||||
|
onUpdate: handleChangeIndex
|
||||||
|
});
|
||||||
|
resizeResult();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
defineExpose({ handleScroll });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div ref="historyRef" class="history">
|
||||||
|
<template v-if="historyList.length">
|
||||||
|
<div :style="titleStyle">搜索历史</div>
|
||||||
|
<div
|
||||||
|
v-for="(item, index) in historyList"
|
||||||
|
:key="item.path"
|
||||||
|
:ref="'historyItemRef' + index"
|
||||||
|
class="history-item dark:bg-[#1d1d1d]"
|
||||||
|
:style="itemStyle(item)"
|
||||||
|
@click="handleTo"
|
||||||
|
@mouseenter="handleMouse(item)"
|
||||||
|
>
|
||||||
|
<SearchHistoryItem
|
||||||
|
:item="item"
|
||||||
|
@delete-item="handleDelete"
|
||||||
|
@collect-item="handleCollect"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-if="collectList.length">
|
||||||
|
<div :style="titleStyle">
|
||||||
|
收藏{{ collectList.length > 1 ? "(可拖拽排序)" : "" }}
|
||||||
|
</div>
|
||||||
|
<div class="collect-container">
|
||||||
|
<div
|
||||||
|
v-for="(item, index) in collectList"
|
||||||
|
:key="item.path"
|
||||||
|
:ref="'historyItemRef' + (index + historyList.length)"
|
||||||
|
class="history-item dark:bg-[#1d1d1d]"
|
||||||
|
:style="itemStyle(item)"
|
||||||
|
@click="handleTo"
|
||||||
|
@mouseenter="handleMouse(item)"
|
||||||
|
>
|
||||||
|
<SearchHistoryItem :item="item" @delete-item="handleDelete" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.history {
|
||||||
|
padding-bottom: 12px;
|
||||||
|
|
||||||
|
&-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 56px;
|
||||||
|
padding: 14px;
|
||||||
|
margin: 8px auto 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
border: 0.1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: font-size 0.16s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -0,0 +1,52 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { optionsItem } from "../types";
|
||||||
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
|
import Star from "@iconify-icons/ep/star";
|
||||||
|
import Close from "@iconify-icons/ep/close";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
item: optionsItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: "collectItem", val: optionsItem): void;
|
||||||
|
(e: "deleteItem", val: optionsItem): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
withDefaults(defineProps<Props>(), {});
|
||||||
|
|
||||||
|
function handleCollect(item) {
|
||||||
|
emit("collectItem", item);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDelete(item) {
|
||||||
|
emit("deleteItem", item);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<component :is="useRenderIcon(item.meta?.icon)" />
|
||||||
|
<span class="history-item-title">
|
||||||
|
{{ item.meta?.title }}
|
||||||
|
</span>
|
||||||
|
<IconifyIconOffline
|
||||||
|
v-show="item.type === 'history'"
|
||||||
|
:icon="Star"
|
||||||
|
class="w-[18px] h-[18px] mr-2 hover:text-[#d7d5d4]"
|
||||||
|
@click.stop="handleCollect(item)"
|
||||||
|
/>
|
||||||
|
<IconifyIconOffline
|
||||||
|
:icon="Close"
|
||||||
|
class="w-[18px] h-[18px] hover:text-[#d7d5d4] cursor-pointer"
|
||||||
|
@click.stop="handleDelete(item)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.history-item-title {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,13 +1,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { match } from "pinyin-pro";
|
import { match } from "pinyin-pro";
|
||||||
|
import { getConfig } from "@/config";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import SearchResult from "./SearchResult.vue";
|
import SearchResult from "./SearchResult.vue";
|
||||||
import SearchFooter from "./SearchFooter.vue";
|
import SearchFooter from "./SearchFooter.vue";
|
||||||
import { useNav } from "@/layout/hooks/useNav";
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
import { ref, computed, shallowRef } from "vue";
|
import SearchHistory from "./SearchHistory.vue";
|
||||||
import { cloneDeep, isAllEmpty } from "@pureadmin/utils";
|
import type { optionsItem, dragItem } from "../types";
|
||||||
|
import { ref, computed, shallowRef, watch } from "vue";
|
||||||
import { useDebounceFn, onKeyStroke } from "@vueuse/core";
|
import { useDebounceFn, onKeyStroke } from "@vueuse/core";
|
||||||
import { usePermissionStoreHook } from "@/store/modules/permission";
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||||
|
import { cloneDeep, isAllEmpty, storageLocal } from "@pureadmin/utils";
|
||||||
import Search from "@iconify-icons/ri/search-line";
|
import Search from "@iconify-icons/ri/search-line";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -22,15 +25,25 @@ interface Emits {
|
|||||||
const { device } = useNav();
|
const { device } = useNav();
|
||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
const props = withDefaults(defineProps<Props>(), {});
|
const props = withDefaults(defineProps<Props>(), {});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
const HISTORY_TYPE = "history";
|
||||||
|
const COLLECT_TYPE = "collect";
|
||||||
|
const LOCALEHISTORYKEY = "menu-search-history";
|
||||||
|
const LOCALECOLLECTKEY = "menu-search-collect";
|
||||||
|
|
||||||
const keyword = ref("");
|
const keyword = ref("");
|
||||||
const scrollbarRef = ref();
|
|
||||||
const resultRef = ref();
|
const resultRef = ref();
|
||||||
|
const historyRef = ref();
|
||||||
|
const scrollbarRef = ref();
|
||||||
const activePath = ref("");
|
const activePath = ref("");
|
||||||
const inputRef = ref<HTMLInputElement | null>(null);
|
const historyPath = ref("");
|
||||||
const resultOptions = shallowRef([]);
|
const resultOptions = shallowRef([]);
|
||||||
|
const historyOptions = shallowRef([]);
|
||||||
const handleSearch = useDebounceFn(search, 300);
|
const handleSearch = useDebounceFn(search, 300);
|
||||||
|
const historyNum = getConfig().MenuSearchHistory;
|
||||||
|
const inputRef = ref<HTMLInputElement | null>(null);
|
||||||
|
|
||||||
/** 菜单树形结构 */
|
/** 菜单树形结构 */
|
||||||
const menusData = computed(() => {
|
const menusData = computed(() => {
|
||||||
@ -46,6 +59,36 @@ const show = computed({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
newValue => {
|
||||||
|
if (newValue) getHistory();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const showSearchResult = computed(() => {
|
||||||
|
return keyword.value && resultOptions.value.length > 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
const showSearchHistory = computed(() => {
|
||||||
|
return !keyword.value && historyOptions.value.length > 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
const showEmpty = computed(() => {
|
||||||
|
return (
|
||||||
|
(!keyword.value && historyOptions.value.length === 0) ||
|
||||||
|
(keyword.value && resultOptions.value.length === 0)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
function getStorageItem(key) {
|
||||||
|
return storageLocal().getItem<optionsItem[]>(key) || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function setStorageItem(key, value) {
|
||||||
|
storageLocal().setItem(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
/** 将菜单树形结构扁平化为一维数组,用于菜单查询 */
|
/** 将菜单树形结构扁平化为一维数组,用于菜单查询 */
|
||||||
function flatTree(arr) {
|
function flatTree(arr) {
|
||||||
const res = [];
|
const res = [];
|
||||||
@ -75,11 +118,8 @@ function search() {
|
|||||||
)
|
)
|
||||||
: false
|
: false
|
||||||
);
|
);
|
||||||
if (resultOptions.value?.length > 0) {
|
activePath.value =
|
||||||
activePath.value = resultOptions.value[0].path;
|
resultOptions.value?.length > 0 ? resultOptions.value[0].path : "";
|
||||||
} else {
|
|
||||||
activePath.value = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
@ -87,54 +127,143 @@ function handleClose() {
|
|||||||
/** 延时处理防止用户看到某些操作 */
|
/** 延时处理防止用户看到某些操作 */
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resultOptions.value = [];
|
resultOptions.value = [];
|
||||||
|
historyPath.value = "";
|
||||||
keyword.value = "";
|
keyword.value = "";
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollTo(index) {
|
function scrollTo(index) {
|
||||||
const scrollTop = resultRef.value.handleScroll(index);
|
const ref = resultOptions.value.length ? resultRef.value : historyRef.value;
|
||||||
|
const scrollTop = ref.handleScroll(index);
|
||||||
scrollbarRef.value.setScrollTop(scrollTop);
|
scrollbarRef.value.setScrollTop(scrollTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取当前选项和路径 */
|
||||||
|
function getCurrentOptionsAndPath() {
|
||||||
|
const isResultOptions = resultOptions.value.length > 0;
|
||||||
|
const options = isResultOptions ? resultOptions.value : historyOptions.value;
|
||||||
|
const currentPath = isResultOptions ? activePath.value : historyPath.value;
|
||||||
|
return { options, currentPath, isResultOptions };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新路径并滚动到指定项 */
|
||||||
|
function updatePathAndScroll(newIndex, isResultOptions) {
|
||||||
|
if (isResultOptions) {
|
||||||
|
activePath.value = resultOptions.value[newIndex].path;
|
||||||
|
} else {
|
||||||
|
historyPath.value = historyOptions.value[newIndex].path;
|
||||||
|
}
|
||||||
|
scrollTo(newIndex);
|
||||||
|
}
|
||||||
|
|
||||||
/** key up */
|
/** key up */
|
||||||
function handleUp() {
|
function handleUp() {
|
||||||
const { length } = resultOptions.value;
|
const { options, currentPath, isResultOptions } = getCurrentOptionsAndPath();
|
||||||
if (length === 0) return;
|
if (options.length === 0) return;
|
||||||
const index = resultOptions.value.findIndex(
|
const index = options.findIndex(item => item.path === currentPath);
|
||||||
item => item.path === activePath.value
|
const prevIndex = (index - 1 + options.length) % options.length;
|
||||||
);
|
updatePathAndScroll(prevIndex, isResultOptions);
|
||||||
if (index === 0) {
|
|
||||||
activePath.value = resultOptions.value[length - 1].path;
|
|
||||||
scrollTo(resultOptions.value.length - 1);
|
|
||||||
} else {
|
|
||||||
activePath.value = resultOptions.value[index - 1].path;
|
|
||||||
scrollTo(index - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** key down */
|
/** key down */
|
||||||
function handleDown() {
|
function handleDown() {
|
||||||
const { length } = resultOptions.value;
|
const { options, currentPath, isResultOptions } = getCurrentOptionsAndPath();
|
||||||
if (length === 0) return;
|
if (options.length === 0) return;
|
||||||
const index = resultOptions.value.findIndex(
|
const index = options.findIndex(item => item.path === currentPath);
|
||||||
item => item.path === activePath.value
|
const nextIndex = (index + 1) % options.length;
|
||||||
);
|
updatePathAndScroll(nextIndex, isResultOptions);
|
||||||
if (index + 1 === length) {
|
|
||||||
activePath.value = resultOptions.value[0].path;
|
|
||||||
} else {
|
|
||||||
activePath.value = resultOptions.value[index + 1].path;
|
|
||||||
}
|
|
||||||
scrollTo(index + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** key enter */
|
/** key enter */
|
||||||
function handleEnter() {
|
function handleEnter() {
|
||||||
const { length } = resultOptions.value;
|
const { options, currentPath, isResultOptions } = getCurrentOptionsAndPath();
|
||||||
if (length === 0 || activePath.value === "") return;
|
if (options.length === 0 || currentPath === "") return;
|
||||||
router.push(activePath.value);
|
const index = options.findIndex(item => item.path === currentPath);
|
||||||
|
if (index === -1) return;
|
||||||
|
if (isResultOptions) {
|
||||||
|
saveHistory();
|
||||||
|
} else {
|
||||||
|
updateHistory();
|
||||||
|
}
|
||||||
|
router.push(options[index].path);
|
||||||
handleClose();
|
handleClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 删除历史记录 */
|
||||||
|
function handleDelete(item) {
|
||||||
|
const key = item.type === HISTORY_TYPE ? LOCALEHISTORYKEY : LOCALECOLLECTKEY;
|
||||||
|
let list = getStorageItem(key);
|
||||||
|
list = list.filter(listItem => listItem.path !== item.path);
|
||||||
|
setStorageItem(key, list);
|
||||||
|
getHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 收藏历史记录 */
|
||||||
|
function handleCollect(item) {
|
||||||
|
let searchHistoryList = getStorageItem(LOCALEHISTORYKEY);
|
||||||
|
let searchCollectList = getStorageItem(LOCALECOLLECTKEY);
|
||||||
|
searchHistoryList = searchHistoryList.filter(
|
||||||
|
historyItem => historyItem.path !== item.path
|
||||||
|
);
|
||||||
|
setStorageItem(LOCALEHISTORYKEY, searchHistoryList);
|
||||||
|
if (!searchCollectList.some(collectItem => collectItem.path === item.path)) {
|
||||||
|
searchCollectList.unshift({ ...item, type: COLLECT_TYPE });
|
||||||
|
setStorageItem(LOCALECOLLECTKEY, searchCollectList);
|
||||||
|
}
|
||||||
|
getHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 存储搜索记录 */
|
||||||
|
function saveHistory() {
|
||||||
|
const { path, meta } = resultOptions.value.find(
|
||||||
|
item => item.path === activePath.value
|
||||||
|
);
|
||||||
|
const searchHistoryList = getStorageItem(LOCALEHISTORYKEY);
|
||||||
|
const searchCollectList = getStorageItem(LOCALECOLLECTKEY);
|
||||||
|
const isCollected = searchCollectList.some(item => item.path === path);
|
||||||
|
const existingIndex = searchHistoryList.findIndex(item => item.path === path);
|
||||||
|
if (!isCollected) {
|
||||||
|
if (existingIndex !== -1) searchHistoryList.splice(existingIndex, 1);
|
||||||
|
if (searchHistoryList.length >= historyNum) searchHistoryList.pop();
|
||||||
|
searchHistoryList.unshift({ path, meta, type: HISTORY_TYPE });
|
||||||
|
storageLocal().setItem(LOCALEHISTORYKEY, searchHistoryList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新存储的搜索记录 */
|
||||||
|
function updateHistory() {
|
||||||
|
let searchHistoryList = getStorageItem(LOCALEHISTORYKEY);
|
||||||
|
const historyIndex = searchHistoryList.findIndex(
|
||||||
|
item => item.path === historyPath.value
|
||||||
|
);
|
||||||
|
if (historyIndex !== -1) {
|
||||||
|
const [historyItem] = searchHistoryList.splice(historyIndex, 1);
|
||||||
|
searchHistoryList.unshift(historyItem);
|
||||||
|
setStorageItem(LOCALEHISTORYKEY, searchHistoryList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取本地历史记录 */
|
||||||
|
function getHistory() {
|
||||||
|
const searchHistoryList = getStorageItem(LOCALEHISTORYKEY);
|
||||||
|
const searchCollectList = getStorageItem(LOCALECOLLECTKEY);
|
||||||
|
historyOptions.value = [...searchHistoryList, ...searchCollectList];
|
||||||
|
historyPath.value = historyOptions.value[0]?.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 拖拽改变收藏顺序 */
|
||||||
|
function handleDrag(item: dragItem) {
|
||||||
|
const searchCollectList = getStorageItem(LOCALECOLLECTKEY);
|
||||||
|
const [reorderedItem] = searchCollectList.splice(item.oldIndex, 1);
|
||||||
|
searchCollectList.splice(item.newIndex, 0, reorderedItem);
|
||||||
|
storageLocal().setItem(LOCALECOLLECTKEY, searchCollectList);
|
||||||
|
historyOptions.value = [
|
||||||
|
...getStorageItem(LOCALEHISTORYKEY),
|
||||||
|
...getStorageItem(LOCALECOLLECTKEY)
|
||||||
|
];
|
||||||
|
historyPath.value = reorderedItem.path;
|
||||||
|
}
|
||||||
|
|
||||||
onKeyStroke("Enter", handleEnter);
|
onKeyStroke("Enter", handleEnter);
|
||||||
onKeyStroke("ArrowUp", handleUp);
|
onKeyStroke("ArrowUp", handleUp);
|
||||||
onKeyStroke("ArrowDown", handleDown);
|
onKeyStroke("ArrowDown", handleDown);
|
||||||
@ -142,9 +271,9 @@ onKeyStroke("ArrowDown", handleDown);
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
|
v-model="show"
|
||||||
top="5vh"
|
top="5vh"
|
||||||
class="pure-search-dialog"
|
class="pure-search-dialog"
|
||||||
v-model="show"
|
|
||||||
:show-close="false"
|
:show-close="false"
|
||||||
:width="device === 'mobile' ? '80vw' : '40vw'"
|
:width="device === 'mobile' ? '80vw' : '40vw'"
|
||||||
:before-close="handleClose"
|
:before-close="handleClose"
|
||||||
@ -157,10 +286,10 @@ onKeyStroke("ArrowDown", handleDown);
|
|||||||
>
|
>
|
||||||
<el-input
|
<el-input
|
||||||
ref="inputRef"
|
ref="inputRef"
|
||||||
size="large"
|
|
||||||
v-model="keyword"
|
v-model="keyword"
|
||||||
|
size="large"
|
||||||
clearable
|
clearable
|
||||||
placeholder="搜索菜单"
|
placeholder="搜索菜单(支持拼音搜索)"
|
||||||
@input="handleSearch"
|
@input="handleSearch"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
@ -170,14 +299,21 @@ onKeyStroke("ArrowDown", handleDown);
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
<div class="search-result-container">
|
<div class="search-content">
|
||||||
<el-scrollbar ref="scrollbarRef" max-height="calc(90vh - 140px)">
|
<el-scrollbar ref="scrollbarRef" max-height="calc(90vh - 140px)">
|
||||||
<el-empty
|
<el-empty v-if="showEmpty" description="暂无搜索结果" />
|
||||||
v-if="resultOptions.length === 0"
|
<SearchHistory
|
||||||
description="暂无搜索结果"
|
v-if="showSearchHistory"
|
||||||
|
ref="historyRef"
|
||||||
|
v-model:value="historyPath"
|
||||||
|
:options="historyOptions"
|
||||||
|
@click="handleEnter"
|
||||||
|
@delete="handleDelete"
|
||||||
|
@collect="handleCollect"
|
||||||
|
@drag="handleDrag"
|
||||||
/>
|
/>
|
||||||
<SearchResult
|
<SearchResult
|
||||||
v-else
|
v-if="showSearchResult"
|
||||||
ref="resultRef"
|
ref="resultRef"
|
||||||
v-model:value="activePath"
|
v-model:value="activePath"
|
||||||
:options="resultOptions"
|
:options="resultOptions"
|
||||||
@ -192,7 +328,7 @@ onKeyStroke("ArrowDown", handleDown);
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.search-result-container {
|
.search-content {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,23 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useResizeObserver } from "@vueuse/core";
|
import type { Props } from "../types";
|
||||||
|
import { useResizeObserver } from "@pureadmin/utils";
|
||||||
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
|
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
|
||||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
import { ref, computed, getCurrentInstance, onMounted } from "vue";
|
import { ref, computed, getCurrentInstance, onMounted } from "vue";
|
||||||
import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
|
import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
|
||||||
import Bookmark2Line from "@iconify-icons/ri/bookmark-2-line";
|
|
||||||
|
|
||||||
interface optionsItem {
|
|
||||||
path: string;
|
|
||||||
meta?: {
|
|
||||||
icon?: string;
|
|
||||||
title?: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
value: string;
|
|
||||||
options: Array<optionsItem>;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: "update:value", val: string): void;
|
(e: "update:value", val: string): void;
|
||||||
@ -26,9 +13,9 @@ interface Emits {
|
|||||||
|
|
||||||
const resultRef = ref();
|
const resultRef = ref();
|
||||||
const innerHeight = ref();
|
const innerHeight = ref();
|
||||||
const props = withDefaults(defineProps<Props>(), {});
|
|
||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
const instance = getCurrentInstance()!;
|
const instance = getCurrentInstance()!;
|
||||||
|
const props = withDefaults(defineProps<Props>(), {});
|
||||||
|
|
||||||
const itemStyle = computed(() => {
|
const itemStyle = computed(() => {
|
||||||
return item => {
|
return item => {
|
||||||
@ -64,9 +51,7 @@ function resizeResult() {
|
|||||||
innerHeight.value = window.innerHeight - window.innerHeight / 10 - 140;
|
innerHeight.value = window.innerHeight - window.innerHeight / 10 - 140;
|
||||||
}
|
}
|
||||||
|
|
||||||
useResizeObserver(resultRef, () => {
|
useResizeObserver(resultRef, resizeResult);
|
||||||
resizeResult();
|
|
||||||
});
|
|
||||||
|
|
||||||
function handleScroll(index: number) {
|
function handleScroll(index: number) {
|
||||||
const curInstance = instance?.proxy?.$refs[`resultItemRef${index}`];
|
const curInstance = instance?.proxy?.$refs[`resultItemRef${index}`];
|
||||||
@ -94,8 +79,10 @@ defineExpose({ handleScroll });
|
|||||||
@click="handleTo"
|
@click="handleTo"
|
||||||
@mouseenter="handleMouse(item)"
|
@mouseenter="handleMouse(item)"
|
||||||
>
|
>
|
||||||
<component :is="useRenderIcon(item.meta?.icon ?? Bookmark2Line)" />
|
<component :is="useRenderIcon(item.meta?.icon)" />
|
||||||
<span class="result-item-title">{{ item.meta?.title }}</span>
|
<span class="result-item-title">
|
||||||
|
{{ item.meta?.title }}
|
||||||
|
</span>
|
||||||
<enterOutlined />
|
<enterOutlined />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -114,7 +101,7 @@ defineExpose({ handleScroll });
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border: 0.1px solid #ccc;
|
border: 0.1px solid #ccc;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
transition: all 0.3s;
|
transition: font-size 0.16s;
|
||||||
|
|
||||||
&-title {
|
&-title {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { SearchModal } from "./components";
|
import { SearchModal } from "./components";
|
||||||
import { useBoolean } from "../../hooks/useBoolean";
|
import { useBoolean } from "../../hooks/useBoolean";
|
||||||
import Search from "@iconify-icons/ep/search";
|
|
||||||
|
|
||||||
const { bool: show, toggle } = useBoolean();
|
const { bool: show, toggle } = useBoolean();
|
||||||
function handleSearch() {
|
function handleSearch() {
|
||||||
@ -10,11 +9,13 @@ function handleSearch() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div>
|
||||||
class="search-container w-[40px] h-[48px] flex-c cursor-pointer navbar-bg-hover"
|
<div
|
||||||
@click="handleSearch"
|
class="search-container w-[40px] h-[48px] flex-c cursor-pointer navbar-bg-hover"
|
||||||
>
|
@click="handleSearch"
|
||||||
<IconifyIconOffline :icon="Search" />
|
>
|
||||||
|
<IconifyIconOffline icon="ri:search-line" />
|
||||||
|
</div>
|
||||||
|
<SearchModal v-model:value="show" />
|
||||||
</div>
|
</div>
|
||||||
<SearchModal v-model:value="show" />
|
|
||||||
</template>
|
</template>
|
||||||
|
20
src/layout/components/search/types.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
interface optionsItem {
|
||||||
|
path: string;
|
||||||
|
type: "history" | "collect";
|
||||||
|
meta: {
|
||||||
|
icon?: string;
|
||||||
|
title?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface dragItem {
|
||||||
|
oldIndex: number;
|
||||||
|
newIndex: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
value: string;
|
||||||
|
options: Array<optionsItem>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { optionsItem, dragItem, Props };
|
@ -6,36 +6,26 @@ import {
|
|||||||
reactive,
|
reactive,
|
||||||
computed,
|
computed,
|
||||||
nextTick,
|
nextTick,
|
||||||
|
onUnmounted,
|
||||||
onBeforeMount
|
onBeforeMount
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import {
|
|
||||||
useDark,
|
|
||||||
debounce,
|
|
||||||
useGlobal,
|
|
||||||
storageLocal,
|
|
||||||
storageSession
|
|
||||||
} from "@pureadmin/utils";
|
|
||||||
import { getConfig } from "@/config";
|
|
||||||
import { useRouter } from "vue-router";
|
|
||||||
import panel from "../panel/index.vue";
|
import panel from "../panel/index.vue";
|
||||||
import { emitter } from "@/utils/mitt";
|
import { emitter } from "@/utils/mitt";
|
||||||
import { resetRouter } from "@/router";
|
|
||||||
import { removeToken } from "@/utils/auth";
|
|
||||||
import { routerArrays } from "@/layout/types";
|
|
||||||
import { useNav } from "@/layout/hooks/useNav";
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
import { useAppStoreHook } from "@/store/modules/app";
|
import { useAppStoreHook } from "@/store/modules/app";
|
||||||
|
import { useDark, useGlobal, debounce } from "@pureadmin/utils";
|
||||||
import { toggleTheme } from "@pureadmin/theme/dist/browser-utils";
|
import { toggleTheme } from "@pureadmin/theme/dist/browser-utils";
|
||||||
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
||||||
|
import Segmented, { type OptionsType } from "@/components/ReSegmented";
|
||||||
import { useDataThemeChange } from "@/layout/hooks/useDataThemeChange";
|
import { useDataThemeChange } from "@/layout/hooks/useDataThemeChange";
|
||||||
|
|
||||||
|
import Check from "@iconify-icons/ep/check";
|
||||||
import dayIcon from "@/assets/svg/day.svg?component";
|
import dayIcon from "@/assets/svg/day.svg?component";
|
||||||
import darkIcon from "@/assets/svg/dark.svg?component";
|
import darkIcon from "@/assets/svg/dark.svg?component";
|
||||||
import Check from "@iconify-icons/ep/check";
|
import systemIcon from "@/assets/svg/system.svg?component";
|
||||||
import Logout from "@iconify-icons/ri/logout-circle-r-line";
|
|
||||||
|
|
||||||
const router = useRouter();
|
const { device } = useNav();
|
||||||
const { isDark } = useDark();
|
const { isDark } = useDark();
|
||||||
const { device, tooltipEffect } = useNav();
|
|
||||||
const { $storage } = useGlobal<GlobalPropertiesApi>();
|
const { $storage } = useGlobal<GlobalPropertiesApi>();
|
||||||
|
|
||||||
const mixRef = ref();
|
const mixRef = ref();
|
||||||
@ -44,10 +34,11 @@ const horizontalRef = ref();
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
dataTheme,
|
dataTheme,
|
||||||
|
overallStyle,
|
||||||
layoutTheme,
|
layoutTheme,
|
||||||
themeColors,
|
themeColors,
|
||||||
|
toggleClass,
|
||||||
dataThemeChange,
|
dataThemeChange,
|
||||||
setEpThemeColor,
|
|
||||||
setLayoutThemeColor
|
setLayoutThemeColor
|
||||||
} = useDataThemeChange();
|
} = useDataThemeChange();
|
||||||
|
|
||||||
@ -72,6 +63,7 @@ const settings = reactive({
|
|||||||
tabsVal: $storage.configure.hideTabs,
|
tabsVal: $storage.configure.hideTabs,
|
||||||
showLogo: $storage.configure.showLogo,
|
showLogo: $storage.configure.showLogo,
|
||||||
showModel: $storage.configure.showModel,
|
showModel: $storage.configure.showModel,
|
||||||
|
hideFooter: $storage.configure.hideFooter,
|
||||||
multiTagsCache: $storage.configure.multiTagsCache
|
multiTagsCache: $storage.configure.multiTagsCache
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -81,7 +73,7 @@ const getThemeColorStyle = computed(() => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 当网页为暗黑模式时不显示亮白色切换选项 */
|
/** 当网页整体为暗色风格时不显示亮白色主题配色切换选项 */
|
||||||
const showThemeColors = computed(() => {
|
const showThemeColors = computed(() => {
|
||||||
return themeColor => {
|
return themeColor => {
|
||||||
return themeColor === "light" && isDark.value ? false : true;
|
return themeColor === "light" && isDark.value ? false : true;
|
||||||
@ -94,60 +86,45 @@ function storageConfigureChange<T>(key: string, val: T): void {
|
|||||||
$storage.configure = storageConfigure;
|
$storage.configure = storageConfigure;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) {
|
|
||||||
const targetEl = target || document.body;
|
|
||||||
let { className } = targetEl;
|
|
||||||
className = className.replace(clsName, "").trim();
|
|
||||||
targetEl.className = flag ? `${className} ${clsName} ` : className;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 灰色模式设置 */
|
/** 灰色模式设置 */
|
||||||
const greyChange = (value): void => {
|
const greyChange = (value): void => {
|
||||||
toggleClass(settings.greyVal, "html-grey", document.querySelector("html"));
|
const htmlEl = document.querySelector("html");
|
||||||
|
toggleClass(settings.greyVal, "html-grey", htmlEl);
|
||||||
storageConfigureChange("grey", value);
|
storageConfigureChange("grey", value);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 色弱模式设置 */
|
/** 色弱模式设置 */
|
||||||
const weekChange = (value): void => {
|
const weekChange = (value): void => {
|
||||||
toggleClass(
|
const htmlEl = document.querySelector("html");
|
||||||
settings.weakVal,
|
toggleClass(settings.weakVal, "html-weakness", htmlEl);
|
||||||
"html-weakness",
|
|
||||||
document.querySelector("html")
|
|
||||||
);
|
|
||||||
storageConfigureChange("weak", value);
|
storageConfigureChange("weak", value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 隐藏标签页设置 */
|
||||||
const tagsChange = () => {
|
const tagsChange = () => {
|
||||||
const showVal = settings.tabsVal;
|
const showVal = settings.tabsVal;
|
||||||
storageConfigureChange("hideTabs", showVal);
|
storageConfigureChange("hideTabs", showVal);
|
||||||
emitter.emit("tagViewsChange", showVal as unknown as string);
|
emitter.emit("tagViewsChange", showVal as unknown as string);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 隐藏页脚设置 */
|
||||||
|
const hideFooterChange = () => {
|
||||||
|
const hideFooter = settings.hideFooter;
|
||||||
|
storageConfigureChange("hideFooter", hideFooter);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 标签页持久化设置 */
|
||||||
const multiTagsCacheChange = () => {
|
const multiTagsCacheChange = () => {
|
||||||
const multiTagsCache = settings.multiTagsCache;
|
const multiTagsCache = settings.multiTagsCache;
|
||||||
storageConfigureChange("multiTagsCache", multiTagsCache);
|
storageConfigureChange("multiTagsCache", multiTagsCache);
|
||||||
useMultiTagsStoreHook().multiTagsCacheChange(multiTagsCache);
|
useMultiTagsStoreHook().multiTagsCacheChange(multiTagsCache);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 清空缓存并返回登录页 */
|
function onChange({ option }) {
|
||||||
function onReset() {
|
const { value } = option;
|
||||||
removeToken();
|
markValue.value = value;
|
||||||
storageLocal().clear();
|
storageConfigureChange("showModel", value);
|
||||||
storageSession().clear();
|
emitter.emit("tagViewsShowModel", value);
|
||||||
const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig();
|
|
||||||
useAppStoreHook().setLayout(Layout);
|
|
||||||
setEpThemeColor(EpThemeColor);
|
|
||||||
useMultiTagsStoreHook().multiTagsCacheChange(MultiTagsCache);
|
|
||||||
toggleClass(Grey, "html-grey", document.querySelector("html"));
|
|
||||||
toggleClass(Weak, "html-weakness", document.querySelector("html"));
|
|
||||||
router.push("/login");
|
|
||||||
useMultiTagsStoreHook().handleTags("equal", [...routerArrays]);
|
|
||||||
resetRouter();
|
|
||||||
}
|
|
||||||
|
|
||||||
function onChange(label) {
|
|
||||||
storageConfigureChange("showModel", label);
|
|
||||||
emitter.emit("tagViewsShowModel", label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 侧边栏Logo */
|
/** 侧边栏Logo */
|
||||||
@ -183,6 +160,45 @@ const getThemeColor = computed(() => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const themeOptions = computed<Array<OptionsType>>(() => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: "浅色",
|
||||||
|
icon: dayIcon,
|
||||||
|
theme: "light",
|
||||||
|
tip: "清新启航,点亮舒适的工作界面",
|
||||||
|
iconAttrs: { fill: isDark.value ? "#fff" : "#000" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "深色",
|
||||||
|
icon: darkIcon,
|
||||||
|
theme: "dark",
|
||||||
|
tip: "月光序曲,沉醉于夜的静谧雅致",
|
||||||
|
iconAttrs: { fill: isDark.value ? "#fff" : "#000" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "自动",
|
||||||
|
icon: systemIcon,
|
||||||
|
theme: "system",
|
||||||
|
tip: "同步时光,界面随晨昏自然呼应",
|
||||||
|
iconAttrs: { fill: isDark.value ? "#fff" : "#000" }
|
||||||
|
}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
const markOptions: Array<OptionsType> = [
|
||||||
|
{
|
||||||
|
label: "灵动",
|
||||||
|
tip: "灵动标签,添趣生辉",
|
||||||
|
value: "smart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "卡片",
|
||||||
|
tip: "卡片标签,高效浏览",
|
||||||
|
value: "card"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
/** 设置导航模式 */
|
/** 设置导航模式 */
|
||||||
function setLayoutModel(layout: string) {
|
function setLayoutModel(layout: string) {
|
||||||
layoutTheme.value.layout = layout;
|
layoutTheme.value.layout = layout;
|
||||||
@ -192,7 +208,9 @@ function setLayoutModel(layout: string) {
|
|||||||
theme: layoutTheme.value.theme,
|
theme: layoutTheme.value.theme,
|
||||||
darkMode: $storage.layout?.darkMode,
|
darkMode: $storage.layout?.darkMode,
|
||||||
sidebarStatus: $storage.layout?.sidebarStatus,
|
sidebarStatus: $storage.layout?.sidebarStatus,
|
||||||
epThemeColor: $storage.layout?.epThemeColor
|
epThemeColor: $storage.layout?.epThemeColor,
|
||||||
|
themeColor: $storage.layout?.themeColor,
|
||||||
|
overallStyle: $storage.layout?.overallStyle
|
||||||
};
|
};
|
||||||
useAppStoreHook().setLayout(layout);
|
useAppStoreHook().setLayout(layout);
|
||||||
}
|
}
|
||||||
@ -217,188 +235,201 @@ watch($storage, ({ layout }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const mediaQueryList = window.matchMedia("(prefers-color-scheme: dark)");
|
||||||
|
|
||||||
|
/** 根据操作系统主题设置平台整体风格 */
|
||||||
|
function updateTheme() {
|
||||||
|
if (overallStyle.value !== "system") return;
|
||||||
|
if (mediaQueryList.matches) {
|
||||||
|
dataTheme.value = true;
|
||||||
|
} else {
|
||||||
|
dataTheme.value = false;
|
||||||
|
}
|
||||||
|
dataThemeChange(overallStyle.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeMatchMedia() {
|
||||||
|
mediaQueryList.removeEventListener("change", updateTheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 监听操作系统主题改变 */
|
||||||
|
function watchSystemThemeChange() {
|
||||||
|
updateTheme();
|
||||||
|
removeMatchMedia();
|
||||||
|
mediaQueryList.addEventListener("change", updateTheme);
|
||||||
|
}
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
/* 初始化项目配置 */
|
/* 初始化项目配置 */
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
watchSystemThemeChange();
|
||||||
settings.greyVal &&
|
settings.greyVal &&
|
||||||
document.querySelector("html")?.setAttribute("class", "html-grey");
|
document.querySelector("html")?.classList.add("html-grey");
|
||||||
settings.weakVal &&
|
settings.weakVal &&
|
||||||
document.querySelector("html")?.setAttribute("class", "html-weakness");
|
document.querySelector("html")?.classList.add("html-weakness");
|
||||||
settings.tabsVal && tagsChange();
|
settings.tabsVal && tagsChange();
|
||||||
|
settings.hideFooter && hideFooterChange();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => removeMatchMedia);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<panel>
|
<panel>
|
||||||
<el-divider>主题</el-divider>
|
<div class="p-6">
|
||||||
<el-switch
|
<p class="mb-3 font-medium text-sm dark:text-white">整体风格</p>
|
||||||
v-model="dataTheme"
|
<Segmented
|
||||||
inline-prompt
|
class="select-none"
|
||||||
class="pure-datatheme"
|
:modelValue="overallStyle === 'system' ? 2 : dataTheme ? 1 : 0"
|
||||||
:active-icon="dayIcon"
|
:options="themeOptions"
|
||||||
:inactive-icon="darkIcon"
|
@change="
|
||||||
@change="dataThemeChange"
|
theme => {
|
||||||
/>
|
theme.index === 1 && theme.index !== 2
|
||||||
|
? (dataTheme = true)
|
||||||
|
: (dataTheme = false);
|
||||||
|
overallStyle = theme.option.theme;
|
||||||
|
dataThemeChange(theme.option.theme);
|
||||||
|
theme.index === 2 && watchSystemThemeChange();
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
|
||||||
<el-divider>导航栏模式</el-divider>
|
<p class="mt-5 mb-3 font-medium text-sm dark:text-white">主题色</p>
|
||||||
<ul class="pure-theme">
|
<ul class="theme-color">
|
||||||
<el-tooltip
|
<li
|
||||||
:effect="tooltipEffect"
|
v-for="(item, index) in themeColors"
|
||||||
class="item"
|
v-show="showThemeColors(item.themeColor)"
|
||||||
content="左侧模式"
|
:key="index"
|
||||||
placement="bottom"
|
:style="getThemeColorStyle(item.color)"
|
||||||
popper-class="pure-tooltip"
|
@click="setLayoutThemeColor(item.themeColor)"
|
||||||
>
|
>
|
||||||
|
<el-icon
|
||||||
|
style="margin: 0.1em 0.1em 0 0"
|
||||||
|
:size="17"
|
||||||
|
:color="getThemeColor(item.themeColor)"
|
||||||
|
>
|
||||||
|
<IconifyIconOffline :icon="Check" />
|
||||||
|
</el-icon>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p class="mt-5 mb-3 font-medium text-sm dark:text-white">导航模式</p>
|
||||||
|
<ul class="pure-theme">
|
||||||
<li
|
<li
|
||||||
:class="layoutTheme.layout === 'vertical' ? 'is-select' : ''"
|
|
||||||
ref="verticalRef"
|
ref="verticalRef"
|
||||||
|
v-tippy="{
|
||||||
|
content: '左侧菜单,亲切熟悉',
|
||||||
|
zIndex: 41000
|
||||||
|
}"
|
||||||
|
:class="layoutTheme.layout === 'vertical' ? 'is-select' : ''"
|
||||||
@click="setLayoutModel('vertical')"
|
@click="setLayoutModel('vertical')"
|
||||||
>
|
>
|
||||||
<div />
|
<div />
|
||||||
<div />
|
<div />
|
||||||
</li>
|
</li>
|
||||||
</el-tooltip>
|
|
||||||
|
|
||||||
<el-tooltip
|
|
||||||
v-if="device !== 'mobile'"
|
|
||||||
:effect="tooltipEffect"
|
|
||||||
class="item"
|
|
||||||
content="顶部模式"
|
|
||||||
placement="bottom"
|
|
||||||
popper-class="pure-tooltip"
|
|
||||||
>
|
|
||||||
<li
|
<li
|
||||||
:class="layoutTheme.layout === 'horizontal' ? 'is-select' : ''"
|
v-if="device !== 'mobile'"
|
||||||
ref="horizontalRef"
|
ref="horizontalRef"
|
||||||
|
v-tippy="{
|
||||||
|
content: '顶部菜单,简洁概览',
|
||||||
|
zIndex: 41000
|
||||||
|
}"
|
||||||
|
:class="layoutTheme.layout === 'horizontal' ? 'is-select' : ''"
|
||||||
@click="setLayoutModel('horizontal')"
|
@click="setLayoutModel('horizontal')"
|
||||||
>
|
>
|
||||||
<div />
|
<div />
|
||||||
<div />
|
<div />
|
||||||
</li>
|
</li>
|
||||||
</el-tooltip>
|
|
||||||
|
|
||||||
<el-tooltip
|
|
||||||
v-if="device !== 'mobile'"
|
|
||||||
:effect="tooltipEffect"
|
|
||||||
class="item"
|
|
||||||
content="混合模式"
|
|
||||||
placement="bottom"
|
|
||||||
popper-class="pure-tooltip"
|
|
||||||
>
|
|
||||||
<li
|
<li
|
||||||
:class="layoutTheme.layout === 'mix' ? 'is-select' : ''"
|
v-if="device !== 'mobile'"
|
||||||
ref="mixRef"
|
ref="mixRef"
|
||||||
|
v-tippy="{
|
||||||
|
content: '混合菜单,灵活多变',
|
||||||
|
zIndex: 41000
|
||||||
|
}"
|
||||||
|
:class="layoutTheme.layout === 'mix' ? 'is-select' : ''"
|
||||||
@click="setLayoutModel('mix')"
|
@click="setLayoutModel('mix')"
|
||||||
>
|
>
|
||||||
<div />
|
<div />
|
||||||
<div />
|
<div />
|
||||||
</li>
|
</li>
|
||||||
</el-tooltip>
|
</ul>
|
||||||
</ul>
|
|
||||||
|
|
||||||
<el-divider>主题色</el-divider>
|
<p class="mt-5 mb-3 font-medium text-base dark:text-white">页签风格</p>
|
||||||
<ul class="theme-color">
|
<Segmented
|
||||||
<li
|
class="select-none"
|
||||||
v-for="(item, index) in themeColors"
|
:modelValue="markValue === 'smart' ? 0 : 1"
|
||||||
:key="index"
|
:options="markOptions"
|
||||||
v-show="showThemeColors(item.themeColor)"
|
@change="onChange"
|
||||||
:style="getThemeColorStyle(item.color)"
|
|
||||||
@click="setLayoutThemeColor(item.themeColor)"
|
|
||||||
>
|
|
||||||
<el-icon
|
|
||||||
style="margin: 0.1em 0.1em 0 0"
|
|
||||||
:size="17"
|
|
||||||
:color="getThemeColor(item.themeColor)"
|
|
||||||
>
|
|
||||||
<IconifyIconOffline :icon="Check" />
|
|
||||||
</el-icon>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<el-divider>界面显示</el-divider>
|
|
||||||
<ul class="setting">
|
|
||||||
<li>
|
|
||||||
<span class="dark:text-white">灰色模式</span>
|
|
||||||
<el-switch
|
|
||||||
v-model="settings.greyVal"
|
|
||||||
inline-prompt
|
|
||||||
inactive-color="#a6a6a6"
|
|
||||||
active-text="开"
|
|
||||||
inactive-text="关"
|
|
||||||
@change="greyChange"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<span class="dark:text-white">色弱模式</span>
|
|
||||||
<el-switch
|
|
||||||
v-model="settings.weakVal"
|
|
||||||
inline-prompt
|
|
||||||
inactive-color="#a6a6a6"
|
|
||||||
active-text="开"
|
|
||||||
inactive-text="关"
|
|
||||||
@change="weekChange"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<span class="dark:text-white">隐藏标签页</span>
|
|
||||||
<el-switch
|
|
||||||
v-model="settings.tabsVal"
|
|
||||||
inline-prompt
|
|
||||||
inactive-color="#a6a6a6"
|
|
||||||
active-text="开"
|
|
||||||
inactive-text="关"
|
|
||||||
@change="tagsChange"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<span class="dark:text-white">侧边栏Logo</span>
|
|
||||||
<el-switch
|
|
||||||
v-model="logoVal"
|
|
||||||
inline-prompt
|
|
||||||
:active-value="true"
|
|
||||||
:inactive-value="false"
|
|
||||||
inactive-color="#a6a6a6"
|
|
||||||
active-text="开"
|
|
||||||
inactive-text="关"
|
|
||||||
@change="logoChange"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<span class="dark:text-white">标签页持久化</span>
|
|
||||||
<el-switch
|
|
||||||
v-model="settings.multiTagsCache"
|
|
||||||
inline-prompt
|
|
||||||
inactive-color="#a6a6a6"
|
|
||||||
active-text="开"
|
|
||||||
inactive-text="关"
|
|
||||||
@change="multiTagsCacheChange"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<span class="dark:text-white">标签风格</span>
|
|
||||||
<el-radio-group v-model="markValue" size="small" @change="onChange">
|
|
||||||
<el-radio label="card">卡片</el-radio>
|
|
||||||
<el-radio label="smart">灵动</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<el-divider />
|
|
||||||
<el-button
|
|
||||||
type="danger"
|
|
||||||
style="width: 90%; margin: 24px 15px"
|
|
||||||
@click="onReset"
|
|
||||||
>
|
|
||||||
<IconifyIconOffline
|
|
||||||
:icon="Logout"
|
|
||||||
width="15"
|
|
||||||
height="15"
|
|
||||||
style="margin-right: 4px"
|
|
||||||
/>
|
/>
|
||||||
清空缓存并返回登录页
|
|
||||||
</el-button>
|
<p class="mt-5 mb-1 font-medium text-sm dark:text-white">界面显示</p>
|
||||||
|
<ul class="setting">
|
||||||
|
<li>
|
||||||
|
<span class="dark:text-white">灰色模式</span>
|
||||||
|
<el-switch
|
||||||
|
v-model="settings.greyVal"
|
||||||
|
inline-prompt
|
||||||
|
active-text="开"
|
||||||
|
inactive-text="关"
|
||||||
|
@change="greyChange"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span class="dark:text-white">色弱模式</span>
|
||||||
|
<el-switch
|
||||||
|
v-model="settings.weakVal"
|
||||||
|
inline-prompt
|
||||||
|
active-text="开"
|
||||||
|
inactive-text="关"
|
||||||
|
@change="weekChange"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span class="dark:text-white">隐藏标签页</span>
|
||||||
|
<el-switch
|
||||||
|
v-model="settings.tabsVal"
|
||||||
|
inline-prompt
|
||||||
|
active-text="开"
|
||||||
|
inactive-text="关"
|
||||||
|
@change="tagsChange"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span class="dark:text-white">隐藏页脚</span>
|
||||||
|
<el-switch
|
||||||
|
v-model="settings.hideFooter"
|
||||||
|
inline-prompt
|
||||||
|
active-text="开"
|
||||||
|
inactive-text="关"
|
||||||
|
@change="hideFooterChange"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span class="dark:text-white">Logo</span>
|
||||||
|
<el-switch
|
||||||
|
v-model="logoVal"
|
||||||
|
inline-prompt
|
||||||
|
:active-value="true"
|
||||||
|
:inactive-value="false"
|
||||||
|
active-text="开"
|
||||||
|
inactive-text="关"
|
||||||
|
@change="logoChange"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<span class="dark:text-white">页签持久化</span>
|
||||||
|
<el-switch
|
||||||
|
v-model="settings.multiTagsCache"
|
||||||
|
inline-prompt
|
||||||
|
active-text="开"
|
||||||
|
inactive-text="关"
|
||||||
|
@change="multiTagsCacheChange"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</panel>
|
</panel>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -408,41 +439,41 @@ onBeforeMount(() => {
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
.is-select {
|
:deep(.el-switch__core) {
|
||||||
border: 2px solid var(--el-color-primary);
|
--el-switch-off-color: var(--pure-switch-off-color);
|
||||||
|
|
||||||
|
min-width: 36px;
|
||||||
|
height: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.setting {
|
:deep(.el-switch__core .el-switch__action) {
|
||||||
width: 100%;
|
height: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-color {
|
||||||
|
height: 20px;
|
||||||
|
|
||||||
li {
|
li {
|
||||||
display: flex;
|
float: left;
|
||||||
align-items: center;
|
height: 20px;
|
||||||
justify-content: space-between;
|
margin-right: 8px;
|
||||||
margin: 25px;
|
cursor: pointer;
|
||||||
}
|
border-radius: 4px;
|
||||||
}
|
|
||||||
|
|
||||||
.pure-datatheme {
|
&:nth-child(1) {
|
||||||
display: block;
|
border: 1px solid #ddd;
|
||||||
width: 100%;
|
}
|
||||||
height: 50px;
|
}
|
||||||
padding-top: 25px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.pure-theme {
|
.pure-theme {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
gap: 12px;
|
||||||
justify-content: space-around;
|
|
||||||
width: 100%;
|
|
||||||
height: 50px;
|
|
||||||
margin-top: 25px;
|
|
||||||
|
|
||||||
li {
|
li {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 18%;
|
width: 46px;
|
||||||
height: 45px;
|
height: 36px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background: #f0f2f5;
|
background: #f0f2f5;
|
||||||
@ -503,27 +534,17 @@ onBeforeMount(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-color {
|
.is-select {
|
||||||
display: flex;
|
border: 2px solid var(--el-color-primary);
|
||||||
justify-content: center;
|
}
|
||||||
width: 100%;
|
|
||||||
height: 40px;
|
|
||||||
margin-top: 20px;
|
|
||||||
|
|
||||||
|
.setting {
|
||||||
li {
|
li {
|
||||||
float: left;
|
display: flex;
|
||||||
width: 20px;
|
align-items: center;
|
||||||
height: 20px;
|
justify-content: space-between;
|
||||||
margin-top: 8px;
|
padding: 4px 0;
|
||||||
margin-right: 8px;
|
font-size: 14px;
|
||||||
font-weight: 700;
|
|
||||||
text-align: center;
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: 2px;
|
|
||||||
|
|
||||||
&:nth-child(2) {
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { isEqual } from "@pureadmin/utils";
|
import { isEqual } from "@pureadmin/utils";
|
||||||
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { ref, watch, onMounted, toRaw } from "vue";
|
import { ref, watch, onMounted, toRaw } from "vue";
|
||||||
import { getParentPaths, findRouteByPath } from "@/router/utils";
|
import { getParentPaths, findRouteByPath } from "@/router/utils";
|
||||||
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
||||||
import { useRoute, useRouter, RouteLocationMatched } from "vue-router";
|
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const levelList = ref([]);
|
const levelList = ref([]);
|
||||||
@ -63,12 +63,28 @@ const getBreadcrumb = (): void => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLink = (item: RouteLocationMatched): void => {
|
const handleLink = item => {
|
||||||
const { redirect, path } = item;
|
const { redirect, name, path } = item;
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
router.push(redirect as any);
|
router.push(redirect as any);
|
||||||
} else {
|
} else {
|
||||||
router.push(path);
|
if (name) {
|
||||||
|
if (item.query) {
|
||||||
|
router.push({
|
||||||
|
name,
|
||||||
|
query: item.query
|
||||||
|
});
|
||||||
|
} else if (item.params) {
|
||||||
|
router.push({
|
||||||
|
name,
|
||||||
|
params: item.params
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
router.push({ name });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
router.push({ path });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -91,9 +107,9 @@ watch(
|
|||||||
<el-breadcrumb class="!leading-[50px] select-none" separator="/">
|
<el-breadcrumb class="!leading-[50px] select-none" separator="/">
|
||||||
<transition-group name="breadcrumb">
|
<transition-group name="breadcrumb">
|
||||||
<el-breadcrumb-item
|
<el-breadcrumb-item
|
||||||
class="!inline !items-stretch"
|
|
||||||
v-for="item in levelList"
|
v-for="item in levelList"
|
||||||
:key="item.path"
|
:key="item.path"
|
||||||
|
class="!inline !items-stretch"
|
||||||
>
|
>
|
||||||
<a @click.prevent="handleLink(item)">
|
<a @click.prevent="handleLink(item)">
|
||||||
{{ item.meta.title }}
|
{{ item.meta.title }}
|
||||||
|
@ -17,6 +17,7 @@ const {
|
|||||||
logout,
|
logout,
|
||||||
backTopMenu,
|
backTopMenu,
|
||||||
onPanel,
|
onPanel,
|
||||||
|
getLogo,
|
||||||
username,
|
username,
|
||||||
userAvatar,
|
userAvatar,
|
||||||
avatarsStyle
|
avatarsStyle
|
||||||
@ -37,13 +38,14 @@ nextTick(() => {
|
|||||||
class="horizontal-header"
|
class="horizontal-header"
|
||||||
>
|
>
|
||||||
<div class="horizontal-header-left" @click="backTopMenu">
|
<div class="horizontal-header-left" @click="backTopMenu">
|
||||||
<img src="/logo.svg" alt="logo" />
|
<img :src="getLogo()" alt="logo" />
|
||||||
<span>{{ title }}</span>
|
<span>{{ title }}</span>
|
||||||
</div>
|
</div>
|
||||||
<el-menu
|
<el-menu
|
||||||
router
|
|
||||||
ref="menuRef"
|
ref="menuRef"
|
||||||
|
router
|
||||||
mode="horizontal"
|
mode="horizontal"
|
||||||
|
popper-class="pure-scrollbar"
|
||||||
class="horizontal-header-menu"
|
class="horizontal-header-menu"
|
||||||
:default-active="defaultActive"
|
:default-active="defaultActive"
|
||||||
>
|
>
|
||||||
@ -56,7 +58,7 @@ nextTick(() => {
|
|||||||
</el-menu>
|
</el-menu>
|
||||||
<div class="horizontal-header-right">
|
<div class="horizontal-header-right">
|
||||||
<!-- 菜单搜索 -->
|
<!-- 菜单搜索 -->
|
||||||
<Search />
|
<Search id="header-search" />
|
||||||
<!-- 通知 -->
|
<!-- 通知 -->
|
||||||
<Notice id="header-notice" />
|
<Notice id="header-notice" />
|
||||||
<!-- 退出登录 -->
|
<!-- 退出登录 -->
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from "vue";
|
import { computed } from "vue";
|
||||||
|
import { useGlobal } from "@pureadmin/utils";
|
||||||
import { useNav } from "@/layout/hooks/useNav";
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
|
|
||||||
import MenuFold from "@iconify-icons/ri/menu-fold-fill";
|
import MenuFold from "@iconify-icons/ri/menu-fold-fill";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -11,7 +13,6 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
isActive: false
|
isActive: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const visible = ref(false);
|
|
||||||
const { tooltipEffect } = useNav();
|
const { tooltipEffect } = useNav();
|
||||||
|
|
||||||
const iconClass = computed(() => {
|
const iconClass = computed(() => {
|
||||||
@ -22,14 +23,14 @@ const iconClass = computed(() => {
|
|||||||
"h-[16px]",
|
"h-[16px]",
|
||||||
"inline-block",
|
"inline-block",
|
||||||
"align-middle",
|
"align-middle",
|
||||||
"text-primary",
|
|
||||||
"cursor-pointer",
|
"cursor-pointer",
|
||||||
"duration-[100ms]",
|
"duration-[100ms]"
|
||||||
"hover:text-primary",
|
|
||||||
"dark:hover:!text-white"
|
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { $storage } = useGlobal<GlobalPropertiesApi>();
|
||||||
|
const themeColor = computed(() => $storage.layout?.themeColor);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: "toggleClick"): void;
|
(e: "toggleClick"): void;
|
||||||
}>();
|
}>();
|
||||||
@ -40,32 +41,29 @@ const toggleClick = () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="collapse-container">
|
||||||
<el-tooltip
|
<IconifyIconOffline
|
||||||
placement="right"
|
v-tippy="{
|
||||||
:visible="visible"
|
content: props.isActive ? '点击折叠' : '点击展开',
|
||||||
:effect="tooltipEffect"
|
theme: tooltipEffect,
|
||||||
:content="props.isActive ? '点击折叠' : '点击展开'"
|
hideOnClick: 'toggle',
|
||||||
>
|
placement: 'right'
|
||||||
<IconifyIconOffline
|
}"
|
||||||
:icon="MenuFold"
|
:icon="MenuFold"
|
||||||
:class="iconClass"
|
:class="[iconClass, themeColor === 'light' ? '' : 'text-primary']"
|
||||||
:style="{ transform: props.isActive ? 'none' : 'rotateY(180deg)' }"
|
:style="{ transform: props.isActive ? 'none' : 'rotateY(180deg)' }"
|
||||||
@click="toggleClick"
|
@click="toggleClick"
|
||||||
@mouseenter="visible = true"
|
/>
|
||||||
@mouseleave="visible = false"
|
|
||||||
/>
|
|
||||||
</el-tooltip>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.container {
|
.collapse-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
box-shadow: 0 0 6px -2px var(--el-color-primary);
|
box-shadow: 0 0 6px -3px var(--el-color-primary);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
36
src/layout/components/sidebar/linkItem.vue
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from "vue";
|
||||||
|
import { isUrl } from "@pureadmin/utils";
|
||||||
|
import { menuType } from "@/layout/types";
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "LinkItem"
|
||||||
|
});
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
to: menuType;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const isExternalLink = computed(() => isUrl(props.to.name));
|
||||||
|
const getLinkProps = (item: menuType) => {
|
||||||
|
if (isExternalLink.value) {
|
||||||
|
return {
|
||||||
|
href: item.name,
|
||||||
|
target: "_blank",
|
||||||
|
rel: "noopener"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
to: item
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<component
|
||||||
|
:is="isExternalLink ? 'a' : 'router-link'"
|
||||||
|
v-bind="getLinkProps(to)"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</component>
|
||||||
|
</template>
|
@ -6,7 +6,7 @@ const props = defineProps({
|
|||||||
collapse: Boolean
|
collapse: Boolean
|
||||||
});
|
});
|
||||||
|
|
||||||
const { title } = useNav();
|
const { title, getLogo } = useNav();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -19,7 +19,7 @@ const { title } = useNav();
|
|||||||
class="sidebar-logo-link"
|
class="sidebar-logo-link"
|
||||||
:to="getTopMenu()?.path ?? '/'"
|
:to="getTopMenu()?.path ?? '/'"
|
||||||
>
|
>
|
||||||
<img src="/logo.svg" alt="logo" />
|
<img :src="getLogo()" alt="logo" />
|
||||||
<span class="sidebar-title">{{ title }}</span>
|
<span class="sidebar-title">{{ title }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
<router-link
|
<router-link
|
||||||
@ -29,7 +29,7 @@ const { title } = useNav();
|
|||||||
class="sidebar-logo-link"
|
class="sidebar-logo-link"
|
||||||
:to="getTopMenu()?.path ?? '/'"
|
:to="getTopMenu()?.path ?? '/'"
|
||||||
>
|
>
|
||||||
<img src="/logo.svg" alt="logo" />
|
<img :src="getLogo()" alt="logo" />
|
||||||
<span class="sidebar-title">{{ title }}</span>
|
<span class="sidebar-title">{{ title }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</transition>
|
</transition>
|
||||||
@ -48,6 +48,7 @@ const { title } = useNav();
|
|||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
padding-left: 10px;
|
||||||
|
|
||||||
img {
|
img {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -54,13 +54,14 @@ watch(
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
v-if="device !== 'mobile'"
|
v-if="device !== 'mobile'"
|
||||||
class="horizontal-header"
|
|
||||||
v-loading="usePermissionStoreHook().wholeMenus.length === 0"
|
v-loading="usePermissionStoreHook().wholeMenus.length === 0"
|
||||||
|
class="horizontal-header"
|
||||||
>
|
>
|
||||||
<el-menu
|
<el-menu
|
||||||
router
|
|
||||||
ref="menuRef"
|
ref="menuRef"
|
||||||
|
router
|
||||||
mode="horizontal"
|
mode="horizontal"
|
||||||
|
popper-class="pure-scrollbar"
|
||||||
class="horizontal-header-menu"
|
class="horizontal-header-menu"
|
||||||
:default-active="defaultActive"
|
:default-active="defaultActive"
|
||||||
>
|
>
|
||||||
@ -89,7 +90,7 @@ watch(
|
|||||||
</el-menu>
|
</el-menu>
|
||||||
<div class="horizontal-header-right">
|
<div class="horizontal-header-right">
|
||||||
<!-- 菜单搜索 -->
|
<!-- 菜单搜索 -->
|
||||||
<Search />
|
<Search id="header-search" />
|
||||||
<!-- 通知 -->
|
<!-- 通知 -->
|
||||||
<Notice id="header-notice" />
|
<Notice id="header-notice" />
|
||||||
<!-- 退出登录 -->
|
<!-- 退出登录 -->
|
||||||
|
@ -1,17 +1,27 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { getConfig } from "@/config";
|
import { getConfig } from "@/config";
|
||||||
|
import LinkItem from "./linkItem.vue";
|
||||||
import { menuType } from "../../types";
|
import { menuType } from "../../types";
|
||||||
import extraIcon from "./extraIcon.vue";
|
import extraIcon from "./extraIcon.vue";
|
||||||
|
import { ReText } from "@/components/ReText";
|
||||||
import { useNav } from "@/layout/hooks/useNav";
|
import { useNav } from "@/layout/hooks/useNav";
|
||||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
import { ref, toRaw, PropType, nextTick, computed, CSSProperties } from "vue";
|
import {
|
||||||
|
type PropType,
|
||||||
|
type CSSProperties,
|
||||||
|
ref,
|
||||||
|
toRaw,
|
||||||
|
computed,
|
||||||
|
useAttrs
|
||||||
|
} from "vue";
|
||||||
|
|
||||||
import ArrowUp from "@iconify-icons/ep/arrow-up-bold";
|
import ArrowUp from "@iconify-icons/ep/arrow-up-bold";
|
||||||
import EpArrowDown from "@iconify-icons/ep/arrow-down-bold";
|
import EpArrowDown from "@iconify-icons/ep/arrow-down-bold";
|
||||||
import ArrowLeft from "@iconify-icons/ep/arrow-left-bold";
|
import ArrowLeft from "@iconify-icons/ep/arrow-left-bold";
|
||||||
import ArrowRight from "@iconify-icons/ep/arrow-right-bold";
|
import ArrowRight from "@iconify-icons/ep/arrow-right-bold";
|
||||||
|
|
||||||
|
const attrs = useAttrs();
|
||||||
const { layout, isCollapse, tooltipEffect, getDivStyle } = useNav();
|
const { layout, isCollapse, tooltipEffect, getDivStyle } = useNav();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -28,29 +38,15 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const getSpanStyle = computed((): CSSProperties => {
|
|
||||||
return {
|
|
||||||
width: "100%",
|
|
||||||
textAlign: "center"
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const getNoDropdownStyle = computed((): CSSProperties => {
|
const getNoDropdownStyle = computed((): CSSProperties => {
|
||||||
return {
|
return {
|
||||||
|
width: "100%",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center"
|
alignItems: "center"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const getMenuTextStyle = computed(() => {
|
const getSubMenuIconStyle = computed((): CSSProperties => {
|
||||||
return {
|
|
||||||
overflow: "hidden",
|
|
||||||
textOverflow: "ellipsis",
|
|
||||||
outline: "none"
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const getsubMenuIconStyle = computed((): CSSProperties => {
|
|
||||||
return {
|
return {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
@ -59,45 +55,8 @@ const getsubMenuIconStyle = computed((): CSSProperties => {
|
|||||||
layout.value === "horizontal"
|
layout.value === "horizontal"
|
||||||
? "0 5px 0 0"
|
? "0 5px 0 0"
|
||||||
: isCollapse.value
|
: isCollapse.value
|
||||||
? "0 auto"
|
? "0 auto"
|
||||||
: "0 5px 0 0"
|
: "0 5px 0 0"
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const getSubTextStyle = computed((): CSSProperties => {
|
|
||||||
if (!isCollapse.value) {
|
|
||||||
return {
|
|
||||||
width: "210px",
|
|
||||||
display: "inline-block",
|
|
||||||
overflow: "hidden",
|
|
||||||
textOverflow: "ellipsis"
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
width: ""
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const getSubMenuDivStyle = computed((): any => {
|
|
||||||
return item => {
|
|
||||||
return !isCollapse.value
|
|
||||||
? {
|
|
||||||
width: "100%",
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
overflow: "hidden"
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
width: "100%",
|
|
||||||
textAlign:
|
|
||||||
item?.parentId === null
|
|
||||||
? "center"
|
|
||||||
: layout.value === "mix" && item?.pathList?.length === 2
|
|
||||||
? "center"
|
|
||||||
: ""
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -112,41 +71,6 @@ const expandCloseIcon = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onlyOneChild: menuType = ref(null);
|
const onlyOneChild: menuType = ref(null);
|
||||||
// 存放菜单是否存在showTooltip属性标识
|
|
||||||
const hoverMenuMap = new WeakMap();
|
|
||||||
// 存储菜单文本dom元素
|
|
||||||
const menuTextRef = ref(null);
|
|
||||||
|
|
||||||
function hoverMenu(key) {
|
|
||||||
// 如果当前菜单showTooltip属性已存在,退出计算
|
|
||||||
if (hoverMenuMap.get(key)) return;
|
|
||||||
|
|
||||||
nextTick(() => {
|
|
||||||
// 如果文本内容的整体宽度大于其可视宽度,则文本溢出
|
|
||||||
menuTextRef.value?.scrollWidth > menuTextRef.value?.clientWidth
|
|
||||||
? Object.assign(key, {
|
|
||||||
showTooltip: true
|
|
||||||
})
|
|
||||||
: Object.assign(key, {
|
|
||||||
showTooltip: false
|
|
||||||
});
|
|
||||||
hoverMenuMap.set(key, true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 左侧菜单折叠后,当菜单没有图标时只显示第一个文字并加上省略号
|
|
||||||
function overflowSlice(text, item?: any) {
|
|
||||||
const newText =
|
|
||||||
(text?.length > 1 ? text.toString().slice(0, 1) : text) + "...";
|
|
||||||
if (item && !(isCollapse.value && item?.parentId === null)) {
|
|
||||||
return layout.value === "mix" &&
|
|
||||||
item?.pathList?.length === 2 &&
|
|
||||||
isCollapse.value
|
|
||||||
? newText
|
|
||||||
: text;
|
|
||||||
}
|
|
||||||
return newText;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasOneShowingChild(children: menuType[] = [], parent: menuType) {
|
function hasOneShowingChild(children: menuType[] = [], parent: menuType) {
|
||||||
const showingChildren = children.filter((item: any) => {
|
const showingChildren = children.filter((item: any) => {
|
||||||
@ -181,129 +105,110 @@ function resolvePath(routePath) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-menu-item
|
<link-item
|
||||||
v-if="
|
v-if="
|
||||||
hasOneShowingChild(props.item.children, props.item) &&
|
hasOneShowingChild(props.item.children, props.item) &&
|
||||||
(!onlyOneChild.children || onlyOneChild.noShowingChildren)
|
(!onlyOneChild.children || onlyOneChild.noShowingChildren)
|
||||||
"
|
"
|
||||||
:index="resolvePath(onlyOneChild.path)"
|
:to="item"
|
||||||
:class="{ 'submenu-title-noDropdown': !isNest }"
|
|
||||||
:style="getNoDropdownStyle"
|
|
||||||
>
|
>
|
||||||
<div
|
<el-menu-item
|
||||||
v-if="toRaw(props.item.meta.icon)"
|
:index="resolvePath(onlyOneChild.path)"
|
||||||
class="sub-menu-icon"
|
:class="{ 'submenu-title-noDropdown': !isNest }"
|
||||||
:style="getsubMenuIconStyle"
|
:style="getNoDropdownStyle"
|
||||||
|
v-bind="attrs"
|
||||||
>
|
>
|
||||||
<component
|
<div
|
||||||
:is="
|
v-if="toRaw(props.item.meta.icon)"
|
||||||
useRenderIcon(
|
class="sub-menu-icon"
|
||||||
toRaw(onlyOneChild.meta.icon) ||
|
:style="getSubMenuIconStyle"
|
||||||
(props.item.meta && toRaw(props.item.meta.icon))
|
>
|
||||||
)
|
<component
|
||||||
|
:is="
|
||||||
|
useRenderIcon(
|
||||||
|
toRaw(onlyOneChild.meta.icon) ||
|
||||||
|
(props.item.meta && toRaw(props.item.meta.icon))
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<el-text
|
||||||
|
v-if="
|
||||||
|
(!props.item?.meta.icon &&
|
||||||
|
isCollapse &&
|
||||||
|
layout === 'vertical' &&
|
||||||
|
props.item?.pathList?.length === 1) ||
|
||||||
|
(!onlyOneChild.meta.icon &&
|
||||||
|
isCollapse &&
|
||||||
|
layout === 'mix' &&
|
||||||
|
props.item?.pathList?.length === 2)
|
||||||
"
|
"
|
||||||
/>
|
truncated
|
||||||
</div>
|
class="!px-4 !text-inherit"
|
||||||
<span
|
>
|
||||||
v-if="
|
{{ onlyOneChild.meta.title }}
|
||||||
!props.item?.meta.icon &&
|
</el-text>
|
||||||
isCollapse &&
|
|
||||||
layout === 'vertical' &&
|
<template #title>
|
||||||
props.item?.pathList?.length === 1
|
<div :style="getDivStyle">
|
||||||
"
|
<ReText
|
||||||
:style="getSpanStyle"
|
:tippyProps="{
|
||||||
>
|
offset: [0, -10],
|
||||||
{{ overflowSlice(onlyOneChild.meta.title) }}
|
theme: tooltipEffect
|
||||||
</span>
|
}"
|
||||||
<span
|
class="!text-inherit"
|
||||||
v-if="
|
|
||||||
!onlyOneChild.meta.icon &&
|
|
||||||
isCollapse &&
|
|
||||||
layout === 'mix' &&
|
|
||||||
props.item?.pathList?.length === 2
|
|
||||||
"
|
|
||||||
:style="getSpanStyle"
|
|
||||||
>
|
|
||||||
{{ overflowSlice(onlyOneChild.meta.title) }}
|
|
||||||
</span>
|
|
||||||
<template #title>
|
|
||||||
<div :style="getDivStyle">
|
|
||||||
<span v-if="layout === 'horizontal'">
|
|
||||||
{{ onlyOneChild.meta.title }}
|
|
||||||
</span>
|
|
||||||
<el-tooltip
|
|
||||||
v-else
|
|
||||||
placement="top"
|
|
||||||
:effect="tooltipEffect"
|
|
||||||
:offset="-10"
|
|
||||||
:disabled="!onlyOneChild.showTooltip"
|
|
||||||
>
|
|
||||||
<template #content>
|
|
||||||
{{ onlyOneChild.meta.title }}
|
|
||||||
</template>
|
|
||||||
<span
|
|
||||||
ref="menuTextRef"
|
|
||||||
:style="getMenuTextStyle"
|
|
||||||
@mouseover="hoverMenu(onlyOneChild)"
|
|
||||||
>
|
>
|
||||||
{{ onlyOneChild.meta.title }}
|
{{ onlyOneChild.meta.title }}
|
||||||
</span>
|
</ReText>
|
||||||
</el-tooltip>
|
<extraIcon :extraIcon="onlyOneChild.meta.extraIcon" />
|
||||||
<extraIcon :extraIcon="onlyOneChild.meta.extraIcon" />
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
</el-menu-item>
|
||||||
</el-menu-item>
|
</link-item>
|
||||||
|
|
||||||
<el-sub-menu
|
<el-sub-menu
|
||||||
v-else
|
v-else
|
||||||
ref="subMenu"
|
ref="subMenu"
|
||||||
v-bind="expandCloseIcon"
|
teleported
|
||||||
:index="resolvePath(props.item.path)"
|
:index="resolvePath(props.item.path)"
|
||||||
|
v-bind="expandCloseIcon"
|
||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<div
|
<div
|
||||||
v-if="toRaw(props.item.meta.icon)"
|
v-if="toRaw(props.item.meta.icon)"
|
||||||
:style="getsubMenuIconStyle"
|
:style="getSubMenuIconStyle"
|
||||||
class="sub-menu-icon"
|
class="sub-menu-icon"
|
||||||
>
|
>
|
||||||
<component
|
<component
|
||||||
:is="useRenderIcon(props.item.meta && toRaw(props.item.meta.icon))"
|
:is="useRenderIcon(props.item.meta && toRaw(props.item.meta.icon))"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span v-if="layout === 'horizontal'">
|
<ReText
|
||||||
{{ props.item.meta.title }}
|
|
||||||
</span>
|
|
||||||
<div
|
|
||||||
:style="getSubMenuDivStyle(props.item)"
|
|
||||||
v-if="
|
v-if="
|
||||||
!(
|
!(
|
||||||
|
layout === 'vertical' &&
|
||||||
isCollapse &&
|
isCollapse &&
|
||||||
toRaw(props.item.meta.icon) &&
|
toRaw(props.item.meta.icon) &&
|
||||||
props.item.parentId === null
|
props.item.parentId === null
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
:tippyProps="{
|
||||||
|
offset: [0, -10],
|
||||||
|
theme: tooltipEffect
|
||||||
|
}"
|
||||||
|
:class="{
|
||||||
|
'!text-inherit': true,
|
||||||
|
'!px-4':
|
||||||
|
layout !== 'horizontal' &&
|
||||||
|
isCollapse &&
|
||||||
|
!toRaw(props.item.meta.icon) &&
|
||||||
|
props.item.parentId === null
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
<el-tooltip
|
{{ props.item.meta.title }}
|
||||||
v-if="layout !== 'horizontal'"
|
</ReText>
|
||||||
placement="top"
|
<extraIcon v-if="!isCollapse" :extraIcon="props.item.meta.extraIcon" />
|
||||||
:effect="tooltipEffect"
|
|
||||||
:offset="-10"
|
|
||||||
:disabled="!props.item.showTooltip"
|
|
||||||
>
|
|
||||||
<template #content>
|
|
||||||
{{ props.item.meta.title }}
|
|
||||||
</template>
|
|
||||||
<span
|
|
||||||
ref="menuTextRef"
|
|
||||||
:style="getSubTextStyle"
|
|
||||||
@mouseover="hoverMenu(props.item)"
|
|
||||||
>
|
|
||||||
{{ overflowSlice(props.item.meta.title, props.item) }}
|
|
||||||
</span>
|
|
||||||
</el-tooltip>
|
|
||||||
<extraIcon v-if="!isCollapse" :extraIcon="props.item.meta.extraIcon" />
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<sidebar-item
|
<sidebar-item
|
||||||
v-for="child in props.item.children"
|
v-for="child in props.item.children"
|
||||||
:key="child.path"
|
:key="child.path"
|
||||||
|
@ -18,7 +18,14 @@ const showLogo = ref(
|
|||||||
)?.showLogo ?? true
|
)?.showLogo ?? true
|
||||||
);
|
);
|
||||||
|
|
||||||
const { device, pureApp, isCollapse, menuSelect, toggleSideBar } = useNav();
|
const {
|
||||||
|
device,
|
||||||
|
pureApp,
|
||||||
|
isCollapse,
|
||||||
|
tooltipEffect,
|
||||||
|
menuSelect,
|
||||||
|
toggleSideBar
|
||||||
|
} = useNav();
|
||||||
|
|
||||||
const subMenuData = ref([]);
|
const subMenuData = ref([]);
|
||||||
|
|
||||||
@ -80,7 +87,7 @@ onBeforeUnmount(() => {
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:class="['sidebar-container', showLogo ? 'has-logo' : '']"
|
:class="['sidebar-container', showLogo ? 'has-logo' : 'no-logo']"
|
||||||
>
|
>
|
||||||
<Logo v-if="showLogo" :collapse="isCollapse" />
|
<Logo v-if="showLogo" :collapse="isCollapse" />
|
||||||
<el-scrollbar
|
<el-scrollbar
|
||||||
@ -91,10 +98,12 @@ onBeforeUnmount(() => {
|
|||||||
router
|
router
|
||||||
unique-opened
|
unique-opened
|
||||||
mode="vertical"
|
mode="vertical"
|
||||||
|
popper-class="pure-scrollbar"
|
||||||
class="outer-most select-none"
|
class="outer-most select-none"
|
||||||
:collapse="isCollapse"
|
:collapse="isCollapse"
|
||||||
:default-active="defaultActive"
|
|
||||||
:collapse-transition="false"
|
:collapse-transition="false"
|
||||||
|
:popper-effect="tooltipEffect"
|
||||||
|
:default-active="defaultActive"
|
||||||
>
|
>
|
||||||
<sidebar-item
|
<sidebar-item
|
||||||
v-for="routes in menuData"
|
v-for="routes in menuData"
|
||||||
|
@ -18,26 +18,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes rotate {
|
|
||||||
from {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes close {
|
|
||||||
from {
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
to {
|
|
||||||
transform: translate(0, -50%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.tags-view {
|
.tags-view {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -51,46 +31,40 @@
|
|||||||
.scroll-item {
|
.scroll-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 28px;
|
height: 34px;
|
||||||
padding: 0 6px;
|
padding-left: 6px;
|
||||||
margin-right: 4px;
|
line-height: 34px;
|
||||||
line-height: 28px;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 3px 3px 0 0;
|
|
||||||
box-shadow: 0 0 1px #888;
|
|
||||||
transition: all 0.4s;
|
transition: all 0.4s;
|
||||||
|
|
||||||
|
&:not(:first-child) {
|
||||||
|
padding-right: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
.el-icon-close {
|
.el-icon-close {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
font-size: 10px;
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
color: var(--el-color-primary);
|
color: var(--el-color-primary);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: font-size 0.2s;
|
border-radius: 4px;
|
||||||
transform: translate(-50%, -50%);
|
transition:
|
||||||
|
background-color 0.12s,
|
||||||
|
color 0.12s;
|
||||||
|
transform: translate(0, -50%);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
font-size: 13px;
|
color: rgb(0 0 0 / 88%) !important;
|
||||||
color: #fff;
|
background-color: rgb(0 0 0 / 6%);
|
||||||
background: #b4bccc;
|
|
||||||
border-radius: 50%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.is-closable:not(:first-child) {
|
|
||||||
&:hover {
|
|
||||||
padding-right: 18px;
|
|
||||||
|
|
||||||
&:not(.is-active) {
|
|
||||||
.el-icon-close {
|
|
||||||
animation: close 200ms ease-in forwards;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
.tag-title {
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
color: var(--el-text-color-primary);
|
color: var(--el-text-color-primary);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@ -99,7 +73,6 @@
|
|||||||
.scroll-container {
|
.scroll-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 5px 0;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
@ -109,13 +82,12 @@
|
|||||||
overflow: visible;
|
overflow: visible;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
transition: transform 0.5s ease-in-out;
|
|
||||||
|
|
||||||
.scroll-item {
|
.scroll-item {
|
||||||
transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
||||||
|
|
||||||
&:nth-child(1) {
|
&:nth-child(1) {
|
||||||
margin-left: 5px;
|
padding: 0 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,16 +167,9 @@
|
|||||||
.scroll-item.is-active {
|
.scroll-item.is-active {
|
||||||
position: relative;
|
position: relative;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
box-shadow: 0 0 0.7px #888;
|
||||||
|
|
||||||
&:not(:first-child) {
|
.tag-title {
|
||||||
padding-right: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-icon-close {
|
|
||||||
transform: translate(0, -50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: var(--el-color-primary) !important;
|
color: var(--el-color-primary) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,16 +178,16 @@
|
|||||||
.arrow-right,
|
.arrow-right,
|
||||||
.arrow-down {
|
.arrow-down {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
width: 40px;
|
width: 40px;
|
||||||
height: 38px;
|
height: 34px;
|
||||||
color: var(--el-text-color-primary);
|
color: var(--el-text-color-primary);
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
position: absolute;
|
|
||||||
left: 50%;
|
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
transform: translate(-50%, 50%);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +212,7 @@
|
|||||||
.card-in {
|
.card-in {
|
||||||
color: var(--el-color-primary);
|
color: var(--el-color-primary);
|
||||||
|
|
||||||
a {
|
.tag-title {
|
||||||
color: var(--el-color-primary);
|
color: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,7 +222,7 @@
|
|||||||
color: #666;
|
color: #666;
|
||||||
border: none;
|
border: none;
|
||||||
|
|
||||||
a {
|
.tag-title {
|
||||||
color: #666;
|
color: #666;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,21 +3,26 @@ import { emitter } from "@/utils/mitt";
|
|||||||
import { RouteConfigs } from "../../types";
|
import { RouteConfigs } from "../../types";
|
||||||
import { useTags } from "../../hooks/useTag";
|
import { useTags } from "../../hooks/useTag";
|
||||||
import { routerArrays } from "@/layout/types";
|
import { routerArrays } from "@/layout/types";
|
||||||
|
import { useFullscreen, onClickOutside } from "@vueuse/core";
|
||||||
import { handleAliveRoute, getTopMenu } from "@/router/utils";
|
import { handleAliveRoute, getTopMenu } from "@/router/utils";
|
||||||
import { useSettingStoreHook } from "@/store/modules/settings";
|
import { useSettingStoreHook } from "@/store/modules/settings";
|
||||||
import { useResizeObserver, useFullscreen } from "@vueuse/core";
|
|
||||||
import { isEqual, isAllEmpty, debounce } from "@pureadmin/utils";
|
|
||||||
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
||||||
import { ref, watch, unref, toRaw, nextTick, onBeforeUnmount } from "vue";
|
import { ref, watch, unref, toRaw, nextTick, onBeforeUnmount } from "vue";
|
||||||
|
import {
|
||||||
|
delay,
|
||||||
|
isEqual,
|
||||||
|
isAllEmpty,
|
||||||
|
useResizeObserver
|
||||||
|
} from "@pureadmin/utils";
|
||||||
|
|
||||||
import ExitFullscreen from "@iconify-icons/ri/fullscreen-exit-fill";
|
import ExitFullscreen from "@iconify-icons/ri/fullscreen-exit-fill";
|
||||||
import Fullscreen from "@iconify-icons/ri/fullscreen-fill";
|
import Fullscreen from "@iconify-icons/ri/fullscreen-fill";
|
||||||
import ArrowDown from "@iconify-icons/ri/arrow-down-s-line";
|
import ArrowDown from "@iconify-icons/ri/arrow-down-s-line";
|
||||||
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 CloseBold from "@iconify-icons/ep/close-bold";
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
Close,
|
||||||
route,
|
route,
|
||||||
router,
|
router,
|
||||||
visible,
|
visible,
|
||||||
@ -32,6 +37,7 @@ const {
|
|||||||
pureSetting,
|
pureSetting,
|
||||||
activeIndex,
|
activeIndex,
|
||||||
getTabStyle,
|
getTabStyle,
|
||||||
|
isScrolling,
|
||||||
iconIsActive,
|
iconIsActive,
|
||||||
linkIsActive,
|
linkIsActive,
|
||||||
currentSelect,
|
currentSelect,
|
||||||
@ -47,6 +53,7 @@ const {
|
|||||||
const tabDom = ref();
|
const tabDom = ref();
|
||||||
const containerDom = ref();
|
const containerDom = ref();
|
||||||
const scrollbarDom = ref();
|
const scrollbarDom = ref();
|
||||||
|
const contextmenuRef = ref();
|
||||||
const isShowArrow = ref(false);
|
const isShowArrow = ref(false);
|
||||||
const topPath = getTopMenu()?.path;
|
const topPath = getTopMenu()?.path;
|
||||||
const { VITE_HIDE_HOME } = import.meta.env;
|
const { VITE_HIDE_HOME } = import.meta.env;
|
||||||
@ -130,6 +137,38 @@ const handleScroll = (offset: number): void => {
|
|||||||
translateX.value = 0;
|
translateX.value = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
isScrolling.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleWheel = (event: WheelEvent): void => {
|
||||||
|
isScrolling.value = true;
|
||||||
|
const scrollIntensity = Math.abs(event.deltaX) + Math.abs(event.deltaY);
|
||||||
|
let offset = 0;
|
||||||
|
if (event.deltaX < 0) {
|
||||||
|
offset = scrollIntensity > 0 ? scrollIntensity : 100;
|
||||||
|
} else {
|
||||||
|
offset = scrollIntensity > 0 ? -scrollIntensity : -100;
|
||||||
|
}
|
||||||
|
|
||||||
|
smoothScroll(offset);
|
||||||
|
};
|
||||||
|
|
||||||
|
const smoothScroll = (offset: number): void => {
|
||||||
|
// 每帧滚动的距离
|
||||||
|
const scrollAmount = 20;
|
||||||
|
let remaining = Math.abs(offset);
|
||||||
|
|
||||||
|
const scrollStep = () => {
|
||||||
|
const scrollOffset = Math.sign(offset) * Math.min(scrollAmount, remaining);
|
||||||
|
handleScroll(scrollOffset);
|
||||||
|
remaining -= Math.abs(scrollOffset);
|
||||||
|
|
||||||
|
if (remaining > 0) {
|
||||||
|
requestAnimationFrame(scrollStep);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
requestAnimationFrame(scrollStep);
|
||||||
};
|
};
|
||||||
|
|
||||||
function dynamicRouteTag(value: string): void {
|
function dynamicRouteTag(value: string): void {
|
||||||
@ -140,7 +179,7 @@ function dynamicRouteTag(value: string): void {
|
|||||||
function concatPath(arr: object[], value: string) {
|
function concatPath(arr: object[], value: string) {
|
||||||
if (!hasValue) {
|
if (!hasValue) {
|
||||||
arr.forEach((arrItem: any) => {
|
arr.forEach((arrItem: any) => {
|
||||||
if (arrItem.path === value || arrItem.path === value) {
|
if (arrItem.path === value) {
|
||||||
useMultiTagsStoreHook().handleTags("push", {
|
useMultiTagsStoreHook().handleTags("push", {
|
||||||
path: value,
|
path: value,
|
||||||
meta: arrItem.meta,
|
meta: arrItem.meta,
|
||||||
@ -326,6 +365,7 @@ function handleCommand(command: any) {
|
|||||||
|
|
||||||
/** 触发右键中菜单的点击事件 */
|
/** 触发右键中菜单的点击事件 */
|
||||||
function selectTag(key, item) {
|
function selectTag(key, item) {
|
||||||
|
closeMenu();
|
||||||
onClickDrop(key, item, currentSelect.value);
|
onClickDrop(key, item, currentSelect.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,7 +459,7 @@ function openMenu(tag, e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentSelect.value = tag;
|
currentSelect.value = tag;
|
||||||
const menuMinWidth = 105;
|
const menuMinWidth = 140;
|
||||||
const offsetLeft = unref(containerDom).getBoundingClientRect().left;
|
const offsetLeft = unref(containerDom).getBoundingClientRect().left;
|
||||||
const offsetWidth = unref(containerDom).offsetWidth;
|
const offsetWidth = unref(containerDom).offsetWidth;
|
||||||
const maxLeft = offsetWidth - menuMinWidth;
|
const maxLeft = offsetWidth - menuMinWidth;
|
||||||
@ -460,6 +500,10 @@ function tagOnClick(item) {
|
|||||||
// showMenuModel(item?.path, item?.query);
|
// showMenuModel(item?.path, item?.query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClickOutside(contextmenuRef, closeMenu, {
|
||||||
|
detectIframe: true
|
||||||
|
});
|
||||||
|
|
||||||
watch(route, () => {
|
watch(route, () => {
|
||||||
activeIndex.value = -1;
|
activeIndex.value = -1;
|
||||||
dynamicTagView();
|
dynamicTagView();
|
||||||
@ -495,10 +539,8 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
useResizeObserver(
|
useResizeObserver(scrollbarDom, dynamicTagView);
|
||||||
scrollbarDom,
|
delay().then(() => dynamicTagView());
|
||||||
debounce(() => dynamicTagView())
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
@ -510,34 +552,31 @@ onBeforeUnmount(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div ref="containerDom" class="tags-view" v-if="!showTags">
|
<div v-if="!showTags" ref="containerDom" class="tags-view">
|
||||||
<span v-show="isShowArrow" class="arrow-left">
|
<span v-show="isShowArrow" class="arrow-left">
|
||||||
<IconifyIconOffline :icon="ArrowLeftSLine" @click="handleScroll(200)" />
|
<IconifyIconOffline :icon="ArrowLeftSLine" @click="handleScroll(200)" />
|
||||||
</span>
|
</span>
|
||||||
<div ref="scrollbarDom" class="scroll-container">
|
<div
|
||||||
<div class="tab select-none" ref="tabDom" :style="getTabStyle">
|
ref="scrollbarDom"
|
||||||
|
class="scroll-container"
|
||||||
|
@wheel.prevent="handleWheel"
|
||||||
|
>
|
||||||
|
<div ref="tabDom" class="tab select-none" :style="getTabStyle">
|
||||||
<div
|
<div
|
||||||
:ref="'dynamic' + index"
|
|
||||||
v-for="(item, index) in multiTags"
|
v-for="(item, index) in multiTags"
|
||||||
|
:ref="'dynamic' + index"
|
||||||
:key="index"
|
:key="index"
|
||||||
:class="[
|
:class="['scroll-item is-closable', linkIsActive(item)]"
|
||||||
'scroll-item is-closable',
|
|
||||||
linkIsActive(item),
|
|
||||||
route.path === item.path && showModel === 'card'
|
|
||||||
? 'card-active'
|
|
||||||
: ''
|
|
||||||
]"
|
|
||||||
@contextmenu.prevent="openMenu(item, $event)"
|
@contextmenu.prevent="openMenu(item, $event)"
|
||||||
@mouseenter.prevent="onMouseenter(index)"
|
@mouseenter.prevent="onMouseenter(index)"
|
||||||
@mouseleave.prevent="onMouseleave(index)"
|
@mouseleave.prevent="onMouseleave(index)"
|
||||||
@click="tagOnClick(item)"
|
@click="tagOnClick(item)"
|
||||||
>
|
>
|
||||||
<router-link
|
<span
|
||||||
:to="item.path"
|
class="tag-title dark:!text-text_color_primary dark:hover:!text-primary"
|
||||||
class="dark:!text-text_color_primary dark:hover:!text-primary"
|
|
||||||
>
|
>
|
||||||
{{ item.meta.title }}
|
{{ item.meta.title }}
|
||||||
</router-link>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="
|
v-if="
|
||||||
iconIsActive(item, index) ||
|
iconIsActive(item, index) ||
|
||||||
@ -546,11 +585,11 @@ onBeforeUnmount(() => {
|
|||||||
class="el-icon-close"
|
class="el-icon-close"
|
||||||
@click.stop="deleteMenu(item)"
|
@click.stop="deleteMenu(item)"
|
||||||
>
|
>
|
||||||
<IconifyIconOffline :icon="CloseBold" />
|
<IconifyIconOffline :icon="Close" />
|
||||||
</span>
|
</span>
|
||||||
<div
|
<span
|
||||||
:ref="'schedule' + index"
|
|
||||||
v-if="showModel !== 'card'"
|
v-if="showModel !== 'card'"
|
||||||
|
:ref="'schedule' + index"
|
||||||
:class="[scheduleIsActive(item)]"
|
:class="[scheduleIsActive(item)]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -563,6 +602,7 @@ onBeforeUnmount(() => {
|
|||||||
<transition name="el-zoom-in-top">
|
<transition name="el-zoom-in-top">
|
||||||
<ul
|
<ul
|
||||||
v-show="visible"
|
v-show="visible"
|
||||||
|
ref="contextmenuRef"
|
||||||
:key="Math.random()"
|
:key="Math.random()"
|
||||||
:style="getContextMenuStyle"
|
:style="getContextMenuStyle"
|
||||||
class="contextmenu"
|
class="contextmenu"
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
<script lang="ts" setup>
|
<script setup lang="ts">
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import { ref, unref, onMounted, nextTick } from "vue";
|
import { ref, unref, watch, onMounted, nextTick } from "vue";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "FrameView"
|
name: "FrameView"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
frameInfo?: {
|
||||||
|
frameSrc?: string;
|
||||||
|
fullPath?: string;
|
||||||
|
};
|
||||||
|
}>();
|
||||||
|
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const currentRoute = useRoute();
|
const currentRoute = useRoute();
|
||||||
const frameSrc = ref<string>("");
|
const frameSrc = ref<string>("");
|
||||||
const frameRef = ref<HTMLElement | null>(null);
|
const frameRef = ref<HTMLElement | null>(null);
|
||||||
|
|
||||||
if (unref(currentRoute.meta)?.frameSrc) {
|
if (unref(currentRoute.meta)?.frameSrc) {
|
||||||
frameSrc.value = unref(currentRoute.meta)?.frameSrc as string;
|
frameSrc.value = unref(currentRoute.meta)?.frameSrc as string;
|
||||||
}
|
}
|
||||||
@ -37,21 +43,38 @@ function init() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => currentRoute.fullPath,
|
||||||
|
path => {
|
||||||
|
if (
|
||||||
|
currentRoute.name === "Redirect" &&
|
||||||
|
path.includes(props.frameInfo?.fullPath)
|
||||||
|
) {
|
||||||
|
frameSrc.value = path; // redirect时,置换成任意值,待重定向后 重新赋值
|
||||||
|
loading.value = true;
|
||||||
|
}
|
||||||
|
// 重新赋值
|
||||||
|
if (props.frameInfo?.fullPath === path) {
|
||||||
|
frameSrc.value = props.frameInfo?.frameSrc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="frame" v-loading="loading" element-loading-text="加载中...">
|
<div v-loading="loading" class="frame" element-loading-text="加载中...">
|
||||||
<iframe :src="frameSrc" class="frame-iframe" ref="frameRef" />
|
<iframe ref="frameRef" :src="frameSrc" class="frame-iframe" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.frame {
|
.frame {
|
||||||
z-index: 998;
|
position: absolute;
|
||||||
height: calc(100vh - 88px);
|
inset: 0;
|
||||||
|
|
||||||
.frame-iframe {
|
.frame-iframe {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { getConfig } from "@/config";
|
import { getConfig } from "@/config";
|
||||||
import { useLayout } from "./useLayout";
|
import { useLayout } from "./useLayout";
|
||||||
import { themeColorsType } from "../types";
|
import { removeToken } from "@/utils/auth";
|
||||||
import { useGlobal } from "@pureadmin/utils";
|
import { routerArrays } from "@/layout/types";
|
||||||
|
import { router, resetRouter } from "@/router";
|
||||||
|
import type { themeColorsType } from "../types";
|
||||||
|
import { useAppStoreHook } from "@/store/modules/app";
|
||||||
|
import { useGlobal, storageLocal } from "@pureadmin/utils";
|
||||||
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
|
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
|
||||||
|
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
|
||||||
import {
|
import {
|
||||||
darken,
|
darken,
|
||||||
lighten,
|
lighten,
|
||||||
@ -13,42 +18,55 @@ import {
|
|||||||
export function useDataThemeChange() {
|
export function useDataThemeChange() {
|
||||||
const { layoutTheme, layout } = useLayout();
|
const { layoutTheme, layout } = useLayout();
|
||||||
const themeColors = ref<Array<themeColorsType>>([
|
const themeColors = ref<Array<themeColorsType>>([
|
||||||
/* 道奇蓝(默认) */
|
|
||||||
{ color: "#1b2a47", themeColor: "default" },
|
|
||||||
/* 亮白色 */
|
/* 亮白色 */
|
||||||
{ color: "#ffffff", themeColor: "light" },
|
{ color: "#ffffff", themeColor: "light" },
|
||||||
|
/* 道奇蓝 */
|
||||||
|
{ color: "#1b2a47", themeColor: "default" },
|
||||||
|
/* 深紫罗兰色 */
|
||||||
|
{ color: "#722ed1", themeColor: "saucePurple" },
|
||||||
|
/* 深粉色 */
|
||||||
|
{ color: "#eb2f96", themeColor: "pink" },
|
||||||
/* 猩红色 */
|
/* 猩红色 */
|
||||||
{ color: "#f5222d", themeColor: "dusk" },
|
{ color: "#f5222d", themeColor: "dusk" },
|
||||||
/* 橙红色 */
|
/* 橙红色 */
|
||||||
{ color: "#fa541c", themeColor: "volcano" },
|
{ color: "#fa541c", themeColor: "volcano" },
|
||||||
/* 金色 */
|
|
||||||
{ color: "#fadb14", themeColor: "yellow" },
|
|
||||||
/* 绿宝石 */
|
/* 绿宝石 */
|
||||||
{ color: "#13c2c2", themeColor: "mingQing" },
|
{ color: "#13c2c2", themeColor: "mingQing" },
|
||||||
/* 酸橙绿 */
|
/* 酸橙绿 */
|
||||||
{ color: "#52c41a", themeColor: "auroraGreen" },
|
{ color: "#52c41a", themeColor: "auroraGreen" }
|
||||||
/* 深粉色 */
|
|
||||||
{ color: "#eb2f96", themeColor: "pink" },
|
|
||||||
/* 深紫罗兰色 */
|
|
||||||
{ color: "#722ed1", themeColor: "saucePurple" }
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const { $storage } = useGlobal<GlobalPropertiesApi>();
|
const { $storage } = useGlobal<GlobalPropertiesApi>();
|
||||||
const dataTheme = ref<boolean>($storage?.layout?.darkMode);
|
const dataTheme = ref<boolean>($storage?.layout?.darkMode);
|
||||||
|
const overallStyle = ref<string>($storage?.layout?.overallStyle);
|
||||||
const body = document.documentElement as HTMLElement;
|
const body = document.documentElement as HTMLElement;
|
||||||
|
|
||||||
|
function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) {
|
||||||
|
const targetEl = target || document.body;
|
||||||
|
let { className } = targetEl;
|
||||||
|
className = className.replace(clsName, "").trim();
|
||||||
|
targetEl.className = flag ? `${className} ${clsName}` : className;
|
||||||
|
}
|
||||||
|
|
||||||
/** 设置导航主题色 */
|
/** 设置导航主题色 */
|
||||||
function setLayoutThemeColor(theme = getConfig().Theme ?? "default") {
|
function setLayoutThemeColor(
|
||||||
|
theme = getConfig().Theme ?? "light",
|
||||||
|
isClick = true
|
||||||
|
) {
|
||||||
layoutTheme.value.theme = theme;
|
layoutTheme.value.theme = theme;
|
||||||
toggleTheme({
|
toggleTheme({
|
||||||
scopeName: `layout-theme-${theme}`
|
scopeName: `layout-theme-${theme}`
|
||||||
});
|
});
|
||||||
|
// 如果非isClick,保留之前的themeColor
|
||||||
|
const storageThemeColor = $storage.layout.themeColor;
|
||||||
$storage.layout = {
|
$storage.layout = {
|
||||||
layout: layout.value,
|
layout: layout.value,
|
||||||
theme,
|
theme,
|
||||||
darkMode: dataTheme.value,
|
darkMode: dataTheme.value,
|
||||||
sidebarStatus: $storage.layout?.sidebarStatus,
|
sidebarStatus: $storage.layout?.sidebarStatus,
|
||||||
epThemeColor: $storage.layout?.epThemeColor
|
epThemeColor: $storage.layout?.epThemeColor,
|
||||||
|
themeColor: isClick ? theme : storageThemeColor,
|
||||||
|
overallStyle: overallStyle.value
|
||||||
};
|
};
|
||||||
|
|
||||||
if (theme === "default" || theme === "light") {
|
if (theme === "default" || theme === "light") {
|
||||||
@ -78,27 +96,48 @@ export function useDataThemeChange() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 日间、夜间主题切换 */
|
/** 浅色、深色整体风格切换 */
|
||||||
function dataThemeChange() {
|
function dataThemeChange(overall?: string) {
|
||||||
/* 如果当前是light夜间主题,默认切换到default主题 */
|
overallStyle.value = overall;
|
||||||
if (useEpThemeStoreHook().epTheme === "light" && dataTheme.value) {
|
if (useEpThemeStoreHook().epTheme === "light" && dataTheme.value) {
|
||||||
setLayoutThemeColor("default");
|
setLayoutThemeColor("default", false);
|
||||||
} else {
|
} else {
|
||||||
setLayoutThemeColor(useEpThemeStoreHook().epTheme);
|
setLayoutThemeColor(useEpThemeStoreHook().epTheme, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataTheme.value) {
|
if (dataTheme.value) {
|
||||||
document.documentElement.classList.add("dark");
|
document.documentElement.classList.add("dark");
|
||||||
} else {
|
} else {
|
||||||
|
if ($storage.layout.themeColor === "light") {
|
||||||
|
setLayoutThemeColor("light", false);
|
||||||
|
}
|
||||||
document.documentElement.classList.remove("dark");
|
document.documentElement.classList.remove("dark");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 清空缓存并返回登录页 */
|
||||||
|
function onReset() {
|
||||||
|
removeToken();
|
||||||
|
storageLocal().clear();
|
||||||
|
const { Grey, Weak, MultiTagsCache, EpThemeColor, Layout } = getConfig();
|
||||||
|
useAppStoreHook().setLayout(Layout);
|
||||||
|
setEpThemeColor(EpThemeColor);
|
||||||
|
useMultiTagsStoreHook().multiTagsCacheChange(MultiTagsCache);
|
||||||
|
toggleClass(Grey, "html-grey", document.querySelector("html"));
|
||||||
|
toggleClass(Weak, "html-weakness", document.querySelector("html"));
|
||||||
|
router.push("/login");
|
||||||
|
useMultiTagsStoreHook().handleTags("equal", [...routerArrays]);
|
||||||
|
resetRouter();
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
body,
|
body,
|
||||||
dataTheme,
|
dataTheme,
|
||||||
|
overallStyle,
|
||||||
layoutTheme,
|
layoutTheme,
|
||||||
themeColors,
|
themeColors,
|
||||||
|
onReset,
|
||||||
|
toggleClass,
|
||||||
dataThemeChange,
|
dataThemeChange,
|
||||||
setEpThemeColor,
|
setEpThemeColor,
|
||||||
setLayoutThemeColor
|
setLayoutThemeColor
|
||||||
|
@ -18,10 +18,12 @@ export function useLayout() {
|
|||||||
if (!$storage.layout) {
|
if (!$storage.layout) {
|
||||||
$storage.layout = {
|
$storage.layout = {
|
||||||
layout: $config?.Layout ?? "vertical",
|
layout: $config?.Layout ?? "vertical",
|
||||||
theme: $config?.Theme ?? "default",
|
theme: $config?.Theme ?? "light",
|
||||||
darkMode: $config?.DarkMode ?? false,
|
darkMode: $config?.DarkMode ?? false,
|
||||||
sidebarStatus: $config?.SidebarStatus ?? true,
|
sidebarStatus: $config?.SidebarStatus ?? true,
|
||||||
epThemeColor: $config?.EpThemeColor ?? "#409EFF"
|
epThemeColor: $config?.EpThemeColor ?? "#409EFF",
|
||||||
|
themeColor: $config?.Theme ?? "light",
|
||||||
|
overallStyle: $config?.OverallStyle ?? "light"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/** 灰色模式、色弱模式、隐藏标签页 */
|
/** 灰色模式、色弱模式、隐藏标签页 */
|
||||||
@ -30,6 +32,7 @@ export function useLayout() {
|
|||||||
grey: $config?.Grey ?? false,
|
grey: $config?.Grey ?? false,
|
||||||
weak: $config?.Weak ?? false,
|
weak: $config?.Weak ?? false,
|
||||||
hideTabs: $config?.HideTabs ?? false,
|
hideTabs: $config?.HideTabs ?? false,
|
||||||
|
hideFooter: $config.HideFooter ?? true,
|
||||||
showLogo: $config?.ShowLogo ?? true,
|
showLogo: $config?.ShowLogo ?? true,
|
||||||
showModel: $config?.ShowModel ?? "smart",
|
showModel: $config?.ShowModel ?? "smart",
|
||||||
multiTagsCache: $config?.MultiTagsCache ?? false
|
multiTagsCache: $config?.MultiTagsCache ?? false
|
||||||
@ -37,7 +40,7 @@ export function useLayout() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 清空缓存后从serverConfig.json读取默认配置并赋值到storage中 */
|
/** 清空缓存后从platform-config.json读取默认配置并赋值到storage中 */
|
||||||
const layout = computed(() => {
|
const layout = computed(() => {
|
||||||
return $storage?.layout.layout;
|
return $storage?.layout.layout;
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import { getConfig } from "@/config";
|
import { getConfig } from "@/config";
|
||||||
import { emitter } from "@/utils/mitt";
|
import { emitter } from "@/utils/mitt";
|
||||||
import { routeMetaType } from "../types";
|
|
||||||
import userAvatar from "@/assets/user.jpg";
|
import userAvatar from "@/assets/user.jpg";
|
||||||
import { getTopMenu } from "@/router/utils";
|
import { getTopMenu } from "@/router/utils";
|
||||||
import { useGlobal } from "@pureadmin/utils";
|
import { useGlobal } from "@pureadmin/utils";
|
||||||
|
import type { routeMetaType } from "../types";
|
||||||
import { useRouter, useRoute } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import { router, remainingPaths } from "@/router";
|
import { router, remainingPaths } from "@/router";
|
||||||
import { computed, type CSSProperties } from "vue";
|
import { computed, type CSSProperties } from "vue";
|
||||||
@ -107,6 +107,11 @@ export function useNav() {
|
|||||||
return remainingPaths.includes(path);
|
return remainingPaths.includes(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取`logo` */
|
||||||
|
function getLogo() {
|
||||||
|
return new URL("/logo.svg", import.meta.url).href;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
route,
|
route,
|
||||||
title,
|
title,
|
||||||
@ -123,6 +128,7 @@ export function useNav() {
|
|||||||
menuSelect,
|
menuSelect,
|
||||||
handleResize,
|
handleResize,
|
||||||
resolvePath,
|
resolvePath,
|
||||||
|
getLogo,
|
||||||
isCollapse,
|
isCollapse,
|
||||||
pureApp,
|
pureApp,
|
||||||
username,
|
username,
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
unref,
|
unref,
|
||||||
watch,
|
|
||||||
computed,
|
computed,
|
||||||
reactive,
|
reactive,
|
||||||
onMounted,
|
onMounted,
|
||||||
CSSProperties,
|
type CSSProperties,
|
||||||
getCurrentInstance
|
getCurrentInstance
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import { tagsViewsType } from "../types";
|
import type { tagsViewsType } from "../types";
|
||||||
import { useEventListener } from "@vueuse/core";
|
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { responsiveStorageNameSpace } from "@/config";
|
import { responsiveStorageNameSpace } from "@/config";
|
||||||
import { useSettingStoreHook } from "@/store/modules/settings";
|
import { useSettingStoreHook } from "@/store/modules/settings";
|
||||||
@ -43,6 +41,7 @@ export function useTags() {
|
|||||||
const activeIndex = ref(-1);
|
const activeIndex = ref(-1);
|
||||||
// 当前右键选中的路由信息
|
// 当前右键选中的路由信息
|
||||||
const currentSelect = ref({});
|
const currentSelect = ref({});
|
||||||
|
const isScrolling = ref(false);
|
||||||
|
|
||||||
/** 显示模式,默认灵动模式 */
|
/** 显示模式,默认灵动模式 */
|
||||||
const showModel = ref(
|
const showModel = ref(
|
||||||
@ -153,7 +152,8 @@ export function useTags() {
|
|||||||
|
|
||||||
const getTabStyle = computed((): CSSProperties => {
|
const getTabStyle = computed((): CSSProperties => {
|
||||||
return {
|
return {
|
||||||
transform: `translateX(${translateX.value}px)`
|
transform: `translateX(${translateX.value}px)`,
|
||||||
|
transition: isScrolling.value ? "none" : "transform 0.5s ease-in-out"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ export function useTags() {
|
|||||||
toggleClass(true, "schedule-in", instance.refs["schedule" + index][0]);
|
toggleClass(true, "schedule-in", instance.refs["schedule" + index][0]);
|
||||||
toggleClass(false, "schedule-out", instance.refs["schedule" + index][0]);
|
toggleClass(false, "schedule-out", instance.refs["schedule" + index][0]);
|
||||||
} else {
|
} else {
|
||||||
if (hasClass(instance.refs["dynamic" + index][0], "card-active")) return;
|
if (hasClass(instance.refs["dynamic" + index][0], "is-active")) return;
|
||||||
toggleClass(true, "card-in", instance.refs["dynamic" + index][0]);
|
toggleClass(true, "card-in", instance.refs["dynamic" + index][0]);
|
||||||
toggleClass(false, "card-out", instance.refs["dynamic" + index][0]);
|
toggleClass(false, "card-out", instance.refs["dynamic" + index][0]);
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ export function useTags() {
|
|||||||
toggleClass(false, "schedule-in", instance.refs["schedule" + index][0]);
|
toggleClass(false, "schedule-in", instance.refs["schedule" + index][0]);
|
||||||
toggleClass(true, "schedule-out", instance.refs["schedule" + index][0]);
|
toggleClass(true, "schedule-out", instance.refs["schedule" + index][0]);
|
||||||
} else {
|
} else {
|
||||||
if (hasClass(instance.refs["dynamic" + index][0], "card-active")) return;
|
if (hasClass(instance.refs["dynamic" + index][0], "is-active")) return;
|
||||||
toggleClass(false, "card-in", instance.refs["dynamic" + index][0]);
|
toggleClass(false, "card-in", instance.refs["dynamic" + index][0]);
|
||||||
toggleClass(true, "card-out", instance.refs["dynamic" + index][0]);
|
toggleClass(true, "card-out", instance.refs["dynamic" + index][0]);
|
||||||
}
|
}
|
||||||
@ -214,14 +214,8 @@ export function useTags() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
|
||||||
() => visible.value,
|
|
||||||
() => {
|
|
||||||
useEventListener(document, "click", closeMenu);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Close,
|
||||||
route,
|
route,
|
||||||
router,
|
router,
|
||||||
visible,
|
visible,
|
||||||
@ -236,6 +230,7 @@ export function useTags() {
|
|||||||
pureSetting,
|
pureSetting,
|
||||||
activeIndex,
|
activeIndex,
|
||||||
getTabStyle,
|
getTabStyle,
|
||||||
|
isScrolling,
|
||||||
iconIsActive,
|
iconIsActive,
|
||||||
linkIsActive,
|
linkIsActive,
|
||||||
currentSelect,
|
currentSelect,
|
||||||
|