From 7cafc8358ccc5f87f2ae8534e204405b78a6d730 Mon Sep 17 00:00:00 2001 From: wenbo <616421019@qq.com> Date: Sun, 28 Mar 2021 18:59:48 +0800 Subject: [PATCH] mark mind pro --- package.json | 9 +- src/main/onedrive.js | 2 +- src/renderer/App.vue | 506 +++++++++++++++---- src/renderer/components/editor.vue | 45 +- src/renderer/components/profile.vue | 30 +- src/renderer/components/signup.vue | 174 +++++++ src/renderer/components/treeList.vue | 116 ++++- src/renderer/locales/en.json | 19 +- src/renderer/locales/zh.json | 27 +- src/renderer/main.js | 3 + src/renderer/mind/assist/callout.js | 10 +- src/renderer/mind/export/exportKityMind.js | 2 +- src/renderer/mind/export/exportOPML.js | 4 +- src/renderer/mind/import/importMindmaster.js | 231 +++++++++ src/renderer/mind/import/importXmind.js | 11 +- src/renderer/mind/layout/MindLayout2.js | 253 ++++++++-- src/renderer/mind/list/list.js | 39 +- src/renderer/mind/mind.js | 98 ++-- src/renderer/mind/node.js | 8 +- src/renderer/router/index.js | 5 + 20 files changed, 1348 insertions(+), 244 deletions(-) create mode 100644 src/renderer/components/signup.vue create mode 100644 src/renderer/mind/import/importMindmaster.js diff --git a/package.json b/package.json index d3b35f0..6a16555 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mind", - "version": "1.1.9", + "version": "1.2.0", "author": "", "description": "an mind map and outliner software", "license": null, @@ -116,15 +116,16 @@ "quill": "^1.3.7", "request": "^2.88.2", "svg.js": "^2.7.1", + "turndown": "^7.0.0", + "turndown-plugin-gfm": "^1.0.2", "twemoji": "^12.1.5", "vue": "^2.5.16", "vue-electron": "^1.0.6", "vue-i18n": "^8.17.3", "vue-router": "^3.0.1", + "vuejs-dialog": "^1.4.2", "vuex": "^3.0.1", - "vuex-electron": "^1.0.0", - "turndown": "^7.0.0", - "turndown-plugin-gfm": "^1.0.2" + "vuex-electron": "^1.0.0" }, "devDependencies": { "ajv": "^6.5.0", diff --git a/src/main/onedrive.js b/src/main/onedrive.js index 3dc1cff..6f37306 100644 --- a/src/main/onedrive.js +++ b/src/main/onedrive.js @@ -343,7 +343,7 @@ function getFile(e,id,url){ process.on('uncaughtException', function(err) { - + console.log(err); }); diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 54a3ac6..f256615 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -50,10 +50,9 @@ @click="about.show = false" > -

MarkMind

-

{{ about.version }}

-

Twitter: @MarkMind

-

github: @MarkMindLtd

+

MarkMind Pro

+

v{{ about.version }}

