UPDATE: Update readme and Next 16.07 (CVE-2025-66478)
This commit is contained in:
67
src/stores/lightconeStore.ts
Normal file
67
src/stores/lightconeStore.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { LightConeBasic, FilterLightconeType, LightConeDetail } from '@/types';
|
||||
import { create } from 'zustand'
|
||||
|
||||
interface LightconeState {
|
||||
listLightcone: LightConeBasic[];
|
||||
listRawLightcone: LightConeBasic[];
|
||||
listPath: Record<string, boolean>;
|
||||
listRank: Record<string, boolean>;
|
||||
filter: FilterLightconeType;
|
||||
defaultFilter: { path: string[], rarity: string[] };
|
||||
mapLightconeInfo: Record<string, LightConeDetail>;
|
||||
setListPath: (newListPath: Record<string, boolean>) => void;
|
||||
setListRank: (newListRank: Record<string, boolean>) => void;
|
||||
setDefaultFilter: (newDefaultFilter: { path: string[], rarity: string[] }) => void;
|
||||
setListLightcone: (newListLightcone: LightConeBasic[]) => void;
|
||||
setFilter: (newFilter: FilterLightconeType) => void;
|
||||
setMapLightconeInfo: (lightconeId: string, newLightcone: LightConeDetail) => void;
|
||||
setAllMapLightconeInfo: (newLightcone: Record<string, LightConeDetail>) => void;
|
||||
}
|
||||
|
||||
const useLightconeStore = create<LightconeState>((set, get) => ({
|
||||
listLightcone: [],
|
||||
listRawLightcone: [],
|
||||
mapLightconeInfo: {},
|
||||
|
||||
filter: {
|
||||
name: "",
|
||||
path: [],
|
||||
locale: "",
|
||||
rarity: [],
|
||||
},
|
||||
defaultFilter: { path: [], rarity: [] },
|
||||
listPath: { "knight": false, "mage": false, "priest": false, "rogue": false, "shaman": false, "warlock": false, "warrior": false, "memory": false },
|
||||
listRank: { "3": false, "4": false, "5": false },
|
||||
setListPath: (newListPath: Record<string, boolean>) => set({ listPath: newListPath }),
|
||||
setListRank: (newListRank: Record<string, boolean>) => set({ listRank: newListRank }),
|
||||
setDefaultFilter: (newDefaultFilter: { path: string[], rarity: string[] }) => set({ defaultFilter: newDefaultFilter }),
|
||||
setListLightcone: (newListLightcone: LightConeBasic[]) => set({ listLightcone: newListLightcone, listRawLightcone: newListLightcone }),
|
||||
setFilter: (newFilter: FilterLightconeType) => {
|
||||
set({ filter: newFilter })
|
||||
|
||||
if (newFilter.locale === "") {
|
||||
return
|
||||
}
|
||||
let filteredList = get().listRawLightcone;
|
||||
if (newFilter.name && newFilter.locale) {
|
||||
filteredList = filteredList.filter((lightcone) => {
|
||||
return lightcone.lang?.get(newFilter.locale)?.toLowerCase().includes(newFilter.name.toLowerCase()) ?? false;
|
||||
});
|
||||
}
|
||||
if (newFilter.path && newFilter.path.length > 0) {
|
||||
filteredList = filteredList.filter((lightcone) => {
|
||||
return newFilter.path.some((path) => lightcone.baseType?.toLowerCase().includes(path.toLowerCase())) ?? false;
|
||||
});
|
||||
}
|
||||
if (newFilter.rarity && newFilter.rarity.length > 0) {
|
||||
filteredList = filteredList.filter((lightcone) => {
|
||||
return newFilter.rarity.some((rarity) => lightcone.rank?.toLowerCase().includes(rarity.toLowerCase())) ?? false;
|
||||
});
|
||||
}
|
||||
set({ listLightcone: filteredList });
|
||||
},
|
||||
setMapLightconeInfo: (lightconeId: string, newLightcone: LightConeDetail) => set((state) => ({ mapLightconeInfo: { ...state.mapLightconeInfo, [lightconeId]: newLightcone } })),
|
||||
setAllMapLightconeInfo: (newLightcone: Record<string, LightConeDetail>) => set({ mapLightconeInfo: newLightcone }),
|
||||
}));
|
||||
|
||||
export default useLightconeStore;
|
||||
Reference in New Issue
Block a user