Skip to content

Commit

Permalink
feat: 预览列表增加 快捷开关 包含官方/商店版/未续费订阅不支持的协议
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Nov 21, 2024
1 parent fdc016d commit 2b86e83
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 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.299",
"version": "2.14.300",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
37 changes: 30 additions & 7 deletions src/components/PreviewPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<span>{{ desc }}</span>
<nut-icon name="tips"></nut-icon>
</div>
<div class="includeUnsupportedProxy">
<input type="checkbox" id="includeUnsupportedProxy" name="includeUnsupportedProxy" value="includeUnsupportedProxy" v-model="includeUnsupportedProxy">
<label for="includeUnsupportedProxy">包含官方/商店版/未续费订阅不支持的协议</label>
</div>
<ul class="preview-list">
<li v-for="platform in platformList" :key="platform.name">
<div class="infos">
Expand All @@ -17,9 +21,7 @@

<div class="actions">
<a
:href="`${host}/download/${
type === 'sub' ? '' : 'collection/'
}${encodeURIComponent(name)}${platform.path !== null ? `?target=${platform.path}` : ''}`"
:href="getUrl(platform.path)"
target="_blank"
>
<svg-icon
Expand All @@ -42,6 +44,7 @@
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { Toast, Dialog } from '@nutui/nutui';
import json from '@/assets/icons/json.svg';
import uri from '@/assets/icons/uri.svg';
Expand All @@ -64,6 +67,7 @@
import SvgIcon from '@/components/SvgIcon.vue';
import { useHostAPI } from '@/hooks/useHostAPI';
const includeUnsupportedProxy = ref(false);
const { copy, isSupported } = useClipboard();
const { toClipboard: copyFallback } = useV3Clipboard();
const { showNotify } = useAppNotifyStore();
Expand All @@ -80,11 +84,16 @@
}>();
const { currentUrl: host } = useHostAPI();
const targetCopy = async (path: string) => {
const urlTarget: string = path !== null ? `?target=${path}` : '';
const url = `${host.value}/download/${
const getUrl = (path: string) => {
const query = {} as Record<string, string | boolean>
if(path !== null) query.target = path;
if(includeUnsupportedProxy.value) query.includeUnsupportedProxy = true;
return `${host.value}/download/${
type === 'sub' ? '' : 'collection/'
}${encodeURIComponent(name)}${urlTarget}`;
}${encodeURIComponent(name)}${Object.keys(query).length > 0 ? `?${Object.entries(query).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join('&')}` : ''}`;
}
const targetCopy = async (path: string) => {
const url = getUrl(path);
if (isSupported) {
await copy(url);
} else {
Expand Down Expand Up @@ -190,6 +199,20 @@
</script>

<style lang="scss" scoped>
.includeUnsupportedProxy {
margin: 4px 0;
display: flex;
align-items: center;
justify-content: center;
input {
cursor: pointer;
padding: 0;
margin: 0 4px 0 0;
}
label {
cursor: pointer;
}
}
.desc {
display: flex;
justify-content: center;
Expand Down

0 comments on commit 2b86e83

Please sign in to comment.