chore: format code

pull/8/head
fantasticit 2022-03-12 10:31:03 +08:00
parent b13dd26d9a
commit f629eedbb0
36 changed files with 387 additions and 425 deletions

4
.prettierignore 100644
View File

@ -0,0 +1,4 @@
node_modules
.next
dist
lib

12
.prettierrc 100644
View File

@ -0,0 +1,12 @@
{
"singleQuote": true,
"quoteProps": "consistent",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"printWidth": 100,
"endOfLine": "lf"
}

View File

@ -89,40 +89,40 @@ pnpm run dev
```yaml
# 开发环境配置
server:
prefix: "/api"
prefix: '/api'
port: 5001
collaborationPort: 5003
client:
assetPrefix: "/"
apiUrl: "http://localhost:5001/api"
collaborationUrl: "ws://localhost:5003"
assetPrefix: '/'
apiUrl: 'http://localhost:5001/api'
collaborationUrl: 'ws://localhost:5003'
# 数据库配置
db:
mysql:
host: "127.0.0.1"
username: "root"
password: "root"
database: "think"
host: '127.0.0.1'
username: 'root'
password: 'root'
database: 'think'
port: 3306
charset: "utf8mb4"
timezone: "+08:00"
charset: 'utf8mb4'
timezone: '+08:00'
synchronize: true
# oss 文件存储服务
oss:
aliyun:
accessKeyId: ""
accessKeySecret: ""
bucket: ""
accessKeyId: ''
accessKeySecret: ''
bucket: ''
https: true
region: ""
region: ''
# jwt 配置
jwt:
secretkey: "zA_Think+KNOWLEDGE+WIKI+DOCUMENTS@2022"
expiresIn: "6h"
secretkey: 'zA_Think+KNOWLEDGE+WIKI+DOCUMENTS@2022'
expiresIn: '6h'
```
### 项目部署

View File

@ -19,7 +19,12 @@
"start:client": "pnpm run --dir packages/client start",
"pm2": "concurrently \"pnpm:pm2:*\"",
"pm2:server": "pnpm run --dir packages/server pm2",
"pm2:client": "pnpm run --dir packages/client pm2"
"pm2:client": "pnpm run --dir packages/client pm2",
"lint": "eslint . -c ./.eslintrc.js --fix --quiet 'packages/**/*.{ts,tsx,js,jsx}'",
"format": "npm run format:md && npm run format:json && npm run format:source",
"format:md": "prettier --parser markdown --write './**/*.md'",
"format:json": "prettier --parser json --write './**/*.json'",
"format:source": "prettier --write './**/*.{js,ts}'"
},
"dependencies": {
"concurrently": "^7.0.0",
@ -31,6 +36,7 @@
"node": ">=16.5.0"
},
"devDependencies": {
"prettier": "^2.3.2",
"typescript": "^4.5.5"
}
}

View File

@ -1,6 +1,6 @@
const semi = require("@douyinfe/semi-next").default({});
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const { getConfig } = require("@think/config");
const semi = require('@douyinfe/semi-next').default({});
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const { getConfig } = require('@think/config');
const config = getConfig().client;
/** @type {import('next').NextConfig} */

View File

