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
}
function refreshCookie() {
QueryPostAPI<string>(`${ACCOUNT_API_URL}refresh-token`).then((data) => {
QueryPostAPI<string>(`${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<APIRoot<string>> {
return QueryPostAPI<string>(`${ACCOUNT_API_URL}register`, {
return QueryPostAPI<string>(`${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<APIRoot<string>> {
return QueryPostAPI<string>(`${ACCOUNT_API_URL}login`, {
return QueryPostAPI<string>(`${ACCOUNT_API_URL()}login`, {
nameOrEmail,
password,
})
}
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 */
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<T>(url: string, body?: unknown, headers?: [string, string][]): Promise<APIRoot<T>> {
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<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 = 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<T>
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<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 QueryGetAPI<T>(urlString: string, params?: any, headers?: [string, string][]): Promise<APIRoot<T>> {
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<T>
try {
const data = await fetch(url.toString(), {
method: 'get',
headers: headers,
})
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>>> {
return await QueryPostAPI<PaginationResponse<T>>(url, body)

View File

@@ -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<UserInfo>
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<UserInfo>(`${USER_API_URL}info`, {
const result = await QueryGetAPI<UserInfo>(`${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<APIRoot<UserInfo>> {
return QueryGetAPI<UserInfo>(`${USER_API_URL}info`, {
return QueryGetAPI<UserInfo>(`${USER_API_URL()}info`, {
id: id,
})
}

View File

@@ -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(() => {

View File

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

View File

@@ -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)
})

View File

@@ -197,10 +197,10 @@ export default class DanmakuClient {
}
private sendHeartbeat() {
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) => {
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<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) {
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() || '未知错误',

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 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')) },

View File

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

View File

@@ -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<string>(BASE_API + 'vtsuru/version').then((version) => {
if (version.code == 200) {
currentVersion = version.data
const savedVersion = localStorage.getItem('Version')
QueryGetAPI<string>(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()
})

View File

@@ -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(() => {

View File

@@ -43,7 +43,7 @@ const newFeedback = ref<FeedbackModel>({
async function get() {
try {
const data = await QueryGetAPI<ResponseFeedbackModel[]>(FEEDBACK_API_URL + 'get')
const data = await QueryGetAPI<ResponseFeedbackModel[]>(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<ResponseFeedbackModel>(FEEDBACK_API_URL + 'add', newFeedback.value)
await QueryPostAPI<ResponseFeedbackModel>(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('发送失败')
})
}

View File

@@ -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('发送失败')
})
}

View File

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

View File

@@ -33,12 +33,11 @@ const totalTime = computed(() => {
async function get() {
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) {
return data.data
}
} catch (err) {
console.error(err)
message.error('获取失败')
}
return null
@@ -117,14 +116,12 @@ function formatSecondsToTime(seconds: number): string {
<NDivider vertical />
已观看 {{ watchedVideos.length }}
</NDivider>
<NAlert v-if="watchedVideos.length == acceptVideos?.length" type="success">
已观看全部视频
</NAlert>
<NAlert v-if="watchedVideos.length == acceptVideos?.length" type="success"> 已观看全部视频 </NAlert>
<NList ref="card">
<NListItem v-for="item in acceptVideos" v-bind:key="item.info.bvid">
<NCard size="small" :hoverable="!item.video.watched" :embedded="!item.video.watched">
<NSpace>
<NImage :src="item.video.cover + '@100h'" lazy :img-props="{ referrerpolicy: 'no-referrer' }" height="75" @click="onClick(item.video)" preview-disabled style="cursor: pointer"/>
<NImage :src="item.video.cover + '@100h'" lazy :img-props="{ referrerpolicy: 'no-referrer' }" height="75" @click="onClick(item.video)" preview-disabled style="cursor: pointer" />
<NSpace vertical :size="5">
<NButton style="width: 100%; max-width: 100px" @click="onClick(item.video)" text>
<NText :title="item.video.title" :delete="item.video.watched" :style="`color: ${item.video.watched ? '#a54e4e' : ''};width: ${width - 20}px;`">

View File

@@ -28,12 +28,11 @@ const isLoading = ref(false)
async function get() {
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) {
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(() => {

View File

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

View File

@@ -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

View File

@@ -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(() => {

View File

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

View File

@@ -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: [
{

View File

@@ -22,9 +22,9 @@ const liveInfo = ref<ResponseLiveDetail | undefined>(await get())
async function get() {
try {
const data = await QueryGetAPI<ResponseLiveDetail>(LIVE_API_URL + 'get', {
const data = await QueryGetAPI<ResponseLiveDetail>(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

View File

@@ -21,7 +21,7 @@ const defaultDanmakusCount = ref(0)
async function getAll() {
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) {
return data.data
} else {
@@ -29,7 +29,6 @@ async function getAll() {
return []
}
} catch (err) {
console.error(err)
message.error('无法获取数据')
}
return []

View File

@@ -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('发生错误')
}
}

View File

@@ -66,7 +66,7 @@ const shareUrl = computed(() => 'https://vtsuru.live/user/' + accountInfo.value?
async function GetRecieveQAInfo() {
isLoading.value = true
await QueryGetAPI<QAInfo[]>(QUESTION_API_URL + 'get-recieve')
await QueryGetAPI<QAInfo[]>(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<QAInfo[]>(QUESTION_API_URL + 'get-send')
await QueryGetAPI<QAInfo[]>(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<QAInfo>(QUESTION_API_URL + 'reply', {
await QueryPostAPI<QAInfo>(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('拉黑失败')
})
}

View File

@@ -119,7 +119,7 @@ const selectedScheduleWeek = ref(Number(format(Date.now(), 'w')) + 1)
async function get() {
isLoading.value = true
await QueryGetAPI<ScheduleWeekInfo[]>(SCHEDULE_API_URL + 'get', {
await QueryGetAPI<ScheduleWeekInfo[]>(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) => {

View File

@@ -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(() => {

View File

@@ -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<SongsInfo[]>(SONG_API_URL + 'get-netease-list', {
await QueryGetAPI<SongsInfo[]>(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<string> {
const isLoading = ref(true)
async function getSongs() {
isLoading.value = true
await QueryGetAPI<any>(SONG_API_URL + 'get', {
await QueryGetAPI<any>(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(() => {

View File

@@ -108,7 +108,7 @@ const acceptVideos = computed(() => {
async function getData() {
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) {
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<VideoCollectTable>(VIDEO_COLLECT_API_URL + 'update', updateModel.value)
QueryPostAPI<VideoCollectTable>(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(() => {

View File

@@ -94,7 +94,7 @@ const isLoading2 = ref(false)
async function get() {
try {
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) {
//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<VideoCollectTable>(VIDEO_COLLECT_API_URL + 'create', createVideoModel.value)
QueryPostAPI<VideoCollectTable>(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(() => {

View File

@@ -30,15 +30,13 @@ const isMoreThanContainer = computed(() => {
async function getUsers() {
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,
})
if (data.code == 200) {
return data.data
}
} catch (err) {
console.error(err)
}
} catch (err) {}
return {
users: [],
resultUsers: [],

View File

@@ -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(() => {
<div class="queue-content" ref="listContainerRef">
<template v-if="activeItems.length > 0">
<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">
{{ item.user?.fans_medal_level }}
</div>
@@ -302,7 +308,7 @@ onUnmounted(() => {
}
/* 弹幕点歌 */
.queue-list-item[payment='0'] .queue-list-item-payment{
.queue-list-item[payment='0'] .queue-list-item-payment {
display: none;
}

View File

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

View File

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

View File

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

View File

@@ -191,7 +191,7 @@ const table = ref()
async function getAll() {
if (accountInfo.value) {
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,
})
if (data.code == 200) {
@@ -202,7 +202,6 @@ async function getAll() {
return []
}
} catch (err) {
console.error(err)
message.error('无法获取数据')
}
return []
@@ -216,37 +215,33 @@ async function add(danmaku: EventModel) {
}
console.log(`[OPEN-LIVE-QUEUE] 收到 [${danmaku.name}] 的排队请求`)
if (accountInfo.value) {
await QueryPostAPI<ResponseQueueModel>(QUEUE_API_URL + 'try-add', danmaku)
.then((data) => {
if (data.code == 200) {
if (data.message != 'EventFetcher') {
//如果存在则替换, 否则插入最后
const index = originQueue.value.findIndex((q) => q.id == data.data.id)
if (index > -1) {
message.info(
`${data.data.user?.name} 通过发送礼物再次付费: ¥ ${((data.data?.giftPrice ?? 0) - (originQueue.value[index]?.giftPrice ?? 0)).toFixed(1)}, 当前总计付费: ¥ ${data.data.giftPrice}`
)
originQueue.value.splice(index, 1, data.data)
} else {
originQueue.value.push(data.data)
message.success(`[${danmaku.name}] 添加至队列`)
}
await QueryPostAPI<ResponseQueueModel>(QUEUE_API_URL() + 'try-add', danmaku).then((data) => {
if (data.code == 200) {
if (data.message != 'EventFetcher') {
//如果存在则替换, 否则插入最后
const index = originQueue.value.findIndex((q) => q.id == data.data.id)
if (index > -1) {
message.info(
`${data.data.user?.name} 通过发送礼物再次付费: ¥ ${((data.data?.giftPrice ?? 0) - (originQueue.value[index]?.giftPrice ?? 0)).toFixed(1)}, 当前总计付费: ¥ ${data.data.giftPrice}`
)
originQueue.value.splice(index, 1, data.data)
} else {
originQueue.value.push(data.data)
message.success(`[${danmaku.name}] 添加至队列`)
}
} else {
//message.error(`[${danmaku.name}] 添加曲目失败: ${data.message}`)
const time = Date.now()
notice.warning({
title: danmaku.name + ' 排队失败',
description: data.message,
duration: isWarnMessageAutoClose.value ? 3000 : 0,
meta: () => h(NTime, { type: 'relative', time: time, key: updateKey.value }),
})
console.log(`[OPEN-LIVE-QUEUE] [${danmaku.name}] 排队失败: ${data.message}`)
}
})
.catch((err) => {
console.error(err)
})
} else {
//message.error(`[${danmaku.name}] 添加曲目失败: ${data.message}`)
const time = Date.now()
notice.warning({
title: danmaku.name + ' 排队失败',
description: data.message,
duration: isWarnMessageAutoClose.value ? 3000 : 0,
meta: () => h(NTime, { type: 'relative', time: time, key: updateKey.value }),
})
console.log(`[OPEN-LIVE-QUEUE] [${danmaku.name}] 排队失败: ${data.message}`)
}
})
} else {
const songData = {
status: QueueStatus.Waiting,
@@ -274,22 +269,18 @@ async function addManual() {
return
}
if (accountInfo.value) {
await QueryPostAPIWithParams<ResponseQueueModel>(QUEUE_API_URL + 'add', {
await QueryPostAPIWithParams<ResponseQueueModel>(QUEUE_API_URL() + 'add', {
name: newQueueName.value,
}).then((data) => {
if (data.code == 200) {
message.success(`已手动添加用户至队列: ${data.data.user?.name}`)
originQueue.value.unshift(data.data)
newQueueName.value = ''
console.log(`[OPEN-LIVE-QUEUE] 已手动添加用户至队列: ${data.data.user?.name}`)
} else {
message.error(`手动添加失败: ${data.message}`)
}
})
.then((data) => {
if (data.code == 200) {
message.success(`已手动添加用户至队列: ${data.data.user?.name}`)
originQueue.value.unshift(data.data)
newQueueName.value = ''
console.log(`[OPEN-LIVE-QUEUE] 已手动添加用户至队列: ${data.data.user?.name}`)
} else {
message.error(`手动添加失败: ${data.message}`)
}
})
.catch((err) => {
console.error(err)
})
} else {
const songData = {
status: QueueStatus.Waiting,
@@ -311,7 +302,7 @@ async function updateStatus(queueData: ResponseQueueModel, status: QueueStatus)
return
}
isLoading.value = true
await QueryGetAPI(QUEUE_API_URL + 'set-status', {
await QueryGetAPI(QUEUE_API_URL() + 'set-status', {
id: queueData.id,
status: status,
})
@@ -329,7 +320,6 @@ async function updateStatus(queueData: ResponseQueueModel, status: QueueStatus)
}
})
.catch((err) => {
console.error(err)
message.error(`更新队列状态失败`)
})
.finally(() => {
@@ -427,7 +417,6 @@ async function onUpdateFunctionEnable() {
}
})
.catch((err) => {
console.error(err)
message.error(`队列功能${accountInfo.value?.settings.enableFunctions.includes(FunctionTypes.SongRequest) ? '启用' : '禁用'}失败: ${err}`)
})
}
@@ -435,7 +424,7 @@ async function onUpdateFunctionEnable() {
async function updateSettings() {
if (accountInfo.value) {
isLoading.value = true
await QueryPostAPI(QUEUE_API_URL + 'update-setting', settings.value)
await QueryPostAPI(QUEUE_API_URL() + 'update-setting', settings.value)
.then((data) => {
if (data.code == 200) {
message.success('已保存')
@@ -444,7 +433,6 @@ async function updateSettings() {
}
})
.catch((err) => {
console.error(err)
message.error('保存失败')
})
.finally(() => {
@@ -469,12 +457,11 @@ async function deleteQueue(values: ResponseQueueModel[]) {
}
})
.catch((err) => {
console.error(err)
message.error('删除失败')
})
}
async function deactiveAllSongs() {
await QueryGetAPI(QUEUE_API_URL + 'deactive')
await QueryGetAPI(QUEUE_API_URL() + 'deactive')
.then((data) => {
if (data.code == 200) {
message.success('已全部取消')
@@ -488,7 +475,6 @@ async function deactiveAllSongs() {
}
})
.catch((err) => {
console.error(err)
message.error('取消失败')
})
}
@@ -677,7 +663,7 @@ function GetGuardColor(level: number | null | undefined): string {
async function updateActive() {
if (!accountInfo.value) return
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,
})
if (data.code == 200) {
@@ -700,9 +686,7 @@ async function updateActive() {
message.error('无法获取队列: ' + data.message)
return []
}
} catch (err) {
console.error(err)
}
} catch (err) {}
}
let timer: any
let updateActiveTimer: any
@@ -989,14 +973,14 @@ onUnmounted(() => {
/>
</NSpace>
<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.Or"> 礼物名/价格 二选一 </NRadioButton>
</NRadioGroup>
</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>
<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>
<NDivider> 冷却 (单位: ) </NDivider>
<NCheckbox v-model:checked="settings.enableCooldown" @update:checked="updateSettings" :disabled="!configCanEdit"> 启用排队冷却 </NCheckbox>

View File

@@ -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<QAInfo[]>(QUESTION_API_URL + 'get-public', {
QueryGetAPI<QAInfo[]>(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

View File

@@ -30,7 +30,7 @@ const errMessage = ref('')
async function get() {
isLoading.value = true
await QueryGetAPI<ScheduleWeekInfo[]>(SCHEDULE_API_URL + 'get', {
await QueryGetAPI<ScheduleWeekInfo[]>(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(() => {

View File

@@ -45,20 +45,18 @@ const settings = ref<Setting_SongRequest>({} 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<SongsInfo[]>(SONG_API_URL + 'get', {
await QueryGetAPI<SongsInfo[]>(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 {