mirror of
https://github.com/jackhh66/ChatGPT_Web_accessToken.git
synced 2026-12-03 21:39:32 +00:00
feat: session 返回接口方式做显示判断
This commit is contained in:
1 parent
c5552893d7
commit
95724845cf
3 files changed
+27
-7
No files matched your search
@@ -3,9 +3,14 @@ import { getToken, removeToken, setToken } from './helper'
|
||||
import { store } from '@/store'
|
||||
import { fetchSession } from '@/api'
|
||||
|
||||
interface SessionResponse {
|
||||
auth: boolean
|
||||
model: 'ChatGPTAPI' | 'ChatGPTUnofficialProxyAPI'
|
||||
}
|
||||
|
||||
export interface AuthState {
|
||||
token: string | undefined
|
||||
session: { auth: boolean } | null
|
||||
session: SessionResponse | null
|
||||
}
|
||||
|
||||
export const useAuthStore = defineStore('auth-store', {
|
||||
@@ -14,10 +19,16 @@ export const useAuthStore = defineStore('auth-store', {
|
||||
session: null,
|
||||
}),
|
||||
|
||||
getters: {
|
||||
isChatGPTAPI(state): boolean {
|
||||
return state.session?.model === 'ChatGPTAPI'
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
async getSession() {
|
||||
try {
|
||||
const { data } = await fetchSession<{ auth: boolean }>()
|
||||
const { data } = await fetchSession<SessionResponse>()
|
||||
this.session = { ...data }
|
||||
return Promise.resolve(data)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user