feat: get expenditure and income
This commit is contained in:
parent
f385fb233c
commit
9c4ce78f5e
|
@ -8,6 +8,10 @@
|
|||
href="/src/assets/images/favicon.png"
|
||||
/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta
|
||||
name="description"
|
||||
content="The CUTEST Visual Novel Forum!世界上最萌的 Galgame 论坛. Topic, Technique. NO ADs Forever. Free Forever"
|
||||
/>
|
||||
<title>KUNGalgame</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
26
src/api/balance/index.ts
Normal file
26
src/api/balance/index.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { fetchGet } from '@/utils/request'
|
||||
import type * as Balance from './types/balance'
|
||||
// 将对象转为请求参数的函数
|
||||
import objectToQueryParams from '@/utils/objectToQueryParams'
|
||||
|
||||
// 获取 income
|
||||
export async function getIncomeApi(
|
||||
requestData: Balance.BalanceIncomeRequestData
|
||||
): Promise<Balance.BalanceIncomeResponseData> {
|
||||
const queryParams = objectToQueryParams(requestData)
|
||||
const response = await fetchGet<Balance.BalanceIncomeResponseData>(
|
||||
`/balance/income?${queryParams}`
|
||||
)
|
||||
return response
|
||||
}
|
||||
|
||||
// 获取 expenditure
|
||||
export async function getExpenditureApi(
|
||||
requestData: Balance.BalanceExpenditureRequestData
|
||||
): Promise<Balance.BalanceExpenditureResponseData> {
|
||||
const queryParams = objectToQueryParams(requestData)
|
||||
const response = await fetchGet<Balance.BalanceExpenditureResponseData>(
|
||||
`/balance/expenditure?${queryParams}`
|
||||
)
|
||||
return response
|
||||
}
|
34
src/api/balance/types/balance.ts
Normal file
34
src/api/balance/types/balance.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
type SortField = 'time' | 'amount'
|
||||
type SortOrder = 'asc' | 'desc'
|
||||
|
||||
// 获取 income 请求数据
|
||||
export interface BalanceIncomeRequestData {
|
||||
page: number
|
||||
limit: number
|
||||
sortField: SortField
|
||||
sortOrder: SortOrder
|
||||
}
|
||||
|
||||
// 获取 expenditure 请求数据
|
||||
export interface BalanceExpenditureRequestData {
|
||||
page: number
|
||||
limit: number
|
||||
sortField: SortField
|
||||
sortOrder: SortOrder
|
||||
}
|
||||
|
||||
// income 响应数据
|
||||
export type BalanceIncomeResponseData = KUNGalgameResponseData<{
|
||||
iid: number
|
||||
reason: string
|
||||
time: number
|
||||
amount: number
|
||||
}>
|
||||
|
||||
// expenditure 响应数据
|
||||
export type BalanceExpenditureResponseData = KUNGalgameResponseData<{
|
||||
eid: number
|
||||
reason: string
|
||||
time: number
|
||||
amount: number
|
||||
}>
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
|
||||
// 暴露出所有 interface
|
||||
export * from './balance/types/balance'
|
||||
export * from './edit/types/edit'
|
||||
export * from './home/types/home'
|
||||
export * from './user/types/user'
|
||||
|
@ -11,6 +12,7 @@ export * from './topic/types'
|
|||
export * from './update-log/types/updateLog'
|
||||
|
||||
// 暴露出所有 api
|
||||
export * from './balance'
|
||||
export * from './edit'
|
||||
export * from './home'
|
||||
export * from './user'
|
||||
|
|
|
@ -254,6 +254,8 @@ $navNumber: v-bind(navItemNum);
|
|||
}
|
||||
}
|
||||
img {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
cursor: pointer;
|
||||
border-radius: 50%;
|
||||
height: 40px;
|
||||
|
|
62
src/store/modules/balance.ts
Normal file
62
src/store/modules/balance.ts
Normal file
|
@ -0,0 +1,62 @@
|
|||
// 评论的临时数据,用于组件间传输
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import type {
|
||||
BalanceIncomeRequestData,
|
||||
BalanceExpenditureRequestData,
|
||||
BalanceIncomeResponseData,
|
||||
BalanceExpenditureResponseData,
|
||||
} from '@/api'
|
||||
|
||||
import { getIncomeApi, getExpenditureApi } from '@/api'
|
||||
|
||||
interface BalanceStore {
|
||||
income: BalanceIncomeRequestData
|
||||
expenditure: BalanceExpenditureRequestData
|
||||
}
|
||||
|
||||
export const useKUNGalgameBalanceStore = defineStore({
|
||||
id: 'KUNGalgameBalance',
|
||||
// 不持久
|
||||
persist: false,
|
||||
state: (): BalanceStore => ({
|
||||
income: {
|
||||
page: 0,
|
||||
limit: 0,
|
||||
sortField: 'time',
|
||||
sortOrder: 'desc',
|
||||
},
|
||||
expenditure: {
|
||||
page: 0,
|
||||
limit: 0,
|
||||
sortField: 'time',
|
||||
sortOrder: 'desc',
|
||||
},
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
// 获取 income
|
||||
async getIncome(): Promise<BalanceIncomeResponseData> {
|
||||
// 这里的默认值用于初始化
|
||||
const requestData: BalanceIncomeRequestData = {
|
||||
page: this.income.page,
|
||||
limit: this.income.limit,
|
||||
sortField: this.income.sortField,
|
||||
sortOrder: this.income.sortOrder,
|
||||
}
|
||||
return await getIncomeApi(requestData)
|
||||
},
|
||||
|
||||
// 获取 expenditure
|
||||
async getExpenditure(): Promise<BalanceExpenditureResponseData> {
|
||||
// 这里的默认值用于初始化
|
||||
const requestData: BalanceExpenditureRequestData = {
|
||||
page: this.income.page,
|
||||
limit: this.income.limit,
|
||||
sortField: this.income.sortField,
|
||||
sortOrder: this.income.sortOrder,
|
||||
}
|
||||
return await getExpenditureApi(requestData)
|
||||
},
|
||||
},
|
||||
})
|
|
@ -1,6 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import { FSLog } from '../log'
|
||||
defineProps(['isIncome'])
|
||||
defineProps<{
|
||||
isIncome?: boolean
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -61,7 +61,6 @@ const mpWidth = computed(() => {
|
|||
width: 140px;
|
||||
height: 140px;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0px 0px 2px 4px var(--kungalgame-trans-red-2);
|
||||
&:hover {
|
||||
animation: spin 1s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue