From c88c57365caa72698570f860ba3a0791fd5c3df7 Mon Sep 17 00:00:00 2001 From: Simon Ding Date: Mon, 1 Jul 2024 18:17:37 +0800 Subject: [PATCH] update ui --- ui/.browserslistrc | 4 ++++ ui/.dockerignore | 21 ++++++++++++++++++ ui/.editorconfig | 14 ++++++++++++ ui/.env | 5 +++++ ui/.env.development | 8 +++++++ ui/.env.production | 13 +++++++++++ ui/.env.staging | 16 ++++++++++++++ ui/.gitignore | 22 +++++++++++++++++++ ui/.husky/commit-msg | 8 +++++++ ui/.husky/common.sh | 9 ++++++++ ui/.husky/pre-commit | 10 +++++++++ ui/.lintstagedrc | 20 +++++++++++++++++ ui/.markdownlint.json | 11 ++++++++++ ui/.npmrc | 4 ++++ ui/.nvmrc | 1 + ui/.prettierrc.js | 9 ++++++++ ui/.stylelintignore | 4 ++++ .../components/lay-sidebar/NavHorizontal.vue | 4 ++-- .../layout/components/lay-sidebar/NavMix.vue | 4 ++-- .../components/lay-sidebar/NavVertical.vue | 8 +++---- ui/src/utils/http/index.ts | 2 +- ui/src/utils/localforage/index.ts | 2 +- 22 files changed, 189 insertions(+), 10 deletions(-) create mode 100644 ui/.browserslistrc create mode 100644 ui/.dockerignore create mode 100644 ui/.editorconfig create mode 100644 ui/.env create mode 100644 ui/.env.development create mode 100644 ui/.env.production create mode 100644 ui/.env.staging create mode 100644 ui/.gitignore create mode 100755 ui/.husky/commit-msg create mode 100644 ui/.husky/common.sh create mode 100755 ui/.husky/pre-commit create mode 100644 ui/.lintstagedrc create mode 100644 ui/.markdownlint.json create mode 100644 ui/.npmrc create mode 100644 ui/.nvmrc create mode 100644 ui/.prettierrc.js create mode 100644 ui/.stylelintignore diff --git a/ui/.browserslistrc b/ui/.browserslistrc new file mode 100644 index 0000000..40bd99c --- /dev/null +++ b/ui/.browserslistrc @@ -0,0 +1,4 @@ +> 1% +last 2 versions +not dead +not ie 11 \ No newline at end of file diff --git a/ui/.dockerignore b/ui/.dockerignore new file mode 100644 index 0000000..0376edd --- /dev/null +++ b/ui/.dockerignore @@ -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 diff --git a/ui/.editorconfig b/ui/.editorconfig new file mode 100644 index 0000000..ea6e20f --- /dev/null +++ b/ui/.editorconfig @@ -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 diff --git a/ui/.env b/ui/.env new file mode 100644 index 0000000..09344c1 --- /dev/null +++ b/ui/.env @@ -0,0 +1,5 @@ +# 平台本地运行端口号 +VITE_PORT = 8848 + +# 是否隐藏首页 隐藏 true 不隐藏 false (勿删除,VITE_HIDE_HOME只需在.env文件配置) +VITE_HIDE_HOME = false diff --git a/ui/.env.development b/ui/.env.development new file mode 100644 index 0000000..90d1146 --- /dev/null +++ b/ui/.env.development @@ -0,0 +1,8 @@ +# 平台本地运行端口号 +VITE_PORT = 8848 + +# 开发环境读取配置文件路径 +VITE_PUBLIC_PATH = / + +# 开发环境路由历史模式(Hash模式传"hash"、HTML5模式传"h5"、Hash模式带base参数传"hash,base参数"、HTML5模式带base参数传"h5,base参数") +VITE_ROUTER_HISTORY = "hash" diff --git a/ui/.env.production b/ui/.env.production new file mode 100644 index 0000000..84e6086 --- /dev/null +++ b/ui/.env.production @@ -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" \ No newline at end of file diff --git a/ui/.env.staging b/ui/.env.staging new file mode 100644 index 0000000..65b57e3 --- /dev/null +++ b/ui/.env.staging @@ -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" diff --git a/ui/.gitignore b/ui/.gitignore new file mode 100644 index 0000000..423ed2b --- /dev/null +++ b/ui/.gitignore @@ -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 \ No newline at end of file diff --git a/ui/.husky/commit-msg b/ui/.husky/commit-msg new file mode 100755 index 0000000..5ee2d16 --- /dev/null +++ b/ui/.husky/commit-msg @@ -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" \ No newline at end of file diff --git a/ui/.husky/common.sh b/ui/.husky/common.sh new file mode 100644 index 0000000..5f0540b --- /dev/null +++ b/ui/.husky/common.sh @@ -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 diff --git a/ui/.husky/pre-commit b/ui/.husky/pre-commit new file mode 100755 index 0000000..6e229ea --- /dev/null +++ b/ui/.husky/pre-commit @@ -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 \ No newline at end of file diff --git a/ui/.lintstagedrc b/ui/.lintstagedrc new file mode 100644 index 0000000..ebf359a --- /dev/null +++ b/ui/.lintstagedrc @@ -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"] +} diff --git a/ui/.markdownlint.json b/ui/.markdownlint.json new file mode 100644 index 0000000..d628d44 --- /dev/null +++ b/ui/.markdownlint.json @@ -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 +} diff --git a/ui/.npmrc b/ui/.npmrc new file mode 100644 index 0000000..dddf8bc --- /dev/null +++ b/ui/.npmrc @@ -0,0 +1,4 @@ +shell-emulator=true +shamefully-hoist=true +enable-pre-post-scripts=false +strict-peer-dependencies=false \ No newline at end of file diff --git a/ui/.nvmrc b/ui/.nvmrc new file mode 100644 index 0000000..67d2ffe --- /dev/null +++ b/ui/.nvmrc @@ -0,0 +1 @@ +v20.13.1 \ No newline at end of file diff --git a/ui/.prettierrc.js b/ui/.prettierrc.js new file mode 100644 index 0000000..775d970 --- /dev/null +++ b/ui/.prettierrc.js @@ -0,0 +1,9 @@ +// @ts-check + +/** @type {import("prettier").Config} */ +export default { + bracketSpacing: true, + singleQuote: false, + arrowParens: "avoid", + trailingComma: "none" +}; diff --git a/ui/.stylelintignore b/ui/.stylelintignore new file mode 100644 index 0000000..0c34e61 --- /dev/null +++ b/ui/.stylelintignore @@ -0,0 +1,4 @@ +/dist/* +/public/* +public/* +src/style/reset.scss \ No newline at end of file diff --git a/ui/src/layout/components/lay-sidebar/NavHorizontal.vue b/ui/src/layout/components/lay-sidebar/NavHorizontal.vue index eec5f65..f6cc55b 100644 --- a/ui/src/layout/components/lay-sidebar/NavHorizontal.vue +++ b/ui/src/layout/components/lay-sidebar/NavHorizontal.vue @@ -6,8 +6,8 @@ import LaySearch from "../lay-search/index.vue"; import LayNotice from "../lay-notice/index.vue"; import { useTranslationLang } from "../../hooks/useTranslationLang"; import { usePermissionStoreHook } from "@/store/modules/permission"; -import LaySidebarItem from "../lay-sidebar/components/SidebarItem.vue"; -import LaySidebarFullScreen from "../lay-sidebar/components/SidebarFullScreen.vue"; +import LaySidebarItem from "./components/SidebarItem.vue"; +import LaySidebarFullScreen from "./components/SidebarFullScreen.vue"; import GlobalizationIcon from "@/assets/svg/globalization.svg?component"; import AccountSettingsIcon from "@iconify-icons/ri/user-settings-line"; diff --git a/ui/src/layout/components/lay-sidebar/NavMix.vue b/ui/src/layout/components/lay-sidebar/NavMix.vue index fc50ede..bb57884 100644 --- a/ui/src/layout/components/lay-sidebar/NavMix.vue +++ b/ui/src/layout/components/lay-sidebar/NavMix.vue @@ -9,8 +9,8 @@ import { useRenderIcon } from "@/components/ReIcon/src/hooks"; import { getParentPaths, findRouteByPath } from "@/router/utils"; import { useTranslationLang } from "../../hooks/useTranslationLang"; import { usePermissionStoreHook } from "@/store/modules/permission"; -import LaySidebarExtraIcon from "../lay-sidebar/components/SidebarExtraIcon.vue"; -import LaySidebarFullScreen from "../lay-sidebar/components/SidebarFullScreen.vue"; +import LaySidebarExtraIcon from "./components/SidebarExtraIcon.vue"; +import LaySidebarFullScreen from "./components/SidebarFullScreen.vue"; import GlobalizationIcon from "@/assets/svg/globalization.svg?component"; import AccountSettingsIcon from "@iconify-icons/ri/user-settings-line"; diff --git a/ui/src/layout/components/lay-sidebar/NavVertical.vue b/ui/src/layout/components/lay-sidebar/NavVertical.vue index 0e9fa12..011cffd 100644 --- a/ui/src/layout/components/lay-sidebar/NavVertical.vue +++ b/ui/src/layout/components/lay-sidebar/NavVertical.vue @@ -7,10 +7,10 @@ import { storageLocal, isAllEmpty } from "@pureadmin/utils"; import { findRouteByPath, getParentPaths } from "@/router/utils"; import { usePermissionStoreHook } from "@/store/modules/permission"; import { ref, computed, watch, onMounted, onBeforeUnmount } from "vue"; -import LaySidebarLogo from "../lay-sidebar/components/SidebarLogo.vue"; -import LaySidebarItem from "../lay-sidebar/components/SidebarItem.vue"; -import LaySidebarLeftCollapse from "../lay-sidebar/components/SidebarLeftCollapse.vue"; -import LaySidebarCenterCollapse from "../lay-sidebar/components/SidebarCenterCollapse.vue"; +import LaySidebarLogo from "./components/SidebarLogo.vue"; +import LaySidebarItem from "./components/SidebarItem.vue"; +import LaySidebarLeftCollapse from "./components/SidebarLeftCollapse.vue"; +import LaySidebarCenterCollapse from "./components/SidebarCenterCollapse.vue"; const route = useRoute(); const isShow = ref(false); diff --git a/ui/src/utils/http/index.ts b/ui/src/utils/http/index.ts index 19b5be2..fe44d97 100644 --- a/ui/src/utils/http/index.ts +++ b/ui/src/utils/http/index.ts @@ -8,7 +8,7 @@ import type { RequestMethods, PureHttpResponse, PureHttpRequestConfig -} from "./types.d"; +} from "./types"; import { stringify } from "qs"; import NProgress from "../progress"; import { getToken, formatToken } from "@/utils/auth"; diff --git a/ui/src/utils/localforage/index.ts b/ui/src/utils/localforage/index.ts index 013545f..4d8137c 100644 --- a/ui/src/utils/localforage/index.ts +++ b/ui/src/utils/localforage/index.ts @@ -1,5 +1,5 @@ import forage from "localforage"; -import type { LocalForage, ProxyStorage, ExpiresData } from "./types.d"; +import type { LocalForage, ProxyStorage, ExpiresData } from "./types"; class StorageProxy implements ProxyStorage { protected storage: LocalForage;