diff --git a/src/app.tsx b/src/app.tsx index ea14745..2ba34bf 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -8,7 +8,6 @@ import type { import type { RunTimeLayoutConfig, RuntimeConfig } from '@umijs/max'; import { FormattedMessage, getLocale, history } from '@umijs/max'; import { message } from 'antd'; -import { parse } from 'query-string'; import defaultSettings from '../config/defaultSettings'; import HeaderContent from './components/headerContent'; import { getAdminInfo } from './services/admin'; @@ -19,7 +18,6 @@ import { getSessionStore, getStore, removeStore, - setSessionStore, setStore, } from './utils/store'; @@ -93,10 +91,6 @@ export async function getInitialState(): Promise<{ // ProLayout 支持的api https://procomponents.ant.design/components/layout export const layout: RunTimeLayoutConfig = ({ initialState }) => { - const query = parse(history.location.search) || {}; - if (query['admin-login'] === 'true') { - setSessionStore('site-id', query['site_id']); - } return { breadcrumbRender: false, rightContentRender: () => , @@ -201,6 +195,10 @@ export const request: RuntimeConfig['request'] = { if (adminToken) { config.headers.admin = adminToken; } + const sessionToken = getSessionStore('adminToken'); + if (sessionToken) { + config.headers.admin = sessionToken; + } const siteId = getSessionStore('site-id'); if (siteId) { config.headers['Site-Id'] = siteId; diff --git a/src/locales/bn-BD/content.ts b/src/locales/bn-BD/content.ts index b835b57..0f4df39 100644 --- a/src/locales/bn-BD/content.ts +++ b/src/locales/bn-BD/content.ts @@ -236,6 +236,17 @@ export default { 'content.archive.edit': 'নথি পরিবর্তন করুন', 'content.archive.add': 'ডকুমেন্ট যোগ করুন', 'content.keywords.select': 'কীওয়ার্ড নির্বাচন করুন', + 'content.keywords.extract': 'কীওয়ার্ড বের করুন', + 'content.description.extract': 'সারাংশ বের করুন', + 'content.archive.content.length.error': + 'কন্টেন্টটি খুবই ছোট এবং বের করা যাবে না', + 'content.archive.extract.description': 'সারাংশ বের করুন', + 'content.archive.extract.description.content': + 'আপনি কি নিশ্চিত যে আপনি নথির বিষয়বস্তু থেকে বিমূর্তটি বের করতে চান? অনুগ্রহ করে নিশ্চিত করুন যে আপনি নথির বিষয়বস্তু পূরণ করেছেন। ', + 'content.archive.extract.keywords': 'কীওয়ার্ড বের করুন', + 'content.archive.extract.keywords.content': + 'আপনি কি নিশ্চিত নথির বিষয়বস্তু থেকে কীওয়ার্ড বের করতে চান? অনুগ্রহ করে নিশ্চিত করুন যে আপনি নথির বিষয়বস্তু পূরণ করেছেন। ', + 'content.param.extra-fields': 'কাস্টম প্যারামিটার', 'content.param.other': 'অন্যান্য পরামিতি', 'content.origin-url.name': 'আসল ঠিকানা', 'content.field.default': 'ডিফল্টভাবে পূরণ করার প্রয়োজন নেই', diff --git a/src/locales/en-US/content.ts b/src/locales/en-US/content.ts index fe705f0..97d6649 100644 --- a/src/locales/en-US/content.ts +++ b/src/locales/en-US/content.ts @@ -238,6 +238,16 @@ export default { 'content.archive.edit': 'Modify document', 'content.archive.add': 'Add document', 'content.keywords.select': 'Select keywords', + 'content.keywords.extract': 'Extract keywords', + 'content.description.extract': 'Extract summary', + 'content.archive.content.length.error': 'Content is too short to extract', + 'content.archive.extract.description': 'Extract summary', + 'content.archive.extract.description.content': + 'Are you sure you want to extract the summary from the document content? Please make sure you have completed the document content. ', + 'content.archive.extract.keywords': 'Extract keywords', + 'content.archive.extract.keywords.content': + 'Are you sure you want to extract keywords from the document content? Please make sure you have completed the document content. ', + 'content.param.extra-fields': 'Custom parameters', 'content.param.other': 'Other parameters', 'content.origin-url.name': 'Original address', 'content.field.default': 'No need to fill in by default', diff --git a/src/locales/fa-IR/content.ts b/src/locales/fa-IR/content.ts index 5a53a51..61bee8f 100644 --- a/src/locales/fa-IR/content.ts +++ b/src/locales/fa-IR/content.ts @@ -236,6 +236,17 @@ export default { 'content.archive.edit': 'اصلاح سند', 'content.archive.add': 'سند اضافه کنید', 'content.keywords.select': 'کلمات کلیدی را انتخاب کنید', + 'content.keywords.extract': 'Extract keywords', + 'content.description.extract': 'خلاصه استخراج', + 'content.archive.content.length.error': + 'محتوا خیلی کوتاه است و قابل استخراج نیست', + 'content.archive.extract.description': 'خلاصه استخراج', + 'content.archive.extract.description.content': + 'آیا مطمئن هستید که می خواهید چکیده را از محتوای سند استخراج کنید؟ لطفاً تأیید کنید که محتوای سند را تکمیل کرده اید. ', + 'content.archive.extract.keywords': 'Extract keywords', + 'content.archive.extract.keywords.content': + 'آیا مطمئن هستید که می خواهید کلمات کلیدی را از محتوای سند استخراج کنید؟ لطفاً تأیید کنید که محتوای سند را تکمیل کرده اید. ', + 'content.param.extra-fields': 'پارامترهای سفارشی', 'content.param.other': 'سایر پارامترها', 'content.origin-url.name': 'آدرس اصلی', 'content.field.default': 'نیازی به پر کردن به صورت پیش فرض نیست', diff --git a/src/locales/id-ID/content.ts b/src/locales/id-ID/content.ts index f158b8b..306dbcd 100644 --- a/src/locales/id-ID/content.ts +++ b/src/locales/id-ID/content.ts @@ -239,6 +239,17 @@ export default { 'content.archive.edit': 'Ubah dokumen', 'content.archive.add': 'Tambahkan dokumen', 'content.keywords.select': 'Pilih kata kunci', + 'content.keywords.extract': 'Ekstrak kata kunci', + 'content.description.extract': 'Ekstrak ringkasan', + 'content.archive.content.length.error': + 'Konten terlalu pendek dan tidak dapat diekstraksi', + 'content.archive.extract.description': 'Ekstrak ringkasan', + 'content.archive.extract.description.content': + 'Apakah Anda yakin ingin mengekstrak abstrak dari konten dokumen? Mohon konfirmasi bahwa Anda telah selesai mengisi isi dokumen. ', + 'content.archive.extract.keywords': 'Ekstrak kata kunci', + 'content.archive.extract.keywords.content': + 'Apakah Anda yakin ingin mengekstrak kata kunci dari konten dokumen? Mohon konfirmasi bahwa Anda telah selesai mengisi isi dokumen. ', + 'content.param.extra-fields': 'Parameter khusus', 'content.param.other': 'Parameter lainnya', 'content.origin-url.name': 'Alamat asli', 'content.field.default': 'Tidak perlu mengisi secara default', diff --git a/src/locales/ja-JP/content.ts b/src/locales/ja-JP/content.ts index 8a51932..091e362 100644 --- a/src/locales/ja-JP/content.ts +++ b/src/locales/ja-JP/content.ts @@ -233,6 +233,17 @@ export default { 'content.archive.edit': 'ドキュメントを変更する', 'content.archive.add': 'ドキュメントの追加', 'content.keywords.select': 'キーワードを選択してください', + 'content.keywords.extract': 'キーワードを抽出', + 'content.description.extract': '概要を抽出', + 'content.archive.content.length.error': + 'コンテンツが短すぎるため抽出できません', + 'content.archive.extract.description': '概要を抽出', + 'content.archive.extract.description.content': + '文書コンテンツから要約を抽出してもよろしいですか?書類内容の入力が完了していることをご確認ください。 ', + 'content.archive.extract.keywords': 'キーワードを抽出', + 'content.archive.extract.keywords.content': + 'ドキュメントのコンテンツからキーワードを抽出してもよろしいですか?書類内容の入力が完了していることをご確認ください。 ', + 'content.param.extra-fields': 'カスタムパラメータ', 'content.param.other': 'その他のパラメータ', 'content.origin-url.name': '元のアドレス', 'content.field.default': 'デフォルトでは入力する必要はありません', diff --git a/src/locales/pt-BR/content.ts b/src/locales/pt-BR/content.ts index 2cb33c4..25d49bb 100644 --- a/src/locales/pt-BR/content.ts +++ b/src/locales/pt-BR/content.ts @@ -242,6 +242,17 @@ export default { 'content.archive.edit': 'Modificar documento', 'content.archive.add': 'Adicionar documento', 'content.keywords.select': 'Selecione palavras-chave', + 'content.keywords.extract': 'Extrair palavras-chave', + 'content.description.extract': 'Extrair resumo', + 'content.archive.content.length.error': + 'O conteúdo é muito curto e não pode ser extraído', + 'content.archive.extract.description': 'Extrair resumo', + 'content.archive.extract.description.content': + 'Tem certeza que deseja extrair o resumo do conteúdo do documento? Por favor, confirme que você completou o preenchimento do conteúdo do documento. ', + 'content.archive.extract.keywords': 'Extrair palavras-chave', + 'content.archive.extract.keywords.content': + 'Tem certeza de que deseja extrair palavras-chave do conteúdo do documento? Por favor, confirme que você completou o preenchimento do conteúdo do documento. ', + 'content.param.extra-fields': 'Parâmetros personalizados', 'content.param.other': 'Outros parâmetros', 'content.origin-url.name': 'Endereço original', 'content.field.default': 'Não há necessidade de preencher por padrão', diff --git a/src/locales/ru-RU/content.ts b/src/locales/ru-RU/content.ts index 3c0da4a..c5517df 100644 --- a/src/locales/ru-RU/content.ts +++ b/src/locales/ru-RU/content.ts @@ -239,6 +239,17 @@ export default { 'content.archive.edit': 'Изменить документ', 'content.archive.add': 'Добавить документ', 'content.keywords.select': 'Выберите ключевые слова', + 'content.keywords.extract': 'Извлечь ключевые слова', + 'content.description.extract': 'Извлечь сводку', + 'content.archive.content.length.error': + 'Содержимое слишком короткое и не может быть извлечено', + 'content.archive.extract.description': 'Извлечь сводку', + 'content.archive.extract.description.content': + 'Вы уверены, что хотите извлечь реферат из содержимого документа? Пожалуйста, подтвердите, что вы завершили заполнение содержания документа. ', + 'content.archive.extract.keywords': 'Извлечь ключевые слова', + 'content.archive.extract.keywords.content': + 'Вы уверены, что хотите извлечь ключевые слова из содержимого документа? Пожалуйста, подтвердите, что вы завершили заполнение содержания документа. ', + 'content.param.extra-fields': 'Пользовательские параметры', 'content.param.other': 'Другие параметры', 'content.origin-url.name': 'Исходный адрес', 'content.field.default': 'Не нужно заполнять по умолчанию', diff --git a/src/locales/zh-CN/content.ts b/src/locales/zh-CN/content.ts index 2430413..93b5b93 100644 --- a/src/locales/zh-CN/content.ts +++ b/src/locales/zh-CN/content.ts @@ -223,6 +223,16 @@ export default { 'content.archive.edit': '修改文档', 'content.archive.add': '添加文档', 'content.keywords.select': '选择关键词', + 'content.keywords.extract': '提取关键词', + 'content.description.extract': '提取摘要', + 'content.archive.content.length.error': '内容太短,无法提取', + 'content.archive.extract.description': '提取摘要', + 'content.archive.extract.description.content': + '确定要从文档内容中提取摘要吗?请确认您已经完成了文档内容的填写。', + 'content.archive.extract.keywords': '提取关键词', + 'content.archive.extract.keywords.content': + '确定要从文档内容中提取关键词吗?请确认您已经完成了文档内容的填写。', + 'content.param.extra-fields': '自定义参数', 'content.param.other': '其他参数', 'content.origin-url.name': '原文地址', 'content.field.default': '默认不用填写', diff --git a/src/locales/zh-TW/content.ts b/src/locales/zh-TW/content.ts index 457ca2e..a45aed0 100644 --- a/src/locales/zh-TW/content.ts +++ b/src/locales/zh-TW/content.ts @@ -220,6 +220,16 @@ export default { 'content.archive.edit': '修改文檔', 'content.archive.add': '新增文件', 'content.keywords.select': '選擇關鍵字', + 'content.keywords.extract': '提取關鍵字', + 'content.description.extract': '提取摘要', + 'content.archive.content.length.error': '內容太短,無法提取', + 'content.archive.extract.description': '提取摘要', + 'content.archive.extract.description.content': + '確定要從文件內容中提取摘要嗎?請確認您已經完成了文件內容的填寫。 ', + 'content.archive.extract.keywords': '提取關鍵字', + 'content.archive.extract.keywords.content': + '確定要從文件內容中提取關鍵字嗎?請確認您已經完成了文件內容的填寫。 ', + 'content.param.extra-fields': '自訂參數', 'content.param.other': '其他參數', 'content.origin-url.name': '原文位址', 'content.field.default': '預設不用填寫', diff --git a/src/pages/content/archive/detail.tsx b/src/pages/content/archive/detail.tsx index 90ee014..e7d60e1 100644 --- a/src/pages/content/archive/detail.tsx +++ b/src/pages/content/archive/detail.tsx @@ -7,6 +7,8 @@ import WangEditor from '@/components/editor'; import Keywords from '@/components/keywords'; import MarkdownEditor from '@/components/markdown'; import { + anqiExtractDescription, + anqiExtractKeywords, deleteArchiveImage, getArchiveInfo, getCategories, @@ -32,7 +34,17 @@ import { ProFormTextArea, } from '@ant-design/pro-components'; import { FormattedMessage, history, injectIntl } from '@umijs/max'; -import { Button, Card, Col, Image, Modal, Row, Tag, message } from 'antd'; +import { + Button, + Card, + Col, + Image, + Modal, + Row, + Space, + Tag, + message, +} from 'antd'; import dayjs from 'dayjs'; import React from 'react'; import { IntlShape } from 'react-intl'; @@ -332,6 +344,88 @@ class ArchiveForm extends React.Component { .catch(() => {}); }; + handleExtractDescription = () => { + if (this.state.content.length < 100) { + message.error( + this.props.intl.formatMessage({ + id: 'content.archive.content.length.error', + }), + ); + return false; + } + Modal.confirm({ + title: this.props.intl.formatMessage({ + id: 'content.archive.extract.description', + }), + content: this.props.intl.formatMessage({ + id: 'content.archive.extract.description.content', + }), + onOk: () => { + anqiExtractDescription({ + text: this.state.content, + }) + .then((res) => { + if (res.code === 0) { + this.formRef?.current?.setFieldsValue({ + description: res.data, + }); + } else { + message.info(res.msg); + } + }) + .catch((err) => { + message.error( + err.msg || + this.props.intl.formatMessage({ + id: 'content.submit.failure', + }), + ); + }); + }, + }); + }; + + handleExtractKeywords = () => { + if (this.state.content.length < 100) { + message.error( + this.props.intl.formatMessage({ + id: 'content.archive.content.length.error', + }), + ); + return false; + } + Modal.confirm({ + title: this.props.intl.formatMessage({ + id: 'content.archive.extract.keywords', + }), + content: this.props.intl.formatMessage({ + id: 'content.archive.extract.keywords.content', + }), + onOk: () => { + anqiExtractKeywords({ + text: this.state.content, + }) + .then((res) => { + if (res.code === 0) { + this.formRef?.current?.setFieldsValue({ + keywords: res.data?.join(','), + }); + } else { + message.info(res.msg); + } + }) + .catch((err) => { + message.error( + err.msg || + this.props.intl.formatMessage({ + id: 'content.submit.failure', + }), + ); + }); + }, + }); + }; + handleChooseKeywords = () => { this.setState({ keywordsVisible: true, @@ -644,12 +738,20 @@ class ArchiveForm extends React.Component { })} fieldProps={{ suffix: ( - - - + + + + + + + + ), }} /> @@ -658,6 +760,16 @@ class ArchiveForm extends React.Component { label={this.props.intl.formatMessage({ id: 'content.description.name', })} + extra={ + + + + + + } /> { })} /> - {module.fields?.map((item: any, index: number) => ( - - {item.type === 'text' ? ( + + + {module.fields && ( + + + {module.fields?.map( + (item: any, index: number) => + item.type !== 'editor' && ( + + {item.type === 'text' ? ( + + ) : item.type === 'number' ? ( + + ) : item.type === 'textarea' ? ( + + ) : item.type === 'editor' ? ( + '' + ) : item.type === 'radio' ? ( + { + const tmpData = item.content.split('\n'); + const data = []; + for (const item1 of tmpData) { + data.push({ + label: item1, + value: item1, + }); + } + return data; + }} + /> + ) : item.type === 'checkbox' ? ( + { + const tmpData = item.content.split('\n'); + const data = []; + for (const item1 of tmpData) { + data.push({ + label: item1, + value: item1, + }); + } + return data; + }} + /> + ) : item.type === 'select' ? ( + { + const tmpData = item.content.split('\n'); + const data = []; + for (const item1 of tmpData) { + data.push({ + label: item1, + value: item1, + }); + } + return data; + }} + /> + ) : item.type === 'image' ? ( + + {archive.extra[item.field_name]?.value ? ( +
+ + + + +
+ ) : ( + +
+
+ +
+ +
+
+
+
+ )} +
+ ) : item.type === 'file' ? ( + + {archive.extra[item.field_name]?.value ? ( +
+ + { + archive.extra[item.field_name] + ?.value + } + + + + +
+ ) : ( + + + + )} +
+ ) : ( + '' + )} + + ), + )} +
+ {module.fields?.map( + (item: any, index: number) => + item.type === 'editor' && ( - ) : item.type === 'number' ? ( - - ) : item.type === 'textarea' ? ( - - ) : item.type === 'editor' ? ( - '' - ) : item.type === 'radio' ? ( - { - const tmpData = item.content.split('\n'); - const data = []; - for (const item1 of tmpData) { - data.push({ label: item1, value: item1 }); - } - return data; - }} - /> - ) : item.type === 'checkbox' ? ( - { - const tmpData = item.content.split('\n'); - const data = []; - for (const item1 of tmpData) { - data.push({ label: item1, value: item1 }); - } - return data; - }} - /> - ) : item.type === 'select' ? ( - { - const tmpData = item.content.split('\n'); - const data = []; - for (const item1 of tmpData) { - data.push({ label: item1, value: item1 }); - } - return data; - }} - /> - ) : item.type === 'image' ? ( - - {archive.extra[item.field_name]?.value ? ( -
- - - - -
- ) : ( - -
-
- -
- -
-
-
-
- )} -
- ) : item.type === 'file' ? ( - - {archive.extra[item.field_name]?.value ? ( -
- - {archive.extra[item.field_name]?.value} - - - - -
+ content={extraContent[item.field_name] || ''} + ref={null} + /> ) : ( - - - + content={extraContent[item.field_name] || ''} + key={item.field_name} + field={item.field_name} + ref={null} + /> )}
- ) : ( - '' - )} - - ))} - -
+ ), + )} + + )} {contentSetting.editor === 'markdown' ? ( { ref={this.editorRef} /> )} - {module.fields?.map( - (item: any, index: number) => - item.type === 'editor' && ( - - {contentSetting.editor === 'markdown' ? ( - - ) : ( - - )} - - ), - )}
diff --git a/src/pages/content/archive/index.less b/src/pages/content/archive/index.less index 0b0dfd3..721f3a7 100644 --- a/src/pages/content/archive/index.less +++ b/src/pages/content/archive/index.less @@ -15,6 +15,9 @@ .update-tag { color: #f30; } +.extract-tag { + color: rgba(0, 0, 0, 0.88); +} .relation-item { display: flex; padding: 8px 0; diff --git a/src/pages/content/category/archive/detail.tsx b/src/pages/content/category/archive/detail.tsx index 5d50b8d..6df4756 100644 --- a/src/pages/content/category/archive/detail.tsx +++ b/src/pages/content/category/archive/detail.tsx @@ -1,5 +1,6 @@ import NewContainer from '@/components/NewContainer'; import AttachmentSelect from '@/components/attachment'; +import CollapseItem from '@/components/collaspeItem'; import WangEditor from '@/components/editor'; import MarkdownEditor from '@/components/markdown'; import { @@ -371,165 +372,328 @@ const ArchiveCategoryDetail: React.FC = () => { id: 'content.category.status.description', })} /> - {currentModule.category_fields?.map( - (item: any, index: number) => ( - - {item.type === 'text' ? ( - - ) : item.type === 'number' ? ( - - ) : item.type === 'textarea' ? ( - - ) : item.type === 'editor' ? ( - '' - ) : item.type === 'radio' ? ( - { - const tmpData = item.content.split('\n'); - const data = []; - for (const item1 of tmpData) { - data.push({ label: item1, value: item1 }); - } - return data; - }} - /> - ) : item.type === 'checkbox' ? ( - { - const tmpData = item.content.split('\n'); - const data = []; - for (const item1 of tmpData) { - data.push({ label: item1, value: item1 }); - } - return data; - }} - /> - ) : item.type === 'select' ? ( - { - const tmpData = item.content.split('\n'); - const data = []; - for (const item1 of tmpData) { - data.push({ label: item1, value: item1 }); + {currentModule.category_fields && ( + + + {currentModule.category_fields?.map( + (item: any, index: number) => + item.type !== 'editor' && ( + + {item.type === 'text' ? ( + + ) : item.type === 'number' ? ( + + ) : item.type === 'textarea' ? ( + + ) : item.type === 'radio' ? ( + { + const tmpData = item.content.split('\n'); + const data = []; + for (const item1 of tmpData) { + data.push({ label: item1, value: item1 }); + } + return data; + }} + /> + ) : item.type === 'checkbox' ? ( + { + const tmpData = item.content.split('\n'); + const data = []; + for (const item1 of tmpData) { + data.push({ label: item1, value: item1 }); + } + return data; + }} + /> + ) : item.type === 'select' ? ( + { + const tmpData = item.content.split('\n'); + const data = []; + for (const item1 of tmpData) { + data.push({ label: item1, value: item1 }); + } + return data; + }} + /> + ) : item.type === 'image' ? ( + + {category.extra[item.field_name] ? ( +
+ + + handleCleanExtraField(item.field_name) + } + > + + +
+ ) : ( + + handleUploadExtraField( + item.field_name, + row, + ) + } + open={false} + > +
+
+ +
+ +
+
+
+
+ )} +
+ ) : item.type === 'file' ? ( + + {category.extra[item.field_name] ? ( +
+ + {category.extra[item.field_name]} + + + handleCleanExtraField(item.field_name) + } + > + + +
+ ) : ( + + handleUploadExtraField( + item.field_name, + row, + ) + } + open={false} + > + + + )} +
+ ) : null} + + ), + )} +
+ {currentModule.category_fields?.map( + (item: any, index: number) => + item.type === 'editor' ? ( + - ) : item.type === 'image' ? ( - - {category.extra[item.field_name] ? ( -
- + {contentSetting.editor === 'markdown' ? ( + + updateExtraContent(item.field_name, html) + } + content={extraContent[item.field_name] || ''} + ref={null} /> - - handleCleanExtraField(item.field_name) + ) : ( + + updateExtraContent(item.field_name, html) } - > - - -
- ) : ( - - handleUploadExtraField(item.field_name, row) + content={extraContent[item.field_name] || ''} + key={item.field_name} + field={item.field_name} + ref={null} + /> + )} +
+ ) : item.type === 'radio' ? ( + { + const tmpData = item.content.split('\n'); + const data = []; + for (const item1 of tmpData) { + data.push({ label: item1, value: item1 }); } - open={false} - > + return data; + }} + /> + ) : item.type === 'checkbox' ? ( + { + const tmpData = item.content.split('\n'); + const data = []; + for (const item1 of tmpData) { + data.push({ label: item1, value: item1 }); + } + return data; + }} + /> + ) : item.type === 'select' ? ( + { + const tmpData = item.content.split('\n'); + const data = []; + for (const item1 of tmpData) { + data.push({ label: item1, value: item1 }); + } + return data; + }} + /> + ) : item.type === 'image' ? ( + + {category.extra[item.field_name] ? (
-
- -
- + + + handleCleanExtraField(item.field_name) + } + > + + +
+ ) : ( + + handleUploadExtraField(item.field_name, row) + } + open={false} + > +
+
+ +
+ +
+
+ )} + + ) : item.type === 'file' ? ( + + {category.extra[item.field_name] ? ( +
+ {category.extra[item.field_name]} + + handleCleanExtraField(item.field_name) + } + > + +
- - )} -
- ) : item.type === 'file' ? ( - - {category.extra[item.field_name] ? ( -
- {category.extra[item.field_name]} - - handleCleanExtraField(item.field_name) + ) : ( + + handleUploadExtraField(item.field_name, row) } + open={false} > - - -
- ) : ( - - handleUploadExtraField(item.field_name, row) - } - open={false} - > - - - )} -
- ) : ( - '' - )} - - ), + + + )} + + ) : ( + '' + ), + )} + )} {loaded && ( <> @@ -556,155 +720,6 @@ const ArchiveCategoryDetail: React.FC = () => { )} )} - {currentModule.category_fields?.map( - (item: any, index: number) => - item.type === 'editor' ? ( - - {contentSetting.editor === 'markdown' ? ( - - updateExtraContent(item.field_name, html) - } - content={extraContent[item.field_name] || ''} - ref={null} - /> - ) : ( - - updateExtraContent(item.field_name, html) - } - content={extraContent[item.field_name] || ''} - key={item.field_name} - field={item.field_name} - ref={null} - /> - )} - - ) : item.type === 'radio' ? ( - { - const tmpData = item.content.split('\n'); - const data = []; - for (const item1 of tmpData) { - data.push({ label: item1, value: item1 }); - } - return data; - }} - /> - ) : item.type === 'checkbox' ? ( - { - const tmpData = item.content.split('\n'); - const data = []; - for (const item1 of tmpData) { - data.push({ label: item1, value: item1 }); - } - return data; - }} - /> - ) : item.type === 'select' ? ( - { - const tmpData = item.content.split('\n'); - const data = []; - for (const item1 of tmpData) { - data.push({ label: item1, value: item1 }); - } - return data; - }} - /> - ) : item.type === 'image' ? ( - - {category.extra[item.field_name] ? ( -
- - - handleCleanExtraField(item.field_name) - } - > - - -
- ) : ( - - handleUploadExtraField(item.field_name, row) - } - open={false} - > -
-
- -
- -
-
-
-
- )} -
- ) : item.type === 'file' ? ( - - {category.extra[item.field_name] ? ( -
- {category.extra[item.field_name]} - - handleCleanExtraField(item.field_name) - } - > - - -
- ) : ( - - handleUploadExtraField(item.field_name, row) - } - open={false} - > - - - )} -
- ) : ( - '' - ), - )}
diff --git a/src/pages/content/module/components/moduleForm/index.tsx b/src/pages/content/module/components/moduleForm/index.tsx index 36e1584..6030377 100644 --- a/src/pages/content/module/components/moduleForm/index.tsx +++ b/src/pages/content/module/components/moduleForm/index.tsx @@ -390,7 +390,13 @@ const ModuleForm: React.FC = (props) => { key="add" type="primary" onClick={() => { - setCurrentField({ form: 'archive' }); + setCurrentField({ + form: 'archive', + type: 'text', + required: false, + follow_level: false, + is_filter: false, + }); setEditVisible(true); }} > @@ -427,7 +433,13 @@ const ModuleForm: React.FC = (props) => { key="add" type="primary" onClick={() => { - setCurrentField({ form: 'category' }); + setCurrentField({ + form: 'category', + type: 'text', + required: false, + follow_level: false, + is_filter: false, + }); setEditVisible(true); }} > diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index 6d05c36..ea35aaf 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -19,7 +19,7 @@ import React, { useEffect, useState } from 'react'; import CopyToClipboard from 'react-copy-to-clipboard'; import { getSiteInfo } from '@/services'; -import { setStore } from '@/utils/store'; +import { setSessionStore, setStore } from '@/utils/store'; import styles from './index.less'; const LoginMessage: React.FC<{ @@ -85,7 +85,9 @@ const Login: React.FC = () => { }); message.success(defaultLoginSuccessMessage); - setStore('adminToken', res.data.token); + // 后台快速登录的,存 session + setSessionStore('site-id', res.data.site_id); + setSessionStore('adminToken', res.data.token); await fetchUserInfo(); /** 此方法会跳转到 redirect 参数所在的位置 */ if (!history) return; diff --git a/src/pages/plugin/guestbook/components/setting/index.tsx b/src/pages/plugin/guestbook/components/setting/index.tsx index 9f6bd4e..f93039a 100644 --- a/src/pages/plugin/guestbook/components/setting/index.tsx +++ b/src/pages/plugin/guestbook/components/setting/index.tsx @@ -1,4 +1,7 @@ -import { pluginGetGuestbookSetting, pluginSaveGuestbookSetting } from '@/services/plugin/guestbook'; +import { + pluginGetGuestbookSetting, + pluginSaveGuestbookSetting, +} from '@/services/plugin/guestbook'; import { ActionType, ModalForm, @@ -38,8 +41,12 @@ const GuestbookSetting: React.FC = (props) => { const handleRemoveItem = (index: number) => { Modal.confirm({ - title: intl.formatMessage({ id: 'plugin.guestbook.field.delete.confirm' }), - content: intl.formatMessage({ id: 'plugin.guestbook.field.delete.confirm.content' }), + title: intl.formatMessage({ + id: 'plugin.guestbook.field.delete.confirm', + }), + content: intl.formatMessage({ + id: 'plugin.guestbook.field.delete.confirm.content', + }), onOk: async () => { setting.fields.splice(index, 1); setting.fields = [].concat(setting.fields); @@ -118,11 +125,15 @@ const GuestbookSetting: React.FC = (props) => { valueEnum: { false: { - text: intl.formatMessage({ id: 'content.module.field.isrequired.no' }), + text: intl.formatMessage({ + id: 'content.module.field.isrequired.no', + }), status: 'Default', }, true: { - text: intl.formatMessage({ id: 'content.module.field.isrequired.yes' }), + text: intl.formatMessage({ + id: 'content.module.field.isrequired.yes', + }), status: 'Success', }, }, @@ -208,7 +219,7 @@ const GuestbookSetting: React.FC = (props) => { key="add" type="primary" onClick={() => { - setCurrentField({}); + setCurrentField({ type: 'text', required: false }); setEditVisible(true); }} > @@ -232,7 +243,8 @@ const GuestbookSetting: React.FC = (props) => { width={600} title={ currentField.name - ? currentField.name + intl.formatMessage({ id: 'content.module.field.edit' }) + ? currentField.name + + intl.formatMessage({ id: 'content.module.field.edit' }) : intl.formatMessage({ id: 'content.module.field.add' }) } open={editVisible} @@ -251,39 +263,67 @@ const GuestbookSetting: React.FC = (props) => { name="name" required label={intl.formatMessage({ id: 'content.module.field.name' })} - extra={intl.formatMessage({ id: 'content.module.field.name.description' })} + extra={intl.formatMessage({ + id: 'content.module.field.name.description', + })} /> = (props) => { fieldProps={{ rows: 4, }} - extra={intl.formatMessage({ id: 'content.module.field.default.description' })} + extra={intl.formatMessage({ + id: 'content.module.field.default.description', + })} /> )} diff --git a/src/pages/plugin/user/components/setting/index.tsx b/src/pages/plugin/user/components/setting/index.tsx index 0040e6d..b80f1c5 100644 --- a/src/pages/plugin/user/components/setting/index.tsx +++ b/src/pages/plugin/user/components/setting/index.tsx @@ -39,8 +39,12 @@ const UserFieldSetting: React.FC = (props) => { const handleRemoveItem = (record: any, index: number) => { Modal.confirm({ - title: intl.formatMessage({ id: 'plugin.guestbook.field.delete.confirm' }), - content: intl.formatMessage({ id: 'plugin.guestbook.field.delete.confirm.content' }), + title: intl.formatMessage({ + id: 'plugin.guestbook.field.delete.confirm', + }), + content: intl.formatMessage({ + id: 'plugin.guestbook.field.delete.confirm.content', + }), onOk: async () => { pluginDeleteUserField({ field_name: record.field_name }); setting.fields.splice(index, 1); @@ -171,7 +175,7 @@ const UserFieldSetting: React.FC = (props) => { key="add" type="primary" onClick={() => { - setCurrentField({}); + setCurrentField({ type: 'text', required: false }); setEditVisible(true); }} > @@ -199,7 +203,8 @@ const UserFieldSetting: React.FC = (props) => { width={600} title={ currentField.name - ? currentField.name + intl.formatMessage({ id: 'content.module.field.edit' }) + ? currentField.name + + intl.formatMessage({ id: 'content.module.field.edit' }) : intl.formatMessage({ id: 'content.module.field.add' }) } open={editVisible} @@ -218,27 +223,49 @@ const UserFieldSetting: React.FC = (props) => { name="name" required label={intl.formatMessage({ id: 'content.module.field.name' })} - extra={intl.formatMessage({ id: 'plugin.user.setting.name.description' })} + extra={intl.formatMessage({ + id: 'plugin.user.setting.name.description', + })} /> = (props) => { fieldProps={{ rows: 4, }} - extra={intl.formatMessage({ id: 'content.module.field.default.description' })} + extra={intl.formatMessage({ + id: 'content.module.field.default.description', + })} /> )} diff --git a/src/pages/setting/diyfield.tsx b/src/pages/setting/diyfield.tsx index b86d713..0bcbdcc 100644 --- a/src/pages/setting/diyfield.tsx +++ b/src/pages/setting/diyfield.tsx @@ -52,7 +52,7 @@ const SettingDiyFieldFrom: React.FC = () => { const handleEditField = (index: number) => { if (index === -1) { - setCurrentField({}); + setCurrentField({ type: 'text', required: false }); } else { setCurrentField(setting[index]); } diff --git a/src/services/anqi.ts b/src/services/anqi.ts index 91a0c91..9d9189e 100644 --- a/src/services/anqi.ts +++ b/src/services/anqi.ts @@ -8,7 +8,10 @@ export async function anqiLogin(body: any, options?: { [key: string]: any }) { }); } -export async function getAnqiInfo(params?: any, options?: { [key: string]: any }) { +export async function getAnqiInfo( + params?: any, + options?: { [key: string]: any }, +) { return get({ url: '/anqi/info', params, @@ -16,7 +19,10 @@ export async function getAnqiInfo(params?: any, options?: { [key: string]: any } }); } -export async function checkAnqiInfo(params?: any, options?: { [key: string]: any }) { +export async function checkAnqiInfo( + params?: any, + options?: { [key: string]: any }, +) { return get({ url: '/anqi/check', params, @@ -32,7 +38,10 @@ export async function anqiUpload(body: any, options?: { [key: string]: any }) { }); } -export async function anqiShareTemplate(body: any, options?: { [key: string]: any }) { +export async function anqiShareTemplate( + body: any, + options?: { [key: string]: any }, +) { return post({ url: '/anqi/template/share', body, @@ -40,7 +49,10 @@ export async function anqiShareTemplate(body: any, options?: { [key: string]: an }); } -export async function anqiDownloadTemplate(body: any, options?: { [key: string]: any }) { +export async function anqiDownloadTemplate( + body: any, + options?: { [key: string]: any }, +) { return post({ url: '/anqi/template/download', body, @@ -48,7 +60,10 @@ export async function anqiDownloadTemplate(body: any, options?: { [key: string]: }); } -export async function anqiSendFeedback(body: any, options?: { [key: string]: any }) { +export async function anqiSendFeedback( + body: any, + options?: { [key: string]: any }, +) { return post({ url: '/anqi/feedback', body, @@ -64,7 +79,10 @@ export async function anqiRestart(body: any, options?: { [key: string]: any }) { }); } -export async function anqiTranslateArchive(body: any, options?: { [key: string]: any }) { +export async function anqiTranslateArchive( + body: any, + options?: { [key: string]: any }, +) { return post({ url: '/anqi/translate', body, @@ -72,7 +90,10 @@ export async function anqiTranslateArchive(body: any, options?: { [key: string]: }); } -export async function anqiAiPseudoArchive(body: any, options?: { [key: string]: any }) { +export async function anqiAiPseudoArchive( + body: any, + options?: { [key: string]: any }, +) { return post({ url: '/anqi/ai/pseudo', body, @@ -80,7 +101,10 @@ export async function anqiAiPseudoArchive(body: any, options?: { [key: string]: }); } -export async function anqiAiGenerateStream(body: any, options?: { [key: string]: any }) { +export async function anqiAiGenerateStream( + body: any, + options?: { [key: string]: any }, +) { return post({ url: '/anqi/ai/stream', body, @@ -88,10 +112,35 @@ export async function anqiAiGenerateStream(body: any, options?: { [key: string]: }); } -export async function anqiAiGenerateStreamData(params?: any, options?: { [key: string]: any }) { +export async function anqiAiGenerateStreamData( + params?: any, + options?: { [key: string]: any }, +) { return get({ url: '/anqi/ai/stream/data', params, options, }); } + +export async function anqiExtractDescription( + body: any, + options?: { [key: string]: any }, +) { + return post({ + url: '/anqi/extract/description', + body, + options, + }); +} + +export async function anqiExtractKeywords( + body: any, + options?: { [key: string]: any }, +) { + return post({ + url: '/anqi/extract/keywords', + body, + options, + }); +}