1
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { defineStore, acceptHMRUpdate } from 'pinia';
|
||||
|
||||
type IconSize = '1x1' | '1x2' | '2x1' | '2x2' | '2x4';
|
||||
|
||||
@ -9,6 +9,7 @@ interface Icon {
|
||||
url: string;
|
||||
size?: IconSize;
|
||||
img?: string; // 可选:用于图片图标(如徽标)
|
||||
text?: string; // 可选:用于文字图标
|
||||
bgColor?: string; // 可选:纯色背景
|
||||
}
|
||||
|
||||
@ -74,6 +75,17 @@ export const useLayoutStore = defineStore('layout', {
|
||||
}
|
||||
}),
|
||||
actions: {
|
||||
addIcon(icon: Omit<Icon, 'id'>) {
|
||||
const nextId = `custom-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
||||
this.icons.push({ ...icon, id: nextId });
|
||||
localStorage.setItem('itab_icons', JSON.stringify(this.icons));
|
||||
},
|
||||
updateIcon(iconId: string, updates: Partial<Omit<Icon, 'id'>>) {
|
||||
const icon = this.icons.find(item => item.id === iconId);
|
||||
if (!icon) return;
|
||||
Object.assign(icon, updates);
|
||||
localStorage.setItem('itab_icons', JSON.stringify(this.icons));
|
||||
},
|
||||
reorderIcons(draggedId: string, targetId: string) {
|
||||
const draggedIndex = this.icons.findIndex(p => p.id === draggedId);
|
||||
const targetIndex = this.icons.findIndex(p => p.id === targetId);
|
||||
@ -123,3 +135,7 @@ export const useLayoutStore = defineStore('layout', {
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
if (import.meta.hot) {
|
||||
import.meta.hot.accept(acceptHMRUpdate(useLayoutStore, import.meta.hot));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user