File tree Expand file tree Collapse file tree 8 files changed +50
-42
lines changed
Expand file tree Collapse file tree 8 files changed +50
-42
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import GlobalProviders from " @/components/GlobalProviders.vue" ;
3- import Layout from " @/components/Layout.vue" ;
4- import { useAuthKey } from " @/services/auth" ;
5- import { computed } from " vue" ;
6-
7- const authKey = useAuthKey ();
8- const isLoggedIn = computed (() => !! authKey .value );
93 </script >
104
115<template >
126 <global-providers >
137 <div id =" app-root" >
14- <layout v-if =" isLoggedIn" key =" layout" />
15- <router-view v-else key =" auth" />
8+ <router-view />
169 </div >
1710 </global-providers >
1811</template >
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ const Message = defineComponent({
7171<template >
7272 <n-config-provider :theme-overrides =" themeOverrides" >
7373 <n-loading-bar-provider >
74- <n-message-provider >
74+ <n-message-provider placement = " top-right " >
7575 <n-dialog-provider >
7676 <slot />
7777 <loading-bar />
Original file line number Diff line number Diff line change @@ -136,10 +136,10 @@ function handleClose() {
136136<style scoped>
137137.global-task-progress {
138138 position : fixed ;
139- top : 20 px ;
140- right : 20 px ;
139+ bottom : 62 px ;
140+ right : 10 px ;
141141 z-index : 9999 ;
142- width : 360 px ;
142+ width : 350 px ;
143143 background : white ;
144144 border-radius : var (--border-radius-md );
145145 box-shadow : var (--shadow-lg );
Original file line number Diff line number Diff line change @@ -176,7 +176,11 @@ async function testKey(_key: KeyRow) {
176176 if (curValid .is_valid ) {
177177 window .$message .success (" 密钥测试成功" );
178178 } else {
179- window .$message .error (curValid .error || " 密钥测试失败: 无效的API密钥" );
179+ window .$message .error (curValid .error || " 密钥测试失败: 无效的API密钥" , {
180+ keepAliveOnHover: true ,
181+ duration: 5000 ,
182+ closable: true ,
183+ });
180184 }
181185 } catch (_error ) {
182186 console .error (" 测试失败" );
Original file line number Diff line number Diff line change @@ -72,7 +72,11 @@ const loadLogs = async () => {
7272 } else {
7373 logs .value = [];
7474 total .value = 0 ;
75- window .$message .error (res .message || " 加载日志失败" );
75+ window .$message .error (res .message || " 加载日志失败" , {
76+ keepAliveOnHover: true ,
77+ duration: 5000 ,
78+ closable: true ,
79+ });
7680 }
7781 } catch (_error ) {
7882 window .$message .error (" 加载日志请求失败" );
Original file line number Diff line number Diff line change 11import { useAuthService } from "@/services/auth" ;
22import { createRouter , createWebHistory , type RouteRecordRaw } from "vue-router" ;
3+ import Layout from "@/components/Layout.vue" ;
34
45const routes : Array < RouteRecordRaw > = [
56 {
67 path : "/" ,
7- name : "dashboard" ,
8- component : ( ) => import ( "@/views/Dashboard.vue" ) ,
9- } ,
10- {
11- path : "/keys" ,
12- name : "keys" ,
13- component : ( ) => import ( "@/views/Keys.vue" ) ,
14- } ,
15- {
16- path : "/logs" ,
17- name : "logs" ,
18- component : ( ) => import ( "@/views/Logs.vue" ) ,
19- } ,
20- {
21- path : "/settings" ,
22- name : "settings" ,
23- component : ( ) => import ( "@/views/Settings.vue" ) ,
8+ component : Layout ,
9+ children : [
10+ {
11+ path : "" ,
12+ name : "dashboard" ,
13+ component : ( ) => import ( "@/views/Dashboard.vue" ) ,
14+ } ,
15+ {
16+ path : "keys" ,
17+ name : "keys" ,
18+ component : ( ) => import ( "@/views/Keys.vue" ) ,
19+ } ,
20+ {
21+ path : "logs" ,
22+ name : "logs" ,
23+ component : ( ) => import ( "@/views/Logs.vue" ) ,
24+ } ,
25+ {
26+ path : "settings" ,
27+ name : "settings" ,
28+ component : ( ) => import ( "@/views/Settings.vue" ) ,
29+ } ,
30+ ] ,
2431 } ,
2532 {
2633 path : "/login" ,
Original file line number Diff line number Diff line change @@ -35,26 +35,28 @@ http.interceptors.response.use(
3535 response => {
3636 appState . loading = false ;
3737 if ( response . config . method !== "get" && ! response . config . hideMessage ) {
38- window . $message . success ( "操作成功" ) ;
38+ window . $message . success ( response . data . message ?? "操作成功" ) ;
3939 }
4040 return response . data ;
4141 } ,
4242 error => {
4343 appState . loading = false ;
4444 if ( error . response ) {
45- // The request was made and the server responded with a status code
46- // that falls out of the range of 2xx
4745 if ( error . response . status === 401 ) {
48- const { logout } = useAuthService ( ) ;
49- logout ( ) ;
50- window . location . href = "/login" ;
46+ if ( window . location . pathname !== "/login" ) {
47+ const { logout } = useAuthService ( ) ;
48+ logout ( ) ;
49+ window . location . href = "/login" ;
50+ }
5151 }
52- window . $message . error ( error . response . data ?. message || `请求失败: ${ error . response . status } ` ) ;
52+ window . $message . error ( error . response . data ?. message || `请求失败: ${ error . response . status } ` , {
53+ keepAliveOnHover : true ,
54+ duration : 5000 ,
55+ closable : true ,
56+ } ) ;
5357 } else if ( error . request ) {
54- // The request was made but no response was received
5558 window . $message . error ( "网络错误,请检查您的连接" ) ;
5659 } else {
57- // Something happened in setting up the request that triggered an Error
5860 window . $message . error ( "请求设置错误" ) ;
5961 }
6062 return Promise . reject ( error ) ;
Original file line number Diff line number Diff line change @@ -22,8 +22,6 @@ const handleLogin = async () => {
2222 loading .value = false ;
2323 if (success ) {
2424 router .push (" /" );
25- } else {
26- message .error (" 登录失败,请检查您的授权密钥" );
2725 }
2826};
2927 </script >
You can’t perform that action at this time.
0 commit comments