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']);
|
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) {
|
export async function GetSelfAccount(token?: string) {
|
||||||
if (cookie.value.cookie || token) {
|
if (cookie.value.cookie || token) {
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ onUnmounted(() => {
|
|||||||
<template #header-extra>
|
<template #header-extra>
|
||||||
<slot name="header-extra" />
|
<slot name="header-extra" />
|
||||||
</template>
|
</template>
|
||||||
<template v-if="cookie">
|
<template v-if="cookie.cookie">
|
||||||
<NAlert type="warning">
|
<NAlert type="warning">
|
||||||
你已经登录
|
你已经登录
|
||||||
</NAlert>
|
</NAlert>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ const failoverAPI = `https://failover-api.vtsuru.suki.club/`;
|
|||||||
|
|
||||||
export const isBackendUsable = ref(true);
|
export const isBackendUsable = ref(true);
|
||||||
export const isDev = import.meta.env.MODE === 'development';
|
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 AVATAR_URL = 'https://workers.vrp.moe/api/bilibili/avatar/';
|
||||||
export const FILE_BASE_URL = 'https://files.vtsuru.live';
|
export const FILE_BASE_URL = 'https://files.vtsuru.live';
|
||||||
|
|||||||
61
src/main.ts
61
src/main.ts
@@ -1,5 +1,5 @@
|
|||||||
import { QueryGetAPI } from '@/api/query'
|
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 HyperDX from '@hyperdx/browser'
|
||||||
import EasySpeech from 'easy-speech'
|
import EasySpeech from 'easy-speech'
|
||||||
import { createDiscreteApi, NButton, NFlex, NText } from 'naive-ui'
|
import { createDiscreteApi, NButton, NFlex, NText } from 'naive-ui'
|
||||||
@@ -55,33 +55,38 @@ QueryGetAPI<string>(`${BASE_API_URL}vtsuru/version`)
|
|||||||
const path = url.pathname
|
const path = url.pathname
|
||||||
|
|
||||||
if (!path.startsWith('/obs')) {
|
if (!path.startsWith('/obs')) {
|
||||||
const n = notification.info({
|
if (isTauri) {
|
||||||
title: '发现新的版本更新',
|
location.reload();
|
||||||
content: '是否现在刷新?',
|
}
|
||||||
meta: () => h(NText, { depth: 3 }, () => currentVersion),
|
else {
|
||||||
action: () =>
|
const n = notification.info({
|
||||||
h(NFlex, null, () => [
|
title: '发现新的版本更新',
|
||||||
h(
|
content: '是否现在刷新?',
|
||||||
NButton,
|
meta: () => h(NText, { depth: 3 }, () => currentVersion),
|
||||||
{
|
action: () =>
|
||||||
text: true,
|
h(NFlex, null, () => [
|
||||||
type: 'primary',
|
h(
|
||||||
onClick: () => location.reload(),
|
NButton,
|
||||||
size: 'small',
|
{
|
||||||
},
|
text: true,
|
||||||
{ default: () => '刷新' },
|
type: 'primary',
|
||||||
),
|
onClick: () => location.reload(),
|
||||||
h(
|
size: 'small',
|
||||||
NButton,
|
},
|
||||||
{
|
{ default: () => '刷新' },
|
||||||
text: true,
|
),
|
||||||
onClick: () => n.destroy(),
|
h(
|
||||||
size: 'small',
|
NButton,
|
||||||
},
|
{
|
||||||
{ default: () => '稍后' },
|
text: true,
|
||||||
),
|
onClick: () => n.destroy(),
|
||||||
]),
|
size: 'small',
|
||||||
})
|
},
|
||||||
|
{ default: () => '稍后' },
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user