This commit is contained in:
yinsx
2026-01-28 17:51:06 +08:00
parent d97ea9c791
commit a68e380c42
45 changed files with 4980 additions and 151 deletions

View File

@ -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));
}