@ -1,171 +1,171 @@
export const EXPRESSIONES = [
"😀",
"😃",
"😄",
"😁",
"😆",
"😅",
"😂",
"🤣",
"🥲",
"😊",
"😇",
"🙂",
"🙃",
"😉",
"😌",
"😍",
"🥰",
"😘",
"😗",
"😙",
"😚",
"😋",
"😛",
"😝",
"😜",
"🤪",
"🤨",
"🧐",
"🤓",
"😎",
"🥸",
"🤩",
"🥳",
"😏",
"😒",
"😞",
"😔",
"😟",
"😕",
"🙁",
"😣",
"😖",
"😫",
"😩",
"🥺",
"😢",
"😭",
"😤",
"😠",
"😡",
"🤬",
"🤯",
"😳",
"🥵",
"🥶",
"😱",
"😨",
"😰",
"😥",
"😓",
"🤗",
"🤔",
"🤭",
"🤫",
"🤥",
"😶",
"😐",
"😑",
"😬",
"🙄",
"😯",
"😦",
"😧",
"😮",
"😲",
"🥱",
"😴",
"🤤",
"😪",
"😵",
"🤐",
"🥴",
"🤢",
"🤮",
"🤧",
"😷",
"🤒",
"🤕",
"🤑",
"🤠",
"😈",
"👿",
"👹",
"👺",
"🤡",
"💩",
"👻",
"💀",
"☠️",
"👽",
"👾",
"🤖",
"🎃",
"😺",
"😸",
"😹",
"😻",
"😼",
"😽",
"🙀",
"😿",
"😾",
'😀',
'😃',
'😄',
'😁',
'😆',
'😅',
'😂',
'🤣',
'🥲',
'😊',
'😇',
'🙂',
'🙃',
'😉',
'😌',
'😍',
'🥰',
'😘',
'😗',
'😙',
'😚',
'😋',
'😛',
'😝',
'😜',
'🤪',
'🤨',
'🧐',
'🤓',
'😎',
'🥸',
'🤩',
'🥳',
'😏',
'😒',
'😞',
'😔',
'😟',
'😕',
'🙁',
'😣',
'😖',
'😫',
'😩',
'🥺',
'😢',
'😭',
'😤',
'😠',
'😡',
'🤬',
'🤯',
'😳',
'🥵',
'🥶',
'😱',
'😨',
'😰',
'😥',
'😓',
'🤗',
'🤔',
'🤭',
'🤫',
'🤥',
'😶',
'😐',
'😑',
'😬',
'🙄',
'😯',
'😦',
'😧',
'😮',
'😲',
'🥱',
'😴',
'🤤',
'😪',
'😵',
'🤐',
'🥴',
'🤢',
'🤮',
'🤧',
'😷',
'🤒',
'🤕',
'🤑',
'🤠',
'😈',
'👿',
'👹',
'👺',
'🤡',
'💩',
'👻',
'💀',
'☠️',
'👽',
'👾',
'🤖',
'🎃',
'😺',
'😸',
'😹',
'😻',
'😼',
'😽',
'🙀',
'😿',
'😾',
];
export const GESTURES = [
"👋",
"🤚",
"🖐",
"✋",
"🖖",
"👌",
"🤌",
"🤏",
"✌️",
"🤞",
"🤟",
"🤘",
"🤙",
"👈",
"👉",
"👆",
"🖕",
"👇",
"☝️",
"👍",
"👎",
"✊",
"👊",
"🤛",
"🤜",
"👏",
"🙌",
"👐",
"🤲",
"🤝",
"🙏",
"✍️",
"💅",
"🤳",
"💪",
"🦾",
"🦵",
"🦿",
"🦶",
"👣",
"👂",
"🦻",
"👃",
"🫀",
"🫁",
"🧠",
"🦷",
"🦴",
"👀",
"👁",
"👅",
"👄",
"💋",
"🩸",
'👋',
'🤚',
'🖐',
'✋',
'🖖',
'👌',
'🤌',
'🤏',
'✌️',
'🤞',
'🤟',
'🤘',
'🤙',
'👈',
'👉',
'👆',
'🖕',
'👇',
'☝️',
'👍',
'👎',
'✊',
'👊',
'🤛',
'🤜',
'👏',
'🙌',
'👐',
'🤲',
'🤝',
'🙏',
'✍️',
'💅',
'🤳',
'💪',
'🦾',
'🦵',
'🦿',
'🦶',
'👣',
'👂',
'🦻',
'👃',
'🫀',
'🫁',
'🧠',
'🦷',
'🦴',
'👀',
'👁',
'👅',
'👄',
'💋',
'🩸',
];

