chore: refactor

This commit is contained in:
fantasticit 2022-03-11 13:57:55 +08:00
parent 1c21079dcd
commit db52047c99
167 changed files with 1575 additions and 803 deletions

View File

@ -7,9 +7,11 @@
"dev": "concurrently \"pnpm:dev:*\"", "dev": "concurrently \"pnpm:dev:*\"",
"dev:server": "pnpm run --dir packages/server dev", "dev:server": "pnpm run --dir packages/server dev",
"dev:client": "pnpm run --dir packages/client dev", "dev:client": "pnpm run --dir packages/client dev",
"build": "pnpm build:share && pnpm build:server && pnpm build:client", "build": "pnpm build:server && pnpm build:client",
"build:dep": "pnpm build:constants && pnpm build:domains && pnpm build:config",
"build:constants": "pnpm run --dir packages/constants build",
"build:domains": "pnpm run --dir packages/domains build",
"build:config": "pnpm run --dir packages/config build", "build:config": "pnpm run --dir packages/config build",
"build:share": "pnpm run --dir packages/share build",
"build:server": "pnpm run --dir packages/server build", "build:server": "pnpm run --dir packages/server build",
"build:client": "pnpm run --dir packages/client build", "build:client": "pnpm run --dir packages/client build",
"start": "concurrently \"pnpm:start:*\"", "start": "concurrently \"pnpm:start:*\"",

View File

@ -15,7 +15,8 @@
"@douyinfe/semi-ui": "^2.3.1", "@douyinfe/semi-ui": "^2.3.1",
"@hocuspocus/provider": "^1.0.0-alpha.29", "@hocuspocus/provider": "^1.0.0-alpha.29",
"@think/config": "workspace:^1.0.0", "@think/config": "workspace:^1.0.0",
"@think/share": "workspace:^1.0.0", "@think/constants": "workspace:^1.0.0",
"@think/domains": "workspace:^1.0.0",
"@tiptap/core": "^2.0.0-beta.171", "@tiptap/core": "^2.0.0-beta.171",
"@tiptap/extension-blockquote": "^2.0.0-beta.26", "@tiptap/extension-blockquote": "^2.0.0-beta.26",
"@tiptap/extension-bold": "^2.0.0-beta.25", "@tiptap/extension-bold": "^2.0.0-beta.25",

View File

@ -1,3 +1,4 @@
import type { IDocument } from "@think/domains";
import { useCallback } from "react"; import { useCallback } from "react";
import Router from "next/router"; import Router from "next/router";
import Link from "next/link"; import Link from "next/link";
@ -10,7 +11,6 @@ import {
Skeleton, Skeleton,
} from "@douyinfe/semi-ui"; } from "@douyinfe/semi-ui";
import { IconEdit, IconUser } from "@douyinfe/semi-icons"; import { IconEdit, IconUser } from "@douyinfe/semi-icons";
import { IDocument } from "@think/share";
import { LocaleTime } from "components/locale-time"; import { LocaleTime } from "components/locale-time";
import { IconDocument } from "components/icons/IconDocument"; import { IconDocument } from "components/icons/IconDocument";
import { DocumentShare } from "components/document/share"; import { DocumentShare } from "components/document/share";

View File

