Skip to content

Commit

Permalink
feat: 新增图标仓库自定义仓库本地持久化
Browse files Browse the repository at this point in the history
  • Loading branch information
hsingyin committed Dec 19, 2024
1 parent 1388c65 commit c75e81e
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 107 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store-front-end",
"version": "2.14.311",
"version": "2.14.312",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ export default {
selectCollectionBtn: "Select a icon collection",
more: "More",
useCustomIconCollection: "Use Custom Icon Collection",
resetDefaultIconCollection: "Reset Default",
collectionPicker: {
title: "Select a icon collection",
cancel: "Cancel",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ export default {
selectCollectionBtn: '切换图标仓库',
more: '更多',
useCustomIconCollection: '使用自定义仓库',
resetDefaultIconCollection: '恢复默认',
collectionPicker: {
title: '选择一个图标仓库',
cancel: '取消',
Expand Down
53 changes: 53 additions & 0 deletions src/store/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,46 @@ export const useGlobalStore = defineStore('globalStore', {
ishostApi: getHostAPIUrl(),
savedPositions: {},
defaultIconCollection: localStorage.getItem('defaultIconCollection') || '',
defaultIconCollections: [
{
text: "cc63/ICON",
value: "https://raw.githubusercontent.com/cc63/ICON/main/icons.json",
},
{
text: "Koolson/QureColor",
value:
"https://raw.githubusercontent.com/Koolson/Qure/master/Other/QureColor.json",
},
{
text: "Koolson/QureColor-All",
value:
"https://raw.githubusercontent.com/Koolson/Qure/master/Other/QureColor-All.json",
},
{
text: "Orz-3/mini",
value: "https://raw.githubusercontent.com/Orz-3/mini/master/mini.json",
},
{
text: "Orz-3/mini+",
value: "https://raw.githubusercontent.com/Orz-3/mini/master/mini%2B.json",
},
{
text: "Orz-3/miniColor",
value: "https://raw.githubusercontent.com/Orz-3/mini/master/miniColor.json",
},
{
text: "Orz-3/Color+",
value: "https://raw.githubusercontent.com/Orz-3/mini/master/Color%2B.json",
},
{
text: "Twoandz9/TheMagic-Icons",
value:
"https://raw.githubusercontent.com/Twoandz9/TheMagic-Icons/main/TheRaw.json",
},
],
customIconCollections: localStorage.getItem("customIconCollections")
? JSON.parse(localStorage.getItem("customIconCollections"))
: [],
};
},
getters: {},
Expand Down Expand Up @@ -149,5 +189,18 @@ export const useGlobalStore = defineStore('globalStore', {
}
this.defaultIconCollection = defaultIconCollection;
},
setCustomIconCollections(collections: any[]) {
if (collections && collections.length > 0) {
// 合并去重
const list = Array.from(
new Set([...this.customIconCollections, ...collections]),
);
localStorage.setItem('customIconCollections', JSON.stringify(list));
this.customIconCollections = list;
} else {
localStorage.removeItem('customIconCollections');
this.customIconCollections = [];
}
},
},
});
2 changes: 2 additions & 0 deletions src/types/store/globalStore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ interface GlobalStoreState {
savedPositions: any;
subProgressStyle: any;
defaultIconCollection: string;
defaultIconCollections?: any;
customIconCollections?: any[];
}

interface ENV {
Expand Down
Loading

0 comments on commit c75e81e

Please sign in to comment.