From 97ceae5e3e19856f9fcbdbc4f91dbb655481c788 Mon Sep 17 00:00:00 2001 From: Leo Wang Date: Sun, 6 Aug 2023 03:53:25 +0800 Subject: [PATCH] [optimize] update build client --- models/Base.ts | 14 ++++++++------ pages/index.tsx | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/models/Base.ts b/models/Base.ts index 2714a06..cf6e7ff 100644 --- a/models/Base.ts +++ b/models/Base.ts @@ -1,5 +1,7 @@ import { HTTPClient } from 'koajax'; +import { lark } from '../pages/api/Lark/core'; + export const isServer = () => typeof window === 'undefined'; export const VercelHost = process.env.VERCEL_URL, @@ -14,12 +16,12 @@ const API_Host = isServer() const { BUILDING } = process.env; -export const larkClient = new HTTPClient({ - baseURI: BUILDING - ? 'https://open.feishu.cn/open-apis/' - : `${API_Host}/api/Lark/`, - responseType: 'json', -}); +export const larkClient = BUILDING + ? lark.client + : new HTTPClient({ + baseURI: `${API_Host}/api/Lark/`, + responseType: 'json', + }); export const githubClient = new HTTPClient({ baseURI: 'https://api.github.com/', diff --git a/pages/index.tsx b/pages/index.tsx index 021a671..3833ff9 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -17,8 +17,10 @@ import { i18n } from '../models/Translation'; import styles from '../styles/Home.module.less'; import { getTarget } from './api/core'; import { service } from './api/home'; +import { lark } from './api/Lark/core'; export const getStaticProps = async () => { + await lark.getAccessToken(); const [projects, repositories, partners, members] = await Promise.all([ new ProjectModel().getList({}, 1, 9), new RepositoryModel().getList(),