refactor: license price list

This commit is contained in:
Tristan Yang
2023-01-11 06:07:13 +08:00
parent af97379a84
commit 6e8829aac0
4 changed files with 33 additions and 11 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "vocechat-web", "name": "vocechat-web",
"version": "0.3.32", "version": "0.3.33",
"private": true, "private": true,
"homepage": "https://voce.chat", "homepage": "https://voce.chat",
"dependencies": { "dependencies": {
+29 -8
View File
@@ -10,24 +10,44 @@ let prices: Price[] = [
{ {
type: "subscription", type: "subscription",
// sub_type: "year", //day month year // sub_type: "year", //day month year
title: i18n.t("price.pro.title"), title: "Pro",
limit: 100, limit: 100,
pid: "price_1MN8C7GGoUDRyc3jos06bCqM", pid: "price_1MN8C7GGoUDRyc3jos06bCqM",
desc: i18n.t("price.pro.desc"), desc: "Pro Desc",
}, },
{ {
type: "payment", type: "payment",
title: i18n.t("price.supreme.title"), title: "supreme",
limit: 99999, limit: 99999,
pid: "price_1M5VoGGGoUDRyc3j6xhQou6D", pid: "price_1M5VoGGGoUDRyc3j6xhQou6D",
desc: i18n.t("price.supreme.desc"), desc: "supreme desc",
} }
]; ];
export const LicensePriceList: Price[] = export const getLicensePriceList = () => {
process.env.NODE_ENV === "development" 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", type: "payment",
title: "Test VoceChat Enterprise", title: "Test VoceChat Enterprise",
@@ -44,7 +64,8 @@ export const LicensePriceList: Price[] =
sub_dur: "year", //day month year sub_dur: "year", //day month year
}, },
] ]
: prices; : ps;
};
export const PAYMENT_URL_PREFIX = export const PAYMENT_URL_PREFIX =
process.env.NODE_ENV === "production" process.env.NODE_ENV === "production"
? `https://vera.nicegoodthings.com` ? `https://vera.nicegoodthings.com`
@@ -6,7 +6,7 @@ import Button from "../../../common/component/styled/Button";
import StyledRadio from "../../../common/component/styled/Radio"; import StyledRadio from "../../../common/component/styled/Radio";
import { useGetLicensePaymentUrlMutation } from "../../../app/services/server"; import { useGetLicensePaymentUrlMutation } from "../../../app/services/server";
import { LicensePriceList } from "../../../app/config"; import { getLicensePriceList } from "../../../app/config";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { PriceSubscriptionDuration, PriceType } from "../../../types/common"; import { PriceSubscriptionDuration, PriceType } from "../../../types/common";
@@ -36,6 +36,7 @@ const getExpireDay = (sub_dur: PriceSubscriptionDuration) => {
}; };
return res.format("YYYY-MM-DD"); return res.format("YYYY-MM-DD");
}; };
const LicensePriceList = getLicensePriceList();
const LicensePriceListModal: FC<Props> = ({ closeModal }) => { const LicensePriceListModal: FC<Props> = ({ closeModal }) => {
const { t } = useTranslation("setting"); const { t } = useTranslation("setting");
const { t: ct } = useTranslation(); const { t: ct } = useTranslation();
+1 -1
View File
@@ -69,7 +69,7 @@ registerRoute(
plugins: [ plugins: [
// Ensure that once this runtime cache reaches a maximum size the // Ensure that once this runtime cache reaches a maximum size the
// least-recently used images are removed. // least-recently used images are removed.
new ExpirationPlugin({ maxEntries: 100, maxAgeSeconds: 30 * 60 }) new ExpirationPlugin({ maxEntries: 100, maxAgeSeconds: 5 * 60 })
] ]
}) })
); );