feat: 初始化仓库
4
.browserslistrc
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
> 1%
|
||||||
|
last 2 versions
|
||||||
|
not dead
|
||||||
|
not ie 11
|
||||||
21
.dockerignore
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
.eslintcache
|
||||||
|
report.html
|
||||||
|
|
||||||
|
yarn.lock
|
||||||
|
npm-debug.log*
|
||||||
|
.pnpm-error.log*
|
||||||
|
.pnpm-debug.log
|
||||||
|
tests/**/coverage/
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.idea
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
tsconfig.tsbuildinfo
|
||||||
14
.editorconfig
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# http://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
insert_final_newline = false
|
||||||
|
trim_trailing_whitespace = false
|
||||||
5
.env
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# 平台本地运行端口号
|
||||||
|
VITE_PORT = 80
|
||||||
|
|
||||||
|
# 是否隐藏首页 隐藏 true 不隐藏 false (勿删除,VITE_HIDE_HOME只需在.env文件配置)
|
||||||
|
VITE_HIDE_HOME = false
|
||||||
8
.env.development
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# 平台本地运行端口号
|
||||||
|
VITE_PORT = 80
|
||||||
|
|
||||||
|
# 开发环境读取配置文件路径
|
||||||
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
|
# 开发环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
|
VITE_ROUTER_HISTORY = "hash"
|
||||||
13
.env.production
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# 线上环境平台打包路径
|
||||||
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
|
# 线上环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
|
VITE_ROUTER_HISTORY = "hash"
|
||||||
|
|
||||||
|
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
|
||||||
|
VITE_CDN = false
|
||||||
|
|
||||||
|
# 是否启用gzip压缩或brotli压缩(分两种情况,删除原始文件和不删除原始文件)
|
||||||
|
# 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
# 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
VITE_COMPRESSION = "none"
|
||||||
16
.env.staging
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# 预发布也需要生产环境的行为
|
||||||
|
# https://cn.vitejs.dev/guide/env-and-mode.html#modes
|
||||||
|
# NODE_ENV = development
|
||||||
|
|
||||||
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
|
# 预发布环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数")
|
||||||
|
VITE_ROUTER_HISTORY = "hash"
|
||||||
|
|
||||||
|
# 是否在打包时使用cdn替换本地库 替换 true 不替换 false
|
||||||
|
VITE_CDN = true
|
||||||
|
|
||||||
|
# 是否启用gzip压缩或brotli压缩(分两种情况,删除原始文件和不删除原始文件)
|
||||||
|
# 压缩时不删除原始文件的配置:gzip、brotli、both(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
# 压缩时删除原始文件的配置:gzip-clear、brotli-clear、both-clear(同时开启 gzip 与 brotli 压缩)、none(不开启压缩,默认)
|
||||||
|
VITE_COMPRESSION = "none"
|
||||||
22
.gitignore
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
.eslintcache
|
||||||
|
report.html
|
||||||
|
vite.config.*.timestamp*
|
||||||
|
|
||||||
|
yarn.lock
|
||||||
|
npm-debug.log*
|
||||||
|
.pnpm-error.log*
|
||||||
|
.pnpm-debug.log
|
||||||
|
tests/**/coverage/
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.idea
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
tsconfig.tsbuildinfo
|
||||||
8
.husky/commit-msg
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# shellcheck source=./_/husky.sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
PATH="/usr/local/bin:$PATH"
|
||||||
|
|
||||||
|
npx --no-install commitlint --edit "$1"
|
||||||
9
.husky/common.sh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
command_exists () {
|
||||||
|
command -v "$1" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Workaround for Windows 10, Git Bash and Pnpm
|
||||||
|
if command_exists winpty && test -t 1; then
|
||||||
|
exec < /dev/tty
|
||||||
|
fi
|
||||||
10
.husky/pre-commit
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
. "$(dirname "$0")/common.sh"
|
||||||
|
|
||||||
|
[ -n "$CI" ] && exit 0
|
||||||
|
|
||||||
|
PATH="/usr/local/bin:$PATH"
|
||||||
|
|
||||||
|
# Perform lint check on files in the staging area through .lintstagedrc configuration
|
||||||
|
pnpm exec lint-staged
|
||||||
20
.lintstagedrc
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"*.{js,jsx,ts,tsx}": [
|
||||||
|
"prettier --cache --ignore-unknown --write",
|
||||||
|
"eslint --cache --fix"
|
||||||
|
],
|
||||||
|
"{!(package)*.json,*.code-snippets,.!({browserslist,npm,nvm})*rc}": [
|
||||||
|
"prettier --cache --write--parser json"
|
||||||
|
],
|
||||||
|
"package.json": ["prettier --cache --write"],
|
||||||
|
"*.vue": [
|
||||||
|
"prettier --write",
|
||||||
|
"eslint --cache --fix",
|
||||||
|
"stylelint --fix --allow-empty-input"
|
||||||
|
],
|
||||||
|
"*.{css,scss,html}": [
|
||||||
|
"prettier --cache --ignore-unknown --write",
|
||||||
|
"stylelint --fix --allow-empty-input"
|
||||||
|
],
|
||||||
|
"*.md": ["prettier --cache --ignore-unknown --write"]
|
||||||
|
}
|
||||||
11
.markdownlint.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"default": true,
|
||||||
|
"MD003": false,
|
||||||
|
"MD033": false,
|
||||||
|
"MD013": false,
|
||||||
|
"MD001": false,
|
||||||
|
"MD025": false,
|
||||||
|
"MD024": false,
|
||||||
|
"MD007": { "indent": 4 },
|
||||||
|
"no-hard-tabs": false
|
||||||
|
}
|
||||||
4
.npmrc
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
shell-emulator=true
|
||||||
|
shamefully-hoist=true
|
||||||
|
enable-pre-post-scripts=false
|
||||||
|
strict-peer-dependencies=false
|
||||||
9
.prettierrc.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/** @type {import("prettier").Config} */
|
||||||
|
export default {
|
||||||
|
bracketSpacing: true,
|
||||||
|
singleQuote: false,
|
||||||
|
arrowParens: "avoid",
|
||||||
|
trailingComma: "none"
|
||||||
|
};
|
||||||
4
.stylelintignore
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/dist/*
|
||||||
|
/public/*
|
||||||
|
public/*
|
||||||
|
src/style/reset.scss
|
||||||
20
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"christian-kohler.path-intellisense",
|
||||||
|
"warmthsea.vscode-custom-code-color",
|
||||||
|
"vscode-icons-team.vscode-icons",
|
||||||
|
"davidanson.vscode-markdownlint",
|
||||||
|
"ms-azuretools.vscode-docker",
|
||||||
|
"stylelint.vscode-stylelint",
|
||||||
|
"bradlc.vscode-tailwindcss",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"lokalise.i18n-ally",
|
||||||
|
"redhat.vscode-yaml",
|
||||||
|
"csstools.postcss",
|
||||||
|
"mikestead.dotenv",
|
||||||
|
"eamodio.gitlens",
|
||||||
|
"antfu.iconify",
|
||||||
|
"Vue.volar"
|
||||||
|
]
|
||||||
|
}
|
||||||
56
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"editor.formatOnType": true,
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"[vue]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"editor.formatOnPaste": true,
|
||||||
|
"editor.guides.bracketPairs": "active",
|
||||||
|
"files.autoSave": "afterDelay",
|
||||||
|
"git.confirmSync": false,
|
||||||
|
"workbench.startupEditor": "newUntitledFile",
|
||||||
|
"editor.suggestSelection": "first",
|
||||||
|
"editor.acceptSuggestionOnCommitCharacter": false,
|
||||||
|
"css.lint.propertyIgnoredDueToDisplay": "ignore",
|
||||||
|
"editor.quickSuggestions": {
|
||||||
|
"other": true,
|
||||||
|
"comments": true,
|
||||||
|
"strings": true
|
||||||
|
},
|
||||||
|
"files.associations": {
|
||||||
|
"editor.snippetSuggestions": "top"
|
||||||
|
},
|
||||||
|
"[css]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": "explicit"
|
||||||
|
},
|
||||||
|
"i18n-ally.localesPaths": "locales",
|
||||||
|
"i18n-ally.keystyle": "nested",
|
||||||
|
"i18n-ally.sortKeys": true,
|
||||||
|
"i18n-ally.namespace": true,
|
||||||
|
"i18n-ally.enabledParsers": [
|
||||||
|
"yaml",
|
||||||
|
"js"
|
||||||
|
],
|
||||||
|
"i18n-ally.sourceLanguage": "en",
|
||||||
|
"i18n-ally.displayLanguage": "zh-CN",
|
||||||
|
"i18n-ally.enabledFrameworks": [
|
||||||
|
"vue"
|
||||||
|
],
|
||||||
|
"iconify.excludes": [
|
||||||
|
"el"
|
||||||
|
],
|
||||||
|
"vscodeCustomCodeColor.highlightValue": [
|
||||||
|
"v-loading",
|
||||||
|
"v-auth",
|
||||||
|
"v-copy",
|
||||||
|
"v-longpress",
|
||||||
|
"v-optimize",
|
||||||
|
"v-perms",
|
||||||
|
"v-ripple"
|
||||||
|
],
|
||||||
|
"vscodeCustomCodeColor.highlightValueColor": "#b392f0",
|
||||||
|
}
|
||||||
22
.vscode/vue3.0.code-snippets
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"Vue3.0快速生成模板": {
|
||||||
|
"scope": "vue",
|
||||||
|
"prefix": "Vue3.0",
|
||||||
|
"body": [
|
||||||
|
"<template>",
|
||||||
|
"\t<div>test</div>",
|
||||||
|
"</template>\n",
|
||||||
|
"<script lang='ts'>",
|
||||||
|
"export default {",
|
||||||
|
"\tsetup() {",
|
||||||
|
"\t\treturn {}",
|
||||||
|
"\t}",
|
||||||
|
"}",
|
||||||
|
"</script>\n",
|
||||||
|
"<style lang='scss' scoped>\n",
|
||||||
|
"</style>",
|
||||||
|
"$2"
|
||||||
|
],
|
||||||
|
"description": "Vue3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
17
.vscode/vue3.2.code-snippets
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"Vue3.2+快速生成模板": {
|
||||||
|
"scope": "vue",
|
||||||
|
"prefix": "Vue3.2+",
|
||||||
|
"body": [
|
||||||
|
"<script setup lang='ts'>",
|
||||||
|
"</script>\n",
|
||||||
|
"<template>",
|
||||||
|
"\t<div>test</div>",
|
||||||
|
"</template>\n",
|
||||||
|
"<style lang='scss' scoped>\n",
|
||||||
|
"</style>",
|
||||||
|
"$2"
|
||||||
|
],
|
||||||
|
"description": "Vue3.2+"
|
||||||
|
}
|
||||||
|
}
|
||||||
20
.vscode/vue3.3.code-snippets
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"Vue3.3+defineOptions快速生成模板": {
|
||||||
|
"scope": "vue",
|
||||||
|
"prefix": "Vue3.3+",
|
||||||
|
"body": [
|
||||||
|
"<script setup lang='ts'>",
|
||||||
|
"defineOptions({",
|
||||||
|
"\tname: ''",
|
||||||
|
"})",
|
||||||
|
"</script>\n",
|
||||||
|
"<template>",
|
||||||
|
"\t<div>test</div>",
|
||||||
|
"</template>\n",
|
||||||
|
"<style lang='scss' scoped>\n",
|
||||||
|
"</style>",
|
||||||
|
"$2"
|
||||||
|
],
|
||||||
|
"description": "Vue3.3+defineOptions快速生成模板"
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
FROM node:20-alpine as build-stage
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
RUN corepack enable
|
||||||
|
RUN corepack prepare pnpm@latest --activate
|
||||||
|
|
||||||
|
RUN npm config set registry https://registry.npmmirror.com
|
||||||
|
|
||||||
|
COPY .npmrc package.json pnpm-lock.yaml ./
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN pnpm build
|
||||||
|
|
||||||
|
FROM nginx:stable-alpine as production-stage
|
||||||
|
|
||||||
|
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020-present, pure-admin
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
47
README.en-US.md
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<h1>vue-pure-admin Lite Edition(i18n version)</h1>
|
||||||
|
|
||||||
|
[](LICENSE)
|
||||||
|
|
||||||
|
**English** | [中文](./README.md)
|
||||||
|
|
||||||
|
## Introduce
|
||||||
|
|
||||||
|
The simplified version is based on the shelf extracted from [vue-pure-admin](https://github.com/pure-admin/vue-pure-admin), which contains main functions and is more suitable for actual project development. The packaged size is introduced globally [element-plus](https://element-plus.org) is still below `2.3MB`, and the full version of the code will be permanently synchronized. After enabling `brotli` compression and `cdn` to replace the local library mode, the package size is less than `350kb`
|
||||||
|
|
||||||
|
## `js` version
|
||||||
|
|
||||||
|
[Click me to view js version](https://pure-admin.cn/pages/js/)
|
||||||
|
|
||||||
|
## `max` version
|
||||||
|
|
||||||
|
[Click me to view the max version](https://pure-admin.cn/pages/max/)
|
||||||
|
|
||||||
|
## Supporting video
|
||||||
|
|
||||||
|
[Click me to view UI design](https://www.bilibili.com/video/BV17g411T7rq)
|
||||||
|
[Click me to view the rapid development tutorial](https://www.bilibili.com/video/BV1kg411v7QT)
|
||||||
|
|
||||||
|
## Nanny-level documents
|
||||||
|
|
||||||
|
[Click me to view vue-pure-admin documentation](https://pure-admin.cn/)
|
||||||
|
[Click me to view @pureadmin/utils documentation](https://pure-admin-utils.netlify.app)
|
||||||
|
|
||||||
|
## Quality service, software outsourcing, sponsorship support
|
||||||
|
|
||||||
|
[Click me to view details](https://pure-admin.cn/pages/service/)
|
||||||
|
|
||||||
|
## Preview
|
||||||
|
|
||||||
|
[Click me to view the preview station](https://pure-admin-thin.netlify.app/#/login)
|
||||||
|
|
||||||
|
## Maintainer
|
||||||
|
|
||||||
|
[xiaoxian521](https://github.com/xiaoxian521)
|
||||||
|
|
||||||
|
## ⚠️ Attention
|
||||||
|
|
||||||
|
The Lite version does not accept any issues and prs. If you have any questions, please go to the full version [issues](https://github.com/pure-admin/vue-pure-admin/issues/new/choose) to mention, thank you!
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT © 2020-present, pure-admin](./LICENSE)
|
||||||
51
README.md
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<h1>vue-pure-admin精简版(国际化版本)</h1>
|
||||||
|
|
||||||
|
[](LICENSE)
|
||||||
|
|
||||||
|
**中文** | [English](./README.en-US.md)
|
||||||
|
|
||||||
|
## 介绍
|
||||||
|
|
||||||
|
精简版是基于 [vue-pure-admin](https://github.com/pure-admin/vue-pure-admin) 提炼出的架子,包含主体功能,更适合实际项目开发,打包后的大小在全局引入 [element-plus](https://element-plus.org) 的情况下仍然低于 `2.3MB`,并且会永久同步完整版的代码。开启 `brotli` 压缩和 `cdn` 替换本地库模式后,打包大小低于 `350kb`
|
||||||
|
|
||||||
|
## 版本选择
|
||||||
|
|
||||||
|
当前是国际化版本,如果您需要非国际化版本 [请点击](https://github.com/pure-admin/pure-admin-thin)
|
||||||
|
|
||||||
|
## `js` 版本
|
||||||
|
|
||||||
|
[点我查看 js 版本](https://pure-admin.cn/pages/js/)
|
||||||
|
|
||||||
|
## `max` 版本
|
||||||
|
|
||||||
|
[点我查看 max 版本](https://pure-admin.cn/pages/max/)
|
||||||
|
|
||||||
|
## 配套视频
|
||||||
|
|
||||||
|
[点我查看 UI 设计](https://www.bilibili.com/video/BV17g411T7rq)
|
||||||
|
[点我查看快速开发教程](https://www.bilibili.com/video/BV1kg411v7QT)
|
||||||
|
|
||||||
|
## 配套保姆级文档
|
||||||
|
|
||||||
|
[点我查看 vue-pure-admin 文档](https://pure-admin.cn/)
|
||||||
|
[点我查看 @pureadmin/utils 文档](https://pure-admin-utils.netlify.app)
|
||||||
|
|
||||||
|
## 优质服务、软件外包、赞助支持
|
||||||
|
|
||||||
|
[点我查看详情](https://pure-admin.cn/pages/service/)
|
||||||
|
|
||||||
|
## 预览
|
||||||
|
|
||||||
|
[查看预览](https://pure-admin-thin.netlify.app/#/login)
|
||||||
|
|
||||||
|
## 维护者
|
||||||
|
|
||||||
|
[xiaoxian521](https://github.com/xiaoxian521)
|
||||||
|
|
||||||
|
## ⚠️ 注意
|
||||||
|
|
||||||
|
精简版不接受任何 `issues` 和 `pr`,如果有问题请到完整版 [issues](https://github.com/pure-admin/vue-pure-admin/issues/new/choose) 去提,谢谢!
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
[MIT © 2020-present, pure-admin](./LICENSE)
|
||||||
60
build/cdn.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { Plugin as importToCDN } from "vite-plugin-cdn-import";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 打包时采用`cdn`模式,仅限外网使用(默认不采用,如果需要采用cdn模式,请在 .env.production 文件,将 VITE_CDN 设置成true)
|
||||||
|
* 平台采用国内cdn:https://www.bootcdn.cn,当然你也可以选择 https://unpkg.com 或者 https://www.jsdelivr.com
|
||||||
|
* 注意:上面提到的仅限外网使用也不是完全肯定的,如果你们公司内网部署的有相关js、css文件,也可以将下面配置对应改一下,整一套内网版cdn
|
||||||
|
*/
|
||||||
|
export const cdn = importToCDN({
|
||||||
|
//(prodUrl解释: name: 对应下面modules的name,version: 自动读取本地package.json中dependencies依赖中对应包的版本号,path: 对应下面modules的path,当然也可写完整路径,会替换prodUrl)
|
||||||
|
prodUrl: "https://cdn.bootcdn.net/ajax/libs/{name}/{version}/{path}",
|
||||||
|
modules: [
|
||||||
|
{
|
||||||
|
name: "vue",
|
||||||
|
var: "Vue",
|
||||||
|
path: "vue.global.prod.min.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "vue-router",
|
||||||
|
var: "VueRouter",
|
||||||
|
path: "vue-router.global.min.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "vue-i18n",
|
||||||
|
var: "VueI18n",
|
||||||
|
path: "vue-i18n.runtime.global.prod.min.js"
|
||||||
|
},
|
||||||
|
// 项目中没有直接安装vue-demi,但是pinia用到了,所以需要在引入pinia前引入vue-demi(https://github.com/vuejs/pinia/blob/v2/packages/pinia/package.json#L77)
|
||||||
|
{
|
||||||
|
name: "vue-demi",
|
||||||
|
var: "VueDemi",
|
||||||
|
path: "index.iife.min.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "pinia",
|
||||||
|
var: "Pinia",
|
||||||
|
path: "pinia.iife.min.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "element-plus",
|
||||||
|
var: "ElementPlus",
|
||||||
|
path: "index.full.min.js",
|
||||||
|
css: "index.min.css"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "axios",
|
||||||
|
var: "axios",
|
||||||
|
path: "axios.min.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "dayjs",
|
||||||
|
var: "dayjs",
|
||||||
|
path: "dayjs.min.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "echarts",
|
||||||
|
var: "echarts",
|
||||||
|
path: "echarts.min.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
63
build/compress.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import type { Plugin } from "vite";
|
||||||
|
import { isArray } from "@pureadmin/utils";
|
||||||
|
import compressPlugin from "vite-plugin-compression";
|
||||||
|
|
||||||
|
export const configCompressPlugin = (
|
||||||
|
compress: ViteCompression
|
||||||
|
): Plugin | Plugin[] => {
|
||||||
|
if (compress === "none") return null;
|
||||||
|
|
||||||
|
const gz = {
|
||||||
|
// 生成的压缩包后缀
|
||||||
|
ext: ".gz",
|
||||||
|
// 体积大于threshold才会被压缩
|
||||||
|
threshold: 0,
|
||||||
|
// 默认压缩.js|mjs|json|css|html后缀文件,设置成true,压缩全部文件
|
||||||
|
filter: () => true,
|
||||||
|
// 压缩后是否删除原始文件
|
||||||
|
deleteOriginFile: false
|
||||||
|
};
|
||||||
|
const br = {
|
||||||
|
ext: ".br",
|
||||||
|
algorithm: "brotliCompress",
|
||||||
|
threshold: 0,
|
||||||
|
filter: () => true,
|
||||||
|
deleteOriginFile: false
|
||||||
|
};
|
||||||
|
|
||||||
|
const codeList = [
|
||||||
|
{ k: "gzip", v: gz },
|
||||||
|
{ k: "brotli", v: br },
|
||||||
|
{ k: "both", v: [gz, br] }
|
||||||
|
];
|
||||||
|
|
||||||
|
const plugins: Plugin[] = [];
|
||||||
|
|
||||||
|
codeList.forEach(item => {
|
||||||
|
if (compress.includes(item.k)) {
|
||||||
|
if (compress.includes("clear")) {
|
||||||
|
if (isArray(item.v)) {
|
||||||
|
item.v.forEach(vItem => {
|
||||||
|
plugins.push(
|
||||||
|
compressPlugin(Object.assign(vItem, { deleteOriginFile: true }))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
plugins.push(
|
||||||
|
compressPlugin(Object.assign(item.v, { deleteOriginFile: true }))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isArray(item.v)) {
|
||||||
|
item.v.forEach(vItem => {
|
||||||
|
plugins.push(compressPlugin(vItem));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
plugins.push(compressPlugin(item.v));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return plugins;
|
||||||
|
};
|
||||||
52
build/info.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import type { Plugin } from "vite";
|
||||||
|
import gradient from "gradient-string";
|
||||||
|
import { getPackageSize } from "./utils";
|
||||||
|
import dayjs, { type Dayjs } from "dayjs";
|
||||||
|
import duration from "dayjs/plugin/duration";
|
||||||
|
import boxen, { type Options as BoxenOptions } from "boxen";
|
||||||
|
dayjs.extend(duration);
|
||||||
|
|
||||||
|
const boxenOptions: BoxenOptions = {
|
||||||
|
padding: 0.5,
|
||||||
|
borderColor: "cyan",
|
||||||
|
borderStyle: "round"
|
||||||
|
};
|
||||||
|
|
||||||
|
export function viteBuildInfo(): Plugin {
|
||||||
|
let config: { command: string };
|
||||||
|
let startTime: Dayjs;
|
||||||
|
let endTime: Dayjs;
|
||||||
|
let outDir: string;
|
||||||
|
return {
|
||||||
|
name: "vite:buildInfo",
|
||||||
|
configResolved(resolvedConfig) {
|
||||||
|
config = resolvedConfig;
|
||||||
|
outDir = resolvedConfig.build?.outDir ?? "dist";
|
||||||
|
},
|
||||||
|
buildStart() {
|
||||||
|
if (config.command === "build") {
|
||||||
|
startTime = dayjs(new Date());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
closeBundle() {
|
||||||
|
if (config.command === "build") {
|
||||||
|
endTime = dayjs(new Date());
|
||||||
|
getPackageSize({
|
||||||
|
folder: outDir,
|
||||||
|
callback: (size: string) => {
|
||||||
|
console.log(
|
||||||
|
boxen(
|
||||||
|
gradient(["cyan", "magenta"]).multiline(
|
||||||
|
`🎉 恭喜打包完成(总用时${dayjs
|
||||||
|
.duration(endTime.diff(startTime))
|
||||||
|
.format("mm分ss秒")},打包后的大小为${size})`
|
||||||
|
),
|
||||||
|
boxenOptions
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
30
build/optimize.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* 此文件作用于 `vite.config.ts` 的 `optimizeDeps.include` 依赖预构建配置项
|
||||||
|
* 依赖预构建,`vite` 启动时会将下面 include 里的模块,编译成 esm 格式并缓存到 node_modules/.vite 文件夹,页面加载到对应模块时如果浏览器有缓存就读取浏览器缓存,如果没有会读取本地缓存并按需加载
|
||||||
|
* 尤其当您禁用浏览器缓存时(这种情况只应该发生在调试阶段)必须将对应模块加入到 include里,否则会遇到开发环境切换页面卡顿的问题(vite 会认为它是一个新的依赖包会重新加载并强制刷新页面),因为它既无法使用浏览器缓存,又没有在本地 node_modules/.vite 里缓存
|
||||||
|
* 温馨提示:如果您使用的第三方库是全局引入,也就是引入到 src/main.ts 文件里,就不需要再添加到 include 里了,因为 vite 会自动将它们缓存到 node_modules/.vite
|
||||||
|
*/
|
||||||
|
const include = [
|
||||||
|
"qs",
|
||||||
|
"mitt",
|
||||||
|
"dayjs",
|
||||||
|
"axios",
|
||||||
|
"pinia",
|
||||||
|
"vue-i18n",
|
||||||
|
"vue-types",
|
||||||
|
"js-cookie",
|
||||||
|
"vue-tippy",
|
||||||
|
"pinyin-pro",
|
||||||
|
"sortablejs",
|
||||||
|
"@vueuse/core",
|
||||||
|
"@pureadmin/utils",
|
||||||
|
"responsive-storage"
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在预构建中强制排除的依赖项
|
||||||
|
* 温馨提示:所有以 `@iconify-icons/` 开头引入的的本地图标模块,都应该加入到下面的 `exclude` 里,因为平台推荐的使用方式是哪里需要哪里引入而且都是单个的引入,不需要预构建,直接让浏览器加载就好
|
||||||
|
*/
|
||||||
|
const exclude = ["@iconify-icons/ep", "@iconify-icons/ri"];
|
||||||
|
|
||||||
|
export { include, exclude };
|
||||||
55
build/plugins.ts
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import { cdn } from "./cdn";
|
||||||
|
import vue from "@vitejs/plugin-vue";
|
||||||
|
import { pathResolve } from "./utils";
|
||||||
|
import { viteBuildInfo } from "./info";
|
||||||
|
import svgLoader from "vite-svg-loader";
|
||||||
|
import type { PluginOption } from "vite";
|
||||||
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||||
|
import { configCompressPlugin } from "./compress";
|
||||||
|
import removeNoMatch from "vite-plugin-router-warn";
|
||||||
|
import { visualizer } from "rollup-plugin-visualizer";
|
||||||
|
import removeConsole from "vite-plugin-remove-console";
|
||||||
|
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
|
||||||
|
import { codeInspectorPlugin } from "code-inspector-plugin";
|
||||||
|
|
||||||
|
export function getPluginsList(
|
||||||
|
VITE_CDN: boolean,
|
||||||
|
VITE_COMPRESSION: ViteCompression
|
||||||
|
): PluginOption[] {
|
||||||
|
const lifecycle = process.env.npm_lifecycle_event;
|
||||||
|
return [
|
||||||
|
vue(),
|
||||||
|
// jsx、tsx语法支持
|
||||||
|
vueJsx(),
|
||||||
|
VueI18nPlugin({
|
||||||
|
include: [pathResolve("../locales/**")]
|
||||||
|
}),
|
||||||
|
/**
|
||||||
|
* 在页面上按住组合键时,鼠标在页面移动即会在 DOM 上出现遮罩层并显示相关信息,点击一下将自动打开 IDE 并将光标定位到元素对应的代码位置
|
||||||
|
* Mac 默认组合键 Option + Shift
|
||||||
|
* Windows 默认组合键 Alt + Shift
|
||||||
|
* 更多用法看 https://inspector.fe-dev.cn/guide/start.html
|
||||||
|
*/
|
||||||
|
codeInspectorPlugin({
|
||||||
|
bundler: "vite",
|
||||||
|
hideConsole: true
|
||||||
|
}),
|
||||||
|
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(),
|
||||||
|
// svg组件化支持
|
||||||
|
svgLoader(),
|
||||||
|
VITE_CDN ? cdn : null,
|
||||||
|
configCompressPlugin(VITE_COMPRESSION),
|
||||||
|
// 线上环境删除console
|
||||||
|
removeConsole({ external: ["src/assets/iconfont/iconfont.js"] }),
|
||||||
|
// 打包分析
|
||||||
|
lifecycle === "report"
|
||||||
|
? visualizer({ open: true, brotliSize: true, filename: "report.html" })
|
||||||
|
: (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 wrapperEnv = (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__, wrapperEnv, getPackageSize };
|
||||||
35
commitlint.config.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/** @type {import("@commitlint/types").UserConfig} */
|
||||||
|
export default {
|
||||||
|
ignores: [commit => commit.includes("init")],
|
||||||
|
extends: ["@commitlint/config-conventional"],
|
||||||
|
rules: {
|
||||||
|
"body-leading-blank": [2, "always"],
|
||||||
|
"footer-leading-blank": [1, "always"],
|
||||||
|
"header-max-length": [2, "always", 108],
|
||||||
|
"subject-empty": [2, "never"],
|
||||||
|
"type-empty": [2, "never"],
|
||||||
|
"type-enum": [
|
||||||
|
2,
|
||||||
|
"always",
|
||||||
|
[
|
||||||
|
"feat",
|
||||||
|
"fix",
|
||||||
|
"perf",
|
||||||
|
"style",
|
||||||
|
"docs",
|
||||||
|
"test",
|
||||||
|
"refactor",
|
||||||
|
"build",
|
||||||
|
"ci",
|
||||||
|
"chore",
|
||||||
|
"revert",
|
||||||
|
"wip",
|
||||||
|
"workflow",
|
||||||
|
"types",
|
||||||
|
"release"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
184
eslint.config.js
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
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: [
|
||||||
|
"**/.*",
|
||||||
|
"dist/*",
|
||||||
|
"*.d.ts",
|
||||||
|
"public/*",
|
||||||
|
"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",
|
||||||
|
warnOnUnsupportedTypeScriptVersion: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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-unused-expressions": "off",
|
||||||
|
"@typescript-eslint/no-unsafe-function-type": "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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
87
index.html
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||||
|
<meta name="renderer" content="webkit" />
|
||||||
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
|
||||||
|
/>
|
||||||
|
<title>pure-admin-thin</title>
|
||||||
|
<link rel="icon" href="/favicon.ico" />
|
||||||
|
<script>
|
||||||
|
window.process = {};
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="app">
|
||||||
|
<style>
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
#app {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader,
|
||||||
|
.loader::before,
|
||||||
|
.loader::after {
|
||||||
|
width: 2.5em;
|
||||||
|
height: 2.5em;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: load-animation 1.8s infinite ease-in-out;
|
||||||
|
animation-fill-mode: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader {
|
||||||
|
position: relative;
|
||||||
|
top: 0;
|
||||||
|
margin: 80px auto;
|
||||||
|
font-size: 10px;
|
||||||
|
color: #406eeb;
|
||||||
|
text-indent: -9999em;
|
||||||
|
transform: translateZ(0);
|
||||||
|
transform: translate(-50%, 0);
|
||||||
|
animation-delay: -0.16s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader::before,
|
||||||
|
.loader::after {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
content: "";
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader::before {
|
||||||
|
left: -3.5em;
|
||||||
|
animation-delay: -0.32s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader::after {
|
||||||
|
left: 3.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes load-animation {
|
||||||
|
0%,
|
||||||
|
80%,
|
||||||
|
100% {
|
||||||
|
box-shadow: 0 2.5em 0 -1.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
40% {
|
||||||
|
box-shadow: 0 2.5em 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="loader"></div>
|
||||||
|
</div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
124
locales/en.yaml
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
buttons:
|
||||||
|
pureLoginOut: LoginOut
|
||||||
|
pureLogin: Login
|
||||||
|
pureOpenSystemSet: Open System Configs
|
||||||
|
pureReload: Reload
|
||||||
|
pureCloseCurrentTab: Close CurrentTab
|
||||||
|
pureCloseLeftTabs: Close LeftTabs
|
||||||
|
pureCloseRightTabs: Close RightTabs
|
||||||
|
pureCloseOtherTabs: Close OtherTabs
|
||||||
|
pureCloseAllTabs: Close AllTabs
|
||||||
|
pureContentFullScreen: Content FullScreen
|
||||||
|
pureContentExitFullScreen: Content ExitFullScreen
|
||||||
|
pureClickCollapse: Collapse
|
||||||
|
pureClickExpand: Expand
|
||||||
|
pureConfirm: Confirm
|
||||||
|
pureSwitch: Switch
|
||||||
|
pureClose: Close
|
||||||
|
pureBackTop: BackTop
|
||||||
|
pureOpenText: Open
|
||||||
|
pureCloseText: Close
|
||||||
|
search:
|
||||||
|
pureTotal: Total
|
||||||
|
pureHistory: History
|
||||||
|
pureCollect: Collect
|
||||||
|
pureDragSort: (Drag Sort)
|
||||||
|
pureEmpty: Empty
|
||||||
|
purePlaceholder: Search Menu
|
||||||
|
panel:
|
||||||
|
pureSystemSet: System Configs
|
||||||
|
pureCloseSystemSet: Close System Configs
|
||||||
|
pureClearCacheAndToLogin: Clear cache and return to login page
|
||||||
|
pureClearCache: Clear Cache
|
||||||
|
pureOverallStyle: Overall Style
|
||||||
|
pureOverallStyleLight: Light
|
||||||
|
pureOverallStyleLightTip: Set sail freshly and light up the comfortable work interface
|
||||||
|
pureOverallStyleDark: Dark
|
||||||
|
pureOverallStyleDarkTip: Moonlight Overture, indulge in the tranquility and elegance of the night
|
||||||
|
pureOverallStyleSystem: Auto
|
||||||
|
pureOverallStyleSystemTip: Synchronize time, the interface naturally responds to morning and dusk
|
||||||
|
pureThemeColor: Theme Color
|
||||||
|
pureLayoutModel: Layout Model
|
||||||
|
pureVerticalTip: The menu on the left is familiar and friendly
|
||||||
|
pureHorizontalTip: Top menu, concise overview
|
||||||
|
pureMixTip: Mixed menu, flexible
|
||||||
|
pureStretch: Stretch Page
|
||||||
|
pureStretchFixed: Fixed
|
||||||
|
pureStretchFixedTip: Compact pages make it easy to find the information you need
|
||||||
|
pureStretchCustom: Custom
|
||||||
|
pureStretchCustomTip: Minimum 1280, maximum 1600
|
||||||
|
pureTagsStyle: Tags Style
|
||||||
|
pureTagsStyleSmart: Smart
|
||||||
|
pureTagsStyleSmartTip: Smart tags add fun and brilliance
|
||||||
|
pureTagsStyleCard: Card
|
||||||
|
pureTagsStyleCardTip: Card tags for efficient browsing
|
||||||
|
pureTagsStyleChrome: Chrome
|
||||||
|
pureTagsStyleChromeTip: Chrome style is classic and elegant
|
||||||
|
pureInterfaceDisplay: Interface Display
|
||||||
|
pureGreyModel: Grey Model
|
||||||
|
pureWeakModel: Weak Model
|
||||||
|
pureHiddenTags: Hidden Tags
|
||||||
|
pureHiddenFooter: Hidden Footer
|
||||||
|
pureMultiTagsCache: MultiTags Cache
|
||||||
|
menus:
|
||||||
|
pureHome: Home
|
||||||
|
pureLogin: Login
|
||||||
|
pureAbnormal: Abnormal Page
|
||||||
|
pureFourZeroFour: "404"
|
||||||
|
pureFourZeroOne: "403"
|
||||||
|
pureFive: "500"
|
||||||
|
purePermission: Permission Manage
|
||||||
|
purePermissionPage: Page Permission
|
||||||
|
purePermissionButton: Button Permission
|
||||||
|
purePermissionButtonRouter: Route return button permission
|
||||||
|
purePermissionButtonLogin: Login interface return button permission
|
||||||
|
status:
|
||||||
|
pureLoad: Loading...
|
||||||
|
pureMessage: Message
|
||||||
|
pureNotify: Notify
|
||||||
|
pureTodo: Todo
|
||||||
|
pureNoMessage: No Message
|
||||||
|
pureNoNotify: No Notify
|
||||||
|
pureNoTodo: No Todo
|
||||||
|
login:
|
||||||
|
pureUsername: Username
|
||||||
|
purePassword: Password
|
||||||
|
pureVerifyCode: VerifyCode
|
||||||
|
pureRemember: days no need to login
|
||||||
|
pureRememberInfo: After checking and logging in, will automatically log in to the system without entering your username and password within the specified number of days.
|
||||||
|
pureSure: Sure Password
|
||||||
|
pureForget: Forget Password?
|
||||||
|
pureLogin: Login
|
||||||
|
pureThirdLogin: Third Login
|
||||||
|
purePhoneLogin: Phone Login
|
||||||
|
pureQRCodeLogin: QRCode Login
|
||||||
|
pureRegister: Register
|
||||||
|
pureWeChatLogin: WeChat Login
|
||||||
|
pureAlipayLogin: Alipay Login
|
||||||
|
pureQQLogin: QQ Login
|
||||||
|
pureWeiBoLogin: Weibo Login
|
||||||
|
purePhone: Phone
|
||||||
|
pureSmsVerifyCode: SMS VerifyCode
|
||||||
|
pureBack: Back
|
||||||
|
pureTest: Mock Test
|
||||||
|
pureTip: After scanning the code, click "Confirm" to complete the login
|
||||||
|
pureDefinite: Definite
|
||||||
|
pureLoginSuccess: Login Success
|
||||||
|
pureLoginFail: Login Fail
|
||||||
|
pureRegisterSuccess: Regist Success
|
||||||
|
pureTickPrivacy: Please tick Privacy Policy
|
||||||
|
pureReadAccept: I have read it carefully and accept
|
||||||
|
purePrivacyPolicy: Privacy Policy
|
||||||
|
pureGetVerifyCode: Get VerifyCode
|
||||||
|
pureInfo: Seconds
|
||||||
|
pureUsernameReg: Please enter username
|
||||||
|
purePassWordReg: Please enter password
|
||||||
|
pureVerifyCodeReg: Please enter verify code
|
||||||
|
pureVerifyCodeCorrectReg: Please enter correct verify code
|
||||||
|
pureVerifyCodeSixReg: Please enter a 6-digit verify code
|
||||||
|
purePhoneReg: Please enter the phone
|
||||||
|
purePhoneCorrectReg: Please enter the correct phone number format
|
||||||
|
purePassWordRuleReg: The password format should be any combination of 8-18 digits
|
||||||
|
purePassWordSureReg: Please enter confirm password
|
||||||
|
purePassWordDifferentReg: The two passwords do not match!
|
||||||
|
purePassWordUpdateReg: Password has been updated
|
||||||
124
locales/zh-CN.yaml
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
buttons:
|
||||||
|
pureLoginOut: 退出系统
|
||||||
|
pureLogin: 登录
|
||||||
|
pureOpenSystemSet: 打开系统配置
|
||||||
|
pureReload: 重新加载
|
||||||
|
pureCloseCurrentTab: 关闭当前标签页
|
||||||
|
pureCloseLeftTabs: 关闭左侧标签页
|
||||||
|
pureCloseRightTabs: 关闭右侧标签页
|
||||||
|
pureCloseOtherTabs: 关闭其他标签页
|
||||||
|
pureCloseAllTabs: 关闭全部标签页
|
||||||
|
pureContentFullScreen: 内容区全屏
|
||||||
|
pureContentExitFullScreen: 内容区退出全屏
|
||||||
|
pureClickCollapse: 点击折叠
|
||||||
|
pureClickExpand: 点击展开
|
||||||
|
pureConfirm: 确认
|
||||||
|
pureSwitch: 切换
|
||||||
|
pureClose: 关闭
|
||||||
|
pureBackTop: 回到顶部
|
||||||
|
pureOpenText: 开
|
||||||
|
pureCloseText: 关
|
||||||
|
search:
|
||||||
|
pureTotal: 共
|
||||||
|
pureHistory: 搜索历史
|
||||||
|
pureCollect: 收藏
|
||||||
|
pureDragSort: (可拖拽排序)
|
||||||
|
pureEmpty: 暂无搜索结果
|
||||||
|
purePlaceholder: 搜索菜单(支持拼音搜索)
|
||||||
|
panel:
|
||||||
|
pureSystemSet: 系统配置
|
||||||
|
pureCloseSystemSet: 关闭配置
|
||||||
|
pureClearCacheAndToLogin: 清空缓存并返回登录页
|
||||||
|
pureClearCache: 清空缓存
|
||||||
|
pureOverallStyle: 整体风格
|
||||||
|
pureOverallStyleLight: 浅色
|
||||||
|
pureOverallStyleLightTip: 清新启航,点亮舒适的工作界面
|
||||||
|
pureOverallStyleDark: 深色
|
||||||
|
pureOverallStyleDarkTip: 月光序曲,沉醉于夜的静谧雅致
|
||||||
|
pureOverallStyleSystem: 自动
|
||||||
|
pureOverallStyleSystemTip: 同步时光,界面随晨昏自然呼应
|
||||||
|
pureThemeColor: 主题色
|
||||||
|
pureLayoutModel: 导航模式
|
||||||
|
pureVerticalTip: 左侧菜单,亲切熟悉
|
||||||
|
pureHorizontalTip: 顶部菜单,简洁概览
|
||||||
|
pureMixTip: 混合菜单,灵活多变
|
||||||
|
pureStretch: 页宽
|
||||||
|
pureStretchFixed: 固定
|
||||||
|
pureStretchFixedTip: 紧凑页面,轻松找到所需信息
|
||||||
|
pureStretchCustom: 自定义
|
||||||
|
pureStretchCustomTip: 最小1280、最大1600
|
||||||
|
pureTagsStyle: 页签风格
|
||||||
|
pureTagsStyleSmart: 灵动
|
||||||
|
pureTagsStyleSmartTip: 灵动标签,添趣生辉
|
||||||
|
pureTagsStyleCard: 卡片
|
||||||
|
pureTagsStyleCardTip: 卡片标签,高效浏览
|
||||||
|
pureTagsStyleChrome: 谷歌
|
||||||
|
pureTagsStyleChromeTip: 谷歌风格,经典美观
|
||||||
|
pureInterfaceDisplay: 界面显示
|
||||||
|
pureGreyModel: 灰色模式
|
||||||
|
pureWeakModel: 色弱模式
|
||||||
|
pureHiddenTags: 隐藏标签页
|
||||||
|
pureHiddenFooter: 隐藏页脚
|
||||||
|
pureMultiTagsCache: 页签持久化
|
||||||
|
menus:
|
||||||
|
pureHome: 首页
|
||||||
|
pureLogin: 登录
|
||||||
|
pureAbnormal: 异常页面
|
||||||
|
pureFourZeroFour: "404"
|
||||||
|
pureFourZeroOne: "403"
|
||||||
|
pureFive: "500"
|
||||||
|
purePermission: 权限管理
|
||||||
|
purePermissionPage: 页面权限
|
||||||
|
purePermissionButton: 按钮权限
|
||||||
|
purePermissionButtonRouter: 路由返回按钮权限
|
||||||
|
purePermissionButtonLogin: 登录接口返回按钮权限
|
||||||
|
status:
|
||||||
|
pureLoad: 加载中...
|
||||||
|
pureMessage: 消息
|
||||||
|
pureNotify: 通知
|
||||||
|
pureTodo: 待办
|
||||||
|
pureNoMessage: 暂无消息
|
||||||
|
pureNoNotify: 暂无通知
|
||||||
|
pureNoTodo: 暂无待办
|
||||||
|
login:
|
||||||
|
pureUsername: 账号
|
||||||
|
purePassword: 密码
|
||||||
|
pureVerifyCode: 验证码
|
||||||
|
pureRemember: 天内免登录
|
||||||
|
pureRememberInfo: 勾选并登录后,规定天数内无需输入用户名和密码会自动登入系统
|
||||||
|
pureSure: 确认密码
|
||||||
|
pureForget: 忘记密码?
|
||||||
|
pureLogin: 登录
|
||||||
|
pureThirdLogin: 第三方登录
|
||||||
|
purePhoneLogin: 手机登录
|
||||||
|
pureQRCodeLogin: 二维码登录
|
||||||
|
pureRegister: 注册
|
||||||
|
pureWeChatLogin: 微信登录
|
||||||
|
pureAlipayLogin: 支付宝登录
|
||||||
|
pureQQLogin: QQ登录
|
||||||
|
pureWeiBoLogin: 微博登录
|
||||||
|
purePhone: 手机号码
|
||||||
|
pureSmsVerifyCode: 短信验证码
|
||||||
|
pureBack: 返回
|
||||||
|
pureTest: 模拟测试
|
||||||
|
pureTip: 扫码后点击"确认",即可完成登录
|
||||||
|
pureDefinite: 确定
|
||||||
|
pureLoginSuccess: 登录成功
|
||||||
|
pureLoginFail: 登录失败
|
||||||
|
pureRegisterSuccess: 注册成功
|
||||||
|
pureTickPrivacy: 请勾选隐私政策
|
||||||
|
pureReadAccept: 我已仔细阅读并接受
|
||||||
|
purePrivacyPolicy: 《隐私政策》
|
||||||
|
pureGetVerifyCode: 获取验证码
|
||||||
|
pureInfo: 秒后重新获取
|
||||||
|
pureUsernameReg: 请输入账号
|
||||||
|
purePassWordReg: 请输入密码
|
||||||
|
pureVerifyCodeReg: 请输入验证码
|
||||||
|
pureVerifyCodeCorrectReg: 请输入正确的验证码
|
||||||
|
pureVerifyCodeSixReg: 请输入6位数字验证码
|
||||||
|
purePhoneReg: 请输入手机号码
|
||||||
|
purePhoneCorrectReg: 请输入正确的手机号码格式
|
||||||
|
purePassWordRuleReg: 密码格式应为8-18位数字、字母、符号的任意两种组合
|
||||||
|
purePassWordSureReg: 请输入确认密码
|
||||||
|
purePassWordDifferentReg: 两次密码不一致!
|
||||||
|
purePassWordUpdateReg: 修改密码成功
|
||||||
161
package.json
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
{
|
||||||
|
"name": "pure-admin-thin",
|
||||||
|
"version": "5.9.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "NODE_OPTIONS=--max-old-space-size=4096 vite",
|
||||||
|
"serve": "pnpm dev",
|
||||||
|
"build": "rimraf dist && NODE_OPTIONS=--max-old-space-size=8192 vite build",
|
||||||
|
"build:staging": "rimraf dist && vite build --mode staging",
|
||||||
|
"report": "rimraf dist && vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"preview:build": "pnpm build && vite preview",
|
||||||
|
"typecheck": "tsc --noEmit && vue-tsc --noEmit --skipLibCheck",
|
||||||
|
"svgo": "svgo -f . -r",
|
||||||
|
"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:prettier": "prettier --write \"src/**/*.{js,ts,json,tsx,css,scss,vue,html,md}\"",
|
||||||
|
"lint:stylelint": "stylelint --cache --fix \"**/*.{html,vue,css,scss}\" --cache-location node_modules/.cache/stylelint/",
|
||||||
|
"lint": "pnpm lint:eslint && pnpm lint:prettier && pnpm lint:stylelint",
|
||||||
|
"prepare": "husky",
|
||||||
|
"preinstall": "npx only-allow pnpm"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"pure-admin-thin",
|
||||||
|
"vue-pure-admin",
|
||||||
|
"element-plus",
|
||||||
|
"tailwindcss",
|
||||||
|
"pure-admin",
|
||||||
|
"typescript",
|
||||||
|
"pinia",
|
||||||
|
"vue3",
|
||||||
|
"vite",
|
||||||
|
"esm"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/pure-admin/pure-admin-thin/tree/i18n",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/pure-admin/pure-admin-thin.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/pure-admin/vue-pure-admin/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"author": {
|
||||||
|
"name": "xiaoxian521",
|
||||||
|
"email": "pureadmin@163.com",
|
||||||
|
"url": "https://github.com/xiaoxian521"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@pureadmin/descriptions": "^1.2.1",
|
||||||
|
"@pureadmin/table": "^3.2.1",
|
||||||
|
"@pureadmin/utils": "^2.5.0",
|
||||||
|
"@vueuse/core": "^12.0.0",
|
||||||
|
"@vueuse/motion": "^2.2.6",
|
||||||
|
"animate.css": "^4.1.1",
|
||||||
|
"axios": "^1.7.9",
|
||||||
|
"dayjs": "^1.11.13",
|
||||||
|
"echarts": "^5.5.1",
|
||||||
|
"element-plus": "^2.9.0",
|
||||||
|
"js-cookie": "^3.0.5",
|
||||||
|
"localforage": "^1.10.0",
|
||||||
|
"mitt": "^3.0.1",
|
||||||
|
"nprogress": "^0.2.0",
|
||||||
|
"path-browserify": "^1.0.1",
|
||||||
|
"pinia": "^2.3.0",
|
||||||
|
"pinyin-pro": "^3.26.0",
|
||||||
|
"qrcode": "^1.5.4",
|
||||||
|
"qs": "^6.13.1",
|
||||||
|
"responsive-storage": "^2.2.0",
|
||||||
|
"sortablejs": "^1.15.6",
|
||||||
|
"typeit": "^8.8.7",
|
||||||
|
"vue": "^3.5.13",
|
||||||
|
"vue-i18n": "^10.0.5",
|
||||||
|
"vue-router": "^4.5.0",
|
||||||
|
"vue-tippy": "^6.5.0",
|
||||||
|
"vue-types": "^5.1.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@commitlint/cli": "^19.6.0",
|
||||||
|
"@commitlint/config-conventional": "^19.6.0",
|
||||||
|
"@commitlint/types": "^19.5.0",
|
||||||
|
"@eslint/js": "^9.16.0",
|
||||||
|
"@faker-js/faker": "^9.3.0",
|
||||||
|
"@iconify-icons/ep": "^1.2.12",
|
||||||
|
"@iconify-icons/ri": "^1.2.10",
|
||||||
|
"@iconify/vue": "^4.2.0",
|
||||||
|
"@intlify/unplugin-vue-i18n": "^6.0.1",
|
||||||
|
"@types/js-cookie": "^3.0.6",
|
||||||
|
"@types/node": "^20.17.9",
|
||||||
|
"@types/nprogress": "^0.2.3",
|
||||||
|
"@types/path-browserify": "^1.0.3",
|
||||||
|
"@types/qs": "^6.9.17",
|
||||||
|
"@types/sortablejs": "^1.15.8",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
||||||
|
"@typescript-eslint/parser": "^8.18.0",
|
||||||
|
"@vitejs/plugin-vue": "^5.2.1",
|
||||||
|
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
||||||
|
"autoprefixer": "^10.4.20",
|
||||||
|
"boxen": "^8.0.1",
|
||||||
|
"code-inspector-plugin": "^0.18.2",
|
||||||
|
"cssnano": "^7.0.6",
|
||||||
|
"eslint": "^9.16.0",
|
||||||
|
"eslint-config-prettier": "^9.1.0",
|
||||||
|
"eslint-define-config": "^2.1.0",
|
||||||
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
|
"eslint-plugin-vue": "^9.32.0",
|
||||||
|
"gradient-string": "^3.0.0",
|
||||||
|
"husky": "^9.1.7",
|
||||||
|
"lint-staged": "^15.2.10",
|
||||||
|
"postcss": "^8.4.49",
|
||||||
|
"postcss-html": "^1.7.0",
|
||||||
|
"postcss-import": "^16.1.0",
|
||||||
|
"postcss-scss": "^4.0.9",
|
||||||
|
"prettier": "^3.4.2",
|
||||||
|
"rimraf": "^6.0.1",
|
||||||
|
"rollup-plugin-visualizer": "^5.12.0",
|
||||||
|
"sass": "^1.82.0",
|
||||||
|
"stylelint": "^16.11.0",
|
||||||
|
"stylelint-config-recess-order": "^5.1.1",
|
||||||
|
"stylelint-config-recommended-vue": "^1.5.0",
|
||||||
|
"stylelint-config-standard-scss": "^13.1.0",
|
||||||
|
"stylelint-prettier": "^5.0.2",
|
||||||
|
"svgo": "^3.3.2",
|
||||||
|
"tailwindcss": "^3.4.16",
|
||||||
|
"typescript": "5.6.3",
|
||||||
|
"vite": "^6.0.3",
|
||||||
|
"vite-plugin-cdn-import": "^1.0.1",
|
||||||
|
"vite-plugin-compression": "^0.5.1",
|
||||||
|
"vite-plugin-fake-server": "^2.1.4",
|
||||||
|
"vite-plugin-remove-console": "^2.2.0",
|
||||||
|
"vite-plugin-router-warn": "^1.0.0",
|
||||||
|
"vite-svg-loader": "^5.1.0",
|
||||||
|
"vue-eslint-parser": "^9.4.3",
|
||||||
|
"vue-tsc": "^2.1.10"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.18.0 || ^20.9.0 || >=22.0.0",
|
||||||
|
"pnpm": ">=9"
|
||||||
|
},
|
||||||
|
"pnpm": {
|
||||||
|
"allowedDeprecatedVersions": {
|
||||||
|
"are-we-there-yet": "*",
|
||||||
|
"sourcemap-codec": "*",
|
||||||
|
"domexception": "*",
|
||||||
|
"w3c-hr-time": "*",
|
||||||
|
"inflight": "*",
|
||||||
|
"npmlog": "*",
|
||||||
|
"rimraf": "*",
|
||||||
|
"stable": "*",
|
||||||
|
"gauge": "*",
|
||||||
|
"abab": "*",
|
||||||
|
"glob": "*"
|
||||||
|
},
|
||||||
|
"peerDependencyRules": {
|
||||||
|
"allowedVersions": {
|
||||||
|
"eslint": "9"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7385
pnpm-lock.yaml
generated
Normal file
12
postcss.config.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/** @type {import('postcss-load-config').Config} */
|
||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
"postcss-import": {},
|
||||||
|
"tailwindcss/nesting": {},
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
...(process.env.NODE_ENV === "production" ? { cssnano: {} } : {})
|
||||||
|
}
|
||||||
|
};
|
||||||
BIN
public/favicon.ico
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
1
public/logo.svg
Normal file
@@ -0,0 +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.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>
|
||||||
|
After Width: | Height: | Size: 706 B |
27
public/platform-config.json
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"Version": "5.9.0",
|
||||||
|
"Title": "PureAdmin",
|
||||||
|
"FixedHeader": true,
|
||||||
|
"HiddenSideBar": false,
|
||||||
|
"MultiTagsCache": false,
|
||||||
|
"KeepAlive": true,
|
||||||
|
"Locale": "zh",
|
||||||
|
"Layout": "vertical",
|
||||||
|
"Theme": "light",
|
||||||
|
"DarkMode": false,
|
||||||
|
"OverallStyle": "light",
|
||||||
|
"Grey": false,
|
||||||
|
"Weak": false,
|
||||||
|
"HideTabs": false,
|
||||||
|
"HideFooter": false,
|
||||||
|
"Stretch": false,
|
||||||
|
"SidebarStatus": true,
|
||||||
|
"EpThemeColor": "#409EFF",
|
||||||
|
"ShowLogo": true,
|
||||||
|
"ShowModel": "smart",
|
||||||
|
"MenuArrowIconNoTransition": false,
|
||||||
|
"CachingAsyncRoutes": false,
|
||||||
|
"TooltipEffect": "light",
|
||||||
|
"ResponsiveStorageNameSpace": "responsive-",
|
||||||
|
"MenuSearchHistory": 6
|
||||||
|
}
|
||||||
27
src/App.vue
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<template>
|
||||||
|
<el-config-provider :locale="currentLocale">
|
||||||
|
<router-view />
|
||||||
|
<ReDialog />
|
||||||
|
</el-config-provider>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent } from "vue";
|
||||||
|
import { ElConfigProvider } from "element-plus";
|
||||||
|
import { ReDialog } from "@/components/ReDialog";
|
||||||
|
import en from "element-plus/es/locale/lang/en";
|
||||||
|
import zhCn from "element-plus/es/locale/lang/zh-cn";
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: "app",
|
||||||
|
components: {
|
||||||
|
[ElConfigProvider.name]: ElConfigProvider,
|
||||||
|
ReDialog
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
currentLocale() {
|
||||||
|
return this.$storage.locale?.locale === "zh" ? zhCn : en;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
10
src/api/routes.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { http } from "@/utils/http";
|
||||||
|
|
||||||
|
type Result = {
|
||||||
|
success: boolean;
|
||||||
|
data: Array<any>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAsyncRoutes = () => {
|
||||||
|
return http.request<Result>("get", "/get-async-routes");
|
||||||
|
};
|
||||||
53
src/api/user.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { http } from "@/utils/http";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录结果
|
||||||
|
*/
|
||||||
|
export type LoginResponse = {
|
||||||
|
/**用户Token */
|
||||||
|
token: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UserResult = {
|
||||||
|
/**用户ID */
|
||||||
|
userId: string;
|
||||||
|
/** 用户名 */
|
||||||
|
username: string;
|
||||||
|
/**用户头像 */
|
||||||
|
avatar: string;
|
||||||
|
/** 用户角色 */
|
||||||
|
roles: string[];
|
||||||
|
/** `token` */
|
||||||
|
accessToken: string;
|
||||||
|
/**用户权限 */
|
||||||
|
permissions: string[];
|
||||||
|
/** `accessToken`的过期时间戳(毫秒) */
|
||||||
|
expires: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 登录 */
|
||||||
|
export const getLogin = (data?: object) => {
|
||||||
|
return http.request<UserResult>("post", "/api/login", {
|
||||||
|
// headers: {
|
||||||
|
// "Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
// },
|
||||||
|
data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export type CaptchaResponse = {
|
||||||
|
/**验证码 */
|
||||||
|
image: string;
|
||||||
|
/**验证码ID */
|
||||||
|
captchaId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 获取验证码 */
|
||||||
|
export const GetCaptchaAPI = () => {
|
||||||
|
return http.request<CaptchaResponse>("get", "/api/captcha");
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UserInfo = {
|
||||||
|
permissions: string[];
|
||||||
|
roles: string[];
|
||||||
|
};
|
||||||
27
src/assets/iconfont/iconfont.css
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
@font-face {
|
||||||
|
font-family: "iconfont"; /* Project id 2208059 */
|
||||||
|
src:
|
||||||
|
url("iconfont.woff2?t=1671895108120") format("woff2"),
|
||||||
|
url("iconfont.woff?t=1671895108120") format("woff"),
|
||||||
|
url("iconfont.ttf?t=1671895108120") format("truetype");
|
||||||
|
}
|
||||||
|
|
||||||
|
.iconfont {
|
||||||
|
font-family: "iconfont" !important;
|
||||||
|
font-size: 16px;
|
||||||
|
font-style: normal;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-iconfont-tabs:before {
|
||||||
|
content: "\e63e";
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-iconfont-logo:before {
|
||||||
|
content: "\e620";
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-iconfont-new:before {
|
||||||
|
content: "\e615";
|
||||||
|
}
|
||||||
69
src/assets/iconfont/iconfont.js
Normal file
30
src/assets/iconfont/iconfont.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"id": "2208059",
|
||||||
|
"name": "pure-admin",
|
||||||
|
"font_family": "iconfont",
|
||||||
|
"css_prefix_text": "pure-iconfont-",
|
||||||
|
"description": "pure-admin-iconfont",
|
||||||
|
"glyphs": [
|
||||||
|
{
|
||||||
|
"icon_id": "20594647",
|
||||||
|
"name": "Tabs",
|
||||||
|
"font_class": "tabs",
|
||||||
|
"unicode": "e63e",
|
||||||
|
"unicode_decimal": 58942
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon_id": "22129506",
|
||||||
|
"name": "PureLogo",
|
||||||
|
"font_class": "logo",
|
||||||
|
"unicode": "e620",
|
||||||
|
"unicode_decimal": 58912
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"icon_id": "7795615",
|
||||||
|
"name": "New",
|
||||||
|
"font_class": "new",
|
||||||
|
"unicode": "e615",
|
||||||
|
"unicode_decimal": 58901
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
src/assets/iconfont/iconfont.ttf
Normal file
BIN
src/assets/iconfont/iconfont.woff
Normal file
BIN
src/assets/iconfont/iconfont.woff2
Normal file
1
src/assets/login/avatar.svg
Normal file
@@ -0,0 +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.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>
|
||||||
|
After Width: | Height: | Size: 706 B |
BIN
src/assets/login/bg.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
1
src/assets/login/illustration.svg
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
1
src/assets/status/403.svg
Normal file
|
After Width: | Height: | Size: 10 KiB |
1
src/assets/status/404.svg
Normal file
|
After Width: | Height: | Size: 11 KiB |
1
src/assets/status/500.svg
Normal file
|
After Width: | Height: | Size: 13 KiB |
1
src/assets/svg/back_top.svg
Normal file
@@ -0,0 +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.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>
|
||||||
|
After Width: | Height: | Size: 533 B |
1
src/assets/svg/dark.svg
Normal file
@@ -0,0 +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.981"/></svg>
|
||||||
|
After Width: | Height: | Size: 262 B |
1
src/assets/svg/day.svg
Normal file
@@ -0,0 +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 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>
|
||||||
|
After Width: | Height: | Size: 435 B |
1
src/assets/svg/enter_outlined.svg
Normal file
@@ -0,0 +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-8"/></svg>
|
||||||
|
After Width: | Height: | Size: 351 B |
1
src/assets/svg/exit_screen.svg
Normal file
@@ -0,0 +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.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>
|
||||||
|
After Width: | Height: | Size: 327 B |
1
src/assets/svg/full_screen.svg
Normal file
@@ -0,0 +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 12h10V4H3zm2-6h6v4H5zM2 6H1V2.5l.5-.5H5v1H2zm13-3.5V6h-1V3h-3V2h3.5zM14 10h1v3.5l-.5.5H11v-1h3zM2 13h3v1H1.5l-.5-.5V10h1z"/></svg>
|
||||||
|
After Width: | Height: | Size: 302 B |
1
src/assets/svg/globalization.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" aria-hidden="true" class="globalization" viewBox="0 0 512 512"><path fill="currentColor" d="m478.33 433.6-90-218a22 22 0 0 0-40.67 0l-90 218a22 22 0 1 0 40.67 16.79L316.66 406h102.67l18.33 44.39A22 22 0 0 0 458 464a22 22 0 0 0 20.32-30.4zM334.83 362 368 281.65 401.17 362zm-66.99-19.08a22 22 0 0 0-4.89-30.7c-.2-.15-15-11.13-36.49-34.73 39.65-53.68 62.11-114.75 71.27-143.49H330a22 22 0 0 0 0-44H214V70a22 22 0 0 0-44 0v20H54a22 22 0 0 0 0 44h197.25c-9.52 26.95-27.05 69.5-53.79 108.36-31.41-41.68-43.08-68.65-43.17-68.87a22 22 0 0 0-40.58 17c.58 1.38 14.55 34.23 52.86 83.93.92 1.19 1.83 2.35 2.74 3.51-39.24 44.35-77.74 71.86-93.85 80.74a22 22 0 1 0 21.07 38.63c2.16-1.18 48.6-26.89 101.63-85.59 22.52 24.08 38 35.44 38.93 36.1a22 22 0 0 0 30.75-4.9z"/></svg>
|
||||||
|
After Width: | Height: | Size: 826 B |
1
src/assets/svg/keyboard_esc.svg
Normal file
@@ -0,0 +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 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>
|
||||||
|
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 |
1
src/assets/table-bar/collapse.svg
Normal file
@@ -0,0 +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 2m10 16H7a1 1 0 0 0 0 2h10a1 1 0 0 0 0-2"/></svg>
|
||||||
|
After Width: | Height: | Size: 439 B |
1
src/assets/table-bar/drag.svg
Normal file
@@ -0,0 +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 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>
|
||||||
|
After Width: | Height: | Size: 392 B |
1
src/assets/table-bar/expand.svg
Normal file
@@ -0,0 +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.5V4z"/></svg>
|
||||||
|
After Width: | Height: | Size: 161 B |
1
src/assets/table-bar/refresh.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg width="32" height="32" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/></svg>
|
||||||
|
After Width: | Height: | Size: 235 B |
1
src/assets/table-bar/settings.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<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>
|
||||||
|
After Width: | Height: | Size: 840 B |
BIN
src/assets/user.jpg
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
5
src/components/ReAuth/index.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import auth from "./src/auth";
|
||||||
|
|
||||||
|
const Auth = auth;
|
||||||
|
|
||||||
|
export { Auth };
|
||||||
20
src/components/ReAuth/src/auth.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { defineComponent, Fragment } from "vue";
|
||||||
|
import { hasAuth } from "@/router/utils";
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: "Auth",
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: undefined,
|
||||||
|
default: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup(props, { slots }) {
|
||||||
|
return () => {
|
||||||
|
if (!slots) return null;
|
||||||
|
return hasAuth(props.value) ? (
|
||||||
|
<Fragment>{slots.default?.()}</Fragment>
|
||||||
|
) : null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
29
src/components/ReCol/index.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { ElCol } from "element-plus";
|
||||||
|
import { h, defineComponent } from "vue";
|
||||||
|
|
||||||
|
// 封装element-plus的el-col组件
|
||||||
|
export default defineComponent({
|
||||||
|
name: "ReCol",
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: Number,
|
||||||
|
default: 24
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
const attrs = this.$attrs;
|
||||||
|
const val = this.value;
|
||||||
|
return h(
|
||||||
|
ElCol,
|
||||||
|
{
|
||||||
|
xs: val,
|
||||||
|
sm: val,
|
||||||
|
md: val,
|
||||||
|
lg: val,
|
||||||
|
xl: val,
|
||||||
|
...attrs
|
||||||
|
},
|
||||||
|
{ default: () => this.$slots.default() }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
69
src/components/ReDialog/index.ts
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import { ref } from "vue";
|
||||||
|
import reDialog from "./index.vue";
|
||||||
|
import { useTimeoutFn } from "@vueuse/core";
|
||||||
|
import { withInstall } from "@pureadmin/utils";
|
||||||
|
import type {
|
||||||
|
EventType,
|
||||||
|
ArgsType,
|
||||||
|
DialogProps,
|
||||||
|
ButtonProps,
|
||||||
|
DialogOptions
|
||||||
|
} from "./type";
|
||||||
|
|
||||||
|
const dialogStore = ref<Array<DialogOptions>>([]);
|
||||||
|
|
||||||
|
/** 打开弹框 */
|
||||||
|
const addDialog = (options: DialogOptions) => {
|
||||||
|
const open = () =>
|
||||||
|
dialogStore.value.push(Object.assign(options, { visible: true }));
|
||||||
|
if (options?.openDelay) {
|
||||||
|
useTimeoutFn(() => {
|
||||||
|
open();
|
||||||
|
}, options.openDelay);
|
||||||
|
} else {
|
||||||
|
open();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 关闭弹框 */
|
||||||
|
const closeDialog = (options: DialogOptions, index: number, args?: any) => {
|
||||||
|
dialogStore.value[index].visible = false;
|
||||||
|
options.closeCallBack && options.closeCallBack({ options, index, args });
|
||||||
|
|
||||||
|
const closeDelay = options?.closeDelay ?? 200;
|
||||||
|
useTimeoutFn(() => {
|
||||||
|
dialogStore.value.splice(index, 1);
|
||||||
|
}, closeDelay);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 更改弹框自身属性值
|
||||||
|
* @param value 属性值
|
||||||
|
* @param key 属性,默认`title`
|
||||||
|
* @param index 弹框索引(默认`0`,代表只有一个弹框,对于嵌套弹框要改哪个弹框的属性值就把该弹框索引赋给`index`)
|
||||||
|
*/
|
||||||
|
const updateDialog = (value: any, key = "title", index = 0) => {
|
||||||
|
dialogStore.value[index][key] = value;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 关闭所有弹框 */
|
||||||
|
const closeAllDialog = () => {
|
||||||
|
dialogStore.value = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 千万别忘了在下面这三处引入并注册下,放心注册,不使用`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#L12
|
||||||
|
* https://github.com/pure-admin/vue-pure-admin/blob/main/src/App.vue#L22
|
||||||
|
*/
|
||||||
|
const ReDialog = withInstall(reDialog);
|
||||||
|
|
||||||
|
export type { EventType, ArgsType, DialogProps, ButtonProps, DialogOptions };
|
||||||
|
export {
|
||||||
|
ReDialog,
|
||||||
|
dialogStore,
|
||||||
|
addDialog,
|
||||||
|
closeDialog,
|
||||||
|
updateDialog,
|
||||||
|
closeAllDialog
|
||||||
|
};
|
||||||
206
src/components/ReDialog/index.vue
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
type EventType,
|
||||||
|
type ButtonProps,
|
||||||
|
type DialogOptions,
|
||||||
|
closeDialog,
|
||||||
|
dialogStore
|
||||||
|
} from "./index";
|
||||||
|
import { ref, computed } from "vue";
|
||||||
|
import { isFunction } from "@pureadmin/utils";
|
||||||
|
import Fullscreen from "@iconify-icons/ri/fullscreen-fill";
|
||||||
|
import ExitFullscreen from "@iconify-icons/ri/fullscreen-exit-fill";
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "ReDialog"
|
||||||
|
});
|
||||||
|
|
||||||
|
const sureBtnMap = ref({});
|
||||||
|
const fullscreen = ref(false);
|
||||||
|
|
||||||
|
const footerButtons = computed(() => {
|
||||||
|
return (options: DialogOptions) => {
|
||||||
|
return options?.footerButtons?.length > 0
|
||||||
|
? options.footerButtons
|
||||||
|
: ([
|
||||||
|
{
|
||||||
|
label: "取消",
|
||||||
|
text: true,
|
||||||
|
bg: true,
|
||||||
|
btnClick: ({ dialog: { options, index } }) => {
|
||||||
|
const done = () =>
|
||||||
|
closeDialog(options, index, { command: "cancel" });
|
||||||
|
if (options?.beforeCancel && isFunction(options?.beforeCancel)) {
|
||||||
|
options.beforeCancel(done, { options, index });
|
||||||
|
} else {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "确定",
|
||||||
|
type: "primary",
|
||||||
|
text: true,
|
||||||
|
bg: true,
|
||||||
|
popconfirm: options?.popconfirm,
|
||||||
|
btnClick: ({ dialog: { options, index } }) => {
|
||||||
|
if (options?.sureBtnLoading) {
|
||||||
|
sureBtnMap.value[index] = Object.assign(
|
||||||
|
{},
|
||||||
|
sureBtnMap.value[index],
|
||||||
|
{
|
||||||
|
loading: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const closeLoading = () => {
|
||||||
|
if (options?.sureBtnLoading) {
|
||||||
|
sureBtnMap.value[index].loading = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const done = () => {
|
||||||
|
closeLoading();
|
||||||
|
closeDialog(options, index, { command: "sure" });
|
||||||
|
};
|
||||||
|
if (options?.beforeSure && isFunction(options?.beforeSure)) {
|
||||||
|
options.beforeSure(done, { options, index, closeLoading });
|
||||||
|
} else {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
] as Array<ButtonProps>);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const fullscreenClass = computed(() => {
|
||||||
|
return [
|
||||||
|
"el-icon",
|
||||||
|
"el-dialog__close",
|
||||||
|
"-translate-x-2",
|
||||||
|
"cursor-pointer",
|
||||||
|
"hover:!text-[red]"
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
function eventsCallBack(
|
||||||
|
event: EventType,
|
||||||
|
options: DialogOptions,
|
||||||
|
index: number,
|
||||||
|
isClickFullScreen = false
|
||||||
|
) {
|
||||||
|
if (!isClickFullScreen) fullscreen.value = options?.fullscreen ?? false;
|
||||||
|
if (options?.[event] && isFunction(options?.[event])) {
|
||||||
|
return options?.[event]({ options, index });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClose(
|
||||||
|
options: DialogOptions,
|
||||||
|
index: number,
|
||||||
|
args = { command: "close" }
|
||||||
|
) {
|
||||||
|
closeDialog(options, index, args);
|
||||||
|
eventsCallBack("close", options, index);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
v-for="(options, index) in dialogStore"
|
||||||
|
:key="index"
|
||||||
|
v-bind="options"
|
||||||
|
v-model="options.visible"
|
||||||
|
class="pure-dialog"
|
||||||
|
:fullscreen="fullscreen ? true : options?.fullscreen ? true : false"
|
||||||
|
@closed="handleClose(options, index)"
|
||||||
|
@opened="eventsCallBack('open', options, index)"
|
||||||
|
@openAutoFocus="eventsCallBack('openAutoFocus', options, index)"
|
||||||
|
@closeAutoFocus="eventsCallBack('closeAutoFocus', options, index)"
|
||||||
|
>
|
||||||
|
<!-- header -->
|
||||||
|
<template
|
||||||
|
v-if="options?.fullscreenIcon || options?.headerRenderer"
|
||||||
|
#header="{ close, titleId, titleClass }"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="options?.fullscreenIcon"
|
||||||
|
class="flex items-center justify-between"
|
||||||
|
>
|
||||||
|
<span :id="titleId" :class="titleClass">{{ options?.title }}</span>
|
||||||
|
<i
|
||||||
|
v-if="!options?.fullscreen"
|
||||||
|
:class="fullscreenClass"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
fullscreen = !fullscreen;
|
||||||
|
eventsCallBack(
|
||||||
|
'fullscreenCallBack',
|
||||||
|
{ ...options, fullscreen },
|
||||||
|
index,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<IconifyIconOffline
|
||||||
|
class="pure-dialog-svg"
|
||||||
|
:icon="
|
||||||
|
options?.fullscreen
|
||||||
|
? ExitFullscreen
|
||||||
|
: fullscreen
|
||||||
|
? ExitFullscreen
|
||||||
|
: Fullscreen
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</i>
|
||||||
|
</div>
|
||||||
|
<component
|
||||||
|
:is="options?.headerRenderer({ close, titleId, titleClass })"
|
||||||
|
v-else
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<component
|
||||||
|
v-bind="options?.props"
|
||||||
|
:is="options.contentRenderer({ options, index })"
|
||||||
|
@close="args => handleClose(options, index, args)"
|
||||||
|
/>
|
||||||
|
<!-- footer -->
|
||||||
|
<template v-if="!options?.hideFooter" #footer>
|
||||||
|
<template v-if="options?.footerRenderer">
|
||||||
|
<component :is="options?.footerRenderer({ options, index })" />
|
||||||
|
</template>
|
||||||
|
<span v-else>
|
||||||
|
<template v-for="(btn, key) in footerButtons(options)" :key="key">
|
||||||
|
<el-popconfirm
|
||||||
|
v-if="btn.popconfirm"
|
||||||
|
v-bind="btn.popconfirm"
|
||||||
|
@confirm="
|
||||||
|
btn.btnClick({
|
||||||
|
dialog: { options, index },
|
||||||
|
button: { btn, index: key }
|
||||||
|
})
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<el-button v-bind="btn">{{ btn?.label }}</el-button>
|
||||||
|
</template>
|
||||||
|
</el-popconfirm>
|
||||||
|
<el-button
|
||||||
|
v-else
|
||||||
|
v-bind="btn"
|
||||||
|
:loading="key === 1 && sureBtnMap[index]?.loading"
|
||||||
|
@click="
|
||||||
|
btn.btnClick({
|
||||||
|
dialog: { options, index },
|
||||||
|
button: { btn, index: key }
|
||||||
|
})
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ btn?.label }}
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
275
src/components/ReDialog/type.ts
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
import type { CSSProperties, VNode, Component } from "vue";
|
||||||
|
|
||||||
|
type DoneFn = (cancel?: boolean) => void;
|
||||||
|
type EventType =
|
||||||
|
| "open"
|
||||||
|
| "close"
|
||||||
|
| "openAutoFocus"
|
||||||
|
| "closeAutoFocus"
|
||||||
|
| "fullscreenCallBack";
|
||||||
|
type ArgsType = {
|
||||||
|
/** `cancel` 点击取消按钮、`sure` 点击确定按钮、`close` 点击右上角关闭按钮或空白页或按下了esc键 */
|
||||||
|
command: "cancel" | "sure" | "close";
|
||||||
|
};
|
||||||
|
type ButtonType =
|
||||||
|
| "primary"
|
||||||
|
| "success"
|
||||||
|
| "warning"
|
||||||
|
| "danger"
|
||||||
|
| "info"
|
||||||
|
| "text";
|
||||||
|
|
||||||
|
/** https://element-plus.org/zh-CN/component/dialog.html#attributes */
|
||||||
|
type DialogProps = {
|
||||||
|
/** `Dialog` 的显示与隐藏 */
|
||||||
|
visible?: boolean;
|
||||||
|
/** `Dialog` 的标题 */
|
||||||
|
title?: string;
|
||||||
|
/** `Dialog` 的宽度,默认 `50%` */
|
||||||
|
width?: string | number;
|
||||||
|
/** 是否为全屏 `Dialog`(会一直处于全屏状态,除非弹框关闭),默认 `false`,`fullscreen` 和 `fullscreenIcon` 都传时只有 `fullscreen` 会生效 */
|
||||||
|
fullscreen?: boolean;
|
||||||
|
/** 是否显示全屏操作图标,默认 `false`,`fullscreen` 和 `fullscreenIcon` 都传时只有 `fullscreen` 会生效 */
|
||||||
|
fullscreenIcon?: boolean;
|
||||||
|
/** `Dialog CSS` 中的 `margin-top` 值,默认 `15vh` */
|
||||||
|
top?: string;
|
||||||
|
/** 是否需要遮罩层,默认 `true` */
|
||||||
|
modal?: boolean;
|
||||||
|
/** `Dialog` 自身是否插入至 `body` 元素上。嵌套的 `Dialog` 必须指定该属性并赋值为 `true`,默认 `false` */
|
||||||
|
appendToBody?: boolean;
|
||||||
|
/** 是否在 `Dialog` 出现时将 `body` 滚动锁定,默认 `true` */
|
||||||
|
lockScroll?: boolean;
|
||||||
|
/** `Dialog` 的自定义类名 */
|
||||||
|
class?: string;
|
||||||
|
/** `Dialog` 的自定义样式 */
|
||||||
|
style?: CSSProperties;
|
||||||
|
/** `Dialog` 打开的延时时间,单位毫秒,默认 `0` */
|
||||||
|
openDelay?: number;
|
||||||
|
/** `Dialog` 关闭的延时时间,单位毫秒,默认 `0` */
|
||||||
|
closeDelay?: number;
|
||||||
|
/** 是否可以通过点击 `modal` 关闭 `Dialog`,默认 `true` */
|
||||||
|
closeOnClickModal?: boolean;
|
||||||
|
/** 是否可以通过按下 `ESC` 关闭 `Dialog`,默认 `true` */
|
||||||
|
closeOnPressEscape?: boolean;
|
||||||
|
/** 是否显示关闭按钮,默认 `true` */
|
||||||
|
showClose?: boolean;
|
||||||
|
/** 关闭前的回调,会暂停 `Dialog` 的关闭. 回调函数内执行 `done` 参数方法的时候才是真正关闭对话框的时候 */
|
||||||
|
beforeClose?: (done: DoneFn) => void;
|
||||||
|
/** 为 `Dialog` 启用可拖拽功能,默认 `false` */
|
||||||
|
draggable?: boolean;
|
||||||
|
/** 是否让 `Dialog` 的 `header` 和 `footer` 部分居中排列,默认 `false` */
|
||||||
|
center?: boolean;
|
||||||
|
/** 是否水平垂直对齐对话框,默认 `false` */
|
||||||
|
alignCenter?: boolean;
|
||||||
|
/** 当关闭 `Dialog` 时,销毁其中的元素,默认 `false` */
|
||||||
|
destroyOnClose?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
//element-plus.org/zh-CN/component/popconfirm.html#attributes
|
||||||
|
type Popconfirm = {
|
||||||
|
/** 标题 */
|
||||||
|
title?: string;
|
||||||
|
/** 确定按钮文字 */
|
||||||
|
confirmButtonText?: string;
|
||||||
|
/** 取消按钮文字 */
|
||||||
|
cancelButtonText?: string;
|
||||||
|
/** 确定按钮类型,默认 `primary` */
|
||||||
|
confirmButtonType?: ButtonType;
|
||||||
|
/** 取消按钮类型,默认 `text` */
|
||||||
|
cancelButtonType?: ButtonType;
|
||||||
|
/** 自定义图标,默认 `QuestionFilled` */
|
||||||
|
icon?: string | Component;
|
||||||
|
/** `Icon` 颜色,默认 `#f90` */
|
||||||
|
iconColor?: string;
|
||||||
|
/** 是否隐藏 `Icon`,默认 `false` */
|
||||||
|
hideIcon?: boolean;
|
||||||
|
/** 关闭时的延迟,默认 `200` */
|
||||||
|
hideAfter?: number;
|
||||||
|
/** 是否将 `popover` 的下拉列表插入至 `body` 元素,默认 `true` */
|
||||||
|
teleported?: boolean;
|
||||||
|
/** 当 `popover` 组件长时间不触发且 `persistent` 属性设置为 `false` 时, `popover` 将会被删除,默认 `false` */
|
||||||
|
persistent?: boolean;
|
||||||
|
/** 弹层宽度,最小宽度 `150px`,默认 `150` */
|
||||||
|
width?: string | number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type BtnClickDialog = {
|
||||||
|
options?: DialogOptions;
|
||||||
|
index?: number;
|
||||||
|
};
|
||||||
|
type BtnClickButton = {
|
||||||
|
btn?: ButtonProps;
|
||||||
|
index?: number;
|
||||||
|
};
|
||||||
|
/** https://element-plus.org/zh-CN/component/button.html#button-attributes */
|
||||||
|
type ButtonProps = {
|
||||||
|
/** 按钮文字 */
|
||||||
|
label: string;
|
||||||
|
/** 按钮尺寸 */
|
||||||
|
size?: "large" | "default" | "small";
|
||||||
|
/** 按钮类型 */
|
||||||
|
type?: "primary" | "success" | "warning" | "danger" | "info";
|
||||||
|
/** 是否为朴素按钮,默认 `false` */
|
||||||
|
plain?: boolean;
|
||||||
|
/** 是否为文字按钮,默认 `false` */
|
||||||
|
text?: boolean;
|
||||||
|
/** 是否显示文字按钮背景颜色,默认 `false` */
|
||||||
|
bg?: boolean;
|
||||||
|
/** 是否为链接按钮,默认 `false` */
|
||||||
|
link?: boolean;
|
||||||
|
/** 是否为圆角按钮,默认 `false` */
|
||||||
|
round?: boolean;
|
||||||
|
/** 是否为圆形按钮,默认 `false` */
|
||||||
|
circle?: boolean;
|
||||||
|
/** 确定按钮的 `Popconfirm` 气泡确认框相关配置 */
|
||||||
|
popconfirm?: Popconfirm;
|
||||||
|
/** 是否为加载中状态,默认 `false` */
|
||||||
|
loading?: boolean;
|
||||||
|
/** 自定义加载中状态图标组件 */
|
||||||
|
loadingIcon?: string | Component;
|
||||||
|
/** 按钮是否为禁用状态,默认 `false` */
|
||||||
|
disabled?: boolean;
|
||||||
|
/** 图标组件 */
|
||||||
|
icon?: string | Component;
|
||||||
|
/** 是否开启原生 `autofocus` 属性,默认 `false` */
|
||||||
|
autofocus?: boolean;
|
||||||
|
/** 原生 `type` 属性,默认 `button` */
|
||||||
|
nativeType?: "button" | "submit" | "reset";
|
||||||
|
/** 自动在两个中文字符之间插入空格 */
|
||||||
|
autoInsertSpace?: boolean;
|
||||||
|
/** 自定义按钮颜色, 并自动计算 `hover` 和 `active` 触发后的颜色 */
|
||||||
|
color?: string;
|
||||||
|
/** `dark` 模式, 意味着自动设置 `color` 为 `dark` 模式的颜色,默认 `false` */
|
||||||
|
dark?: boolean;
|
||||||
|
/** 自定义元素标签 */
|
||||||
|
tag?: string | Component;
|
||||||
|
/** 点击按钮后触发的回调 */
|
||||||
|
btnClick?: ({
|
||||||
|
dialog,
|
||||||
|
button
|
||||||
|
}: {
|
||||||
|
/** 当前 `Dialog` 信息 */
|
||||||
|
dialog: BtnClickDialog;
|
||||||
|
/** 当前 `button` 信息 */
|
||||||
|
button: BtnClickButton;
|
||||||
|
}) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface DialogOptions extends DialogProps {
|
||||||
|
/** 内容区组件的 `props`,可通过 `defineProps` 接收 */
|
||||||
|
props?: any;
|
||||||
|
/** 是否隐藏 `Dialog` 按钮操作区的内容 */
|
||||||
|
hideFooter?: boolean;
|
||||||
|
/** 确定按钮的 `Popconfirm` 气泡确认框相关配置 */
|
||||||
|
popconfirm?: Popconfirm;
|
||||||
|
/** 点击确定按钮后是否开启 `loading` 加载动画 */
|
||||||
|
sureBtnLoading?: boolean;
|
||||||
|
/**
|
||||||
|
* @description 自定义对话框标题的内容渲染器
|
||||||
|
* @see {@link https://element-plus.org/zh-CN/component/dialog.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E5%A4%B4%E9%83%A8}
|
||||||
|
*/
|
||||||
|
headerRenderer?: ({
|
||||||
|
close,
|
||||||
|
titleId,
|
||||||
|
titleClass
|
||||||
|
}: {
|
||||||
|
close: Function;
|
||||||
|
titleId: string;
|
||||||
|
titleClass: string;
|
||||||
|
}) => VNode | Component;
|
||||||
|
/** 自定义内容渲染器 */
|
||||||
|
contentRenderer?: ({
|
||||||
|
options,
|
||||||
|
index
|
||||||
|
}: {
|
||||||
|
options: DialogOptions;
|
||||||
|
index: number;
|
||||||
|
}) => VNode | Component;
|
||||||
|
/** 自定义按钮操作区的内容渲染器,会覆盖`footerButtons`以及默认的 `取消` 和 `确定` 按钮 */
|
||||||
|
footerRenderer?: ({
|
||||||
|
options,
|
||||||
|
index
|
||||||
|
}: {
|
||||||
|
options: DialogOptions;
|
||||||
|
index: number;
|
||||||
|
}) => VNode | Component;
|
||||||
|
/** 自定义底部按钮操作 */
|
||||||
|
footerButtons?: Array<ButtonProps>;
|
||||||
|
/** `Dialog` 打开后的回调 */
|
||||||
|
open?: ({
|
||||||
|
options,
|
||||||
|
index
|
||||||
|
}: {
|
||||||
|
options: DialogOptions;
|
||||||
|
index: number;
|
||||||
|
}) => void;
|
||||||
|
/** `Dialog` 关闭后的回调(只有点击右上角关闭按钮或空白页或按下了esc键关闭页面时才会触发) */
|
||||||
|
close?: ({
|
||||||
|
options,
|
||||||
|
index
|
||||||
|
}: {
|
||||||
|
options: DialogOptions;
|
||||||
|
index: number;
|
||||||
|
}) => void;
|
||||||
|
/** `Dialog` 关闭后的回调。 `args` 返回的 `command` 值解析:`cancel` 点击取消按钮、`sure` 点击确定按钮、`close` 点击右上角关闭按钮或空白页或按下了esc键 */
|
||||||
|
closeCallBack?: ({
|
||||||
|
options,
|
||||||
|
index,
|
||||||
|
args
|
||||||
|
}: {
|
||||||
|
options: DialogOptions;
|
||||||
|
index: number;
|
||||||
|
args: any;
|
||||||
|
}) => void;
|
||||||
|
/** 点击全屏按钮时的回调 */
|
||||||
|
fullscreenCallBack?: ({
|
||||||
|
options,
|
||||||
|
index
|
||||||
|
}: {
|
||||||
|
options: DialogOptions;
|
||||||
|
index: number;
|
||||||
|
}) => void;
|
||||||
|
/** 输入焦点聚焦在 `Dialog` 内容时的回调 */
|
||||||
|
openAutoFocus?: ({
|
||||||
|
options,
|
||||||
|
index
|
||||||
|
}: {
|
||||||
|
options: DialogOptions;
|
||||||
|
index: number;
|
||||||
|
}) => void;
|
||||||
|
/** 输入焦点从 `Dialog` 内容失焦时的回调 */
|
||||||
|
closeAutoFocus?: ({
|
||||||
|
options,
|
||||||
|
index
|
||||||
|
}: {
|
||||||
|
options: DialogOptions;
|
||||||
|
index: number;
|
||||||
|
}) => void;
|
||||||
|
/** 点击底部取消按钮的回调,会暂停 `Dialog` 的关闭. 回调函数内执行 `done` 参数方法的时候才是真正关闭对话框的时候 */
|
||||||
|
beforeCancel?: (
|
||||||
|
done: Function,
|
||||||
|
{
|
||||||
|
options,
|
||||||
|
index
|
||||||
|
}: {
|
||||||
|
options: DialogOptions;
|
||||||
|
index: number;
|
||||||
|
}
|
||||||
|
) => void;
|
||||||
|
/** 点击底部确定按钮的回调,会暂停 `Dialog` 的关闭. 回调函数内执行 `done` 参数方法的时候才是真正关闭对话框的时候 */
|
||||||
|
beforeSure?: (
|
||||||
|
done: Function,
|
||||||
|
{
|
||||||
|
options,
|
||||||
|
index,
|
||||||
|
closeLoading
|
||||||
|
}: {
|
||||||
|
options: DialogOptions;
|
||||||
|
index: number;
|
||||||
|
/** 关闭确定按钮的 `loading` 加载动画 */
|
||||||
|
closeLoading: Function;
|
||||||
|
}
|
||||||
|
) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { EventType, ArgsType, DialogProps, ButtonProps, DialogOptions };
|
||||||
12
src/components/ReIcon/index.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import iconifyIconOffline from "./src/iconifyIconOffline";
|
||||||
|
import iconifyIconOnline from "./src/iconifyIconOnline";
|
||||||
|
import fontIcon from "./src/iconfont";
|
||||||
|
|
||||||
|
/** 本地图标组件 */
|
||||||
|
const IconifyIconOffline = iconifyIconOffline;
|
||||||
|
/** 在线图标组件 */
|
||||||
|
const IconifyIconOnline = iconifyIconOnline;
|
||||||
|
/** `iconfont`组件 */
|
||||||
|
const FontIcon = fontIcon;
|
||||||
|
|
||||||
|
export { IconifyIconOffline, IconifyIconOnline, FontIcon };
|
||||||
61
src/components/ReIcon/src/hooks.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import type { iconType } from "./types";
|
||||||
|
import { h, defineComponent, type Component } from "vue";
|
||||||
|
import { IconifyIconOnline, IconifyIconOffline, FontIcon } from "../index";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支持 `iconfont`、自定义 `svg` 以及 `iconify` 中所有的图标
|
||||||
|
* @see 点击查看文档图标篇 {@link https://pure-admin.cn/pages/icon/}
|
||||||
|
* @param icon 必传 图标
|
||||||
|
* @param attrs 可选 iconType 属性
|
||||||
|
* @returns Component
|
||||||
|
*/
|
||||||
|
export function useRenderIcon(icon: any, attrs?: iconType): Component {
|
||||||
|
// iconfont
|
||||||
|
const ifReg = /^IF-/;
|
||||||
|
// typeof icon === "function" 属于SVG
|
||||||
|
if (ifReg.test(icon)) {
|
||||||
|
// iconfont
|
||||||
|
const name = icon.split(ifReg)[1];
|
||||||
|
const iconName = name.slice(
|
||||||
|
0,
|
||||||
|
name.indexOf(" ") == -1 ? name.length : name.indexOf(" ")
|
||||||
|
);
|
||||||
|
const iconType = name.slice(name.indexOf(" ") + 1, name.length);
|
||||||
|
return defineComponent({
|
||||||
|
name: "FontIcon",
|
||||||
|
render() {
|
||||||
|
return h(FontIcon, {
|
||||||
|
icon: iconName,
|
||||||
|
iconType,
|
||||||
|
...attrs
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (typeof icon === "function" || typeof icon?.render === "function") {
|
||||||
|
// svg
|
||||||
|
return attrs ? h(icon, { ...attrs }) : icon;
|
||||||
|
} else if (typeof icon === "object") {
|
||||||
|
return defineComponent({
|
||||||
|
name: "OfflineIcon",
|
||||||
|
render() {
|
||||||
|
return h(IconifyIconOffline, {
|
||||||
|
icon: icon,
|
||||||
|
...attrs
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 通过是否存在 : 符号来判断是在线还是本地图标,存在即是在线图标,反之
|
||||||
|
return defineComponent({
|
||||||
|
name: "Icon",
|
||||||
|
render() {
|
||||||
|
const IconifyIcon =
|
||||||
|
icon && icon.includes(":") ? IconifyIconOnline : IconifyIconOffline;
|
||||||
|
return h(IconifyIcon, {
|
||||||
|
icon: icon,
|
||||||
|
...attrs
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/components/ReIcon/src/iconfont.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { h, defineComponent } from "vue";
|
||||||
|
|
||||||
|
// 封装iconfont组件,默认`font-class`引用模式,支持`unicode`引用、`font-class`引用、`symbol`引用 (https://www.iconfont.cn/help/detail?spm=a313x.7781069.1998910419.20&helptype=code)
|
||||||
|
export default defineComponent({
|
||||||
|
name: "FontIcon",
|
||||||
|
props: {
|
||||||
|
icon: {
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
const attrs = this.$attrs;
|
||||||
|
if (Object.keys(attrs).includes("uni") || attrs?.iconType === "uni") {
|
||||||
|
return h(
|
||||||
|
"i",
|
||||||
|
{
|
||||||
|
class: "iconfont",
|
||||||
|
...attrs
|
||||||
|
},
|
||||||
|
this.icon
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
Object.keys(attrs).includes("svg") ||
|
||||||
|
attrs?.iconType === "svg"
|
||||||
|
) {
|
||||||
|
return h(
|
||||||
|
"svg",
|
||||||
|
{
|
||||||
|
class: "icon-svg",
|
||||||
|
"aria-hidden": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => [
|
||||||
|
h("use", {
|
||||||
|
"xlink:href": `#${this.icon}`
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return h("i", {
|
||||||
|
class: `iconfont ${this.icon}`,
|
||||||
|
...attrs
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
30
src/components/ReIcon/src/iconifyIconOffline.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { h, defineComponent } from "vue";
|
||||||
|
import { Icon as IconifyIcon, addIcon } from "@iconify/vue/dist/offline";
|
||||||
|
|
||||||
|
// Iconify Icon在Vue里本地使用(用于内网环境)
|
||||||
|
export default defineComponent({
|
||||||
|
name: "IconifyIconOffline",
|
||||||
|
components: { IconifyIcon },
|
||||||
|
props: {
|
||||||
|
icon: {
|
||||||
|
default: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
if (typeof this.icon === "object") addIcon(this.icon, this.icon);
|
||||||
|
const attrs = this.$attrs;
|
||||||
|
return h(
|
||||||
|
IconifyIcon,
|
||||||
|
{
|
||||||
|
icon: this.icon,
|
||||||
|
style: attrs?.style
|
||||||
|
? Object.assign(attrs.style, { outline: "none" })
|
||||||
|
: { outline: "none" },
|
||||||
|
...attrs
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
30
src/components/ReIcon/src/iconifyIconOnline.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { h, defineComponent } from "vue";
|
||||||
|
import { Icon as IconifyIcon } from "@iconify/vue";
|
||||||
|
|
||||||
|
// Iconify Icon在Vue里在线使用(用于外网环境)
|
||||||
|
export default defineComponent({
|
||||||
|
name: "IconifyIconOnline",
|
||||||
|
components: { IconifyIcon },
|
||||||
|
props: {
|
||||||
|
icon: {
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
const attrs = this.$attrs;
|
||||||
|
return h(
|
||||||
|
IconifyIcon,
|
||||||
|
{
|
||||||
|
icon: `${this.icon}`,
|
||||||
|
style: attrs?.style
|
||||||
|
? Object.assign(attrs.style, { outline: "none" })
|
||||||
|
: { outline: "none" },
|
||||||
|
...attrs
|
||||||
|
},
|
||||||
|
{
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
14
src/components/ReIcon/src/offlineIcon.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// 这里存放本地图标,在 src/layout/index.vue 文件中加载,避免在首启动加载
|
||||||
|
import { addIcon } from "@iconify/vue/dist/offline";
|
||||||
|
|
||||||
|
// 本地菜单图标,后端在路由的 icon 中返回对应的图标字符串并且前端在此处使用 addIcon 添加即可渲染菜单图标
|
||||||
|
// @iconify-icons/ep
|
||||||
|
import Lollipop from "@iconify-icons/ep/lollipop";
|
||||||
|
import HomeFilled from "@iconify-icons/ep/home-filled";
|
||||||
|
addIcon("ep:lollipop", Lollipop);
|
||||||
|
addIcon("ep:home-filled", HomeFilled);
|
||||||
|
// @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);
|
||||||
20
src/components/ReIcon/src/types.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
export interface iconType {
|
||||||
|
// iconify (https://docs.iconify.design/icon-components/vue/#properties)
|
||||||
|
inline?: boolean;
|
||||||
|
width?: string | number;
|
||||||
|
height?: string | number;
|
||||||
|
horizontalFlip?: boolean;
|
||||||
|
verticalFlip?: boolean;
|
||||||
|
flip?: string;
|
||||||
|
rotate?: number | string;
|
||||||
|
color?: string;
|
||||||
|
horizontalAlign?: boolean;
|
||||||
|
verticalAlign?: boolean;
|
||||||
|
align?: string;
|
||||||
|
onLoad?: Function;
|
||||||
|
includes?: Function;
|
||||||
|
// svg 需要什么SVG属性自行添加
|
||||||
|
fill?: string;
|
||||||
|
// all icon
|
||||||
|
style?: object;
|
||||||
|
}
|
||||||
7
src/components/ReImageVerify/index.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import reImageVerify from "./src/index.vue";
|
||||||
|
import { withInstall } from "@pureadmin/utils";
|
||||||
|
|
||||||
|
/** 图形验证码组件 */
|
||||||
|
export const ReImageVerify = withInstall(reImageVerify);
|
||||||
|
|
||||||
|
export default ReImageVerify;
|
||||||
85
src/components/ReImageVerify/src/hooks.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import { ref, onMounted } from "vue";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绘制图形验证码
|
||||||
|
* @param width - 图形宽度
|
||||||
|
* @param height - 图形高度
|
||||||
|
*/
|
||||||
|
export const useImageVerify = (width = 120, height = 40) => {
|
||||||
|
const domRef = ref<HTMLCanvasElement>();
|
||||||
|
const imgCode = ref("");
|
||||||
|
|
||||||
|
function setImgCode(code: string) {
|
||||||
|
imgCode.value = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getImgCode() {
|
||||||
|
if (!domRef.value) return;
|
||||||
|
imgCode.value = draw(domRef.value, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getImgCode();
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
domRef,
|
||||||
|
imgCode,
|
||||||
|
setImgCode,
|
||||||
|
getImgCode
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
function randomNum(min: number, max: number) {
|
||||||
|
const num = Math.floor(Math.random() * (max - min) + min);
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
function randomColor(min: number, max: number) {
|
||||||
|
const r = randomNum(min, max);
|
||||||
|
const g = randomNum(min, max);
|
||||||
|
const b = randomNum(min, max);
|
||||||
|
return `rgb(${r},${g},${b})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw(dom: HTMLCanvasElement, width: number, height: number) {
|
||||||
|
let imgCode = "";
|
||||||
|
|
||||||
|
const NUMBER_STRING = "0123456789";
|
||||||
|
|
||||||
|
const ctx = dom.getContext("2d");
|
||||||
|
if (!ctx) return imgCode;
|
||||||
|
|
||||||
|
ctx.fillStyle = randomColor(180, 230);
|
||||||
|
ctx.fillRect(0, 0, width, height);
|
||||||
|
for (let i = 0; i < 4; i += 1) {
|
||||||
|
const text = NUMBER_STRING[randomNum(0, NUMBER_STRING.length)];
|
||||||
|
imgCode += text;
|
||||||
|
const fontSize = randomNum(18, 41);
|
||||||
|
const deg = randomNum(-30, 30);
|
||||||
|
ctx.font = `${fontSize}px Simhei`;
|
||||||
|
ctx.textBaseline = "top";
|
||||||
|
ctx.fillStyle = randomColor(80, 150);
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(30 * i + 15, 15);
|
||||||
|
ctx.rotate((deg * Math.PI) / 180);
|
||||||
|
ctx.fillText(text, -15 + 5, -15);
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
for (let i = 0; i < 5; i += 1) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(randomNum(0, width), randomNum(0, height));
|
||||||
|
ctx.lineTo(randomNum(0, width), randomNum(0, height));
|
||||||
|
ctx.strokeStyle = randomColor(180, 230);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
for (let i = 0; i < 41; i += 1) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(randomNum(0, width), randomNum(0, height), 1, 0, 2 * Math.PI);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fillStyle = randomColor(150, 200);
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
return imgCode;
|
||||||
|
}
|
||||||
46
src/components/ReImageVerify/src/index.vue
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { watch } from "vue";
|
||||||
|
import { useImageVerify } from "./hooks";
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "ReImageVerify"
|
||||||
|
});
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
code?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: "update:code", code: string): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
code: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
|
const { domRef, imgCode, setImgCode, getImgCode } = useImageVerify();
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.code,
|
||||||
|
newValue => {
|
||||||
|
setImgCode(newValue);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
watch(imgCode, newValue => {
|
||||||
|
emit("update:code", newValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
defineExpose({ getImgCode });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<canvas
|
||||||
|
ref="domRef"
|
||||||
|
width="120"
|
||||||
|
height="40"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="getImgCode"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
5
src/components/RePerms/index.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import perms from "./src/perms";
|
||||||
|
|
||||||
|
const Perms = perms;
|
||||||
|
|
||||||
|
export { Perms };
|
||||||
20
src/components/RePerms/src/perms.tsx
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { defineComponent, Fragment } from "vue";
|
||||||
|
import { hasPerms } from "@/utils/auth";
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: "Perms",
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: undefined,
|
||||||
|
default: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup(props, { slots }) {
|
||||||
|
return () => {
|
||||||
|
if (!slots) return null;
|
||||||
|
return hasPerms(props.value) ? (
|
||||||
|
<Fragment>{slots.default?.()}</Fragment>
|
||||||
|
) : null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
5
src/components/RePureTableBar/index.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import pureTableBar from "./src/bar";
|
||||||
|
import { withInstall } from "@pureadmin/utils";
|
||||||
|
|
||||||
|
/** 配合 `@pureadmin/table` 实现快速便捷的表格操作 https://github.com/pure-admin/pure-admin-table */
|
||||||
|
export const PureTableBar = withInstall(pureTableBar);
|
||||||
398
src/components/RePureTableBar/src/bar.tsx
Normal file
@@ -0,0 +1,398 @@
|
|||||||
|
import Sortable from "sortablejs";
|
||||||
|
import { transformI18n } from "@/plugins/i18n";
|
||||||
|
import { useEpThemeStoreHook } from "@/store/modules/epTheme";
|
||||||
|
import {
|
||||||
|
type PropType,
|
||||||
|
ref,
|
||||||
|
unref,
|
||||||
|
computed,
|
||||||
|
nextTick,
|
||||||
|
defineComponent,
|
||||||
|
getCurrentInstance
|
||||||
|
} from "vue";
|
||||||
|
import {
|
||||||
|
delay,
|
||||||
|
cloneDeep,
|
||||||
|
isBoolean,
|
||||||
|
isFunction,
|
||||||
|
getKeyList
|
||||||
|
} from "@pureadmin/utils";
|
||||||
|
|
||||||
|
import Fullscreen from "@iconify-icons/ri/fullscreen-fill";
|
||||||
|
import ExitFullscreen from "@iconify-icons/ri/fullscreen-exit-fill";
|
||||||
|
import DragIcon from "@/assets/table-bar/drag.svg?component";
|
||||||
|
import ExpandIcon from "@/assets/table-bar/expand.svg?component";
|
||||||
|
import RefreshIcon from "@/assets/table-bar/refresh.svg?component";
|
||||||
|
import SettingIcon from "@/assets/table-bar/settings.svg?component";
|
||||||
|
import CollapseIcon from "@/assets/table-bar/collapse.svg?component";
|
||||||
|
|
||||||
|
const props = {
|
||||||
|
/** 头部最左边的标题 */
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: "列表"
|
||||||
|
},
|
||||||
|
/** 对于树形表格,如果想启用展开和折叠功能,传入当前表格的ref即可 */
|
||||||
|
tableRef: {
|
||||||
|
type: Object as PropType<any>
|
||||||
|
},
|
||||||
|
/** 需要展示的列 */
|
||||||
|
columns: {
|
||||||
|
type: Array as PropType<TableColumnList>,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
isExpandAll: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
tableKey: {
|
||||||
|
type: [String, Number] as PropType<string | number>,
|
||||||
|
default: "0"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: "PureTableBar",
|
||||||
|
props,
|
||||||
|
emits: ["refresh", "fullscreen"],
|
||||||
|
setup(props, { emit, slots, attrs }) {
|
||||||
|
const size = ref("default");
|
||||||
|
const loading = ref(false);
|
||||||
|
const checkAll = ref(true);
|
||||||
|
const isFullscreen = ref(false);
|
||||||
|
const isIndeterminate = ref(false);
|
||||||
|
const instance = getCurrentInstance()!;
|
||||||
|
const isExpandAll = ref(props.isExpandAll);
|
||||||
|
const filterColumns = cloneDeep(props?.columns).filter(column =>
|
||||||
|
isBoolean(column?.hide)
|
||||||
|
? !column.hide
|
||||||
|
: !(isFunction(column?.hide) && column?.hide())
|
||||||
|
);
|
||||||
|
let checkColumnList = getKeyList(cloneDeep(props?.columns), "label");
|
||||||
|
const checkedColumns = ref(getKeyList(cloneDeep(filterColumns), "label"));
|
||||||
|
const dynamicColumns = ref(cloneDeep(props?.columns));
|
||||||
|
|
||||||
|
const getDropdownItemStyle = computed(() => {
|
||||||
|
return s => {
|
||||||
|
return {
|
||||||
|
background:
|
||||||
|
s === size.value ? useEpThemeStoreHook().epThemeColor : "",
|
||||||
|
color: s === size.value ? "#fff" : "var(--el-text-color-primary)"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const iconClass = computed(() => {
|
||||||
|
return [
|
||||||
|
"text-black",
|
||||||
|
"dark:text-white",
|
||||||
|
"duration-100",
|
||||||
|
"hover:!text-primary",
|
||||||
|
"cursor-pointer",
|
||||||
|
"outline-none"
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
const topClass = computed(() => {
|
||||||
|
return [
|
||||||
|
"flex",
|
||||||
|
"justify-between",
|
||||||
|
"pt-[3px]",
|
||||||
|
"px-[11px]",
|
||||||
|
"border-b-[1px]",
|
||||||
|
"border-solid",
|
||||||
|
"border-[#dcdfe6]",
|
||||||
|
"dark:border-[#303030]"
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
function onReFresh() {
|
||||||
|
loading.value = true;
|
||||||
|
emit("refresh");
|
||||||
|
delay(500).then(() => (loading.value = false));
|
||||||
|
}
|
||||||
|
|
||||||
|
function onExpand() {
|
||||||
|
isExpandAll.value = !isExpandAll.value;
|
||||||
|
toggleRowExpansionAll(props.tableRef.data, isExpandAll.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFullscreen() {
|
||||||
|
isFullscreen.value = !isFullscreen.value;
|
||||||
|
emit("fullscreen", isFullscreen.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleRowExpansionAll(data, isExpansion) {
|
||||||
|
data.forEach(item => {
|
||||||
|
props.tableRef.toggleRowExpansion(item, isExpansion);
|
||||||
|
if (item.children !== undefined && item.children !== null) {
|
||||||
|
toggleRowExpansionAll(item.children, isExpansion);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCheckAllChange(val: boolean) {
|
||||||
|
checkedColumns.value = val ? checkColumnList : [];
|
||||||
|
isIndeterminate.value = false;
|
||||||
|
dynamicColumns.value.map(column =>
|
||||||
|
val ? (column.hide = false) : (column.hide = true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCheckedColumnsChange(value: string[]) {
|
||||||
|
checkedColumns.value = value;
|
||||||
|
const checkedCount = value.length;
|
||||||
|
checkAll.value = checkedCount === checkColumnList.length;
|
||||||
|
isIndeterminate.value =
|
||||||
|
checkedCount > 0 && checkedCount < checkColumnList.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCheckColumnListChange(val: boolean, label: string) {
|
||||||
|
dynamicColumns.value.filter(
|
||||||
|
item => transformI18n(item.label) === transformI18n(label)
|
||||||
|
)[0].hide = !val;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onReset() {
|
||||||
|
checkAll.value = true;
|
||||||
|
isIndeterminate.value = false;
|
||||||
|
dynamicColumns.value = cloneDeep(props?.columns);
|
||||||
|
checkColumnList = [];
|
||||||
|
checkColumnList = await getKeyList(cloneDeep(props?.columns), "label");
|
||||||
|
checkedColumns.value = getKeyList(cloneDeep(filterColumns), "label");
|
||||||
|
}
|
||||||
|
|
||||||
|
const dropdown = {
|
||||||
|
dropdown: () => (
|
||||||
|
<el-dropdown-menu class="translation">
|
||||||
|
<el-dropdown-item
|
||||||
|
style={getDropdownItemStyle.value("large")}
|
||||||
|
onClick={() => (size.value = "large")}
|
||||||
|
>
|
||||||
|
宽松
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item
|
||||||
|
style={getDropdownItemStyle.value("default")}
|
||||||
|
onClick={() => (size.value = "default")}
|
||||||
|
>
|
||||||
|
默认
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item
|
||||||
|
style={getDropdownItemStyle.value("small")}
|
||||||
|
onClick={() => (size.value = "small")}
|
||||||
|
>
|
||||||
|
紧凑
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 列展示拖拽排序 */
|
||||||
|
const rowDrop = (event: { preventDefault: () => void }) => {
|
||||||
|
event.preventDefault();
|
||||||
|
nextTick(() => {
|
||||||
|
const wrapper: HTMLElement = (
|
||||||
|
instance?.proxy?.$refs[`GroupRef${unref(props.tableKey)}`] as any
|
||||||
|
).$el.firstElementChild;
|
||||||
|
Sortable.create(wrapper, {
|
||||||
|
animation: 300,
|
||||||
|
handle: ".drag-btn",
|
||||||
|
onEnd: ({ newIndex, oldIndex, item }) => {
|
||||||
|
const targetThElem = item;
|
||||||
|
const wrapperElem = targetThElem.parentNode as HTMLElement;
|
||||||
|
const oldColumn = dynamicColumns.value[oldIndex];
|
||||||
|
const newColumn = dynamicColumns.value[newIndex];
|
||||||
|
if (oldColumn?.fixed || newColumn?.fixed) {
|
||||||
|
// 当前列存在fixed属性 则不可拖拽
|
||||||
|
const oldThElem = wrapperElem.children[oldIndex] as HTMLElement;
|
||||||
|
if (newIndex > oldIndex) {
|
||||||
|
wrapperElem.insertBefore(targetThElem, oldThElem);
|
||||||
|
} else {
|
||||||
|
wrapperElem.insertBefore(
|
||||||
|
targetThElem,
|
||||||
|
oldThElem ? oldThElem.nextElementSibling : oldThElem
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const currentRow = dynamicColumns.value.splice(oldIndex, 1)[0];
|
||||||
|
dynamicColumns.value.splice(newIndex, 0, currentRow);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const isFixedColumn = (label: string) => {
|
||||||
|
return dynamicColumns.value.filter(
|
||||||
|
item => transformI18n(item.label) === transformI18n(label)
|
||||||
|
)[0].fixed
|
||||||
|
? true
|
||||||
|
: 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 = {
|
||||||
|
reference: () => (
|
||||||
|
<SettingIcon
|
||||||
|
class={["w-[16px]", iconClass.value]}
|
||||||
|
v-tippy={rendTippyProps("列设置")}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
return () => (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
{...attrs}
|
||||||
|
class={[
|
||||||
|
"w-[99/100]",
|
||||||
|
"px-2",
|
||||||
|
"pb-2",
|
||||||
|
"bg-bg_color",
|
||||||
|
isFullscreen.value
|
||||||
|
? ["!w-full", "!h-full", "z-[2002]", "fixed", "inset-0"]
|
||||||
|
: "mt-2"
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<div class="flex justify-between w-full h-[60px] p-4">
|
||||||
|
{slots?.title ? (
|
||||||
|
slots.title()
|
||||||
|
) : (
|
||||||
|
<p class="font-bold truncate">{props.title}</p>
|
||||||
|
)}
|
||||||
|
<div class="flex items-center justify-around">
|
||||||
|
{slots?.buttons ? (
|
||||||
|
<div class="flex mr-4">{slots.buttons()}</div>
|
||||||
|
) : null}
|
||||||
|
{props.tableRef?.size ? (
|
||||||
|
<>
|
||||||
|
<ExpandIcon
|
||||||
|
class={["w-[16px]", iconClass.value]}
|
||||||
|
style={{
|
||||||
|
transform: isExpandAll.value ? "none" : "rotate(-90deg)"
|
||||||
|
}}
|
||||||
|
v-tippy={rendTippyProps(
|
||||||
|
isExpandAll.value ? "折叠" : "展开"
|
||||||
|
)}
|
||||||
|
onClick={() => onExpand()}
|
||||||
|
/>
|
||||||
|
<el-divider direction="vertical" />
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
<RefreshIcon
|
||||||
|
class={[
|
||||||
|
"w-[16px]",
|
||||||
|
iconClass.value,
|
||||||
|
loading.value ? "animate-spin" : ""
|
||||||
|
]}
|
||||||
|
v-tippy={rendTippyProps("刷新")}
|
||||||
|
onClick={() => onReFresh()}
|
||||||
|
/>
|
||||||
|
<el-divider direction="vertical" />
|
||||||
|
<el-dropdown
|
||||||
|
v-slots={dropdown}
|
||||||
|
trigger="click"
|
||||||
|
v-tippy={rendTippyProps("密度")}
|
||||||
|
>
|
||||||
|
<CollapseIcon class={["w-[16px]", iconClass.value]} />
|
||||||
|
</el-dropdown>
|
||||||
|
<el-divider direction="vertical" />
|
||||||
|
|
||||||
|
<el-popover
|
||||||
|
v-slots={reference}
|
||||||
|
placement="bottom-start"
|
||||||
|
popper-style={{ padding: 0 }}
|
||||||
|
width="200"
|
||||||
|
trigger="click"
|
||||||
|
>
|
||||||
|
<div class={[topClass.value]}>
|
||||||
|
<el-checkbox
|
||||||
|
class="!-mr-1"
|
||||||
|
label="列展示"
|
||||||
|
v-model={checkAll.value}
|
||||||
|
indeterminate={isIndeterminate.value}
|
||||||
|
onChange={value => handleCheckAllChange(value)}
|
||||||
|
/>
|
||||||
|
<el-button type="primary" link onClick={() => onReset()}>
|
||||||
|
重置
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-[6px] pl-[11px]">
|
||||||
|
<el-scrollbar max-height="36vh">
|
||||||
|
<el-checkbox-group
|
||||||
|
ref={`GroupRef${unref(props.tableKey)}`}
|
||||||
|
modelValue={checkedColumns.value}
|
||||||
|
onChange={value => handleCheckedColumnsChange(value)}
|
||||||
|
>
|
||||||
|
<el-space
|
||||||
|
direction="vertical"
|
||||||
|
alignment="flex-start"
|
||||||
|
size={0}
|
||||||
|
>
|
||||||
|
{checkColumnList.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<div class="flex items-center">
|
||||||
|
<DragIcon
|
||||||
|
class={[
|
||||||
|
"drag-btn w-[16px] mr-2",
|
||||||
|
isFixedColumn(item)
|
||||||
|
? "!cursor-no-drop"
|
||||||
|
: "!cursor-grab"
|
||||||
|
]}
|
||||||
|
onMouseenter={(event: {
|
||||||
|
preventDefault: () => void;
|
||||||
|
}) => rowDrop(event)}
|
||||||
|
/>
|
||||||
|
<el-checkbox
|
||||||
|
key={index}
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
onChange={value =>
|
||||||
|
handleCheckColumnListChange(value, item)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
title={transformI18n(item)}
|
||||||
|
class="inline-block w-[120px] truncate hover:text-text_color_primary"
|
||||||
|
>
|
||||||
|
{transformI18n(item)}
|
||||||
|
</span>
|
||||||
|
</el-checkbox>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</el-space>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-scrollbar>
|
||||||
|
</div>
|
||||||
|
</el-popover>
|
||||||
|
<el-divider direction="vertical" />
|
||||||
|
|
||||||
|
<iconifyIconOffline
|
||||||
|
class={["w-[16px]", iconClass.value]}
|
||||||
|
icon={isFullscreen.value ? ExitFullscreen : Fullscreen}
|
||||||
|
v-tippy={isFullscreen.value ? "退出全屏" : "全屏"}
|
||||||
|
onClick={() => onFullscreen()}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{slots.default({
|
||||||
|
size: size.value,
|
||||||
|
dynamicColumns: dynamicColumns.value
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
7
src/components/ReQrcode/index.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import reQrcode from "./src/index";
|
||||||
|
import { withInstall } from "@pureadmin/utils";
|
||||||
|
|
||||||
|
/** 二维码组件 */
|
||||||
|
export const ReQrcode = withInstall(reQrcode);
|
||||||
|
|
||||||
|
export default ReQrcode;
|
||||||
9
src/components/ReQrcode/src/index.scss
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
.qrcode {
|
||||||
|
&--disabled {
|
||||||
|
background: rgb(255 255 255 / 95%);
|
||||||
|
|
||||||
|
& > div {
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
261
src/components/ReQrcode/src/index.tsx
Normal file
@@ -0,0 +1,261 @@
|
|||||||
|
import {
|
||||||
|
type PropType,
|
||||||
|
ref,
|
||||||
|
unref,
|
||||||
|
watch,
|
||||||
|
nextTick,
|
||||||
|
computed,
|
||||||
|
defineComponent
|
||||||
|
} from "vue";
|
||||||
|
import "./index.scss";
|
||||||
|
import propTypes from "@/utils/propTypes";
|
||||||
|
import { isString, cloneDeep } from "@pureadmin/utils";
|
||||||
|
import QRCode, { type QRCodeRenderersOptions } from "qrcode";
|
||||||
|
import RefreshRight from "@iconify-icons/ep/refresh-right";
|
||||||
|
|
||||||
|
interface QrcodeLogo {
|
||||||
|
src?: string;
|
||||||
|
logoSize?: number;
|
||||||
|
bgColor?: string;
|
||||||
|
borderSize?: number;
|
||||||
|
crossOrigin?: string;
|
||||||
|
borderRadius?: number;
|
||||||
|
logoRadius?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = {
|
||||||
|
// img 或者 canvas,img不支持logo嵌套
|
||||||
|
tag: propTypes.string
|
||||||
|
.validate((v: string) => ["canvas", "img"].includes(v))
|
||||||
|
.def("canvas"),
|
||||||
|
// 二维码内容
|
||||||
|
text: {
|
||||||
|
type: [String, Array] as PropType<string | Recordable[]>,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
// qrcode.js配置项
|
||||||
|
options: {
|
||||||
|
type: Object as PropType<QRCodeRenderersOptions>,
|
||||||
|
default: (): QRCodeRenderersOptions => ({})
|
||||||
|
},
|
||||||
|
// 宽度
|
||||||
|
width: propTypes.number.def(200),
|
||||||
|
// logo
|
||||||
|
logo: {
|
||||||
|
type: [String, Object] as PropType<Partial<QrcodeLogo> | string>,
|
||||||
|
default: (): QrcodeLogo | string => ""
|
||||||
|
},
|
||||||
|
// 是否过期
|
||||||
|
disabled: propTypes.bool.def(false),
|
||||||
|
// 过期提示内容
|
||||||
|
disabledText: propTypes.string.def("")
|
||||||
|
};
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: "ReQrcode",
|
||||||
|
props,
|
||||||
|
emits: ["done", "click", "disabled-click"],
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const { toCanvas, toDataURL } = QRCode;
|
||||||
|
const loading = ref(true);
|
||||||
|
const wrapRef = ref<Nullable<HTMLCanvasElement | HTMLImageElement>>(null);
|
||||||
|
const renderText = computed(() => String(props.text));
|
||||||
|
const wrapStyle = computed(() => {
|
||||||
|
return {
|
||||||
|
width: props.width + "px",
|
||||||
|
height: props.width + "px"
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const initQrcode = async () => {
|
||||||
|
await nextTick();
|
||||||
|
const options = cloneDeep(props.options || {});
|
||||||
|
if (props.tag === "canvas") {
|
||||||
|
// 容错率,默认对内容少的二维码采用高容错率,内容多的二维码采用低容错率
|
||||||
|
options.errorCorrectionLevel =
|
||||||
|
options.errorCorrectionLevel ||
|
||||||
|
getErrorCorrectionLevel(unref(renderText));
|
||||||
|
const _width: number = await getOriginWidth(unref(renderText), options);
|
||||||
|
options.scale =
|
||||||
|
props.width === 0 ? undefined : (props.width / _width) * 4;
|
||||||
|
const canvasRef: any = await toCanvas(
|
||||||
|
unref(wrapRef) as HTMLCanvasElement,
|
||||||
|
unref(renderText),
|
||||||
|
options
|
||||||
|
);
|
||||||
|
if (props.logo) {
|
||||||
|
const url = await createLogoCode(canvasRef);
|
||||||
|
emit("done", url);
|
||||||
|
loading.value = false;
|
||||||
|
} else {
|
||||||
|
emit("done", canvasRef.toDataURL());
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const url = await toDataURL(renderText.value, {
|
||||||
|
errorCorrectionLevel: "H",
|
||||||
|
width: props.width,
|
||||||
|
...options
|
||||||
|
});
|
||||||
|
(unref(wrapRef) as any).src = url;
|
||||||
|
emit("done", url);
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
watch(
|
||||||
|
() => renderText.value,
|
||||||
|
val => {
|
||||||
|
if (!val) return;
|
||||||
|
initQrcode();
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deep: true,
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const createLogoCode = (canvasRef: HTMLCanvasElement) => {
|
||||||
|
const canvasWidth = canvasRef.width;
|
||||||
|
const logoOptions: QrcodeLogo = Object.assign(
|
||||||
|
{
|
||||||
|
logoSize: 0.15,
|
||||||
|
bgColor: "#ffffff",
|
||||||
|
borderSize: 0.05,
|
||||||
|
crossOrigin: "anonymous",
|
||||||
|
borderRadius: 8,
|
||||||
|
logoRadius: 0
|
||||||
|
},
|
||||||
|
isString(props.logo) ? {} : props.logo
|
||||||
|
);
|
||||||
|
const {
|
||||||
|
logoSize = 0.15,
|
||||||
|
bgColor = "#ffffff",
|
||||||
|
borderSize = 0.05,
|
||||||
|
crossOrigin = "anonymous",
|
||||||
|
borderRadius = 8,
|
||||||
|
logoRadius = 0
|
||||||
|
} = logoOptions;
|
||||||
|
const logoSrc = isString(props.logo) ? props.logo : props.logo.src;
|
||||||
|
const logoWidth = canvasWidth * logoSize;
|
||||||
|
const logoXY = (canvasWidth * (1 - logoSize)) / 2;
|
||||||
|
const logoBgWidth = canvasWidth * (logoSize + borderSize);
|
||||||
|
const logoBgXY = (canvasWidth * (1 - logoSize - borderSize)) / 2;
|
||||||
|
const ctx = canvasRef.getContext("2d");
|
||||||
|
if (!ctx) return;
|
||||||
|
// logo 底色
|
||||||
|
canvasRoundRect(ctx)(
|
||||||
|
logoBgXY,
|
||||||
|
logoBgXY,
|
||||||
|
logoBgWidth,
|
||||||
|
logoBgWidth,
|
||||||
|
borderRadius
|
||||||
|
);
|
||||||
|
ctx.fillStyle = bgColor;
|
||||||
|
ctx.fill();
|
||||||
|
// logo
|
||||||
|
const image = new Image();
|
||||||
|
if (crossOrigin || logoRadius) {
|
||||||
|
image.setAttribute("crossOrigin", crossOrigin);
|
||||||
|
}
|
||||||
|
(image as any).src = logoSrc;
|
||||||
|
// 使用image绘制可以避免某些跨域情况
|
||||||
|
const drawLogoWithImage = (image: HTMLImageElement) => {
|
||||||
|
ctx.drawImage(image, logoXY, logoXY, logoWidth, logoWidth);
|
||||||
|
};
|
||||||
|
// 使用canvas绘制以获得更多的功能
|
||||||
|
const drawLogoWithCanvas = (image: HTMLImageElement) => {
|
||||||
|
const canvasImage = document.createElement("canvas");
|
||||||
|
canvasImage.width = logoXY + logoWidth;
|
||||||
|
canvasImage.height = logoXY + logoWidth;
|
||||||
|
const imageCanvas = canvasImage.getContext("2d");
|
||||||
|
if (!imageCanvas || !ctx) return;
|
||||||
|
imageCanvas.drawImage(image, logoXY, logoXY, logoWidth, logoWidth);
|
||||||
|
canvasRoundRect(ctx)(logoXY, logoXY, logoWidth, logoWidth, logoRadius);
|
||||||
|
if (!ctx) return;
|
||||||
|
const fillStyle = ctx.createPattern(canvasImage, "no-repeat");
|
||||||
|
if (fillStyle) {
|
||||||
|
ctx.fillStyle = fillStyle;
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// 将 logo绘制到 canvas上
|
||||||
|
return new Promise((resolve: any) => {
|
||||||
|
image.onload = () => {
|
||||||
|
logoRadius ? drawLogoWithCanvas(image) : drawLogoWithImage(image);
|
||||||
|
resolve(canvasRef.toDataURL());
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
// 得到原QrCode的大小,以便缩放得到正确的QrCode大小
|
||||||
|
const getOriginWidth = async (
|
||||||
|
content: string,
|
||||||
|
options: QRCodeRenderersOptions
|
||||||
|
) => {
|
||||||
|
const _canvas = document.createElement("canvas");
|
||||||
|
await toCanvas(_canvas, content, options);
|
||||||
|
return _canvas.width;
|
||||||
|
};
|
||||||
|
// 对于内容少的QrCode,增大容错率
|
||||||
|
const getErrorCorrectionLevel = (content: string) => {
|
||||||
|
if (content.length > 36) {
|
||||||
|
return "M";
|
||||||
|
} else if (content.length > 16) {
|
||||||
|
return "Q";
|
||||||
|
} else {
|
||||||
|
return "H";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// 用于绘制圆角
|
||||||
|
const canvasRoundRect = (ctx: CanvasRenderingContext2D) => {
|
||||||
|
return (x: number, y: number, w: number, h: number, r: number) => {
|
||||||
|
const minSize = Math.min(w, h);
|
||||||
|
if (r > minSize / 2) {
|
||||||
|
r = minSize / 2;
|
||||||
|
}
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x + r, y);
|
||||||
|
ctx.arcTo(x + w, y, x + w, y + h, r);
|
||||||
|
ctx.arcTo(x + w, y + h, x, y + h, r);
|
||||||
|
ctx.arcTo(x, y + h, x, y, r);
|
||||||
|
ctx.arcTo(x, y, x + w, y, r);
|
||||||
|
ctx.closePath();
|
||||||
|
return ctx;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const clickCode = () => {
|
||||||
|
emit("click");
|
||||||
|
};
|
||||||
|
const disabledClick = () => {
|
||||||
|
emit("disabled-click");
|
||||||
|
};
|
||||||
|
return () => (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
v-loading={unref(loading)}
|
||||||
|
class="qrcode relative inline-block"
|
||||||
|
style={unref(wrapStyle)}
|
||||||
|
>
|
||||||
|
{props.tag === "canvas" ? (
|
||||||
|
<canvas ref={wrapRef} onClick={clickCode}></canvas>
|
||||||
|
) : (
|
||||||
|
<img ref={wrapRef} onClick={clickCode}></img>
|
||||||
|
)}
|
||||||
|
{props.disabled && (
|
||||||
|
<div
|
||||||
|
class="qrcode--disabled absolute top-0 left-0 flex w-full h-full items-center justify-center"
|
||||||
|
onClick={disabledClick}
|
||||||
|
>
|
||||||
|
<div class="absolute top-[50%] left-[50%] font-bold">
|
||||||
|
<iconify-icon-offline
|
||||||
|
class="cursor-pointer"
|
||||||
|
icon={RefreshRight}
|
||||||
|
width="30"
|
||||||
|
color="var(--el-color-primary)"
|
||||||
|
/>
|
||||||
|
<div>{props.disabledText}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
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";
|
||||||
157
src/components/ReSegmented/src/index.css
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
.pure-segmented {
|
||||||
|
--pure-control-padding-horizontal: 12px;
|
||||||
|
--pure-control-padding-horizontal-sm: 8px;
|
||||||
|
--pure-segmented-track-padding: 2px;
|
||||||
|
--pure-segmented-line-width: 1px;
|
||||||
|
|
||||||
|
--pure-segmented-border-radius-small: 4px;
|
||||||
|
--pure-segmented-border-radius-base: 6px;
|
||||||
|
--pure-segmented-border-radius-large: 8px;
|
||||||
|
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: inline-block;
|
||||||
|
padding: var(--pure-segmented-track-padding);
|
||||||
|
font-size: var(--el-font-size-base);
|
||||||
|
color: rgba(0, 0, 0, 0.65);
|
||||||
|
background-color: rgb(0 0 0 / 4%);
|
||||||
|
border-radius: var(--pure-segmented-border-radius-base);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-block {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-block .pure-segmented-item {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-block .pure-segmented-item > .pure-segmented-item-label > span {
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* small */
|
||||||
|
.pure-segmented.pure-segmented--small {
|
||||||
|
border-radius: var(--pure-segmented-border-radius-small);
|
||||||
|
}
|
||||||
|
.pure-segmented.pure-segmented--small .pure-segmented-item {
|
||||||
|
border-radius: var(--el-border-radius-small);
|
||||||
|
}
|
||||||
|
.pure-segmented.pure-segmented--small .pure-segmented-item > div {
|
||||||
|
min-height: calc(
|
||||||
|
var(--el-component-size-small) - var(--pure-segmented-track-padding) * 2
|
||||||
|
);
|
||||||
|
line-height: calc(
|
||||||
|
var(--el-component-size-small) - var(--pure-segmented-track-padding) * 2
|
||||||
|
);
|
||||||
|
padding: 0
|
||||||
|
calc(
|
||||||
|
var(--pure-control-padding-horizontal-sm) -
|
||||||
|
var(--pure-segmented-line-width)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* large */
|
||||||
|
.pure-segmented.pure-segmented--large {
|
||||||
|
border-radius: var(--pure-segmented-border-radius-large);
|
||||||
|
}
|
||||||
|
.pure-segmented.pure-segmented--large .pure-segmented-item {
|
||||||
|
border-radius: calc(
|
||||||
|
var(--el-border-radius-base) + var(--el-border-radius-small)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
.pure-segmented.pure-segmented--large .pure-segmented-item > div {
|
||||||
|
min-height: calc(
|
||||||
|
var(--el-component-size-large) - var(--pure-segmented-track-padding) * 2
|
||||||
|
);
|
||||||
|
line-height: calc(
|
||||||
|
var(--el-component-size-large) - var(--pure-segmented-track-padding) * 2
|
||||||
|
);
|
||||||
|
padding: 0
|
||||||
|
calc(
|
||||||
|
var(--pure-control-padding-horizontal) - var(--pure-segmented-line-width)
|
||||||
|
);
|
||||||
|
font-size: var(--el-font-size-medium);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* default */
|
||||||
|
.pure-segmented-item {
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: var(--el-border-radius-base);
|
||||||
|
transition: all 0.1s cubic-bezier(0.645, 0.045, 0.355, 1);
|
||||||
|
}
|
||||||
|
.pure-segmented .pure-segmented-item > div {
|
||||||
|
min-height: calc(
|
||||||
|
var(--el-component-size) - var(--pure-segmented-track-padding) * 2
|
||||||
|
);
|
||||||
|
line-height: calc(
|
||||||
|
var(--el-component-size) - var(--pure-segmented-track-padding) * 2
|
||||||
|
);
|
||||||
|
padding: 0
|
||||||
|
calc(
|
||||||
|
var(--pure-control-padding-horizontal) - var(--pure-segmented-line-width)
|
||||||
|
);
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
transition: 0.1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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 > 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;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-item-icon svg {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-segmented-item-disabled {
|
||||||
|
color: rgba(0, 0, 0, 0.25);
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
216
src/components/ReSegmented/src/index.tsx
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
import "./index.css";
|
||||||
|
import type { OptionsType } from "./type";
|
||||||
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
|
import {
|
||||||
|
useDark,
|
||||||
|
isNumber,
|
||||||
|
isFunction,
|
||||||
|
useResizeObserver
|
||||||
|
} from "@pureadmin/utils";
|
||||||
|
import {
|
||||||
|
type PropType,
|
||||||
|
h,
|
||||||
|
ref,
|
||||||
|
toRef,
|
||||||
|
watch,
|
||||||
|
nextTick,
|
||||||
|
defineComponent,
|
||||||
|
getCurrentInstance
|
||||||
|
} from "vue";
|
||||||
|
|
||||||
|
const props = {
|
||||||
|
options: {
|
||||||
|
type: Array<OptionsType>,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
/** 默认选中,按照第一个索引为 `0` 的模式,可选(`modelValue`只有传`number`类型时才为响应式) */
|
||||||
|
modelValue: {
|
||||||
|
type: undefined,
|
||||||
|
require: false,
|
||||||
|
default: "0"
|
||||||
|
},
|
||||||
|
/** 将宽度调整为父元素宽度 */
|
||||||
|
block: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
/** 控件尺寸 */
|
||||||
|
size: {
|
||||||
|
type: String as PropType<"small" | "default" | "large">
|
||||||
|
},
|
||||||
|
/** 是否全局禁用,默认 `false` */
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
/** 当内容发生变化时,设置 `resize` 可使其自适应容器位置 */
|
||||||
|
resize: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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 (props.disabled || 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) {
|
||||||
|
if (props.disabled) return;
|
||||||
|
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) {
|
||||||
|
if (props.disabled) return;
|
||||||
|
event.preventDefault();
|
||||||
|
curMouseActive.value = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleInit(index = curIndex.value) {
|
||||||
|
nextTick(() => {
|
||||||
|
const curLabelRef = instance?.proxy?.$refs[`labelRef${index}`] as ElRef;
|
||||||
|
if (!curLabelRef) return;
|
||||||
|
width.value = curLabelRef.clientWidth;
|
||||||
|
translateX.value = curLabelRef.offsetLeft;
|
||||||
|
initStatus.value = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleResizeInit() {
|
||||||
|
useResizeObserver(".pure-segmented", () => {
|
||||||
|
nextTick(() => {
|
||||||
|
handleInit(curIndex.value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
(props.block || props.resize) && handleResizeInit();
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => curIndex.value,
|
||||||
|
index => {
|
||||||
|
nextTick(() => {
|
||||||
|
handleInit(index);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(() => props.size, handleResizeInit, {
|
||||||
|
immediate: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const rendLabel = () => {
|
||||||
|
return props.options.map((option, index) => {
|
||||||
|
return (
|
||||||
|
<label
|
||||||
|
ref={`labelRef${index}`}
|
||||||
|
class={[
|
||||||
|
"pure-segmented-item",
|
||||||
|
(props.disabled || option?.disabled) &&
|
||||||
|
"pure-segmented-item-disabled"
|
||||||
|
]}
|
||||||
|
style={{
|
||||||
|
background:
|
||||||
|
curMouseActive.value === index ? segmentedItembg.value : "",
|
||||||
|
color: props.disabled
|
||||||
|
? null
|
||||||
|
: !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": true,
|
||||||
|
"pure-segmented-block": props.block,
|
||||||
|
"pure-segmented--large": props.size === "large",
|
||||||
|
"pure-segmented--small": props.size === "small"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<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://pure-admin.cn/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;
|
||||||
|
}
|
||||||