mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
improve setting save
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { QueryGetAPI, QueryPostAPI } from '@/api/query'
|
import { QueryGetAPI, QueryPostAPI, QueryPostAPIWithParams } from '@/api/query'
|
||||||
import { ACCOUNT_API_URL, VTSURU_API_URL } from '@/data/constants'
|
import { ACCOUNT_API_URL, VTSURU_API_URL } from '@/data/constants'
|
||||||
import { useLocalStorage } from '@vueuse/core'
|
import { useLocalStorage } from '@vueuse/core'
|
||||||
import { isSameDay } from 'date-fns'
|
import { isSameDay } from 'date-fns'
|
||||||
@@ -63,6 +63,19 @@ export async function SaveAccountSettings() {
|
|||||||
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 async function SaveSetting(
|
||||||
|
name: 'Queue' | 'Point' | 'Index' | 'General' | 'QuestionDisplay' | 'SongRequest' | 'QuestionBox' | 'SendEmail',
|
||||||
|
setting: unknown,
|
||||||
|
) {
|
||||||
|
const result = await QueryPostAPIWithParams(
|
||||||
|
ACCOUNT_API_URL + 'update-single-setting',
|
||||||
|
{
|
||||||
|
name,
|
||||||
|
},
|
||||||
|
setting,
|
||||||
|
)
|
||||||
|
return result.message
|
||||||
|
}
|
||||||
export async function UpdateFunctionEnable(func: FunctionTypes) {
|
export async function UpdateFunctionEnable(func: FunctionTypes) {
|
||||||
if (ACCOUNT.value) {
|
if (ACCOUNT.value) {
|
||||||
const oldValue = JSON.parse(JSON.stringify(ACCOUNT.value.settings.enableFunctions))
|
const oldValue = JSON.parse(JSON.stringify(ACCOUNT.value.settings.enableFunctions))
|
||||||
|
|||||||
@@ -242,6 +242,7 @@ export enum QueueSortType {
|
|||||||
GuardFirst,
|
GuardFirst,
|
||||||
PaymentFist,
|
PaymentFist,
|
||||||
TimeFirst,
|
TimeFirst,
|
||||||
|
FansMedalFirst
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum QueueGiftFilterType {
|
export enum QueueGiftFilterType {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ QueryGetAPI<string>(BASE_API_URL + 'vtsuru/version')
|
|||||||
isHaveNewVersion = true
|
isHaveNewVersion = true
|
||||||
currentVersion = version.data
|
currentVersion = version.data
|
||||||
localStorage.setItem('Version', currentVersion)
|
localStorage.setItem('Version', currentVersion)
|
||||||
|
console.log('[vtsuru] 发现新版本: ' + currentVersion)
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
if (!route.path.startsWith('/obs')) {
|
if (!route.path.startsWith('/obs')) {
|
||||||
const n = notification.info({
|
const n = notification.info({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { copyToClipboard, downloadImage } from '@/Utils'
|
import { copyToClipboard, downloadImage } from '@/Utils'
|
||||||
import { DisableFunction, EnableFunction, SaveAccountSettings, useAccount } from '@/api/account'
|
import { DisableFunction, EnableFunction, SaveAccountSettings, SaveSetting, useAccount } from '@/api/account'
|
||||||
import { FunctionTypes, QAInfo } from '@/api/api-models'
|
import { FunctionTypes, QAInfo } from '@/api/api-models'
|
||||||
import { QueryGetAPI } from '@/api/query'
|
import { QueryGetAPI } from '@/api/query'
|
||||||
import { QUESTION_API_URL } from '@/data/constants'
|
import { QUESTION_API_URL } from '@/data/constants'
|
||||||
@@ -117,18 +117,19 @@ function saveQRCode() {
|
|||||||
downloadImage(`https://api.qrserver.com/v1/create-qr-code/?data=${shareUrl.value}`, 'vtsuru-提问箱二维码.png')
|
downloadImage(`https://api.qrserver.com/v1/create-qr-code/?data=${shareUrl.value}`, 'vtsuru-提问箱二维码.png')
|
||||||
}
|
}
|
||||||
async function saveSettings() {
|
async function saveSettings() {
|
||||||
try {
|
useQB.isLoading = true
|
||||||
useQB.isLoading = true
|
await SaveSetting('QuestionBox', accountInfo.value.settings.questionBox)
|
||||||
const data = await SaveAccountSettings()
|
.then((msg) => {
|
||||||
if (data.code == 200) {
|
if (msg) {
|
||||||
message.success('保存成功')
|
message.success('已保存')
|
||||||
} else {
|
return true
|
||||||
message.error('保存失败: ' + data.message)
|
} else {
|
||||||
}
|
message.error('保存失败: ' + msg)
|
||||||
} catch (error) {
|
}
|
||||||
message.error('保存失败:' + error)
|
})
|
||||||
}
|
.finally(() => {
|
||||||
useQB.isLoading = false
|
useQB.isLoading = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentRef = ref<HTMLElement | null>(null)
|
const parentRef = ref<HTMLElement | null>(null)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useAccount } from '@/api/account'
|
import { SaveSetting, useAccount } from '@/api/account'
|
||||||
import { EventDataTypes, SettingPointGiftAllowType, Setting_Point } from '@/api/api-models'
|
import { EventDataTypes, SettingPointGiftAllowType, Setting_Point } from '@/api/api-models'
|
||||||
import { QueryPostAPI } from '@/api/query'
|
import { QueryPostAPI } from '@/api/query'
|
||||||
import { POINT_API_URL } from '@/data/constants'
|
import { POINT_API_URL } from '@/data/constants'
|
||||||
@@ -68,12 +68,12 @@ async function updateSettings() {
|
|||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
setting.value.giftPercentMap ??= {}
|
setting.value.giftPercentMap ??= {}
|
||||||
try {
|
try {
|
||||||
const data = await QueryPostAPI(POINT_API_URL + 'update-setting', setting.value)
|
const msg = await SaveSetting('Point', setting.value)
|
||||||
if (data.code == 200) {
|
if (msg) {
|
||||||
message.success('已保存')
|
message.success('已保存')
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
message.error('保存失败: ' + data.message)
|
message.error('保存失败: ' + msg)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
message.error('保存失败: ' + err)
|
message.error('保存失败: ' + err)
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ const songs = computed(() => {
|
|||||||
case QueueSortType.PaymentFist: {
|
case QueueSortType.PaymentFist: {
|
||||||
result = result.OrderByDescending((q) => q.price ?? 0).ThenBy((q) => q.createAt)
|
result = result.OrderByDescending((q) => q.price ?? 0).ThenBy((q) => q.createAt)
|
||||||
}
|
}
|
||||||
|
case QueueSortType.FansMedalFirst: {
|
||||||
|
result = result.OrderByDescending((q) => q.user?.fans_medal_level ?? 0).ThenBy((q) => q.createAt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (settings.value.isReverse) {
|
if (settings.value.isReverse) {
|
||||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
||||||
@@ -161,7 +164,7 @@ onUnmounted(() => {
|
|||||||
<div v-else class="live-request-processing-empty">暂无</div>
|
<div v-else class="live-request-processing-empty">暂无</div>
|
||||||
<div class="live-request-processing-suffix"></div>
|
<div class="live-request-processing-suffix"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="live-request-content" ref="listContainerRef">
|
<div class="live-request-content" ref="listContainerRef">
|
||||||
<template v-if="activeSongs.length > 0">
|
<template v-if="activeSongs.length > 0">
|
||||||
<Vue3Marquee
|
<Vue3Marquee
|
||||||
class="live-request-list"
|
class="live-request-list"
|
||||||
|
|||||||
@@ -53,12 +53,15 @@ const activeItems = computed(() => {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case QueueSortType.GuardFirst: {
|
case QueueSortType.GuardFirst: {
|
||||||
list = list.OrderBy((q) => q.user?.guard_level).ThenBy((q) => q.createAt)
|
list = list.OrderBy((q) => (q.user?.guard_level == 0 || q.user?.guard_level == null ? 4 : q.user.guard_level)).ThenBy((q) => q.createAt)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case QueueSortType.PaymentFist: {
|
case QueueSortType.PaymentFist: {
|
||||||
list = list.OrderByDescending((q) => q.giftPrice ?? 0).ThenBy((q) => q.createAt)
|
list = list.OrderByDescending((q) => q.giftPrice ?? 0).ThenBy((q) => q.createAt)
|
||||||
}
|
}
|
||||||
|
case QueueSortType.FansMedalFirst: {
|
||||||
|
list = list.OrderByDescending((q) => q.user?.fans_medal_level ?? 0).ThenBy((q) => q.createAt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (settings.value.isReverse) {
|
if (settings.value.isReverse) {
|
||||||
list = list.Reverse()
|
list = list.Reverse()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { AddBiliBlackList, SaveEnableFunctions, useAccount } from '@/api/account'
|
import { AddBiliBlackList, SaveEnableFunctions, SaveSetting, useAccount } from '@/api/account'
|
||||||
import {
|
import {
|
||||||
DanmakuUserInfo,
|
DanmakuUserInfo,
|
||||||
EventDataTypes,
|
EventDataTypes,
|
||||||
@@ -172,6 +172,9 @@ const songs = computed(() => {
|
|||||||
case QueueSortType.PaymentFist: {
|
case QueueSortType.PaymentFist: {
|
||||||
result = result.OrderByDescending((q) => q.price ?? 0).ThenBy((q) => q.createAt)
|
result = result.OrderByDescending((q) => q.price ?? 0).ThenBy((q) => q.createAt)
|
||||||
}
|
}
|
||||||
|
case QueueSortType.FansMedalFirst: {
|
||||||
|
result = result.OrderByDescending((q) => q.user?.fans_medal_level ?? 0).ThenBy((q) => q.createAt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (configCanEdit.value ? settings.value.isReverse : isReverse.value) {
|
if (configCanEdit.value ? settings.value.isReverse : isReverse.value) {
|
||||||
return result.Reverse().ToArray()
|
return result.Reverse().ToArray()
|
||||||
@@ -438,17 +441,15 @@ 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 SaveSetting('SongRequest', settings.value)
|
||||||
.then((data) => {
|
.then((msg) => {
|
||||||
if (data.code == 200) {
|
if (msg) {
|
||||||
//message.success('已保存')
|
message.success('已保存')
|
||||||
|
return true
|
||||||
} else {
|
} else {
|
||||||
message.error('保存失败: ' + data.message)
|
message.error('保存失败: ' + msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
|
||||||
message.error('保存失败')
|
|
||||||
})
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
})
|
})
|
||||||
@@ -868,6 +869,7 @@ onUnmounted(() => {
|
|||||||
<NRadioButton :value="QueueSortType.TimeFirst"> 加入时间优先 </NRadioButton>
|
<NRadioButton :value="QueueSortType.TimeFirst"> 加入时间优先 </NRadioButton>
|
||||||
<NRadioButton :value="QueueSortType.PaymentFist"> 付费价格优先 </NRadioButton>
|
<NRadioButton :value="QueueSortType.PaymentFist"> 付费价格优先 </NRadioButton>
|
||||||
<NRadioButton :value="QueueSortType.GuardFirst"> 舰长优先 (按等级) </NRadioButton>
|
<NRadioButton :value="QueueSortType.GuardFirst"> 舰长优先 (按等级) </NRadioButton>
|
||||||
|
<NRadioButton :value="QueueSortType.FansMedalFirst"> 粉丝牌等级优先 </NRadioButton>
|
||||||
</NRadioGroup>
|
</NRadioGroup>
|
||||||
<NCheckbox v-if="configCanEdit" v-model:checked="settings.isReverse" @update:checked="updateSettings">
|
<NCheckbox v-if="configCanEdit" v-model:checked="settings.isReverse" @update:checked="updateSettings">
|
||||||
倒序
|
倒序
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { AddBiliBlackList, SaveEnableFunctions, useAccount } from '@/api/account'
|
import { AddBiliBlackList, SaveEnableFunctions, SaveSetting, useAccount } from '@/api/account'
|
||||||
import {
|
import {
|
||||||
DanmakuUserInfo,
|
DanmakuUserInfo,
|
||||||
EventDataTypes,
|
EventDataTypes,
|
||||||
@@ -163,12 +163,17 @@ const queue = computed(() => {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case QueueSortType.GuardFirst: {
|
case QueueSortType.GuardFirst: {
|
||||||
list = list.OrderBy((q) => q.user?.guard_level).ThenBy((q) => q.createAt)
|
list = list
|
||||||
|
.OrderBy((q) => (q.user?.guard_level == 0 || q.user?.guard_level == null ? 4 : q.user.guard_level))
|
||||||
|
.ThenBy((q) => q.createAt)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case QueueSortType.PaymentFist: {
|
case QueueSortType.PaymentFist: {
|
||||||
list = list.OrderByDescending((q) => q.giftPrice ?? 0).ThenBy((q) => q.createAt)
|
list = list.OrderByDescending((q) => q.giftPrice ?? 0).ThenBy((q) => q.createAt)
|
||||||
}
|
}
|
||||||
|
case QueueSortType.FansMedalFirst: {
|
||||||
|
list = list.OrderByDescending((q) => q.user?.fans_medal_level ?? 0).ThenBy((q) => q.createAt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (configCanEdit.value ? settings.value.isReverse : isReverse.value) {
|
if (configCanEdit.value ? settings.value.isReverse : isReverse.value) {
|
||||||
list = list.Reverse()
|
list = list.Reverse()
|
||||||
@@ -420,17 +425,15 @@ 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 SaveSetting('Queue', settings.value)
|
||||||
.then((data) => {
|
.then((msg) => {
|
||||||
if (data.code == 200) {
|
if (msg) {
|
||||||
message.success('已保存')
|
message.success('已保存')
|
||||||
|
return true
|
||||||
} else {
|
} else {
|
||||||
message.error('保存失败: ' + data.message)
|
message.error('保存失败: ' + msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
|
||||||
message.error('保存失败')
|
|
||||||
})
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
})
|
})
|
||||||
@@ -832,6 +835,7 @@ onUnmounted(() => {
|
|||||||
<NRadioButton :value="QueueSortType.TimeFirst"> 加入时间优先 </NRadioButton>
|
<NRadioButton :value="QueueSortType.TimeFirst"> 加入时间优先 </NRadioButton>
|
||||||
<NRadioButton :value="QueueSortType.PaymentFist"> 付费价格优先 </NRadioButton>
|
<NRadioButton :value="QueueSortType.PaymentFist"> 付费价格优先 </NRadioButton>
|
||||||
<NRadioButton :value="QueueSortType.GuardFirst"> 舰长优先 (按等级) </NRadioButton>
|
<NRadioButton :value="QueueSortType.GuardFirst"> 舰长优先 (按等级) </NRadioButton>
|
||||||
|
<NRadioButton :value="QueueSortType.FansMedalFirst"> 粉丝牌等级优先 </NRadioButton>
|
||||||
</NRadioGroup>
|
</NRadioGroup>
|
||||||
<NCheckbox v-if="configCanEdit" v-model:checked="settings.isReverse" @update:checked="updateSettings">
|
<NCheckbox v-if="configCanEdit" v-model:checked="settings.isReverse" @update:checked="updateSettings">
|
||||||
倒序
|
倒序
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<!-- eslint-disable @typescript-eslint/no-explicit-any -->
|
<!-- eslint-disable @typescript-eslint/no-explicit-any -->
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useAccount } from '@/api/account'
|
import { SaveSetting, useAccount } from '@/api/account'
|
||||||
import { QuestionDisplayAlign, Setting_QuestionDisplay } from '@/api/api-models'
|
import { QuestionDisplayAlign, Setting_QuestionDisplay } from '@/api/api-models'
|
||||||
import { QueryPostAPI } from '@/api/query'
|
import { QueryPostAPI } from '@/api/query'
|
||||||
import QuestionItem from '@/components/QuestionItem.vue'
|
import QuestionItem from '@/components/QuestionItem.vue'
|
||||||
@@ -86,17 +86,15 @@ const setting = computed({
|
|||||||
async function updateSettings() {
|
async function updateSettings() {
|
||||||
if (accountInfo.value) {
|
if (accountInfo.value) {
|
||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
await QueryPostAPI(QUESTION_API_URL + 'update-setting', setting.value)
|
await SaveSetting('QuestionDisplay', setting.value)
|
||||||
.then((data) => {
|
.then((msg) => {
|
||||||
if (data.code == 200) {
|
if (msg) {
|
||||||
//message.success('已保存')
|
message.success('已保存')
|
||||||
|
return true
|
||||||
} else {
|
} else {
|
||||||
message.error('保存失败: ' + data.message)
|
message.error('保存失败: ' + msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
|
||||||
message.error('保存失败')
|
|
||||||
})
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user