diff --git a/src/api/account.ts b/src/api/account.ts index 3af0163..04e385e 100644 --- a/src/api/account.ts +++ b/src/api/account.ts @@ -39,7 +39,7 @@ export async function GetSelfAccount() { isLoadingAccount.value = false } function refreshCookie() { - QueryPostAPI(`${ACCOUNT_API_URL}refresh-token`).then((data) => { + QueryPostAPI(`${ACCOUNT_API_URL()}refresh-token`).then((data) => { if (data.code == 200) { cookie.value = data.data cookieRefreshDate.value = Date.now() @@ -48,17 +48,17 @@ function refreshCookie() { }) } export async function SaveAccountSettings() { - return await QueryPostAPI(ACCOUNT_API_URL + 'update-setting', ACCOUNT.value?.settings) + return await QueryPostAPI(ACCOUNT_API_URL() + 'update-setting', ACCOUNT.value?.settings) } export async function SaveEnableFunctions(functions: FunctionTypes[]) { - return await QueryPostAPI(ACCOUNT_API_URL + 'update-enable-functions', functions) + return await QueryPostAPI(ACCOUNT_API_URL() + 'update-enable-functions', functions) } export function useAccount() { return ACCOUNT } export async function Register(name: string, email: string, password: string, token: string): Promise> { - return QueryPostAPI(`${ACCOUNT_API_URL}register`, { + return QueryPostAPI(`${ACCOUNT_API_URL()}register`, { name, email, password, @@ -67,11 +67,11 @@ export async function Register(name: string, email: string, password: string, to } export async function Login(nameOrEmail: string, password: string): Promise> { - return QueryPostAPI(`${ACCOUNT_API_URL}login`, { + return QueryPostAPI(`${ACCOUNT_API_URL()}login`, { nameOrEmail, password, }) } export async function Self(): Promise> { - return QueryPostAPI(`${ACCOUNT_API_URL}self`) + return QueryPostAPI(`${ACCOUNT_API_URL()}self`) } diff --git a/src/api/query.ts b/src/api/query.ts index ab86447..b61adfa 100644 --- a/src/api/query.ts +++ b/src/api/query.ts @@ -1,48 +1,73 @@ /* eslint-disable indent */ import { useLocalStorage } from '@vueuse/core' import { APIRoot, PaginationResponse } from './api-models' -import { Cookies20Regular } from '@vicons/fluent' +import { apiFail } from '@/data/constants' const cookie = useLocalStorage('JWT_Token', '') +let failCount = 0 -export async function QueryPostAPI(url: string, body?: unknown, headers?: [string, string][]): Promise> { - headers ??= [] - if (cookie.value) headers?.push(['Authorization', `Bearer ${cookie.value}`]) - headers?.push(['Content-Type', 'application/json']) - - const data = await fetch(url, { - method: 'post', - headers: headers, - body: typeof body === 'string' ? body : JSON.stringify(body), - }) // 不处理异常, 在页面处理 - return (await data.json()) as APIRoot +export async function QueryPostAPI(urlString: string, body?: unknown, headers?: [string, string][]): Promise> { + return await QueryPostAPIWithParams(urlString, undefined, body, 'application/json', headers) } export async function QueryPostAPIWithParams(urlString: string, params?: any, body?: any, contentType?: string, headers?: [string, string][]): Promise> { const url = new URL(urlString) - url.search = new URLSearchParams(params).toString() + url.search = getParams(params) headers ??= [] headers?.push(['Authorization', `Bearer ${cookie.value}`]) + if (contentType) headers?.push(['Content-Type', contentType]) - const data = await fetch(url, { - method: 'post', - headers: headers, - body: body, - }) // 不处理异常, 在页面处理 - return (await data.json()) as APIRoot + try { + const data = await fetch(url, { + method: 'post', + headers: headers, + body: typeof body === 'string' ? body : JSON.stringify(body), + }) + const result = (await data.json()) as APIRoot + failCount = 0 + return result + } catch (e) { + console.error(`[POST] API调用失败: ${e}`) + failCount++ + if (failCount > 3 && !apiFail.value) { + apiFail.value = true + console.log('默认API异常, 切换至故障转移节点') + } + throw e + } } export async function QueryGetAPI(urlString: string, params?: any, headers?: [string, string][]): Promise> { const url = new URL(urlString) - url.search = new URLSearchParams(params).toString() + url.search = getParams(params) if (cookie.value) { headers ??= [] headers?.push(['Authorization', `Bearer ${cookie.value}`]) } - const data = await fetch(url.toString(), { - method: 'get', - headers: headers, - }) // 不处理异常, 在页面处理 - return (await data.json()) as APIRoot + try { + const data = await fetch(url.toString(), { + method: 'get', + headers: headers, + }) + const result = (await data.json()) as APIRoot + failCount = 0 + return result + } catch (e) { + console.error(`[GET] API调用失败: ${e}`) + failCount++ + if (failCount > 3 && !apiFail.value) { + apiFail.value = true + console.log('默认API异常, 切换至故障转移节点') + } + throw e + } +} +function getParams(params?: [string, string][]) { + const urlParams = new URLSearchParams(window.location.search) + const resultParams = new URLSearchParams(params) + if (urlParams.has('as')) { + resultParams.set('as', urlParams.get('as') || '') + } + return resultParams.toString() } export async function QueryPostPaginationAPI(url: string, body?: unknown): Promise>> { return await QueryPostAPI>(url, body) diff --git a/src/api/user.ts b/src/api/user.ts index 0b2cda3..f34e338 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,5 +1,5 @@ import { QueryGetAPI } from '@/api/query' -import { BASE_API, USER_API_URL } from '@/data/constants' +import { BASE_API, USER_API_URL, apiFail } from '@/data/constants' import { APIRoot, UserInfo } from './api-models' import { ref } from 'vue' import { useRouteParams } from '@vueuse/router' @@ -12,7 +12,13 @@ export async function useUser(id: string | undefined = undefined) { id ??= route.params.id.toString() if (id) { if (!USERS.value[id]) { - const result = await GetInfo(id) + let result: APIRoot + try { + result = await GetInfo(id) + } catch { + apiFail.value = true + result = await GetInfo(id) + } if (result.code == 200) { USERS.value[id] = result.data } @@ -24,7 +30,7 @@ export async function useUser(id: string | undefined = undefined) { } export async function useUserWithUId(id: number) { if (!USERS.value[id.toString()]) { - const result = await QueryGetAPI(`${USER_API_URL}info`, { + const result = await QueryGetAPI(`${USER_API_URL()}info`, { uId: id, }) if (result.code == 200) { @@ -35,7 +41,7 @@ export async function useUserWithUId(id: number) { } export async function GetInfo(id: string): Promise> { - return QueryGetAPI(`${USER_API_URL}info`, { + return QueryGetAPI(`${USER_API_URL()}info`, { id: id, }) } diff --git a/src/components/RegisterAndLogin.vue b/src/components/RegisterAndLogin.vue index 08a1194..9151acb 100644 --- a/src/components/RegisterAndLogin.vue +++ b/src/components/RegisterAndLogin.vue @@ -143,9 +143,6 @@ function onRegisterButtonClick() { message.error(data.message) } }) - .catch((err) => { - console.error(err) - }) .finally(() => { isLoading.value = false turnstile.value?.reset() @@ -158,7 +155,7 @@ function onLoginButtonClick() { await QueryPostAPI<{ account: AccountInfo token: string - }>(ACCOUNT_API_URL + 'login', { + }>(ACCOUNT_API_URL() + 'login', { nameOrEmail: loginModel.value.account, password: loginModel.value.password, }) @@ -174,7 +171,6 @@ function onLoginButtonClick() { } }) .catch((err) => { - console.error(err) message.error('登陆失败') }) .finally(() => { @@ -184,7 +180,7 @@ function onLoginButtonClick() { } async function onForgetPassword() { canSendForgetPassword.value = false - await QueryGetAPI(ACCOUNT_API_URL + 'reset-password', { email: inputForgetPasswordValue.value }, [['Turnstile', token.value]]) + await QueryGetAPI(ACCOUNT_API_URL() + 'reset-password', { email: inputForgetPasswordValue.value }, [['Turnstile', token.value]]) .then(async (data) => { if (data.code == 200) { message.success('已发送密码重置链接到你的邮箱, 请检查') @@ -193,7 +189,6 @@ async function onForgetPassword() { } }) .catch((err) => { - console.error(err) message.error('发生错误') }) .finally(() => { diff --git a/src/components/SongList.vue b/src/components/SongList.vue index 542ad84..d0a4c78 100644 --- a/src/components/SongList.vue +++ b/src/components/SongList.vue @@ -393,7 +393,7 @@ function renderCell(value: string | number) { } async function updateSong() { - await QueryPostAPI(SONG_API_URL + 'update', { + await QueryPostAPI(SONG_API_URL() + 'update', { key: updateSongModel.value.key, song: updateSongModel.value, }).then((data) => { @@ -407,7 +407,7 @@ async function updateSong() { }) } async function delSong(song: SongsInfo) { - await QueryGetAPI(SONG_API_URL + 'del', { + await QueryGetAPI(SONG_API_URL() + 'del', { key: song.key, }).then((data) => { if (data.code == 200) { diff --git a/src/components/SongPlayer.vue b/src/components/SongPlayer.vue index e9758a2..00fc60d 100644 --- a/src/components/SongPlayer.vue +++ b/src/components/SongPlayer.vue @@ -43,7 +43,7 @@ function OnPlayMusic(song: SongsInfo) { } async function GetLyric(song: SongsInfo) { emits('update:isLrcLoading', song.key) - QueryGetAPI<{ lyric: string; tlyric: string }>(SONG_API_URL + 'get-netease-lyric', { id: song.id }) + QueryGetAPI<{ lyric: string; tlyric: string }>(SONG_API_URL() + 'get-netease-lyric', { id: song.id }) .then((data) => { console.log(mergeLyrics(data.data.lyric, data.data.tlyric)) if (data.code == 200) { @@ -67,9 +67,6 @@ async function GetLyric(song: SongsInfo) { } } }) - .catch((err) => { - console.error(err) - }) .finally(() => { emits('update:isLrcLoading', undefined) }) diff --git a/src/data/DanmakuClient.ts b/src/data/DanmakuClient.ts index 9cb1393..1bb4b49 100644 --- a/src/data/DanmakuClient.ts +++ b/src/data/DanmakuClient.ts @@ -197,10 +197,10 @@ export default class DanmakuClient { } private sendHeartbeat() { if (this.client) { - const query = this.authInfo ? QueryPostAPI(OPEN_LIVE_API_URL + 'heartbeat', this.authInfo) : QueryGetAPI(OPEN_LIVE_API_URL + 'heartbeat-internal') + const query = this.authInfo ? QueryPostAPI(OPEN_LIVE_API_URL() + 'heartbeat', this.authInfo) : QueryGetAPI(OPEN_LIVE_API_URL() + 'heartbeat-internal') query.then((data) => { if (data.code != 200) { - console.error('[OPEN-LIVE] 心跳失败: ' + data.message) + console.error('[OPEN-LIVE] 心跳失败') this.client.stop() this.client = null this.initClient() @@ -267,7 +267,7 @@ export default class DanmakuClient { } private async getAuthInfo(): Promise<{ data: OpenLiveInfo | null; message: string }> { try { - const data = await QueryPostAPI(OPEN_LIVE_API_URL + 'start', this.authInfo?.Code ? this.authInfo : undefined) + const data = await QueryPostAPI(OPEN_LIVE_API_URL() + 'start', this.authInfo?.Code ? this.authInfo : undefined) if (data.code == 200) { console.log('[OPEN-LIVE] 已获取场次信息') return { @@ -275,15 +275,12 @@ export default class DanmakuClient { message: '', } } else { - console.error('无法获取场次数据: ' + data.message) return { data: null, message: data.message, } } } catch (err) { - console.error(err) - return { data: null, message: err?.toString() || '未知错误', diff --git a/src/data/constants.ts b/src/data/constants.ts index cf34ba9..786cf6b 100644 --- a/src/data/constants.ts +++ b/src/data/constants.ts @@ -1,33 +1,35 @@ -import { defineAsyncComponent, ref } from 'vue' +import { computed, defineAsyncComponent, ref, watchEffect } from 'vue' const debugAPI = import.meta.env.VITE_DEBUG_API const releseAPI = `https://vtsuru.suki.club/api/` +const failoverAPI = `https://failover-api.vtsuru.live/api/` export const isBackendUsable = ref(true) export const AVATAR_URL = 'https://workers.vrp.moe/api/bilibili/avatar/' +export const apiFail = ref(false) -export const BASE_API = process.env.NODE_ENV === 'development' ? debugAPI : releseAPI +export const BASE_API = () => (process.env.NODE_ENV === 'development' ? debugAPI : apiFail.value ? failoverAPI : releseAPI) export const FETCH_API = 'https://fetch.vtsuru.live/' export const TURNSTILE_KEY = '0x4AAAAAAAETUSAKbds019h0' -export const USER_API_URL = `${BASE_API}user/` -export const ACCOUNT_API_URL = `${BASE_API}account/` -export const BILI_API_URL = `${BASE_API}bili/` -export const SONG_API_URL = `${BASE_API}song-list/` -export const NOTIFACTION_API_URL = `${BASE_API}notifaction/` -export const QUESTION_API_URL = `${BASE_API}qa/` -export const LOTTERY_API_URL = `${BASE_API}lottery/` -export const HISTORY_API_URL = `${BASE_API}history/` -export const SCHEDULE_API_URL = `${BASE_API}schedule/` -export const VIDEO_COLLECT_API_URL = `${BASE_API}video-collect/` -export const OPEN_LIVE_API_URL = `${BASE_API}open-live/` -export const SONG_REQUEST_API_URL = `${BASE_API}song-request/` -export const QUEUE_API_URL = `${BASE_API}queue/` -export const EVENT_API_URL = `${BASE_API}event/` -export const LIVE_API_URL = `${BASE_API}live/` -export const FEEDBACK_API_URL = `${BASE_API}feedback/` +export const USER_API_URL = () => `${BASE_API()}user/` +export const ACCOUNT_API_URL = () => `${BASE_API()}account/` +export const BILI_API_URL = () => `${BASE_API()}bili/` +export const SONG_API_URL = () => `${BASE_API()}song-list/` +export const NOTIFACTION_API_URL = () => `${BASE_API()}notifaction/` +export const QUESTION_API_URL = () => `${BASE_API()}qa/` +export const LOTTERY_API_URL = () => `${BASE_API()}lottery/` +export const HISTORY_API_URL = () => `${BASE_API()}history/` +export const SCHEDULE_API_URL = () => `${BASE_API()}schedule/` +export const VIDEO_COLLECT_API_URL = () => `${BASE_API()}video-collect/` +export const OPEN_LIVE_API_URL = () => `${BASE_API()}open-live/` +export const SONG_REQUEST_API_URL = () => `${BASE_API()}song-request/` +export const QUEUE_API_URL = () => `${BASE_API()}queue/` +export const EVENT_API_URL = () => `${BASE_API()}event/` +export const LIVE_API_URL = () => `${BASE_API()}live/` +export const FEEDBACK_API_URL = () => `${BASE_API()}feedback/` export const ScheduleTemplateMap = { '': { name: '默认', compoent: defineAsyncComponent(() => import('@/views/view/scheduleTemplate/DefaultScheduleTemplate.vue')) }, diff --git a/src/data/notifactions.ts b/src/data/notifactions.ts index 21eba69..58808c9 100644 --- a/src/data/notifactions.ts +++ b/src/data/notifactions.ts @@ -10,7 +10,7 @@ const n = ref() let isLoading = false function get() { if (isLoading) return - QueryGetAPI(SONG_REQUEST_API_URL + 'get-active') + QueryGetAPI(SONG_REQUEST_API_URL() + 'get-active') .then((data) => { if (data.code == 200) { n.value = data.data diff --git a/src/main.ts b/src/main.ts index 052268b..3383fd0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,5 @@ import { QueryGetAPI } from '@/api/query' -import { BASE_API } from '@/data/constants' +import { BASE_API, apiFail } from '@/data/constants' import { createApp, h } from 'vue' import App from './App.vue' import router from './router' @@ -9,25 +9,33 @@ import { NText, createDiscreteApi } from 'naive-ui' createApp(App).use(router).mount('#app') -GetSelfAccount() -GetNotifactions() let currentVersion: string const { notification } = createDiscreteApi(['notification']) -QueryGetAPI(BASE_API + 'vtsuru/version').then((version) => { - if (version.code == 200) { - currentVersion = version.data - const savedVersion = localStorage.getItem('Version') +QueryGetAPI(BASE_API() + 'vtsuru/version') + .then((version) => { + if (version.code == 200) { + currentVersion = version.data + const savedVersion = localStorage.getItem('Version') - if (currentVersion && savedVersion && savedVersion !== currentVersion) { - //alert('发现新的版本更新, 请按 Ctrl+F5 强制刷新页面') - notification.info({ - title: '发现新的版本更新', - content: '请按 Ctrl+F5 强制刷新页面', - duration: 5000, - meta: () => h(NText, { depth: 3 }, () => currentVersion), - }) + if (currentVersion && savedVersion && savedVersion !== currentVersion) { + //alert('发现新的版本更新, 请按 Ctrl+F5 强制刷新页面') + notification.info({ + title: '发现新的版本更新', + content: '请按 Ctrl+F5 强制刷新页面', + duration: 5000, + meta: () => h(NText, { depth: 3 }, () => currentVersion), + }) + } + + localStorage.setItem('Version', currentVersion) } - - localStorage.setItem('Version', currentVersion) - } -}) + }) + .catch(() => { + apiFail.value = true + console.log('默认API调用失败, 切换至故障转移节点') + }) + .finally(() => { + //加载其他数据 + GetSelfAccount() + GetNotifactions() + }) diff --git a/src/views/ChangePasswordView.vue b/src/views/ChangePasswordView.vue index 9391549..8b2aefc 100644 --- a/src/views/ChangePasswordView.vue +++ b/src/views/ChangePasswordView.vue @@ -21,7 +21,7 @@ function changePassword() { return } isLoading.value = true - QueryGetAPI(ACCOUNT_API_URL + 'verify/reset-password', { + QueryGetAPI(ACCOUNT_API_URL() + 'verify/reset-password', { key: key.value, password: password.value, }) @@ -34,7 +34,6 @@ function changePassword() { } }) .catch((err) => { - console.error(err) message.error('发生错误') }) .finally(() => { diff --git a/src/views/FeedbackManage.vue b/src/views/FeedbackManage.vue index 279da5e..1229c59 100644 --- a/src/views/FeedbackManage.vue +++ b/src/views/FeedbackManage.vue @@ -43,7 +43,7 @@ const newFeedback = ref({ async function get() { try { - const data = await QueryGetAPI(FEEDBACK_API_URL + 'get') + const data = await QueryGetAPI(FEEDBACK_API_URL() + 'get') if (data.code == 200) { return new List(data.data).OrderByDescending((s) => s.createAt).ToArray() } else { @@ -51,7 +51,6 @@ async function get() { return [] } } catch (err) { - console.error(err) message.error('无法获取数据') } return [] @@ -61,7 +60,7 @@ async function add() { message.error('反馈内容不能为空') return } - await QueryPostAPI(FEEDBACK_API_URL + 'add', newFeedback.value) + await QueryPostAPI(FEEDBACK_API_URL() + 'add', newFeedback.value) .then((data) => { if (data.code == 200) { message.success('发送成功, 感谢你的反馈!') @@ -73,7 +72,6 @@ async function add() { } }) .catch((err) => { - console.error(err) message.error('发送失败') }) } diff --git a/src/views/ManageLayout.vue b/src/views/ManageLayout.vue index ab2d1b5..746be94 100644 --- a/src/views/ManageLayout.vue +++ b/src/views/ManageLayout.vue @@ -285,7 +285,7 @@ const menuOptions = [ ] async function resendEmail() { - await QueryGetAPI(ACCOUNT_API_URL + 'send-verify-email') + await QueryGetAPI(ACCOUNT_API_URL() + 'send-verify-email') .then((data) => { if (data.code == 200) { canResendEmail.value = false @@ -296,7 +296,6 @@ async function resendEmail() { } }) .catch((err) => { - console.error(err) message.error('发送失败') }) } diff --git a/src/views/VerifyView.vue b/src/views/VerifyView.vue index f28e1b2..911ab7b 100644 --- a/src/views/VerifyView.vue +++ b/src/views/VerifyView.vue @@ -15,7 +15,7 @@ const isLoading = ref(false) async function VerifyAccount() { isLoading.value = true - await QueryGetAPI(ACCOUNT_API_URL + 'verify', { + await QueryGetAPI(ACCOUNT_API_URL() + 'verify', { target: route.query.target, }) .then((data) => { diff --git a/src/views/VideoCollectListView.vue b/src/views/VideoCollectListView.vue index 9ccb54a..19a4666 100644 --- a/src/views/VideoCollectListView.vue +++ b/src/views/VideoCollectListView.vue @@ -33,12 +33,11 @@ const totalTime = computed(() => { async function get() { try { - const data = await QueryGetAPI(VIDEO_COLLECT_API_URL + 'get', { id: route.params.id }) + const data = await QueryGetAPI(VIDEO_COLLECT_API_URL() + 'get', { id: route.params.id }) if (data.code == 200) { return data.data } } catch (err) { - console.error(err) message.error('获取失败') } return null @@ -117,14 +116,12 @@ function formatSecondsToTime(seconds: number): string { 已观看 {{ watchedVideos.length }} 条 - - 已观看全部视频 - + 已观看全部视频 - + diff --git a/src/views/VideoCollectPublic.vue b/src/views/VideoCollectPublic.vue index 34855ea..fb40efe 100644 --- a/src/views/VideoCollectPublic.vue +++ b/src/views/VideoCollectPublic.vue @@ -28,12 +28,11 @@ const isLoading = ref(false) async function get() { try { - const data = await QueryGetAPI(VIDEO_COLLECT_API_URL + 'get', { id: route.params.id }) + const data = await QueryGetAPI(VIDEO_COLLECT_API_URL() + 'get', { id: route.params.id }) if (data.code == 200) { return data.data.table } } catch (err) { - console.error(err) message.error('获取失败') } return null @@ -45,7 +44,7 @@ async function add() { } isLoading.value = true addModel.value.id = table.value?.id ?? route.params.id.toString() - await QueryPostAPI(VIDEO_COLLECT_API_URL + 'add', addModel.value, [['Turnstile', token.value]]) + await QueryPostAPI(VIDEO_COLLECT_API_URL() + 'add', addModel.value, [['Turnstile', token.value]]) .then((data) => { if (data.code == 200) { message.success('已成功推荐视频') @@ -57,7 +56,6 @@ async function add() { } }) .catch((err) => { - console.error(err) message.error('添加失败') }) .finally(() => { diff --git a/src/views/ViewerLayout.vue b/src/views/ViewerLayout.vue index 721186f..3c54397 100644 --- a/src/views/ViewerLayout.vue +++ b/src/views/ViewerLayout.vue @@ -63,9 +63,6 @@ async function RequestBiliUserData() { throw new Error('Bili User API Error: ' + data.message) } }) - .catch((err) => { - console.error(err) - }) } onMounted(async () => { diff --git a/src/views/manage/BiliVerifyView.vue b/src/views/manage/BiliVerifyView.vue index 5793891..af9b98d 100644 --- a/src/views/manage/BiliVerifyView.vue +++ b/src/views/manage/BiliVerifyView.vue @@ -18,7 +18,7 @@ const roomId = ref() const timer = ref() function onStartVerify() { - QueryGetAPI(BILI_API_URL + 'verify', { + QueryGetAPI(BILI_API_URL() + 'verify', { uId: uId.value, }).then((data) => { if (data.code == 200) { @@ -34,7 +34,7 @@ async function checkStatus() { uId: number roomId: number endTime: number - }>(BILI_API_URL + 'status') + }>(BILI_API_URL() + 'status') if (data.code == 200) { //正在进行认证 roomId.value ??= data.data.roomId diff --git a/src/views/manage/DashboardView.vue b/src/views/manage/DashboardView.vue index 38ada44..3358f4b 100644 --- a/src/views/manage/DashboardView.vue +++ b/src/views/manage/DashboardView.vue @@ -38,7 +38,7 @@ function logout() { } function resetBili() { isLoading.value = true - QueryGetAPI(ACCOUNT_API_URL + 'reset-bili') + QueryGetAPI(ACCOUNT_API_URL() + 'reset-bili') .then((data) => { if (data.code == 200) { message.success('已解绑 Bilibili 账号') @@ -50,13 +50,12 @@ function resetBili() { } }) .catch((err) => { - console.error(err) message.error('发生错误') }) } function resetEmail() { isLoading.value = true - QueryGetAPI(ACCOUNT_API_URL + 'reset-email', { email: newEmailAddress.value, code: newEmailVerifyCode.value }) + QueryGetAPI(ACCOUNT_API_URL() + 'reset-email', { email: newEmailAddress.value, code: newEmailVerifyCode.value }) .then((data) => { if (data.code == 200) { message.success('已将邮箱改绑为 ' + newEmailAddress.value) @@ -68,12 +67,11 @@ function resetEmail() { } }) .catch((err) => { - console.error(err) message.error('发生错误') }) } function sendEmailVerifyCode() { - QueryGetAPI(ACCOUNT_API_URL + 'reset-email/code', { email: newEmailAddress.value }) + QueryGetAPI(ACCOUNT_API_URL() + 'reset-email/code', { email: newEmailAddress.value }) .then((data) => { if (data.code == 200) { message.success('发送成功, 请检查目标邮箱. 如果没有收到, 请检查垃圾邮件') @@ -86,7 +84,6 @@ function sendEmailVerifyCode() { } }) .catch((err) => { - console.error(err) message.error('发生错误') }) } @@ -95,7 +92,7 @@ async function resetPassword() { message.error('两次密码不一致') return } - await QueryGetAPI(ACCOUNT_API_URL + 'verify/reset-password', { password: newPassword.value }) + await QueryGetAPI(ACCOUNT_API_URL() + 'verify/reset-password', { password: newPassword.value }) .then(async (data) => { if (data.code == 200) { message.success('密码已修改') @@ -107,7 +104,6 @@ async function resetPassword() { } }) .catch((err) => { - console.error(err) message.error('发生错误') }) } @@ -122,7 +118,7 @@ async function BindBili() { uid: number uface: string room_id: number - }>(ACCOUNT_API_URL + 'bind-bili', { code: biliCode.value }, [['Turnstile', token.value]]) + }>(ACCOUNT_API_URL() + 'bind-bili', { code: biliCode.value }, [['Turnstile', token.value]]) .then(async (data) => { if (data.code == 200) { message.success('已绑定, 如无特殊情况请勿刷新身份码, 如果刷新了且还需要使用本站直播相关功能请更新身份码') @@ -134,7 +130,6 @@ async function BindBili() { } }) .catch((err) => { - console.error(err) message.error('发生错误') }) .finally(() => { @@ -153,7 +148,7 @@ async function ChangeBili() { uid: number uface: string room_id: number - }>(ACCOUNT_API_URL + 'change-bili', { code: biliCode.value }, [['Turnstile', token.value]]) + }>(ACCOUNT_API_URL() + 'change-bili', { code: biliCode.value }, [['Turnstile', token.value]]) .then(async (data) => { if (data.code == 200) { message.success('已更新身份码') @@ -165,7 +160,6 @@ async function ChangeBili() { } }) .catch((err) => { - console.error(err) message.error('发生错误') }) .finally(() => { diff --git a/src/views/manage/EventView.vue b/src/views/manage/EventView.vue index cfe02fa..961c90b 100644 --- a/src/views/manage/EventView.vue +++ b/src/views/manage/EventView.vue @@ -86,7 +86,7 @@ async function onDateChange() { } async function get() { try { - const data = await QueryGetAPI(BASE_API + 'event/get', { + const data = await QueryGetAPI(BASE_API() + 'event/get', { start: selectedDate.value[0], end: selectedDate.value[1], }) diff --git a/src/views/manage/HistoryView.vue b/src/views/manage/HistoryView.vue index 85ceb95..335317b 100644 --- a/src/views/manage/HistoryView.vue +++ b/src/views/manage/HistoryView.vue @@ -32,7 +32,7 @@ async function getFansHistory() { time: number count: number }[] - >(HISTORY_API_URL + 'fans') + >(HISTORY_API_URL() + 'fans') .then((data) => { if (data.code == 200) { fansHistory.value = data.data @@ -41,7 +41,6 @@ async function getFansHistory() { } }) .catch((err) => { - console.error(err) message.error('加载失败') }) } @@ -51,7 +50,7 @@ async function getGuardsHistory() { time: number count: number }[] - >(HISTORY_API_URL + 'guards') + >(HISTORY_API_URL() + 'guards') .then((data) => { if (data.code == 200) { guardHistory.value = data.data @@ -60,7 +59,6 @@ async function getGuardsHistory() { } }) .catch((err) => { - console.error(err) message.error('加载失败') }) } @@ -73,7 +71,7 @@ async function getUpstatHistory() { likes: number } }[] - >(HISTORY_API_URL + 'upstat') + >(HISTORY_API_URL() + 'upstat') .then((data) => { if (data.code == 200) { upstatHistory.value = data.data @@ -82,7 +80,6 @@ async function getUpstatHistory() { } }) .catch((err) => { - console.error(err) message.error('加载失败') }) } @@ -97,7 +94,6 @@ function getOptions() { time: Date count: number }[] = [] - let guards = [] as { time: number; count: number; timeString: string }[] if (fansHistory.value) { const startTime = new Date(fansHistory.value[0].time) @@ -143,14 +139,21 @@ function getOptions() { let lastDayGuards = 0 let lastDay = 0 + let guardsIncreacement = [] as { time: number; count: number; timeString: string }[] + let guards = [] as { time: number; count: number; timeString: string }[] guardHistory.value?.forEach((g) => { - if (!isSameDaySimple(g.time, lastDayGuards)) { - guards.push({ + if (!isSameDay(g.time, lastDay)) { + guardsIncreacement.push({ time: lastDayGuards, count: lastDay == 0 ? 0 : g.count - lastDayGuards, //将timeString转换为yyyy-MM-dd HH timeString: format(g.time, 'yyyy-MM-dd'), }) + guards.push({ + time: g.time, + count: g.count, + timeString: format(g.time, 'yyyy-MM-dd'), + }) lastDay = g.time lastDayGuards = g.count } @@ -238,7 +241,7 @@ function getOptions() { axisTick: { alignWithLabel: true, }, - boundaryGap: false, // 设置为false使得柱状图紧贴左右两侧 + //boundaryGap: chartData.dailyIncrements.length < 15, // 设置为false使得柱状图紧贴左右两侧 axisLine: { onZero: false, lineStyle: { @@ -292,6 +295,9 @@ function getOptions() { { type: 'value', }, + { + type: 'value', + }, ], xAxis: [ { @@ -306,7 +312,7 @@ function getOptions() { }, }, // prettier-ignore - data: guards.map((f) => f.timeString ), + data: guardsIncreacement.map((f) => f.timeString), }, ], series: [ @@ -319,6 +325,15 @@ function getOptions() { }, data: guards.map((f) => f.count), }, + { + name: '日增', + type: 'bar', + yAxisIndex: 1, + emphasis: { + focus: 'series', + }, + data: guardsIncreacement.map((f) => f.count), + }, ], dataZoom: [ { diff --git a/src/views/manage/LiveDetailManage.vue b/src/views/manage/LiveDetailManage.vue index 48bf9c8..ce8bb17 100644 --- a/src/views/manage/LiveDetailManage.vue +++ b/src/views/manage/LiveDetailManage.vue @@ -22,9 +22,9 @@ const liveInfo = ref(await get()) async function get() { try { - const data = await QueryGetAPI(LIVE_API_URL + 'get', { + const data = await QueryGetAPI(LIVE_API_URL() + 'get', { id: route.params.id, - useEmoji: true + useEmoji: true, }) if (data.code == 200) { return data.data @@ -33,7 +33,6 @@ async function get() { return undefined } } catch (err) { - console.error(err) message.error('无法获取数据') } return undefined diff --git a/src/views/manage/LiveManager.vue b/src/views/manage/LiveManager.vue index 0c4c05c..2b671bb 100644 --- a/src/views/manage/LiveManager.vue +++ b/src/views/manage/LiveManager.vue @@ -21,7 +21,7 @@ const defaultDanmakusCount = ref(0) async function getAll() { try { - const data = await QueryGetAPI(LIVE_API_URL + 'get-all') + const data = await QueryGetAPI(LIVE_API_URL() + 'get-all') if (data.code == 200) { return data.data } else { @@ -29,7 +29,6 @@ async function getAll() { return [] } } catch (err) { - console.error(err) message.error('无法获取数据') } return [] diff --git a/src/views/manage/LotteryView.vue b/src/views/manage/LotteryView.vue index a269574..18dd164 100644 --- a/src/views/manage/LotteryView.vue +++ b/src/views/manage/LotteryView.vue @@ -164,7 +164,6 @@ async function getCommentsUsers() { } }) .catch((err) => { - console.error(err) message.error('获取失败') }) .finally(() => { @@ -191,7 +190,6 @@ async function getForwardUsers() { } }) .catch((err) => { - console.error(err) message.error('获取失败') }) .finally(() => { @@ -249,7 +247,6 @@ function startLottery() { } } } catch (err) { - console.error(err) message.error('发生错误') } } diff --git a/src/views/manage/QuestionBoxManageView.vue b/src/views/manage/QuestionBoxManageView.vue index f6ab72b..64e8fb3 100644 --- a/src/views/manage/QuestionBoxManageView.vue +++ b/src/views/manage/QuestionBoxManageView.vue @@ -66,7 +66,7 @@ const shareUrl = computed(() => 'https://vtsuru.live/user/' + accountInfo.value? async function GetRecieveQAInfo() { isLoading.value = true - await QueryGetAPI(QUESTION_API_URL + 'get-recieve') + await QueryGetAPI(QUESTION_API_URL() + 'get-recieve') .then((data) => { if (data.code == 200) { if (data.data.length > 0) { @@ -84,7 +84,6 @@ async function GetRecieveQAInfo() { }) .catch((err) => { message.error('发生错误') - console.error(err) }) .finally(() => { isLoading.value = false @@ -92,7 +91,7 @@ async function GetRecieveQAInfo() { } async function GetSendQAInfo() { isLoading.value = true - await QueryGetAPI(QUESTION_API_URL + 'get-send') + await QueryGetAPI(QUESTION_API_URL() + 'get-send') .then((data) => { if (data.code == 200) { sendQuestions.value = data.data @@ -103,7 +102,6 @@ async function GetSendQAInfo() { }) .catch((err) => { message.error('发生错误') - console.error(err) }) .finally(() => { isLoading.value = false @@ -111,7 +109,7 @@ async function GetSendQAInfo() { } async function reply() { isRepling.value = true - await QueryPostAPI(QUESTION_API_URL + 'reply', { + await QueryPostAPI(QUESTION_API_URL() + 'reply', { Id: currentQuestion.value?.id, Message: replyMessage.value, }) @@ -129,7 +127,6 @@ async function reply() { } }) .catch((err) => { - console.error(err) message.error('发送失败') }) .finally(() => { @@ -137,7 +134,7 @@ async function reply() { }) } async function read(question: QAInfo, read: boolean) { - await QueryGetAPI(QUESTION_API_URL + 'read', { + await QueryGetAPI(QUESTION_API_URL() + 'read', { id: question.id, read: read ? 'true' : 'false', }) @@ -149,12 +146,11 @@ async function read(question: QAInfo, read: boolean) { } }) .catch((err) => { - console.error(err) message.error('修改失败') }) } async function favorite(question: QAInfo, fav: boolean) { - await QueryGetAPI(QUESTION_API_URL + 'favorite', { + await QueryGetAPI(QUESTION_API_URL() + 'favorite', { id: question.id, favorite: fav, }) @@ -166,13 +162,12 @@ async function favorite(question: QAInfo, fav: boolean) { } }) .catch((err) => { - console.error(err) message.error('修改失败') }) } async function setPublic(pub: boolean) { isChangingPublic.value = true - await QueryGetAPI(QUESTION_API_URL + 'public', { + await QueryGetAPI(QUESTION_API_URL() + 'public', { id: currentQuestion.value?.id, public: pub, }) @@ -185,7 +180,6 @@ async function setPublic(pub: boolean) { } }) .catch((err) => { - console.error(err) message.error('修改失败') }) .finally(() => { @@ -193,30 +187,25 @@ async function setPublic(pub: boolean) { }) } async function blacklist(question: QAInfo) { - await QueryGetAPI(ACCOUNT_API_URL + 'black-list/add', { + await QueryGetAPI(ACCOUNT_API_URL() + 'black-list/add', { id: question.sender.id, }) .then(async (data) => { if (data.code == 200) { - await QueryGetAPI(QUESTION_API_URL + 'del', { + await QueryGetAPI(QUESTION_API_URL() + 'del', { id: question.id, + }).then((data) => { + if (data.code == 200) { + message.success('已拉黑 ' + question.sender.name) + } else { + message.error('修改失败: ' + data.message) + } }) - .then((data) => { - if (data.code == 200) { - message.success('已拉黑 ' + question.sender.name) - } else { - message.error('修改失败: ' + data.message) - } - }) - .catch((err) => { - console.error(err) - }) } else { message.error('拉黑失败: ' + data.message) } }) .catch((err) => { - console.error(err) message.error('拉黑失败') }) } diff --git a/src/views/manage/ScheduleManageView.vue b/src/views/manage/ScheduleManageView.vue index c797095..4280867 100644 --- a/src/views/manage/ScheduleManageView.vue +++ b/src/views/manage/ScheduleManageView.vue @@ -119,7 +119,7 @@ const selectedScheduleWeek = ref(Number(format(Date.now(), 'w')) + 1) async function get() { isLoading.value = true - await QueryGetAPI(SCHEDULE_API_URL + 'get', { + await QueryGetAPI(SCHEDULE_API_URL() + 'get', { id: accountInfo.value?.id ?? -1, }) .then((data) => { @@ -130,7 +130,6 @@ async function get() { } }) .catch((err) => { - console.error(err) message.error('加载失败') }) .finally(() => (isLoading.value = false)) @@ -138,7 +137,7 @@ async function get() { const isFetching = ref(false) async function addSchedule() { isFetching.value = true - await QueryPostAPI(SCHEDULE_API_URL + 'update', { + await QueryPostAPI(SCHEDULE_API_URL() + 'update', { year: selectedScheduleYear.value, week: selectedScheduleWeek.value, }) @@ -167,7 +166,7 @@ async function onCopySchedule() { } async function onUpdateSchedule() { isFetching.value = true - await QueryPostAPI(SCHEDULE_API_URL + 'update', { + await QueryPostAPI(SCHEDULE_API_URL() + 'update', { year: updateScheduleModel.value.year, week: updateScheduleModel.value.week, day: selectedDay.value, @@ -192,7 +191,7 @@ async function onUpdateSchedule() { }) } async function onDeleteSchedule(schedule: ScheduleWeekInfo) { - await QueryGetAPI(SCHEDULE_API_URL + 'del', { + await QueryGetAPI(SCHEDULE_API_URL() + 'del', { year: schedule.year, week: schedule.week, }).then((data) => { diff --git a/src/views/manage/SettingsManageView.vue b/src/views/manage/SettingsManageView.vue index fa54d8e..a8467cc 100644 --- a/src/views/manage/SettingsManageView.vue +++ b/src/views/manage/SettingsManageView.vue @@ -199,9 +199,6 @@ async function RequestBiliUserData() { throw new Error('Bili User API Error: ' + data.message) } }) - .catch((err) => { - console.error(err) - }) } async function SaveComboGroupSetting(value: (string | number)[], meta: { actionType: 'check' | 'uncheck'; value: string | number }) { if (accountInfo.value) { @@ -219,7 +216,6 @@ async function SaveComboGroupSetting(value: (string | number)[], meta: { actionT } }) .catch((err) => { - console.error(err) message.error('修改失败') }) .finally(() => { @@ -240,7 +236,6 @@ async function SaveComboSetting() { } }) .catch((err) => { - console.error(err) message.error('修改失败') }) .finally(() => { diff --git a/src/views/manage/SongListManageView.vue b/src/views/manage/SongListManageView.vue index 440e735..3128c74 100644 --- a/src/views/manage/SongListManageView.vue +++ b/src/views/manage/SongListManageView.vue @@ -164,7 +164,6 @@ async function addCustomSong() { }) .catch((err) => { message.error('添加失败') - console.error(err) }) }) .finally(() => { @@ -190,7 +189,6 @@ async function addNeteaseSongs() { }) .catch((err) => { message.error('添加失败') - console.error(err) }) .finally(() => { isModalLoading.value = false @@ -205,7 +203,6 @@ async function addFingsingSongs(song: SongsInfo) { } catch (err) { isModalLoading.value = false message.error('添加失败') - console.error(err) return } } @@ -221,7 +218,6 @@ async function addFingsingSongs(song: SongsInfo) { }) .catch((err) => { message.error('添加失败') - console.error(err) }) .finally(() => { isModalLoading.value = false @@ -243,7 +239,7 @@ async function addSongs(songsShoudAdd: SongsInfo[], from: SongFrom) { async function getNeteaseSongList() { isModalLoading.value = true - await QueryGetAPI(SONG_API_URL + 'get-netease-list', { + await QueryGetAPI(SONG_API_URL() + 'get-netease-list', { id: neteaseSongListId.value, }) .then((data) => { @@ -260,7 +256,6 @@ async function getNeteaseSongList() { } }) .catch((err) => { - console.error(err) message.error('获取歌单失败: ' + err) }) .finally(() => { @@ -293,7 +288,6 @@ async function getFivesingSearchList(isRestart = false) { message.success(`成功获取搜索信息, 共 ${json.pageInfo.totalCount} 条, 当前第 ${fivesingCurrentPage.value} 页`) }) .catch((err) => { - console.error(err) message.error('获取歌单失败: ' + err) }) .finally(() => { @@ -316,7 +310,6 @@ async function playFivesingSong(song: SongsInfo) { song.url = data }) .catch((err) => { - console.error(err) message.error('获取歌曲链接失败: ' + err) }) .finally(() => { @@ -336,7 +329,7 @@ async function getFivesingSongUrl(song: SongsInfo): Promise { const isLoading = ref(true) async function getSongs() { isLoading.value = true - await QueryGetAPI(SONG_API_URL + 'get', { + await QueryGetAPI(SONG_API_URL() + 'get', { id: accountInfo.value?.id, }) .then((data) => { @@ -345,7 +338,6 @@ async function getSongs() { } }) .catch((err) => { - console.error(err) message.error('获取歌曲失败: ' + err) }) .finally(() => { diff --git a/src/views/manage/VideoCollectDetailView.vue b/src/views/manage/VideoCollectDetailView.vue index 5b40f39..e752592 100644 --- a/src/views/manage/VideoCollectDetailView.vue +++ b/src/views/manage/VideoCollectDetailView.vue @@ -108,7 +108,7 @@ const acceptVideos = computed(() => { async function getData() { try { - const data = await QueryGetAPI(VIDEO_COLLECT_API_URL + 'get', { id: route.params.id }) + const data = await QueryGetAPI(VIDEO_COLLECT_API_URL() + 'get', { id: route.params.id }) if (data.code == 200) { updateModel.value = { id: data.data.table.id, @@ -120,7 +120,6 @@ async function getData() { return data.data } } catch (err) { - console.error(err) message.error('获取失败') } return {} as VideoCollectDetail @@ -201,7 +200,7 @@ const rejectButtonGroup = (v: VideoInfo) => ]) function setStatus(status: VideoStatus, video: VideoInfo) { isLoading.value = true - QueryGetAPI(VIDEO_COLLECT_API_URL + 'set-status', { + QueryGetAPI(VIDEO_COLLECT_API_URL() + 'set-status', { id: videoDetail.value.table.id, bvid: video.bvid, status: status, @@ -215,7 +214,6 @@ function setStatus(status: VideoStatus, video: VideoInfo) { } }) .catch((err) => { - console.error(err) message.error('设置失败') }) .finally(() => { @@ -237,7 +235,7 @@ function dateDisabled(ts: number) { function updateTable() { isLoading.value = true updateModel.value.id = videoDetail.value.table.id - QueryPostAPI(VIDEO_COLLECT_API_URL + 'update', updateModel.value) + QueryPostAPI(VIDEO_COLLECT_API_URL() + 'update', updateModel.value) .then((data) => { if (data.code == 200) { message.success('更新成功') @@ -247,7 +245,6 @@ function updateTable() { } }) .catch((err) => { - console.error(err) message.error('更新失败') }) .finally(() => { @@ -256,7 +253,7 @@ function updateTable() { } function deleteTable() { isLoading.value = true - QueryGetAPI(VIDEO_COLLECT_API_URL + 'del', { + QueryGetAPI(VIDEO_COLLECT_API_URL() + 'del', { id: videoDetail.value.table.id, }) .then((data) => { @@ -270,7 +267,6 @@ function deleteTable() { } }) .catch((err) => { - console.error(err) message.error('删除失败') }) .finally(() => { @@ -279,7 +275,7 @@ function deleteTable() { } function closeTable() { isLoading.value = true - QueryGetAPI(VIDEO_COLLECT_API_URL + 'finish', { + QueryGetAPI(VIDEO_COLLECT_API_URL() + 'finish', { id: videoDetail.value.table.id, finish: !videoDetail.value.table.isFinish, }) @@ -292,7 +288,6 @@ function closeTable() { } }) .catch((err) => { - console.error(err) message.error('操作失败') }) .finally(() => { diff --git a/src/views/manage/VideoCollectManageView.vue b/src/views/manage/VideoCollectManageView.vue index 8b5e407..b88393e 100644 --- a/src/views/manage/VideoCollectManageView.vue +++ b/src/views/manage/VideoCollectManageView.vue @@ -94,7 +94,7 @@ const isLoading2 = ref(false) async function get() { try { isLoading.value = true - const data = await QueryGetAPI(VIDEO_COLLECT_API_URL + 'get-all') + const data = await QueryGetAPI(VIDEO_COLLECT_API_URL() + 'get-all') if (data.code == 200) { //videoTables.value = data.data return data.data @@ -103,7 +103,6 @@ async function get() { return [] } } catch (err) { - console.error(err) message.error('获取失败') return [] } finally { @@ -113,7 +112,7 @@ async function get() { function createTable() { formRef.value?.validate().then(async () => { isLoading2.value = true - QueryPostAPI(VIDEO_COLLECT_API_URL + 'create', createVideoModel.value) + QueryPostAPI(VIDEO_COLLECT_API_URL() + 'create', createVideoModel.value) .then((data) => { if (data.code == 200) { videoTables.value.push(data.data) @@ -125,7 +124,6 @@ function createTable() { } }) .catch((err) => { - console.error(err) message.error('创建失败') }) .finally(() => { diff --git a/src/views/obs/LiveLotteryOBS.vue b/src/views/obs/LiveLotteryOBS.vue index f5ee7b2..865326d 100644 --- a/src/views/obs/LiveLotteryOBS.vue +++ b/src/views/obs/LiveLotteryOBS.vue @@ -30,15 +30,13 @@ const isMoreThanContainer = computed(() => { async function getUsers() { try { - const data = await QueryGetAPI(LOTTERY_API_URL + 'live/get-users', { + const data = await QueryGetAPI(LOTTERY_API_URL() + 'live/get-users', { code: currentCode.value, }) if (data.code == 200) { return data.data } - } catch (err) { - console.error(err) - } + } catch (err) {} return { users: [], resultUsers: [], diff --git a/src/views/obs/QueueOBS.vue b/src/views/obs/QueueOBS.vue index 24ba28e..d20d002 100644 --- a/src/views/obs/QueueOBS.vue +++ b/src/views/obs/QueueOBS.vue @@ -54,15 +54,13 @@ const activeItems = computed(() => { async function get() { try { - const data = await QueryGetAPI<{ queue: ResponseQueueModel[]; setting: Setting_Queue }>(QUEUE_API_URL + 'get-active-and-settings', { + const data = await QueryGetAPI<{ queue: ResponseQueueModel[]; setting: Setting_Queue }>(QUEUE_API_URL() + 'get-active-and-settings', { id: currentId.value, }) if (data.code == 200) { return data.data } - } catch (err) { - console.error(err) - } + } catch (err) {} return {} as { queue: ResponseQueueModel[]; setting: Setting_Queue } } const isMoreThanContainer = computed(() => { @@ -119,7 +117,15 @@ onUnmounted(() => {
+ 在队列中时允许继续发送礼物累计付费量 (仅限上方设定的礼物) + 允许发送任意礼物来叠加付费量 冷却 (单位: 秒) 启用排队冷却 diff --git a/src/views/view/QuestionBoxView.vue b/src/views/view/QuestionBoxView.vue index fb67295..9985d1d 100644 --- a/src/views/view/QuestionBoxView.vue +++ b/src/views/view/QuestionBoxView.vue @@ -85,7 +85,6 @@ async function SendQuestion() { }) .catch((err) => { message.error('发送失败') - console.error(err) }) .finally(() => { isSending.value = false @@ -112,7 +111,7 @@ function OnFileListChange(files: UploadFileInfo[]) { } function getPublicQuestions() { isGetting.value = true - QueryGetAPI(QUESTION_API_URL + 'get-public', { + QueryGetAPI(QUESTION_API_URL() + 'get-public', { id: userInfo?.id, }) .then((data) => { @@ -124,7 +123,6 @@ function getPublicQuestions() { }) .catch((err) => { message.error('获取公开提问失败') - console.error(err) }) .finally(() => { isGetting.value = false diff --git a/src/views/view/ScheduleView.vue b/src/views/view/ScheduleView.vue index 63c473b..d89d5a9 100644 --- a/src/views/view/ScheduleView.vue +++ b/src/views/view/ScheduleView.vue @@ -30,7 +30,7 @@ const errMessage = ref('') async function get() { isLoading.value = true - await QueryGetAPI(SCHEDULE_API_URL + 'get', { + await QueryGetAPI(SCHEDULE_API_URL() + 'get', { id: props.userInfo?.id, }) .then((data) => { @@ -42,7 +42,6 @@ async function get() { } }) .catch((err) => { - console.error(err) message.error('加载失败') }) .finally(() => { diff --git a/src/views/view/SongListView.vue b/src/views/view/SongListView.vue index fc8eff8..d448711 100644 --- a/src/views/view/SongListView.vue +++ b/src/views/view/SongListView.vue @@ -45,20 +45,18 @@ const settings = ref({} as Setting_SongRequest) async function getSongRequestInfo() { try { - const data = await QueryGetAPI<{ songs: SongRequestInfo[]; setting: Setting_SongRequest }>(SONG_REQUEST_API_URL + 'get-active-and-settings', { + const data = await QueryGetAPI<{ songs: SongRequestInfo[]; setting: Setting_SongRequest }>(SONG_REQUEST_API_URL() + 'get-active-and-settings', { id: props.userInfo?.id, }) if (data.code == 200) { return data.data } - } catch (err) { - console.error(err) - } + } catch (err) {} return {} as { songs: SongRequestInfo[]; setting: Setting_SongRequest } } async function getSongs() { isLoading.value = true - await QueryGetAPI(SONG_API_URL + 'get', { + await QueryGetAPI(SONG_API_URL() + 'get', { id: props.userInfo?.id, }) .then((data) => { @@ -70,7 +68,6 @@ async function getSongs() { } }) .catch((err) => { - console.error(err) message.error('加载失败') }) .finally(() => { @@ -88,7 +85,7 @@ async function requestSong(song: SongsInfo) { } else { if (props.userInfo) { try { - const data = await QueryPostAPIWithParams(SONG_REQUEST_API_URL + 'add-from-web', { + const data = await QueryPostAPIWithParams(SONG_REQUEST_API_URL() + 'add-from-web', { target: props.userInfo?.id, song: song.key, }) @@ -117,7 +114,6 @@ onMounted(async () => { } }, 1000) } catch (err) { - console.error(err) message.error('加载失败') } } else {