From 65bd3ac5fa0c7623144369eb42eb3dc2e592ebb5 Mon Sep 17 00:00:00 2001 From: xream Date: Fri, 12 Jan 2024 07:22:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=87=E4=BB=B6=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B/=E5=90=88=E5=B9=B6(=E5=90=8E=E7=AB=AF=20>=20?= =?UTF-8?q?2.14.146)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/components/FileListItem.vue | 98 ++++++++++++------------------ src/locales/en.ts | 17 +++++- src/locales/zh.ts | 17 +++++- src/views/FileEditor.vue | 104 ++++++++++++++++++++++++++++++-- 5 files changed, 167 insertions(+), 71 deletions(-) diff --git a/package.json b/package.json index 98c153e90..484bc0117 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sub-store-front-end", - "version": "2.14.38", + "version": "2.14.39", "private": true, "scripts": { "dev": "vite --host", diff --git a/src/components/FileListItem.vue b/src/components/FileListItem.vue index 4e1aa60e8..f8226fa77 100644 --- a/src/components/FileListItem.vue +++ b/src/components/FileListItem.vue @@ -37,7 +37,10 @@
-

+

+ {{ displayName || name }} +

+

{{ displayName || name }}

@@ -73,7 +76,37 @@
- + + + @@ -222,65 +255,8 @@ }); const flow = computed(() => { - if (props.type === 'sub') { - const urlList = Object.keys(flows.value); - if (props.sub.source === 'local') return t('subPage.subItem.local'); - if (isFlowFetching.value && !urlList.includes(props.sub.url)) - return t('subPage.subItem.loading'); - - const target = toRaw(flows.value[props.sub.url]); - if (!target) { - return { - firstLine: t('subPage.subItem.noRecord'), - secondLine: ``, - }; - } - - if (target.status === 'success') { - const { - expires, - total, - usage: { upload, download }, - } = target.data; - - let secondLine: string; - if (isSimpleMode.value) { - secondLine = !expires - ? '' - : `${dayjs.unix(expires).format('YYYY-MM-DD')}`; - return { - firstLine: `${getString(upload + download, total, 'B')}`, - secondLine, - }; - } else { - secondLine = !expires - ? t('subPage.subItem.noExpiresInfo') - : `${t('subPage.subItem.expires')}:${dayjs - .unix(expires) - .format('YYYY-MM-DD')}`; - return { - firstLine: `${t('subPage.subItem.flow')}:${getString( - upload + download, - total, - 'B' - )}`, - secondLine, - }; - } - } else if (target?.status === 'failed') { - if (target.error.code === 'NO_FLOW_INFO') { - return { - firstLine: t('subPage.subItem.noFlowInfo'), - secondLine: ``, - }; - } else { - return { - firstLine: `${target.error?.type}`, - secondLine: `${target.error?.message}`, - }; - } - } - } + if (props.file.source === 'remote') return t('filePage.source.remote'); + return t('filePage.source.local'); }); const closePreview = () => { diff --git a/src/locales/en.ts b/src/locales/en.ts index bfeec594b..2c22ccace 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -68,6 +68,12 @@ export default { content: { placeholder: 'The content of the file' }, + url: { + label: 'URL', + placeholder: 'URL (please separate multiple urls with a new line)', + isEmpty: 'URL cannot be empty', + isIllegal: 'Invalid URL', + }, copyNotify: { succeed: 'Successfully copied link!\nIf you use it internally, just {path}', failed: 'Failed to copy file link!\n{e}', @@ -77,6 +83,13 @@ export default { desc: 'After adding you can enjoy the love of YM Peng', btn: 'Create File Now', }, + source: { + local: 'Local', + remote: 'Remote', + }, + ignoreFailedRemoteFile: { + label: 'Ignore failed remote file(s)' + }, }, // subscription management page subPage: { @@ -120,7 +133,7 @@ export default { }, }, copyNotify: { - succeed: 'Successfully copied link!\nYou can paste in Proxy Tool now!', + succeed: 'Successfully copied link!', failed: 'Failed to copy subscription link!\n{e}', }, copyConfigNotify: { @@ -214,7 +227,7 @@ export default { ua: { label: 'User-Agent', placeholder: - 'The User-Agent for downloading the original subscription', + 'The User-Agent for downloading resource(s)', }, }, commonOptions: { diff --git a/src/locales/zh.ts b/src/locales/zh.ts index e65311f97..6d03d3ed5 100644 --- a/src/locales/zh.ts +++ b/src/locales/zh.ts @@ -68,6 +68,12 @@ export default { content: { placeholder: '填入文件内容' }, + url: { + label: '链接', + placeholder: '链接(多个链接请换行)', + isEmpty: '链接不能为空', + isIllegal: '链接格式非法', + }, copyNotify: { succeed: '复制文件链接成功\n如果你只在内部使用, 仅需 {path}', failed: '复制文件链接失败\n{e}', @@ -77,6 +83,13 @@ export default { desc: '添加后开始使用文件', btn: '立即添加', }, + source: { + local: '本地', + remote: '远程', + }, + ignoreFailedRemoteFile: { + label: '忽略失败的远程文件' + }, }, // 订阅管理页 subPage: { @@ -213,7 +226,7 @@ export default { }, ua: { label: 'User-Agent', - placeholder: '下载订阅使用的 UA,不填使用默认', + placeholder: '下载时使用的 UA,不填使用默认', }, }, commonOptions: { @@ -497,7 +510,7 @@ export default { }, }, copyNotify: { - succeed: '复制 Gist 链接成功\n可以前往代理工具使用咯~', + succeed: '复制 Gist 链接成功', failed: '复制 Gist 链接失败\n{e}', }, addArtForm: { diff --git a/src/views/FileEditor.vue b/src/views/FileEditor.vue index 8eadeff96..b7fc78364 100644 --- a/src/views/FileEditor.vue +++ b/src/views/FileEditor.vue @@ -53,7 +53,49 @@ type="text" /> + +
+ + {{ $t(`filePage.source.remote`) }} + + {{ $t(`filePage.source.local`) }} + + +
+
+ + + @@ -68,11 +110,47 @@ type="text" /> + + + + - - - - + +
+ + {{ $t(`editorPage.subConfig.basic.source.noMerge`) }} + + {{ $t(`editorPage.subConfig.basic.source.localFirst`) }} + + {{ $t(`editorPage.subConfig.basic.source.remoteFirst`) }} + + +
+
+ +
+ +
+
0) { @@ -344,6 +427,17 @@ }); }; + // url 格式验证器 + const urlValidator = (val: string): Promise => { + return new Promise(resolve => { + if (/\n/.test(val)) { + resolve(val.split(/[\r\n]+/).map(i => i.trim()).filter(i => i.length).every(i => /^(http|https):\/\/\S+$/.test(i))) + } else { + resolve(/^(http|https):\/\/\S+$/.test(val)); + } + + }); + }; // 失去焦点触发验证 const customerBlurValidate = (prop: string) => { ruleForm.value.validate(prop);