diff --git a/src/components/LexicalEditor/Index.jsx b/src/components/LexicalEditor/Index.jsx index cc0a69b..b0cfa13 100644 --- a/src/components/LexicalEditor/Index.jsx +++ b/src/components/LexicalEditor/Index.jsx @@ -87,38 +87,29 @@ function LexicalDefaultValuePlugin({ value = "" }= {}) { const nodes = $generateNodesFromDOM(editor, dom); if (clear) { root.clear(); - // $getRoot().clear(); - // $getRoot().select(); } - // const p = $createParagraphNode(); - // const _p = nodes.filter(n => n.__size !== 0).forEach((n) => { const paragraphNode = $createParagraphNode(); paragraphNode.append(n); - // p.append(paragraphNode); root.append(paragraphNode); }); - - // root.append(...nodes.filter(n => n)); }; - // 默认值设置只用初始化一次; - // 空值不更新 HTML; useEffect(() => { if (editor && !isEmpty(value)) { editor.update(() => { updateHTML(editor, value, true); }); } - }, [value]); + }, [editor, value]); return null; } function MyOnChangePlugin({ ignoreHistoryMergeTagChange = true, ignoreSelectionChange = true, onChange }) { const [editor] = useLexicalComposerContext(); useEffect(() => { - if (onChange) { + if (typeof onChange === 'function') { return editor.registerUpdateListener(({editorState, dirtyElements, dirtyLeaves, prevEditorState, tags}) => { if ( @@ -130,21 +121,11 @@ function MyOnChangePlugin({ ignoreHistoryMergeTagChange = true, ignoreSelectionC ) { return; } - // const editorStateJSON = editorState.toJSON(); - let html; - let textContent; editorState.read(() => { const root = $getRoot(); const textContent = root.getTextContent(); - // console.log('textContent', textContent); - const html = $generateHtmlFromNodes(editor); - // console.log('html', html); - - // setEditorContent(content); - if (typeof onChange === 'function') { - onChange({ editorStateJSON: editorState.toJSON(), editor, tags, htmlContent: html, textContent }); - } + onChange({ editorStateJSON: editorState.toJSON(), editor, tags, htmlContent: html, textContent }); }); }); } diff --git a/src/config.js b/src/config.js index 3128562..6b282e1 100644 --- a/src/config.js +++ b/src/config.js @@ -6,7 +6,7 @@ // export const WS_URL = 'wss://p9axztuwd7x8a7.mycht.cn/whatsapp_144'; // prod: Slave // debug: -export const API_HOST = 'http://202.103.68.157:8889/v2'; +export const API_HOST = 'http://202.103.68.144:8889/v2'; export const WS_URL = 'ws://202.103.68.157:8889'; // prod: // export const API_HOST = 'https://p9axztuwd7x8a7.mycht.cn/whatsapp_server'; diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index eb2e528..87046dc 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -51,7 +51,7 @@ const useAuthStore = create(devtools((set, get) => ({ setLoginStatus(200) const json = await fetchJSON( - 'http://202.103.68.157:889/dingtalk/dingtalkwork/WhatsAppAuth', + 'http://202.103.68.144:889/dingtalk/dingtalkwork/WhatsAppAuth', //`https://p9axztuwd7x8a7.mycht.cn/dingtalk/dingtalkwork/WhatsAppAuth`, { authCode }, ) diff --git a/src/views/accounts/SnippetList.jsx b/src/views/accounts/SnippetList.jsx index 4b5eba2..89d252b 100644 --- a/src/views/accounts/SnippetList.jsx +++ b/src/views/accounts/SnippetList.jsx @@ -1,4 +1,4 @@ -import { Row, Col, Tag, List, Form, Input, Button, Space, Modal, Select, message } from 'antd' +import { App, Row, Col, Tag, List, Form, Input, Button, Space, Modal, Select, message } from 'antd' import { useState, useEffect } from 'react' import EditorInput from '../../components/EditorInput' import HtmlPreview from './HtmlPreview' @@ -25,12 +25,28 @@ function SnippetList() { const [loginUser] = useAuthStore((state) => [state.loginUser]) + const { notification } = App.useApp() const [isSnippetModalOpen, setSnippetModalOpen] = useState(false) const [isHtmlLoading, setHtmlLoading] = useState(false) const onSnippetFinish = (values) => { - console.log('onSnippetFinish:', values) saveOrUpdateSnippet(values) + .then(() => { + notification.info({ + message: 'Notification', + description: '图文保存成功', + placement: 'top', + }) + setSnippetModalOpen(false) + }) + .catch(ex => { + notification.error({ + message: 'Notification', + description: ex.message, + placement: 'top', + duration: 4, + }) + }) } const onSnippetFailed = (error) => {