@ -133,11 +133,7 @@ export const DocumentCollaboration: React.FC<IProps> = ({
<AvatarGroup maxCount={5} size="extra-small"> <AvatarGroup maxCount={5} size="extra-small">
{collaborationUsers.map((user) => { {collaborationUsers.map((user) => {
return ( return (
<Tooltip <Tooltip key={user.id} content={`${user.name}`} position="bottom">
key={user.id}
content={`${user.name}-${user.clientId}`}
position="bottom"
>
<Avatar src={user.avatar} size="extra-small"> <Avatar src={user.avatar} size="extra-small">
{user.name && user.name.charAt(0)} {user.name && user.name.charAt(0)}
</Avatar> </Avatar>

View File

@ -1,5 +1,5 @@
import React from "react"; import React from "react";
import type { IComment, IUser } from "@think/share"; import type { IComment, IUser } from "@think/domains";
import { import {
Avatar, Avatar,
Typography, Typography,

View File

@ -1,5 +1,5 @@
import React from "react"; import React from "react";
import type { IComment } from "@think/share"; import type { IComment } from "@think/domains";
import { CommentItem } from "./Item"; import { CommentItem } from "./Item";
interface IProps { interface IProps {

View File

@ -9,7 +9,6 @@ import {
Pagination, Pagination,
} from "@douyinfe/semi-ui"; } from "@douyinfe/semi-ui";
import { useToggle } from "hooks/useToggle"; import { useToggle } from "hooks/useToggle";
import { useClickOutside } from "hooks/use-click-outside";
import { DEFAULT_EXTENSION, Document, CommentMenuBar } from "components/tiptap"; import { DEFAULT_EXTENSION, Document, CommentMenuBar } from "components/tiptap";
import { DataRender } from "components/data-render"; import { DataRender } from "components/data-render";
import { useUser } from "data/user"; import { useUser } from "data/user";
@ -40,10 +39,6 @@ export const CommentEditor: React.FC<IProps> = ({ documentId }) => {
const [replyComment, setReplyComment] = useState(null); const [replyComment, setReplyComment] = useState(null);
const [editComment, setEditComment] = useState(null); const [editComment, setEditComment] = useState(null);
useClickOutside($container, {
out: () => isEdit && toggleIsEdit(false),
});
const editor = useEditor({ const editor = useEditor({
editable: true, editable: true,
extensions: [...DEFAULT_EXTENSION, Document], extensions: [...DEFAULT_EXTENSION, Document],

View File

@ -65,7 +65,7 @@ export const DocumentCreator: React.FC<IProps> = ({
okButtonProps={{ loading }} okButtonProps={{ loading }}
style={{ style={{
maxWidth: "96vw", maxWidth: "96vw",
width: "calc(100vh - 120px)", width: "calc(80vw - 120px)",
}} }}
bodyStyle={{ bodyStyle={{
maxHeight: "calc(90vh - 120px)", maxHeight: "calc(90vh - 120px)",

View File

@ -2,7 +2,7 @@ import React, { useMemo, useEffect } from "react";
import cls from "classnames"; import cls from "classnames";
import { useEditor, EditorContent } from "@tiptap/react"; import { useEditor, EditorContent } from "@tiptap/react";
import { Layout, Nav, BackTop, Toast } from "@douyinfe/semi-ui"; import { Layout, Nav, BackTop, Toast } from "@douyinfe/semi-ui";
import { IUser, IAuthority } from "@think/share"; import { IUser, IAuthority } from "@think/domains";
import { useToggle } from "hooks/useToggle"; import { useToggle } from "hooks/useToggle";
import { import {
DEFAULT_EXTENSION, DEFAULT_EXTENSION,

View File

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { useEditor, EditorContent } from "@tiptap/react"; import { useEditor, EditorContent } from "@tiptap/react";
import { Layout } from "@douyinfe/semi-ui"; import { Layout } from "@douyinfe/semi-ui";
import { IDocument } from "@think/share"; import { IDocument } from "@think/domains";
import { DEFAULT_EXTENSION, DocumentWithTitle } from "components/tiptap"; import { DEFAULT_EXTENSION, DocumentWithTitle } from "components/tiptap";
import { safeJSONParse } from "helpers/json"; import { safeJSONParse } from "helpers/json";

View File

@ -1,7 +1,7 @@
import React, { useMemo, useEffect } from "react"; import React, { useMemo, useEffect } from "react";
import { useEditor, EditorContent } from "@tiptap/react"; import { useEditor, EditorContent } from "@tiptap/react";
import { Layout } from "@douyinfe/semi-ui"; import { Layout } from "@douyinfe/semi-ui";
import { IUser } from "@think/share"; import { IUser } from "@think/domains";
import { useToggle } from "hooks/useToggle"; import { useToggle } from "hooks/useToggle";
import { import {
DEFAULT_EXTENSION, DEFAULT_EXTENSION,

View File

@ -1,6 +1,6 @@
import { Space, Typography, Avatar } from "@douyinfe/semi-ui"; import { Space, Typography, Avatar } from "@douyinfe/semi-ui";
import { IconUser } from "@douyinfe/semi-icons"; import { IconUser } from "@douyinfe/semi-icons";
import { IDocument } from "@think/share"; import { IDocument } from "@think/domains";
import { LocaleTime } from "components/locale-time"; import { LocaleTime } from "components/locale-time";
const { Text } = Typography; const { Text } = Typography;

View File

@ -1,7 +1,8 @@
import React, { useMemo, useState, useEffect } from "react"; import React, { useMemo, useState, useEffect } from "react";
import { Button, Modal, Input, Typography, Toast } from "@douyinfe/semi-ui"; import { Button, Modal, Input, Typography, Toast } from "@douyinfe/semi-ui";
import { IconLink } from "@douyinfe/semi-icons"; import { IconLink } from "@douyinfe/semi-icons";
import { isPublicDocument, getDocumentShareURL } from "@think/share"; import { isPublicDocument } from "@think/domains";
import { getDocumentShareURL } from "helpers/url";
import { ShareIllustration } from "illustrations/share"; import { ShareIllustration } from "illustrations/share";
import { DataRender } from "components/data-render"; import { DataRender } from "components/data-render";
import { useToggle } from "hooks/useToggle"; import { useToggle } from "hooks/useToggle";

View File

@ -0,0 +1,20 @@
import React from "react";
import { Icon } from "@douyinfe/semi-ui";
export const IconSearch: React.FC<{ style?: React.CSSProperties }> = ({
style = {},
}) => {
return (
<Icon
style={style}
svg={
<svg width="18" height="18" viewBox="0 0 24 24" role="presentation">
<path
d="M16.473 17.887A9.46 9.46 0 0 1 10.5 20a9.5 9.5 0 1 1 9.5-9.5 9.46 9.46 0 0 1-2.113 5.973l3.773 3.773a.996.996 0 0 1-.007 1.407.996.996 0 0 1-1.407.007l-3.773-3.773ZM18 10.5a7.5 7.5 0 1 0-15 0 7.5 7.5 0 0 0 15 0Z"
fill="currentColor"
></path>
</svg>
}
/>
);
};

View File

@ -33,3 +33,4 @@ export * from "./IconMergeCell";
export * from "./IconSplitCell"; export * from "./IconSplitCell";
export * from "./IconAttachment"; export * from "./IconAttachment";
export * from "./IconMath"; export * from "./IconMath";
export * from "./IconSearch";

View File

@ -167,6 +167,9 @@ export const Message = () => {
), ),
duration: 3, duration: 3,
onHookClose() {
readMessage(msg.id);
},
}); });
}, [unreadMsgs]); }, [unreadMsgs]);

View File

@ -0,0 +1,43 @@
.itemsWrap {
}
.itemWrap {
margin-top: 8px;
border-radius: var(--semi-border-radius-small);
&:hover {
background-color: var(--semi-color-fill-0);
color: var(--semi-color-text-0);
}
.item {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 4px 8px;
.leftWrap {
display: flex;
align-items: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: var(--semi-color-primary);
> span {
word-break: break-all;
}
svg {
fill: var(--semi-color-primary);
color: var(--semi-color-primary);
}
> div {
display: flex;
flex-direction: column;
}
}
}
}

View File

@ -0,0 +1,125 @@
import React, { useCallback, useEffect, useMemo, useState } from "react";
import Link from "next/link";
import Router from "next/router";
import { Typography, Button, Modal, Input } from "@douyinfe/semi-ui";
import { IconSearch } from "components/icons";
import { IDocument } from "@think/domains";
import { useRecentDocuments } from "data/document";
import { useToggle } from "hooks/useToggle";
import { searchDocument } from "services/document";
import { Empty } from "components/empty";
import { DataRender } from "components/data-render";
import { LocaleTime } from "components/locale-time";
import { DocumentStar } from "components/document/star";
import { IconDocumentFill } from "components/icons/IconDocumentFill";
import styles from "./index.module.scss";
const { Text } = Typography;
export const Search = () => {
const [visible, toggleVisible] = useToggle(false);
const { data: recentDocs, loading, error } = useRecentDocuments();
const [keyword, setKeyword] = useState("");
const [searchDocs, setSearchDocs] = useState<IDocument[]>([]);
const data = useMemo(
() => (searchDocs.length ? searchDocs : recentDocs),
[searchDocs.length, recentDocs]
);
const search = useCallback(() => {
searchDocument(keyword).then((res) => {
setSearchDocs(res);
});
}, [keyword]);
useEffect(() => {
const fn = () => {
toggleVisible(false);
};
Router.events.on("routeChangeStart", fn);
return () => {
Router.events.off("routeChangeStart", fn);
};
}, []);
return (
<>
<Button
type="tertiary"
theme="borderless"
icon={<IconSearch />}
onClick={toggleVisible}
/>
<Modal
visible={visible}
title="文档搜索"
footer={null}
onCancel={toggleVisible}
>
<div style={{ paddingBottom: 24 }}>
<Input
placeholder={"搜索文档"}
size="large"
value={keyword}
onChange={(val) => setKeyword(val)}
onEnterPress={search}
/>
<DataRender
loading={loading}
error={error}
normalContent={() => {
return (
<div className={styles.itemsWrap}>
{data.length ? (
data.map((doc) => {
return (
<div className={styles.itemWrap}>
<Link
href={{
pathname: "/wiki/[wikiId]/document/[documentId]",
query: {
wikiId: doc.wikiId,
documentId: doc.id,
},
}}
>
<a className={styles.item}>
<div className={styles.leftWrap}>
<IconDocumentFill style={{ marginRight: 12 }} />
<div>
<Text
ellipsis={{ showTooltip: true }}
style={{ width: 180 }}
>
{doc.title}
</Text>
<Text size="small" type="tertiary">
{doc.createUser &&
doc.createUser.name} {" "}
<LocaleTime date={doc.updatedAt} timeago />
</Text>
</div>
</div>
<div className={styles.rightWrap}>
<DocumentStar documentId={doc.id} />
</div>
</a>
</Link>
</div>
);
})
) : (
<Empty message="最近访问的文档会出现在此处" />
)}
</div>
);
}}
/>
</div>
</Modal>
</>
);
};

View File

@ -1,4 +1,4 @@
import type { ITemplate } from "@think/share"; import type { ITemplate } from "@think/domains";
import { useCallback } from "react"; import { useCallback } from "react";
import cls from "classnames"; import cls from "classnames";
import Router from "next/router"; import Router from "next/router";

View File

@ -16,7 +16,7 @@ import {
BackTop, BackTop,
} from "@douyinfe/semi-ui"; } from "@douyinfe/semi-ui";
import { IconChevronLeft, IconArticle } from "@douyinfe/semi-icons"; import { IconChevronLeft, IconArticle } from "@douyinfe/semi-icons";
import { IUser, ITemplate } from "@think/share"; import { IUser, ITemplate } from "@think/domains";
import { Theme } from "components/theme"; import { Theme } from "components/theme";
import { import {
DEFAULT_EXTENSION, DEFAULT_EXTENSION,

View File

@ -2,7 +2,7 @@ import React, { useMemo } from "react";
import cls from "classnames"; import cls from "classnames";
import { useEditor, EditorContent } from "@tiptap/react"; import { useEditor, EditorContent } from "@tiptap/react";
import { Layout, Spin, Typography } from "@douyinfe/semi-ui"; import { Layout, Spin, Typography } from "@douyinfe/semi-ui";
import { IUser, ITemplate } from "@think/share"; import { IUser, ITemplate } from "@think/domains";
import { DEFAULT_EXTENSION, DocumentWithTitle } from "components/tiptap"; import { DEFAULT_EXTENSION, DocumentWithTitle } from "components/tiptap";
import { DataRender } from "components/data-render"; import { DataRender } from "components/data-render";
import { useDocumentStyle } from "hooks/useDocumentStyle"; import { useDocumentStyle } from "hooks/useDocumentStyle";

View File

@ -102,7 +102,7 @@ export const BaseExtension = [
TableCell, TableCell,
TableHeader, TableHeader,
Toc, Toc,
TrailingNode, // TrailingNode,
Attachment, Attachment,
Katex, Katex,
DocumentReference, DocumentReference,

View File

@ -20,7 +20,7 @@ export const TrailingNode = Extension.create<TrailingNodeOptions>({
addOptions() { addOptions() {
return { return {
node: "paragraph", node: "paragraph",
notAfter: ["title", "paragraph"], notAfter: ["paragraph"],
}; };
}, },

View File

@ -1,5 +1,5 @@
import { HocuspocusProvider } from "@hocuspocus/provider"; import { HocuspocusProvider } from "@hocuspocus/provider";
import { IUser } from "@think/share"; import { IUser } from "@think/domains";
const PROVIDER_POOL_READER = new Map(); const PROVIDER_POOL_READER = new Map();
const PROVIDER_POOL_EDITOR = new Map(); const PROVIDER_POOL_EDITOR = new Map();

View File

@ -1,7 +1,7 @@
import Link from "next/link"; import Link from "next/link";
import { Space, Typography, Avatar, Skeleton } from "@douyinfe/semi-ui"; import { Space, Typography, Avatar, Skeleton } from "@douyinfe/semi-ui";
import { IconUser } from "@douyinfe/semi-icons"; import { IconUser } from "@douyinfe/semi-icons";
import { IWiki } from "@think/share"; import { IWiki } from "@think/domains";
import { LocaleTime } from "components/locale-time"; import { LocaleTime } from "components/locale-time";
import { IconDocument } from "components/icons/IconDocument"; import { IconDocument } from "components/icons/IconDocument";
import { WikiStar } from "components/wiki/star"; import { WikiStar } from "components/wiki/star";

View File

@ -1,4 +1,4 @@
import type { IWiki } from "@think/share"; import type { IWiki } from "@think/domains";
import { Dispatch, SetStateAction, useRef } from "react"; import { Dispatch, SetStateAction, useRef } from "react";
import Router from "next/router"; import Router from "next/router";
import { Form, Modal } from "@douyinfe/semi-ui"; import { Form, Modal } from "@douyinfe/semi-ui";

View File

@ -1,6 +1,6 @@
import Link from "next/link"; import Link from "next/link";
import { Space, Typography, Avatar, Skeleton } from "@douyinfe/semi-ui"; import { Space, Typography, Avatar, Skeleton } from "@douyinfe/semi-ui";
import { IWiki } from "@think/share"; import { IWiki } from "@think/domains";
import { LocaleTime } from "components/locale-time"; import { LocaleTime } from "components/locale-time";
import { IconDocument } from "components/icons/IconDocument"; import { IconDocument } from "components/icons/IconDocument";
import { WikiStar } from "components/wiki/star"; import { WikiStar } from "components/wiki/star";

View File

@ -1,7 +1,8 @@
import { useRef, useEffect, useState } from "react"; import { useRef, useEffect, useState } from "react";
import { Form, Button, Toast } from "@douyinfe/semi-ui"; import { Form, Button, Toast } from "@douyinfe/semi-ui";
import { FormApi } from "@douyinfe/semi-ui/lib/es/form"; import { FormApi } from "@douyinfe/semi-ui/lib/es/form";
import { IWiki, WIKI_AVATARS } from "@think/share"; import type { IWiki } from "@think/domains";
import { WIKI_AVATARS } from "@think/constants";
import { Upload } from "components/upload"; import { Upload } from "components/upload";
import styles from "./index.module.scss"; import styles from "./index.module.scss";

View File

@ -10,7 +10,11 @@ import {
} from "@douyinfe/semi-ui"; } from "@douyinfe/semi-ui";
import { Checkbox } from "@douyinfe/semi-ui"; import { Checkbox } from "@douyinfe/semi-ui";
import { IconClose } from "@douyinfe/semi-icons"; import { IconClose } from "@douyinfe/semi-icons";
import { WIKI_STATUS_LIST, isPublicDocument, isPublicWiki } from "@think/share"; import {
WIKI_STATUS_LIST,
isPublicDocument,
isPublicWiki,
} from "@think/domains";
import { useWikiDetail, useWikiTocs } from "data/wiki"; import { useWikiDetail, useWikiTocs } from "data/wiki";
import { buildUrl } from "helpers/url"; import { buildUrl } from "helpers/url";
import { flattenTree2Array } from "components/wiki/tocs/utils"; import { flattenTree2Array } from "components/wiki/tocs/utils";

View File

@ -8,7 +8,7 @@ import {
Select, Select,
Banner, Banner,
} from "@douyinfe/semi-ui"; } from "@douyinfe/semi-ui";
import { WIKI_USER_ROLES, WikiUserRole } from "@think/share"; import { WIKI_USER_ROLES, WikiUserRole } from "@think/domains";
import { IWikiUserOpeateData } from "data/wiki"; import { IWikiUserOpeateData } from "data/wiki";
interface IProps { interface IProps {

View File

@ -1,6 +1,6 @@
import React, { useCallback, useState } from "react"; import React, { useCallback, useState } from "react";
import { Modal, Button, Select, Banner } from "@douyinfe/semi-ui"; import { Modal, Button, Select, Banner } from "@douyinfe/semi-ui";
import { WIKI_USER_ROLES, WikiUserRole } from "@think/share"; import { WIKI_USER_ROLES, WikiUserRole } from "@think/domains";
interface IProps { interface IProps {
visible: boolean; visible: boolean;

View File

@ -4,7 +4,7 @@ import { IconEdit, IconDelete } from "@douyinfe/semi-icons";
import { useWikiUsers } from "data/wiki"; import { useWikiUsers } from "data/wiki";
import { DataRender } from "components/data-render"; import { DataRender } from "components/data-render";
import { LocaleTime } from "components/locale-time"; import { LocaleTime } from "components/locale-time";
import { renderWikiUserRole } from "@think/share"; import { renderWikiUserRole } from "@think/domains";
import { useToggle } from "hooks/useToggle"; import { useToggle } from "hooks/useToggle";
import { Placeholder } from "./placeholder"; import { Placeholder } from "./placeholder";
import { AddUser } from "./add"; import { AddUser } from "./add";

View File

@ -9,11 +9,8 @@ import { findParents } from "components/wiki/tocs/utils";
import { IconDocument, IconSetting, IconOverview } from "components/icons"; import { IconDocument, IconSetting, IconOverview } from "components/icons";
import { DocumentCreator } from "components/document/create"; import { DocumentCreator } from "components/document/create";
import { DataRender } from "components/data-render"; import { DataRender } from "components/data-render";
import { TreeMenu } from "./menu";
import { NavItem } from "./NavItem"; import { NavItem } from "./NavItem";
import { Tree } from "./tree"; import { Tree } from "./tree";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
interface IProps { interface IProps {

View File

@ -9,6 +9,7 @@ interface IProps {
} }
interface IDataNode { interface IDataNode {
index: number;
key: string; key: string;
id: string; id: string;
parentDocumentId?: string; parentDocumentId?: string;
@ -20,15 +21,18 @@ const { Title, Text } = Typography;
const extractRelation = (treeData: Array<IDataNode>) => { const extractRelation = (treeData: Array<IDataNode>) => {
const res = []; const res = [];
const data = [...treeData] as IDataNode[]; const data = [...treeData] as IDataNode[];
let index = 0;
while (data.length) { while (data.length) {
const node = data.shift(); const node = data.shift();
res.push({ res.push({
index,
id: node.id, id: node.id,
parentDocumentId: node.parentDocumentId, parentDocumentId: node.parentDocumentId,
}); });
index++;
if (node.children && node.children.length) { if (node.children && node.children.length) {
data.push(...node.children.map((sub) => ({ ...sub }))); data.push(...node.children.map((sub, j) => ({ ...sub, index: j })));
} }
} }

View File

@ -1,56 +0,0 @@
.wrap {
list-style: none;
overflow-y: hidden;
> a {
display: flex;
align-items: center;
width: 100%;
height: 36px;
font-size: 14px;
color: var(--semi-color-text-0);
border-radius: var(--semi-border-radius-small);
cursor: pointer;
&:hover {
background-color: var(--semi-color-fill-0);
color: var(--semi-color-text-0);
}
&.isActive {
background-color: var(--semi-color-primary-light-default);
color: var(--semi-color-primary);
}
> span {
display: flex;
align-items: center;
}
.icon {
margin: 0 4px;
color: var(--semi-color-text-0);
}
.title {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.rightAction {
font-size: 0;
&.isActive {
font-size: 1em;
}
}
&:hover {
.rightAction {
font-size: 1em;
}
}
}
}

View File

@ -1,102 +0,0 @@
import type { IDocument } from "@think/share";
import React, { useCallback, useEffect, useMemo } from "react";
import Link from "next/link";
import cls from "classnames";
import { Button } from "@douyinfe/semi-ui";
import {
IconChevronRight,
IconChevronDown,
IconRadio,
IconMore,
} from "@douyinfe/semi-icons";
import { useToggle } from "hooks/useToggle";
import { DocumentActions } from "components/document/actions";
import styles from "./index.module.scss";
interface IProps {
data: IDocument;
hasChildren: boolean;
docAsLink?: string;
getDocLink?: (arg: string) => string;
parentIds: Array<string>;
activeId: string;
isShareMode?: boolean;
}
export const MenuItem: React.FC<IProps> = ({
data,
hasChildren,
docAsLink,
getDocLink,
parentIds,
activeId,
isShareMode = false,
children,
}) => {
const [opened, toggleOpened] = useToggle(false);
const [isOperating, toggleOperating] = useToggle(false);
const url = useMemo(() => getDocLink(data.id), [data.id]);
const height = useMemo(() => (!opened ? 40 : 9999), [opened]);
const isActive = useMemo(() => activeId === data.id, [activeId, data.id]);
useEffect(() => {
if (parentIds.includes(data.id)) {
toggleOpened(true);
}
}, [parentIds, activeId, data.id]);
const onClick = useCallback(
(e) => {
if (!hasChildren) return;
e.preventDefault();
e.stopPropagation();
toggleOpened();
},
[hasChildren]
);
return (
<li className={styles.wrap} style={{ maxHeight: height }}>
<Link href={docAsLink} as={url}>
<a className={cls(isActive && styles.isActive)}>
<span className={cls(styles.icon)} onClick={onClick}>
{hasChildren ? (
opened ? (
<IconChevronDown style={{ fontSize: "0.75em" }} />
) : (
<IconChevronRight style={{ fontSize: "0.75em" }} />
)
) : (
<IconRadio style={{ fontSize: "0.75em" }} />
)}
</span>
<span className={styles.title}>{data.title}</span>
{isShareMode ? null : (
<span
className={cls(
styles.rightAction,
isOperating && styles.isActive
)}
>
<DocumentActions
wikiId={data.wikiId}
documentId={data.id}
onVisibleChange={toggleOperating}
>
<Button
style={{ fontSize: "1em" }}
theme="borderless"
type="tertiary"
icon={<IconMore style={{ fontSize: "1em" }} />}
size="small"
onClick={onClick}
/>
</DocumentActions>
</span>
)}
</a>
</Link>
{children}
</li>
);
};

View File

@ -1,7 +0,0 @@
.wrap {
padding: 0 0.5rem;
ul {
margin: 0;
}
}

View File

@ -1,85 +0,0 @@
import { IDocument } from "@think/share";
import React from "react";
import { MenuItem } from "../menu-item";
import styles from "./index.module.scss";
interface IProps {
data: Array<IDocument>;
docAsLink?: string;
getDocLink?: (arg: string) => string;
parentIds: Array<string>;
activeId: string;
isShareMode?: boolean;
}
const PADDING_LEFT = 22;
const Menu = ({
data,
depth,
docAsLink,
getDocLink,
parentIds,
activeId,
isShareMode,
}) => {
return (
<ul
key={"menu" + depth}
style={{ paddingLeft: depth > 0 ? PADDING_LEFT : 0 }}
>
{data.map((item) => {
const hasChildren = item.children && item.children.length;
return (
<MenuItem
key={item.id}
data={item}
hasChildren={hasChildren}
docAsLink={docAsLink}
getDocLink={getDocLink}
parentIds={parentIds}
activeId={activeId}
isShareMode={isShareMode}
>
{hasChildren ? (
<Menu
key={item.id + "menu"}
data={item.children}
depth={depth + 1}
docAsLink={docAsLink}
getDocLink={getDocLink}
parentIds={parentIds}
activeId={activeId}
isShareMode={isShareMode}
/>
) : null}
</MenuItem>
);
})}
</ul>
);
};
export const TreeMenu: React.FC<IProps> = ({
data,
docAsLink,
getDocLink,
parentIds,
activeId,
isShareMode,
}) => {
return (
<div className={styles.wrap}>
<Menu
key={"root-menu"}
data={data}
depth={0}
docAsLink={docAsLink}
getDocLink={getDocLink}
parentIds={parentIds}
activeId={activeId}
isShareMode={isShareMode}
/>
</div>
);
};

View File

@ -8,7 +8,7 @@ import { Seo } from "components/seo";
import { findParents } from "components/wiki/tocs/utils"; import { findParents } from "components/wiki/tocs/utils";
import { LogoImage, LogoText } from "components/logo"; import { LogoImage, LogoText } from "components/logo";
import { DataRender } from "components/data-render"; import { DataRender } from "components/data-render";
import { TreeMenu } from "./menu"; import { Tree } from "./tree";
import { NavItem } from "./NavItem"; import { NavItem } from "./NavItem";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
@ -135,13 +135,13 @@ export const WikiPublicTocs: React.FC<IProps> = ({
} }
error={tocsError} error={tocsError}
normalContent={() => ( normalContent={() => (
<TreeMenu <Tree
data={tocs || []} data={tocs || []}
docAsLink={docAsLink} docAsLink={docAsLink}
getDocLink={getDocLink} getDocLink={getDocLink}
parentIds={parentIds} parentIds={parentIds}
activeId={documentId} activeId={documentId}
isShareMode={true} isShareMode
/> />
)} )}
/> />

View File

@ -65,7 +65,14 @@ const AddDocument = () => {
); );
}; };
export const Tree = ({ data, docAsLink, getDocLink, parentIds, activeId }) => { export const Tree = ({
data,
docAsLink,
getDocLink,
parentIds,
activeId,
isShareMode = false,
}) => {
const [expandedKeys, setExpandedKeys] = useState(parentIds); const [expandedKeys, setExpandedKeys] = useState(parentIds);
const renderBtn = useCallback( const renderBtn = useCallback(
@ -88,10 +95,10 @@ export const Tree = ({ data, docAsLink, getDocLink, parentIds, activeId }) => {
</Typography.Text> </Typography.Text>
</a> </a>
</Link> </Link>
{renderBtn(item)} {isShareMode ? null : renderBtn(item)}
</div> </div>
), ),
[] [isShareMode]
); );
useEffect(() => { useEffect(() => {

View File

@ -1,4 +1,4 @@
import type { IComment } from "@think/share"; import type { IComment } from "@think/domains";
import { useState } from "react"; import { useState } from "react";
import useSWR from "swr"; import useSWR from "swr";
import { HttpClient } from "services/HttpClient"; import { HttpClient } from "services/HttpClient";

View File

@ -1,4 +1,4 @@
import type { IUser, IDocument } from "@think/share"; import type { IUser, IDocument } from "@think/domains";
import useSWR from "swr"; import useSWR from "swr";
import { useState, useCallback, useEffect } from "react"; import { useState, useCallback, useEffect } from "react";
import { useAsyncLoading } from "hooks/useAsyncLoading"; import { useAsyncLoading } from "hooks/useAsyncLoading";

View File

@ -1,4 +1,4 @@
import type { IMessage } from "@think/share"; import type { IMessage } from "@think/domains";
import { useState } from "react"; import { useState } from "react";
import useSWR from "swr"; import useSWR from "swr";
import { HttpClient } from "services/HttpClient"; import { HttpClient } from "services/HttpClient";
@ -13,7 +13,7 @@ export const useAllMessages = () => {
data: Array<IMessage>; data: Array<IMessage>;
total: number; total: number;
}>(`/message/all?page=${page}`, (url) => HttpClient.get(url), { }>(`/message/all?page=${page}`, (url) => HttpClient.get(url), {
refreshInterval: 200, // refreshInterval: 200,
}); });
const loading = !data && !error; const loading = !data && !error;
@ -36,7 +36,7 @@ export const useReadMessages = () => {
data: Array<IMessage>; data: Array<IMessage>;
total: number; total: number;
}>(`/message/read?page=${page}`, (url) => HttpClient.get(url), { }>(`/message/read?page=${page}`, (url) => HttpClient.get(url), {
refreshInterval: 200, // refreshInterval: 200,
}); });
const loading = !data && !error; const loading = !data && !error;
@ -59,7 +59,7 @@ export const useUnreadMessages = () => {
data: Array<IMessage>; data: Array<IMessage>;
total: number; total: number;
}>(`/message/unread?page=${page}`, (url) => HttpClient.get(url), { }>(`/message/unread?page=${page}`, (url) => HttpClient.get(url), {
refreshInterval: 200, // refreshInterval: 200,
}); });
const loading = !data && !error; const loading = !data && !error;

View File

@ -1,4 +1,4 @@
import type { ITemplate } from "@think/share"; import type { ITemplate } from "@think/domains";
import { useState } from "react"; import { useState } from "react";
import useSWR from "swr"; import useSWR from "swr";
import { HttpClient } from "services/HttpClient"; import { HttpClient } from "services/HttpClient";

View File

@ -1,12 +1,10 @@
import type { IUser, ILoginUser } from "@think/domains";
import useSWR from "swr"; import useSWR from "swr";
import { useCallback, useEffect } from "react"; import { useCallback, useEffect } from "react";
import Router, { useRouter } from "next/router"; import Router, { useRouter } from "next/router";
import { IUser } from "@think/share";
import { HttpClient } from "services/HttpClient"; import { HttpClient } from "services/HttpClient";
import { getStorage, setStorage } from "helpers/storage"; import { getStorage, setStorage } from "helpers/storage";
export type ILoginUser = Pick<IUser, "name" | "password">;
export const useUser = () => { export const useUser = () => {
const router = useRouter(); const router = useRouter();
const { data, error, mutate } = useSWR("user", getStorage); const { data, error, mutate } = useSWR("user", getStorage);
@ -20,7 +18,7 @@ export const useUser = () => {
const login = useCallback((data) => { const login = useCallback((data) => {
HttpClient.post<IUser>("/user/login", data).then((res) => { HttpClient.post<IUser>("/user/login", data).then((res) => {
const user = res as unknown as IUser; const user = res as unknown as ILoginUser;
mutate(user); mutate(user);
setStorage("user", JSON.stringify(user)); setStorage("user", JSON.stringify(user));
user.token && setStorage("token", user.token); user.token && setStorage("token", user.token);

View File

@ -1,4 +1,10 @@
import { CollectType, IDocument, IUser, IWiki, IWikiUser } from "@think/share"; import {
CollectType,
IDocument,
IUser,
IWiki,
IWikiUser,
} from "@think/domains";
import useSWR from "swr"; import useSWR from "swr";
import { HttpClient } from "services/HttpClient"; import { HttpClient } from "services/HttpClient";

View File

@ -1,4 +1,12 @@
export const buildUrl = (url) => { export const buildUrl = (url) => {
if (typeof window === 'undefined') return url; if (typeof window === "undefined") return url;
return `${window.location.origin}${url}`; return `${window.location.origin}${url}`;
}; };
export const getWikiShareURL = (wikiId) => {
return window.location.host + "/share/wiki/" + wikiId;
};
export const getDocumentShareURL = (documentId) => {
return window.location.host + "/share/document/" + documentId;
};

View File

@ -60,7 +60,12 @@ export const Recent = () => {
> >
{doc.title} {doc.title}
</Text> </Text>
<Text size="small" type="tertiary"> <Text size="small" type="tertiary">
{doc.createUser &&
doc.createUser.name}{" "}
{" "}
<LocaleTime <LocaleTime
date={doc.updatedAt} date={doc.updatedAt}
timeago timeago

View File

@ -7,6 +7,7 @@ import { WikiOrDocumentCreator } from "components/wiki-or-document-creator";
import { LogoImage, LogoText } from "components/logo"; import { LogoImage, LogoText } from "components/logo";
import { Theme } from "components/theme"; import { Theme } from "components/theme";
import { Message } from "components/message"; import { Message } from "components/message";
import { Search } from "components/search";
import { useWindowSize } from "hooks/useWindowSize"; import { useWindowSize } from "hooks/useWindowSize";
import { Recent } from "./Recent"; import { Recent } from "./Recent";
import { Wiki } from "./Wiki"; import { Wiki } from "./Wiki";
@ -81,6 +82,7 @@ export const RouterHeader: React.FC = () => {
footer={ footer={
<Space> <Space>
<WikiOrDocumentCreator /> <WikiOrDocumentCreator />
<Search />
<Message /> <Message />
<Theme /> <Theme />
<User /> <User />

View File

@ -1,5 +1,5 @@
import type { NextPage } from "next"; import type { NextPage } from "next";
import type { IDocument } from "@think/share"; import type { IDocument } from "@think/domains";
import Link from "next/link"; import Link from "next/link";
import React from "react"; import React from "react";
import { Typography, Button, Table, Spin, List } from "@douyinfe/semi-ui"; import { Typography, Button, Table, Spin, List } from "@douyinfe/semi-ui";
@ -99,7 +99,7 @@ const RecentDocs = () => {
const Page: NextPage = () => { const Page: NextPage = () => {
const [visible, toggleVisible] = useToggle(false); const [visible, toggleVisible] = useToggle(false);
const { data: staredWikis, loading, error, refresh } = useStaredWikis(); const { data: staredWikis, loading, error } = useStaredWikis();
return ( return (
<SingleColumnLayout> <SingleColumnLayout>
@ -110,9 +110,7 @@ const Page: NextPage = () => {
访 访
</Title> </Title>
<> <>
<Button onClick={toggleVisible} type="tertiary"> <Button onClick={toggleVisible}></Button>
</Button>
<WikiCreator visible={visible} toggleVisible={toggleVisible} /> <WikiCreator visible={visible} toggleVisible={toggleVisible} />
</> </>
</div> </div>

View File

@ -1,4 +1,4 @@
import { IDocument } from "@think/share"; import { IDocument } from "@think/domains";
import { HttpClient } from "./HttpClient"; import { HttpClient } from "./HttpClient";
/** /**
@ -22,3 +22,12 @@ export const getPublicDocumentDetail = (
): Promise<IDocument> => { ): Promise<IDocument> => {
return HttpClient.post("/document/public/detail/" + id, data); return HttpClient.post("/document/public/detail/" + id, data);
}; };
/**
*
* @param keyword
* @returns
*/
export const searchDocument = (keyword: string): Promise<IDocument[]> => {
return HttpClient.get("/document/search", { params: { keyword } });
};

View File

@ -1,4 +1,4 @@
import type { IUser } from "@think/share"; import type { IUser } from "@think/domains";
import { HttpClient } from "./HttpClient"; import { HttpClient } from "./HttpClient";
export const register = (data: Partial<IUser>): Promise<IUser> => { export const register = (data: Partial<IUser>): Promise<IUser> => {

View File

@ -157,7 +157,7 @@
ul[data-type="taskList"] { ul[data-type="taskList"] {
list-style: none; list-style: none;
padding: 0 0 0 8px; padding: 0;
p { p {
margin: 0; margin: 0;
@ -165,16 +165,26 @@
li { li {
display: flex; display: flex;
align-items: center;
> label { > label {
flex: 0 0 auto; flex: 0 0 auto;
user-select: none; user-select: none;
transform: translateY(2px);
} }
> div { > div {
flex: 1 1 auto; flex: 1 1 auto;
padding-left: 0.5rem; padding-left: 0.5rem;
} }
&[data-checked="true"] {
color: var(--semi-color-text-2);
> div {
text-decoration: line-through;
}
}
} }
} }

View File

@ -15,7 +15,7 @@ db:
host: "127.0.0.1" host: "127.0.0.1"
username: "root" username: "root"
password: "root" password: "root"
database: "think" database: "think7"
port: 3306 port: 3306
charset: "utf8mb4" charset: "utf8mb4"
timezone: "+08:00" timezone: "+08:00"
@ -24,11 +24,11 @@ db:
# oss 文件存储服务 # oss 文件存储服务
oss: oss:
aliyun: aliyun:
accessKeyId: "" accessKeyId: "LTAI4Fc65yMwx2LR23PZwUed"
accessKeySecret: "" accessKeySecret: "I0EBFxRTWLyVk674raeYgC8h1tvSqG"
bucket: "" bucket: "wipi"
https: true https: true
region: "" region: "oss-cn-shanghai"
# jwt 配置 # jwt 配置
jwt: jwt:

View File

@ -16,4 +16,4 @@ exports.WIKI_AVATARS = [
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default17-96.png", "https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default17-96.png",
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default18-96.png", "https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default18-96.png",
]; ];
//# sourceMappingURL=default.js.map //# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAC9B,sEAAsE,CAAC;AAE5D,QAAA,YAAY,GAAG;IAC1B,2BAAmB;IACnB,sEAAsE;IACtE,sEAAsE;IACtE,sEAAsE;IACtE,uEAAuE;IACvE,uEAAuE;IACvE,uEAAuE;IACvE,4EAA4E;IAC5E,sEAAsE;IACtE,uEAAuE;IACvE,uEAAuE;IACvE,uEAAuE;CACxE,CAAC"}

View File

@ -0,0 +1,24 @@
{
"name": "@think/constants",
"version": "1.0.0",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"exports": {
".": {
"import": "./lib/index.js",
"require": "./lib/index.js"
}
},
"sideEffects": false,
"license": "MIT",
"scripts": {
"build": "tsc --declaration"
},
"files": [
"lib",
"src"
],
"devDependencies": {
"typescript": "^4.5.5"
}
}

2
packages/domains/lib/index.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
export * from "./models";
export * from "./util";

View File

@ -10,7 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./default"), exports); __exportStar(require("./models"), exports);
__exportStar(require("./enum"), exports); __exportStar(require("./util"), exports);
__exportStar(require("./type"), exports);
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB"}

View File

@ -0,0 +1,4 @@
export declare enum CollectType {
document = "document",
wiki = "wiki"
}

View File

@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CollectType = void 0;
var CollectType;
(function (CollectType) {
CollectType["document"] = "document";
CollectType["wiki"] = "wiki";
})(CollectType = exports.CollectType || (exports.CollectType = {}));
//# sourceMappingURL=collector.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../src/models/collector.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,4BAAa,CAAA;AACf,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB"}

View File

@ -0,0 +1,16 @@
import { IUser } from "./user";
import { IDocument } from "./document";
export interface IComment {
id: string;
parentCommentId?: IComment["id"];
documentId: IDocument["id"];
createUserId: IUser["id"];
createUser: IUser;
replyUserId?: IUser["id"];
replyUser?: IUser;
html: string;
userAgent: string;
createdAt: Date;
updatedAt: Date;
children?: IComment[];
}

View File

@ -1,3 +1,3 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=type.js.map //# sourceMappingURL=comment.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"comment.js","sourceRoot":"","sources":["../../src/models/comment.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,29 @@
import { IUser } from "./user";
import { IWiki } from "./wiki";
export declare enum DocumentStatus {
private = "private",
public = "public"
}
export interface IDocument {
id: string;
wikiId: IWiki["id"];
isWikiHome: boolean;
createUserId: IUser["id"];
createUser: IUser;
parentDocumentId?: IDocument["id"];
title: string;
content: string;
status: DocumentStatus;
views: number;
sharePassword?: string;
createdAt: Date;
updatedAt: Date;
children?: IDocument[];
}
export interface IAuthority {
id: string;
documentId: IDocument["id"];
userId: IUser["id"];
readable: boolean;
editable: boolean;
}

View File

@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentStatus = void 0;
var DocumentStatus;
(function (DocumentStatus) {
DocumentStatus["private"] = "private";
DocumentStatus["public"] = "public";
})(DocumentStatus = exports.DocumentStatus || (exports.DocumentStatus = {}));
//# sourceMappingURL=document.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/models/document.ts"],"names":[],"mappings":";;;AAMA,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB"}

View File

@ -0,0 +1,8 @@
export * from "./user";
export * from "./wiki";
export * from "./document";
export * from "./message";
export * from "./template";
export * from "./comment";
export * from "./collector";
export * from "./pagination";

View File

@ -0,0 +1,21 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./user"), exports);
__exportStar(require("./wiki"), exports);
__exportStar(require("./document"), exports);
__exportStar(require("./message"), exports);
__exportStar(require("./template"), exports);
__exportStar(require("./comment"), exports);
__exportStar(require("./collector"), exports);
__exportStar(require("./pagination"), exports);
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,yCAAuB;AACvB,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,8CAA4B;AAC5B,+CAA6B"}

View File

@ -0,0 +1,11 @@
import { IUser } from "./user";
export interface IMessage {
id: string;
userId: IUser["id"];
title: string;
message: string;
url: string;
read: boolean;
createdAt: Date;
updatedAt: Date;
}

View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=message.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/models/message.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,4 @@
export declare type IPagination = {
page: number;
pageSize: number;
};

View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=pagination.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/models/pagination.ts"],"names":[],"mappings":""}

View File

@ -0,0 +1,13 @@
import { IUser } from "./user";
export interface ITemplate {
id: string;
createUserId: IUser["id"];
createUser: IUser;
title: string;
content: string;
state: string;
usageAmount: number;
isPublic: boolean;
createdAt: Date;
updatedAt: Date;
}

View File

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=template.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/models/template.ts"],"names":[],"mappings":""}

21
packages/domains/lib/models/user.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
export declare enum UserRole {
normal = "normal",
admin = "admin",
superadmin = "superadmin"
}
export declare enum UserStatus {
normal = "normal",
locked = "locked"
}
export interface IUser {
id: string;
name: string;
password?: string;
avatar?: string;
email?: string;
role: UserRole;
status: UserStatus;
}
export interface ILoginUser extends IUser {
token: string;
}

View File

@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserStatus = exports.UserRole = void 0;
var UserRole;
(function (UserRole) {
UserRole["normal"] = "normal";
UserRole["admin"] = "admin";
UserRole["superadmin"] = "superadmin";
})(UserRole = exports.UserRole || (exports.UserRole = {}));
var UserStatus;
(function (UserStatus) {
UserStatus["normal"] = "normal";
UserStatus["locked"] = "locked";
})(UserStatus = exports.UserStatus || (exports.UserStatus = {}));
//# sourceMappingURL=user.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/models/user.ts"],"names":[],"mappings":";;;AAGA,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,2BAAe,CAAA;IACf,qCAAyB,CAAA;AAC3B,CAAC,EAJW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAInB;AAKD,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB"}

30
packages/domains/lib/models/wiki.d.ts vendored Normal file
View File

@ -0,0 +1,30 @@
import { IUser } from "./user";
export declare enum WikiStatus {
private = "private",
public = "public"
}
export declare enum WikiUserStatus {
applying = "applying",
inviting = "inviting",
normal = "normal"
}
export declare enum WikiUserRole {
normal = "normal",
admin = "admin"
}
export interface IWiki {
id: string;
name: string;
avatar: string;
description: string;
createUserId: IUser["id"];
createUser: IUser;
status: WikiStatus;
createdAt: Date;
updatedAt: Date;
}
export interface IWikiUser extends IUser {
userRole: WikiUserRole;
userStatus: WikiUserStatus;
isCreator: boolean;
}

View File

@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WikiUserRole = exports.WikiUserStatus = exports.WikiStatus = void 0;
var WikiStatus;
(function (WikiStatus) {
WikiStatus["private"] = "private";
WikiStatus["public"] = "public";
})(WikiStatus = exports.WikiStatus || (exports.WikiStatus = {}));
var WikiUserStatus;
(function (WikiUserStatus) {
WikiUserStatus["applying"] = "applying";
WikiUserStatus["inviting"] = "inviting";
WikiUserStatus["normal"] = "normal";
})(WikiUserStatus = exports.WikiUserStatus || (exports.WikiUserStatus = {}));
var WikiUserRole;
(function (WikiUserRole) {
WikiUserRole["normal"] = "normal";
WikiUserRole["admin"] = "admin";
})(WikiUserRole = exports.WikiUserRole || (exports.WikiUserRole = {}));
//# sourceMappingURL=wiki.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"wiki.js","sourceRoot":"","sources":["../../src/models/wiki.ts"],"names":[],"mappings":";;;AAKA,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB;AAKD,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,uCAAqB,CAAA;IACrB,mCAAiB,CAAA;AACnB,CAAC,EAJW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAIzB;AAKD,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,+BAAe,CAAA;AACjB,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB"}

View File

@ -0,0 +1,37 @@
import { IUser, IWiki, IDocument, CollectType } from "../models";
export declare type ICollectDto = {
targetId: IWiki["id"] | IDocument["id"];
type: CollectType;
};
export declare abstract class ICollectorService {
/**
*
*/
wikis = [];
getWikisLoading = false;
getWikisError = null;
/**
*
*/
documents = [];
getDocumentsLoading = false;
getDocumentsError = null;
/**
*
*/
toggleLoading = false;
toggleError = null;
/**
*
*/
checkLoading = false;
checkError = null;
abstract toggleCollect(data: ICollectDto, user?: IUser): Promise<void>;
abstract checkCollect(data: ICollectDto): Promise<boolean>;
abstract getCollectWikis(user?: IUser): Promise<IWiki[]>;
abstract getCollectDocuments(user?: IUser): Promise<IDocument[]>;
}

View File

@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ICollectorService = void 0;
class ICollectorService {
}
exports.ICollectorService = ICollectorService;
//# sourceMappingURL=ICollectorService.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ICollectorService.js","sourceRoot":"","sources":["../../src/services/ICollectorService.ts"],"names":[],"mappings":";;;AAcA,MAAsB,iBAAiB;CAyBtC;AAzBD,8CAyBC"}

View File

@ -0,0 +1,17 @@
import { IUser, IComment, IDocument, IPagination } from "../models";
export declare type ICreateCommentDto = {
parentCommentId?: IComment["id"];
documentId: IDocument["id"];
html: string;
replyUserId?: IUser["id"];
};
export declare type IUpdateCommentDto = {
id: IComment["id"];
html?: string;
};
export declare abstract class ICommentService {
abstract createComment(data: ICreateCommentDto, user?: IUser, userAgent?: string): Promise<IComment>;
abstract updateComment(data: IUpdateCommentDto, user?: IUser): Promise<IComment>;
abstract deleteComment(id: IComment["id"], user?: IUser): Promise<void>;
abstract getDocumentComments(documentId: IDocument["id"], pagination: IPagination): Promise<IComment[]>;
}

View File

@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ICommentService = void 0;
class ICommentService {
}
exports.ICommentService = ICommentService;
//# sourceMappingURL=ICommentService.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ICommentService.js","sourceRoot":"","sources":["../../src/services/ICommentService.ts"],"names":[],"mappings":";;;AAkCA,MAAsB,eAAe;CAuCpC;AAvCD,0CAuCC"}

View File

@ -0,0 +1,70 @@
import { IUser, IWiki, ITemplate, IDocument, IAuthority } from "../models";
export declare type ICreateDocumentDto = {
wikiId: IWiki["id"];
parentDocumentId?: IDocument["id"] | null;
title?: string;
templateId?: ITemplate["id"];
};
export declare type IUpdateDocumentDto = {
content: string;
state: Uint8Array;
} & Pick<ICreateDocumentDto, "title">;
export declare type IShareDocumentDto = {
sharePassword?: string;
};
export declare type IDocumentAuthorityDto = {
documentId: IDocument["id"];
userName: IUser["name"];
readable: boolean;
editable: boolean;
};
export declare abstract class IDocumentService {
createLoading: boolean;
createError: any;
documentsDetail: Map<any, any>;
getDocumentDetailLoading: boolean;
getDocumentDetailError: any;
updateDocumentLoading: boolean;
updateDocumentError: any;
deleteDocumentLoading: boolean;
deleteDocumentError: any;
documentsChildren: Map<any, any>;
getDocumentChildrenLoading: boolean;
getDocumentChildrenError: any;
publicDocumentsChildren: Map<any, any>;
getPublicDocumentChildrenLoading: boolean;
getPublicDocumentChildrenError: any;
shareLoading: boolean;
shareError: any;
documentsUsers: Map<any, any>;
getDocumentUsersLoading: boolean;
getDocumentUsersError: any;
addDocumentUserLoading: boolean;
addDocumentUserError: any;
updateDocumentUserLoading: boolean;
updateDocumentUserError: any;
deleteDocumentUserLoading: boolean;
deleteDocumentUserError: any;
recentlyViewedDocuments: any[];
getRecentlyViewedDocumentsLoading: boolean;
getRecentlyViewedDocumentsError: any;
publicDocumentsDetail: Map<any, any>;
getPublicDocumentDetailLoading: boolean;
getPublicDocumentDetailError: any;
abstract createDocument(data: ICreateDocumentDto, user?: IUser): Promise<IDocument>;
abstract getDocumentDetail(id: IDocument["id"], user: IUser): Promise<IDocument>;
abstract updateDocument(id: IDocument["id"], data: IUpdateDocumentDto, user?: IUser): Promise<IDocument>;
abstract deleteDocument(id: IDocument["id"], user?: IUser): Promise<void>;
abstract getDocumentChidren(wikiId: IWiki["id"], documentId: IDocument["id"], user?: IUser): Promise<IDocument[]>;
abstract shareDocument(id: IDocument["id"], data: IShareDocumentDto, user?: IUser): Promise<IDocument>;
abstract getDocumentUsers(id: IDocument["id"], user?: IUser): Promise<Array<{
user: IUser;
authority: IAuthority;
}>>;
abstract addDocumentUser(data: IDocumentAuthorityDto, user?: IUser): Promise<IAuthority>;
abstract updateDocumentUser(data: IDocumentAuthorityDto, user?: IUser): Promise<IAuthority>;
abstract deleteDocumentUser(data: IDocumentAuthorityDto, user?: IUser): Promise<void>;
abstract getRecentlyViewedDocuments(user?: IUser): Promise<IDocument[]>;
abstract getPublicDocumentDetail(id: IDocument["id"], data?: IShareDocumentDto, userAgent?: string): any;
abstract getPublicDocumentChildren(wikiId: IWiki["id"], documentId: IDocument["id"]): Promise<IDocument[]>;
}

View File

@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IDocumentService = void 0;
class IDocumentService {
constructor() {
this.createLoading = false;
this.createError = null;
this.documentsDetail = new Map();
this.getDocumentDetailLoading = false;
this.getDocumentDetailError = null;
this.updateDocumentLoading = false;
this.updateDocumentError = null;
this.deleteDocumentLoading = false;
this.deleteDocumentError = null;
this.documentsChildren = new Map();
this.getDocumentChildrenLoading = false;
this.getDocumentChildrenError = null;
this.publicDocumentsChildren = new Map();
this.getPublicDocumentChildrenLoading = false;
this.getPublicDocumentChildrenError = null;
this.shareLoading = false;
this.shareError = null;
this.documentsUsers = new Map();
this.getDocumentUsersLoading = false;
this.getDocumentUsersError = null;
this.addDocumentUserLoading = false;
this.addDocumentUserError = null;
this.updateDocumentUserLoading = false;
this.updateDocumentUserError = null;
this.deleteDocumentUserLoading = false;
this.deleteDocumentUserError = null;
this.recentlyViewedDocuments = [];
this.getRecentlyViewedDocumentsLoading = false;
this.getRecentlyViewedDocumentsError = null;
this.publicDocumentsDetail = new Map();
this.getPublicDocumentDetailLoading = false;
this.getPublicDocumentDetailError = null;
}
}
exports.IDocumentService = IDocumentService;
//# sourceMappingURL=IDocumentService.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"IDocumentService.js","sourceRoot":"","sources":["../../src/services/IDocumentService.ts"],"names":[],"mappings":";;;AA+DA,MAAsB,gBAAgB;IAAtC;QAIE,kBAAa,GAAG,KAAK,CAAC;QACtB,gBAAW,GAAG,IAAI,CAAC;QAKnB,oBAAe,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,6BAAwB,GAAG,KAAK,CAAC;QACjC,2BAAsB,GAAG,IAAI,CAAC;QAK9B,0BAAqB,GAAG,KAAK,CAAC;QAC9B,wBAAmB,GAAG,IAAI,CAAC;QAK3B,0BAAqB,GAAG,KAAK,CAAC;QAC9B,wBAAmB,GAAG,IAAI,CAAC;QAK3B,sBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;QAC9B,+BAA0B,GAAG,KAAK,CAAC;QACnC,6BAAwB,GAAG,IAAI,CAAC;QAKhC,4BAAuB,GAAG,IAAI,GAAG,EAAE,CAAC;QACpC,qCAAgC,GAAG,KAAK,CAAC;QACzC,mCAA8B,GAAG,IAAI,CAAC;QAKtC,iBAAY,GAAG,KAAK,CAAC;QACrB,eAAU,GAAG,IAAI,CAAC;QAKlB,mBAAc,GAAG,IAAI,GAAG,EAAE,CAAC;QAC3B,4BAAuB,GAAG,KAAK,CAAC;QAChC,0BAAqB,GAAG,IAAI,CAAC;QAK7B,2BAAsB,GAAG,KAAK,CAAC;QAC/B,yBAAoB,GAAG,IAAI,CAAC;QAK5B,8BAAyB,GAAG,KAAK,CAAC;QAClC,4BAAuB,GAAG,IAAI,CAAC;QAK/B,8BAAyB,GAAG,KAAK,CAAC;QAClC,4BAAuB,GAAG,IAAI,CAAC;QAK/B,4BAAuB,GAAG,EAAE,CAAC;QAC7B,sCAAiC,GAAG,KAAK,CAAC;QAC1C,oCAA+B,GAAG,IAAI,CAAC;QAKvC,0BAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,mCAA8B,GAAG,KAAK,CAAC;QACvC,iCAA4B,GAAG,IAAI,CAAC;IAoItC,CAAC;CAAA;AAvND,4CAuNC"}

View File

@ -0,0 +1,3 @@
export declare abstract class IFileService {
abstract uploadFile(file: any): Promise<string>;
}

Some files were not shown because too many files have changed in this diff Show More