Skip to content

Commit

Permalink
feat: 增加链接参数说明; 支持同步配置时选择包含官方/商店版不支持的协议; 修复同步配置点击预览
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Jan 17, 2024
1 parent c8a5949 commit a4e9871
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 65 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.71",
"version": "2.14.72",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
74 changes: 56 additions & 18 deletions src/components/ArtifactPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,37 @@
></nut-cascader>

</nut-form-item>
<nut-form-item v-if="sourceInput && ['subscription', 'collection'].includes(editPanelData.type) " :label="$t(`syncPage.addArtForm.platform.label`)">
<nut-radiogroup
direction="horizontal"
v-model="editPanelData.platform"
class="artifact-radio-group"
<template v-if="sourceInput && ['subscription', 'collection'].includes(editPanelData.type)">
<nut-form-item
:label="$t(`syncPage.addArtForm.includeUnsupportedProxy.label`)"
prop="includeUnsupportedProxy"
class="include-unsupported-proxy-wrapper"
>
<nut-radio label="Stash">Stash</nut-radio>
<nut-radio label="ClashMeta">Clash.Meta(mihomo)</nut-radio>
<nut-radio label="Clash">Clash</nut-radio>
<nut-radio label="Surfboard">Surfboard</nut-radio>
<nut-radio label="Surge">Surge</nut-radio>
<nut-radio label="Loon">Loon</nut-radio>
<nut-radio label="ShadowRocket">Shadowrocket</nut-radio>
<nut-radio label="QX">Quantumult X</nut-radio>
<nut-radio label="sing-box">sing-box</nut-radio>
<nut-radio label="V2Ray">V2Ray</nut-radio>
</nut-radiogroup>
</nut-form-item>
<div class="swtich-wrapper">
<nut-icon name="tips" @click="includeUnsupportedProxyTips"></nut-icon>
<nut-switch v-model="editPanelData.includeUnsupportedProxy"/>
</div>
</nut-form-item>

