Skip to content

Commit

Permalink
add openwechat enabled
Browse files Browse the repository at this point in the history
Signed-off-by: jingyang <3161362058@qq.com>
  • Loading branch information
zjy365 committed Feb 3, 2024
1 parent 54fe440 commit 4488c80
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
13 changes: 8 additions & 5 deletions frontend/desktop/src/components/signin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ export default function SigninComponent() {
service_protocol_en = '',
private_protocol_en = '',
needPassword = false,
needSms = false
needSms = false,
openWechatEnabled = false
} = platformEnv?.data || {};
const needTabs = needPassword && needSms;
const needTabs = (needPassword && needSms) || (needSms && openWechatEnabled);

const disclosure = useDisclosure();
const { t, i18n } = useTranslation();
Expand Down Expand Up @@ -180,9 +181,11 @@ export default function SigninComponent() {
<Tab px="0" _selected={{ color: 'white' }}>
{t('Password Login')}
</Tab>
<Tab px="0" _selected={{ color: 'white' }}>
{t('Official account login')}
</Tab>
{openWechatEnabled && (
<Tab px="0" _selected={{ color: 'white' }}>
{t('Official account login')}
</Tab>
)}
</TabList>
<TabIndicator mt="-2px" height="2px" bg="#FFFFFF" borderRadius="1px" />
</Tabs>
Expand Down
7 changes: 5 additions & 2 deletions frontend/desktop/src/pages/api/platform/getEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
enableStripe,
enableWechatRecharge,
enableLicense,
enableRecharge
enableRecharge,
enableOpenWechat
} from '@/services/enable';
import { ApiResp, SystemEnv } from '@/types';

Expand All @@ -32,6 +33,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const licenseEnabled = enableLicense();
const rechargeEnabled = enableRecharge();
const guideEnabled = process.env.GUIDE_ENABLED === 'true';
const openWechatEnabled = enableOpenWechat();

jsonRes<SystemEnv>(res, {
data: {
Expand All @@ -53,7 +55,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
wechatEnabledRecharge,
rechargeEnabled,
licenseEnabled,
guideEnabled
guideEnabled,
openWechatEnabled
}
});
}
2 changes: 2 additions & 0 deletions frontend/desktop/src/services/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const enableGoogle = () =>
export const enableRecharge = () => {
return process.env.RECHARGE_ENABLED === 'true';
};
export const enableOpenWechat = () =>
!!process.env.PBULIC_WECHAT_APP_ID && !!process.env.PBULIC_WECHAT_APP_SECRET;
export const enableSignUp = () => process.env.SIGN_UP_ENABLED === 'true';
export const enableApi = () => process.env.API_ENABLED === 'true';
// costcenter
Expand Down
1 change: 1 addition & 0 deletions frontend/desktop/src/types/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export type SystemEnv = {
rechargeEnabled: boolean;
licenseEnabled: boolean;
guideEnabled: boolean;
openWechatEnabled: boolean;
} & LoginProps;

0 comments on commit 4488c80

Please sign in to comment.