Skip to content

Commit

Permalink
feat: 支持显示剩余重置天数(后端 > 2.14.246 且订阅设置了 resetDay)
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Mar 10, 2024
1 parent ae406f4 commit 8a2cb5a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 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.156",
"version": "2.14.157",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
2 changes: 1 addition & 1 deletion src/components/ArtifactsListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ watch(isSyncOpen, async () => {
flex-shrink: 0;
width: 56px;
height: 56px;
margin-right: 20px;
margin-right: 15px;
border-radius: 12px;
img {
Expand Down
2 changes: 1 addition & 1 deletion src/components/FileListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@
flex-shrink: 0;
width: 56px;
height: 56px;
margin-right: 20px;
margin-right: 15px;
border-radius: 12px;
img {
Expand Down
29 changes: 20 additions & 9 deletions src/components/SubListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@
</span>
</template>
<template v-else>
<span style="font-weight: normal">
{{ flow.firstLine }} &nbsp;
<span v-if="flow.secondLine" style="font-weight: normal">
{{ flow.firstLine + ' | ' + flow.secondLine }}
</span>
<span v-else style="font-weight: normal">
{{ flow.firstLine }}
</span>
<span style="font-weight: normal">{{ flow.secondLine }}</span>
</template>
</p>
<p v-else-if="type === 'collection'" class="sub-item-detail-isSimple">
Expand Down Expand Up @@ -273,7 +275,7 @@ const collectionDetail = computed(() => {
const sub = subsStore.getOneSub(name);
return sub?.displayName || sub?.["display-name"] || sub.name;
});
return `${t("subPage.collectionItem.contain")}${displayNameList.join(
return `${t("subPage.collectionItem.contain")}: ${displayNameList.join(
""
)}`;
}
Expand Down Expand Up @@ -302,6 +304,7 @@ const flow = computed(() => {
};
} else if (target.status === "success") {
const {
remainingDays,
expires,
total,
usage: { upload, download },
Expand All @@ -316,22 +319,30 @@ const flow = computed(() => {
}
let secondLine: string;
if (isSimpleMode.value) {
secondLine = !expires
secondLine = remainingDays ? `${remainingDays}${t(
"subPage.subItem.remainingDaysUnit"
)}` : ''
const expiresInfo = !expires
? ""
: `${dayjs.unix(expires).format("YYYY-MM-DD")}`;
secondLine = secondLine ? `${secondLine} | ${expiresInfo}` : expiresInfo;
return {
firstLine: `${getString(upload + download, total, "B")}`,
secondLine,
progress
};
} else {
secondLine = !expires
secondLine = remainingDays ? `${t("subPage.subItem.remainingDays")}: ${remainingDays}${t(
"subPage.subItem.remainingDaysUnit"
)}` : ''
const expiresInfo = !expires
? t("subPage.subItem.noExpiresInfo")
: `${t("subPage.subItem.expires")}${dayjs
: `${t("subPage.subItem.expires")}: ${dayjs
.unix(expires)
.format("YYYY-MM-DD")}`;
secondLine = secondLine ? `${secondLine} | ${expiresInfo}` : expiresInfo;
return {
firstLine: `${t("subPage.subItem.flow")}${getString(
firstLine: `${t("subPage.subItem.flow")}: ${getString(
upload + download,
total,
"B"
Expand Down Expand Up @@ -568,7 +579,7 @@ const onClickRefresh = async () => {
flex-shrink: 0;
width: 56px;
height: 56px;
margin-right: 20px;
margin-right: 15px;
border-radius: 12px;
img {
Expand Down
4 changes: 3 additions & 1 deletion src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export default {
loading: 'Loading...',
flow: 'Usage / Total',
expires: 'Expires',
remainingDays: 'Remaining Reset Days',
remainingDaysUnit: '',
noRecord: 'Refresh to get usage',
noFlow: 'No flow',
noFlowInfo: 'No flow info',
Expand Down Expand Up @@ -217,7 +219,7 @@ export default {
},
url: {
label: 'URL',
placeholder: 'Subscription URL (please separate multiple subscriptions with a new line). Supported parameters: validCheck - error will be reported when expired or there is no remaining traffic, noFlow - do not query for flow, noCache - do not use cache. For example: http://a.com?token=1#noFlow&noCache',
placeholder: 'Subscription URL (please separate multiple subscriptions with a new line). Supported parameters: validCheck - error will be reported when expired or there is no remaining traffic, resetDay - the day when monthly data usage resets, noFlow - do not query for flow, noCache - do not use cache. For example: http://a.com?token=1#noFlow&noCache or http://a.com?token=1#resetDay=15',
isEmpty: 'URL cannot be empty',
isIllegal: 'Invalid URL',
},
Expand Down
6 changes: 4 additions & 2 deletions src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ export default {
local: '本地订阅',
loading: '加载中...',
flow: '已用/总流量',
expires: '到期时间',
expires: '到期',
remainingDays: '重置',
remainingDaysUnit: ' 天',
noRecord: '刷新后可获取流量情况',
noFlow: '不查询流量',
noFlowInfo: '无流量信息',
Expand Down Expand Up @@ -217,7 +219,7 @@ export default {
},
url: {
label: '链接',
placeholder: '订阅链接(多个订阅请换行) 支持参数: validCheck 过期或无剩余流量时报错, noFlow 不查询流量, noCache 不使用缓存. 例: http://a.com?token=1#noFlow&noCache',
placeholder: '订阅链接(多个订阅请换行) 支持参数: validCheck 过期或无剩余流量时报错, resetDay 每月流量重置日, noFlow 不查询流量, noCache 不使用缓存. 例: http://a.com?token=1#noFlow&noCache 或 http://a.com?token=1#resetDay=15',
isEmpty: '订阅链接不能为空',
isIllegal: '订阅链接格式非法',
},
Expand Down
3 changes: 2 additions & 1 deletion src/types/store/subsStore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ interface Artifacts {
interface Flow {
status: 'success' | 'noFlow';
data: {
expires: number;
remainingDays?: number;
expires?: number;
total: number;
usage: {
upload: number;
Expand Down

0 comments on commit 8a2cb5a

Please sign in to comment.