11<script setup lang="ts">
2- import { ref } from ' vue'
2+ import { onMounted , ref } from ' vue'
33import { client , AuthService } from ' @/client/api'
4- import { setAuthToken } from ' @/client/auth'
4+ import { getRememberLogin , setAuthToken } from ' @/client/auth'
55import { createDebugApiBaseUrl , getDefaultApiBaseUrl } from ' @/client/base'
66import { getErrorMessage } from ' @/client/utils'
77import router from ' @/router'
@@ -18,6 +18,7 @@ const toast = useToastStore()
1818const nonebotStore = useNoneBotStore ()
1919
2020const token = ref (' ' )
21+ const rememberLogin = ref (false )
2122const isDebug = ref (false )
2223const host = ref (' ' )
2324const port = ref (' ' )
@@ -51,7 +52,7 @@ const login = async () => {
5152 }
5253
5354 if (data ?.detail ) {
54- setAuthToken (data .detail )
55+ setAuthToken (data .detail , rememberLogin . value )
5556 client .interceptors .request .use ((request : ClientRequest ) => {
5657 request .headers .set (' Authorization' , ` Bearer ${data .detail } ` )
5758 return request
@@ -61,6 +62,10 @@ const login = async () => {
6162 toast .add (' success' , ' 登录成功' , ' ' , 5000 )
6263 }
6364}
65+
66+ onMounted (() => {
67+ rememberLogin .value = getRememberLogin ()
68+ })
6469 </script >
6570
6671<template >
@@ -76,13 +81,19 @@ const login = async () => {
7681 required
7782 />
7883 <div class =" label" >
79- <span class =" label-text" >开发模式</span >
80- <input
81- type =" checkbox"
82- class =" checkbox checkbox-xs"
83- :checked =" isDebug"
84- @click =" isDebug = !isDebug"
85- />
84+ <div class =" flex items-center gap-2" >
85+ <span class =" label-text" >记住登录</span >
86+ <input v-model =" rememberLogin" type =" checkbox" class =" checkbox checkbox-xs" />
87+ </div >
88+ <div class =" flex items-center gap-2" >
89+ <span class =" label-text" >开发模式</span >
90+ <input
91+ type =" checkbox"
92+ class =" checkbox checkbox-xs"
93+ :checked =" isDebug"
94+ @click =" isDebug = !isDebug"
95+ />
96+ </div >
8697 </div >
8798 </label >
8899
0 commit comments