Commit 25441285 authored by 孙灵跃 leon's avatar 孙灵跃 leon

feat

parent b86506d1
......@@ -5,12 +5,7 @@
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"buildLibrary": "vue-cli-service build --mode library --target lib --name simpleMindMap ../simple-mind-map/full.js --dest ../simple-mind-map/dist && esbuild ../simple-mind-map/full.js --bundle --external:buffer --format=esm --outfile=../simple-mind-map/dist/simpleMindMap.esm.js && esbuild ../simple-mind-map/full.js --bundle --minify --external:buffer --format=esm --outfile=../simple-mind-map/dist/simpleMindMap.esm.min.js",
"format": "prettier --write src/* src/*/* src/*/*/* src/*/*/*/*",
"buildDoc": "node ./scripts/buildDoc.js",
"autoBuildDoc": "node ./scripts/autoBuildDoc.js",
"createNodeImageList": "node ./scripts/createNodeImageList.js"
"lint": "vue-cli-service lint"
},
"dependencies": {
"@toast-ui/editor": "^3.1.5",
......
......@@ -9,8 +9,10 @@
<script>
// 自定义静态资源的路径
window.externalPublicPath = './'
// 接管应用
window.takeOverApp = false
if(typeof window.takeOverApp !== 'boolean'){
// 如果是本地调试的话, 就不需要接管应用
window.takeOverApp = false
}
</script>
</head>
<body>
......@@ -20,7 +22,10 @@
<div id="app"></div>
<!-- built files will be auto injected -->
<script>
const getDataFromBackend = () => {
// 如果外部没有传入思维导图的方法,则使用默认数据
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve({
......@@ -45,33 +50,37 @@
}, 200)
})
}
const setTakeOverAppMethods = (data) => {
window.takeOverAppMethods = {}
// 获取思维导图数据的函数
window.takeOverAppMethods.getMindMapData = () => {
return data.mindMapData
}
// 保存思维导图数据的函数
window.takeOverAppMethods.saveMindMapData = (data) => {
console.log(data)
window.takeOverAppMethods = window.takeOverAppMethods || {}
if(!window.takeOverAppMethods['getMindMapData']){
window.takeOverAppMethods['getMindMapData'] = ()=>{
return data.mindMapData
}
}
if(!window.takeOverAppMethods['saveManualMindMapData']){
window.takeOverAppMethods['saveManualMindMapData'] = void 0
}
if(!window.takeOverAppMethods['manualCancel']){
window.takeOverAppMethods['manualCancel'] = ()=>void 0
}
// 获取语言的函数
window.takeOverAppMethods.getLanguage = () => {
window.takeOverAppMethods['saveMindMapData'] = ()=>{
}
window.takeOverAppMethods['getLanguage'] = ()=>{
return data.lang
}
// 保存语言的函数
window.takeOverAppMethods.saveLanguage = (lang) => {
console.log(lang)
window.takeOverAppMethods['saveLanguage'] = ()=>{
}
// 获取本地配置的函数
window.takeOverAppMethods.getLocalConfig = () => {
window.takeOverAppMethods['getLocalConfig'] = ()=>{
return data.localConfig
}
// 保存本地配置的函数
window.takeOverAppMethods.saveLocalConfig = (config) => {
console.log(config)
window.takeOverAppMethods['saveLocalConfig'] = ()=>{
}
}
window.onload = async () => {
if (!window.takeOverApp) return
// 请求数据
......@@ -79,10 +88,9 @@
// 设置全局的方法
setTakeOverAppMethods(data)
// 思维导图实例创建完成事件
window.$bus.$on('app_inited', (mindMap) => {
console.log(mindMap)
})
// 可以通过window.$bus.$on()来监听应用的一些事件
// window.$bus.$on('app_inited', (mindMap) => {
// console.log('思维导图实例创建完成事件',mindMap)
// })
// 实例化页面
window.initApp()
}
......
......@@ -8,11 +8,7 @@ const SIMPLE_MIND_MAP_LOCAL_CONFIG = 'SIMPLE_MIND_MAP_LOCAL_CONFIG'
let mindMapData = null
/**
* @Author: 王林
* @Date: 2021-08-02 22:36:48
* @Desc: 克隆思维导图数据,去除激活状态
*/
const copyMindMapTreeData = (tree, root) => {
tree.data = simpleDeepClone(root.data)
// tree.data.isActive = false
......@@ -25,11 +21,7 @@ const copyMindMapTreeData = (tree, root) => {
return tree
}
/**
* @Author: 王林
* @Date: 2021-08-01 10:10:49
* @Desc: 获取缓存的思维导图数据
*/
export const getData = () => {
if (window.takeOverApp) {
mindMapData = window.takeOverAppMethods.getMindMapData()
......@@ -47,11 +39,7 @@ export const getData = () => {
}
}
/**
* @Author: 王林
* @Date: 2021-08-01 10:14:28
* @Desc: 存储思维导图数据
*/
export const storeData = data => {
try {
let originData = null
......@@ -74,11 +62,7 @@ export const storeData = data => {
}
}
/**
* @Author: 王林
* @Date: 2021-08-01 10:24:56
* @Desc: 存储思维导图配置数据
*/
export const storeConfig = config => {
try {
let originData = null
......@@ -104,12 +88,26 @@ export const storeConfig = config => {
}
}
/**
* javascript comment
* @Author: 王林
* @Date: 2022-11-05 14:36:50
* @Desc: 存储语言
*/
export const manualSaveConfig = config=>{
try {
config.data = Object.assign({}, mindMapData, config.data)
if(window.takeOverAppMethods?.saveManualMindMapData){
window.takeOverAppMethods.saveManualMindMapData(config)
}
} catch (error) {
console.log(error)
}
}
export const manualCancel= ()=>{
if(window.takeOverAppMethods?.manualCancel){
window.takeOverAppMethods.manualCancel()
}
}
export const storeLang = lang => {
if (window.takeOverApp) {
window.takeOverAppMethods.saveLanguage(lang)
......@@ -118,12 +116,7 @@ export const storeLang = lang => {
localStorage.setItem(SIMPLE_MIND_MAP_LANG, lang)
}
/**
* javascript comment
* @Author: 王林
* @Date: 2022-11-05 14:37:36
* @Desc: 获取存储的语言
*/
export const getLang = () => {
if (window.takeOverApp) {
return window.takeOverAppMethods.getLanguage() || 'zh'
......@@ -136,12 +129,7 @@ export const getLang = () => {
return 'zh'
}
/**
* javascript comment
* @Author: 王林25
* @Date: 2022-11-14 18:57:31
* @Desc: 存储本地配置
*/
export const storeLocalConfig = config => {
if (window.takeOverApp) {
return window.takeOverAppMethods.saveLocalConfig(config)
......@@ -149,12 +137,7 @@ export const storeLocalConfig = config => {
localStorage.setItem(SIMPLE_MIND_MAP_LOCAL_CONFIG, JSON.stringify(config))
}
/**
* javascript comment
* @Author: 王林25
* @Date: 2022-11-14 18:57:37
* @Desc: 获取本地配置
*/
export const getLocalConfig = () => {
if (window.takeOverApp) {
return window.takeOverAppMethods.getLocalConfig()
......
......@@ -244,7 +244,10 @@ export default {
fileContentError: 'File content error',
fileOpenFailed: 'File open failed',
defaultFileName: 'Mind map',
creatingTip: 'Creating file'
creatingTip: 'Creating file',
save: 'Save',
saveAndClose: 'Save and Close',
close:'Close'
},
edit: {
newFeatureNoticeTitle: 'New feature reminder',
......
......@@ -240,7 +240,10 @@ export default {
fileContentError: '文件内容有误',
fileOpenFailed: '文件打开失败',
defaultFileName: '思维导图',
creatingTip: '正在创建文件'
creatingTip: '正在创建文件',
save:'保存',
close:'关闭',
saveAndClose: '保存并关闭'
},
edit: {
newFeatureNoticeTitle: '新特性提醒',
......
......@@ -4,7 +4,9 @@ import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/assets/icon-font/iconfont.css'
import 'viewerjs/dist/viewer.css'
import VueViewer from 'v-viewer'
import i18n from './i18n'
......
......@@ -57,7 +57,7 @@ import ShortcutKey from './ShortcutKey'
import Contextmenu from './Contextmenu'
import RichTextToolbar from './RichTextToolbar'
import NodeNoteContentShow from './NodeNoteContentShow.vue'
import { getData, storeData, storeConfig } from '@/api'
import { getData, storeData, storeConfig, manualSaveConfig ,manualCancel} from '@/api'
import Navigator from './Navigator.vue'
import NodeImgPreview from './NodeImgPreview.vue'
import SidebarTrigger from './SidebarTrigger.vue'
......@@ -174,6 +174,8 @@ export default {
this.$bus.$on('startPainter', this.handleStartPainter)
this.$bus.$on('node_tree_render_end', this.handleHideLoading)
this.$bus.$on('showLoading', this.handleShowLoading)
this.$bus.$on('SAVE', this.handleSaveData)
this.$bus.$on('CLOSE', this.handleClose)
window.addEventListener('resize', this.handleResize)
},
beforeDestroy() {
......@@ -186,7 +188,8 @@ export default {
this.$bus.$off('createAssociativeLine', this.handleCreateLineFromActiveNode)
this.$bus.$off('startPainter', this.handleStartPainter)
this.$bus.$off('node_tree_render_end', this.handleHideLoading)
this.$bus.$off('showLoading', this.handleShowLoading)
this.$bus.$off('SAVE')
this.$bus.$off('CLOSE')
window.removeEventListener('resize', this.handleResize)
},
methods: {
......@@ -210,6 +213,20 @@ export default {
this.mindMap.resize()
},
async handleSaveData(){
const file = await this.mindMap.export('png', false);
const config = {
data: this.mindMap.getData(true),
file
}
manualSaveConfig(config)
},
handleClose(){
console.log('handleClose')
manualCancel()
},
// 显示loading
handleShowLoading() {
this.enableShowLoading = true
......@@ -361,6 +378,8 @@ export default {
// return el
// },
})
window['mindMap'] = this.mindMap;
if (this.openNodeRichText) this.addRichTextPlugin()
this.mindMap.keyCommand.addShortcut('Control+s', () => {
this.manualSave()
......
......@@ -187,6 +187,8 @@ export default {
} else {
this.$bus.$emit('export', this.exportType, true, this.fileName)
}
this.$notify.info({
title: this.$t('export.notifyTitle'),
message: this.$t('export.notifyMessage')
......
......@@ -64,26 +64,6 @@
<div class="item">
<Scale :isDark="isDark" :mindMap="mindMap"></Scale>
</div>
<div class="item">
<div
class="btn iconfont"
:class="[isDark ? 'iconmoon_line' : 'iconlieri']"
@click="toggleDark"
></div>
</div>
<div class="item">
<el-dropdown @command="handleCommand">
<div class="btn iconfont iconbangzhu"></div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="github">Github</el-dropdown-item>
<el-dropdown-item command="helpDoc">使用文档</el-dropdown-item>
<el-dropdown-item command="devDoc">开发文档</el-dropdown-item>
<el-dropdown-item command="site">官方网站</el-dropdown-item>
<el-dropdown-item command="issue">意见反馈</el-dropdown-item>
<el-dropdown-item disabled>当前:v{{ version }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
</template>
......
......@@ -24,8 +24,18 @@
</div>
</el-popover>
</div>
<div class="toolbarBtn" @click="$bus.$emit('SAVE')" >
<el-button type="primary" size="mini">{{$t('toolbar.saveAndClose')}}</el-button>
</div>
<div class="toolbarBtn" @click="$bus.$emit('CLOSE')" >
<el-button size="mini">{{$t('toolbar.close')}}</el-button>
</div>
<!-- 导出 -->
<div class="toolbarBlock">
<!-- <div class="toolbarBlock">
<div class="toolbarBtn" @click="createNewLocalFile">
<span class="icon iconfont iconxinjian"></span>
<span class="text">{{ $t('toolbar.newFile') }}</span>
......@@ -46,7 +56,7 @@
<span class="icon iconfont iconexport"></span>
<span class="text">{{ $t('toolbar.export') }}</span>
</div>
</div>
</div> -->
</div>
<NodeImage></NodeImage>
<NodeHyperlink></NodeHyperlink>
......@@ -362,7 +372,7 @@ export default {
background-color: #fff;
padding: 10px 20px;
border-radius: 6px;
box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.06);
// box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.06);
border: 1px solid rgba(0, 0, 0, 0.06);
margin-right: 20px;
flex-shrink: 0;
......
<template>
<div class="toolbarNodeBtnList" :class="[dir, { isDark: isDark }]">
<template v-for="item in list">
<div v-for="item in list" :key="item">
<div
v-if="item === 'back'"
class="toolbarBtn"
......@@ -156,7 +156,7 @@
<span class="icon iconfont icongongshi"></span>
<span class="text">{{ $t('toolbar.formula') }}</span>
</div>
</template>
</div>
</div>
</template>
......@@ -295,10 +295,6 @@ export default {
cursor: pointer;
margin-right: 20px;
&:last-of-type {
margin-right: 0;
}
&:hover {
&:not(.disabled) {
.icon {
......
......@@ -58,11 +58,11 @@ export default {
}
],
functionList: [
{
icon: 'iconjingzi',
name: '主题',
value: '内置多种主题,允许高度自定义样式,支持注册新主题。'
},
// {
// icon: 'iconjingzi',
// name: '主题',
// value: '内置多种主题,允许高度自定义样式,支持注册新主题。'
// },
{
icon: 'iconjiegou',
name: '结构',
......
......@@ -66,7 +66,6 @@ const routes = [
]
const router = new VueRouter({
mode: 'history',
routes
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment