32 lines
702 B
TypeScript
32 lines
702 B
TypeScript
import { create } from 'zustand';
|
|
import { query } from '@kevisual/resources/modules/query';
|
|
|
|
type Statistic = {
|
|
list: any[];
|
|
total: number;
|
|
size: number;
|
|
sizeMb: number;
|
|
};
|
|
export interface StatisticStore {
|
|
statistic: Statistic;
|
|
setStatistic: (statistic: Statistic) => void;
|
|
getStatistic: () => Promise<void>;
|
|
}
|
|
|
|
export const useStatisticStore = create<StatisticStore>((set) => ({
|
|
statistic: {
|
|
list: [],
|
|
total: 0,
|
|
size: 0,
|
|
sizeMb: 0,
|
|
},
|
|
setStatistic: (statistic: Statistic) => set({ statistic }),
|
|
getStatistic: async () => {
|
|
const res = await query.post({
|
|
path: 'file',
|
|
key: 'me-all-file-stat',
|
|
});
|
|
set({ statistic: res.data });
|
|
},
|
|
}));
|