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
|
||||
*/
|
||||
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)
|
||||
);
|
||||
|
||||
|
|
|
@ -296,7 +296,11 @@ export const getDocumentChildren = (data, cookie = null): Promise<Array<IDocumen
|
|||
*/
|
||||
export const useChildrenDocument = ({ wikiId, documentId, isShare = false }) => {
|
||||
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 })
|
||||
);
|
||||
const loading = !data && !error;
|
||||
|
|
|
@ -13,7 +13,15 @@ import { Hydrate, QueryClient, QueryClientProvider } from 'react-query';
|
|||
|
||||
class MyApp extends App<{ isMobile: boolean }> {
|
||||
state = {
|
||||
queryClient: new QueryClient(),
|
||||
queryClient: new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
refetchOnWindowFocus: true,
|
||||
retry: false,
|
||||
staleTime: 30000,
|
||||
},
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
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="updatedAt" key="updatedAt" render={(date) => <LocaleTime date={date} />} />,
|
||||
<Column
|
||||
title="操作"
|
||||
dataIndex="operate"
|
||||
|
|
|
@ -8,7 +8,6 @@ import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, use
|
|||
import { IndexeddbPersistence } from 'tiptap/core/y-indexeddb';
|
||||
|
||||
import { Editor } from '../../react';
|
||||
import { ReaderEditor } from '../reader';
|
||||
import { EditorInstance } from './editor';
|
||||
import styles from './index.module.scss';
|
||||
import { ICollaborationEditorProps, ProviderStatus } from './type';
|
||||
|
@ -27,7 +26,6 @@ export const CollaborationEditor = forwardRef((props: ICollaborationEditorProps,
|
|||
onTitleUpdate,
|
||||
user,
|
||||
menubar,
|
||||
initialContent,
|
||||
renderInEditorPortal,
|
||||
onAwarenessUpdate,
|
||||
} = props;
|
||||
|
@ -100,16 +98,12 @@ export const CollaborationEditor = forwardRef((props: ICollaborationEditorProps,
|
|||
<DataRender
|
||||
loading={loading}
|
||||
loadingContent={
|
||||
initialContent ? (
|
||||
<ReaderEditor content={initialContent} />
|
||||
) : (
|
||||
<div style={{ width: 174, margin: 'auto' }}>
|
||||
<Spin tip="正在为您加载编辑器中...">
|
||||
{/* FIXME: semi-design 的问题,不加 div,文字会换行! */}
|
||||
<div></div>
|
||||
</Spin>
|
||||
</div>
|
||||
)
|
||||
<div style={{ width: 174, margin: 'auto' }}>
|
||||
<Spin tip="正在加载中...">
|
||||
{/* FIXME: semi-design 的问题,不加 div,文字会换行! */}
|
||||
<div></div>
|
||||
</Spin>
|
||||
</div>
|
||||
}
|
||||
error={error}
|
||||
errorContent={(error) => (
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common';
|
|||
import * as cluster from 'cluster';
|
||||
import * as os from 'os';
|
||||
|
||||
const numCPUs = os.cpus().length;
|
||||
const numCPUs = os.cpus().length - 2;
|
||||
|
||||
@Injectable()
|
||||
export class AppClusterService {
|
||||
|
|
Loading…
Reference in New Issue