mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
重构多个组件以优化代码格式和可读性,删除不必要的文件,更新类型定义,添加数据分析路由
This commit is contained in:
56
src/main.ts
56
src/main.ts
@@ -1,24 +1,21 @@
|
||||
import { QueryGetAPI } from '@/api/query'
|
||||
import { BASE_API_URL, apiFail } from '@/data/constants'
|
||||
import { apiFail, BASE_API_URL } from '@/data/constants'
|
||||
import HyperDX from '@hyperdx/browser'
|
||||
import EasySpeech from 'easy-speech'
|
||||
import { NButton, NFlex, NText, createDiscreteApi } from 'naive-ui'
|
||||
import { createDiscreteApi, NButton, NFlex, NText } from 'naive-ui'
|
||||
import { createPinia } from 'pinia'
|
||||
import { createApp, h } from 'vue'
|
||||
import App from './App.vue'
|
||||
import { GetSelfAccount, UpdateAccountLoop, useAccount } from './api/account'
|
||||
import App from './App.vue'
|
||||
import { GetNotifactions } from './data/notifactions'
|
||||
import emitter from './mitt'
|
||||
import router from './router'
|
||||
import { useAuthStore } from './store/useAuthStore'
|
||||
import { useVTsuruHub } from './store/useVTsuruHub'
|
||||
import { useNotificationStore } from './store/useNotificationStore'
|
||||
import HyperDX from '@hyperdx/browser'
|
||||
import mitt from 'mitt'
|
||||
import { MittType } from './mitt'
|
||||
import emitter from './mitt'
|
||||
|
||||
const pinia = createPinia()
|
||||
|
||||
QueryGetAPI<string>(BASE_API_URL + 'vtsuru/version')
|
||||
QueryGetAPI<string>(`${BASE_API_URL}vtsuru/version`)
|
||||
.then((version) => {
|
||||
if (version.code == 200) {
|
||||
currentVersion = version.data
|
||||
@@ -29,28 +26,29 @@ QueryGetAPI<string>(BASE_API_URL + 'vtsuru/version')
|
||||
setTimeout(() => {
|
||||
location.reload()
|
||||
}, 1000)
|
||||
//alert('发现新的版本更新, 请按 Ctrl+F5 强制刷新页面')
|
||||
// alert('发现新的版本更新, 请按 Ctrl+F5 强制刷新页面')
|
||||
notification.info({
|
||||
title: '发现新的版本更新',
|
||||
content: '将自动刷新页面',
|
||||
duration: 5000,
|
||||
meta: () => h(NText, { depth: 3 }, () => currentVersion)
|
||||
meta: () => h(NText, { depth: 3 }, () => currentVersion),
|
||||
})
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setInterval(() => {
|
||||
if (isHaveNewVersion) {
|
||||
return
|
||||
}
|
||||
QueryGetAPI<string>(BASE_API_URL + 'vtsuru/version').then(
|
||||
QueryGetAPI<string>(`${BASE_API_URL}vtsuru/version`).then(
|
||||
(keepCheckData) => {
|
||||
if (
|
||||
keepCheckData.code == 200 &&
|
||||
keepCheckData.data != currentVersion
|
||||
keepCheckData.code == 200
|
||||
&& keepCheckData.data != currentVersion
|
||||
) {
|
||||
isHaveNewVersion = true
|
||||
currentVersion = keepCheckData.data
|
||||
localStorage.setItem('Version', currentVersion)
|
||||
console.log('[vtsuru] 发现新版本: ' + currentVersion)
|
||||
console.log(`[vtsuru] 发现新版本: ${currentVersion}`)
|
||||
|
||||
const url = new URL(window.location.href)
|
||||
const path = url.pathname
|
||||
@@ -68,24 +66,24 @@ QueryGetAPI<string>(BASE_API_URL + 'vtsuru/version')
|
||||
text: true,
|
||||
type: 'primary',
|
||||
onClick: () => location.reload(),
|
||||
size: 'small'
|
||||
size: 'small',
|
||||
},
|
||||
{ default: () => '刷新' }
|
||||
{ default: () => '刷新' },
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
text: true,
|
||||
onClick: () => n.destroy(),
|
||||
size: 'small'
|
||||
size: 'small',
|
||||
},
|
||||
{ default: () => '稍后' }
|
||||
)
|
||||
])
|
||||
{ default: () => '稍后' },
|
||||
),
|
||||
]),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}, 60 * 1000)
|
||||
}
|
||||
@@ -102,10 +100,10 @@ QueryGetAPI<string>(BASE_API_URL + 'vtsuru/version')
|
||||
service: 'vtsuru.live',
|
||||
tracePropagationTargets: [/vtsuru.suki.club/i], // Set to link traces from frontend to backend requests
|
||||
consoleCapture: true, // Capture console logs (default false)
|
||||
advancedNetworkCapture: true // Capture full HTTP request/response headers and bodies (default false)
|
||||
advancedNetworkCapture: true, // Capture full HTTP request/response headers and bodies (default false)
|
||||
})
|
||||
}
|
||||
//加载其他数据
|
||||
// 加载其他数据
|
||||
InitTTS()
|
||||
await GetSelfAccount()
|
||||
const account = useAccount()
|
||||
@@ -142,11 +140,13 @@ function InitTTS() {
|
||||
if (result.speechSynthesis) {
|
||||
EasySpeech.init({ maxTimeout: 5000, interval: 250 })
|
||||
.then(() => console.log('[SpeechSynthesis] 已加载tts服务'))
|
||||
.catch((e) => console.error(e))
|
||||
} else {
|
||||
.catch(e => console.error(e))
|
||||
}
|
||||
else {
|
||||
console.log('[SpeechSynthesis] 当前浏览器不支持tts服务')
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
console.log('[SpeechSynthesis] 当前浏览器不支持tts服务')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user