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

@@ -1,13 +1,11 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI
name: Bun CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:

View File

@@ -1,3 +1,6 @@
import { ExtendedDock24Filled } from "@vicons/fluent"
import { UserConsumptionSetting } from "./models/consumption"
export interface APIRoot<T> {
code: number
message: string
@@ -58,6 +61,7 @@ export interface AccountInfo extends UserInfo {
biliVerifyCode?: string
bindEmail?: string
settings: UserSetting
consumptionSetting: UserConsumptionSetting
token: string
biliAuthCode?: string

View File

@@ -0,0 +1,20 @@
export enum ConsumptionTypes{
DanmakuStorage,
}
export interface IDeductionSetting {
isEnabled: boolean
}
export interface UserConsumptionSetting {
danmakuStorage: DanmakuStorageDeductionSetting
}
export enum DeductionStorageType {
Time,
Count
}
export interface DanmakuStorageDeductionSetting extends IDeductionSetting {
storageType: DeductionStorageType
isUnlimited: boolean
limitDays: number
limitCount: number
}

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

View File

@@ -287,19 +287,6 @@ onUnmounted(() => {
<template>
<NFlex justify="center" align="center" vertical>
<NAlert type="warning" title="2024.2.26">
近期逸站对开放平台直播弹幕流进行了极为严格的限制, 目前本站服务器只能连接个位数的直播间, 这使得在不使用
<NButton tag="a" href="https://www.yuque.com/megghy/dez70g/vfvcyv3024xvaa1p" target="_blank" type="primary" text>
VtsuruEventFetcher
</NButton>
的情况下获取弹幕数据几乎不可能实现.
<br />
在这种情况下建议有相关功能需求的用户 (如直播记录, 积分等) 部署
<NButton tag="a" href="https://www.yuque.com/megghy/dez70g/vfvcyv3024xvaa1p" target="_blank" type="primary" text>
VtsuruEventFetcher
</NButton>
以获得完整的功能体验
</NAlert>
<NTabs type="segment" animated v-if="accountInfo" style="width: 100%;">
<NTabPane name="info" tab="个人信息" style="width: 100%;" display-directive="show:lazy">
<NFlex justify="center" align="center">

View File

@@ -1,12 +1,26 @@
<script setup lang="ts">
import { useAccount } from '@/api/account';
import { onMounted } from 'vue';
import { ConsumptionTypes } from '@/api/models/consumption';
import { NFlex, NIcon, NLayout, NLayoutSider, NMenu, NTabPane, NTabs } from 'naive-ui';
import { h, onMounted } from 'vue';
import { useConsumptionSettingStore } from '@/store/usePaymentSettingStore';
import { CheckmarkCircle24Filled } from '@vicons/fluent';
const accountInfo = useAccount()
const useConsumption = useConsumptionSettingStore()
const { } = defineProps<{
}>()
const enabledIcon = h(NIcon, { component: CheckmarkCircle24Filled, color: 'lightgrey' })
const disabledIcon = h(NIcon, { component: CheckmarkCircle24Filled, color: 'red' })
const tabDisplay = (type: ConsumptionTypes) => {
const setting = useConsumption.GetSetting(type)
return h(NFlex, {}, () => [
h(NIcon, { component: setting.isEnabled ? enabledIcon : disabledIcon, }),
h('span', {}, setting.isEnabled ? '已启用' : '未启用'),
])
}
async function getAccountPaymentSettings() {
try {
@@ -22,5 +36,11 @@ onMounted(() => {
</script>
<template>
WIP...
<NTabs animated type="line">
<NTabPane name="弹幕储存" tab="弹幕储存">
<template #tab>
<component :is="tabDisplay(ConsumptionTypes.DanmakuStorage)" />
</template>
</NTabPane>
</NTabs>
</template>