Skip to content

Commit

Permalink
feat: 同步配置来源为文件时, 使用文件的自定义图标
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Jan 16, 2024
1 parent f6b02eb commit cab0732
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 27 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.58",
"version": "2.14.59",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
62 changes: 38 additions & 24 deletions src/components/ArtifactsListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<nut-swipe class="sub-item-swipe" ref="swipe" :disabled="$props.disabled">
<div class="sub-item-wrapper" :style="{'padding': isSimpleMode ? '9px' : '16px' }" @click.stop="previewSource">
<a class="sub-img-wrappers" :href="artifact.url" target="_blank">
<nut-avatar class="sub-item-customer-icon" :size="isSimpleMode ? '36' : '48'" :url="icon" bg-color=""></nut-avatar>
<nut-avatar :class="{ 'sub-item-customer-icon': !isIconColor }" :size="isSimpleMode ? '36' : '48'" :url="icon" bg-color=""></nut-avatar>
</a>
<div class="sub-item-content">
<div class="sub-item-title-wrapper">
Expand Down Expand Up @@ -88,6 +88,7 @@
</template>

<script lang="ts" setup>
import logoIcon from '@/assets/icons/logo.svg';
import singboxIcon from '@/assets/icons/sing-box.png';
import clashIcon from '@/assets/icons/clash.png';
import clashMetaIcon from '@/assets/icons/clashmeta.png';
Expand All @@ -112,7 +113,7 @@ import { useGlobalStore } from '@/store/global';
import { useHostAPI } from '@/hooks/useHostAPI';
const globalStore = useGlobalStore();
const { isLeftRight, isSimpleMode } = storeToRefs(globalStore);
const { isLeftRight, isSimpleMode, isIconColor } = storeToRefs(globalStore);
const { copy, isSupported } = useClipboard();
const { toClipboard: copyFallback } = useV3Clipboard();
Expand All @@ -133,28 +134,7 @@ const artifact = computed(() => {
});
const emit = defineEmits(['edit']);
const icon = computed(() => {
switch (artifact.value.platform) {
case 'Surge':
return surgeIcon;
case 'QX':
return quanxIcon;
case 'Loon':
return loonIcon;
case 'Clash':
return clashIcon;
case 'ClashMeta':
return clashMetaIcon;
case 'Stash':
return stashIcon;
case 'ShadowRocket':
return shadowRocketIcon;
case 'V2Ray':
return v2rayIcon;
case 'sing-box':
return singboxIcon;
}
});
const displayName = computed(() => {
return (
Expand Down Expand Up @@ -183,6 +163,40 @@ const sourceSub = computed(() => {
}
});
const icon = computed(() => {
let platform = String(artifact.value.platform)
if (['file'].includes(artifact.value.type)) {
if (sourceSub.value?.icon) {
return sourceSub.value.icon;
} else {
platform = ''
}
}
switch (platform) {
case 'Surge':
return surgeIcon;
case 'QX':
return quanxIcon;
case 'Loon':
return loonIcon;
case 'Clash':
return clashIcon;
case 'ClashMeta':
return clashMetaIcon;
case 'Stash':
return stashIcon;
case 'ShadowRocket':
return shadowRocketIcon;
case 'V2Ray':
return v2rayIcon;
case 'sing-box':
return singboxIcon;
default:
return logoIcon;
}
});
const sourceUrl = computed(() => {
const urlTarget: string = artifact.value.platform !== null ? `?target=${artifact.value.platform}` : '';
return `${host.value}/download/${
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ export default {
desc: 'Note: Turning on this switch will automatically download and refresh the Gist remote configuration when SubStore is opened. The refresh operation overwrites the current configuration. To prevent data loss, you can manually upload the configuration after the modification. The switch will not be uploaded, and the configuration will be downloaded only after the restart.',
simple: 'Simple Mode',
islr: 'Card right swipe to call out',
isIC: 'Use original color for icons',
isIC: 'Use original color for custom icons',
isEditorCommon: 'Show editor common settings',
isSimpleReicon: 'Show items refresh button',
showFloatingRefreshButton: 'Show floating refresh button',
Expand Down
2 changes: 1 addition & 1 deletion src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ export default {
打开开关不会上传,只有在重启后才会下载配置。`,
simple: '简洁模式',
islr: '卡片右滑呼出',
isIC: '使用订阅图标原始颜色',
isIC: '自定义图标使用原始颜色',
isEditorCommon: '展示编辑页常用配置',
isSimpleReicon: '展示订阅刷新按钮',
showFloatingRefreshButton: '显示悬浮刷新按钮',
Expand Down

0 comments on commit cab0732

Please sign in to comment.