fix message provider get

This commit is contained in:
2024-10-31 14:17:40 +08:00
parent 51897133a7
commit 392a577a7e
7 changed files with 90 additions and 20 deletions

View File

@@ -0,0 +1,41 @@
import { useAccount } from '@/api/account'
import { ConsumptionTypes, IDeductionSetting, UserConsumptionSetting } from '@/api/models/consumption'
import { QueryPostAPIWithParams } from '@/api/query'
import { ACCOUNT_API_URL } from '@/data/constants'
import { defineStore } from 'pinia'
import { computed } from 'vue'
export const useConsumptionSettingStore = defineStore(
'consumptionSetting',
() => {
const accountInfo = useAccount()
const consumptionSetting = computed<UserConsumptionSetting>(() => {
return accountInfo.value.consumptionSetting
})
const consumptionTypeMap = {
[ConsumptionTypes.DanmakuStorage]: {
name: '弹幕存储',
key: 'danmakuStorage'
}
}
async function UpdateConsumptionSetting(
type: ConsumptionTypes,
value: unknown
) {
return await QueryPostAPIWithParams(
ACCOUNT_API_URL + 'update-consumption-setting',
{
type: type
},
value
)
}
function GetSetting(type: ConsumptionTypes) {
// @ts-expect-error 直接从对象获取key
return consumptionSetting.value[consumptionTypeMap[type].key] as IDeductionSetting
}
return { consumptionSetting, consumptionTypeMap, UpdateConsumptionSetting, GetSetting }
}
)

View File

@@ -50,7 +50,7 @@ export const useQuestionBox = defineStore('QuestionBox', () => {
let isRevieveGetted = false
//const isSendGetted = false
const message = useMessage()
const message = window.$message
async function GetRecieveQAInfo() {
isLoading.value = true