u
This commit is contained in:
1 parent
d33cef825a
commit
295b3306a3
7 files changed
+477
-291
No files matched your search
@@ -1,10 +1,10 @@
|
||||
import type { MoneyCategoryItem } from '@/types/money/category'
|
||||
import type { IconGroupType, MoneyCategoryItem } from '@/types/money/category'
|
||||
import { create } from 'zustand'
|
||||
import { createMoneyCategoryApi, deleteMoneyCategoryApi, queryMoneyCategoryApi, updateMoneyCategoryApi, updateMoneyCategorySortApi } from '@/request/api/money/category'
|
||||
import { MoneyCategoryEnum } from '@/types/money/category'
|
||||
|
||||
interface MoneyCategoryStore {
|
||||
ICON_GROUPS: Record<string, string[]>
|
||||
IconGroups: IconGroupType[]
|
||||
categories: MoneyCategoryItem[]
|
||||
|
||||
init: () => Promise<void>
|
||||
@@ -22,77 +22,195 @@ interface MoneyCategoryStore {
|
||||
|
||||
isDuplicateCategory: (name: string, type: number, excludeId: number | null) => boolean
|
||||
|
||||
findIconGroupsRow: (iconName: string) => number
|
||||
clear: () => void
|
||||
}
|
||||
|
||||
export const useMoneyCategoryStore = create<MoneyCategoryStore>()(
|
||||
(set, get) => ({
|
||||
ICON_GROUPS: {
|
||||
餐饮: [
|
||||
'money_canyin',
|
||||
'money_yinpin',
|
||||
'money_lingshi',
|
||||
'money_xiaoye',
|
||||
],
|
||||
娱乐: [
|
||||
'money_yule',
|
||||
'money_youxi',
|
||||
'money_dianying',
|
||||
],
|
||||
交通: [
|
||||
'money_jiaotong',
|
||||
'money_tingchefei',
|
||||
'money_jiayou',
|
||||
],
|
||||
生活消费: [
|
||||
'money_lijin',
|
||||
'money_jiadian',
|
||||
'money_riyongpin',
|
||||
'money_shucai',
|
||||
'money_meifa',
|
||||
'money_shuidian',
|
||||
'money_wenju',
|
||||
'money_zhufang',
|
||||
'money_baoxian',
|
||||
'money_baojianpin',
|
||||
'money_huafei',
|
||||
'money_lvyou',
|
||||
'money_gouwu',
|
||||
'money_shuben',
|
||||
'money_chongwu',
|
||||
'money_ruanjian',
|
||||
],
|
||||
健康: [
|
||||
'money_tijian',
|
||||
'money_yao',
|
||||
'money_jiuyi',
|
||||
],
|
||||
公益: [
|
||||
'money_gongyi',
|
||||
],
|
||||
兼职与收入: [
|
||||
'money_gongzi',
|
||||
'money_jianzhi',
|
||||
],
|
||||
鲜花与水果: [
|
||||
'money_shuiguo',
|
||||
'money_xianhua',
|
||||
],
|
||||
转账与转移: [
|
||||
'money_zhuanzhang',
|
||||
],
|
||||
家庭与家电: [
|
||||
'money_kuaidi',
|
||||
'money_weixiu',
|
||||
'money_jiaju',
|
||||
'money_muying',
|
||||
'money_liwu',
|
||||
],
|
||||
运动与娱乐: [
|
||||
'money_yundong',
|
||||
'money_peixun',
|
||||
],
|
||||
},
|
||||
IconGroups: [
|
||||
{
|
||||
index: 0,
|
||||
type: 'title',
|
||||
value: '餐饮',
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_canyin',
|
||||
'money_yinpin',
|
||||
'money_lingshi',
|
||||
'money_xiaoye',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
type: 'title',
|
||||
value: '娱乐',
|
||||
},
|
||||
{
|
||||
index: 3,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_yule',
|
||||
'money_youxi',
|
||||
'money_dianying',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 4,
|
||||
type: 'title',
|
||||
value: '交通',
|
||||
},
|
||||
{
|
||||
index: 5,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_jiaotong',
|
||||
'money_tingchefei',
|
||||
'money_jiayou',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 6,
|
||||
type: 'title',
|
||||
value: '生活消费',
|
||||
},
|
||||
{
|
||||
index: 7,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_lijin',
|
||||
'money_jiadian',
|
||||
'money_riyongpin',
|
||||
'money_shucai',
|
||||
'money_meifa',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 8,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_shuidian',
|
||||
'money_wenju',
|
||||
'money_zhufang',
|
||||
'money_baoxian',
|
||||
'money_baojianpin',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 9,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_huafei',
|
||||
'money_lvyou',
|
||||
'money_gouwu',
|
||||
'money_shuben',
|
||||
'money_chongwu',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 10,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_ruanjian',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 11,
|
||||
type: 'title',
|
||||
value: '健康',
|
||||
},
|
||||
{
|
||||
index: 12,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_tijian',
|
||||
'money_yao',
|
||||
'money_jiuyi',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 13,
|
||||
type: 'title',
|
||||
value: '公益',
|
||||
},
|
||||
{
|
||||
index: 14,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_gongyi',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 15,
|
||||
type: 'title',
|
||||
value: '兼职与收入',
|
||||
},
|
||||
{
|
||||
index: 16,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_gongzi',
|
||||
'money_jianzhi',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 17,
|
||||
type: 'title',
|
||||
value: '鲜花与水果',
|
||||
},
|
||||
{
|
||||
index: 18,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_shuiguo',
|
||||
'money_xianhua',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 19,
|
||||
type: 'title',
|
||||
value: '转账与转移',
|
||||
},
|
||||
{
|
||||
index: 20,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_zhuanzhang',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 21,
|
||||
type: 'title',
|
||||
value: '家庭与家电',
|
||||
},
|
||||
{
|
||||
index: 22,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_kuaidi',
|
||||
'money_weixiu',
|
||||
'money_jiaju',
|
||||
'money_muying',
|
||||
'money_liwu',
|
||||
],
|
||||
},
|
||||
{
|
||||
index: 23,
|
||||
type: 'title',
|
||||
value: '运动与娱乐',
|
||||
},
|
||||
{
|
||||
index: 24,
|
||||
type: 'icons',
|
||||
value: [
|
||||
'money_yundong',
|
||||
'money_peixun',
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
categories: [],
|
||||
|
||||
@@ -247,5 +365,18 @@ export const useMoneyCategoryStore = create<MoneyCategoryStore>()(
|
||||
&& c.id !== excludeId,
|
||||
)
|
||||
},
|
||||
|
||||
findIconGroupsRow: (iconName) => {
|
||||
const iconGroups = get().IconGroups
|
||||
|
||||
for (const group of iconGroups) {
|
||||
if (group.type === 'icons' && group.value.includes(iconName)) {
|
||||
return group.index
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
},
|
||||
|
||||
}),
|
||||
)
|
||||
Reference in new issue
Block a user