diff --git a/.eslintrc.js b/.eslintrc.js index 7204cfd..fb044f3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,14 +2,8 @@ module.exports = { root: true, env: { node: true, - 'vite/config': true, // 添加Vite环境支持 }, - extends: [ - '@vue/typescript/recommended', - 'plugin:vue/vue3-essential', - 'prettier', - '@vue/eslint-config-typescript', - ], + extends: ['@vue/typescript/recommended', 'plugin:vue/vue3-essential', 'prettier', '@vue/eslint-config-typescript'], parserOptions: { ecmaVersion: 'latest', }, @@ -17,6 +11,8 @@ module.exports = { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'vue/component-name-in-template-casing': ['error', 'PascalCase'], + '@typescript-eslint/no-explicit-any': ['off'], + '@typescript-eslint/no-var-requires': ['warn'], }, overrides: [ { diff --git a/package.json b/package.json index d8a46bb..73c1f5c 100644 --- a/package.json +++ b/package.json @@ -8,53 +8,53 @@ "lint": "vite lint" }, "dependencies": { - "@types/node": "^20.11.5", - "@typescript-eslint/eslint-plugin": "^6.19.0", + "@types/node": "^20.11.19", + "@typescript-eslint/eslint-plugin": "^7.0.1", "@vicons/fluent": "^0.12.0", - "@vitejs/plugin-vue": "^5.0.3", + "@vitejs/plugin-vue": "^5.0.4", "@vueuse/core": "^10.7.2", "@vueuse/router": "^10.7.2", - "date-fns": "^3.2.0", + "date-fns": "^3.3.1", "easy-speech": "^2.3.1", - "echarts": "^5.4.3", + "echarts": "^5.5.0", "eslint": "^8.56.0", "eslint-plugin-import": "^2.29.1", - "eslint-plugin-oxlint": "^0.2.1", + "eslint-plugin-oxlint": "^0.2.3", "eslint-plugin-prettier": "^5.1.3", - "fast-xml-parser": "^4.3.3", + "fast-xml-parser": "^4.3.4", "file-saver": "^2.0.5", "grapheme-splitter": "^1.0.4", "html2canvas": "^1.4.1", "linqts": "^1.15.0", "mitt": "^3.0.1", "pinia": "^2.1.7", - "prettier": "^3.2.4", + "prettier": "^3.2.5", "qrcode.vue": "^3.4.1", "queue-typescript": "^1.0.1", "unplugin-vue-markdown": "^0.26.0", "uuid": "^9.0.1", - "vite": "^5.0.12", + "vite": "^5.1.3", "vite-svg-loader": "^5.1.0", - "vue": "^3.4.15", + "vue": "^3.4.19", "vue-echarts": "^6.6.8", "vue-request": "^2.0.4", "vue-router": "^4.2.5", - "vue-turnstile": "^1.0.7", + "vue-turnstile": "^1.0.8", "vue3-aplayer": "^1.7.3", - "vue3-marquee": "^4.2.0-beta.1", + "vue3-marquee": "^4.2.0", "vueuc": "^0.4.58", - "worker-timers": "^7.1.1", + "worker-timers": "^7.1.2", "xlsx": "^0.18.5" }, "devDependencies": { "@types/eslint": "^8.56.2", - "@types/uuid": "^9", - "@typescript-eslint/parser": "^6.19.0", + "@types/uuid": "^9.0.8", + "@typescript-eslint/parser": "^7.0.1", "@vicons/ionicons5": "^0.12.0", "@vitejs/plugin-vue-jsx": "^3.1.0", "@vue/eslint-config-typescript": "^12.0.0", "eslint-config-prettier": "^9.1.0", - "eslint-plugin-vue": "^9.20.1", + "eslint-plugin-vue": "^9.21.1", "naive-ui": "^2.37.3", "stylus": "^0.62.0", "typescript": "^5.3.3" diff --git a/src/api/account.ts b/src/api/account.ts index 76ca34c..66a5e36 100644 --- a/src/api/account.ts +++ b/src/api/account.ts @@ -5,9 +5,11 @@ import { isSameDay } from 'date-fns' import { createDiscreteApi } from 'naive-ui' import { ref } from 'vue' import { APIRoot, AccountInfo, FunctionTypes } from './api-models' +import { useRoute } from 'vue-router' export const ACCOUNT = ref() export const isLoadingAccount = ref(true) +const route = useRoute() const { message } = createDiscreteApi(['message']) const cookie = useLocalStorage('JWT_Token', '') @@ -40,7 +42,8 @@ export async function GetSelfAccount() { } export function UpdateAccountLoop() { setInterval(() => { - if (ACCOUNT.value) { + if (ACCOUNT.value && route?.name != 'question-display') { + // 防止在问题详情页刷新 GetSelfAccount() } }, 60 * 1000) @@ -93,7 +96,7 @@ export async function DelBiliBlackList(id: number): Promise> { id: id, }) } -export function downloadConfigDirect(name: string) { +export function downloadConfigDirect(name: string) { return QueryGetAPI(VTSURU_API_URL + 'get-config', { name: name, }) diff --git a/src/api/api-models.ts b/src/api/api-models.ts index eefc1ab..8a70cf2 100644 --- a/src/api/api-models.ts +++ b/src/api/api-models.ts @@ -91,6 +91,7 @@ export interface UserSetting { songRequest: Setting_SongRequest queue: Setting_Queue point: Setting_Point + questionDisplay: Setting_QuestionDisplay enableFunctions: FunctionTypes[] @@ -169,6 +170,32 @@ export interface Setting_Point { giftPointPercent: number // double maps to number in TypeScript giftAllowType: SettingPointGiftAllowType } +export interface Setting_QuestionDisplay { + font?: string // Optional string, with a maximum length of 30 characters + nameFont: string // Optional string, with a maximum length of 30 characters + fontSize: number // Default is 20 + fontWeight: number + nameFontSize: number // Default is 20 + lineSpacing: number // Default is 0, 行间距 + fontColor?: string // Optional string, must exactly be 6 characters long + nameFontColor?: string // Optional string, must exactly be 6 characters long + nameFontWeight?: number + backgroundColor?: string // Optional string, must exactly be 6 characters long + showUserName: boolean // Default is true + align: QuestionDisplayAlign // Default is QuestionDisplayAlign.Left, 对齐 + showImage: boolean // Default is false + + borderColor?: string + borderWidth?: number + + currentQuestion?: number +} + +export enum QuestionDisplayAlign { + Left, + Right, + Center, +} export enum SettingPointGiftAllowType { All, WhiteList, diff --git a/src/components/QuestionItem.vue b/src/components/QuestionItem.vue new file mode 100644 index 0000000..bfa9884 --- /dev/null +++ b/src/components/QuestionItem.vue @@ -0,0 +1,51 @@ + + + diff --git a/src/components/QuestionItems.vue b/src/components/QuestionItems.vue new file mode 100644 index 0000000..0e04f82 --- /dev/null +++ b/src/components/QuestionItems.vue @@ -0,0 +1,24 @@ + + + diff --git a/src/mitt.ts b/src/mitt.ts index 9e1fa6f..689b136 100644 --- a/src/mitt.ts +++ b/src/mitt.ts @@ -9,9 +9,7 @@ declare type MittType = { onMusicRequestPlayerEnded: { music: Music } - onMusicRequestPlayNextWaitingMusic: { - - } + onMusicRequestPlayNextWaitingMusic: never }; // 类型 const emitter: Emitter = mitt() diff --git a/src/router/index.ts b/src/router/index.ts index 36fea25..fe88bf9 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -5,6 +5,7 @@ import manage from './manage' import user from './user' import obs from './obs' import open_live from './open_live' +import singlePage from './singlePage' const routes: Array = [ { @@ -96,6 +97,7 @@ const routes: Array = [ title: '页面不存在', }, }, + ...singlePage, ] const router = createRouter({ @@ -106,7 +108,7 @@ router.beforeEach((to, from, next) => { useLoadingBarStore().loadingBar?.start() next() }) -router.afterEach((to, from) => { +router.afterEach(() => { const loadingBar = useLoadingBarStore().loadingBar loadingBar?.finish() }) diff --git a/src/router/obs.ts b/src/router/obs.ts index f0b3ff0..b7cb7ae 100644 --- a/src/router/obs.ts +++ b/src/router/obs.ts @@ -1,38 +1,46 @@ export default { - path: '/obs', - name: 'obs', - children: [ - { - path: 'live-lottery', - name: 'obs-live-lottery', - component: () => import('@/views/obs/LiveLotteryOBS.vue'), - meta: { - title: '直播抽奖', - }, + path: '/obs', + name: 'obs', + children: [ + { + path: 'live-lottery', + name: 'obs-live-lottery', + component: () => import('@/views/obs/LiveLotteryOBS.vue'), + meta: { + title: '直播抽奖', }, - { - path: 'song-request', - name: 'obs-song-request', - component: () => import('@/views/obs/SongRequestOBS.vue'), - meta: { - title: '弹幕点歌 (歌势', - }, + }, + { + path: 'song-request', + name: 'obs-song-request', + component: () => import('@/views/obs/SongRequestOBS.vue'), + meta: { + title: '弹幕点歌 (歌势', }, - { - path: 'queue', - name: 'obs-queue', - component: () => import('@/views/obs/QueueOBS.vue'), - meta: { - title: '弹幕排队', - }, + }, + { + path: 'queue', + name: 'obs-queue', + component: () => import('@/views/obs/QueueOBS.vue'), + meta: { + title: '弹幕排队', }, - { - path: 'music-request', - name: 'obs-music-request', - component: () => import('@/views/obs/MusicRequestOBS.vue'), - meta: { - title: '弹幕排队 (播放', - }, + }, + { + path: 'music-request', + name: 'obs-music-request', + component: () => import('@/views/obs/MusicRequestOBS.vue'), + meta: { + title: '弹幕排队 (播放', }, - ], - } \ No newline at end of file + }, + { + path: 'question-display', + name: 'obs-question-display', + component: () => import('@/views/obs/QuestionDisplayOBS.vue'), + meta: { + title: '棉花糖展示', + }, + }, + ], +} diff --git a/src/router/singlePage.ts b/src/router/singlePage.ts new file mode 100644 index 0000000..97c37f7 --- /dev/null +++ b/src/router/singlePage.ts @@ -0,0 +1,10 @@ +export default [ + { + path: '/question-display', + name: 'question-display', + component: () => import('@/views/single/QuestionDisplay.vue'), + meta: { + title: '棉花糖展示页', + }, + }, +] diff --git a/src/store/useAuthStore.ts b/src/store/useAuthStore.ts index 4a816c0..215ee70 100644 --- a/src/store/useAuthStore.ts +++ b/src/store/useAuthStore.ts @@ -106,7 +106,7 @@ export const useAuthStore = defineStore('BiliAuth', () => { return [] } try { - var resp = await QueryGetAPI(POINT_API_URL + 'get-goods', { + const resp = await QueryGetAPI(POINT_API_URL + 'get-goods', { id: id, }) if (resp.code == 200) { diff --git a/src/store/useQuestionBox.ts b/src/store/useQuestionBox.ts new file mode 100644 index 0000000..41e7c0c --- /dev/null +++ b/src/store/useQuestionBox.ts @@ -0,0 +1,245 @@ +import { useAccount } from '@/api/account' +import { QAInfo } from '@/api/api-models' +import { QueryGetAPI, QueryPostAPI } from '@/api/query' +import { ACCOUNT_API_URL, QUESTION_API_URL } from '@/data/constants' +import { List } from 'linqts' +import { useMessage } from 'naive-ui' +import { defineStore } from 'pinia' +import { computed, ref } from 'vue' + +export const useQuestionBox = defineStore('QuestionBox', () => { + const isLoading = ref(false) + const isRepling = ref(false) + const isChangingPublic = ref(false) + + const accountInfo = useAccount() + + const recieveQuestions = ref([]) + const sendQuestions = ref([]) + + const onlyFavorite = ref(false) + const onlyPublic = ref(false) + const onlyUnread = ref(false) + + const recieveQuestionsFiltered = computed(() => { + const result = recieveQuestions.value.filter((q) => { + /*if (q.id == displayQuestion.value?.id) { + return false + }*/ + return ( + (q.isFavorite || !onlyFavorite.value) && (q.isPublic || !onlyPublic.value) && (!q.isReaded || !onlyUnread.value) + ) + }) + return result + //displayQuestion排在最前面 + //return displayQuestion.value ? [displayQuestion.value, ...result] : result + }) + const currentQuestion = ref() + const displayQuestion = ref() + + let isRevieveGetted = false + let isSendGetted = false + + const message = useMessage() + + async function GetRecieveQAInfo() { + isLoading.value = true + await QueryGetAPI(QUESTION_API_URL + 'get-recieve') + .then((data) => { + if (data.code == 200) { + if (data.data.length > 0) { + recieveQuestions.value = new List(data.data) + .OrderBy((d) => d.isReaded) + //.ThenByDescending(d => d.isFavorite) + .ThenByDescending((d) => d.sendAt) + .ToArray() + const displayId = accountInfo.value?.settings.questionDisplay.currentQuestion + if (displayId && displayQuestion.value?.id != displayId) { + displayQuestion.value = recieveQuestions.value.find((q) => q.id == displayId) + } + } + message.success('共收取 ' + data.data.length + ' 条提问') + isRevieveGetted = true + } else { + message.error(data.message) + } + }) + .catch((err) => { + message.error('发生错误: ' + err) + }) + .finally(() => { + isLoading.value = false + }) + } + async function GetSendQAInfo() { + isLoading.value = true + await QueryGetAPI(QUESTION_API_URL + 'get-send') + .then((data) => { + if (data.code == 200) { + sendQuestions.value = data.data + message.success('共发送 ' + data.data.length + ' 条提问') + } else { + message.error(data.message) + } + }) + .catch((err) => { + message.error('发生错误') + }) + .finally(() => { + isLoading.value = false + }) + } + async function reply(id: number, msg: string) { + isRepling.value = true + await QueryPostAPI(QUESTION_API_URL + 'reply', { + Id: id, + Message: msg, + }) + .then((data) => { + if (data.code == 200) { + var index = recieveQuestions.value.findIndex((q) => q.id == id) + if (index > -1) { + recieveQuestions.value[index] = data.data + } + message.success('回复成功') + currentQuestion.value = undefined + //replyModalVisiable.value = false + } else { + message.error('发送失败: ' + data.message) + } + }) + .catch((err) => { + message.error('发送失败') + }) + .finally(() => { + isRepling.value = false + }) + } + async function read(question: QAInfo, read: boolean) { + await QueryGetAPI(QUESTION_API_URL + 'read', { + id: question.id, + read: read ? 'true' : 'false', + }) + .then((data) => { + if (data.code == 200) { + question.isReaded = read + if (read && displayQuestion.value?.id == question.id) { + setCurrentQuestion(question) //取消设为当前展示的问题 + } + } else { + message.error('修改失败: ' + data.message) + } + }) + .catch((err) => { + message.error('修改失败') + }) + } + async function favorite(question: QAInfo, fav: boolean) { + await QueryGetAPI(QUESTION_API_URL + 'favorite', { + id: question.id, + favorite: fav, + }) + .then((data) => { + if (data.code == 200) { + question.isFavorite = fav + } else { + message.error('修改失败: ' + data.message) + } + }) + .catch((err) => { + message.error('修改失败') + }) + } + async function setPublic(pub: boolean) { + isChangingPublic.value = true + await QueryGetAPI(QUESTION_API_URL + 'public', { + id: currentQuestion.value?.id, + public: pub, + }) + .then((data) => { + if (data.code == 200) { + if (currentQuestion.value) currentQuestion.value.isPublic = pub + message.success('已修改公开状态') + } else { + message.error('修改失败: ' + data.message) + } + }) + .catch((err) => { + message.error('修改失败') + }) + .finally(() => { + isChangingPublic.value = false + }) + } + async function blacklist(question: QAInfo) { + await QueryGetAPI(ACCOUNT_API_URL + 'black-list/add', { + id: question.sender.id, + }) + .then(async (data) => { + if (data.code == 200) { + await QueryGetAPI(QUESTION_API_URL + 'del', { + id: question.id, + }).then((data) => { + if (data.code == 200) { + message.success('已拉黑 ' + question.sender.name) + } else { + message.error('修改失败: ' + data.message) + } + }) + } else { + message.error('拉黑失败: ' + data.message) + } + }) + .catch((err) => { + message.error('拉黑失败') + }) + } + async function setCurrentQuestion(item: QAInfo) { + const isCurrent = displayQuestion.value?.id == item.id + if (!isCurrent) { + displayQuestion.value = item + } else { + displayQuestion.value = undefined + } + try { + const data = await QueryGetAPI( + QUESTION_API_URL + 'set-current', + isCurrent + ? null + : { + id: item.id, + }, + ) + if (data.code == 200) { + //message.success('设置成功') + } else { + message.error('设置失败: ' + data.message) + } + } catch (err) { + message.error('设置失败:' + err) + } + } + + return { + currentQuestion, + isLoading, + isRevieveGetted, + isRepling, + isChangingPublic, + recieveQuestions, + recieveQuestionsFiltered, + sendQuestions, + onlyFavorite, + onlyPublic, + onlyUnread, + displayQuestion, + GetRecieveQAInfo, + GetSendQAInfo, + reply, + read, + favorite, + setPublic, + blacklist, + setCurrentQuestion, + } +}) diff --git a/src/views/AboutView.vue b/src/views/AboutView.vue index 907cc9a..60639a1 100644 --- a/src/views/AboutView.vue +++ b/src/views/AboutView.vue @@ -31,6 +31,7 @@ import { NButton, NCard, NDivider, NLayoutContent, NSpace, NText, NTimeline, NTi 更新日志 + diff --git a/src/views/ManageLayout.vue b/src/views/ManageLayout.vue index 887c86e..3d3dcf1 100644 --- a/src/views/ManageLayout.vue +++ b/src/views/ManageLayout.vue @@ -544,7 +544,7 @@ onMounted(() => { - + diff --git a/src/views/ViewerLayout.vue b/src/views/ViewerLayout.vue index 03ddbc4..66fc1a3 100644 --- a/src/views/ViewerLayout.vue +++ b/src/views/ViewerLayout.vue @@ -59,7 +59,7 @@ const menuOptions = ref() async function RequestBiliUserData() { await fetch(FETCH_API + `https://account.bilibili.com/api/member/getCardByMid?mid=${userInfo.value?.biliId}`).then( async (respone) => { - let data = await respone.json() + const data = await respone.json() if (data.code == 0) { biliUserInfo.value = data.card } else { diff --git a/src/views/manage/LotteryView.vue b/src/views/manage/LotteryView.vue index 1d081c2..ae75f2e 100644 --- a/src/views/manage/LotteryView.vue +++ b/src/views/manage/LotteryView.vue @@ -83,7 +83,7 @@ const showModal = ref(false) const inputDynamic = ref() const inputDynamicId = computed(() => { try { - var id = BigInt(inputDynamic.value ?? '') + const id = BigInt(inputDynamic.value ?? '') return id } catch { try { diff --git a/src/views/manage/QuestionBoxManageView.vue b/src/views/manage/QuestionBoxManageView.vue index 8abb35c..c1515dd 100644 --- a/src/views/manage/QuestionBoxManageView.vue +++ b/src/views/manage/QuestionBoxManageView.vue @@ -2,18 +2,19 @@ import { copyToClipboard, downloadImage } from '@/Utils' import { SaveAccountSettings, useAccount } from '@/api/account' import { QAInfo } from '@/api/api-models' -import { QueryGetAPI, QueryPostAPI } from '@/api/query' -import { ACCOUNT_API_URL, QUESTION_API_URL } from '@/data/constants' +import { QueryGetAPI } from '@/api/query' +import { QUESTION_API_URL } from '@/data/constants' import router from '@/router' -import { Heart, HeartOutline } from '@vicons/ionicons5' +import { Heart, HeartOutline, SwapHorizontal } from '@vicons/ionicons5' import { saveAs } from 'file-saver' import html2canvas from 'html2canvas' -import { List } from 'linqts' import { + NAffix, NButton, NCard, NCheckbox, NDivider, + NFlex, NIcon, NImage, NInput, @@ -21,8 +22,10 @@ import { NList, NListItem, NModal, + NScrollbar, NSpace, NSpin, + NSplit, NSwitch, NTabPane, NTabs, @@ -35,195 +38,42 @@ import { import QrcodeVue from 'qrcode.vue' import { computed, onMounted, ref } from 'vue' import { useRoute } from 'vue-router' +import QuestionDisplay from './QuestionDisplaySettings.vue' +import { useElementSize } from '@vueuse/core' +import QuestionItem from '@/components/QuestionItems.vue' +import { ArrowCircleRight12Filled } from '@vicons/fluent' +import { useQuestionBox } from '@/store/useQuestionBox' const accountInfo = useAccount() const route = useRoute() - -const recieveQuestions = ref([]) -const recieveQuestionsFiltered = computed(() => { - return recieveQuestions.value.filter((q) => { - return ( - (q.isFavorite || !onlyFavorite.value) && (q.isPublic || !onlyPublic.value) && (!q.isReaded || !onlyUnread.value) - ) - }) -}) -const sendQuestions = ref([]) const message = useMessage() +const useQB = useQuestionBox() + const selectedTabItem = ref(route.query.send ? '1' : '0') -const isRepling = ref(false) -const onlyFavorite = ref(false) -const onlyPublic = ref(false) -const onlyUnread = ref(false) -const isLoading = ref(true) -const isChangingPublic = ref(false) const replyModalVisiable = ref(false) const shareModalVisiable = ref(false) -const currentQuestion = ref() const replyMessage = ref() +const showSettingCard = ref(true) + const shareCardRef = ref() const shareUrl = computed(() => 'https://vtsuru.live/user/' + accountInfo.value?.name + '/question-box') -async function GetRecieveQAInfo() { - isLoading.value = true - await QueryGetAPI(QUESTION_API_URL + 'get-recieve') - .then((data) => { - if (data.code == 200) { - if (data.data.length > 0) { - recieveQuestions.value = new List(data.data) - .OrderBy((d) => d.isReaded) - //.ThenByDescending(d => d.isFavorite) - .ThenByDescending((d) => d.sendAt) - .ToArray() - } - message.success('共收取 ' + data.data.length + ' 条提问') - isRevieveGetted = true - } else { - message.error(data.message) - } - }) - .catch((err) => { - message.error('发生错误') - }) - .finally(() => { - isLoading.value = false - }) -} -async function GetSendQAInfo() { - isLoading.value = true - await QueryGetAPI(QUESTION_API_URL + 'get-send') - .then((data) => { - if (data.code == 200) { - sendQuestions.value = data.data - message.success('共发送 ' + data.data.length + ' 条提问') - } else { - message.error(data.message) - } - }) - .catch((err) => { - message.error('发生错误') - }) - .finally(() => { - isLoading.value = false - }) -} -async function reply() { - isRepling.value = true - await QueryPostAPI(QUESTION_API_URL + 'reply', { - Id: currentQuestion.value?.id, - Message: replyMessage.value, - }) - .then((data) => { - if (data.code == 200) { - var index = recieveQuestions.value.findIndex((q) => q.id == currentQuestion.value?.id) - if (index > -1) { - recieveQuestions.value[index] = data.data - } - message.success('回复成功') - currentQuestion.value = undefined - replyModalVisiable.value = false - } else { - message.error('发送失败: ' + data.message) - } - }) - .catch((err) => { - message.error('发送失败') - }) - .finally(() => { - isRepling.value = false - }) -} -async function read(question: QAInfo, read: boolean) { - await QueryGetAPI(QUESTION_API_URL + 'read', { - id: question.id, - read: read ? 'true' : 'false', - }) - .then((data) => { - if (data.code == 200) { - question.isReaded = read - } else { - message.error('修改失败: ' + data.message) - } - }) - .catch((err) => { - message.error('修改失败') - }) -} -async function favorite(question: QAInfo, fav: boolean) { - await QueryGetAPI(QUESTION_API_URL + 'favorite', { - id: question.id, - favorite: fav, - }) - .then((data) => { - if (data.code == 200) { - question.isFavorite = fav - } else { - message.error('修改失败: ' + data.message) - } - }) - .catch((err) => { - message.error('修改失败') - }) -} -async function setPublic(pub: boolean) { - isChangingPublic.value = true - await QueryGetAPI(QUESTION_API_URL + 'public', { - id: currentQuestion.value?.id, - public: pub, - }) - .then((data) => { - if (data.code == 200) { - if (currentQuestion.value) currentQuestion.value.isPublic = pub - message.success('已修改公开状态') - } else { - message.error('修改失败: ' + data.message) - } - }) - .catch((err) => { - message.error('修改失败') - }) - .finally(() => { - isChangingPublic.value = false - }) -} -async function blacklist(question: QAInfo) { - await QueryGetAPI(ACCOUNT_API_URL + 'black-list/add', { - id: question.sender.id, - }) - .then(async (data) => { - if (data.code == 200) { - await QueryGetAPI(QUESTION_API_URL + 'del', { - id: question.id, - }).then((data) => { - if (data.code == 200) { - message.success('已拉黑 ' + question.sender.name) - } else { - message.error('修改失败: ' + data.message) - } - }) - } else { - message.error('拉黑失败: ' + data.message) - } - }) - .catch((err) => { - message.error('拉黑失败') - }) -} let isRevieveGetted = false let isSendGetted = false async function onTabChange(value: string) { if (value == '0' && !isRevieveGetted) { - await GetRecieveQAInfo() + await useQB.GetRecieveQAInfo() isRevieveGetted = true } else if (value == '1' && !isSendGetted) { - await GetSendQAInfo() + await useQB.GetSendQAInfo() isSendGetted = true } } function onOpenModal(question: QAInfo) { - currentQuestion.value = question + useQB.currentQuestion = question replyMessage.value = question.answer?.message replyModalVisiable.value = true } @@ -258,7 +108,7 @@ function saveQRCode() { } async function saveSettings() { try { - isLoading.value = true + useQB.isLoading = true const data = await SaveAccountSettings() if (data.code == 200) { message.success('保存成功') @@ -268,15 +118,21 @@ async function saveSettings() { } catch (error) { message.error('保存失败:' + error) } - isLoading.value = false + useQB.isLoading = false } +const parentRef = ref(null) + onMounted(() => { if (selectedTabItem.value == '0') { - GetRecieveQAInfo() + useQB.GetRecieveQAInfo() } else { - GetSendQAInfo() + useQB.GetSendQAInfo() } + + useQB.displayQuestion = useQB.recieveQuestions.find( + (s) => s.id == accountInfo.value?.settings.questionDisplay.currentQuestion, + ) }) @@ -286,89 +142,63 @@ onMounted(() => { 分享 - + - 只显示收藏 - 只显示公开 - 只显示未读 - - - - - + + - + - +