mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
improve setting save
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
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 { QueryGetAPI } from '@/api/query'
|
||||
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')
|
||||
}
|
||||
async function saveSettings() {
|
||||
try {
|
||||
useQB.isLoading = true
|
||||
const data = await SaveAccountSettings()
|
||||
if (data.code == 200) {
|
||||
message.success('保存成功')
|
||||
} else {
|
||||
message.error('保存失败: ' + data.message)
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('保存失败:' + error)
|
||||
}
|
||||
useQB.isLoading = false
|
||||
useQB.isLoading = true
|
||||
await SaveSetting('QuestionBox', accountInfo.value.settings.questionBox)
|
||||
.then((msg) => {
|
||||
if (msg) {
|
||||
message.success('已保存')
|
||||
return true
|
||||
} else {
|
||||
message.error('保存失败: ' + msg)
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
useQB.isLoading = false
|
||||
})
|
||||
}
|
||||
|
||||
const parentRef = ref<HTMLElement | null>(null)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<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 { QueryPostAPI } from '@/api/query'
|
||||
import { POINT_API_URL } from '@/data/constants'
|
||||
@@ -68,12 +68,12 @@ async function updateSettings() {
|
||||
isLoading.value = true
|
||||
setting.value.giftPercentMap ??= {}
|
||||
try {
|
||||
const data = await QueryPostAPI(POINT_API_URL + 'update-setting', setting.value)
|
||||
if (data.code == 200) {
|
||||
const msg = await SaveSetting('Point', setting.value)
|
||||
if (msg) {
|
||||
message.success('已保存')
|
||||
return true
|
||||
} else {
|
||||
message.error('保存失败: ' + data.message)
|
||||
message.error('保存失败: ' + msg)
|
||||
}
|
||||
} catch (err) {
|
||||
message.error('保存失败: ' + err)
|
||||
|
||||
Reference in New Issue
Block a user