+ @@ -105,6 +104,7 @@ import importKityMind from "./mind/import/importKityMind"; import importXmind from "./mind/import/importXmind"; import importMarkdown from "./mind/import/importMarkdown"; import importTxt from "./mind/import/importTxt"; +import importMindMaster from "./mind/import/importMindmaster"; import i18n from "./locales/index"; import Onedrive from "./components/onedrive"; import tomato from "./components/tomato"; @@ -117,7 +117,10 @@ var turndownPluginGfm = require('turndown-plugin-gfm'); let Store = require("electron-store"); var store = new Store(); var profile = store.get("config"); -var activeCode = store.get("activeCode"); +var userData = store.get("user"); +var testTime=store.get("testTime"); + +var allowUse=true; let canvasWidth = profile.canvasWidth; let canvasHeight = profile.canvasHeight; @@ -169,6 +172,72 @@ function transferDataToList(data) { return arr; } +function listToTree(list) { + var obj = {}; + var root = null; + list.forEach(d => { + if (!obj[d.id]) { + obj[d.id] = d; + d.children = []; + } + if (d.pid) { + if (obj[d.pid]) { + obj[d.pid].children.push(d); + d.children = []; + } + } else { + root = d; + } + + }); + return root; +}; + +function aesEncrypt(data, key) { + const cipher = crypto.createCipher('aes-192-ctr', key); + var crypted = cipher.update(data, 'utf8', 'hex'); + crypted += cipher.final('hex'); + return crypted; +} + +function aesDecrypt(encrypted, key) { + try{ + const decipher = crypto.createDecipher('aes-192-ctr', key); + var decrypted = decipher.update(encrypted, 'hex', 'utf8'); + decrypted += decipher.final('utf8'); + return decrypted; + }catch(err){ + console.log(err); + return false; + } +} + +function InputSecret(vueItem,text,cb){ + + vueItem.$dialog.prompt({ + title: "", + body: i18n.t('profile.secretTip'), + message:"" + },{ + okText: i18n.t('profile.secretConfirm'), + cancelText: i18n.t('profile.secretCancel'), + promptHelp:'' + }).then(dialog=>{ + if(dialog.data){ + var d= aesDecrypt(text,dialog.data); + if(d){ + cb(d); + }else{ + InputSecret(vueItem,text,cb); + } + }else{ + InputSecret(vueItem,text,cb); + } + }).catch(err=>{ + vueItem.$router.push('/list'); + }) +} + export default { name: "app", components: { @@ -191,7 +260,7 @@ export default { msg: "", about: { show: false, - version: "1.1.9", + version: "1.2.0", }, logo: logo, showactive: false, @@ -211,9 +280,12 @@ export default { var openFilePath = this.$store.state.MindData.openFile; if (openFilePath.trim()) { this.$router.push("/refresh"); - this.$store.dispatch("setMindData", {}); this.openFile(openFilePath); } + if(!testTime){ + let t=new Date().getTime()+''; + store.set('testTime',aesEncrypt(t,'1q2w3e4r!@#')); + } }, mounted() { @@ -224,11 +296,11 @@ export default { var me = this; this.checkVersion(); + + var openFilePath = this.$store.state.MindData.openFile; - this.$store.dispatch("vip", { - vip: true, - }); + ipcRenderer.on("cmd", (e, arg) => { this.menu(arg["type"]); @@ -238,6 +310,10 @@ export default { this.$router.push("/list"); } + if(userData&&userData.activeCode){ + this.activeSoft(userData.activeCode); + } + document.addEventListener("paste", (e) => { e.preventDefault(); var text; @@ -398,6 +474,26 @@ export default { toggleMenu() { this.showMenu = !this.showMenu; }, + exportData(data){ + var root = null + var mindData = data; + mindData.mindData.forEach((data, i) => { + if (i == 0) { + root = listToTree(data); + } else { + root.children.push(listToTree(data)); + } + }); + + if (mindData.induceData && mindData.induceData.length) { + mindData.induceData.forEach(d => { + + root.children.push(listToTree(d.mindData)); + }); + } + + return root; + }, dataToList(data) { var list = []; function pushList(data) { @@ -448,6 +544,7 @@ export default { }, save(isCreate, path, arg) { var me = this; + // console.log(this.$store.state.MindData.folderPath); var path = path || this.$store.state.MindData.folderPath; if (path) { try { @@ -481,7 +578,18 @@ export default { if (!data) { return; } - zip.file(file, JSON.stringify(data)); + data.canvasSize=profile.canvasWidth; + // console.log(data); + if(profile.secret){ + var obj={ + secret:true, + data:aesEncrypt(JSON.stringify(data),profile.secret) + } + zip.file(file,JSON.stringify(obj)); + }else{ + zip.file(file,JSON.stringify(data)); + } + zip.generateAsync({ type: "nodebuffer" }).then(function (content) { if (me.$route.name == "editor") { var mind = document.getElementById("mind").mind; @@ -552,8 +660,17 @@ export default { if (!data) { return; } - - zip.file(file, JSON.stringify(data)); + data.canvasSize=profile.canvasSize; + if(profile.secret){ + console.log(data); + var obj={ + secret:true, + data:aesEncrypt(JSON.stringify(data),profile.secret) + } + zip.file(file,JSON.stringify(obj)); + }else{ + zip.file(file,JSON.stringify(data)); + } zip.generateAsync({ type: "nodebuffer" }).then(function (content) { dialog .showSaveDialog({ @@ -587,6 +704,7 @@ export default { }); }); }, + listGetData(list, zip, flag) { var data = JSON.parse(JSON.stringify(list.getData(zip, flag))); var children = data.children; @@ -623,7 +741,10 @@ export default { }); } - var m = JSON.parse(JSON.stringify(this.$store.state.MindData)); + // var m = JSON.parse(JSON.stringify(this.$store.state.MindData)); + var m = { + mindData:window.markmindData + } var oldInduceData = m.mindData.induceData; var newInduceData = []; @@ -702,40 +823,75 @@ export default { res.forEach((data, i) => { images.image[keys[i]] = types[i] + data; }); - me.$store.dispatch("setImage", images).then(() => { + // me.$store.dispatch("setImage", images).then(() => { for (var k in files) { if (k.endsWith(".json")) { files[k].async("text").then((res) => { + var mindData = JSON.parse(res); + if(mindData.secret){ + InputSecret(me,mindData.data,function(data){ + if(data){ + me.$store.dispatch("setFilePath", { path: path }); + + window.markmindData = JSON.parse(data); + markmindData.images = images; + if (flag) return; + var p = "/"; + setTimeout(() => { + me.$router.push("/list"); + }, 0); + } + }); + }else{ + + me.$store.dispatch("setFilePath", { path: path }); + window.markmindData = mindData; + markmindData.images = images; + + if (flag) return; + var p = "/"; + setTimeout(() => { + me.$router.push("/list"); + }, 0); + } - me.$store.dispatch("setFilePath", { path: p }); - me.$store.dispatch("setMindData", mindData).then(() => { - if (flag) return; - var p = "/"; - setTimeout(() => { - me.$router.push("/list"); - }, 0); - }); + + }); } } - }); + // }); }); } else { for (var k in files) { if (k.endsWith(".json")) { files[k].async("text").then((res) => { var mindData = JSON.parse(res); - - me.$store.dispatch("setFilePath", { path: p }); - me.$store.dispatch("setMindData", mindData).then(() => { - if (flag) return; - var p = "/"; - - setTimeout(() => { - me.$router.push("/list"); - }, 0); - }); + if(mindData.secret){ + InputSecret(me,mindData.data,function(data){ + if(data){ + me.$store.dispatch("setFilePath", { path: path }); + window.markmindData = JSON.parse(data); + markmindData.images = {}; + if (flag) return; + var p = "/"; + setTimeout(() => { + me.$router.push("/list"); + }, 0); + } + }); + }else{ + me.$store.dispatch("setFilePath", { path: path }); + window.markmindData = mindData; + markmindData.images = {}; + + if (flag) return; + var p = "/"; + setTimeout(() => { + me.$router.push("/list"); + }, 0); + } }); } } @@ -752,15 +908,60 @@ export default { shell.openExternal(url); }, - activeSoft() { + activeSoft(code) { var me = this; - var code = this.$refs.activeCode.value; if (!code) return; if (!navigator.onLine) { this.message(i18n.t("node.offline")); return; } + + var now =new Date().getTime(); + + if(testTime){ + var _t=aesDecrypt(testTime,'1q2w3e4r!@#'); + if(_t){ + if(now>(parseInt(_t) + 86400000*30)){ + allowUse=false; + } + } + } + + var salt="whoisyourdaddy!@qwerasdf"; + var result=aesDecrypt(code,salt); + + if(result){ + var r = JSON.parse(result); + var endDate = new Date(r.endDate).getTime(); + if(now>endDate){ + if(!allowUse){ + setTimeout(()=>{ + me.$router.push('/signup'); + },0); + } + return { + flag:false, + msg:i18n.t('node.dateLimit') + } + }else{ + this.$store.dispatch("vip", { + vip: true, + }); + allowUse=true; + return { + flag:true, + endDate:r.endDate + } + } + }else{ + if(!allowUse){ + setTimeout(()=>{ + me.$router.push('/signup'); + },0); + } + return false; + } }, getData() { if (this.$route.name == "editor") { @@ -770,9 +971,9 @@ export default { var list = document.getElementById("list").list; var data = this.listGetData(list, null, false); } - var m = JSON.parse(JSON.stringify(this.$store.state.MindData)); - data.scrollTop = m.mindData.scrollTop; - data.scrollLeft = m.mindData.scrollLeft; + // var m = JSON.parse(JSON.stringify(this.$store.state.MindData)); + data.scrollTop = window.markmindData.scrollTop; + data.scrollLeft = window.markmindData.scrollLeft; return data; }, openlink(link){ @@ -783,12 +984,19 @@ export default { this.showMenu = false; switch (id) { case "New File": + if(!allowUse){ + alert(i18n.t('node.allowUse')) + return + } if (this.$route.name == "editor") { var mind = document.getElementById("mind").mind; var needSave = mind.dirty(); - } else { + } else if(this.$route.name == "list"){ var list = document.getElementById("list").list; var needSave = list.dirty(); + }else{ + this.$router.push('/list'); + return; } if (needSave) { @@ -798,12 +1006,23 @@ export default { } me.$store.dispatch("setFilePath", { path: "" }); me.$router.push("/refresh"); - this.$store.dispatch("setMindData", {}).then(() => { - me.$router.push("/list"); - }); + window.markmindData={ + image:{} + }; + setTimeout(()=>{ + me.$router.push("/list"); + },20); + + // this.$store.dispatch("setMindData", {}).then(() => { + + // }); break; case "Open File": + if(!allowUse){ + alert(i18n.t('node.allowUse')) + return + } dialog .showOpenDialog({ properties: ["openFile"], @@ -825,12 +1044,19 @@ export default { break; case "Setting": + if(!allowUse){ + alert(i18n.t('node.allowUse')) + return + } if (this.$route.name == "editor") { var mind = document.getElementById("mind").mind; var needSave = mind.dirty(); - } else { + } else if(this.$route.name == "list"){ var list = document.getElementById("list").list; var needSave = list.dirty(); + }else{ + this.$router.push("/profile"); + return; } if (needSave) { @@ -844,11 +1070,13 @@ export default { this.$router.push("/profile"); break; case "Export-FreeMind": - var data = this.getData(); - this.$store.dispatch("setMindData", data).then(() => { - var listData = JSON.parse( - JSON.stringify(this.$store.getters.getData) - ); + var data = this.getData(); + // window.markmindData = data; + //markmindData.images = {}; + var exportData={}; + $.extend(true,exportData,data); + // this.$store.dispatch("setMindData", data).then(() => { + var listData = this.exportData(exportData); var d = exportFreeMind(listData); // this.$store.dispatch("setMindData", m.mindData); dialog @@ -862,14 +1090,14 @@ export default { fs.writeFileSync(filePath, d); } }); - }); + // }); break; case "Export-OPML": var data = this.getData(); - this.$store.dispatch("setMindData", data).then(() => { - var listData = JSON.parse( - JSON.stringify(this.$store.getters.getData) - ); + var exportData={}; + $.extend(true,exportData,data); + var listData = this.exportData(exportData); + // this.$store.dispatch("setMindData", data).then(() => { var d = exportOPML(listData, listData.text || "markmind"); // this.$store.dispatch("setMindData", m.mindData); dialog @@ -883,17 +1111,16 @@ export default { fs.writeFileSync(filePath, d); } }); - }); + // }); break; case "Export-MarkDown": var data = this.getData(); - this.$store.dispatch("setMindData", data).then(() => { - var listData = JSON.parse( - JSON.stringify(this.$store.getters.getData) - ); - var md = exportMd(listData); - // console.log(m.marks); + var exportData={}; + $.extend(true,exportData,data); + var listData = this.exportData(exportData); + //this.$store.dispatch("setMindData", data).then(() => { + var md = exportMd(listData); // this.$store.dispatch("setMindData", m.mindData); dialog .showSaveDialog({ @@ -907,14 +1134,17 @@ export default { } }) .catch((e) => {}); - }); + // }); break; case "Export-KityMind": var data = this.getData(); - this.$store.dispatch("setMindData", data).then(() => { - var listData = JSON.parse( - JSON.stringify(this.$store.getters.getData) - ); + var exportData={}; + $.extend(true,exportData,data); + var listData = this.exportData(exportData); + // this.$store.dispatch("setMindData", data).then(() => { + // var listData = JSON.parse( + // JSON.stringify(this.$store.getters.getData) + // ); var d = JSON.stringify(exportKityMind(listData)); // this.$store.dispatch("setMindData", m.mindData); dialog @@ -928,7 +1158,7 @@ export default { fs.writeFileSync(filePath, d); } }); - }); + // }); break; case "Import-OPML": dialog @@ -960,11 +1190,13 @@ export default { marks: [], }; me.$store.dispatch("setFilePath", { path: "" }); - me.$store.dispatch("setMindData", mindData).then(() => { + window.markmindData = mindData; + markmindData.images = {}; + // me.$store.dispatch("setMindData", mindData).then(() => { setTimeout(() => { me.$router.push("/list"); }, 0); - }); + //}); }) .catch((e) => {}); }); @@ -997,9 +1229,11 @@ export default { scrollTop: 3800, marks: mdata.marks, }; - me.$store.dispatch("setMindData", mindData).then(() => { + window.markmindData = mindData; + markmindData.images = {}; + // me.$store.dispatch("setMindData", mindData).then(() => { me.$router.push("/list"); - }); + // }); }); } }); @@ -1050,25 +1284,28 @@ export default { res.forEach((data, i) => { images.image[keys[i]] = types[i] + data; }); - me.$store.dispatch("setImage", images).then(() => { + // me.$store.dispatch("setImage", images).then(() => { for (var k in files) { if (k == "content.json") { files[k].async("text").then((res) => { var mindData = JSON.parse(res); me.$store.dispatch("setFilePath", { path: "" }); - me.$store - .dispatch( - "setMindData", - importXmind(mindData[0]) - ) - .then(() => { - var p = "/"; - me.$router.push("/list"); - }); + var data = importXmind(mindData[0]); + window.markmindData = data; + markmindData.images = images; + // me.$store + // .dispatch( + // "setMindData", + // importXmind(mindData[0]) + // ) + //.then(() => { + var p = "/"; + me.$router.push("/list"); + // }); }); } } - }); + // }); }); } else { for (var k in files) { @@ -1076,11 +1313,14 @@ export default { files[k].async("text").then((res) => { var mindData = JSON.parse(res); me.$store.dispatch("setFilePath", { path: "" }); - me.$store - .dispatch("setMindData", importXmind(mindData[0])) - .then(() => { + var data = importXmind(mindData[0]); + window.markmindData = data; + markmindData.images = {}; + // me.$store + // .dispatch("setMindData", importXmind(mindData[0])) + // .then(() => { me.$router.push("/list"); - }); + // }); }); } } @@ -1091,6 +1331,45 @@ export default { }); break; + case 'Import-MindMaster': + dialog + .showOpenDialog({ + properties: ["openFile"], + filters: [{ name: "MindMaster", extensions: ["emmx"] }], + }) + .then(({ filePaths }) => { + if (filePaths.length) { + var p = filePaths[0]; + me.$router.push("/refresh"); + fs.readFile(p, function (err, data) { + if (err) throw err; + var zip = JSZip.loadAsync(data); + zip.then(function (e) { + e.files['page/page.xml'].async('text').then(res=>{ + var xml=$.parseXML(res); + var data=importMindMaster(xml); + window.markmindData = data; + markmindData.images = {}; + me.$router.push("/list"); + }).catch(err=>{ + + }); + + // e.files['rels/page_rels.xml'].async('text').then(res=>{ + // var xml=$.parseXML(res); + // console.log(xml); + // }).catch(err=>{ + + // }); + + + }); + }); + } + }); + + break; + case "Import-MarkDown": dialog .showOpenDialog({ @@ -1105,9 +1384,12 @@ export default { if (err) throw err; var data = importMarkdown(data.toString("utf-8")); me.$store.dispatch("setFilePath", { path: "" }); - me.$store.dispatch("setMindData", data).then(() => { + + window.markmindData = data; + markmindData.images = {}; + // me.$store.dispatch("setMindData", data).then(() => { me.$router.push("/list"); - }); + // }); }); } }); @@ -1127,9 +1409,11 @@ export default { if (err) throw err; var data = importTxt(data.toString("utf-8")); me.$store.dispatch("setFilePath", { path: "" }); - me.$store.dispatch("setMindData", data).then(() => { + window.markmindData = data; + markmindData.images = {}; + //me.$store.dispatch("setMindData", data).then(() => { me.$router.push("/list"); - }); + //}); }); } }); @@ -1209,6 +1493,9 @@ export default { case "Activate": this.showactive = true; break; + case "Login": + this.$router.push('/signup'); + break; case "Save To Onedrive": ipcRenderer.send("refreshToken"); this.$store.dispatch("setShowOneDrive", true); @@ -1983,30 +2270,48 @@ html.print { .bg-red { background-color: red; + border-radius:3px; + padding: 0 3px; } .bg-orange { background-color: orange; + border-radius:3px; + padding: 0 3px; } .bg-green { background-color: green; + border-radius:3px; + padding: 0 3px; } .bg-yellow { background-color: yellow; + border-radius:3px; + padding: 0 3px; } .bg-blue { background-color: blue; + border-radius:3px; + padding: 0 3px; } .bg-gray { background-color: gray; + border-radius:3px; + padding: 0 3px; } .bg-greenyellow { background-color: greenyellow; + border-radius:3px; + padding: 0 3px; } .bg-white { background-color: white; + border-radius:3px; + padding: 0 3px; } .bg-black { background-color: #333; + border-radius:3px; + padding: 0 3px; } .mind-editor .markdown-body blockquote, @@ -2573,14 +2878,6 @@ html.print { background: #fff; } -button { - width: 100%; - height: 24px; - border: 1px solid #d6d6d6; - background: #fff; - margin: 2px 0; -} - .cicada-list .markdown-body blockquote { line-height: 24px; border-left: 0.2em solid #dfe2e5; @@ -2766,10 +3063,23 @@ button { .emptytext { color: rgba(0, 0, 0, 0); background: #f3f3f3; + border-radius:3px; } .emptytext:hover { color: inherit; background: transparent; } + +.node-note{ + box-shadow:0 0 0 #ccc!important; +} +.node-note .win-content{ + background: #fbfae5; + box-shadow: 0px 0px 6px #e0e0e0; +} +mark{ + padding:0 3px; + border-radius:3px; +} diff --git a/src/renderer/components/editor.vue b/src/renderer/components/editor.vue index 2df481b..b617d1c 100644 --- a/src/renderer/components/editor.vue +++ b/src/renderer/components/editor.vue @@ -103,7 +103,7 @@ { - this.$router.push("/list"); - }); + this.storeData(); + this.$router.push("/list"); }, //context menu command(e) { @@ -1476,6 +1491,10 @@ export default { // canvas.width = width * scale; // canvas.height = height * scale; // canvas.getContext("2d").scale(scale, scale); + if(width>16000){ + alert('Image size is too large'); + return + } var box = that.mind.getMindBox(); if (profile.canvasWidth == 8000) { @@ -1806,7 +1825,7 @@ export default { }); }, removeWireFrame() { - console.log(this.selecWireFrame) + //console.log(this.selecWireFrame) this.mind.execute("removeWireFrame", { wf: this.selecWireFrame }); this.showWireFrame = false; }, @@ -2522,4 +2541,6 @@ a { .relate-ship h3 { line-height: 28px !important; } + + diff --git a/src/renderer/components/profile.vue b/src/renderer/components/profile.vue index 7b4e336..71d1e06 100644 --- a/src/renderer/components/profile.vue +++ b/src/renderer/components/profile.vue @@ -30,7 +30,7 @@
{{ $t("profile.lang") }}: - @@ -48,6 +48,14 @@
+
+ {{ $t("profile.secret") }}: +
+
{{ $t("profile.shortcut") }}:
+
{{ $t("profile.canvasSize") }}
@@ -145,6 +154,11 @@ export default { "12000x12000", "14000x14000", "16000x16000", + "18000x18000", + "20000x20000", + "24000x24000", + "28000x28000", + "30000x30000", ], theme: profile.theme, lang: profile.language, @@ -155,6 +169,7 @@ export default { plantuml: profile.plantumlServer || "", keyModel: profile.keyModel || "default", math: profile.math, + secret:profile.secret||'' }; }, mounted() { @@ -184,6 +199,7 @@ export default { plantumlServer: this.plantuml, keyModel: this.keyModel, math: this.math, + secret:this.secret }, }; store.set("config", config); @@ -195,6 +211,11 @@ export default { 2: 12000, 3: 14000, 4: 16000, + 5: 18000, + 6: 20000, + 7: 24000, + 8: 28000, + 9: 30000 }; this.size = i; this.width = obj[i]; @@ -209,6 +230,13 @@ export default { }; \ No newline at end of file diff --git a/src/renderer/components/treeList.vue b/src/renderer/components/treeList.vue index adf1909..ad26af9 100644 --- a/src/renderer/components/treeList.vue +++ b/src/renderer/components/treeList.vue @@ -428,8 +428,6 @@ import uuid from "../mind/uuid"; import $ from "jquery"; import theme from "../mind/theme"; -import { saveAs } from "file-saver"; - import List, { Node } from "../mind/list/list"; function debounce(func, wait) { @@ -444,7 +442,33 @@ function debounce(func, wait) { func.apply(context, args); }, wait); }; -} +}; + +function listToTree(list) { + var obj = {}; + var root = null; + list.forEach(d => { + if (!obj[d.id]) { + obj[d.id] = d; + d.children = []; + } + }); + + list.forEach(d => { + if(d.isRoot||d.nodeType=='induce'||d.nodeType=='freeNode'||d.rootType=='induce'){ + root = d; + } + + if (d.pid) { + if (obj[d.pid]) { + obj[d.pid].children.push(d); + d.children = []; + } + } + }); + return root; +}; + var store = new Store(); var profile = store.get("config"); @@ -662,7 +686,7 @@ export default { focusItem.shoudRender = true; }, 0); } - console.log("shiftTabCtrl"); + return; } @@ -762,7 +786,7 @@ export default { if (focusItem) { if (focusItem == me.list.showingNode) { var n = new Node({ - id: +new Date(), + id: uuid(), text: "", }); @@ -1176,6 +1200,8 @@ export default { document.onmousewheel = null; $(document).off("click"); $("body").off("click"); + $("#list").off("focus"); + $("#list").off("blur"); if (this.list) { this.list.off("showLink", this.showLinkEvent); this.list.off("showNode", this.showNodeEvent); @@ -1190,18 +1216,22 @@ export default { }, mounted() { - var mindData = JSON.parse(JSON.stringify(this.$store.state.MindData)); - var images = mindData.images; + var mindData = window.markmindData; var me = this; try { - var data = JSON.parse(JSON.stringify(this.$store.getters.getData)); + var data = this.getData(mindData); if (mindData) { if (mindData.theme) { theme.use(mindData.theme); } + var images = mindData.images||{}; } } catch (e) { + window.markmindData={ + image:{} + }; + // console.log(markmindData) theme.use("blue"); this.$store.dispatch("setFilePath", { path: "" }); this.$store.dispatch("setTag", "local"); @@ -1223,6 +1253,8 @@ export default { }; } + + this.el = document.getElementById("list"); this.list = new List(this.el); @@ -1305,6 +1337,10 @@ export default { this.list.init(data, images); + if(!this.list.root.isExpand){ + this.list.root.expand(); + } + $("body").off("click"); $("body").on("click", ".li-node .node-priority", function (e) { e.stopPropagation(); @@ -1395,9 +1431,50 @@ export default { window.onresize = () => { this.hidden(); }; + + $("#list").off('focus').on("focus", ".li-node .text", function (e) { + e.preventDefault(); + e.stopPropagation(); + var node =$(this).closest(".li-node").get(0).node; + + if (node.shoudRender) { + node._oldMdText = node.data.mdText; + node.textDom.innerHTML = node.data.mdText; + node.focus(); + } + }); + + $("#list").off('blur').on("blur", ".li-node .text", function (e) { + e.preventDefault(); + e.stopPropagation(); + var node =$(this).closest(".li-node").get(0).node; + node.cancelEdit(); + }); + + }, methods: { + getData(d){ + var root = null + var mindData={}; + var mindData = $.extend(true, mindData, d); + // console.log(d); + mindData.mindData.forEach((data, i) => { + if (i == 0) { + root = listToTree(data); + } else { + root.children.push(listToTree(data)); + } + }); + + if (mindData.induceData && mindData.induceData.length) { + mindData.induceData.forEach(da => { + root.children.push(listToTree(da.mindData)); + }); + } + return root; + }, showColorList() { this.showColor = true; }, @@ -1675,7 +1752,10 @@ export default { }); } - var m = JSON.parse(JSON.stringify(this.$store.state.MindData)); + // var m = JSON.parse(JSON.stringify(this.$store.state.MindData)); + var m = { + mindData:window.markmindData + } var oldInduceData = m.mindData.induceData; var newInduceData = []; @@ -1704,16 +1784,19 @@ export default { m.mindData.relateLinkData = []; } - return this.$store.dispatch("setMindData", m.mindData); + //return this.$store.dispatch("setMindData", m.mindData); + if(window.markmindData.images){ + m.mindData.images=window.markmindData.images + }; + window.markmindData = m.mindData; }, enterMind() { if (!this.list.stack.dirty()) { this.$router.push("/"); return; } - this.saveToStore(true).then(() => { - this.$router.push("/"); - }); + this.saveToStore(true); + this.$router.push("/"); }, refresh(e) { @@ -2047,10 +2130,11 @@ export default { .li-node .node-remark { background: #f5f5f5; outline: transparent solid 2px; - padding: 2px 4px; + padding: 2px 6px; color: inherit; font-size: 12px; - line-height: 24px; + line-height: 20px; + border-radius:3px } .theme-dark .li-node .node-remark { background: #2d2d2d; @@ -2419,6 +2503,8 @@ export default { user-select: none; box-shadow: 0 0 6px #ccc; max-width: 260px; + z-index:4000; + border-radius:4px; } .win-toolbar > span { diff --git a/src/renderer/locales/en.json b/src/renderer/locales/en.json index 2767717..29fda71 100644 --- a/src/renderer/locales/en.json +++ b/src/renderer/locales/en.json @@ -37,6 +37,7 @@ "sure":"Sure", "open":"Open", "active":"Activated", + "expired":"Expired", "end":"End Date", "activeTitle":"Please Enter Activation Code", "activeBtn":"Activate Now", @@ -76,8 +77,10 @@ "top":"top", "left":"left", "right":"right", - "bottom":"bottom" - + "bottom":"bottom", + "register":"Sign Up", + "dateLimit":"Active Code Expired", + "allowUse":"You Should To Purchase An Activation Code To Continue To Use" }, "topMenu":[ { @@ -228,6 +231,11 @@ "name":"About", "type":"menu" }, + { + "id":"Login", + "name":"Login", + "type":"menu" + }, { "id":10, "type":"split" @@ -479,7 +487,12 @@ "math":"Formula Parse Type", "katex":"Katex", "mathjax":"Mathjax Image", - "mathTip":"When Export Mindmap To PNG,Select This Item" + "mathTip":"When Export Mindmap To PNG,Select This Item", + "secret":"Use This Password When Save File", + "secretTip":"Enter Your Password:", + "secretBtns":["Confirm","Cancel"], + "secretConfirm":"Confirm", + "secretCancel":"Cancel" } } \ No newline at end of file diff --git a/src/renderer/locales/zh.json b/src/renderer/locales/zh.json index 7dca0d1..fd14aca 100644 --- a/src/renderer/locales/zh.json +++ b/src/renderer/locales/zh.json @@ -37,6 +37,7 @@ "sure":"确定", "open":"打开", "active":"已激活", + "expired":"已过期", "end":"结束日期", "activeTitle":"请输入激活码", "activeBtn":"立即激活", @@ -76,7 +77,10 @@ "top":"上", "left":"左", "right":"右", - "bottom":"下" + "bottom":"下", + "register":"没有账号,去注册", + "dateLimit":"激活码已过期,请重新购买", + "allowUse":"试用期结束,需要购买激活码才能继续使用" }, "topMenu":[ { @@ -134,7 +138,13 @@ "id":"Import-Xmind Zen", "name":"Xmind Zen", "type":"menu" - },{ + }, + { + "id":"Import-MindMaster", + "name":"MindMaster", + "type":"menu" + }, + { "id":"Import-KityMind", "name":"百度脑图", "type":"menu" @@ -227,6 +237,11 @@ "name":"关于", "type":"menu" }, + { + "id":"Login", + "name":"用户登录", + "type":"menu" + }, { "id":11, "type":"split" @@ -479,7 +494,13 @@ "math":"解析公式", "katex":"Katex", "mathjax":"Mathjax To Image", - "mathTip":"当导出思维导图为图片时,选择该项可以导出比较美观的公式" + "mathTip":"当导出思维导图为图片时,选择该项可以导出比较美观的公式", + "secret":"保存文件时的加密密码", + "secretTip":"文件已加密,请输入密码:", + "secretBtns":["确认","取消"], + "secretConfirm":"确认", + "secretCancel":"取消" + } } \ No newline at end of file diff --git a/src/renderer/main.js b/src/renderer/main.js index e53ca4e..43cc355 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -8,6 +8,9 @@ import store from './store' import i18n from './locales/index' import '../renderer/exportWord/exportword' +import 'vuejs-dialog/dist/vuejs-dialog.min.css'; +import VuejsDialog from 'vuejs-dialog'; +Vue.use(VuejsDialog); var path =require('path'); let ipcRenderer=require('electron').ipcRenderer; diff --git a/src/renderer/mind/assist/callout.js b/src/renderer/mind/assist/callout.js index 4d43141..6d59d2c 100644 --- a/src/renderer/mind/assist/callout.js +++ b/src/renderer/mind/assist/callout.js @@ -1,7 +1,15 @@ import Node from '../node' export default class Callout { - constructor(node,data={text:'callout',nodeType:'callout'},color='#f06'){ + constructor(node,data={ + text:'callout', + nodeType:'callout', + paddingLeft: 6, + paddingRight: 6, + paddingBottom: 2, + paddingTop: 2, + fontSize:12 + },color='#f06'){ this.node=node; this.data=data; this.color=color; diff --git a/src/renderer/mind/export/exportKityMind.js b/src/renderer/mind/export/exportKityMind.js index c2b2e05..bbea793 100644 --- a/src/renderer/mind/export/exportKityMind.js +++ b/src/renderer/mind/export/exportKityMind.js @@ -34,7 +34,7 @@ const createJson=(arr)=>{ var obj={ data:{ id:ele.id, - text:ele.text, + text:htmlToText(ele.text), priority:ele.priority, progress:ele.percent?(parseInt(ele.percent/10)-1):'', hyperlink:ele.link, diff --git a/src/renderer/mind/export/exportOPML.js b/src/renderer/mind/export/exportOPML.js index 971116c..fd23326 100644 --- a/src/renderer/mind/export/exportOPML.js +++ b/src/renderer/mind/export/exportOPML.js @@ -4,7 +4,7 @@ const exportOPML=(data,title)=>{ var nodeXml= createXml(data); console.log(nodeXml); var xml=` - + ${title} @@ -22,7 +22,7 @@ const createXml=(data)=>{ var text=htmlToText(data.text); var html='{ diff --git a/src/renderer/mind/import/importMindmaster.js b/src/renderer/mind/import/importMindmaster.js new file mode 100644 index 0000000..5b7176f --- /dev/null +++ b/src/renderer/mind/import/importMindmaster.js @@ -0,0 +1,231 @@ +import uuid from '../uuid' +import $ from 'jquery' +let Store=require('electron-store'); +var store=new Store(); +var profile=store.get('config'); + +let canvasWidth=profile.canvasWidth; +let canvasHeight=profile.canvasHeight; + +var mind=null; +var nodes = {}; +var root=null; +var summary=[]; +var summaryBoundary={}; + +var color=['#fda16c','#74bdf7','#71FF5E','orange','#D4D4AA','yellow']; + +const importMindmaster=function(data){ + nodes = {}; + root=null; + summary=[]; + summaryBoundary={}; + mind={ + "theme":'blue', + "mindData":[], + "induceData":[], + "wireFrameData":[], + "relateLink":[], + + "background":'', + "relateLinkData":[], + "calloutData":[], + 'marks':[] + }; + + var elements = data.children[0].children; + for (var i=0,len = elements.length;it.trim().length); + var text=t.join('
'); + nodeData.text=text; + } + if(item.tagName=='Note'){ + var textArr=$(item).text().trim().split('\n'); + var t=textArr.filter(t=>t.trim().length); + var text=t.join('
'); + nodeData.remark=text; + } + if(item.tagName=='HyperLinks'){ + nodeData.link=$(item).find('Address').attr('V'); + } + if($ele.attr('Type')=='SummaryTopic'){ + if(item.tagName=='LevelData'){ + nodeData.superids = $(item).find('Super').attr('V'); + if($(item).find('SubLevel')){ + nodeData.childrenIds = $(item).find('SubLevel').attr('V'); + } + } + }else{ + if(item.tagName=='LevelData'){ + nodeData.childrenIds = $(item).find('SubLevel').attr('V'); + } + } + + }); + + //主节点 + if($ele.attr('Type') == 'MainIdea'){ + nodeData.main=1; + nodeData.isRoot=1; + nodeData.x=canvasWidth/2; + nodeData.y=canvasHeight/2; + root=nodeData; + } + + //总结根节点 + if($ele.attr('Type') == 'SummaryTopic'){ + nodeData.eleType = 'SummaryTopic'; + nodeData.nodeType="induce"; + summary.push(nodeData); + } + + nodes[$ele.attr('ID')] = nodeData; + + } + + //callout + if($ele.attr('Type')&&$ele.attr('Type')=='Callout'){ + var callout={ + nodeId:'', + color:'#f06', + rootData:{ + text:'', + id:$ele.attr('ID'), + paddingLeft: 6, + paddingRight: 6, + paddingBottom: 2, + paddingTop: 2, + fontSize:12 + } + }; + + $ele.children().each(function(i,item){ + if(item.tagName == 'Text'){ + var textArr=$(item).text().trim().split('\n'); + var t=textArr.filter(t=>t.trim().length); + var text=t.join('
'); + + callout.rootData.text=text; + } + if(item.tagName=='Data'){ + callout.nodeId=$(item).attr('V'); + } + }); + + mind.calloutData.push(callout); + } + + //summary + if($ele.attr('Type')&&$ele.attr('Type')=='Summary'){ + var sd={ + id:$ele.attr('ID'), + nodes:'' + }; + $ele.children().each(function(i,item){ + if(item.tagName=='BoundaryData'){ + sd.nodes=$(item).find('Shapes').attr('V'); + }; + }); + summaryBoundary[$ele.attr('ID')]=sd; + } + + } + + + combineData(nodes); + + var mainlist=[]; + transferData(root,null,mainlist,true); + mind.mindData.push(mainlist); + + //summary + if(summary&&summary.length){ + summary.forEach(item=>{ + var induceData={ + induceData:{ + range:'', + id:item.id + } + }; + if(item.superids){ + if(summaryBoundary[item.superids]){ + var v = summaryBoundary[item.superids].nodes.split(';'); + induceData.induceData.nodeId=v[0]; + induceData.induceData.endNodeId=v[0]; + var mData=[]; + var da = nodes[item.id]; + if(da){ + transferData(da,null,mData); + } + induceData.mindData=mData; + mind.induceData.push(induceData); + } + } + }); + } + return mind; +}; + + +function combineData(nodes){ + for(var i in nodes){ + if(nodes[i].childrenIds){ + var cids=nodes[i].childrenIds.split(';'); + if(cids.length){ + cids.forEach(cid=>{ + if(nodes[cid]){ + nodes[i].children.push(nodes[cid]); + nodes[cid].pid=nodes[i].id; + } + }); + } + } + } +} + +function transferData(data,parentId,list,mainFlag){ + if(!parentId){ + data.layout={}; + data.layout.layoutName="minder2"; + data.layout.direct="right"; + if(mainFlag){ + data.isRoot=true; + data.main=true; + data.x=canvasWidth/2; + data.y=canvasHeight/2; + }else{ + data.layout.layoutName="minder1"; + } + } + + list.push(data); + + data.children&&data.children.forEach(c=>{ + transferData(c,data.id,list); + }); +} + + +export default importMindmaster; diff --git a/src/renderer/mind/import/importXmind.js b/src/renderer/mind/import/importXmind.js index 63f6e73..ebdac9c 100644 --- a/src/renderer/mind/import/importXmind.js +++ b/src/renderer/mind/import/importXmind.js @@ -126,7 +126,7 @@ function transferData(data,parentId,list,mainFlag){ if(data.href){ node.link=data.href; } - if(data.notes){ + if(data.notes && data.notes.plain && data.notes.plain.content){ node.remark=data.notes.plain.content.replace(/\n/g,"
").trim(); } if(data.image){ @@ -166,7 +166,7 @@ function transferData(data,parentId,list,mainFlag){ //induce data.summaries&&data.summaries.forEach(sum=>{ - var r=sum.range.substring(1,sum.range.length-1); + var r=sum.range.substring(1,sum.range.length-1); // console.log(r,'induce'); var s=r.split(',')[0]; var e=r.split(',')[1]; @@ -242,7 +242,12 @@ function transferData(data,parentId,list,mainFlag){ color:'#f06', rootData:{ text:c.title, - id:c.id + id:c.id, + paddingLeft: 6, + paddingRight: 6, + paddingBottom: 2, + paddingTop: 2, + fontSize:12 } } mind.calloutData.push(callout); diff --git a/src/renderer/mind/layout/MindLayout2.js b/src/renderer/mind/layout/MindLayout2.js index 5ccebf2..6098cb9 100644 --- a/src/renderer/mind/layout/MindLayout2.js +++ b/src/renderer/mind/layout/MindLayout2.js @@ -26,8 +26,9 @@ export default class MindLayout1 extends MindLayout { if (!this.root.isExpand()) { return; } - var lineWidth = theme.use().config['lineWidth'] || 2; - var stroke = theme.use().config['stroke']; + var config=theme.use().config; + var lineWidth =config['lineWidth'] || 1; + var stroke = config['stroke']; var rights = root.children.filter((item) => { return item.direct == 'right' @@ -60,7 +61,6 @@ export default class MindLayout1 extends MindLayout { rt.forEach((child, i) => { var childBox = child.getBox(); - var childPos = child.getPosition(); var toy = childBox.height / 2 + childPos.y; @@ -68,23 +68,44 @@ export default class MindLayout1 extends MindLayout { var p1 = [rootPos.x + rootBox.width / 2 + 6 + rtd * i, rootPos.y + rootBox.height / 2]; if (Math.abs(c) > 2) { - var p2 = [p1[0], toy - 2 * c / Math.abs(c)]; - var p3 = [p1[0] + 2, toy] + var p2 = [p1[0], toy - 5 * c / Math.abs(c)]; + var p3 = [p1[0] + 5, toy] } else { var p2 = [p1[0], toy - c / 2]; var p3 = [p1[0] + Math.abs(c) / 2, toy]; } + var p4 = [childPos.x, toy]; let _stroke = child.stroke || stroke || 'rgb(160,160,160)'; - var line = me.group.polyline(me.linePoint([p1, p2, p3, p4], lineWidth + 2)).stroke({ + var zs= me.linePoint([ + p2 + ], lineWidth)[0]; + var ze= me.linePoint([ + p3 + ], lineWidth)[0]; + + var path = `M${zs[0]} ${zs[1]},Q${zs[0]} ${ze[1]},${ze[0]} ${ze[1]}`; + var bsline = me.group.path().stroke({ + color: _stroke, + width: lineWidth+2, + linecap: 'round', + linejoin: 'round' + }); + bsline.plot(path); + bsline.fill('none'); + var line = me.group.line(me.linePoint([p1, p2], lineWidth + 2)).stroke({ + color: _stroke, + width: lineWidth + 2, + linecap: 'round', + linejoin: 'round' + }).fill('none'); + var line = me.group.line(me.linePoint([p3, p4], lineWidth + 2)).stroke({ color: _stroke, width: lineWidth + 2, linecap: 'round', linejoin: 'round' }).fill('none'); - child.line = line; - }); rb.reverse().forEach((child, i) => { @@ -96,8 +117,8 @@ export default class MindLayout1 extends MindLayout { var p1 = [rootPos.x + rootBox.width / 2 + 6 + rbd * i, rootPos.y + rootBox.height / 2]; if (Math.abs(c) > 2) { - var p2 = [p1[0], toy - 2 * c / Math.abs(c)]; - var p3 = [p1[0] + 2, toy] + var p2 = [p1[0], toy - 5 * c / Math.abs(c)]; + var p3 = [p1[0] + 5, toy] } else { var p2 = [p1[0], toy - c / 2]; var p3 = [p1[0] + Math.abs(c) / 2, toy]; @@ -105,13 +126,39 @@ export default class MindLayout1 extends MindLayout { var p4 = [childPos.x, toy]; let _stroke = child.stroke || stroke || 'rgb(160,160,160)'; - var line = me.group.polyline(me.linePoint([p1, p2, p3, p4], lineWidth + 2)).stroke({ + + var zs= me.linePoint([ + p2 + ], lineWidth)[0]; + var ze= me.linePoint([ + p3 + ], lineWidth)[0]; + + var path = `M${zs[0]} ${zs[1]},Q${zs[0]} ${ze[1]},${ze[0]} ${ze[1]}`; + var bsline = me.group.path().stroke({ + color: _stroke, + width: lineWidth+2, + linecap: 'round', + linejoin: 'round' + }); + bsline.plot(path); + bsline.fill('none'); + + + var line = me.group.line(me.linePoint([p1, p2], lineWidth + 2)).stroke({ + color: _stroke, + width: lineWidth + 2, + linecap: 'round', + linejoin: 'round' + }).fill('none'); + + var line = me.group.line(me.linePoint([p3, p4], lineWidth + 2)).stroke({ color: _stroke, width: lineWidth + 2, linecap: 'round', linejoin: 'round' }).fill('none'); - child.line = line; + }); @@ -139,8 +186,8 @@ export default class MindLayout1 extends MindLayout { var p1 = [rootPos.x + rootBox.width / 2 - 6 - ltd * i, rootPos.y + rootBox.height / 2]; if (Math.abs(c) > 2) { - var p2 = [p1[0], toy - 2 * c / Math.abs(c)]; - var p3 = [p1[0] - 2, toy] + var p2 = [p1[0], toy - 5 * c / Math.abs(c)]; + var p3 = [p1[0] - 5, toy] } else { var p2 = [p1[0], toy - c / 2]; var p3 = [p1[0] - Math.abs(c) / 2, toy]; @@ -148,13 +195,36 @@ export default class MindLayout1 extends MindLayout { var p4 = [childPos.x + childBox.width, toy]; let _stroke = child.stroke || stroke || 'rgb(160,160,160)'; - var line = me.group.polyline(me.linePoint([p1, p2, p3, p4], lineWidth + 2)).stroke({ + var zs= me.linePoint([ + p2 + ], lineWidth)[0]; + var ze= me.linePoint([ + p3 + ], lineWidth)[0]; + + var path = `M${zs[0]} ${zs[1]},Q${zs[0]} ${ze[1]},${ze[0]} ${ze[1]}`; + var bsline = me.group.path().stroke({ + color: _stroke, + width: lineWidth+2, + linecap: 'round', + linejoin: 'round' + }); + bsline.plot(path); + bsline.fill('none'); + var line = me.group.line(me.linePoint([p1, p2], lineWidth + 2)).stroke({ color: _stroke, width: lineWidth + 2, linecap: 'round', linejoin: 'round' }).fill('none'); - child.line = line; + + var line = me.group.line(me.linePoint([p3, p4], lineWidth + 2)).stroke({ + color: _stroke, + width: lineWidth + 2, + linecap: 'round', + linejoin: 'round' + }).fill('none'); + }); @@ -166,8 +236,8 @@ export default class MindLayout1 extends MindLayout { var c = toy - (rootBox.height / 2 + rootPos.y); var p1 = [rootPos.x + rootBox.width / 2 - 6 - lbd * i, rootPos.y + rootBox.height / 2]; if (Math.abs(c) > 2) { - var p2 = [p1[0], toy - 2 * c / Math.abs(c)]; - var p3 = [p1[0] - 2, toy] + var p2 = [p1[0], toy - 5 * c / Math.abs(c)]; + var p3 = [p1[0] - 5, toy] } else { var p2 = [p1[0], toy - c / 2]; var p3 = [p1[0] - Math.abs(c) / 2, toy]; @@ -175,13 +245,38 @@ export default class MindLayout1 extends MindLayout { var p4 = [childPos.x + childBox.width, toy]; let _stroke = child.stroke || stroke || 'rgb(160,160,160)'; - var line = me.group.polyline(me.linePoint([p1, p2, p3, p4], lineWidth + 2)).stroke({ + + var zs= me.linePoint([ + p2 + ], lineWidth)[0]; + var ze= me.linePoint([ + p3 + ], lineWidth)[0]; + + var path = `M${zs[0]} ${zs[1]},Q${zs[0]} ${ze[1]},${ze[0]} ${ze[1]}`; + var bsline = me.group.path().stroke({ + color: _stroke, + width: lineWidth+2, + linecap: 'round', + linejoin: 'round' + }); + bsline.plot(path); + bsline.fill('none'); + + var line = me.group.line(me.linePoint([p1, p2], lineWidth + 2)).stroke({ color: _stroke, width: lineWidth + 2, linecap: 'round', linejoin: 'round' }).fill('none'); - child.line = line; + + var line = me.group.line(me.linePoint([p3, p4], lineWidth + 2)).stroke({ + color: _stroke, + width: lineWidth + 2, + linecap: 'round', + linejoin: 'round' + }).fill('none'); + }); @@ -246,12 +341,20 @@ export default class MindLayout1 extends MindLayout { var p2 = [from.x + dis / 2, from.y]; var p5 = [to.x, to.y]; if (child.isFirst()) { - var p3 = [from.x + dis / 2, to.y + 2]; - var p4 = [from.x + dis / 2 + 2, to.y]; + var p3 = [from.x + dis / 2, to.y + 5]; + var p4 = [from.x + dis / 2 + 5, to.y]; var point = [p1, p2, p3, p4, p5]; } else { - var p4 = [from.x + dis / 2, to.y]; - var point = [p1, p2, p4, p5]; + var d=Math.abs(to.y-from.y); + if(d<3){ + var p4 = [from.x + dis / 2, to.y]; + var point = [p1, p2, p4, p5]; + }else{ + var p3 = [from.x + dis / 2, to.y + 5]; + var p4 = [from.x + dis / 2 + 5, to.y]; + var point = [p1, p2, p3, p4, p5]; + } + } } else { @@ -259,12 +362,20 @@ export default class MindLayout1 extends MindLayout { var p2 = [from.x + dis / 2, from.y]; var p5 = [to.x, to.y]; if (child.isLast()) { - var p3 = [from.x + dis / 2, to.y - 2]; - var p4 = [from.x + dis / 2 + 2, to.y]; + var p3 = [from.x + dis / 2, to.y - 5]; + var p4 = [from.x + dis / 2 + 5, to.y]; var point = [p1, p2, p3, p4, p5]; } else { - var p4 = [from.x + dis / 2, to.y]; - var point = [p1, p2, p4, p5]; + var d=Math.abs(to.y-from.y); + if(d<3){ + var p4 = [from.x + dis / 2, to.y]; + var point = [p1, p2, p4, p5]; + }else{ + var p3 = [from.x + dis / 2, to.y - 5]; + var p4 = [from.x + dis / 2 + 5, to.y]; + var point = [p1, p2, p3, p4, p5]; + } + } } @@ -275,12 +386,19 @@ export default class MindLayout1 extends MindLayout { var p2 = [from.x - dis / 2, from.y]; var p5 = [to.x, to.y]; if (child.isFirst()) { - var p3 = [from.x - dis / 2, to.y + 2]; - var p4 = [from.x - dis / 2 - 2, to.y]; + var p3 = [from.x - dis / 2, to.y + 5]; + var p4 = [from.x - dis / 2 - 5, to.y]; var point = [p1, p2, p3, p4, p5]; } else { - var p4 = [from.x - dis / 2, to.y]; - var point = [p1, p2, p4, p5]; + var d=Math.abs(to.y-from.y); + if(d<3){ + var p4 = [from.x - dis / 2, to.y]; + var point = [p1, p2, p4, p5]; + }else{ + var p3 = [from.x - dis / 2, to.y + 5]; + var p4 = [from.x - dis / 2 - 5, to.y]; + var point = [p1, p2, p3, p4, p5]; + } } @@ -289,27 +407,70 @@ export default class MindLayout1 extends MindLayout { var p2 = [from.x - dis / 2, from.y]; var p5 = [to.x, to.y]; if (child.isLast()) { - var p3 = [from.x - dis / 2, to.y - 2]; - var p4 = [from.x - dis / 2 - 2, to.y]; + var p3 = [from.x - dis / 2, to.y - 5]; + var p4 = [from.x - dis / 2 - 5, to.y]; var point = [p1, p2, p3, p4, p5]; } else { - var p4 = [from.x - dis / 2, to.y]; - var point = [p1, p2, p4, p5]; + var d=Math.abs(to.y-from.y); + if(d<3){ + var p4 = [from.x - dis / 2, to.y]; + var point = [p1, p2, p4, p5]; + }else{ + var p3 = [from.x - dis / 2, to.y - 5]; + var p4 = [from.x - dis / 2 - 5, to.y]; + var point = [p1, p2, p3, p4, p5]; + } + } } } } - - var line = me.group.polyline(me.linePoint(point, lineWidth)); - line.fill('none'); - line.stroke({ - color: _stroke, - width: lineWidth, - linecap: 'round', - linejoin: 'round' - }); - child.line = line; + if(p3){ + var line = me.group.polyline(me.linePoint([p1,p2,p3], lineWidth)); + line.fill('none'); + line.stroke({ + color: _stroke, + width: lineWidth, + linecap: 'round', + linejoin: 'round' + }); + + var zs= me.linePoint([ + p3 + ], lineWidth)[0]; + var ze= me.linePoint([ + p4 + ], lineWidth)[0]; + + var path = `M${zs[0]} ${zs[1]},Q${zs[0]} ${ze[1]},${ze[0]} ${ze[1]}`; + var bsline = me.group.path().stroke({ + color: _stroke, + width: lineWidth, + linecap: 'round', + linejoin: 'round' + }); + bsline.plot(path); + bsline.fill('none'); + var line = me.group.line(me.linePoint([p4,p5], lineWidth)); + line.fill('none'); + line.stroke({ + color: _stroke, + width: lineWidth, + linecap: 'round', + linejoin: 'round' + }); + }else{ + var line = me.group.polyline(me.linePoint(point, lineWidth)); + line.fill('none'); + line.stroke({ + color: _stroke, + width: lineWidth, + linecap: 'round', + linejoin: 'round' + }); + } + createLine(child); }); diff --git a/src/renderer/mind/list/list.js b/src/renderer/mind/list/list.js index 8cad454..717733e 100644 --- a/src/renderer/mind/list/list.js +++ b/src/renderer/mind/list/list.js @@ -166,7 +166,7 @@ class List { } if (imgData) { - var images = imgData.img || {}; + var images = imgData.img || imgData.image||{}; } @@ -177,10 +177,13 @@ class List { if (ndata.isImageNode) { if (!ndata.image) { var key = 'images/' + ndata.id + '-' + ndata.imageName; - ndata.image = images[key] || images['resources/' + ndata.imageName]; - if (!ndata.imageWidth) ndata.imageWidth = 200; - if (!ndata.imageHeight) ndata.imageHeight = 200; - + if(images[key]||images['resources/' + ndata.imageName]){ + ndata.image = images[key] || images['resources/' + ndata.imageName]; + if (!ndata.imageWidth) ndata.imageWidth = 200; + if (!ndata.imageHeight) ndata.imageHeight = 200; + }else{ + ndata.isImageNode=false; + } } } var n = new Node(ndata, parent, me); @@ -536,7 +539,11 @@ class List { } } n.children.forEach(node => { - node.data.pid = n.getId(); + if(node.isRoot||node.nodeType=='induce'||node.rootType=='induce'){ + + }else{ + node.data.pid = n.getId(); + } getData(node, d.children); }); @@ -1412,20 +1419,20 @@ class Node { // } // }; - this.textDom.onfocus = () => { + // this.textDom.onfocus = () => { - if (this.shoudRender) { - this._oldMdText = this.data.mdText; - this.textDom.innerHTML = this.data.mdText; + // if (this.shoudRender) { + // this._oldMdText = this.data.mdText; + // this.textDom.innerHTML = this.data.mdText; - me.focus(); - } + // me.focus(); + // } - }; + // }; - this.textDom.onblur = (e) => { - this.cancelEdit(); - } + // this.textDom.onblur = (e) => { + // this.cancelEdit(); + // } } diff --git a/src/renderer/mind/mind.js b/src/renderer/mind/mind.js index a30edce..6908630 100644 --- a/src/renderer/mind/mind.js +++ b/src/renderer/mind/mind.js @@ -43,6 +43,9 @@ class Mind { this.scaleNum = 1; //scale num this.useMarkDown = false; this.refreshTime = null; + + //init cache data; + // this.initWaitData=[]; //300 history num this.stack = new Stack(300); @@ -57,6 +60,10 @@ class Mind { this.stackChange(); this.initEvent(); + // this.initWaitData.unique(); + // if(this.initWaitData.length){ + + // } } dirty() { @@ -69,6 +76,17 @@ class Mind { stackChange() { var me = this; + // function throttle(fn, wait) { + // let timer = null; + // let start = Date.now(); + // return e => { + // if (Date.now() - start >= wait) { + // clearTimeout(timer) + // timer = setTimeout(fn.bind(this, e), wait); + // start = Date.now() + // } + // }; + // } function refresh(node) { var mind = node.getMind(); @@ -105,12 +123,11 @@ class Mind { if(e&&e.detail){ refresh(e.detail.node); } - }, 100) + }, 100); } else { if(e&&e.detail){ refresh(e.detail.node); } - } this.emit('needsave'); @@ -699,7 +716,7 @@ class Mind { } expandLevel(level) { - this.traverseBF(n => { + this.traverseDF(n => { if (n.getLevel() < level) { n.expand(); if (n.nodeType == 'induce') { @@ -1389,14 +1406,14 @@ class Mind { mdata.push(data); if (zip) { if (n.data.isImageNode) { - if (data.image.startsWith('http')) { - return; + if (data.image.startsWith('data:image;')) { + var imageData = data.image.replace(/^data:image\/(\w|\+)+;base64,/, ""); + zip.file(data.id + '-' + data.imageName, imageData, { + base64: true + }); + data.image = ''; } - var imageData = data.image.replace(/^data:image\/(\w|\+)+;base64,/, ""); - zip.file(data.id + '-' + data.imageName, imageData, { - base64: true - }); - data.image = ''; + } } @@ -1510,7 +1527,7 @@ class Mind { init(data, imgData) { this.initialize = true; if (imgData) { - var images = imgData.img || {}; + var images = imgData.img || imgData.image|| {}; } var me = this; this.themeName = data.theme || 'markdown'; @@ -1618,20 +1635,25 @@ class Mind { var induceData = data.induceData; induceData && induceData.forEach(data => { - + if (data.induceData.nodeId) { var n = me.getNodeById(data.induceData.nodeId); var p = n.parent; var r = data.induceData.range; - var ar = r.split(','); - var rangeNode = [] - p.children.forEach((c, i) => { - if (i >= ar[0] && i <= ar[1]) { - rangeNode.push(c); - } - }); - rangeNode.unique(); - var endNode = rangeNode[rangeNode.length - 1]; + var rangeNode = []; + if(r){ + var ar = r.split(','); + p.children.forEach((c, i) => { + if (i >= ar[0] && i <= ar[1]) { + rangeNode.push(c); + } + }); + rangeNode.unique(); + var endNode = rangeNode[rangeNode.length - 1]; + }else{ + var endNode = n; + rangeNode=[n]; + } } if (n) { @@ -1689,7 +1711,6 @@ class Mind { var n = me.getNodeById(data.nodeId); var p = n.parent; if (p) { - var r = data.range; var ar = r.split(','); var rangeNode = [] @@ -1753,25 +1774,30 @@ class Mind { relateLinkData && relateLinkData.forEach(data => { var startNode = me.getNodeById(data.startNodeId); var endNode = me.getNodeById(data.endNodeId); + if (startNode && endNode) { if (!data.gapsx) { var startBox = startNode.getBox(); var endBox = endNode.getBox(); - data.gapsx = data.box.cpx1 - startBox.x; - data.gapsy = data.box.cpy1 - startBox.y; - data.gapex = data.box.cpx2 - endBox.x; - data.gapey = data.box.cpy2 - endBox.y; + + if(data.box && data.box.cpx1){ + data.gapsx = data.box.cpx1 - startBox.x; + data.gapsy = data.box.cpy1 - startBox.y; + data.gapex = data.box.cpx2 - endBox.x; + data.gapey = data.box.cpy2 - endBox.y; + } } - var rl = new RelateLink(startNode, data); - rl.endNode = endNode; - - rl.setBox(data.box); - me.addRelateLink(rl); - rl.unactive(); - if (!data.box) { - waitRefreshRelateLink.push(rl); + if(data.gapsx){ + var rl = new RelateLink(startNode, data); + rl.endNode = endNode; + rl.setBox(data.box); + me.addRelateLink(rl); + rl.unactive(); + if (!data.box) { + waitRefreshRelateLink.push(rl); + } } } }); @@ -1783,6 +1809,10 @@ class Mind { rl.refresh(); }); + this.updateRelateLink(); + + + //setTimeout(() => { //load katex font this.initialize = false; diff --git a/src/renderer/mind/node.js b/src/renderer/mind/node.js index 2df8d16..f4b3e69 100644 --- a/src/renderer/mind/node.js +++ b/src/renderer/mind/node.js @@ -58,10 +58,10 @@ class Node { y: 0, width: 0, height: 0, - borderTopLeftRadius: 2, - borderBottomLeftRadius: 2, - borderTopRightRadius: 2, - borderBottomRightRadius: 2, + borderTopLeftRadius: 4, + borderBottomLeftRadius: 4, + borderTopRightRadius: 4, + borderBottomRightRadius: 4, z: 10, priority: '', percent: '', diff --git a/src/renderer/router/index.js b/src/renderer/router/index.js index 66ed144..7adc2ad 100644 --- a/src/renderer/router/index.js +++ b/src/renderer/router/index.js @@ -24,6 +24,11 @@ export default new Router({ path: '/profile', name: 'profile', component: require('@/components/profile').default + }, + { + path:'/signup', + name:'signup', + component:require('@/components/signup').default } ] })