Skip to content

Commit

Permalink
feat: 支持参数 hideExpire 隐藏到期时间
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Mar 18, 2024
1 parent ad19dbd commit 0950f43
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 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.183",
"version": "2.14.184",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
16 changes: 12 additions & 4 deletions src/components/SubListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,13 @@ const flow = computed(() => {
secondLine: ``,
};
} else if (target.status === "success") {
const {
let {
remainingDays,
expires,
total,
usage: { upload, download },
} = target.data;
if(target.hideExpire) expires = undefined;
let progress = 0;
try {
progress = 1 - (upload + download) / total
Expand All @@ -328,7 +329,9 @@ const flow = computed(() => {
const expiresInfo = !expires
? ""
: `${dayjs.unix(expires).format("YYYY-MM-DD")}`;
secondLine = secondLine ? `${secondLine} | ${expiresInfo}` : expiresInfo;
if (expiresInfo) {
secondLine = secondLine ? `${secondLine} | ${expiresInfo}` : expiresInfo;
}
return {
firstLine: `${getString(upload + download, total, "B")}`,
secondLine,
Expand All @@ -338,12 +341,17 @@ const flow = computed(() => {
secondLine = remainingDays ? `${t("subPage.subItem.remainingDays")}: ${remainingDays}${t(
"subPage.subItem.remainingDaysUnit"
)}` : ''
const expiresInfo = !expires
let expiresInfo = !expires
? t("subPage.subItem.noExpiresInfo")
: `${t("subPage.subItem.expires")}: ${dayjs
.unix(expires)
.format("YYYY-MM-DD")}`;
secondLine = secondLine ? `${secondLine} | ${expiresInfo}` : expiresInfo;
if (target.hideExpire) {
expiresInfo = ''
}
if (expiresInfo) {
secondLine = secondLine ? `${secondLine} | ${expiresInfo}` : expiresInfo;
}
return {
firstLine: `${t("subPage.subItem.flow")}: ${getString(
upload + 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 @@ -226,7 +226,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, flowUserAgent - the User-Agent for fetching subscription usage info, noFlow - do not query for flow, noCache - do not use cache, resetDay - the day when monthly data usage resets, startDate - subscription start date, cycleDays - reset cycle (in days). For example: http://a.com?token=1#cycleDays=31&startDate=2024-06-04 or http://a.com?token=1#resetDay=15',
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, flowUserAgent - the User-Agent for fetching subscription usage info, noFlow - do not query for flow, hideExpire - hide expiration time, noCache - do not use cache, resetDay - the day when monthly data usage resets, startDate - subscription start date, cycleDays - reset cycle (in days). For example: http://a.com?token=1#cycleDays=31&startDate=2024-06-04 or http://a.com?token=1#resetDay=15',
isEmpty: 'URL cannot be empty',
isIllegal: 'Invalid URL',
},
Expand Down
2 changes: 1 addition & 1 deletion src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default {
},
url: {
label: '链接',
placeholder: '订阅链接(多个订阅请换行) 支持参数: validCheck 过期或无剩余流量时报错, flowUserAgent 查询流量时使用的 User-Agent, noFlow 不查询流量, noCache 不使用缓存, resetDay 每月流量重置日, startDate 订阅开始日期, cycleDays 订阅重置周期(单位: 天). 例: http://a.com?token=1#cycleDays=31&startDate=2024-06-04 或 http://a.com?token=1#resetDay=15',
placeholder: '订阅链接(多个订阅请换行) 支持参数: validCheck 过期或无剩余流量时报错, flowUserAgent 查询流量时使用的 User-Agent, noFlow 不查询流量, hideExpire 隐藏到期, noCache 不使用缓存, resetDay 每月流量重置日, startDate 订阅开始日期, cycleDays 订阅重置周期(单位: 天). 例: http://a.com?token=1#cycleDays=31&startDate=2024-06-04 或 http://a.com?token=1#resetDay=15',
isEmpty: '订阅链接不能为空',
isIllegal: '订阅链接格式非法',
},
Expand Down
4 changes: 2 additions & 2 deletions src/store/subs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ export const useSubsStore = defineStore('subsStore', {
}
},
async fetchFlows(sub?: Sub[]) {
const asyncGetFlow = async ([url, name, noFlow]) => {
const asyncGetFlow = async ([url, name, noFlow, hideExpire]) => {
if (noFlow) {
this.flows[url] = { status:'noFlow' };
} else {
const { data } = await subsApi.getFlow(name);
this.flows[url] = data;
this.flows[url] = {...data, hideExpire };
}
};
// const subs = sub || this.subs;
Expand Down
1 change: 1 addition & 0 deletions src/types/store/subsStore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ interface Artifacts {

interface Flow {
status: 'success' | 'noFlow';
hideExpire?: boolean;
data: {
remainingDays?: number;
expires?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getFlowsUrlList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export const getFlowsUrlList = (subs: Sub[]): string[][] => {
}
}
}
return [raw, name, $arguments?.noFlow];
return [raw, name, $arguments?.noFlow, $arguments?.hideExpire];
});
};

0 comments on commit 0950f43

Please sign in to comment.