From 7b175147e2003bafcb7bdbe51c7404733a698e8f Mon Sep 17 00:00:00 2001 From: Leo Wang Date: Sun, 6 Aug 2023 02:34:44 +0800 Subject: [PATCH] [optimize] update index.tsx getStaticProps ISR --- package.json | 2 +- pages/index.tsx | 42 +++++++++++++++++++-------------------- pnpm-lock.yaml | 52 +++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 65 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index 39c93ef..05d04a3 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "mobx-lark": "^1.0.0-beta.6", "mobx-react": "^6.3.1", "mobx-restful": "^0.6.5", - "mobx-restful-table": "^1.0.2", + "mobx-restful-table": "^1.0.4", "next": "^12.3.4", "react": "^17.0.2", "react-bootstrap": "^2.7.4", diff --git a/pages/index.tsx b/pages/index.tsx index c754928..85dc196 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -15,31 +15,29 @@ import { ProjectModel } from '../models/Project'; import { RepositoryModel } from '../models/Repository'; import { i18n } from '../models/Translation'; import styles from '../styles/Home.module.less'; -import { getTarget, withErrorLog, withTranslation } from './api/core'; +import { getTarget } from './api/core'; import { service } from './api/home'; -export const getServerSideProps = withErrorLog( - withTranslation(async () => { - const [projects, repositories, partners, members] = await Promise.all([ - new ProjectModel().getList({}, 1, 9), - new RepositoryModel().getList(), - new ClientModel().getList({ partnership: '战略合作' }), - new MemberModel().getList({ type: '全职' }), - ]); +export const getServerSideProps = async () => { + const [projects, repositories, partners, members] = await Promise.all([ + new ProjectModel().getList({}, 1, 9), + new RepositoryModel().getList(), + new ClientModel().getList({ partnership: '战略合作' }), + new MemberModel().getList({ type: '全职' }), + ]); - return { - props: { - projects, - repositories, - partners, - members: [...members].sort( - ({ joinedAt: a }, { joinedAt: b }) => - +new Date(a as number) - +new Date(b as number), - ), - }, - }; - }), -); + return { + props: { + projects, + repositories, + partners, + members: [...members].sort( + ({ joinedAt: a }, { joinedAt: b }) => + +new Date(a as number) - +new Date(b as number), + ), + }, + }; +}; const { t } = i18n; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 65e7f15..e327c0c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,9 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + dependencies: classnames: specifier: ^2.3.2 @@ -32,8 +36,8 @@ dependencies: specifier: ^0.6.5 version: 0.6.5(jsdom@21.1.2)(mobx@5.15.7)(typescript@5.1.3) mobx-restful-table: - specifier: ^1.0.2 - version: 1.0.2(@types/react@17.0.60)(jsdom@21.1.2)(mobx@5.15.7)(react-dom@17.0.2)(react@17.0.2)(typescript@5.1.3) + specifier: ^1.0.4 + version: 1.0.4(@types/react@17.0.60)(mobx-i18n@0.3.14)(mobx-react@6.3.1)(mobx-restful@0.6.5)(mobx@5.15.7)(react-dom@17.0.2)(react@17.0.2)(typescript@5.1.3) next: specifier: ^12.3.4 version: 12.3.4(@babel/core@7.22.1)(react-dom@17.0.2)(react@17.0.2) @@ -4356,11 +4360,14 @@ packages: - react-native dev: false - /mobx-restful-table@1.0.2(@types/react@17.0.60)(jsdom@21.1.2)(mobx@5.15.7)(react-dom@17.0.2)(react@17.0.2)(typescript@5.1.3): - resolution: {integrity: sha512-8BmQXAvTnEry5vtMU+hzvbVZyn//cqwAJF1T+rTI6F+MB5YXgUX+t8ikTSZYXzkdfvEf/huZ0JgfRyKPHz5Tdw==} + /mobx-restful-table@1.0.4(@types/react@17.0.60)(mobx-i18n@0.3.14)(mobx-react@6.3.1)(mobx-restful@0.6.5)(mobx@5.15.7)(react-dom@17.0.2)(react@17.0.2)(typescript@5.1.3): + resolution: {integrity: sha512-YyNAysIUeE908yCyGX+NyN3zILuDL9dZz9p+ZRDJGQKz1pz9Ri7IWPPMhfqtDlQr4XN9Fe4kFIMxX4jgVWhf4g==} peerDependencies: mobx: '>=4 <6' - react: '>=16 <18' + mobx-i18n: ^0.3 + mobx-react: ^6 + mobx-restful: ^0.6 + react: '>=16.8' dependencies: '@swc/helpers': 0.4.14 classnames: 2.3.2 @@ -4370,14 +4377,12 @@ packages: mobx-react: 6.3.1(mobx@5.15.7)(react-dom@17.0.2)(react@17.0.2) mobx-restful: 0.6.5(jsdom@21.1.2)(mobx@5.15.7)(typescript@5.1.3) react: 17.0.2 - react-bootstrap: 2.7.4(@types/react@17.0.60)(react-dom@17.0.2)(react@17.0.2) + react-bootstrap: 2.8.0(@types/react@17.0.60)(react-dom@17.0.2)(react@17.0.2) regenerator-runtime: 0.13.11 web-utility: 4.0.0(typescript@5.1.3) transitivePeerDependencies: - '@types/react' - - jsdom - react-dom - - react-native - typescript dev: false @@ -4851,6 +4856,7 @@ packages: /prr@1.0.1: resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} + requiresBuild: true dev: true optional: true @@ -4902,6 +4908,33 @@ packages: warning: 4.0.3 dev: false + /react-bootstrap@2.8.0(@types/react@17.0.60)(react-dom@17.0.2)(react@17.0.2): + resolution: {integrity: sha512-e/aNtxl0Z2ozrIaR82jr6Zz7ss9GSoaXpQaxmvtDUsTZIq/XalkduR/ZXP6vbQHz2T4syvjA+4FbtwELxxmpww==} + peerDependencies: + '@types/react': '>=16.14.8' + react: '>=16.14.0' + react-dom: '>=16.14.0' + peerDependenciesMeta: + '@types/react': + optional: true + dependencies: + '@babel/runtime': 7.22.3 + '@restart/hooks': 0.4.9(react@17.0.2) + '@restart/ui': 1.6.6(react-dom@17.0.2)(react@17.0.2) + '@types/react': 17.0.60 + '@types/react-transition-group': 4.4.6 + classnames: 2.3.2 + dom-helpers: 5.2.1 + invariant: 2.2.4 + prop-types: 15.8.1 + prop-types-extra: 1.1.1(react@17.0.2) + react: 17.0.2 + react-dom: 17.0.2(react@17.0.2) + react-transition-group: 4.4.5(react-dom@17.0.2)(react@17.0.2) + uncontrollable: 7.2.1(react@17.0.2) + warning: 4.0.3 + dev: false + /react-dom@17.0.2(react@17.0.2): resolution: {integrity: sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==} peerDependencies: @@ -5163,9 +5196,11 @@ packages: /safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + requiresBuild: true /sax@1.2.4: resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==} + requiresBuild: true dev: true optional: true @@ -5202,6 +5237,7 @@ packages: /semver@5.7.1: resolution: {integrity: sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==} hasBin: true + requiresBuild: true dev: true optional: true