You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GHHub/src/stores/Products/Index.js

25 lines
548 B
JavaScript

import { create } from 'zustand';
import { devtools } from 'zustand/middleware';
import { fetchJSON } from '@/utils/request';
import { HT_HOST } from '@/config';
const initialState = {
loading: false,
productsList: [],
};
export const useProductsStore = create(
devtools((set, get) => ({
// 初始化状态
...initialState,
// state actions
setProductsList: (productsList) => set({ productsList }),
reset: () => set(initialState),
// side effects
}))
);
export default useProductsStore;