From 5960604867b2e611d42872ff3124616eb07eb240 Mon Sep 17 00:00:00 2001 From: KUN1007 Date: Wed, 18 Oct 2023 19:30:51 +0800 Subject: [PATCH] feat: non moe page --- src/api/index.ts | 2 + src/api/non-moe/index.ts | 14 +++++ src/api/non-moe/types/nonMoe.ts | 18 +++++++ src/store/modules/nonMoe.ts | 28 ++++++++++ src/store/modules/ranking.ts | 1 - .../Home/content/aside/components/Aside.vue | 6 +-- src/views/balance/Balance.vue | 2 +- src/views/balance/components/Form.vue | 4 +- src/views/non-moe/NonMoe.vue | 50 ++++++++++++++++-- src/views/non-moe/components/Log.vue | 26 +++++++--- src/views/non-moe/components/log.ts | 52 ------------------- 11 files changed, 133 insertions(+), 70 deletions(-) create mode 100644 src/api/non-moe/index.ts create mode 100644 src/api/non-moe/types/nonMoe.ts create mode 100644 src/store/modules/nonMoe.ts delete mode 100644 src/views/non-moe/components/log.ts diff --git a/src/api/index.ts b/src/api/index.ts index 944213c1..28396faa 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -8,6 +8,7 @@ export * from './edit/types/edit' export * from './home/types/home' export * from './user/types/user' export * from './login/types/login' +export * from './non-moe/types/nonMoe' export * from './ranking/types/ranking' export * from './topic/types' export * from './update-log/types/updateLog' @@ -18,6 +19,7 @@ export * from './edit' export * from './home' export * from './user' export * from './login' +export * from './non-moe' export * from './ranking' export * from './topic' export * from './update-log' diff --git a/src/api/non-moe/index.ts b/src/api/non-moe/index.ts new file mode 100644 index 00000000..07e26843 --- /dev/null +++ b/src/api/non-moe/index.ts @@ -0,0 +1,14 @@ +import { fetchGet } from '@/utils/request' +import * as NonMoe from './types/nonMoe' +import objectToQueryParams from '@/utils/objectToQueryParams' + +// 获取不萌记录 +export async function getNonMoeLogsApi( + request: NonMoe.NonMoeLogRequestData +): Promise { + const queryParams = objectToQueryParams(request) + const url = `/non-moe/logs?${queryParams}` + + const response = fetchGet(url) + return response +} diff --git a/src/api/non-moe/types/nonMoe.ts b/src/api/non-moe/types/nonMoe.ts new file mode 100644 index 00000000..4f9e50e1 --- /dev/null +++ b/src/api/non-moe/types/nonMoe.ts @@ -0,0 +1,18 @@ +type SortOrder = 'asc' | 'desc' + +export interface NonMoeLogRequestData { + page: number + limit: number + sortOrder: SortOrder +} + +export interface NonMoeLog { + nid: number + uid: number + name: string + description: string + time: number + result: string +} + +export type NonMoeGetLogsResponseData = KUNGalgameResponseData diff --git a/src/store/modules/nonMoe.ts b/src/store/modules/nonMoe.ts new file mode 100644 index 00000000..a13d8c6e --- /dev/null +++ b/src/store/modules/nonMoe.ts @@ -0,0 +1,28 @@ +import { defineStore } from 'pinia' + +import type { NonMoeLogRequestData, NonMoeGetLogsResponseData } from '@/api' + +import { getNonMoeLogsApi } from '@/api' + +export const useKUNGalgameNonMoeStore = defineStore({ + id: 'KUNGalgameNonMoe', + // 不持久 + persist: false, + state: (): NonMoeLogRequestData => ({ + page: 1, + limit: 30, + sortOrder: 'desc', + }), + getters: {}, + actions: { + // 获取不萌记录 + async getLogs(): Promise { + const requestData: NonMoeLogRequestData = { + page: this.page, + limit: this.limit, + sortOrder: this.sortOrder, + } + return await getNonMoeLogsApi(requestData) + }, + }, +}) diff --git a/src/store/modules/ranking.ts b/src/store/modules/ranking.ts index b8525f2f..d924606f 100644 --- a/src/store/modules/ranking.ts +++ b/src/store/modules/ranking.ts @@ -1,4 +1,3 @@ -// 评论的临时数据,用于组件间传输 import { defineStore } from 'pinia' import type { diff --git a/src/views/Home/content/aside/components/Aside.vue b/src/views/Home/content/aside/components/Aside.vue index f9c5d448..bc5897e3 100644 --- a/src/views/Home/content/aside/components/Aside.vue +++ b/src/views/Home/content/aside/components/Aside.vue @@ -7,9 +7,9 @@ import asideItem from './asideItem'
- {{ - $tm(`mainPage.asideActive['${kun.name}']`) - }} + + {{ $tm(`mainPage.asideActive['${kun.name}']`) }} +
diff --git a/src/views/balance/Balance.vue b/src/views/balance/Balance.vue index 90ecc26f..effd7cd8 100644 --- a/src/views/balance/Balance.vue +++ b/src/views/balance/Balance.vue @@ -82,7 +82,7 @@ onMounted(async () => { statement.profitLoss >= 0 ? $tm('balance.surplusAmount') : $tm('balance.deficitAmount') - }}: {{ statement.profitLoss }} CNY + }}: {{ statement.profitLoss }} USDT diff --git a/src/views/balance/components/Form.vue b/src/views/balance/components/Form.vue index 81ffe43d..5b5acbfe 100644 --- a/src/views/balance/components/Form.vue +++ b/src/views/balance/components/Form.vue @@ -30,13 +30,13 @@ const { isIncome, incomeData, expenditureData, statement } = toRefs(props)
{{ $tm(`balance.totalIncome`) }}: {{ statement.totalIncome }} - CNY + USDT
{{ $tm(`balance.totalExpenditure`) }}: {{ statement.totalExpenditure }} - CNY + USDT
diff --git a/src/views/non-moe/NonMoe.vue b/src/views/non-moe/NonMoe.vue index e96ba9a8..c49fac54 100644 --- a/src/views/non-moe/NonMoe.vue +++ b/src/views/non-moe/NonMoe.vue @@ -1,6 +1,31 @@