diff --git a/.env b/.env index d9f3a78..da26759 100644 --- a/.env +++ b/.env @@ -1,14 +1,2 @@ -# port +# 项目本地运行端口号 VITE_PORT = 8848 -# title -VITE_TITLE = vue-pure-admin -# version -VITE_VERSION = 2.6.0 -# open -VITE_OPEN = false - -# public path -VITE_PUBLIC_PATH = / - -# Cross-domain proxy, you can configure multiple -VITE_PROXY = [ ["/api", "http://127.0.0.1:3000" ] ] diff --git a/.env.development b/.env.development index d9f3a78..23c4c72 100644 --- a/.env.development +++ b/.env.development @@ -1,14 +1,12 @@ -# port +# 项目本地运行端口号 VITE_PORT = 8848 -# title -VITE_TITLE = vue-pure-admin -# version -VITE_VERSION = 2.6.0 -# open -VITE_OPEN = false - -# public path + +# 开发环境读取配置文件路径 VITE_PUBLIC_PATH = / -# Cross-domain proxy, you can configure multiple -VITE_PROXY = [ ["/api", "http://127.0.0.1:3000" ] ] +# 开发环境代理 +VITE_PROXY_DOMAIN = /api + +# 开发环境后端地址 +VITE_PROXY_DOMAIN_REAL = "http://127.0.0.1:3000" + diff --git a/.env.production b/.env.production index d6e1ff4..eace0a9 100644 --- a/.env.production +++ b/.env.production @@ -1,2 +1,5 @@ -# public path -VITE_PUBLIC_PATH = /manages/ +# 线上环境项目打包路径 +VITE_PUBLIC_PATH = / + +# 线上环境后端地址 +VITE_PROXY_DOMAIN_REAL = "" diff --git a/.eslintrc.js b/.eslintrc.js index f414aa0..ef92312 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -70,6 +70,12 @@ module.exports = { argsIgnorePattern: "^_", varsIgnorePattern: "^_" } + ], + "prettier/prettier": [ + "error", + { + endOfLine: "auto" + } ] } }; diff --git a/README.en-US.md b/README.en-US.md index ad4bac8..94a2518 100644 --- a/README.en-US.md +++ b/README.en-US.md @@ -8,6 +8,10 @@ The lite version is based on the shelf extracted from https://github.com/xiaoxian521/vue-pure-admin, which contains the main functions and is more suitable for actual project development +## Docs + + + ## Usage ### Installation dependencies diff --git a/README.md b/README.md index ebc089d..ab5ea62 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ 精简版是基于 https://github.com/xiaoxian521/vue-pure-admin 提炼出的架子,包含主体功能,更适合实际项目开发 +## 文档 + + + ## 用法 ### 安装依赖 diff --git a/build/utils.ts b/build/index.ts similarity index 61% rename from build/utils.ts rename to build/index.ts index 92f4b8d..c70fb1c 100644 --- a/build/utils.ts +++ b/build/index.ts @@ -1,5 +1,12 @@ +// 处理环境变量 const warpperEnv = (envConf: Recordable): ViteEnv => { - const ret: any = {}; + // 此处为默认值,无需修改 + const ret: ViteEnv = { + VITE_PORT: 8848, + VITE_PUBLIC_PATH: "", + VITE_PROXY_DOMAIN: "", + VITE_PROXY_DOMAIN_REAL: "" + }; for (const envName of Object.keys(envConf)) { let realName = envConf[envName].replace(/\\n/g, "\n"); @@ -9,13 +16,6 @@ const warpperEnv = (envConf: Recordable): ViteEnv => { if (envName === "VITE_PORT") { realName = Number(realName); } - if (envName === "VITE_PROXY" && realName) { - try { - realName = JSON.parse(realName.replace(/'/g, '"')); - } catch (error) { - realName = ""; - } - } ret[envName] = realName; if (typeof realName === "string") { process.env[envName] = realName; @@ -25,8 +25,15 @@ const warpperEnv = (envConf: Recordable): ViteEnv => { } return ret; }; + +// 跨域代理重写 +const regExps = (value: string, reg: string): string => { + return value.replace(new RegExp(reg, "g"), ""); +}; + +// 环境变量 const loadEnv = (): ViteEnv => { return import.meta.env; }; -export { loadEnv, warpperEnv }; +export { warpperEnv, regExps, loadEnv }; diff --git a/build/proxy.ts b/build/proxy.ts deleted file mode 100644 index 7cae8eb..0000000 --- a/build/proxy.ts +++ /dev/null @@ -1,19 +0,0 @@ -type ProxyItem = [string, string]; - -type ProxyList = ProxyItem[]; - -const regExps = (value: string, reg: string): string => { - return value.replace(new RegExp(reg, "g"), ""); -}; - -export function createProxy(list: ProxyList = []) { - const ret: any = {}; - for (const [prefix, target] of list) { - ret[prefix] = { - target: target, - changeOrigin: true, - rewrite: (path: string) => regExps(path, prefix) - }; - } - return ret; -} diff --git a/package.json b/package.json index e09e508..2d30a03 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "element-plus": "1.2.0-beta.3", "element-resize-detector": "^1.2.3", "font-awesome": "^4.7.0", + "js-cookie": "^3.0.1", "lodash-es": "^4.17.21", "lowdb": "^3.0.0", "mitt": "^3.0.0", @@ -49,6 +50,7 @@ "path": "^0.12.7", "path-to-regexp": "^6.2.0", "pinia": "^2.0.0-rc.14", + "qs": "^6.10.2", "remixicon": "^2.5.0", "resize-observer-polyfill": "^1.5.1", "responsive-storage": "^1.0.11", @@ -62,9 +64,11 @@ "@commitlint/cli": "13.1.0", "@commitlint/config-conventional": "13.1.0", "@types/element-resize-detector": "1.1.3", + "@types/js-cookie": "^3.0.1", "@types/mockjs": "1.0.3", "@types/node": "14.14.14", "@types/nprogress": "0.2.0", + "@types/qs": "^6.9.7", "@typescript-eslint/eslint-plugin": "4.31.0", "@typescript-eslint/parser": "4.31.0", "@vitejs/plugin-vue": "^1.9.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b18048d..8a2c85c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,11 @@ specifiers: "@fortawesome/free-solid-svg-icons": ^5.15.4 "@fortawesome/vue-fontawesome": ^3.0.0-5 "@types/element-resize-detector": 1.1.3 + "@types/js-cookie": ^3.0.1 "@types/mockjs": 1.0.3 "@types/node": 14.14.14 "@types/nprogress": 0.2.0 + "@types/qs": ^6.9.7 "@typescript-eslint/eslint-plugin": 4.31.0 "@typescript-eslint/parser": 4.31.0 "@vitejs/plugin-vue": ^1.9.4 @@ -36,6 +38,7 @@ specifiers: eslint-plugin-vue: 7.17.0 font-awesome: ^4.7.0 husky: 7.0.2 + js-cookie: ^3.0.1 lint-staged: 11.1.2 lodash-es: ^4.17.21 lowdb: ^3.0.0 @@ -49,6 +52,7 @@ specifiers: postcss-import: 14.0.0 prettier: 2.3.2 pretty-quick: 3.1.1 + qs: ^6.10.2 remixicon: ^2.5.0 resize-observer-polyfill: ^1.5.1 responsive-storage: ^1.0.11 @@ -86,6 +90,7 @@ dependencies: element-plus: 1.2.0-beta.3_vue@3.2.21 element-resize-detector: 1.2.3 font-awesome: 4.7.0 + js-cookie: 3.0.1 lodash-es: 4.17.21 lowdb: 3.0.0 mitt: 3.0.0 @@ -94,6 +99,7 @@ dependencies: path: 0.12.7 path-to-regexp: 6.2.0 pinia: 2.0.2_typescript@4.4.2+vue@3.2.21 + qs: 6.10.2 remixicon: 2.5.0 resize-observer-polyfill: 1.5.1 responsive-storage: 1.0.11_vue@3.2.21 @@ -107,9 +113,11 @@ devDependencies: "@commitlint/cli": 13.1.0 "@commitlint/config-conventional": 13.1.0 "@types/element-resize-detector": 1.1.3 + "@types/js-cookie": 3.0.1 "@types/mockjs": 1.0.3 "@types/node": 14.14.14 "@types/nprogress": 0.2.0 + "@types/qs": 6.9.7 "@typescript-eslint/eslint-plugin": 4.31.0_f4e6dc0776b3600ef484e3c64a523136 "@typescript-eslint/parser": 4.31.0_eslint@7.30.0+typescript@4.4.2 "@vitejs/plugin-vue": 1.9.4_vite@2.6.14 @@ -1017,6 +1025,13 @@ packages: } dev: true + /@types/js-cookie/3.0.1: + resolution: + { + integrity: sha512-7wg/8gfHltklehP+oyJnZrz9XBuX5ZPP4zB6UsI84utdlkRYLnOm2HfpLXazTwZA+fpGn0ir8tGNgVnMEleBGQ== + } + dev: true + /@types/json-schema/7.0.9: resolution: { @@ -1089,6 +1104,13 @@ packages: } dev: true + /@types/qs/6.9.7: + resolution: + { + integrity: sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== + } + dev: true + /@types/resolve/1.17.1: resolution: { @@ -1870,6 +1892,16 @@ packages: engines: { node: ">=6" } dev: true + /call-bind/1.0.2: + resolution: + { + integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== + } + dependencies: + function-bind: 1.1.1 + get-intrinsic: 1.1.1 + dev: false + /callsites/3.1.0: resolution: { @@ -3379,7 +3411,6 @@ packages: { integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== } - dev: true /functional-red-black-tree/1.0.1: resolution: { integrity: sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= } @@ -3401,6 +3432,17 @@ packages: engines: { node: 6.* || 8.* || >= 10.* } dev: true + /get-intrinsic/1.1.1: + resolution: + { + integrity: sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== + } + dependencies: + function-bind: 1.1.1 + has: 1.0.3 + has-symbols: 1.0.2 + dev: false + /get-own-enumerable-property-symbols/3.0.2: resolution: { @@ -3586,6 +3628,14 @@ packages: engines: { node: ">=8" } dev: true + /has-symbols/1.0.2: + resolution: + { + integrity: sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw== + } + engines: { node: ">= 0.4" } + dev: false + /has/1.0.3: resolution: { @@ -3594,7 +3644,6 @@ packages: engines: { node: ">= 0.4.0" } dependencies: function-bind: 1.1.1 - dev: true /hash-sum/2.0.0: resolution: @@ -3932,6 +3981,14 @@ packages: resolution: { integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= } dev: true + /js-cookie/3.0.1: + resolution: + { + integrity: sha512-+0rgsUXZu4ncpPxRL+lNEptWMOWl9etvPHc/koSRp6MPwpRYAhmk0dUG00J4bxVV3r9uUzfo24wW0knS07SKSw== + } + engines: { node: ">=12" } + dev: false + /js-tokens/4.0.0: resolution: { @@ -4576,6 +4633,13 @@ packages: resolution: { integrity: sha1-b2gragJ6Tp3fpFZM0lidHU5mnt4= } dev: true + /object-inspect/1.11.1: + resolution: + { + integrity: sha512-If7BjFlpkzzBeV1cqgT3OSWT3azyoxDGajR+iGnFBfVV2EWyDyWaZZW2ERDjUaY2QM8i5jI3Sj7mhsM4DDAqWA== + } + dev: false + /on-finished/2.3.0: resolution: { integrity: sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= } engines: { node: ">= 0.8" } @@ -5103,6 +5167,16 @@ packages: engines: { node: ">=0.6.0", teleport: ">=0.2.0" } dev: true + /qs/6.10.2: + resolution: + { + integrity: sha512-mSIdjzqznWgfd4pMii7sHtaYF8rx8861hBO80SraY5GT0XQibWZWJSid0avzHGkDIZLImux2S5mXO0Hfct2QCw== + } + engines: { node: ">=0.6" } + dependencies: + side-channel: 1.0.4 + dev: false + /queue-microtask/1.2.3: resolution: { @@ -5469,6 +5543,17 @@ packages: engines: { node: ">=8" } dev: true + /side-channel/1.0.4: + resolution: + { + integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== + } + dependencies: + call-bind: 1.0.2 + get-intrinsic: 1.1.1 + object-inspect: 1.11.1 + dev: false + /signal-exit/3.0.5: resolution: { diff --git a/src/api/routes.ts b/src/api/routes.ts index bbd3527..2c6dc6a 100644 --- a/src/api/routes.ts +++ b/src/api/routes.ts @@ -1,5 +1,5 @@ import { http } from "../utils/http"; -export const getAsyncRoutes = (data?: object) => { - return http.request("get", "/getAsyncRoutes", data); +export const getAsyncRoutes = (params?: object) => { + return http.request("get", "/getAsyncRoutes", { params }); }; diff --git a/src/api/user.ts b/src/api/user.ts new file mode 100644 index 0000000..a9bac54 --- /dev/null +++ b/src/api/user.ts @@ -0,0 +1,26 @@ +import { http } from "../utils/http"; + +interface userType extends Promise { + svg?: string; + code?: number; + info?: object; +} + +// 获取验证码 +export const getVerify = (): userType => { + return http.request("get", "/captcha"); +}; + +// 登录 +export const getLogin = (data: object) => { + return http.request("post", "/login", { data }); +}; + +// 刷新token +export const refreshToken = (data: object) => { + return http.request("post", "/refreshToken", { data }); +}; + +// export const searchVague = (data: object) => { +// return http.request("post", "/searchVague", { data }); +// }; diff --git a/src/assets/avatars.jpg b/src/assets/avatars.jpg new file mode 100644 index 0000000..a0226ae Binary files /dev/null and b/src/assets/avatars.jpg differ diff --git a/src/config/index.ts b/src/config/index.ts index c747e16..7b0426a 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,6 +1,9 @@ import { App } from "vue"; import axios from "axios"; +import { loadEnv } from "@build/index"; + let config: object = {}; +const { VITE_PUBLIC_PATH } = loadEnv(); const setConfig = (cfg?: unknown) => { config = Object.assign(config, cfg); @@ -30,10 +33,7 @@ export const getServerConfig = async (app: App): Promise => { return axios({ baseURL: "", method: "get", - url: - process.env.NODE_ENV === "production" - ? "/manages/serverConfig.json" - : "/serverConfig.json" + url: `${VITE_PUBLIC_PATH}serverConfig.json` }) .then(({ data: config }) => { let $config = app.config.globalProperties.$config; diff --git a/src/layout/components/appMain.vue b/src/layout/components/appMain.vue index d1ee605..35211bb 100644 --- a/src/layout/components/appMain.vue +++ b/src/layout/components/appMain.vue @@ -75,7 +75,7 @@ const transitionMain = defineComponent({ hideTabs && layout ? 'padding-top: 48px;' : '', !hideTabs && layout ? 'padding-top: 85px;' : '', hideTabs && !layout ? 'padding-top: 48px' : '', - !hideTabs && !layout ? 'padding-top: 98px;' : '' + !hideTabs && !layout ? 'padding-top: 85px;' : '' ]" > diff --git a/src/layout/components/navbar.vue b/src/layout/components/navbar.vue index 4064e3e..06a7aff 100644 --- a/src/layout/components/navbar.vue +++ b/src/layout/components/navbar.vue @@ -1,17 +1,18 @@