diff --git a/package.json b/package.json
index 95df76336..485dd3fc3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "sub-store-front-end",
- "version": "2.14.311",
+ "version": "2.14.312",
"private": true,
"scripts": {
"dev": "vite --host",
diff --git a/src/locales/en.ts b/src/locales/en.ts
index aeeb36be1..094816c47 100644
--- a/src/locales/en.ts
+++ b/src/locales/en.ts
@@ -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",
diff --git a/src/locales/zh.ts b/src/locales/zh.ts
index ea2fe0d93..afbcaaa71 100644
--- a/src/locales/zh.ts
+++ b/src/locales/zh.ts
@@ -784,6 +784,7 @@ export default {
selectCollectionBtn: '切换图标仓库',
more: '更多',
useCustomIconCollection: '使用自定义仓库',
+ resetDefaultIconCollection: '恢复默认',
collectionPicker: {
title: '选择一个图标仓库',
cancel: '取消',
diff --git a/src/store/global.ts b/src/store/global.ts
index d9d7ee66e..939429d69 100644
--- a/src/store/global.ts
+++ b/src/store/global.ts
@@ -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: {},
@@ -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 = [];
+ }
+ },
},
});
diff --git a/src/types/store/globalStore.d.ts b/src/types/store/globalStore.d.ts
index 4a52a9d50..b3d6a2e98 100644
--- a/src/types/store/globalStore.d.ts
+++ b/src/types/store/globalStore.d.ts
@@ -18,6 +18,8 @@ interface GlobalStoreState {
savedPositions: any;
subProgressStyle: any;
defaultIconCollection: string;
+ defaultIconCollections?: any;
+ customIconCollections?: any[];
}
interface ENV {
diff --git a/src/views/icon/IconPopup.vue b/src/views/icon/IconPopup.vue
index 8d7007254..61f2e9046 100644
--- a/src/views/icon/IconPopup.vue
+++ b/src/views/icon/IconPopup.vue
@@ -25,10 +25,14 @@
{{ form.iconCollectionName }}
{{ form.iconCollectionDesc }}
-
+
{{ $t(`iconCollectionPage.more`) }}
-
+
+
+
+ {{ $t(`iconCollectionPage.resetDefaultIconCollection`) }}
+
@@ -40,7 +44,7 @@
size="mini"
@change="setIconColor"
/>
- {{ $t(`moreSettingPage.isIC`) }}
+ {{ $t(`moreSettingPage.isIC`) }}
- {{ $t(`iconCollectionPage.useCustomIconCollection`) }}
+
+ {{ $t(`iconCollectionPage.useCustomIconCollection`) }}
+
@@ -63,21 +69,20 @@
type="text"
clearable
@clear="clearIconName"
- >
+ >
-
+ @clear="clearCustomIconCollectionUrl"
+ @click-right-icon="handleAddCustomIconCollection"
+ >
@@ -108,7 +113,7 @@
import { Toast } from "@nutui/nutui";
+import { useDebounceFn } from "@vueuse/core";
import axios from "axios";
-import { ref, watch, watchEffect, computed, reactive, onMounted } from 'vue'
import { storeToRefs } from "pinia";
-import { useGlobalStore } from "@/store/global";
-import { useSettingsStore } from '@/store/settings';
+import { computed, onMounted, reactive, ref, watch, watchEffect } from "vue";
import { useI18n } from "vue-i18n";
-import { useDebounceFn } from '@vueuse/core'
+import { useGlobalStore } from "@/store/global";
+import { useSettingsStore } from "@/store/settings";
+
+const props = defineProps({
+ visible: {
+ type: Boolean,
+ default: false,
+ },
+});
+const emit = defineEmits(["update:visible", "setIcon"]);
const { t } = useI18n();
const globalStore = useGlobalStore();
const settingsStore = useSettingsStore();
const { changeAppearanceSetting } = settingsStore;
const { appearanceSetting } = storeToRefs(settingsStore);
-const { bottomSafeArea, defaultIconCollection } = storeToRefs(globalStore);
+const { customIconCollections, defaultIconCollections, defaultIconCollection } =
+ storeToRefs(globalStore);
const setIconColor = (isIconColor: boolean) => {
const data = {
@@ -146,6 +160,7 @@ const form = reactive({
iconName: "",
iconCollectionName: "",
iconCollectionUrl: "",
+ customIconCollectionUrl: "",
iconCollectionDesc: "",
iconListKey: "",
iconItemUrlKey: "",
@@ -161,8 +176,8 @@ const performSearch = () => {
searchResult.value = iconList.value;
} else {
const lowercaseTerm = form.iconName.toLowerCase();
- searchResult.value = iconList.value.filter(item =>
- item.name.toLowerCase().includes(lowercaseTerm)
+ searchResult.value = iconList.value.filter((item) =>
+ item.name.toLowerCase().includes(lowercaseTerm),
);
}
};
@@ -175,48 +190,22 @@ const iconData = computed(() => {
});
// 监听 form.iconName 变化以触发搜索
-watch(() => form.iconName, (newValue) => {
- debouncedSearch();
-});
+watch(
+ () => form.iconName,
+ (newValue) => {
+ debouncedSearch();
+ },
+);
// 图标仓库列表
-const defaultIconCollectionColumns = ref([
- {
- 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",
- },
-]);
+const iconCollectionColumns = computed(() => {
+ // 合并自定义和默认图标仓库
+ const mergedCollections = [
+ ...customIconCollections.value,
+ ...defaultIconCollections.value,
+ ];
+ return mergedCollections;
+});
const isIconColor = ref(false);
@@ -231,14 +220,14 @@ const showIconCollectionPicker = ref(false);
const showCustomIconCollection = ref(false);
-const handleCustomIconCollection = () => {
- showCustomIconCollection.value = !showCustomIconCollection.value;
-};
-
const setDefaultIconCollection = (url: string) => {
globalStore.setDefaultIconCollection(url);
};
+const setCustomIconCollections = (collection: any[]) => {
+ globalStore.setCustomIconCollections(collection);
+};
+
const fetchIcons = async () => {
try {
Toast.loading(t(`globalNotify.refresh.loading`), {
@@ -253,6 +242,7 @@ const fetchIcons = async () => {
iconList.value = data[collectionKey];
form.iconCollectionName = data.name || "";
form.iconCollectionDesc = data.description || "";
+ const { name } = data;
if (iconList.value && iconList.value.length > 0) {
iconList.value = iconList.value.map((item) => {
const iconItem = {
@@ -261,6 +251,26 @@ const fetchIcons = async () => {
};
return iconItem;
});
+ // 添加自定义图标仓库,
+ const hasCollection = iconCollectionColumns.value.some(
+ (item) => item.value === form.iconCollectionUrl,
+ );
+ console.log("hasCollection", hasCollection);
+ if (!hasCollection) {
+ const list = [
+ {
+ text: name,
+ value: form.iconCollectionUrl,
+ },
+ ...customIconCollections.value,
+ ];
+ setCustomIconCollections(list);
+ setDefaultIconCollection(form.iconCollectionUrl);
+ defaultIconCollectionValue.value[0] = form.iconCollectionUrl;
+ } else {
+ setDefaultIconCollection(form.iconCollectionUrl);
+ defaultIconCollectionValue.value[0] = form.iconCollectionUrl;
+ }
} else {
iconList.value = [];
}
@@ -275,15 +285,20 @@ const fetchIcons = async () => {
}
};
+const handleAddCustomIconCollection = () => {
+ form.iconCollectionUrl = form.customIconCollectionUrl;
+ fetchIcons();
+};
+
const handleIcon = (icon) => {
- console.log('icon', icon)
- hide()
- emit("setIcon", icon)
-}
+ console.log("icon", icon);
+ hide();
+ emit("setIcon", icon);
+};
const handleMoreIconCollection = () => {
showPicker();
-}
+};
const showPicker = () => {
showIconCollectionPicker.value = true;
@@ -291,13 +306,15 @@ const showPicker = () => {
const handleConfirm = ({ selectedValue, selectedOptions }) => {
form.iconCollectionUrl = selectedValue[0];
+ form.customIconCollectionUrl = "";
+ showCustomIconCollection.value = false;
setDefaultIconCollection(form.iconCollectionUrl);
refreshIcons();
};
const handleCancel = () => {
// showIconCollectionPicker.value = false;
- console.log('cancel')
+ console.log("cancel");
};
const init = () => {
@@ -305,9 +322,8 @@ const init = () => {
form.iconCollectionUrl = defaultIconCollection.value;
defaultIconCollectionValue.value[0] = defaultIconCollection.value;
} else {
- form.iconCollectionUrl = defaultIconCollectionColumns.value[0].value;
- defaultIconCollectionValue.value[0] =
- defaultIconCollectionColumns.value[0].value;
+ form.iconCollectionUrl = defaultIconCollections.value[0].value;
+ defaultIconCollectionValue.value[0] = defaultIconCollections.value[0].value;
}
refreshIcons();
};
@@ -317,8 +333,8 @@ const clearIconName = () => {
};
const clearCustomIconCollectionUrl = () => {
- form.iconCollectionUrl = "";
-}
+ form.customIconCollectionUrl = "";
+};
const refreshIcons = () => {
if (!form.iconCollectionUrl) {
@@ -332,42 +348,45 @@ const refreshIcons = () => {
}
};
+const handleResetDefault = () => {
+ setCustomIconCollections([]);
+ showCustomIconCollection.value = false;
+ form.customIconCollectionUrl = "";
+ form.iconCollectionUrl = defaultIconCollections.value[0].value;
+ defaultIconCollectionValue.value[0] = defaultIconCollections.value[0].value;
+ refreshIcons();
+};
onMounted(() => {
init();
-})
-const props = defineProps({
- visible: {
- type: Boolean,
- default: false
- }
-})
-const emit = defineEmits(['update:visible', 'setIcon'])
-
-const isVisible = ref(props.visible)
-
-watch(() => props.visible, (newValue) => {
- isVisible.value = newValue
- console.log('newValue', newValue)
- if (newValue) {
- refreshIcons()
- }
-})
+});
+const isVisible = ref(props.visible);
+
+watch(
+ () => props.visible,
+ (newValue) => {
+ isVisible.value = newValue;
+ console.log("newValue", newValue);
+ if (newValue) {
+ refreshIcons();
+ }
+ },
+);
const show = () => {
- isVisible.value = true
- emit('update:visible', true)
-}
+ isVisible.value = true;
+ emit("update:visible", true);
+};
const close = () => {
- clearIconName()
- hide()
-}
+ clearIconName();
+ hide();
+};
const hide = () => {
- isVisible.value = false
- emit('update:visible', false)
-}
+ isVisible.value = false;
+ emit("update:visible", false);
+};
// 暴露方法给父组件
-defineExpose({ show, hide, close })
+defineExpose({ show, hide, close });
\ No newline at end of file
+