diff --git a/config/dev.yaml b/config/dev.yaml index 66572641..b0e3900a 100644 --- a/config/dev.yaml +++ b/config/dev.yaml @@ -1,16 +1,3 @@ -# 以下为前台动态渲染的配置,修改后,无需打包,重启服务即可 -dynamic: - # 输入 logo 的图片地址 - logo: '' - appName: '云策文档' - appDescription: '云策文档是一款开源知识管理工具。通过独立的知识库空间,结构化地组织在线协作文档,实现知识的积累与沉淀,促进知识的复用与流通。' - appKeywords: '云策文档,协作,文档,fantasticit,https://github.com/fantasticit/think' - # 版权信息,可以是 HTML - copyrightInformation: '

Develop by fantasticit

' - # 外部跳转按钮配置 - externalButtonText: 'Github' - externalButtonURL: 'https://github.com/fantasticit/think' - # 开发环境配置 client: port: 5001 diff --git a/config/docker-prod-sample.yaml b/config/docker-prod-sample.yaml index bbe45e47..e60c2c9b 100644 --- a/config/docker-prod-sample.yaml +++ b/config/docker-prod-sample.yaml @@ -1,16 +1,3 @@ -# 以下为前台动态渲染的配置,修改后,无需打包,重启服务即可 -dynamic: - # 输入 logo 的图片地址 - logo: '' - appName: '云策文档' - appDescription: '云策文档是一款开源知识管理工具。通过独立的知识库空间,结构化地组织在线协作文档,实现知识的积累与沉淀,促进知识的复用与流通。' - appKeywords: '云策文档,协作,文档,fantasticit,https://github.com/fantasticit/think' - # 版权信息,可以是 HTML - copyrightInformation: '

Develop by fantasticit

' - # 外部跳转按钮配置 - externalButtonText: 'Github' - externalButtonURL: 'https://github.com/fantasticit/think' - # 开发环境配置 client: port: 5001 diff --git a/dynamic.yaml b/dynamic.yaml new file mode 100644 index 00000000..d3d34347 --- /dev/null +++ b/dynamic.yaml @@ -0,0 +1,12 @@ +# 以下为前台动态渲染的配置,修改后,无需打包,重启服务即可 +dynamic: + # 输入 logo 的图片地址 + logo: '' + appName: '云策文档' + appDescription: '云策文档是一款开源知识管理工具。通过独立的知识库空间,结构化地组织在线协作文档,实现知识的积累与沉淀,促进知识的复用与流通。' + appKeywords: '云策文档,协作,文档,fantasticit,https://github.com/fantasticit/think' + # 版权信息,可以是 HTML + copyrightInformation: '

Develop by fantasticit

