update url

This commit is contained in:
2023-12-14 12:56:28 +08:00
parent 4ab1f6da4f
commit 82a0e72122
39 changed files with 299 additions and 350 deletions

View File

@@ -39,7 +39,7 @@ export async function GetSelfAccount() {
isLoadingAccount.value = false isLoadingAccount.value = false
} }
function refreshCookie() { function refreshCookie() {
QueryPostAPI<string>(`${ACCOUNT_API_URL}refresh-token`).then((data) => { QueryPostAPI<string>(`${ACCOUNT_API_URL()}refresh-token`).then((data) => {
if (data.code == 200) { if (data.code == 200) {
cookie.value = data.data cookie.value = data.data
cookieRefreshDate.value = Date.now() cookieRefreshDate.value = Date.now()
@@ -48,17 +48,17 @@ function refreshCookie() {
}) })
} }
export async function SaveAccountSettings() { 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[]) { 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() { export function useAccount() {
return ACCOUNT return ACCOUNT
} }
export async function Register(name: string, email: string, password: string, token: string): Promise<APIRoot<string>> { export async function Register(name: string, email: string, password: string, token: string): Promise<APIRoot<string>> {
return QueryPostAPI<string>(`${ACCOUNT_API_URL}register`, { return QueryPostAPI<string>(`${ACCOUNT_API_URL()}register`, {
name, name,
email, email,
password, 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<APIRoot<string>> { export async function Login(nameOrEmail: string, password: string): Promise<APIRoot<string>> {
return QueryPostAPI<string>(`${ACCOUNT_API_URL}login`, { return QueryPostAPI<string>(`${ACCOUNT_API_URL()}login`, {
nameOrEmail, nameOrEmail,
password, password,
}) })
} }
export async function Self(): Promise<APIRoot<AccountInfo>> { export async function Self(): Promise<APIRoot<AccountInfo>> {
return QueryPostAPI<AccountInfo>(`${ACCOUNT_API_URL}self`) return QueryPostAPI<AccountInfo>(`${ACCOUNT_API_URL()}self`)
} }

View File

@@ -1,48 +1,73 @@
/* eslint-disable indent */ /* eslint-disable indent */
import { useLocalStorage } from '@vueuse/core' import { useLocalStorage } from '@vueuse/core'
import { APIRoot, PaginationResponse } from './api-models' import { APIRoot, PaginationResponse } from './api-models'
import { Cookies20Regular } from '@vicons/fluent' import { apiFail } from '@/data/constants'
const cookie = useLocalStorage('JWT_Token', '') const cookie = useLocalStorage('JWT_Token', '')
let failCount = 0
export async function QueryPostAPI<T>(url: string, body?: unknown, headers?: [string, string][]): Promise<APIRoot<T>> { export async function QueryPostAPI<T>(urlString: string, body?: unknown, headers?: [string, string][]): Promise<APIRoot<T>> {
return await QueryPostAPIWithParams<T>(urlString, undefined, body, 'application/json', headers)
}
export async function QueryPostAPIWithParams<T>(urlString: string, params?: any, body?: any, contentType?: string, headers?: [string, string][]): Promise<APIRoot<T>> {
const url = new URL(urlString)
url.search = getParams(params)
headers ??= [] headers ??= []
if (cookie.value) headers?.push(['Authorization', `Bearer ${cookie.value}`]) headers?.push(['Authorization', `Bearer ${cookie.value}`])
headers?.push(['Content-Type', 'application/json'])
if (contentType) headers?.push(['Content-Type', contentType])
try {
const data = await fetch(url, { const data = await fetch(url, {
method: 'post', method: 'post',
headers: headers, headers: headers,
body: typeof body === 'string' ? body : JSON.stringify(body), body: typeof body === 'string' ? body : JSON.stringify(body),
}) // 不处理异常, 在页面处理 })
return (await data.json()) as APIRoot<T> const result = (await data.json()) as APIRoot<T>
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 QueryPostAPIWithParams<T>(urlString: string, params?: any, body?: any, contentType?: string, headers?: [string, string][]): Promise<APIRoot<T>> {
const url = new URL(urlString)
url.search = new URLSearchParams(params).toString()
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<T>
} }
export async function QueryGetAPI<T>(urlString: string, params?: any, headers?: [string, string][]): Promise<APIRoot<T>> { export async function QueryGetAPI<T>(urlString: string, params?: any, headers?: [string, string][]): Promise<APIRoot<T>> {
const url = new URL(urlString) const url = new URL(urlString)
url.search = new URLSearchParams(params).toString() url.search = getParams(params)
if (cookie.value) { if (cookie.value) {
headers ??= [] headers ??= []
headers?.push(['Authorization', `Bearer ${cookie.value}`]) headers?.push(['Authorization', `Bearer ${cookie.value}`])
} }
try {
const data = await fetch(url.toString(), { const data = await fetch(url.toString(), {
method: 'get', method: 'get',
headers: headers, headers: headers,
}) // 不处理异常, 在页面处理 })
return (await data.json()) as APIRoot<T> const result = (await data.json()) as APIRoot<T>
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<T>(url: string, body?: unknown): Promise<APIRoot<PaginationResponse<T>>> { export async function QueryPostPaginationAPI<T>(url: string, body?: unknown): Promise<APIRoot<PaginationResponse<T>>> {
return await QueryPostAPI<PaginationResponse<T>>(url, body) return await QueryPostAPI<PaginationResponse<T>>(url, body)

View File

@@ -1,5 +1,5 @@
import { QueryGetAPI } from '@/api/query' 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 { APIRoot, UserInfo } from './api-models'
import { ref } from 'vue' import { ref } from 'vue'
import { useRouteParams } from '@vueuse/router' import { useRouteParams } from '@vueuse/router'
@@ -12,7 +12,13 @@ export async function useUser(id: string | undefined = undefined) {
id ??= route.params.id.toString() id ??= route.params.id.toString()
if (id) { if (id) {
if (!USERS.value[id]) { if (!USERS.value[id]) {
const result = await GetInfo(id) let result: APIRoot<UserInfo>
try {
result = await GetInfo(id)
} catch {
apiFail.value = true
result = await GetInfo(id)
}
if (result.code == 200) { if (result.code == 200) {
USERS.value[id] = result.data USERS.value[id] = result.data
} }
@@ -24,7 +30,7 @@ export async function useUser(id: string | undefined = undefined) {
} }
export async function useUserWithUId(id: number) { export async function useUserWithUId(id: number) {
if (!USERS.value[id.toString()]) { if (!USERS.value[id.toString()]) {
const result = await QueryGetAPI<UserInfo>(`${USER_API_URL}info`, { const result = await QueryGetAPI<UserInfo>(`${USER_API_URL()}info`, {
uId: id, uId: id,
}) })
if (result.code == 200) { if (result.code == 200) {
@@ -35,7 +41,7 @@ export async function useUserWithUId(id: number) {
} }
export async function GetInfo(id: string): Promise<APIRoot<UserInfo>> { export async function GetInfo(id: string): Promise<APIRoot<UserInfo>> {
return QueryGetAPI<UserInfo>(`${USER_API_URL}info`, { return QueryGetAPI<UserInfo>(`${USER_API_URL()}info`, {
id: id, id: id,
}) })
} }

View File

@@ -143,9 +143,6 @@ function onRegisterButtonClick() {
message.error(data.message) message.error(data.message)
} }
}) })
.catch((err) => {
console.error(err)
})
.finally(() => { .finally(() => {
isLoading.value = false isLoading.value = false
turnstile.value?.reset() turnstile.value?.reset()
@@ -158,7 +155,7 @@ function onLoginButtonClick() {
await QueryPostAPI<{ await QueryPostAPI<{
account: AccountInfo account: AccountInfo
token: string token: string
}>(ACCOUNT_API_URL + 'login', { }>(ACCOUNT_API_URL() + 'login', {
nameOrEmail: loginModel.value.account, nameOrEmail: loginModel.value.account,
password: loginModel.value.password, password: loginModel.value.password,
}) })
@@ -174,7 +171,6 @@ function onLoginButtonClick() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('登陆失败') message.error('登陆失败')
}) })
.finally(() => { .finally(() => {
@@ -184,7 +180,7 @@ function onLoginButtonClick() {
} }
async function onForgetPassword() { async function onForgetPassword() {
canSendForgetPassword.value = false 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) => { .then(async (data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已发送密码重置链接到你的邮箱, 请检查') message.success('已发送密码重置链接到你的邮箱, 请检查')
@@ -193,7 +189,6 @@ async function onForgetPassword() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发生错误') message.error('发生错误')
}) })
.finally(() => { .finally(() => {

View File

@@ -393,7 +393,7 @@ function renderCell(value: string | number) {
} }
async function updateSong() { async function updateSong() {
await QueryPostAPI<SongsInfo>(SONG_API_URL + 'update', { await QueryPostAPI<SongsInfo>(SONG_API_URL() + 'update', {
key: updateSongModel.value.key, key: updateSongModel.value.key,
song: updateSongModel.value, song: updateSongModel.value,
}).then((data) => { }).then((data) => {
@@ -407,7 +407,7 @@ async function updateSong() {
}) })
} }
async function delSong(song: SongsInfo) { async function delSong(song: SongsInfo) {
await QueryGetAPI<SongsInfo>(SONG_API_URL + 'del', { await QueryGetAPI<SongsInfo>(SONG_API_URL() + 'del', {
key: song.key, key: song.key,
}).then((data) => { }).then((data) => {
if (data.code == 200) { if (data.code == 200) {

View File

@@ -43,7 +43,7 @@ function OnPlayMusic(song: SongsInfo) {
} }
async function GetLyric(song: SongsInfo) { async function GetLyric(song: SongsInfo) {
emits('update:isLrcLoading', song.key) 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) => { .then((data) => {
console.log(mergeLyrics(data.data.lyric, data.data.tlyric)) console.log(mergeLyrics(data.data.lyric, data.data.tlyric))
if (data.code == 200) { if (data.code == 200) {
@@ -67,9 +67,6 @@ async function GetLyric(song: SongsInfo) {
} }
} }
}) })
.catch((err) => {
console.error(err)
})
.finally(() => { .finally(() => {
emits('update:isLrcLoading', undefined) emits('update:isLrcLoading', undefined)
}) })

View File

@@ -197,10 +197,10 @@ export default class DanmakuClient {
} }
private sendHeartbeat() { private sendHeartbeat() {
if (this.client) { if (this.client) {
const query = this.authInfo ? QueryPostAPI<OpenLiveInfo>(OPEN_LIVE_API_URL + 'heartbeat', this.authInfo) : QueryGetAPI<OpenLiveInfo>(OPEN_LIVE_API_URL + 'heartbeat-internal') const query = this.authInfo ? QueryPostAPI<OpenLiveInfo>(OPEN_LIVE_API_URL() + 'heartbeat', this.authInfo) : QueryGetAPI<OpenLiveInfo>(OPEN_LIVE_API_URL() + 'heartbeat-internal')
query.then((data) => { query.then((data) => {
if (data.code != 200) { if (data.code != 200) {
console.error('[OPEN-LIVE] 心跳失败: ' + data.message) console.error('[OPEN-LIVE] 心跳失败')
this.client.stop() this.client.stop()
this.client = null this.client = null
this.initClient() this.initClient()
@@ -267,7 +267,7 @@ export default class DanmakuClient {
} }
private async getAuthInfo(): Promise<{ data: OpenLiveInfo | null; message: string }> { private async getAuthInfo(): Promise<{ data: OpenLiveInfo | null; message: string }> {
try { try {
const data = await QueryPostAPI<OpenLiveInfo>(OPEN_LIVE_API_URL + 'start', this.authInfo?.Code ? this.authInfo : undefined) const data = await QueryPostAPI<OpenLiveInfo>(OPEN_LIVE_API_URL() + 'start', this.authInfo?.Code ? this.authInfo : undefined)
if (data.code == 200) { if (data.code == 200) {
console.log('[OPEN-LIVE] 已获取场次信息') console.log('[OPEN-LIVE] 已获取场次信息')
return { return {
@@ -275,15 +275,12 @@ export default class DanmakuClient {
message: '', message: '',
} }
} else { } else {
console.error('无法获取场次数据: ' + data.message)
return { return {
data: null, data: null,
message: data.message, message: data.message,
} }
} }
} catch (err) { } catch (err) {
console.error(err)
return { return {
data: null, data: null,
message: err?.toString() || '未知错误', message: err?.toString() || '未知错误',

View File

@@ -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 debugAPI = import.meta.env.VITE_DEBUG_API
const releseAPI = `https://vtsuru.suki.club/api/` const releseAPI = `https://vtsuru.suki.club/api/`
const failoverAPI = `https://failover-api.vtsuru.live/api/`
export const isBackendUsable = ref(true) export const isBackendUsable = ref(true)
export const AVATAR_URL = 'https://workers.vrp.moe/api/bilibili/avatar/' 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 FETCH_API = 'https://fetch.vtsuru.live/'
export const TURNSTILE_KEY = '0x4AAAAAAAETUSAKbds019h0' export const TURNSTILE_KEY = '0x4AAAAAAAETUSAKbds019h0'
export const USER_API_URL = `${BASE_API}user/` export const USER_API_URL = () => `${BASE_API()}user/`
export const ACCOUNT_API_URL = `${BASE_API}account/` export const ACCOUNT_API_URL = () => `${BASE_API()}account/`
export const BILI_API_URL = `${BASE_API}bili/` export const BILI_API_URL = () => `${BASE_API()}bili/`
export const SONG_API_URL = `${BASE_API}song-list/` export const SONG_API_URL = () => `${BASE_API()}song-list/`
export const NOTIFACTION_API_URL = `${BASE_API}notifaction/` export const NOTIFACTION_API_URL = () => `${BASE_API()}notifaction/`
export const QUESTION_API_URL = `${BASE_API}qa/` export const QUESTION_API_URL = () => `${BASE_API()}qa/`
export const LOTTERY_API_URL = `${BASE_API}lottery/` export const LOTTERY_API_URL = () => `${BASE_API()}lottery/`
export const HISTORY_API_URL = `${BASE_API}history/` export const HISTORY_API_URL = () => `${BASE_API()}history/`
export const SCHEDULE_API_URL = `${BASE_API}schedule/` export const SCHEDULE_API_URL = () => `${BASE_API()}schedule/`
export const VIDEO_COLLECT_API_URL = `${BASE_API}video-collect/` export const VIDEO_COLLECT_API_URL = () => `${BASE_API()}video-collect/`
export const OPEN_LIVE_API_URL = `${BASE_API}open-live/` export const OPEN_LIVE_API_URL = () => `${BASE_API()}open-live/`
export const SONG_REQUEST_API_URL = `${BASE_API}song-request/` export const SONG_REQUEST_API_URL = () => `${BASE_API()}song-request/`
export const QUEUE_API_URL = `${BASE_API}queue/` export const QUEUE_API_URL = () => `${BASE_API()}queue/`
export const EVENT_API_URL = `${BASE_API}event/` export const EVENT_API_URL = () => `${BASE_API()}event/`
export const LIVE_API_URL = `${BASE_API}live/` export const LIVE_API_URL = () => `${BASE_API()}live/`
export const FEEDBACK_API_URL = `${BASE_API}feedback/` export const FEEDBACK_API_URL = () => `${BASE_API()}feedback/`
export const ScheduleTemplateMap = { export const ScheduleTemplateMap = {
'': { name: '默认', compoent: defineAsyncComponent(() => import('@/views/view/scheduleTemplate/DefaultScheduleTemplate.vue')) }, '': { name: '默认', compoent: defineAsyncComponent(() => import('@/views/view/scheduleTemplate/DefaultScheduleTemplate.vue')) },

View File

@@ -10,7 +10,7 @@ const n = ref<NotifactionInfo>()
let isLoading = false let isLoading = false
function get() { function get() {
if (isLoading) return if (isLoading) return
QueryGetAPI<NotifactionInfo>(SONG_REQUEST_API_URL + 'get-active') QueryGetAPI<NotifactionInfo>(SONG_REQUEST_API_URL() + 'get-active')
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
n.value = data.data n.value = data.data

View File

@@ -1,5 +1,5 @@
import { QueryGetAPI } from '@/api/query' import { QueryGetAPI } from '@/api/query'
import { BASE_API } from '@/data/constants' import { BASE_API, apiFail } from '@/data/constants'
import { createApp, h } from 'vue' import { createApp, h } from 'vue'
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
@@ -9,11 +9,10 @@ import { NText, createDiscreteApi } from 'naive-ui'
createApp(App).use(router).mount('#app') createApp(App).use(router).mount('#app')
GetSelfAccount()
GetNotifactions()
let currentVersion: string let currentVersion: string
const { notification } = createDiscreteApi(['notification']) const { notification } = createDiscreteApi(['notification'])
QueryGetAPI<string>(BASE_API + 'vtsuru/version').then((version) => { QueryGetAPI<string>(BASE_API() + 'vtsuru/version')
.then((version) => {
if (version.code == 200) { if (version.code == 200) {
currentVersion = version.data currentVersion = version.data
const savedVersion = localStorage.getItem('Version') const savedVersion = localStorage.getItem('Version')
@@ -31,3 +30,12 @@ QueryGetAPI<string>(BASE_API + 'vtsuru/version').then((version) => {
localStorage.setItem('Version', currentVersion) localStorage.setItem('Version', currentVersion)
} }
}) })
.catch(() => {
apiFail.value = true
console.log('默认API调用失败, 切换至故障转移节点')
})
.finally(() => {
//加载其他数据
GetSelfAccount()
GetNotifactions()
})

View File

@@ -21,7 +21,7 @@ function changePassword() {
return return
} }
isLoading.value = true isLoading.value = true
QueryGetAPI(ACCOUNT_API_URL + 'verify/reset-password', { QueryGetAPI(ACCOUNT_API_URL() + 'verify/reset-password', {
key: key.value, key: key.value,
password: password.value, password: password.value,
}) })
@@ -34,7 +34,6 @@ function changePassword() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发生错误') message.error('发生错误')
}) })
.finally(() => { .finally(() => {

View File

@@ -43,7 +43,7 @@ const newFeedback = ref<FeedbackModel>({
async function get() { async function get() {
try { try {
const data = await QueryGetAPI<ResponseFeedbackModel[]>(FEEDBACK_API_URL + 'get') const data = await QueryGetAPI<ResponseFeedbackModel[]>(FEEDBACK_API_URL() + 'get')
if (data.code == 200) { if (data.code == 200) {
return new List(data.data).OrderByDescending((s) => s.createAt).ToArray() return new List(data.data).OrderByDescending((s) => s.createAt).ToArray()
} else { } else {
@@ -51,7 +51,6 @@ async function get() {
return [] return []
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('无法获取数据') message.error('无法获取数据')
} }
return [] return []
@@ -61,7 +60,7 @@ async function add() {
message.error('反馈内容不能为空') message.error('反馈内容不能为空')
return return
} }
await QueryPostAPI<ResponseFeedbackModel>(FEEDBACK_API_URL + 'add', newFeedback.value) await QueryPostAPI<ResponseFeedbackModel>(FEEDBACK_API_URL() + 'add', newFeedback.value)
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('发送成功, 感谢你的反馈!') message.success('发送成功, 感谢你的反馈!')
@@ -73,7 +72,6 @@ async function add() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发送失败') message.error('发送失败')
}) })
} }

View File

@@ -285,7 +285,7 @@ const menuOptions = [
] ]
async function resendEmail() { async function resendEmail() {
await QueryGetAPI(ACCOUNT_API_URL + 'send-verify-email') await QueryGetAPI(ACCOUNT_API_URL() + 'send-verify-email')
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
canResendEmail.value = false canResendEmail.value = false
@@ -296,7 +296,6 @@ async function resendEmail() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发送失败') message.error('发送失败')
}) })
} }

View File

@@ -15,7 +15,7 @@ const isLoading = ref(false)
async function VerifyAccount() { async function VerifyAccount() {
isLoading.value = true isLoading.value = true
await QueryGetAPI<AccountInfo>(ACCOUNT_API_URL + 'verify', { await QueryGetAPI<AccountInfo>(ACCOUNT_API_URL() + 'verify', {
target: route.query.target, target: route.query.target,
}) })
.then((data) => { .then((data) => {

View File

@@ -33,12 +33,11 @@ const totalTime = computed(() => {
async function get() { async function get() {
try { try {
const data = await QueryGetAPI<VideoCollectDetail>(VIDEO_COLLECT_API_URL + 'get', { id: route.params.id }) const data = await QueryGetAPI<VideoCollectDetail>(VIDEO_COLLECT_API_URL() + 'get', { id: route.params.id })
if (data.code == 200) { if (data.code == 200) {
return data.data return data.data
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('获取失败') message.error('获取失败')
} }
return null return null
@@ -117,9 +116,7 @@ function formatSecondsToTime(seconds: number): string {
<NDivider vertical /> <NDivider vertical />
已观看 {{ watchedVideos.length }} 已观看 {{ watchedVideos.length }}
</NDivider> </NDivider>
<NAlert v-if="watchedVideos.length == acceptVideos?.length" type="success"> <NAlert v-if="watchedVideos.length == acceptVideos?.length" type="success"> 已观看全部视频 </NAlert>
已观看全部视频
</NAlert>
<NList ref="card"> <NList ref="card">
<NListItem v-for="item in acceptVideos" v-bind:key="item.info.bvid"> <NListItem v-for="item in acceptVideos" v-bind:key="item.info.bvid">
<NCard size="small" :hoverable="!item.video.watched" :embedded="!item.video.watched"> <NCard size="small" :hoverable="!item.video.watched" :embedded="!item.video.watched">

View File

@@ -28,12 +28,11 @@ const isLoading = ref(false)
async function get() { async function get() {
try { try {
const data = await QueryGetAPI<VideoCollectDetail>(VIDEO_COLLECT_API_URL + 'get', { id: route.params.id }) const data = await QueryGetAPI<VideoCollectDetail>(VIDEO_COLLECT_API_URL() + 'get', { id: route.params.id })
if (data.code == 200) { if (data.code == 200) {
return data.data.table return data.data.table
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('获取失败') message.error('获取失败')
} }
return null return null
@@ -45,7 +44,7 @@ async function add() {
} }
isLoading.value = true isLoading.value = true
addModel.value.id = table.value?.id ?? route.params.id.toString() 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) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已成功推荐视频') message.success('已成功推荐视频')
@@ -57,7 +56,6 @@ async function add() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('添加失败') message.error('添加失败')
}) })
.finally(() => { .finally(() => {

View File

@@ -63,9 +63,6 @@ async function RequestBiliUserData() {
throw new Error('Bili User API Error: ' + data.message) throw new Error('Bili User API Error: ' + data.message)
} }
}) })
.catch((err) => {
console.error(err)
})
} }
onMounted(async () => { onMounted(async () => {

View File

@@ -18,7 +18,7 @@ const roomId = ref()
const timer = ref() const timer = ref()
function onStartVerify() { function onStartVerify() {
QueryGetAPI(BILI_API_URL + 'verify', { QueryGetAPI(BILI_API_URL() + 'verify', {
uId: uId.value, uId: uId.value,
}).then((data) => { }).then((data) => {
if (data.code == 200) { if (data.code == 200) {
@@ -34,7 +34,7 @@ async function checkStatus() {
uId: number uId: number
roomId: number roomId: number
endTime: number endTime: number
}>(BILI_API_URL + 'status') }>(BILI_API_URL() + 'status')
if (data.code == 200) { if (data.code == 200) {
//正在进行认证 //正在进行认证
roomId.value ??= data.data.roomId roomId.value ??= data.data.roomId

View File

@@ -38,7 +38,7 @@ function logout() {
} }
function resetBili() { function resetBili() {
isLoading.value = true isLoading.value = true
QueryGetAPI(ACCOUNT_API_URL + 'reset-bili') QueryGetAPI(ACCOUNT_API_URL() + 'reset-bili')
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已解绑 Bilibili 账号') message.success('已解绑 Bilibili 账号')
@@ -50,13 +50,12 @@ function resetBili() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发生错误') message.error('发生错误')
}) })
} }
function resetEmail() { function resetEmail() {
isLoading.value = true 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) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已将邮箱改绑为 ' + newEmailAddress.value) message.success('已将邮箱改绑为 ' + newEmailAddress.value)
@@ -68,12 +67,11 @@ function resetEmail() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发生错误') message.error('发生错误')
}) })
} }
function sendEmailVerifyCode() { function sendEmailVerifyCode() {
QueryGetAPI(ACCOUNT_API_URL + 'reset-email/code', { email: newEmailAddress.value }) QueryGetAPI(ACCOUNT_API_URL() + 'reset-email/code', { email: newEmailAddress.value })
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('发送成功, 请检查目标邮箱. 如果没有收到, 请检查垃圾邮件') message.success('发送成功, 请检查目标邮箱. 如果没有收到, 请检查垃圾邮件')
@@ -86,7 +84,6 @@ function sendEmailVerifyCode() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发生错误') message.error('发生错误')
}) })
} }
@@ -95,7 +92,7 @@ async function resetPassword() {
message.error('两次密码不一致') message.error('两次密码不一致')
return 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) => { .then(async (data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('密码已修改') message.success('密码已修改')
@@ -107,7 +104,6 @@ async function resetPassword() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发生错误') message.error('发生错误')
}) })
} }
@@ -122,7 +118,7 @@ async function BindBili() {
uid: number uid: number
uface: string uface: string
room_id: number 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) => { .then(async (data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已绑定, 如无特殊情况请勿刷新身份码, 如果刷新了且还需要使用本站直播相关功能请更新身份码') message.success('已绑定, 如无特殊情况请勿刷新身份码, 如果刷新了且还需要使用本站直播相关功能请更新身份码')
@@ -134,7 +130,6 @@ async function BindBili() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发生错误') message.error('发生错误')
}) })
.finally(() => { .finally(() => {
@@ -153,7 +148,7 @@ async function ChangeBili() {
uid: number uid: number
uface: string uface: string
room_id: number 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) => { .then(async (data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已更新身份码') message.success('已更新身份码')
@@ -165,7 +160,6 @@ async function ChangeBili() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发生错误') message.error('发生错误')
}) })
.finally(() => { .finally(() => {

View File

@@ -86,7 +86,7 @@ async function onDateChange() {
} }
async function get() { async function get() {
try { try {
const data = await QueryGetAPI<EventModel[]>(BASE_API + 'event/get', { const data = await QueryGetAPI<EventModel[]>(BASE_API() + 'event/get', {
start: selectedDate.value[0], start: selectedDate.value[0],
end: selectedDate.value[1], end: selectedDate.value[1],
}) })

View File

@@ -32,7 +32,7 @@ async function getFansHistory() {
time: number time: number
count: number count: number
}[] }[]
>(HISTORY_API_URL + 'fans') >(HISTORY_API_URL() + 'fans')
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
fansHistory.value = data.data fansHistory.value = data.data
@@ -41,7 +41,6 @@ async function getFansHistory() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('加载失败') message.error('加载失败')
}) })
} }
@@ -51,7 +50,7 @@ async function getGuardsHistory() {
time: number time: number
count: number count: number
}[] }[]
>(HISTORY_API_URL + 'guards') >(HISTORY_API_URL() + 'guards')
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
guardHistory.value = data.data guardHistory.value = data.data
@@ -60,7 +59,6 @@ async function getGuardsHistory() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('加载失败') message.error('加载失败')
}) })
} }
@@ -73,7 +71,7 @@ async function getUpstatHistory() {
likes: number likes: number
} }
}[] }[]
>(HISTORY_API_URL + 'upstat') >(HISTORY_API_URL() + 'upstat')
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
upstatHistory.value = data.data upstatHistory.value = data.data
@@ -82,7 +80,6 @@ async function getUpstatHistory() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('加载失败') message.error('加载失败')
}) })
} }
@@ -97,7 +94,6 @@ function getOptions() {
time: Date time: Date
count: number count: number
}[] = [] }[] = []
let guards = [] as { time: number; count: number; timeString: string }[]
if (fansHistory.value) { if (fansHistory.value) {
const startTime = new Date(fansHistory.value[0].time) const startTime = new Date(fansHistory.value[0].time)
@@ -143,14 +139,21 @@ function getOptions() {
let lastDayGuards = 0 let lastDayGuards = 0
let lastDay = 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) => { guardHistory.value?.forEach((g) => {
if (!isSameDaySimple(g.time, lastDayGuards)) { if (!isSameDay(g.time, lastDay)) {
guards.push({ guardsIncreacement.push({
time: lastDayGuards, time: lastDayGuards,
count: lastDay == 0 ? 0 : g.count - lastDayGuards, count: lastDay == 0 ? 0 : g.count - lastDayGuards,
//将timeString转换为yyyy-MM-dd HH //将timeString转换为yyyy-MM-dd HH
timeString: format(g.time, 'yyyy-MM-dd'), 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 lastDay = g.time
lastDayGuards = g.count lastDayGuards = g.count
} }
@@ -238,7 +241,7 @@ function getOptions() {
axisTick: { axisTick: {
alignWithLabel: true, alignWithLabel: true,
}, },
boundaryGap: false, // 设置为false使得柱状图紧贴左右两侧 //boundaryGap: chartData.dailyIncrements.length < 15, // 设置为false使得柱状图紧贴左右两侧
axisLine: { axisLine: {
onZero: false, onZero: false,
lineStyle: { lineStyle: {
@@ -292,6 +295,9 @@ function getOptions() {
{ {
type: 'value', type: 'value',
}, },
{
type: 'value',
},
], ],
xAxis: [ xAxis: [
{ {
@@ -306,7 +312,7 @@ function getOptions() {
}, },
}, },
// prettier-ignore // prettier-ignore
data: guards.map((f) => f.timeString ), data: guardsIncreacement.map((f) => f.timeString),
}, },
], ],
series: [ series: [
@@ -319,6 +325,15 @@ function getOptions() {
}, },
data: guards.map((f) => f.count), data: guards.map((f) => f.count),
}, },
{
name: '日增',
type: 'bar',
yAxisIndex: 1,
emphasis: {
focus: 'series',
},
data: guardsIncreacement.map((f) => f.count),
},
], ],
dataZoom: [ dataZoom: [
{ {

View File

@@ -22,9 +22,9 @@ const liveInfo = ref<ResponseLiveDetail | undefined>(await get())
async function get() { async function get() {
try { try {
const data = await QueryGetAPI<ResponseLiveDetail>(LIVE_API_URL + 'get', { const data = await QueryGetAPI<ResponseLiveDetail>(LIVE_API_URL() + 'get', {
id: route.params.id, id: route.params.id,
useEmoji: true useEmoji: true,
}) })
if (data.code == 200) { if (data.code == 200) {
return data.data return data.data
@@ -33,7 +33,6 @@ async function get() {
return undefined return undefined
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('无法获取数据') message.error('无法获取数据')
} }
return undefined return undefined

View File

@@ -21,7 +21,7 @@ const defaultDanmakusCount = ref(0)
async function getAll() { async function getAll() {
try { try {
const data = await QueryGetAPI<ResponseLiveInfoModel[]>(LIVE_API_URL + 'get-all') const data = await QueryGetAPI<ResponseLiveInfoModel[]>(LIVE_API_URL() + 'get-all')
if (data.code == 200) { if (data.code == 200) {
return data.data return data.data
} else { } else {
@@ -29,7 +29,6 @@ async function getAll() {
return [] return []
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('无法获取数据') message.error('无法获取数据')
} }
return [] return []

View File

@@ -164,7 +164,6 @@ async function getCommentsUsers() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('获取失败') message.error('获取失败')
}) })
.finally(() => { .finally(() => {
@@ -191,7 +190,6 @@ async function getForwardUsers() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('获取失败') message.error('获取失败')
}) })
.finally(() => { .finally(() => {
@@ -249,7 +247,6 @@ function startLottery() {
} }
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('发生错误') message.error('发生错误')
} }
} }

View File

@@ -66,7 +66,7 @@ const shareUrl = computed(() => 'https://vtsuru.live/user/' + accountInfo.value?
async function GetRecieveQAInfo() { async function GetRecieveQAInfo() {
isLoading.value = true isLoading.value = true
await QueryGetAPI<QAInfo[]>(QUESTION_API_URL + 'get-recieve') await QueryGetAPI<QAInfo[]>(QUESTION_API_URL() + 'get-recieve')
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
if (data.data.length > 0) { if (data.data.length > 0) {
@@ -84,7 +84,6 @@ async function GetRecieveQAInfo() {
}) })
.catch((err) => { .catch((err) => {
message.error('发生错误') message.error('发生错误')
console.error(err)
}) })
.finally(() => { .finally(() => {
isLoading.value = false isLoading.value = false
@@ -92,7 +91,7 @@ async function GetRecieveQAInfo() {
} }
async function GetSendQAInfo() { async function GetSendQAInfo() {
isLoading.value = true isLoading.value = true
await QueryGetAPI<QAInfo[]>(QUESTION_API_URL + 'get-send') await QueryGetAPI<QAInfo[]>(QUESTION_API_URL() + 'get-send')
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
sendQuestions.value = data.data sendQuestions.value = data.data
@@ -103,7 +102,6 @@ async function GetSendQAInfo() {
}) })
.catch((err) => { .catch((err) => {
message.error('发生错误') message.error('发生错误')
console.error(err)
}) })
.finally(() => { .finally(() => {
isLoading.value = false isLoading.value = false
@@ -111,7 +109,7 @@ async function GetSendQAInfo() {
} }
async function reply() { async function reply() {
isRepling.value = true isRepling.value = true
await QueryPostAPI<QAInfo>(QUESTION_API_URL + 'reply', { await QueryPostAPI<QAInfo>(QUESTION_API_URL() + 'reply', {
Id: currentQuestion.value?.id, Id: currentQuestion.value?.id,
Message: replyMessage.value, Message: replyMessage.value,
}) })
@@ -129,7 +127,6 @@ async function reply() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('发送失败') message.error('发送失败')
}) })
.finally(() => { .finally(() => {
@@ -137,7 +134,7 @@ async function reply() {
}) })
} }
async function read(question: QAInfo, read: boolean) { async function read(question: QAInfo, read: boolean) {
await QueryGetAPI(QUESTION_API_URL + 'read', { await QueryGetAPI(QUESTION_API_URL() + 'read', {
id: question.id, id: question.id,
read: read ? 'true' : 'false', read: read ? 'true' : 'false',
}) })
@@ -149,12 +146,11 @@ async function read(question: QAInfo, read: boolean) {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('修改失败') message.error('修改失败')
}) })
} }
async function favorite(question: QAInfo, fav: boolean) { async function favorite(question: QAInfo, fav: boolean) {
await QueryGetAPI(QUESTION_API_URL + 'favorite', { await QueryGetAPI(QUESTION_API_URL() + 'favorite', {
id: question.id, id: question.id,
favorite: fav, favorite: fav,
}) })
@@ -166,13 +162,12 @@ async function favorite(question: QAInfo, fav: boolean) {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('修改失败') message.error('修改失败')
}) })
} }
async function setPublic(pub: boolean) { async function setPublic(pub: boolean) {
isChangingPublic.value = true isChangingPublic.value = true
await QueryGetAPI(QUESTION_API_URL + 'public', { await QueryGetAPI(QUESTION_API_URL() + 'public', {
id: currentQuestion.value?.id, id: currentQuestion.value?.id,
public: pub, public: pub,
}) })
@@ -185,7 +180,6 @@ async function setPublic(pub: boolean) {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('修改失败') message.error('修改失败')
}) })
.finally(() => { .finally(() => {
@@ -193,30 +187,25 @@ async function setPublic(pub: boolean) {
}) })
} }
async function blacklist(question: QAInfo) { 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, id: question.sender.id,
}) })
.then(async (data) => { .then(async (data) => {
if (data.code == 200) { if (data.code == 200) {
await QueryGetAPI(QUESTION_API_URL + 'del', { await QueryGetAPI(QUESTION_API_URL() + 'del', {
id: question.id, id: question.id,
}) }).then((data) => {
.then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已拉黑 ' + question.sender.name) message.success('已拉黑 ' + question.sender.name)
} else { } else {
message.error('修改失败: ' + data.message) message.error('修改失败: ' + data.message)
} }
}) })
.catch((err) => {
console.error(err)
})
} else { } else {
message.error('拉黑失败: ' + data.message) message.error('拉黑失败: ' + data.message)
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('拉黑失败') message.error('拉黑失败')
}) })
} }

View File

@@ -119,7 +119,7 @@ const selectedScheduleWeek = ref(Number(format(Date.now(), 'w')) + 1)
async function get() { async function get() {
isLoading.value = true isLoading.value = true
await QueryGetAPI<ScheduleWeekInfo[]>(SCHEDULE_API_URL + 'get', { await QueryGetAPI<ScheduleWeekInfo[]>(SCHEDULE_API_URL() + 'get', {
id: accountInfo.value?.id ?? -1, id: accountInfo.value?.id ?? -1,
}) })
.then((data) => { .then((data) => {
@@ -130,7 +130,6 @@ async function get() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('加载失败') message.error('加载失败')
}) })
.finally(() => (isLoading.value = false)) .finally(() => (isLoading.value = false))
@@ -138,7 +137,7 @@ async function get() {
const isFetching = ref(false) const isFetching = ref(false)
async function addSchedule() { async function addSchedule() {
isFetching.value = true isFetching.value = true
await QueryPostAPI(SCHEDULE_API_URL + 'update', { await QueryPostAPI(SCHEDULE_API_URL() + 'update', {
year: selectedScheduleYear.value, year: selectedScheduleYear.value,
week: selectedScheduleWeek.value, week: selectedScheduleWeek.value,
}) })
@@ -167,7 +166,7 @@ async function onCopySchedule() {
} }
async function onUpdateSchedule() { async function onUpdateSchedule() {
isFetching.value = true isFetching.value = true
await QueryPostAPI(SCHEDULE_API_URL + 'update', { await QueryPostAPI(SCHEDULE_API_URL() + 'update', {
year: updateScheduleModel.value.year, year: updateScheduleModel.value.year,
week: updateScheduleModel.value.week, week: updateScheduleModel.value.week,
day: selectedDay.value, day: selectedDay.value,
@@ -192,7 +191,7 @@ async function onUpdateSchedule() {
}) })
} }
async function onDeleteSchedule(schedule: ScheduleWeekInfo) { async function onDeleteSchedule(schedule: ScheduleWeekInfo) {
await QueryGetAPI(SCHEDULE_API_URL + 'del', { await QueryGetAPI(SCHEDULE_API_URL() + 'del', {
year: schedule.year, year: schedule.year,
week: schedule.week, week: schedule.week,
}).then((data) => { }).then((data) => {

View File

@@ -199,9 +199,6 @@ async function RequestBiliUserData() {
throw new Error('Bili User API Error: ' + data.message) 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 }) { async function SaveComboGroupSetting(value: (string | number)[], meta: { actionType: 'check' | 'uncheck'; value: string | number }) {
if (accountInfo.value) { if (accountInfo.value) {
@@ -219,7 +216,6 @@ async function SaveComboGroupSetting(value: (string | number)[], meta: { actionT
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('修改失败') message.error('修改失败')
}) })
.finally(() => { .finally(() => {
@@ -240,7 +236,6 @@ async function SaveComboSetting() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('修改失败') message.error('修改失败')
}) })
.finally(() => { .finally(() => {

View File

@@ -164,7 +164,6 @@ async function addCustomSong() {
}) })
.catch((err) => { .catch((err) => {
message.error('添加失败') message.error('添加失败')
console.error(err)
}) })
}) })
.finally(() => { .finally(() => {
@@ -190,7 +189,6 @@ async function addNeteaseSongs() {
}) })
.catch((err) => { .catch((err) => {
message.error('添加失败') message.error('添加失败')
console.error(err)
}) })
.finally(() => { .finally(() => {
isModalLoading.value = false isModalLoading.value = false
@@ -205,7 +203,6 @@ async function addFingsingSongs(song: SongsInfo) {
} catch (err) { } catch (err) {
isModalLoading.value = false isModalLoading.value = false
message.error('添加失败') message.error('添加失败')
console.error(err)
return return
} }
} }
@@ -221,7 +218,6 @@ async function addFingsingSongs(song: SongsInfo) {
}) })
.catch((err) => { .catch((err) => {
message.error('添加失败') message.error('添加失败')
console.error(err)
}) })
.finally(() => { .finally(() => {
isModalLoading.value = false isModalLoading.value = false
@@ -243,7 +239,7 @@ async function addSongs(songsShoudAdd: SongsInfo[], from: SongFrom) {
async function getNeteaseSongList() { async function getNeteaseSongList() {
isModalLoading.value = true isModalLoading.value = true
await QueryGetAPI<SongsInfo[]>(SONG_API_URL + 'get-netease-list', { await QueryGetAPI<SongsInfo[]>(SONG_API_URL() + 'get-netease-list', {
id: neteaseSongListId.value, id: neteaseSongListId.value,
}) })
.then((data) => { .then((data) => {
@@ -260,7 +256,6 @@ async function getNeteaseSongList() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('获取歌单失败: ' + err) message.error('获取歌单失败: ' + err)
}) })
.finally(() => { .finally(() => {
@@ -293,7 +288,6 @@ async function getFivesingSearchList(isRestart = false) {
message.success(`成功获取搜索信息, 共 ${json.pageInfo.totalCount} 条, 当前第 ${fivesingCurrentPage.value}`) message.success(`成功获取搜索信息, 共 ${json.pageInfo.totalCount} 条, 当前第 ${fivesingCurrentPage.value}`)
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('获取歌单失败: ' + err) message.error('获取歌单失败: ' + err)
}) })
.finally(() => { .finally(() => {
@@ -316,7 +310,6 @@ async function playFivesingSong(song: SongsInfo) {
song.url = data song.url = data
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('获取歌曲链接失败: ' + err) message.error('获取歌曲链接失败: ' + err)
}) })
.finally(() => { .finally(() => {
@@ -336,7 +329,7 @@ async function getFivesingSongUrl(song: SongsInfo): Promise<string> {
const isLoading = ref(true) const isLoading = ref(true)
async function getSongs() { async function getSongs() {
isLoading.value = true isLoading.value = true
await QueryGetAPI<any>(SONG_API_URL + 'get', { await QueryGetAPI<any>(SONG_API_URL() + 'get', {
id: accountInfo.value?.id, id: accountInfo.value?.id,
}) })
.then((data) => { .then((data) => {
@@ -345,7 +338,6 @@ async function getSongs() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('获取歌曲失败: ' + err) message.error('获取歌曲失败: ' + err)
}) })
.finally(() => { .finally(() => {

View File

@@ -108,7 +108,7 @@ const acceptVideos = computed(() => {
async function getData() { async function getData() {
try { try {
const data = await QueryGetAPI<VideoCollectDetail>(VIDEO_COLLECT_API_URL + 'get', { id: route.params.id }) const data = await QueryGetAPI<VideoCollectDetail>(VIDEO_COLLECT_API_URL() + 'get', { id: route.params.id })
if (data.code == 200) { if (data.code == 200) {
updateModel.value = { updateModel.value = {
id: data.data.table.id, id: data.data.table.id,
@@ -120,7 +120,6 @@ async function getData() {
return data.data return data.data
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('获取失败') message.error('获取失败')
} }
return {} as VideoCollectDetail return {} as VideoCollectDetail
@@ -201,7 +200,7 @@ const rejectButtonGroup = (v: VideoInfo) =>
]) ])
function setStatus(status: VideoStatus, video: VideoInfo) { function setStatus(status: VideoStatus, video: VideoInfo) {
isLoading.value = true isLoading.value = true
QueryGetAPI(VIDEO_COLLECT_API_URL + 'set-status', { QueryGetAPI(VIDEO_COLLECT_API_URL() + 'set-status', {
id: videoDetail.value.table.id, id: videoDetail.value.table.id,
bvid: video.bvid, bvid: video.bvid,
status: status, status: status,
@@ -215,7 +214,6 @@ function setStatus(status: VideoStatus, video: VideoInfo) {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('设置失败') message.error('设置失败')
}) })
.finally(() => { .finally(() => {
@@ -237,7 +235,7 @@ function dateDisabled(ts: number) {
function updateTable() { function updateTable() {
isLoading.value = true isLoading.value = true
updateModel.value.id = videoDetail.value.table.id updateModel.value.id = videoDetail.value.table.id
QueryPostAPI<VideoCollectTable>(VIDEO_COLLECT_API_URL + 'update', updateModel.value) QueryPostAPI<VideoCollectTable>(VIDEO_COLLECT_API_URL() + 'update', updateModel.value)
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('更新成功') message.success('更新成功')
@@ -247,7 +245,6 @@ function updateTable() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('更新失败') message.error('更新失败')
}) })
.finally(() => { .finally(() => {
@@ -256,7 +253,7 @@ function updateTable() {
} }
function deleteTable() { function deleteTable() {
isLoading.value = true isLoading.value = true
QueryGetAPI(VIDEO_COLLECT_API_URL + 'del', { QueryGetAPI(VIDEO_COLLECT_API_URL() + 'del', {
id: videoDetail.value.table.id, id: videoDetail.value.table.id,
}) })
.then((data) => { .then((data) => {
@@ -270,7 +267,6 @@ function deleteTable() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('删除失败') message.error('删除失败')
}) })
.finally(() => { .finally(() => {
@@ -279,7 +275,7 @@ function deleteTable() {
} }
function closeTable() { function closeTable() {
isLoading.value = true isLoading.value = true
QueryGetAPI(VIDEO_COLLECT_API_URL + 'finish', { QueryGetAPI(VIDEO_COLLECT_API_URL() + 'finish', {
id: videoDetail.value.table.id, id: videoDetail.value.table.id,
finish: !videoDetail.value.table.isFinish, finish: !videoDetail.value.table.isFinish,
}) })
@@ -292,7 +288,6 @@ function closeTable() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('操作失败') message.error('操作失败')
}) })
.finally(() => { .finally(() => {

View File

@@ -94,7 +94,7 @@ const isLoading2 = ref(false)
async function get() { async function get() {
try { try {
isLoading.value = true isLoading.value = true
const data = await QueryGetAPI<VideoCollectTable[]>(VIDEO_COLLECT_API_URL + 'get-all') const data = await QueryGetAPI<VideoCollectTable[]>(VIDEO_COLLECT_API_URL() + 'get-all')
if (data.code == 200) { if (data.code == 200) {
//videoTables.value = data.data //videoTables.value = data.data
return data.data return data.data
@@ -103,7 +103,6 @@ async function get() {
return [] return []
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('获取失败') message.error('获取失败')
return [] return []
} finally { } finally {
@@ -113,7 +112,7 @@ async function get() {
function createTable() { function createTable() {
formRef.value?.validate().then(async () => { formRef.value?.validate().then(async () => {
isLoading2.value = true isLoading2.value = true
QueryPostAPI<VideoCollectTable>(VIDEO_COLLECT_API_URL + 'create', createVideoModel.value) QueryPostAPI<VideoCollectTable>(VIDEO_COLLECT_API_URL() + 'create', createVideoModel.value)
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
videoTables.value.push(data.data) videoTables.value.push(data.data)
@@ -125,7 +124,6 @@ function createTable() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('创建失败') message.error('创建失败')
}) })
.finally(() => { .finally(() => {

View File

@@ -30,15 +30,13 @@ const isMoreThanContainer = computed(() => {
async function getUsers() { async function getUsers() {
try { try {
const data = await QueryGetAPI<UpdateLiveLotteryUsersModel>(LOTTERY_API_URL + 'live/get-users', { const data = await QueryGetAPI<UpdateLiveLotteryUsersModel>(LOTTERY_API_URL() + 'live/get-users', {
code: currentCode.value, code: currentCode.value,
}) })
if (data.code == 200) { if (data.code == 200) {
return data.data return data.data
} }
} catch (err) { } catch (err) {}
console.error(err)
}
return { return {
users: [], users: [],
resultUsers: [], resultUsers: [],

View File

@@ -54,15 +54,13 @@ const activeItems = computed(() => {
async function get() { async function get() {
try { 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, id: currentId.value,
}) })
if (data.code == 200) { if (data.code == 200) {
return data.data return data.data
} }
} catch (err) { } catch (err) {}
console.error(err)
}
return {} as { queue: ResponseQueueModel[]; setting: Setting_Queue } return {} as { queue: ResponseQueueModel[]; setting: Setting_Queue }
} }
const isMoreThanContainer = computed(() => { const isMoreThanContainer = computed(() => {
@@ -119,7 +117,15 @@ onUnmounted(() => {
<div class="queue-content" ref="listContainerRef"> <div class="queue-content" ref="listContainerRef">
<template v-if="activeItems.length > 0"> <template v-if="activeItems.length > 0">
<Vue3Marquee class="queue-list" :key="key" vertical :pause="!isMoreThanContainer" :duration="20" :style="`height: ${height}px;width: ${width}px;`"> <Vue3Marquee class="queue-list" :key="key" vertical :pause="!isMoreThanContainer" :duration="20" :style="`height: ${height}px;width: ${width}px;`">
<span class="queue-list-item" :from="(item.from as number)" :status="(item.status as number)" :payment="item.giftPrice ?? 0" v-for="item in activeItems" :key="item.id" :style="`height: ${itemHeight}px`"> <span
class="queue-list-item"
:from="(item.from as number)"
:status="(item.status as number)"
:payment="item.giftPrice ?? 0"
v-for="item in activeItems"
:key="item.id"
:style="`height: ${itemHeight}px`"
>
<div class="queue-list-item-level" :has-level="(item.user?.fans_medal_level ?? 0) > 0"> <div class="queue-list-item-level" :has-level="(item.user?.fans_medal_level ?? 0) > 0">
{{ item.user?.fans_medal_level }} {{ item.user?.fans_medal_level }}
</div> </div>

View File

@@ -39,15 +39,13 @@ const activeSongs = computed(() => {
async function get() { async function get() {
try { 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: currentId.value, id: currentId.value,
}) })
if (data.code == 200) { if (data.code == 200) {
return data.data return data.data
} }
} catch (err) { } catch (err) {}
console.error(err)
}
return {} as { songs: SongRequestInfo[]; setting: Setting_SongRequest } return {} as { songs: SongRequestInfo[]; setting: Setting_SongRequest }
} }
const isMoreThanContainer = computed(() => { const isMoreThanContainer = computed(() => {

View File

@@ -180,7 +180,7 @@ const table = ref()
async function getAllSong() { async function getAllSong() {
if (accountInfo.value) { if (accountInfo.value) {
try { try {
const data = await QueryGetAPI<SongRequestInfo[]>(SONG_REQUEST_API_URL + 'get-all', { const data = await QueryGetAPI<SongRequestInfo[]>(SONG_REQUEST_API_URL() + 'get-all', {
id: accountInfo.value.id, id: accountInfo.value.id,
}) })
if (data.code == 200) { if (data.code == 200) {
@@ -191,7 +191,6 @@ async function getAllSong() {
return [] return []
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('无法获取数据') message.error('无法获取数据')
} }
return [] return []
@@ -202,8 +201,7 @@ async function getAllSong() {
async function addSong(danmaku: EventModel) { async function addSong(danmaku: EventModel) {
console.log(`[OPEN-LIVE-Song-Request] 收到 [${danmaku.name}] 的点歌${danmaku.type == EventDataTypes.SC ? 'SC' : '弹幕'}: ${danmaku.msg}`) console.log(`[OPEN-LIVE-Song-Request] 收到 [${danmaku.name}] 的点歌${danmaku.type == EventDataTypes.SC ? 'SC' : '弹幕'}: ${danmaku.msg}`)
if (accountInfo.value) { if (accountInfo.value) {
await QueryPostAPI<SongRequestInfo>(SONG_REQUEST_API_URL + 'try-add', danmaku) await QueryPostAPI<SongRequestInfo>(SONG_REQUEST_API_URL() + 'try-add', danmaku).then((data) => {
.then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success(`[${danmaku.name}] 添加曲目: ${data.data.songName}`) message.success(`[${danmaku.name}] 添加曲目: ${data.data.songName}`)
if (data.message != 'EventFetcher') originSongs.value.unshift(data.data) if (data.message != 'EventFetcher') originSongs.value.unshift(data.data)
@@ -219,9 +217,6 @@ async function addSong(danmaku: EventModel) {
console.log(`[OPEN-LIVE-Song-Request] [${danmaku.name}] 添加曲目失败: ${data.message}`) console.log(`[OPEN-LIVE-Song-Request] [${danmaku.name}] 添加曲目失败: ${data.message}`)
} }
}) })
.catch((err) => {
console.error(err)
})
} else { } else {
const songData = { const songData = {
songName: danmaku.msg.trim().substring(settings.value.orderPrefix.length), songName: danmaku.msg.trim().substring(settings.value.orderPrefix.length),
@@ -251,10 +246,9 @@ async function addSongManual() {
return return
} }
if (accountInfo.value) { if (accountInfo.value) {
await QueryPostAPIWithParams<SongRequestInfo>(SONG_REQUEST_API_URL + 'add', { await QueryPostAPIWithParams<SongRequestInfo>(SONG_REQUEST_API_URL() + 'add', {
name: newSongName.value, name: newSongName.value,
}) }).then((data) => {
.then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success(`已手动添加曲目: ${data.data.songName}`) message.success(`已手动添加曲目: ${data.data.songName}`)
originSongs.value.unshift(data.data) originSongs.value.unshift(data.data)
@@ -264,9 +258,6 @@ async function addSongManual() {
message.error(`手动添加曲目失败: ${data.message}`) message.error(`手动添加曲目失败: ${data.message}`)
} }
}) })
.catch((err) => {
console.error(err)
})
} else { } else {
const songData = { const songData = {
songName: newSongName.value, songName: newSongName.value,
@@ -309,7 +300,7 @@ async function updateSongStatus(song: SongRequestInfo, status: SongRequestStatus
statusString2 = '演唱中' statusString2 = '演唱中'
break break
} }
await QueryGetAPI(SONG_REQUEST_API_URL + statusString, { await QueryGetAPI(SONG_REQUEST_API_URL() + statusString, {
id: song.id, id: song.id,
}) })
.then((data) => { .then((data) => {
@@ -326,7 +317,6 @@ async function updateSongStatus(song: SongRequestInfo, status: SongRequestStatus
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error(`更新曲目状态失败`) message.error(`更新曲目状态失败`)
}) })
.finally(() => { .finally(() => {
@@ -400,7 +390,6 @@ async function onUpdateFunctionEnable() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error(`点歌功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${err}`) message.error(`点歌功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${err}`)
}) })
} }
@@ -408,7 +397,7 @@ async function onUpdateFunctionEnable() {
async function updateSettings() { async function updateSettings() {
if (accountInfo.value) { if (accountInfo.value) {
isLoading.value = true isLoading.value = true
await QueryPostAPI(SONG_REQUEST_API_URL + 'update-setting', settings.value) await QueryPostAPI(SONG_REQUEST_API_URL() + 'update-setting', settings.value)
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已保存') message.success('已保存')
@@ -417,7 +406,6 @@ async function updateSettings() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('保存失败') message.error('保存失败')
}) })
.finally(() => { .finally(() => {
@@ -438,16 +426,14 @@ async function deleteSongs(values: SongRequestInfo[]) {
originSongs.value = originSongs.value.filter((s) => !values.includes(s)) originSongs.value = originSongs.value.filter((s) => !values.includes(s))
} else { } else {
message.error('删除失败: ' + data.message) message.error('删除失败: ' + data.message)
console.error('删除失败: ' + data.message)
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('删除失败') message.error('删除失败')
}) })
} }
async function deactiveAllSongs() { async function deactiveAllSongs() {
await QueryGetAPI(SONG_REQUEST_API_URL + 'deactive') await QueryGetAPI(SONG_REQUEST_API_URL() + 'deactive')
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已全部取消') message.success('已全部取消')
@@ -461,7 +447,6 @@ async function deactiveAllSongs() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('取消失败') message.error('取消失败')
}) })
} }
@@ -666,7 +651,7 @@ function GetGuardColor(level: number | null | undefined): string {
async function updateActive() { async function updateActive() {
if (!accountInfo.value) return if (!accountInfo.value) return
try { try {
const data = await QueryGetAPI<SongRequestInfo[]>(SONG_REQUEST_API_URL + 'get-active', { const data = await QueryGetAPI<SongRequestInfo[]>(SONG_REQUEST_API_URL() + 'get-active', {
id: accountInfo.value?.id, id: accountInfo.value?.id,
}) })
if (data.code == 200) { if (data.code == 200) {
@@ -685,9 +670,7 @@ async function updateActive() {
message.error('无法获取点歌队列: ' + data.message) message.error('无法获取点歌队列: ' + data.message)
return [] return []
} }
} catch (err) { } catch (err) {}
console.error(err)
}
} }
const isLrcLoading = ref('') const isLrcLoading = ref('')

View File

@@ -104,25 +104,23 @@ const props = defineProps<{
async function getUsers() { async function getUsers() {
try { try {
const data = await QueryGetAPI<UpdateLiveLotteryUsersModel>(LOTTERY_API_URL + 'live/get-users', { const data = await QueryGetAPI<UpdateLiveLotteryUsersModel>(LOTTERY_API_URL() + 'live/get-users', {
code: props.code, code: props.code,
}) })
if (data.code == 200) { if (data.code == 200) {
return data.data return data.data
} }
} catch (err) { } catch (err) {}
console.error(err)
}
return null return null
} }
function updateUsers() { function updateUsers() {
QueryPostAPI(LOTTERY_API_URL + 'live/update-users', { QueryPostAPI(LOTTERY_API_URL() + 'live/update-users', {
code: props.code, code: props.code,
users: originUsers.value, users: originUsers.value,
resultUsers: resultUsers.value, resultUsers: resultUsers.value,
type: isLotteried.value ? OpenLiveLotteryType.Result : OpenLiveLotteryType.Waiting, type: isLotteried.value ? OpenLiveLotteryType.Result : OpenLiveLotteryType.Waiting,
}).catch((err) => { }).catch((err) => {
console.error('[OPEN-LIVE-Lottery] 更新历史抽奖用户失败: ' + err) console.error('[OPEN-LIVE-Lottery] 更新历史抽奖用户失败')
}) })
} }
function addUser(user: OpenLiveLotteryUserInfo, danmu: any) { function addUser(user: OpenLiveLotteryUserInfo, danmu: any) {
@@ -213,7 +211,6 @@ function startLottery() {
} }
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('发生错误') message.error('发生错误')
} }
} }

View File

@@ -191,7 +191,7 @@ const table = ref()
async function getAll() { async function getAll() {
if (accountInfo.value) { if (accountInfo.value) {
try { try {
const data = await QueryGetAPI<ResponseQueueModel[]>(QUEUE_API_URL + 'get-all', { const data = await QueryGetAPI<ResponseQueueModel[]>(QUEUE_API_URL() + 'get-all', {
id: accountInfo.value.id, id: accountInfo.value.id,
}) })
if (data.code == 200) { if (data.code == 200) {
@@ -202,7 +202,6 @@ async function getAll() {
return [] return []
} }
} catch (err) { } catch (err) {
console.error(err)
message.error('无法获取数据') message.error('无法获取数据')
} }
return [] return []
@@ -216,8 +215,7 @@ async function add(danmaku: EventModel) {
} }
console.log(`[OPEN-LIVE-QUEUE] 收到 [${danmaku.name}] 的排队请求`) console.log(`[OPEN-LIVE-QUEUE] 收到 [${danmaku.name}] 的排队请求`)
if (accountInfo.value) { if (accountInfo.value) {
await QueryPostAPI<ResponseQueueModel>(QUEUE_API_URL + 'try-add', danmaku) await QueryPostAPI<ResponseQueueModel>(QUEUE_API_URL() + 'try-add', danmaku).then((data) => {
.then((data) => {
if (data.code == 200) { if (data.code == 200) {
if (data.message != 'EventFetcher') { if (data.message != 'EventFetcher') {
//如果存在则替换, 否则插入最后 //如果存在则替换, 否则插入最后
@@ -244,9 +242,6 @@ async function add(danmaku: EventModel) {
console.log(`[OPEN-LIVE-QUEUE] [${danmaku.name}] 排队失败: ${data.message}`) console.log(`[OPEN-LIVE-QUEUE] [${danmaku.name}] 排队失败: ${data.message}`)
} }
}) })
.catch((err) => {
console.error(err)
})
} else { } else {
const songData = { const songData = {
status: QueueStatus.Waiting, status: QueueStatus.Waiting,
@@ -274,10 +269,9 @@ async function addManual() {
return return
} }
if (accountInfo.value) { if (accountInfo.value) {
await QueryPostAPIWithParams<ResponseQueueModel>(QUEUE_API_URL + 'add', { await QueryPostAPIWithParams<ResponseQueueModel>(QUEUE_API_URL() + 'add', {
name: newQueueName.value, name: newQueueName.value,
}) }).then((data) => {
.then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success(`已手动添加用户至队列: ${data.data.user?.name}`) message.success(`已手动添加用户至队列: ${data.data.user?.name}`)
originQueue.value.unshift(data.data) originQueue.value.unshift(data.data)
@@ -287,9 +281,6 @@ async function addManual() {
message.error(`手动添加失败: ${data.message}`) message.error(`手动添加失败: ${data.message}`)
} }
}) })
.catch((err) => {
console.error(err)
})
} else { } else {
const songData = { const songData = {
status: QueueStatus.Waiting, status: QueueStatus.Waiting,
@@ -311,7 +302,7 @@ async function updateStatus(queueData: ResponseQueueModel, status: QueueStatus)
return return
} }
isLoading.value = true isLoading.value = true
await QueryGetAPI(QUEUE_API_URL + 'set-status', { await QueryGetAPI(QUEUE_API_URL() + 'set-status', {
id: queueData.id, id: queueData.id,
status: status, status: status,
}) })
@@ -329,7 +320,6 @@ async function updateStatus(queueData: ResponseQueueModel, status: QueueStatus)
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error(`更新队列状态失败`) message.error(`更新队列状态失败`)
}) })
.finally(() => { .finally(() => {
@@ -427,7 +417,6 @@ async function onUpdateFunctionEnable() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error(`队列功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${err}`) message.error(`队列功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${err}`)
}) })
} }
@@ -435,7 +424,7 @@ async function onUpdateFunctionEnable() {
async function updateSettings() { async function updateSettings() {
if (accountInfo.value) { if (accountInfo.value) {
isLoading.value = true isLoading.value = true
await QueryPostAPI(QUEUE_API_URL + 'update-setting', settings.value) await QueryPostAPI(QUEUE_API_URL() + 'update-setting', settings.value)
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已保存') message.success('已保存')
@@ -444,7 +433,6 @@ async function updateSettings() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('保存失败') message.error('保存失败')
}) })
.finally(() => { .finally(() => {
@@ -469,12 +457,11 @@ async function deleteQueue(values: ResponseQueueModel[]) {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('删除失败') message.error('删除失败')
}) })
} }
async function deactiveAllSongs() { async function deactiveAllSongs() {
await QueryGetAPI(QUEUE_API_URL + 'deactive') await QueryGetAPI(QUEUE_API_URL() + 'deactive')
.then((data) => { .then((data) => {
if (data.code == 200) { if (data.code == 200) {
message.success('已全部取消') message.success('已全部取消')
@@ -488,7 +475,6 @@ async function deactiveAllSongs() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('取消失败') message.error('取消失败')
}) })
} }
@@ -677,7 +663,7 @@ function GetGuardColor(level: number | null | undefined): string {
async function updateActive() { async function updateActive() {
if (!accountInfo.value) return if (!accountInfo.value) return
try { try {
const data = await QueryGetAPI<ResponseQueueModel[]>(QUEUE_API_URL + 'get-active', { const data = await QueryGetAPI<ResponseQueueModel[]>(QUEUE_API_URL() + 'get-active', {
id: accountInfo.value?.id, id: accountInfo.value?.id,
}) })
if (data.code == 200) { if (data.code == 200) {
@@ -700,9 +686,7 @@ async function updateActive() {
message.error('无法获取队列: ' + data.message) message.error('无法获取队列: ' + data.message)
return [] return []
} }
} catch (err) { } catch (err) {}
console.error(err)
}
} }
let timer: any let timer: any
let updateActiveTimer: any let updateActiveTimer: any
@@ -989,14 +973,14 @@ onUnmounted(() => {
/> />
</NSpace> </NSpace>
<span> <span>
<NRadioGroup v-model:value="settings.giftFilterType" :disabled="!configCanEdit"> <NRadioGroup v-model:value="settings.giftFilterType" :disabled="!configCanEdit" @update:value="updateSettings">
<NRadioButton :value="QueueGiftFilterType.And"> 需同时满足礼物名和价格 </NRadioButton> <NRadioButton :value="QueueGiftFilterType.And"> 需同时满足礼物名和价格 </NRadioButton>
<NRadioButton :value="QueueGiftFilterType.Or"> 礼物名/价格 二选一 </NRadioButton> <NRadioButton :value="QueueGiftFilterType.Or"> 礼物名/价格 二选一 </NRadioButton>
</NRadioGroup> </NRadioGroup>
</span> </span>
<NCheckbox v-model:checked="settings.allowIncreasePaymentBySendGift" @update:checked="updateSettings" :disabled="!configCanEdit"> 在队列中时继续发送礼物会叠加 </NCheckbox>
<NCheckbox v-model:checked="settings.allowIncreasePaymentBySendGift" @update:checked="updateSettings" :disabled="!configCanEdit"> 在队列中时允许发送任意礼物来增加付费量 </NCheckbox>
</template> </template>
<NCheckbox v-model:checked="settings.allowIncreasePaymentBySendGift" @update:checked="updateSettings" :disabled="!configCanEdit"> 在队列中时允许继续发送礼物累计付费量 (仅限上方设定的礼物) </NCheckbox>
<NCheckbox v-model:checked="settings.allowIncreasePaymentBySendGift" @update:checked="updateSettings" :disabled="!configCanEdit"> 允许发送任意礼物来叠加付费量 </NCheckbox>
</NSpace> </NSpace>
<NDivider> 冷却 (单位: ) </NDivider> <NDivider> 冷却 (单位: ) </NDivider>
<NCheckbox v-model:checked="settings.enableCooldown" @update:checked="updateSettings" :disabled="!configCanEdit"> 启用排队冷却 </NCheckbox> <NCheckbox v-model:checked="settings.enableCooldown" @update:checked="updateSettings" :disabled="!configCanEdit"> 启用排队冷却 </NCheckbox>

View File

@@ -85,7 +85,6 @@ async function SendQuestion() {
}) })
.catch((err) => { .catch((err) => {
message.error('发送失败') message.error('发送失败')
console.error(err)
}) })
.finally(() => { .finally(() => {
isSending.value = false isSending.value = false
@@ -112,7 +111,7 @@ function OnFileListChange(files: UploadFileInfo[]) {
} }
function getPublicQuestions() { function getPublicQuestions() {
isGetting.value = true isGetting.value = true
QueryGetAPI<QAInfo[]>(QUESTION_API_URL + 'get-public', { QueryGetAPI<QAInfo[]>(QUESTION_API_URL() + 'get-public', {
id: userInfo?.id, id: userInfo?.id,
}) })
.then((data) => { .then((data) => {
@@ -124,7 +123,6 @@ function getPublicQuestions() {
}) })
.catch((err) => { .catch((err) => {
message.error('获取公开提问失败') message.error('获取公开提问失败')
console.error(err)
}) })
.finally(() => { .finally(() => {
isGetting.value = false isGetting.value = false

View File

@@ -30,7 +30,7 @@ const errMessage = ref('')
async function get() { async function get() {
isLoading.value = true isLoading.value = true
await QueryGetAPI<ScheduleWeekInfo[]>(SCHEDULE_API_URL + 'get', { await QueryGetAPI<ScheduleWeekInfo[]>(SCHEDULE_API_URL() + 'get', {
id: props.userInfo?.id, id: props.userInfo?.id,
}) })
.then((data) => { .then((data) => {
@@ -42,7 +42,6 @@ async function get() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('加载失败') message.error('加载失败')
}) })
.finally(() => { .finally(() => {

View File

@@ -45,20 +45,18 @@ const settings = ref<Setting_SongRequest>({} as Setting_SongRequest)
async function getSongRequestInfo() { async function getSongRequestInfo() {
try { 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, id: props.userInfo?.id,
}) })
if (data.code == 200) { if (data.code == 200) {
return data.data return data.data
} }
} catch (err) { } catch (err) {}
console.error(err)
}
return {} as { songs: SongRequestInfo[]; setting: Setting_SongRequest } return {} as { songs: SongRequestInfo[]; setting: Setting_SongRequest }
} }
async function getSongs() { async function getSongs() {
isLoading.value = true isLoading.value = true
await QueryGetAPI<SongsInfo[]>(SONG_API_URL + 'get', { await QueryGetAPI<SongsInfo[]>(SONG_API_URL() + 'get', {
id: props.userInfo?.id, id: props.userInfo?.id,
}) })
.then((data) => { .then((data) => {
@@ -70,7 +68,6 @@ async function getSongs() {
} }
}) })
.catch((err) => { .catch((err) => {
console.error(err)
message.error('加载失败') message.error('加载失败')
}) })
.finally(() => { .finally(() => {
@@ -88,7 +85,7 @@ async function requestSong(song: SongsInfo) {
} else { } else {
if (props.userInfo) { if (props.userInfo) {
try { 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, target: props.userInfo?.id,
song: song.key, song: song.key,
}) })
@@ -117,7 +114,6 @@ onMounted(async () => {
} }
}, 1000) }, 1000)
} catch (err) { } catch (err) {
console.error(err)
message.error('加载失败') message.error('加载失败')
} }
} else { } else {