View File

@ -1,5 +1,5 @@
import { HocuspocusProvider } from "@hocuspocus/provider";
import { IUser } from "@think/domains";
import { HocuspocusProvider } from '@hocuspocus/provider';
import { IUser } from '@think/domains';
const PROVIDER_POOL_READER = new Map();
const PROVIDER_POOL_EDITOR = new Map();
@ -7,22 +7,21 @@ const PROVIDER_POOL_EDITOR = new Map();
export const getProvider = ({
targetId,
token,
cacheType = "READER",
cacheType = 'READER',
user,
docType = "document",
docType = 'document',
events = {},
}: {
targetId: string;
token: string;
cacheType: "READER" | "EDITOR";
cacheType: 'READER' | 'EDITOR';
user: IUser;
docType: "document" | "template";
docType: 'document' | 'template';
events?: {
onAwarenessUpdate?: (states: any) => void;
};
}) => {
const pool =
cacheType === "READER" ? PROVIDER_POOL_READER : PROVIDER_POOL_EDITOR;
const pool = cacheType === 'READER' ? PROVIDER_POOL_READER : PROVIDER_POOL_EDITOR;
if (!pool.has(targetId)) {
const provider = new HocuspocusProvider({
@ -43,12 +42,8 @@ export const getProvider = ({
return pool.get(targetId);
};
export const destoryProvider = (
provider,
cacheType: "READER" | "EDITOR" = "READER"
) => {
const pool =
cacheType === "READER" ? PROVIDER_POOL_READER : PROVIDER_POOL_EDITOR;
export const destoryProvider = (provider, cacheType: 'READER' | 'EDITOR' = 'READER') => {
const pool = cacheType === 'READER' ? PROVIDER_POOL_READER : PROVIDER_POOL_EDITOR;
pool.delete(provider.configuration.name);
provider.document.destroy();

View File

@ -1,9 +1,7 @@
export const isListActive = (editor) => {
return (
editor.isActive("bulletList") ||
editor.isActive("orderedList") ||
editor.isActive("taskList")
editor.isActive('bulletList') || editor.isActive('orderedList') || editor.isActive('taskList')
);
};
export const isTitleActive = (editor) => editor.isActive("title");
export const isTitleActive = (editor) => editor.isActive('title');

View File

@ -1,5 +1,5 @@
export function download(url, name) {
const link = document.createElement("a");
const link = document.createElement('a');
link.download = name;
link.href = url;
document.body.appendChild(link);

View File

@ -1,19 +1,17 @@
import { Node } from "prosemirror-model";
import { Node } from 'prosemirror-model';
export function isBulletListNode(node: Node): boolean {
return node.type.name === "bulletList";
return node.type.name === 'bulletList';
}
export function isOrderedListNode(node: Node): boolean {
return node.type.name === "orderedList";
return node.type.name === 'orderedList';
}
export function isTodoListNode(node: Node): boolean {
return node.type.name === "taskList";
return node.type.name === 'taskList';
}
export function isListNode(node: Node): boolean {
return (
isBulletListNode(node) || isOrderedListNode(node) || isTodoListNode(node)
);
return isBulletListNode(node) || isOrderedListNode(node) || isTodoListNode(node);
}

View File

@ -1,10 +1,7 @@
import { NodeType, Schema } from "prosemirror-model";
import { NodeType, Schema } from 'prosemirror-model';
export function getNodeType(
nameOrType: string | NodeType,
schema: Schema
): NodeType {
if (typeof nameOrType === "string") {
export function getNodeType(nameOrType: string | NodeType, schema: Schema): NodeType {
if (typeof nameOrType === 'string') {
if (!schema.nodes[nameOrType]) {
throw Error(
`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`

View File

@ -1,14 +1,11 @@
import type { IComment } from "@think/domains";
import { useState } from "react";
import useSWR from "swr";
import { HttpClient } from "services/HttpClient";
import type { IComment } from '@think/domains';
import { useState } from 'react';
import useSWR from 'swr';
import { HttpClient } from 'services/HttpClient';
export type CreateCommentDto = Pick<
IComment,
"parentCommentId" | "html" | "replyUserId"
>;
export type CreateCommentDto = Pick<IComment, 'parentCommentId' | 'html' | 'replyUserId'>;
export type UpdateCommentDto = Pick<IComment, "id" | "html">;
export type UpdateCommentDto = Pick<IComment, 'id' | 'html'>;
/**
*
@ -20,9 +17,7 @@ export const useComments = (documentId) => {
const { data, error, mutate } = useSWR<{
data: Array<IComment>;
total: number;
}>(`/comment/document/${documentId}?page=${page}`, (url) =>
HttpClient.get(url)
);
}>(`/comment/document/${documentId}?page=${page}`, (url) => HttpClient.get(url));
const loading = !data && !error;
const addComment = async (data: CreateCommentDto) => {

View File

@ -1,9 +1,9 @@
import type { IUser, IDocument } from "@think/domains";
import useSWR from "swr";
import { useState, useCallback, useEffect } from "react";
import { useAsyncLoading } from "hooks/useAsyncLoading";
import { HttpClient } from "services/HttpClient";
import { getPublicDocumentDetail } from "services/document";
import type { IUser, IDocument } from '@think/domains';
import useSWR from 'swr';
import { useState, useCallback, useEffect } from 'react';
import { useAsyncLoading } from 'hooks/useAsyncLoading';
import { HttpClient } from 'services/HttpClient';
import { getPublicDocumentDetail } from 'services/document';
interface IAuthority {
id: string;
@ -13,20 +13,18 @@ interface IAuthority {
editable: boolean;
}
type ICreateDocument = Partial<Pick<IDocument, "wikiId" | "parentDocumentId">>;
type ICreateDocument = Partial<Pick<IDocument, 'wikiId' | 'parentDocumentId'>>;
type IDocumentWithAuth = { document: IDocument; authority: IAuthority };
type IUpdateDocument = Partial<Pick<IDocument, "title" | "content">>;
type IUpdateDocument = Partial<Pick<IDocument, 'title' | 'content'>>;
/**
*
* @returns
*/
export const useCreateDocument = () => {
const [create, loading] = useAsyncLoading(
(data: ICreateDocument): Promise<IDocument> => {
return HttpClient.post("/document/create", data);
}
);
const [create, loading] = useAsyncLoading((data: ICreateDocument): Promise<IDocument> => {
return HttpClient.post('/document/create', data);
});
return { create, loading };
};
@ -36,7 +34,7 @@ export const useCreateDocument = () => {
* @returns
*/
export const updateDocumentViews = (id: string) => {
return HttpClient.get("/document/views/" + id);
return HttpClient.get('/document/views/' + id);
};
/**
@ -46,7 +44,7 @@ export const updateDocumentViews = (id: string) => {
*/
export const useDeleteDocument = (id) => {
const [deleteDocument, loading] = useAsyncLoading((): Promise<IDocument> => {
return HttpClient.delete("/document/delete/" + id);
return HttpClient.delete('/document/delete/' + id);
});
return { deleteDocument, loading };
};
@ -64,15 +62,13 @@ export const useDocumentDetail = (documentId, options = null) => {
);
const loading = !data && !error;
const update = async (data: IUpdateDocument) => {
const res = await HttpClient.post("/document/update/" + documentId, data);
const res = await HttpClient.post('/document/update/' + documentId, data);
mutate();
return res;
};
const toggleStatus = async (
data: Partial<Pick<IDocument, "sharePassword">>
) => {
const ret = await HttpClient.post("/document/share/" + documentId, data);
const toggleStatus = async (data: Partial<Pick<IDocument, 'sharePassword'>>) => {
const ret = await HttpClient.post('/document/share/' + documentId, data);
mutate();
return ret;
};
@ -85,9 +81,8 @@ export const useDocumentDetail = (documentId, options = null) => {
* @returns
*/
export const useRecentDocuments = () => {
const { data, error, mutate } = useSWR<IDocument[]>(
"/document/recent",
(url) => HttpClient.get(url)
const { data, error, mutate } = useSWR<IDocument[]>('/document/recent', (url) =>
HttpClient.get(url)
);
const loading = !data && !error;
return { data, error, loading, refresh: mutate };
@ -99,18 +94,16 @@ export const useRecentDocuments = () => {
* @returns
*/
export const useDocumentStar = (documentId) => {
const { data, error, mutate } = useSWR<boolean>(
`/collector/check/${documentId}`,
() =>
HttpClient.post(`/collector/check`, {
type: "document",
targetId: documentId,
})
const { data, error, mutate } = useSWR<boolean>(`/collector/check/${documentId}`, () =>
HttpClient.post(`/collector/check`, {
type: 'document',
targetId: documentId,
})
);
const toggleStar = async () => {
await HttpClient.post("/collector/toggle/", {
type: "document",
await HttpClient.post('/collector/toggle/', {
type: 'document',
targetId: documentId,
});
mutate();
@ -124,9 +117,8 @@ export const useDocumentStar = (documentId) => {
* @returns
*/
export const useStaredDocuments = () => {
const { data, error, mutate } = useSWR<IDocument[]>(
"/collector/documents",
(url) => HttpClient.post(url)
const { data, error, mutate } = useSWR<IDocument[]>('/collector/documents', (url) =>
HttpClient.post(url)
);
const loading = !data && !error;
@ -141,13 +133,11 @@ export const useStaredDocuments = () => {
export const usePublicDocument = (documentId: string) => {
const [fetch] = useAsyncLoading(getPublicDocumentDetail);
const [document, setDocument] = useState<IDocument | null>(null);
const [error, setError] = useState<(Error & { statusCode?: number }) | null>(
null
);
const [error, setError] = useState<(Error & { statusCode?: number }) | null>(null);
const loading = !document && !error;
const queryData = useCallback(
(sharePassword = "") => {
(sharePassword = '') => {
fetch(documentId, { sharePassword })
.then((doc) => {
setDocument(doc);
@ -221,16 +211,10 @@ export const useCollaborationDocument = (documentId) => {
* @param isShare 访
* @returns
*/
export const useChildrenDocument = ({
wikiId,
documentId,
isShare = false,
}) => {
export const useChildrenDocument = ({ wikiId, documentId, isShare = false }) => {
const { data, error, mutate } = useSWR<Array<IDocument>>(
isShare ? "/document/public/children" : `/document/children`,
wikiId || documentId
? (url) => HttpClient.post(url, { wikiId, documentId, isShare })
: null,
isShare ? '/document/public/children' : `/document/children`,
wikiId || documentId ? (url) => HttpClient.post(url, { wikiId, documentId, isShare }) : null,
{ shouldRetryOnError: false }
);
const loading = !data && !error;

View File

@ -1,7 +1,7 @@
import type { IMessage } from "@think/domains";
import { useState } from "react";
import useSWR from "swr";
import { HttpClient } from "services/HttpClient";
import type { IMessage } from '@think/domains';
import { useState } from 'react';
import useSWR from 'swr';
import { HttpClient } from 'services/HttpClient';
/**
*

View File

@ -1,7 +1,7 @@
import type { ITemplate } from "@think/domains";
import { useState } from "react";
import useSWR from "swr";
import { HttpClient } from "services/HttpClient";
import type { ITemplate } from '@think/domains';
import { useState } from 'react';
import useSWR from 'swr';
import { HttpClient } from 'services/HttpClient';
export const usePublicTemplates = () => {
const [page, setPage] = useState(1);

View File

@ -1,35 +1,31 @@
import { useEffect } from "react";
import useSWR from "swr";
import { setStorage, getStorage } from "helpers/storage";
import { useEffect } from 'react';
import useSWR from 'swr';
import { setStorage, getStorage } from 'helpers/storage';
export enum Width {
"standardWidth" = "standardWidth",
"fullWidth" = "fullWidth",
'standardWidth' = 'standardWidth',
'fullWidth' = 'fullWidth',
}
const WIDTH_KEY = "document-style-width";
const FONT_SIZE_KEY = "document-style-font-size";
const WIDTH_KEY = 'document-style-width';
const FONT_SIZE_KEY = 'document-style-font-size';
const DEFAULT_WIDTH = Width.standardWidth;
const DEFAULT_FONT_SIZE = 16;
export const useDocumentStyle = () => {
const { data, mutate } = useSWR(
`/fe/mock/${WIDTH_KEY}/${FONT_SIZE_KEY}`,
() => {
if (typeof window !== "undefined") {
return {
width: getStorage(WIDTH_KEY) || DEFAULT_WIDTH,
fontSize:
parseInt(getStorage(FONT_SIZE_KEY), 10) || DEFAULT_FONT_SIZE,
};
}
const { data, mutate } = useSWR(`/fe/mock/${WIDTH_KEY}/${FONT_SIZE_KEY}`, () => {
if (typeof window !== 'undefined') {
return {
width: DEFAULT_WIDTH,
fontSize: DEFAULT_FONT_SIZE,
width: getStorage(WIDTH_KEY) || DEFAULT_WIDTH,
fontSize: parseInt(getStorage(FONT_SIZE_KEY), 10) || DEFAULT_FONT_SIZE,
};
}
);
return {
width: DEFAULT_WIDTH,
fontSize: DEFAULT_FONT_SIZE,
};
});
const setWidth = (width: Width) => {
setStorage(WIDTH_KEY, width);

View File

@ -1,9 +1,9 @@
import { useEffect, useRef } from "react";
import useSWR from "swr";
import { useWindowSize } from "hooks/useWindowSize";
import { setStorage, getStorage } from "helpers/storage";
import { useEffect, useRef } from 'react';
import useSWR from 'swr';
import { useWindowSize } from 'hooks/useWindowSize';
import { setStorage, getStorage } from 'helpers/storage';
const key = "dragable-menu-width";
const key = 'dragable-menu-width';
export const MIN_WIDTH = 240;
export const MAX_WIDTH = 600;
@ -22,7 +22,7 @@ export const useDragableWidth = () => {
};
const toggleCollapsed = (collapsed = null) => {
const isBool = typeof collapsed === "boolean";
const isBool = typeof collapsed === 'boolean';
const nextCollapsed = isBool ? collapsed : !isCollapsed;
let nextWidth = nextCollapsed ? COLLAPSED_WIDTH : MIN_WIDTH;
setStorage(key, nextWidth);

View File

@ -1,5 +1,5 @@
import { IDocument } from "@think/domains";
import { HttpClient } from "./HttpClient";
import { IDocument } from '@think/domains';
import { HttpClient } from './HttpClient';
/**
*
@ -7,7 +7,7 @@ import { HttpClient } from "./HttpClient";
* @returns
*/
export const updateDocumentViews = (id: string) => {
return HttpClient.get("/document/views/" + id);
return HttpClient.get('/document/views/' + id);
};
/**
@ -18,9 +18,9 @@ export const updateDocumentViews = (id: string) => {
*/
export const getPublicDocumentDetail = (
id: string,
data: Partial<Pick<IDocument, "sharePassword">>
data: Partial<Pick<IDocument, 'sharePassword'>>
): Promise<IDocument> => {
return HttpClient.post("/document/public/detail/" + id, data);
return HttpClient.post('/document/public/detail/' + id, data);
};
/**
@ -29,5 +29,5 @@ export const getPublicDocumentDetail = (
* @returns
*/
export const searchDocument = (keyword: string): Promise<IDocument[]> => {
return HttpClient.get("/document/search", { params: { keyword } });
return HttpClient.get('/document/search', { params: { keyword } });
};

View File

@ -1,18 +1,16 @@
import { HttpClient } from "./HttpClient";
import { HttpClient } from './HttpClient';
export const uploadFile = async (file: Blob): Promise<string> => {
if (process.env.ENABLE_ALIYUN_OSS) {
return Promise.reject(
new Error("阿里云OSS配置不完善请自行实现上传文件")
);
return Promise.reject(new Error('阿里云OSS配置不完善请自行实现上传文件'));
}
const formData = new FormData();
formData.append("file", file);
formData.append('file', file);
return HttpClient.post("/file/upload", formData, {
return HttpClient.post('/file/upload', formData, {
headers: {
"Content-Type": "multipart/form-data",
'Content-Type': 'multipart/form-data',
},
});
};

View File

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

View File

@ -14,11 +14,7 @@
"scripts": {
"build": "tsc --declaration"
},
"files": [
"lib",
"src",
"yaml"
],
"files": ["lib", "src", "yaml"],
"dependencies": {
"js-yaml": "^4.1.0"
}

View File

@ -14,10 +14,7 @@
"scripts": {
"build": "tsc --declaration"
},
"files": [
"lib",
"src"
],
"files": ["lib", "src"],
"devDependencies": {
"typescript": "^4.5.5"
}

View File

@ -1,17 +1,17 @@
export const DEFAULT_WIKI_AVATAR =
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default0-96.png";
'https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default0-96.png';
export const WIKI_AVATARS = [
DEFAULT_WIKI_AVATAR,
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default2-96.png",
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default7-96.png",
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default8-96.png",
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default14-96.png",
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default21-96.png",
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default23-96.png",
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default1-96%20(1).png",
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default4-96.png",
"https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default12-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/default2-96.png',
'https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default7-96.png',
'https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default8-96.png',
'https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default14-96.png',
'https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default21-96.png',
'https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default23-96.png',
'https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default1-96%20(1).png',
'https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default4-96.png',
'https://wipi.oss-cn-shanghai.aliyuncs.com/2022-02-01/default12-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',
];

View File

@ -14,10 +14,7 @@
"scripts": {
"build": "tsc --declaration"
},
"files": [
"lib",
"src"
],
"files": ["lib", "src"],
"devDependencies": {
"typescript": "^4.5.5"
}

View File

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

View File

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

View File

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

View File

@ -1,12 +1,12 @@
import { IUser } from "./user";
import { IWiki } from "./wiki";
import { IUser } from './user';
import { IWiki } from './wiki';
/**
*
*/
export enum DocumentStatus {
private = "private",
public = "public",
private = 'private',
public = 'public',
}
/**
@ -14,11 +14,11 @@ export enum DocumentStatus {
*/
export interface IDocument {
id: string;
wikiId: IWiki["id"];
wikiId: IWiki['id'];
isWikiHome: boolean;
createUserId: IUser["id"];
createUserId: IUser['id'];
createUser: IUser;
parentDocumentId?: IDocument["id"];
parentDocumentId?: IDocument['id'];
title: string;
content: string;
status: DocumentStatus;
@ -34,8 +34,8 @@ export interface IDocument {
*/
export interface IAuthority {
id: string;
documentId: IDocument["id"];
userId: IUser["id"];
documentId: IDocument['id'];
userId: IUser['id'];
readable: boolean;
editable: boolean;
}

View File

@ -1,8 +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";
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

@ -1,11 +1,11 @@
import { IUser } from "./user";
import { IUser } from './user';
/**
*
*/
export interface IMessage {
id: string;
userId: IUser["id"];
userId: IUser['id'];
title: string;
message: string;
url: string;

View File

@ -1,11 +1,11 @@
import { IUser } from "./user";
import { IUser } from './user';
/**
*
*/
export interface ITemplate {
id: string;
createUserId: IUser["id"];
createUserId: IUser['id'];
createUser: IUser;
title: string;
content: string;

View File

@ -2,17 +2,17 @@
*
*/
export enum UserRole {
normal = "normal",
admin = "admin",
superadmin = "superadmin",
normal = 'normal',
admin = 'admin',
superadmin = 'superadmin',
}
/**
*
*/
export enum UserStatus {
normal = "normal",
locked = "locked",
normal = 'normal',
locked = 'locked',
}
/**

View File

@ -1,28 +1,28 @@
import { IUser } from "./user";
import { IUser } from './user';
/**
*
*/
export enum WikiStatus {
private = "private",
public = "public",
private = 'private',
public = 'public',
}
/**
*
*/
export enum WikiUserStatus {
applying = "applying",
inviting = "inviting",
normal = "normal",
applying = 'applying',
inviting = 'inviting',
normal = 'normal',
}
/**
*
*/
export enum WikiUserRole {
normal = "normal",
admin = "admin",
normal = 'normal',
admin = 'admin',
}
/**
@ -33,7 +33,7 @@ export interface IWiki {
name: string;
avatar: string;
description: string;
createUserId: IUser["id"];
createUserId: IUser['id'];
createUser: IUser;
status: WikiStatus;
createdAt: Date;

View File

@ -1,10 +1,4 @@
import {
WikiStatus,
WikiUserRole,
DocumentStatus,
IWiki,
IDocument,
} from "./models";
import { WikiStatus, WikiUserRole, DocumentStatus, IWiki, IDocument } from './models';
/**
*
@ -12,11 +6,11 @@ import {
export const WIKI_STATUS_LIST = [
{
value: WikiStatus.private,
label: "私有",
label: '私有',
},
{
value: WikiStatus.public,
label: "公开",
label: '公开',
},
];
@ -25,12 +19,12 @@ export const WIKI_STATUS_LIST = [
*/
export const WIKI_USER_ROLES = [
{
value: "admin",
label: "管理员",
value: 'admin',
label: '管理员',
},
{
value: "normal",
label: "成员",
value: 'normal',
label: '成员',
},
];
@ -40,11 +34,11 @@ export const WIKI_USER_ROLES = [
export const DOCUMENT_STATUS = [
{
value: DocumentStatus.private,
label: "私有",
label: '私有',
},
{
value: DocumentStatus.public,
label: "公开",
label: '公开',
},
];
@ -62,8 +56,7 @@ export const getWikiStatusText = (wiki: IWiki): string => {
* @param currentStatus wiki status
* @returns
*/
export const isPublicWiki = (currentStatus: IWiki["status"]) =>
currentStatus === WikiStatus.public;
export const isPublicWiki = (currentStatus: IWiki['status']) => currentStatus === WikiStatus.public;
/**
*
@ -79,5 +72,5 @@ export const getWikiUserRoleText = (role: WikiUserRole) => {
* @param currentStatus document status
* @returns
*/
export const isPublicDocument = (currentStatus: IDocument["status"]) =>
export const isPublicDocument = (currentStatus: IDocument['status']) =>
currentStatus === DocumentStatus.public;

View File

@ -76,19 +76,13 @@
"typescript": "^4.3.5"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"collectCoverageFrom": ["**/*.(t|j)s"],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}

View File

@ -7,6 +7,7 @@ importers:
concurrently: ^7.0.0
cross-env: ^7.0.3
fs-extra: ^10.0.0
prettier: ^2.3.2
rimraf: ^3.0.2
typescript: ^4.5.5
dependencies:
@ -15,6 +16,7 @@ importers:
fs-extra: 10.0.0
rimraf: 3.0.2
devDependencies:
prettier: 2.5.1
typescript: 4.5.5
packages/client: