mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
add rtc feature, set payment page to wip state
This commit is contained in:
@@ -9,7 +9,6 @@ import { useRoute } from 'vue-router'
|
||||
|
||||
export const ACCOUNT = ref<AccountInfo>({} as AccountInfo)
|
||||
export const isLoadingAccount = ref(true)
|
||||
const route = useRoute()
|
||||
|
||||
const { message } = createDiscreteApi(['message'])
|
||||
const cookie = useLocalStorage('JWT_Token', '')
|
||||
@@ -47,6 +46,7 @@ export async function GetSelfAccount() {
|
||||
}
|
||||
export function UpdateAccountLoop() {
|
||||
setInterval(() => {
|
||||
const route = useRoute()
|
||||
if (ACCOUNT.value && route?.name != 'question-display') {
|
||||
// 防止在问题详情页刷新
|
||||
GetSelfAccount()
|
||||
@@ -63,47 +63,68 @@ 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 async function SaveSetting(
|
||||
name: 'Queue' | 'Point' | 'Index' | 'General' | 'QuestionDisplay' | 'SongRequest' | 'QuestionBox' | 'SendEmail',
|
||||
setting: unknown,
|
||||
name:
|
||||
| 'Queue'
|
||||
| 'Point'
|
||||
| 'Index'
|
||||
| 'General'
|
||||
| 'QuestionDisplay'
|
||||
| 'SongRequest'
|
||||
| 'QuestionBox'
|
||||
| 'SendEmail',
|
||||
setting: unknown
|
||||
) {
|
||||
const result = await QueryPostAPIWithParams(
|
||||
ACCOUNT_API_URL + 'update-single-setting',
|
||||
{
|
||||
name,
|
||||
name
|
||||
},
|
||||
setting,
|
||||
setting
|
||||
)
|
||||
return result.message
|
||||
}
|
||||
export async function UpdateFunctionEnable(func: FunctionTypes) {
|
||||
if (ACCOUNT.value) {
|
||||
const oldValue = JSON.parse(JSON.stringify(ACCOUNT.value.settings.enableFunctions))
|
||||
const oldValue = JSON.parse(
|
||||
JSON.stringify(ACCOUNT.value.settings.enableFunctions)
|
||||
)
|
||||
if (ACCOUNT.value?.settings.enableFunctions.includes(func)) {
|
||||
ACCOUNT.value.settings.enableFunctions = ACCOUNT.value.settings.enableFunctions.filter((f) => f != func)
|
||||
ACCOUNT.value.settings.enableFunctions =
|
||||
ACCOUNT.value.settings.enableFunctions.filter((f) => f != func)
|
||||
} else {
|
||||
ACCOUNT.value.settings.enableFunctions.push(func)
|
||||
}
|
||||
await SaveEnableFunctions(ACCOUNT.value?.settings.enableFunctions)
|
||||
.then((data) => {
|
||||
if (data.code == 200) {
|
||||
message.success(`已${ACCOUNT.value?.settings.enableFunctions.includes(func) ? '启用' : '禁用'}`)
|
||||
message.success(
|
||||
`已${ACCOUNT.value?.settings.enableFunctions.includes(func) ? '启用' : '禁用'}`
|
||||
)
|
||||
} else {
|
||||
if (ACCOUNT.value) {
|
||||
ACCOUNT.value.settings.enableFunctions = oldValue
|
||||
}
|
||||
message.error(
|
||||
`${ACCOUNT.value?.settings.enableFunctions.includes(func) ? '启用' : '禁用'}失败: ${data.message}`,
|
||||
`${ACCOUNT.value?.settings.enableFunctions.includes(func) ? '启用' : '禁用'}失败: ${data.message}`
|
||||
)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
message.error(`${ACCOUNT.value?.settings.enableFunctions.includes(func) ? '启用' : '禁用'}失败: ${err}`)
|
||||
message.error(
|
||||
`${ACCOUNT.value?.settings.enableFunctions.includes(func) ? '启用' : '禁用'}失败: ${err}`
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -111,74 +132,85 @@ export function useAccount() {
|
||||
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`, {
|
||||
name,
|
||||
email,
|
||||
password,
|
||||
token,
|
||||
token
|
||||
})
|
||||
}
|
||||
|
||||
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`, {
|
||||
nameOrEmail,
|
||||
password,
|
||||
password
|
||||
})
|
||||
}
|
||||
export async function Self(): Promise<APIRoot<AccountInfo>> {
|
||||
return QueryPostAPI<AccountInfo>(`${ACCOUNT_API_URL}self`)
|
||||
}
|
||||
export async function AddBiliBlackList(id: number, name: string): Promise<APIRoot<unknown>> {
|
||||
export async function AddBiliBlackList(
|
||||
id: number,
|
||||
name: string
|
||||
): Promise<APIRoot<unknown>> {
|
||||
return QueryGetAPI<AccountInfo>(`${ACCOUNT_API_URL}black-list/add-bili`, {
|
||||
id: id,
|
||||
name: name,
|
||||
name: name
|
||||
})
|
||||
}
|
||||
export async function DelBiliBlackList(id: number): Promise<APIRoot<unknown>> {
|
||||
return QueryGetAPI<AccountInfo>(`${ACCOUNT_API_URL}black-list/del-bili`, {
|
||||
id: id,
|
||||
id: id
|
||||
})
|
||||
}
|
||||
export async function DelBlackList(id: number): Promise<APIRoot<unknown>> {
|
||||
return QueryGetAPI<AccountInfo>(`${ACCOUNT_API_URL}black-list/del`, {
|
||||
id: id,
|
||||
id: id
|
||||
})
|
||||
}
|
||||
export function downloadConfigDirect(name: string) {
|
||||
return QueryGetAPI<string>(VTSURU_API_URL + 'get-config', {
|
||||
name: name,
|
||||
name: name
|
||||
})
|
||||
}
|
||||
export async function DownloadConfig<T>(name: string) {
|
||||
try {
|
||||
const resp = await QueryGetAPI<string>(VTSURU_API_URL + 'get-config', {
|
||||
name: name,
|
||||
name: name
|
||||
})
|
||||
if (resp.code == 200) {
|
||||
console.log('已获取配置文件: ' + name)
|
||||
return {
|
||||
msg: undefined,
|
||||
data: JSON.parse(resp.data) as T,
|
||||
data: JSON.parse(resp.data) as T
|
||||
}
|
||||
} else if (resp.code == 404) {
|
||||
console.error(`未找到名为 ${name} 的配置文件`)
|
||||
return {
|
||||
msg: `未找到名为 ${name} 的配置文件, 需要先上传`,
|
||||
data: undefined,
|
||||
data: undefined
|
||||
}
|
||||
} else {
|
||||
console.error(`无法获取配置文件 [${name}]: ` + resp.message)
|
||||
return {
|
||||
msg: `无法获取配置文件 [${name}]: ` + resp.message,
|
||||
data: undefined,
|
||||
data: undefined
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`无法获取配置文件 [${name}]: ` + err)
|
||||
return {
|
||||
msg: `无法获取配置文件 [${name}]: ` + err,
|
||||
data: undefined,
|
||||
data: undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,7 +218,7 @@ export async function UploadConfig(name: string, data: unknown) {
|
||||
try {
|
||||
const resp = await QueryPostAPI(VTSURU_API_URL + 'set-config', {
|
||||
name: name,
|
||||
json: JSON.stringify(data),
|
||||
json: JSON.stringify(data)
|
||||
})
|
||||
if (resp.code == 200) {
|
||||
console.log('已保存配置文件至服务器:' + name)
|
||||
@@ -208,7 +240,10 @@ export async function EnableFunction(func: FunctionTypes) {
|
||||
if (await updateFunctionEnable()) {
|
||||
return true
|
||||
} else {
|
||||
ACCOUNT.value.settings.enableFunctions.splice(ACCOUNT.value.settings.enableFunctions.indexOf(func), 1)
|
||||
ACCOUNT.value.settings.enableFunctions.splice(
|
||||
ACCOUNT.value.settings.enableFunctions.indexOf(func),
|
||||
1
|
||||
)
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -220,7 +255,10 @@ export async function DisableFunction(func: FunctionTypes) {
|
||||
if (!ACCOUNT.value.settings.enableFunctions.includes(func)) {
|
||||
return true
|
||||
} else {
|
||||
ACCOUNT.value.settings.enableFunctions.splice(ACCOUNT.value.settings.enableFunctions.indexOf(func), 1)
|
||||
ACCOUNT.value.settings.enableFunctions.splice(
|
||||
ACCOUNT.value.settings.enableFunctions.indexOf(func),
|
||||
1
|
||||
)
|
||||
if (await updateFunctionEnable()) {
|
||||
return true
|
||||
} else {
|
||||
@@ -234,7 +272,9 @@ export async function DisableFunction(func: FunctionTypes) {
|
||||
async function updateFunctionEnable() {
|
||||
if (ACCOUNT.value) {
|
||||
try {
|
||||
const data = await SaveEnableFunctions(ACCOUNT.value.settings.enableFunctions)
|
||||
const data = await SaveEnableFunctions(
|
||||
ACCOUNT.value.settings.enableFunctions
|
||||
)
|
||||
if (data.code == 200) {
|
||||
return true
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user