' + # 外部跳转按钮配置 + externalButtonText: 'Github' + externalButtonURL: 'https://github.com/fantasticit/think' diff --git a/packages/client/src/components/admin/system-config/ad/index.tsx b/packages/client/src/components/admin/system-config/ad/index.tsx new file mode 100644 index 00000000..d5434bf4 --- /dev/null +++ b/packages/client/src/components/admin/system-config/ad/index.tsx @@ -0,0 +1,141 @@ +import React, { useCallback, useRef, useState } from 'react'; + +import { Avatar, Button, Form, Image, Modal, Space, Table } from '@douyinfe/semi-ui'; +import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; + +import { AdType } from '@think/domains'; + +import { DataRender } from 'components/data-render'; +import { Upload } from 'components/upload'; +import { useAd } from 'data/ad'; + +const { Option } = Form.Select; + +const AdTypeTextMap = { + [AdType.shareDocCover]: '分享文档主图位', + [AdType.shareDocAside]: '分享文档侧边位', +}; + +const columns = [ + { + title: '类型', + dataIndex: 'type', + render: (type) => { + return AdTypeTextMap[type]; + }, + }, + { + title: '广告图', + dataIndex: 'cover', + render: (url) => { + return ( +
+ +
+ ); + }, + }, + { + title: '广告链接', + dataIndex: 'url', + }, +]; + +export const Ad = () => { + const { data, loading, error, createAd, deleteAd } = useAd(); + const [visible, toggleVisible] = useState(false); + const $form = useRef(); + const [currentCover, setCurrentCover] = useState(''); + + const setCover = useCallback((url) => { + $form.current.setValue('cover', url); + setCurrentCover(url); + }, []); + + const handleOk = useCallback(() => { + $form.current.validate().then((values) => { + if (!values.email) { + delete values.email; + } + createAd(values).then(() => { + $form.current.reset(); + setCover(''); + toggleVisible(false); + }); + }); + }, [createAd, setCover, toggleVisible]); + + return ( + ( +
+ + { + toggleVisible(false); + }} + style={{ maxWidth: '96vw' }} + onOk={handleOk} + > +
($form.current = formApi)} + labelPosition="left" + > + + + + + + + + + + + + + +
+
+ { + return ( + + ); + }, + }, + ]} + dataSource={data} + pagination={false} + /> + + )} + /> + ); +}; diff --git a/packages/client/src/components/admin/system-config/index.tsx b/packages/client/src/components/admin/system-config/index.tsx index 8cc4228b..11b7b816 100644 --- a/packages/client/src/components/admin/system-config/index.tsx +++ b/packages/client/src/components/admin/system-config/index.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { TabPane, Tabs } from '@douyinfe/semi-ui'; +import { Ad } from './ad'; import { Mail } from './mail'; import { System } from './system'; @@ -13,6 +14,7 @@ interface IProps { const TitleMap = { base: '系统管理', mail: '邮箱服务', + ad: '广告管理', }; export const SystemConfig: React.FC = ({ tab, onNavigate }) => { @@ -25,6 +27,10 @@ export const SystemConfig: React.FC = ({ tab, onNavigate }) => { + + + + ); }; diff --git a/packages/client/src/components/admin/system-config/mail/index.tsx b/packages/client/src/components/admin/system-config/mail/index.tsx index 968dae5d..dc0a9d00 100644 --- a/packages/client/src/components/admin/system-config/mail/index.tsx +++ b/packages/client/src/components/admin/system-config/mail/index.tsx @@ -35,6 +35,8 @@ export const Mail = () => { closeIcon={null} /> + {/* + // @ts-ignore */}
{ error={error} normalContent={() => (
+ {/* + // @ts-ignore */} div { + height: 100%; + } + } + .contentWrap { flex: 1; overflow: hidden; diff --git a/packages/client/src/components/document/reader/public/index.tsx b/packages/client/src/components/document/reader/public/index.tsx index 945aa199..6ba12a55 100644 --- a/packages/client/src/components/document/reader/public/index.tsx +++ b/packages/client/src/components/document/reader/public/index.tsx @@ -1,28 +1,40 @@ -import { Breadcrumb, Button, Form, Layout, Nav, Skeleton, Space, Tooltip, Typography } from '@douyinfe/semi-ui'; -import { IconRoute } from '@douyinfe/semi-icons'; -import { FormApi } from '@douyinfe/semi-ui/lib/es/form'; -import { DataRender } from 'components/data-render'; -import { Divider } from 'components/divider'; -import { DocumentStyle } from 'components/document/style'; -import { LogoImage, LogoText } from 'components/logo'; -import { Seo } from 'components/seo'; -import { Theme } from 'components/theme'; -import { User } from 'components/user'; -import { usePublicDocumentDetail } from 'data/document'; -import { useMount } from 'hooks/use-mount'; -import { IsOnMobile } from 'hooks/use-on-mobile'; -import { SecureDocumentIllustration } from 'illustrations/secure-document'; -import Link from 'next/link'; -import React, { useCallback, useMemo, useRef } from 'react'; -import { createPortal } from 'react-dom'; -import { CollaborationEditor } from 'tiptap/editor'; +import { + Breadcrumb, + Button, + Form, + Layout, + Nav, + Skeleton, + Space, + Tooltip, + Typography, + Carousel, +} from "@douyinfe/semi-ui"; +import { IconRoute } from "@douyinfe/semi-icons"; +import { FormApi } from "@douyinfe/semi-ui/lib/es/form"; +import { DataRender } from "components/data-render"; +import { Divider } from "components/divider"; +import { DocumentStyle } from "components/document/style"; +import { LogoImage, LogoText } from "components/logo"; +import { Seo } from "components/seo"; +import { Theme } from "components/theme"; +import { User } from "components/user"; +import { usePublicDocumentDetail } from "data/document"; +import { useMount } from "hooks/use-mount"; +import { IsOnMobile } from "hooks/use-on-mobile"; +import { SecureDocumentIllustration } from "illustrations/secure-document"; +import Link from "next/link"; +import React, { useCallback, useMemo, useRef } from "react"; +import { createPortal } from "react-dom"; +import { CollaborationEditor } from "tiptap/editor"; -import { Author } from '../author'; -import styles from './index.module.scss'; -import Router from 'next/router'; -import { useRouterQuery } from 'hooks/use-router-query'; -import { IDocument, IWiki } from '@think/domains'; -import { DocumentFullscreen } from 'components/document/fullscreen'; +import { Author } from "../author"; +import styles from "./index.module.scss"; +import Router from "next/router"; +import { useRouterQuery } from "hooks/use-router-query"; +import { AdType, IDocument, IWiki } from "@think/domains"; +import { DocumentFullscreen } from "components/document/fullscreen"; +import { useAd } from "data/ad"; const { Header } = Layout; const { Text } = Typography; @@ -32,18 +44,25 @@ interface IProps { hideLogo?: boolean; } -export const DocumentPublicReader: React.FC = ({ documentId, hideLogo = false }) => { +export const DocumentPublicReader: React.FC = ({ + documentId, + hideLogo = false, +}) => { const $form = useRef(); const mounted = useMount(); - const { wikiId: currentWikiId } = useRouterQuery<{ wikiId: IWiki['id']; documentId: IDocument['id'] }>(); + const { wikiId: currentWikiId } = useRouterQuery<{ + wikiId: IWiki["id"]; + documentId: IDocument["id"]; + }>(); const { data, loading, error, query } = usePublicDocumentDetail(documentId); + const { data: ads } = useAd(); const { isMobile } = IsOnMobile.useHook(); - + const renderAuthor = useCallback( (element) => { if (!document) return null; - const target = element && element.querySelector('.ProseMirror .title'); + const target = element && element.querySelector(".ProseMirror .title"); if (target) { return createPortal(, target); @@ -62,27 +81,42 @@ export const DocumentPublicReader: React.FC = ({ documentId, hideLogo = const toPublicWikiOrDocumentURL = useCallback(() => { Router.push({ - pathname: currentWikiId ? '/share/document/[documentId]' : '/share/wiki/[wikiId]/document/[documentId]', - query: currentWikiId ? { documentId } : { wikiId: data.wikiId, documentId }, + pathname: currentWikiId + ? "/share/document/[documentId]" + : "/share/wiki/[wikiId]/document/[documentId]", + query: currentWikiId + ? { documentId } + : { wikiId: data.wikiId, documentId }, }); }, [currentWikiId, documentId, data]); + console.log(ads || []); + const content = useMemo(() => { if (error) { // @ts-ignore if (error.statusCode === 400) { return (
- + ($form.current = formApi)} labelPosition="left" onSubmit={handleOk} layout="horizontal" > - + @@ -94,16 +128,16 @@ export const DocumentPublicReader: React.FC = ({ documentId, hideLogo = return (
- {(error && (error as Error).message) || '未知错误'} + {(error && (error as Error).message) || "未知错误"}
); @@ -144,9 +178,14 @@ export const DocumentPublicReader: React.FC = ({ documentId, hideLogo = } footer={ - {!isMobile && data && } - -