mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
优化 Cookie 存储类型;更新登录状态判断逻辑;添加 Tauri 环境判断以支持版本更新处理
This commit is contained in:
@@ -13,7 +13,7 @@ export const isLoggedIn = computed<boolean>(() => {
|
||||
});
|
||||
|
||||
const { message } = createDiscreteApi(['message']);
|
||||
export const cookie = useLocalStorage('Cookie', {cookie: '', refreshDate: 0}, { serializer: StorageSerializers.object });
|
||||
export const cookie = useLocalStorage<{ cookie: string; refreshDate: number }>('Cookie', {cookie: '', refreshDate: 0}, { serializer: StorageSerializers.object });
|
||||
|
||||
export async function GetSelfAccount(token?: string) {
|
||||
if (cookie.value.cookie || token) {
|
||||
|
||||
@@ -218,7 +218,7 @@ onUnmounted(() => {
|
||||
<template #header-extra>
|
||||
<slot name="header-extra" />
|
||||
</template>
|
||||
<template v-if="cookie">
|
||||
<template v-if="cookie.cookie">
|
||||
<NAlert type="warning">
|
||||
你已经登录
|
||||
</NAlert>
|
||||
|
||||
@@ -10,6 +10,8 @@ const failoverAPI = `https://failover-api.vtsuru.suki.club/`;
|
||||
|
||||
export const isBackendUsable = ref(true);
|
||||
export const isDev = import.meta.env.MODE === 'development';
|
||||
// @ts-ignore
|
||||
export const isTauri = window.__TAURI__ !== undefined || window.__TAURI_INTERNAL__ !== undefined;
|
||||
|
||||
export const AVATAR_URL = 'https://workers.vrp.moe/api/bilibili/avatar/';
|
||||
export const FILE_BASE_URL = 'https://files.vtsuru.live';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { QueryGetAPI } from '@/api/query'
|
||||
import { apiFail, BASE_API_URL } from '@/data/constants'
|
||||
import { apiFail, BASE_API_URL, isTauri } from '@/data/constants'
|
||||
import HyperDX from '@hyperdx/browser'
|
||||
import EasySpeech from 'easy-speech'
|
||||
import { createDiscreteApi, NButton, NFlex, NText } from 'naive-ui'
|
||||
@@ -55,6 +55,10 @@ QueryGetAPI<string>(`${BASE_API_URL}vtsuru/version`)
|
||||
const path = url.pathname
|
||||
|
||||
if (!path.startsWith('/obs')) {
|
||||
if (isTauri) {
|
||||
location.reload();
|
||||
}
|
||||
else {
|
||||
const n = notification.info({
|
||||
title: '发现新的版本更新',
|
||||
content: '是否现在刷新?',
|
||||
@@ -84,6 +88,7 @@ QueryGetAPI<string>(`${BASE_API_URL}vtsuru/version`)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}, 60 * 1000)
|
||||
|
||||
Reference in New Issue
Block a user