From 6aa994fa7d72ca911fec5d37897918e770753ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=9F=E8=B1=86=E5=93=A5?= Date: Mon, 1 Aug 2022 00:16:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/QuickCrud/index.vue | 1 + src/layout/index.vue | 5 ++++- src/pages/login/index.vue | 2 +- src/router/dynamicRouter.ts | 6 +++--- src/router/index.ts | 12 +++++++----- src/store/modules/tab.ts | 6 +++--- src/utils/request.ts | 9 ++++++--- tsconfig.json | 2 +- vite.config.ts | 21 +++++++++++++++++++-- 9 files changed, 45 insertions(+), 19 deletions(-) diff --git a/src/components/QuickCrud/index.vue b/src/components/QuickCrud/index.vue index ddfaa17..43da053 100644 --- a/src/components/QuickCrud/index.vue +++ b/src/components/QuickCrud/index.vue @@ -201,6 +201,7 @@ const refresh = () => { if (leftTree.value && leftTreeRefresh.value) { treeLoad() } else { + load() } } /** diff --git a/src/layout/index.vue b/src/layout/index.vue index 7128893..cd8ef46 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -23,7 +23,6 @@ const { t } = useI18n() console.log('i18n', t('title')) const isCollapse = computed(() => appStore.getCollapse) -// router.push('/home') /** * 选项卡 */ @@ -42,8 +41,12 @@ const handleClick = (activeName: string) => { if (index !== -1) { tabStore.setActiveTab(tabList.value[index]) menuStore.setActiveMenuId(activeName) + editableTabsValue.value = activeName } } +if (activeTab.value.id) { + handleClick(activeTab.value.id) +} watch(activeTab, (val) => { if (val) { const { id, path } = val diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index 2c63ce2..204604d 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -77,7 +77,7 @@ const handleLogin = async (): Promise => { align-items: center; justify-content: center; // background-color: green; - background: url('public/images/login-bg.jpeg') no-repeat center center; + background: url('/images/login-bg.jpeg') no-repeat center center; background-size: 100% 100%; border-radius: 5px; .form { diff --git a/src/router/dynamicRouter.ts b/src/router/dynamicRouter.ts index cd3a92a..15e606b 100644 --- a/src/router/dynamicRouter.ts +++ b/src/router/dynamicRouter.ts @@ -1,16 +1,16 @@ -import layout from '../layout/index.vue' +import layout from '@/layout/index.vue' const dynamicRouter = [ { path: '/', - // name: '', + name: 'fist', component: layout, redirect: '/home', children: [ { path: '/home', name: 'home', - component: () => import('../views/home/index.vue'), + component: () => import('@/views/home/index.vue'), }, ], }, diff --git a/src/router/index.ts b/src/router/index.ts index a9172a2..5b9391b 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -12,10 +12,10 @@ export const router = createRouter({ history: createWebHashHistory(), routes: [...staticRouter, ...dynamicRouter], }) -const modules = import.meta.glob('../views/*/*.vue') -export const formatRouter = (data: Menu[]) => { - console.log('data', data) +const modules = import.meta.glob('../views/**/*.vue') +const layout = import.meta.glob('../layout/*.vue') +export const formatRouter = (data: Menu[]) => { const arr: RouteRecordRaw[] = [] const firstMenuArr: Menu[] = [] const secondMenuArr: Menu[] = [] @@ -30,7 +30,7 @@ export const formatRouter = (data: Menu[]) => { const routerObj: RouteRecordRaw = { name: element.menuId, path: element.path, - component: import('@/layout/index.vue'), + component: layout['../layout/index.vue'], redirect: '', children: [], meta: { @@ -79,13 +79,15 @@ router.beforeEach(async (to, from, next) => { const loginStore = useLoginStore(pinia) if (loginStore.getToken) { if (to.path === '/login') { + isRefresh = true next() } else if (to.name && !isRefresh) { + isRefresh = true next() } else { + isRefresh = false await addRoutes() next({ ...to, replace: true }) - isRefresh = false } } else if (to.path === '/login') { next() diff --git a/src/store/modules/tab.ts b/src/store/modules/tab.ts index 56c1aa3..5734a25 100644 --- a/src/store/modules/tab.ts +++ b/src/store/modules/tab.ts @@ -50,7 +50,7 @@ export const useTabStore = defineStore('tabStore', { } }, }, - // persist: { - // enabled: true, - // }, + persist: { + enabled: true, + }, }) diff --git a/src/utils/request.ts b/src/utils/request.ts index 8eba8f5..0a4000f 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -22,11 +22,14 @@ const quickRequest: AxiosInstance = axios.create({ // 请求拦截器 quickRequest.interceptors.request.use( (config) => { + const cfg = config const loginStore = useLoginStore() - console.log('request', config) const token = loginStore.getToken - config.headers.authorization = `Bearer ${token}` - return config + if (cfg.headers) { + cfg.headers.authorization = `Bearer ${token}` + } + console.log('request', cfg) + return cfg }, (error) => { console.error(error) diff --git a/tsconfig.json b/tsconfig.json index 8262897..9c0e250 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ "skipLibCheck": true, "types": ["element-plus/global"], "suppressImplicitAnyIndexErrors": true, - "baseUrl": ".", + "baseUrl": "./", "paths": { "@/*": ["src/*"] }, diff --git a/vite.config.ts b/vite.config.ts index e864dcd..2513754 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,7 +10,7 @@ export default ({ command, mode }) => { const env = loadEnv(mode, root) const { VITE_APP_TITLE, VITE_PORT, VITE_APP_BASE_URL } = env return { - base: './', + base: '/', plugins: [ vue(), DefineOptions(), @@ -45,9 +45,10 @@ export default ({ command, mode }) => { https: false, // 运行服务是否以https方式 host: true, port: VITE_PORT, + open: true, proxy: { [VITE_APP_BASE_URL]: { - // target: 'http://localhost:3002/', // 代理的目标地址-本地 + // target: 'http://localhost:3102/', // 代理的目标地址-本地 target: 'http://110.42.130.88:3102/', // 代理的目标地址-线上 changeOrigin: false, // 开发模式,默认的origin是真实的 origin:localhost:3000 代理服务会把origin修改为目标地址 secure: false, // 是否https接口 @@ -56,5 +57,21 @@ export default ({ command, mode }) => { }, }, }, + preview: { + https: false, // 运行服务是否以https方式 + host: true, + port: 3103, + open: true, + proxy: { + [VITE_APP_BASE_URL]: { + // target: 'http://localhost:3102/', // 代理的目标地址-本地 + target: 'http://110.42.130.88:3102/', // 代理的目标地址-线上 + changeOrigin: false, // 开发模式,默认的origin是真实的 origin:localhost:3000 代理服务会把origin修改为目标地址 + secure: false, // 是否https接口 + ws: false, // 是否代理websockets + rewrite: (path) => path.replace(/^\/prod-api/, ''), // 路径重写 + }, + }, + }, } } -- Gitee From 061a6f21bbb06100f7729c2592f31b1c10a13c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=9F=E8=B1=86=E5=93=A5?= Date: Sun, 31 Jul 2022 16:32:05 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=BC=94=E7=A4=BA=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6786814..c943d1a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ quick-vue3-admin 是一款免费开源快速搭建中后台系统框架。本框 ## 预览 -- [quick-vue3-admin](https://ainiteam.com:3101/) - 框架演示 +- [quick-vue3-admin](http://quick.ainiteam.com/) - 框架演示 演示账号密码:admin/123456 -- Gitee