mirror of https://github.com/fantasticit/think.git
feat: improve data fetch
This commit is contained in:
parent
4b2722757d
commit
0c37cdf403
|
@ -66,7 +66,7 @@ export const toggleCollectWiki = (wikiId, cookie = null): Promise<boolean> => {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const useWikiCollectToggle = (wikiId) => {
|
export const useWikiCollectToggle = (wikiId) => {
|
||||||
const { data, error, refetch } = useQuery(`${CollectorApiDefinition.check.client()}?wikiId=${wikiId}`, () =>
|
const { data, error, refetch } = useQuery([CollectorApiDefinition.check.client(), wikiId], () =>
|
||||||
getWikiIsCollected(wikiId)
|
getWikiIsCollected(wikiId)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,11 @@ export const getDocumentChildren = (data, cookie = null): Promise<Array<IDocumen
|
||||||
*/
|
*/
|
||||||
export const useChildrenDocument = ({ wikiId, documentId, isShare = false }) => {
|
export const useChildrenDocument = ({ wikiId, documentId, isShare = false }) => {
|
||||||
const { data, error, refetch } = useQuery(
|
const { data, error, refetch } = useQuery(
|
||||||
isShare ? DocumentApiDefinition.getPublicChildren.client() : DocumentApiDefinition.getChildren.client(),
|
[
|
||||||
|
isShare ? DocumentApiDefinition.getPublicChildren.client() : DocumentApiDefinition.getChildren.client(),
|
||||||
|
wikiId,
|
||||||
|
documentId,
|
||||||
|
],
|
||||||
() => getDocumentChildren({ wikiId, documentId, isShare })
|
() => getDocumentChildren({ wikiId, documentId, isShare })
|
||||||
);
|
);
|
||||||
const loading = !data && !error;
|
const loading = !data && !error;
|
||||||
|
|
|
@ -13,7 +13,15 @@ import { Hydrate, QueryClient, QueryClientProvider } from 'react-query';
|
||||||
|
|
||||||
class MyApp extends App<{ isMobile: boolean }> {
|
class MyApp extends App<{ isMobile: boolean }> {
|
||||||
state = {
|
state = {
|
||||||
queryClient: new QueryClient(),
|
queryClient: new QueryClient({
|
||||||
|
defaultOptions: {
|
||||||
|
queries: {
|
||||||
|
refetchOnWindowFocus: true,
|
||||||
|
retry: false,
|
||||||
|
staleTime: 30000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
static getInitialProps = async ({ Component, ctx }) => {
|
static getInitialProps = async ({ Component, ctx }) => {
|
||||||
|
|
|
@ -65,7 +65,6 @@ const RecentDocs = () => {
|
||||||
}}
|
}}
|
||||||
/>,
|
/>,
|
||||||
<Column title="访问时间" dataIndex="visitedAt" key="visitedAt" render={(date) => <LocaleTime date={date} />} />,
|
<Column title="访问时间" dataIndex="visitedAt" key="visitedAt" render={(date) => <LocaleTime date={date} />} />,
|
||||||
<Column title="更新时间" dataIndex="updatedAt" key="updatedAt" render={(date) => <LocaleTime date={date} />} />,
|
|
||||||
<Column
|
<Column
|
||||||
title="操作"
|
title="操作"
|
||||||
dataIndex="operate"
|
dataIndex="operate"
|
||||||
|
|
|
@ -8,7 +8,6 @@ import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, use
|
||||||
import { IndexeddbPersistence } from 'tiptap/core/y-indexeddb';
|
import { IndexeddbPersistence } from 'tiptap/core/y-indexeddb';
|
||||||
|
|
||||||
import { Editor } from '../../react';
|
import { Editor } from '../../react';
|
||||||
import { ReaderEditor } from '../reader';
|
|
||||||
import { EditorInstance } from './editor';
|
import { EditorInstance } from './editor';
|
||||||
import styles from './index.module.scss';
|
import styles from './index.module.scss';
|
||||||
import { ICollaborationEditorProps, ProviderStatus } from './type';
|
import { ICollaborationEditorProps, ProviderStatus } from './type';
|
||||||
|
@ -27,7 +26,6 @@ export const CollaborationEditor = forwardRef((props: ICollaborationEditorProps,
|
||||||
onTitleUpdate,
|
onTitleUpdate,
|
||||||
user,
|
user,
|
||||||
menubar,
|
menubar,
|
||||||
initialContent,
|
|
||||||
renderInEditorPortal,
|
renderInEditorPortal,
|
||||||
onAwarenessUpdate,
|
onAwarenessUpdate,
|
||||||
} = props;
|
} = props;
|
||||||
|
@ -100,16 +98,12 @@ export const CollaborationEditor = forwardRef((props: ICollaborationEditorProps,
|
||||||
<DataRender
|
<DataRender
|
||||||
loading={loading}
|
loading={loading}
|
||||||
loadingContent={
|
loadingContent={
|
||||||
initialContent ? (
|
<div style={{ width: 174, margin: 'auto' }}>
|
||||||
<ReaderEditor content={initialContent} />
|
<Spin tip="正在加载中...">
|
||||||
) : (
|
{/* FIXME: semi-design 的问题,不加 div,文字会换行! */}
|
||||||
<div style={{ width: 174, margin: 'auto' }}>
|
<div></div>
|
||||||
<Spin tip="正在为您加载编辑器中...">
|
</Spin>
|
||||||
{/* FIXME: semi-design 的问题,不加 div,文字会换行! */}
|
</div>
|
||||||
<div></div>
|
|
||||||
</Spin>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
error={error}
|
error={error}
|
||||||
errorContent={(error) => (
|
errorContent={(error) => (
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common';
|
||||||
import * as cluster from 'cluster';
|
import * as cluster from 'cluster';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
|
|
||||||
const numCPUs = os.cpus().length;
|
const numCPUs = os.cpus().length - 2;
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppClusterService {
|
export class AppClusterService {
|
||||||
|
|
Loading…
Reference in New Issue