From 6e8829aac0be77c336e2aa1489db40d9857ebb11 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Wed, 11 Jan 2023 06:07:13 +0800 Subject: [PATCH] refactor: license price list --- package.json | 2 +- src/app/config.ts | 37 +++++++++++++++---- .../setting/License/LicensePriceListModal.tsx | 3 +- src/service-worker.ts | 2 +- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 0269e96f..4d3a584d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vocechat-web", - "version": "0.3.32", + "version": "0.3.33", "private": true, "homepage": "https://voce.chat", "dependencies": { diff --git a/src/app/config.ts b/src/app/config.ts index e93b40ce..761b9959 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -10,24 +10,44 @@ let prices: Price[] = [ { type: "subscription", // sub_type: "year", //day month year - title: i18n.t("price.pro.title"), + title: "Pro", limit: 100, pid: "price_1MN8C7GGoUDRyc3jos06bCqM", - desc: i18n.t("price.pro.desc"), + desc: "Pro Desc", }, { type: "payment", - title: i18n.t("price.supreme.title"), + title: "supreme", limit: 99999, pid: "price_1M5VoGGGoUDRyc3j6xhQou6D", - desc: i18n.t("price.supreme.desc"), + desc: "supreme desc", } ]; -export const LicensePriceList: Price[] = - process.env.NODE_ENV === "development" +export const getLicensePriceList = () => { + const ps = prices.map((p, idx) => { + switch (idx) { + // pro + case 0: { + p.title = i18n.t("price.pro.title"); + p.desc = i18n.t("price.pro.desc"); + } + break; + // supreme + case 1: { + p.title = i18n.t("price.supreme.title"); + p.desc = i18n.t("price.supreme.desc"); + } + break; + + default: + break; + } + return p; + }); + return process.env.NODE_ENV === "development" // 开发环境加入两个测试价格 ? [ - ...prices, + ...ps, { type: "payment", title: "Test VoceChat Enterprise", @@ -44,7 +64,8 @@ export const LicensePriceList: Price[] = sub_dur: "year", //day month year }, ] - : prices; + : ps; +}; export const PAYMENT_URL_PREFIX = process.env.NODE_ENV === "production" ? `https://vera.nicegoodthings.com` diff --git a/src/routes/setting/License/LicensePriceListModal.tsx b/src/routes/setting/License/LicensePriceListModal.tsx index c6709cb8..9f8aa32a 100644 --- a/src/routes/setting/License/LicensePriceListModal.tsx +++ b/src/routes/setting/License/LicensePriceListModal.tsx @@ -6,7 +6,7 @@ import Button from "../../../common/component/styled/Button"; import StyledRadio from "../../../common/component/styled/Radio"; import { useGetLicensePaymentUrlMutation } from "../../../app/services/server"; -import { LicensePriceList } from "../../../app/config"; +import { getLicensePriceList } from "../../../app/config"; import { useTranslation } from "react-i18next"; import dayjs from "dayjs"; import { PriceSubscriptionDuration, PriceType } from "../../../types/common"; @@ -36,6 +36,7 @@ const getExpireDay = (sub_dur: PriceSubscriptionDuration) => { }; return res.format("YYYY-MM-DD"); }; +const LicensePriceList = getLicensePriceList(); const LicensePriceListModal: FC = ({ closeModal }) => { const { t } = useTranslation("setting"); const { t: ct } = useTranslation(); diff --git a/src/service-worker.ts b/src/service-worker.ts index 1076f36e..546cc28b 100644 --- a/src/service-worker.ts +++ b/src/service-worker.ts @@ -69,7 +69,7 @@ registerRoute( plugins: [ // Ensure that once this runtime cache reaches a maximum size the // least-recently used images are removed. - new ExpirationPlugin({ maxEntries: 100, maxAgeSeconds: 30 * 60 }) + new ExpirationPlugin({ maxEntries: 100, maxAgeSeconds: 5 * 60 }) ] }) );