feat:backup

This commit is contained in:
1708-huayu 2024-09-28 22:21:21 +08:00
parent b6b1847b92
commit 1aba426886
4 changed files with 80 additions and 69 deletions

View File

@ -20,6 +20,10 @@ class UploadUtils {
UploadUtils.staticStore = store; UploadUtils.staticStore = store;
} }
getActiveFile() { getActiveFile() {
let persist = this.store.get("persist:tableBarItem");
if (persist === undefined){
return undefined
}
let tableBarItem = JSON.parse(this.store.get("persist:tableBarItem")); let tableBarItem = JSON.parse(this.store.get("persist:tableBarItem"));
if (!tableBarItem) { if (!tableBarItem) {
return; return;

View File

@ -15,6 +15,9 @@ const createWindow = () => {
nodeIntegration: true, nodeIntegration: true,
// 启用后nodeIntegration会无效 // 启用后nodeIntegration会无效
contextIsolation: false, contextIsolation: false,
// 添加预加载脚本
// __dirname 字符串指向当前正在执行脚本的路径
// path.join API 将多个路径联结在一起,创建一个跨平台的路径字符串。
preload: path.join(__dirname, 'preload.js') preload: path.join(__dirname, 'preload.js')
} }
}) })
@ -40,7 +43,7 @@ const createWindow = () => {
event.preventDefault() event.preventDefault()
} }
// console.log('Pressed ',input.key) // console.log('Pressed ',input.key)
if (input.key.toUpperCase() === 'F5' && input.type.toLowerCase() === "keydown" && input.isAutoRepeat === false) { if (input.key.toUpperCase() === 'F5' && input.isAutoRepeat === false) {
win.reload() win.reload()
} }
if (input.key.toUpperCase() === 'F12' && input.type.toLowerCase() === "keydown" && input.isAutoRepeat === false) { if (input.key.toUpperCase() === 'F12' && input.type.toLowerCase() === "keydown" && input.isAutoRepeat === false) {

View File

@ -1,3 +1,4 @@
// 通过预加载脚本从渲染器访问Node.js
// 预加载脚本 在上下文隔离渲染器进程中导入 Node.js 和 Electron 模块的概念 // 预加载脚本 在上下文隔离渲染器进程中导入 Node.js 和 Electron 模块的概念
// 所有的 Node.js API接口 都可以在 preload 进程中被调用. // 所有的 Node.js API接口 都可以在 preload 进程中被调用.
// 它拥有与Chrome扩展一样的沙盒。 // 它拥有与Chrome扩展一样的沙盒。

View File

@ -31,11 +31,12 @@ import TableCellActionMenuPlugin from '@/pages/Note/Hlexical/plugins/TableAction
import ExcalidrawPlugin from "@/pages/Note/Hlexical/plugins/ExcalidrawPlugin"; import ExcalidrawPlugin from "@/pages/Note/Hlexical/plugins/ExcalidrawPlugin";
import TableOfContentsPlugin from "@/pages/Note/Hlexical/plugins/TableOfContentsPlugin"; import TableOfContentsPlugin from "@/pages/Note/Hlexical/plugins/TableOfContentsPlugin";
import ContextMenuPlugin from "@/pages/Note/Hlexical/plugins/ContextMenuPlugin" import ContextMenuPlugin from "@/pages/Note/Hlexical/plugins/ContextMenuPlugin"
import {Spin,FloatButton } from "antd"; import {Spin, FloatButton} from "antd";
import { CommentOutlined, CustomerServiceOutlined } from '@ant-design/icons'; import {CommentOutlined, CustomerServiceOutlined} from '@ant-design/icons';
import {useState} from "react"; import {useState} from "react";
import DragDropPaste from "@/pages/Note/Hlexical/plugins/DragDropPastePlugin"; import DragDropPaste from "@/pages/Note/Hlexical/plugins/DragDropPastePlugin";
import TreeViewPlugin from "@/pages/Note/Hlexical/plugins/TreeViewPlugin"; import TreeViewPlugin from "@/pages/Note/Hlexical/plugins/TreeViewPlugin";
function Placeholder() { function Placeholder() {
return <div className="editor-placeholder">记录一些灵感吧</div>; return <div className="editor-placeholder">记录一些灵感吧</div>;
} }
@ -48,88 +49,90 @@ export default function Hlexical(props) {
}, },
nodes: UsefulNodes nodes: UsefulNodes
}; };
const [spinningState,setSpinningState]=useState(!isEmpty(props.filePath)) const [spinningState, setSpinningState] = useState(!isEmpty(props.filePath))
console.log("Hlexical(props):this.props.filePath:", props.filePath) console.log("Hlexical(props):this.props.filePath:", props.filePath)
if (!isEmpty(props.filePath)&&props.filePath.endsWith(".md")){ if (!isEmpty(props.filePath) && props.filePath.endsWith(".md")) {
let promise = importFile(props.filePath); let promise = importFile(props.filePath);
promise.then(value => { promise.then(value => {
if (isEmpty(value)) { if (isEmpty(value)) {
setSpinningState(false) setSpinningState(false)
return return
} }
editorConfig={...editorConfig,editorState: () => $convertFromMarkdownString(value.toString(), TRANSFORMERS)} editorConfig = {
...editorConfig,
editorState: () => $convertFromMarkdownString(value.toString(), TRANSFORMERS)
}
setSpinningState(false) setSpinningState(false)
}).catch(error => }).catch(error =>
console.error(error) console.error(error)
) )
} }
return ( return (
// <Spin size="large" fullscreen="ture" spinning={spinningState}>
<LexicalComposer initialConfig={editorConfig}>
<div className="editor-container">
{/* 富文本插件 */}
<ToolbarPlugin/>
<div className="editor-inner">
<LexicalComposer initialConfig={editorConfig}> <RichTextPlugin
<div className="editor-container"> contentEditable={<ContentEditable className="editor-input"/>}
{/* 富文本插件 */} placeholder={<Placeholder/>}
<ToolbarPlugin/> ErrorBoundary={LexicalErrorBoundary}
<div className="editor-inner"> />
<Spin size="large" fullscreen="ture" spinning={spinningState}>
<RichTextPlugin
contentEditable={<ContentEditable className="editor-input"/>}
placeholder={<Placeholder/>}
ErrorBoundary={LexicalErrorBoundary}
/> </Spin>
<HistoryPlugin/>
{/*黑窗口动态记录当前操作*/}
{/*<TreeViewPlugin/>*/}
<AutoFocusPlugin/>
<CodeHighlightPlugin/>
<ListPlugin/>
<LinkPlugin/>
<AutoLinkPlugin/>
<ListMaxIndentLevelPlugin maxDepth={7}/>
{/* 表格操作 */}
<TablePlugin
hasCellMerge={true}
hasCellBackgroundColor={true}
/>
{/* 表格单元格操作 */}
<TableCellActionMenuPlugin/>
<TabIndentationPlugin/>
{/*markdown 快捷键*/}
<MarkdownShortcutPlugin transformers={TRANSFORMERS}/>
{/*图片加载*/}
<ImagesPlugin captionsEnabled={true}/>
<InlineImagePlugin/>
{/*分割线 */} <HistoryPlugin/>
<HorizontalRulePlugin/> {/*黑窗口动态记录当前操作*/}
{/*页分割线*/} {/*<TreeViewPlugin/>*/}
<AutoFocusPlugin/>
<CodeHighlightPlugin/>
<ListPlugin/>
<LinkPlugin/>
<AutoLinkPlugin/>
<ListMaxIndentLevelPlugin maxDepth={7}/>
{/* 表格操作 */}
<TablePlugin
hasCellMerge={true}
hasCellBackgroundColor={true}
/>
{/* 表格单元格操作 */}
<TableCellActionMenuPlugin/>
<TabIndentationPlugin/>
{/*markdown 快捷键*/}
<MarkdownShortcutPlugin transformers={TRANSFORMERS}/>
{/*图片加载*/}
<ImagesPlugin captionsEnabled={true}/>
<InlineImagePlugin/>
{/*目录加载*/} {/*分割线 */}
<TableOfContentsPlugin filePath={props.filePath}/> <HorizontalRulePlugin/>
{/*右键菜单*/} {/*页分割线*/}
<ContextMenuPlugin/>
{/* 画图 */} {/*目录加载*/}
<ExcalidrawPlugin/> <TableOfContentsPlugin filePath={props.filePath}/>
{/* 拖拽复制*/} {/*右键菜单*/}
<DragDropPaste /> <ContextMenuPlugin/>
<ImportFilePlugin filePath={props.filePath} setSpinningState={setSpinningState}/> {/* 画图 */}
<SaveFilePlugin filePath={props.filePath}/> <ExcalidrawPlugin/>
{/*文件操作导入文件*/} {/* 拖拽复制*/}
{/*<ActionPlugin/>*/} <DragDropPaste/>
<FloatButton.Group <ImportFilePlugin filePath={props.filePath} setSpinningState={setSpinningState}/>
trigger="hover" <SaveFilePlugin filePath={props.filePath}/>
type="primary" {/*文件操作导入文件*/}
style={{ {/*<ActionPlugin/>*/}
right: 94, <FloatButton.Group
}} trigger="hover"
icon={<CustomerServiceOutlined />} type="primary"
> style={{
<FloatButton /> right: 94,
<FloatButton icon={<CommentOutlined />} /> }}
</FloatButton.Group> icon={<CustomerServiceOutlined/>}>
<FloatButton/>
<FloatButton icon={<CommentOutlined/>}/>
</FloatButton.Group>
</div>
</div> </div>
</div> </LexicalComposer>
// </Spin>
</LexicalComposer>
); );
} }