<nut-form-item :label="$t(`syncPage.addArtForm.platform.label`)">
<nut-radiogroup
direction="horizontal"
v-model="editPanelData.platform"
class="artifact-radio-group"
>
<nut-radio label="Stash">Stash</nut-radio>
<nut-radio label="ClashMeta">Clash.Meta(mihomo)</nut-radio>
<nut-radio label="Clash">Clash</nut-radio>
<nut-radio label="Surfboard">Surfboard</nut-radio>
<nut-radio label="Surge">Surge</nut-radio>
<nut-radio label="Loon">Loon</nut-radio>
<nut-radio label="ShadowRocket">Shadowrocket</nut-radio>
<nut-radio label="QX">Quantumult X</nut-radio>
<nut-radio label="sing-box">sing-box</nut-radio>
<nut-radio label="V2Ray">V2Ray</nut-radio>
</nut-radiogroup>
</nut-form-item>
</template>
</nut-form>
</nut-dialog>
</template>
Expand Down Expand Up @@ -159,6 +172,7 @@
source: '',
type: 'file',
platform: 'Stash',
includeUnsupportedProxy: false,
});
const sourceSelectorIsVisible = ref(false);
Expand Down Expand Up @@ -298,6 +312,20 @@
ruleForm.value.validate(prop);
};
const includeUnsupportedProxyTips = () => {
const includeUnsupportedProxyTipsTitle = t(`syncPage.addArtForm.includeUnsupportedProxy.tips.title`)
const includeUnsupportedProxyTipsContent = t(`syncPage.addArtForm.includeUnsupportedProxy.tips.content`)
Dialog({
title: includeUnsupportedProxyTipsTitle,
content: includeUnsupportedProxyTipsContent,
popClass: 'auto-dialog',
okText: 'OK',
noCancelBtn: true,
closeOnPopstate: true,
lockScroll: true,
});
};
watchEffect(() => {
if (!isInit.value && name) {
const artifact = artifactsStore.artifacts.find(art => art.name === name);
Expand All @@ -317,7 +345,7 @@
.artifact-panel {
.nut-dialog {
width: 83vw;
width: 88vw;
.nut-dialog__content {
max-height: 72vh !important;
Expand Down Expand Up @@ -349,6 +377,16 @@
}
}
}
.include-unsupported-proxy-wrapper {
flex-direction: row;
justify-content: space-between;
.swtich-wrapper {
color: var(--comment-text-color);
display: flex;
justify-content: space-between;
align-items: center;
}
}
}
}
}
Expand Down
19 changes: 18 additions & 1 deletion src/components/ArtifactsListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,30 @@ const icon = computed(() => {
});
const sourceUrl = computed(() => {
if (!artifact.value.type) {
return ''
}
if (artifact.value.type === 'file') {
const path = `/api/file/${encodeURIComponent(artifact.value.source)}`;
const url = `${host.value}${path}`;
return url
}
const urlTarget: string = artifact.value.platform !== null ? `?target=${artifact.value.platform}` : '';
let urlIncludeUnsupportedProxy = artifact.value.includeUnsupportedProxy ? `includeUnsupportedProxy=true` : '';
if (urlTarget && urlIncludeUnsupportedProxy) {
urlIncludeUnsupportedProxy = `&${urlIncludeUnsupportedProxy}`
} else {
urlIncludeUnsupportedProxy = `?${urlIncludeUnsupportedProxy}`
}
return `${host.value}/download/${
artifact.value.type === 'subscription' ? '' : 'collection/'
}${encodeURIComponent(artifact.value.source)}${urlTarget}`;
}${encodeURIComponent(artifact.value.source)}${urlTarget}${urlIncludeUnsupportedProxy}`;
});
const previewSource = () => {
if (!sourceUrl.value) {
return
}
Dialog({
title: t('tabBar.sub'),
content: sourceUrl.value,
Expand Down
1 change: 0 additions & 1 deletion src/components/FileListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
import { useSubsApi } from '@/api/subs';
import { useFilesApi } from '@/api/files';
import icon from '@/assets/icons/logo.svg';
import PreviewPanel from '@/components/PreviewPanel.vue';
import { usePopupRoute } from '@/hooks/usePopupRoute';
import { useAppNotifyStore } from '@/store/appNotify';
import { useGlobalStore } from '@/store/global';
Expand Down
99 changes: 57 additions & 42 deletions src/components/PreviewPanel.vue
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
<template>
<ul class="preview-list">
<li v-for="platform in platformList" :key="platform.name">
<div class="infos">
<div>
<img :src="platform.icon" class="auto-reverse" />
<div>
<div class="desc" @click="tips">
<span>{{ desc }}</span>
<nut-icon name="tips"></nut-icon>
</div>
<ul class="preview-list">
<li v-for="platform in platformList" :key="platform.name">
<div class="infos">
<div>
<img :src="platform.icon" class="auto-reverse" />
</div>
<p>{{ platform.name }}</p>
<nut-icon name="tips" v-if="platform.name === 'Surge'" @click="tips"></nut-icon>
</div>
<p>{{ platform.name }}</p>
<nut-icon name="tips" v-if="platform.name === 'Surge'" @click="surgeTips"></nut-icon>
</div>

<div class="actions">
<a
:href="`${host}/download/${
type === 'sub' ? '' : 'collection/'
}${encodeURIComponent(name)}${platform.path !== null ? `?target=${platform.path}` : ''}`"
target="_blank"
>
<svg-icon
name="view"
class="action-icon"
color="var(--comment-text-color)"
/>
</a>
<button class="copy-sub-link" @click.stop="targetCopy(platform.path)">
<svg-icon
name="copy"
class="action-icon"
color="var(--comment-text-color)"
/>
</button>
</div>
</li>
</ul>
<div class="actions">
<a
:href="`${host}/download/${
type === 'sub' ? '' : 'collection/'
}${encodeURIComponent(name)}${platform.path !== null ? `?target=${platform.path}` : ''}`"
target="_blank"
>
<svg-icon
name="view"
class="action-icon"
color="var(--comment-text-color)"
/>
</a>
<button class="copy-sub-link" @click.stop="targetCopy(platform.path)">
<svg-icon
name="copy"
class="action-icon"
color="var(--comment-text-color)"
/>
</button>
</div>
</li>
</ul>
</div>
</template>

<script lang="ts" setup>
import { Toast } from '@nutui/nutui';
import { Toast, Dialog } from '@nutui/nutui';
import surfboard from '@/assets/icons/surfboard.png';
import surge from '@/assets/icons/surge.png';
import clash from '@/assets/icons/clash.png';
Expand All @@ -56,11 +62,14 @@
const { copy, isSupported } = useClipboard();
const { toClipboard: copyFallback } = useV3Clipboard();
const { showNotify } = useAppNotifyStore();
const { name, type, general, notify } = defineProps<{
const { name, type, general, notify, tipsTitle, tipsContent, desc } = defineProps<{
name: string;
type: 'sub' | 'collection';
general: string;
notify: string;
desc: string;
tipsTitle?: string;
tipsContent?: string;
}>();
const { currentUrl: host } = useHostAPI();
Expand Down Expand Up @@ -134,20 +143,26 @@
icon: v2ray,
},
];
const surgeTips = () => {
Toast.text('"target=SurgeMac" - supports ShadowsocksR/External Proxy Program', {
title: 'Surge Tips',
duration: 0,
cover: true,
'close-on-click-overlay': true,
'bg-color': 'rgba(0, 0, 0, 0.8)',
'cover-color': 'rgba(0, 0, 0, 0.2)',
'text-align-center': false,
const tips = () => {
Dialog({
title: tipsTitle,
content: tipsContent,
popClass: 'auto-dialog',
okText: 'OK',
noCancelBtn: true,
closeOnPopstate: true,
lockScroll: true,
});
};
</script>

<style lang="scss" scoped>
.desc {
display: flex;
justify-content: center;
align-items: center;
}
.preview-list {
flex: 1;
margin: 0;
Expand Down
3 changes: 3 additions & 0 deletions src/components/SubListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@
type: props.type,
general: t('subPage.panel.general'),
notify: t('subPage.copyNotify.succeed'),
tipsTitle: t(`subPage.panel.tips.title`),
tipsContent: `${t('subPage.panel.tips.content')}\n${t('syncPage.addArtForm.includeUnsupportedProxy.tips.content')}`,
desc: t(`subPage.panel.tips.desc`),
}),
onOpened: () => swipe.value.close(),
popClass: 'auto-dialog',
Expand Down
14 changes: 13 additions & 1 deletion src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ export default {
},
panel: {
general: 'General',
tips: {
desc: 'Subscription Link Parameters Description',
title: 'Subscription Link Parameters',
content: '"target=SurgeMac"\n+ ShadowsocksR/External Proxy Program\n\n"includeUnsupportedProxy=true"\nIncludes protocols not supported by the official/store version',
}
},
},
editorPage: {
Expand Down Expand Up @@ -504,7 +509,7 @@ export default {
},
deleteArt: {
title: 'Delete Sync Configuration',
desc: 'Are you sure to delete sync configuration {displayName}? \nDeleted cannot be restored!\n\n⚠️ If the current item has been synced before, an attempt will be made to delete the gist file.',
desc: 'Are you sure to delete sync configuration {displayName}? \nDeleted cannot be restored!\n\n⚠️ If the current item has been synced before, an attempt will be made to delete gist files with the original filename and the encoded filename.',
succeedNotify: 'Successfully deleted!',
btn: {
confirm: 'Delete',
Expand Down Expand Up @@ -536,6 +541,13 @@ export default {
isRequired: 'Source is required',
placeholder: 'Please select a source',
},
includeUnsupportedProxy: {
label: 'Includes protocols not supported by the official/store version',
tips: {
title: 'Includes protocols not supported by the official/store version',
content: 'sing-box: ShadowsocksR\nQuantumult X: VLESS'
}
},
platform: {
label: 'Target Platform',
isRequired: 'Target platform is required',
Expand Down
14 changes: 13 additions & 1 deletion src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ export default {
},
panel: {
general: '通用订阅',
tips: {
desc: '订阅链接参数说明',
title: '订阅链接参数',
content: '"target=SurgeMac"\n+ ShadowsocksR/External Proxy Program\n\n"includeUnsupportedProxy=true" 包含官方/商店版不支持的协议',
}
},
},
editorPage: {
Expand Down Expand Up @@ -506,7 +511,7 @@ export default {
},
deleteArt: {
title: '删除同步配置',
desc: '是否确认删除同步配置 {displayName}?删除后不可恢复!\n\n⚠️ 若当前同步配置进行过同步, 将尝试删除对应的 gist 文件',
desc: '是否确认删除同步配置 {displayName}?删除后不可恢复!\n\n⚠️ 若当前同步配置进行过同步, 将尝试原文件名和编码后的文件名对应的文件',
succeedNotify: '删除同步配置成功!',
btn: {
confirm: '确认删除',
Expand Down Expand Up @@ -541,6 +546,13 @@ export default {
label: '目标平台',
isRequired: '目标平台不能为空',
},
includeUnsupportedProxy: {
label: '包含官方/商店版不支持的协议',
tips: {
title: '包含官方/商店版不支持的协议',
content: 'sing-box: ShadowsocksR\nQuantumult X: VLESS'
}
},
pop: {
errorTitle: '提交出错',
errorBtn: '去修改',
Expand Down
1 change: 1 addition & 0 deletions src/types/store/artifacts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface Artifact {
source: string;
platform: ArtifactsPlatform;
sync?: boolean;
includeUnsupportedProxy?: boolean;
updated?: number;
url?: string;
}
Expand Down

0 comments on commit a4e9871

Please sign in to comment.