feat:backup
This commit is contained in:
parent
b6b1847b92
commit
1aba426886
|
@ -20,6 +20,10 @@ class UploadUtils {
|
|||
UploadUtils.staticStore = store;
|
||||
}
|
||||
getActiveFile() {
|
||||
let persist = this.store.get("persist:tableBarItem");
|
||||
if (persist === undefined){
|
||||
return undefined
|
||||
}
|
||||
let tableBarItem = JSON.parse(this.store.get("persist:tableBarItem"));
|
||||
if (!tableBarItem) {
|
||||
return;
|
||||
|
|
5
main.js
5
main.js
|
@ -15,6 +15,9 @@ const createWindow = () => {
|
|||
nodeIntegration: true,
|
||||
// 启用后nodeIntegration会无效
|
||||
contextIsolation: false,
|
||||
// 添加预加载脚本
|
||||
// __dirname 字符串指向当前正在执行脚本的路径
|
||||
// path.join API 将多个路径联结在一起,创建一个跨平台的路径字符串。
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
|
@ -40,7 +43,7 @@ const createWindow = () => {
|
|||
event.preventDefault()
|
||||
}
|
||||
// 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()
|
||||
}
|
||||
if (input.key.toUpperCase() === 'F12' && input.type.toLowerCase() === "keydown" && input.isAutoRepeat === false) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// 通过预加载脚本从渲染器访问Node.js
|
||||
// 预加载脚本 在上下文隔离渲染器进程中导入 Node.js 和 Electron 模块的概念
|
||||
// 所有的 Node.js API接口 都可以在 preload 进程中被调用.
|
||||
// 它拥有与Chrome扩展一样的沙盒。
|
||||
|
|
|
@ -31,11 +31,12 @@ import TableCellActionMenuPlugin from '@/pages/Note/Hlexical/plugins/TableAction
|
|||
import ExcalidrawPlugin from "@/pages/Note/Hlexical/plugins/ExcalidrawPlugin";
|
||||
import TableOfContentsPlugin from "@/pages/Note/Hlexical/plugins/TableOfContentsPlugin";
|
||||
import ContextMenuPlugin from "@/pages/Note/Hlexical/plugins/ContextMenuPlugin"
|
||||
import {Spin,FloatButton } from "antd";
|
||||
import { CommentOutlined, CustomerServiceOutlined } from '@ant-design/icons';
|
||||
import {Spin, FloatButton} from "antd";
|
||||
import {CommentOutlined, CustomerServiceOutlined} from '@ant-design/icons';
|
||||
import {useState} from "react";
|
||||
import DragDropPaste from "@/pages/Note/Hlexical/plugins/DragDropPastePlugin";
|
||||
import TreeViewPlugin from "@/pages/Note/Hlexical/plugins/TreeViewPlugin";
|
||||
|
||||
function Placeholder() {
|
||||
return <div className="editor-placeholder">记录一些灵感吧</div>;
|
||||
}
|
||||
|
@ -48,34 +49,38 @@ export default function Hlexical(props) {
|
|||
},
|
||||
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)
|
||||
if (!isEmpty(props.filePath)&&props.filePath.endsWith(".md")){
|
||||
if (!isEmpty(props.filePath) && props.filePath.endsWith(".md")) {
|
||||
let promise = importFile(props.filePath);
|
||||
promise.then(value => {
|
||||
if (isEmpty(value)) {
|
||||
setSpinningState(false)
|
||||
return
|
||||
}
|
||||
editorConfig={...editorConfig,editorState: () => $convertFromMarkdownString(value.toString(), TRANSFORMERS)}
|
||||
editorConfig = {
|
||||
...editorConfig,
|
||||
editorState: () => $convertFromMarkdownString(value.toString(), TRANSFORMERS)
|
||||
}
|
||||
setSpinningState(false)
|
||||
}).catch(error =>
|
||||
console.error(error)
|
||||
)
|
||||
}
|
||||
return (
|
||||
|
||||
// <Spin size="large" fullscreen="ture" spinning={spinningState}>
|
||||
<LexicalComposer initialConfig={editorConfig}>
|
||||
<div className="editor-container">
|
||||
{/* 富文本插件 */}
|
||||
<ToolbarPlugin/>
|
||||
<div className="editor-inner">
|
||||
<Spin size="large" fullscreen="ture" spinning={spinningState}>
|
||||
|
||||
<RichTextPlugin
|
||||
contentEditable={<ContentEditable className="editor-input"/>}
|
||||
placeholder={<Placeholder/>}
|
||||
ErrorBoundary={LexicalErrorBoundary}
|
||||
/> </Spin>
|
||||
/>
|
||||
|
||||
<HistoryPlugin/>
|
||||
{/*黑窗口动态记录当前操作*/}
|
||||
{/*<TreeViewPlugin/>*/}
|
||||
|
@ -110,7 +115,7 @@ export default function Hlexical(props) {
|
|||
{/* 画图 */}
|
||||
<ExcalidrawPlugin/>
|
||||
{/* 拖拽复制*/}
|
||||
<DragDropPaste />
|
||||
<DragDropPaste/>
|
||||
<ImportFilePlugin filePath={props.filePath} setSpinningState={setSpinningState}/>
|
||||
<SaveFilePlugin filePath={props.filePath}/>
|
||||
{/*文件操作导入文件*/}
|
||||
|
@ -121,15 +126,13 @@ export default function Hlexical(props) {
|
|||
style={{
|
||||
right: 94,
|
||||
}}
|
||||
icon={<CustomerServiceOutlined />}
|
||||
>
|
||||
<FloatButton />
|
||||
<FloatButton icon={<CommentOutlined />} />
|
||||
icon={<CustomerServiceOutlined/>}>
|
||||
<FloatButton/>
|
||||
<FloatButton icon={<CommentOutlined/>}/>
|
||||
</FloatButton.Group>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</LexicalComposer>
|
||||
|
||||
// </Spin>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue