Skip to content

Commit

Permalink
Feat:增加拖动画布是否触发自动保存的设置
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglin2 committed Sep 26, 2024
1 parent 6da7cf8 commit a25b0f6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
20 changes: 16 additions & 4 deletions web/src/pages/Edit/components/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ export default {
autoSaveTimer: null,
isNewFile: false,
storeConfigTimer: null,
showDragMask: false
showDragMask: false,
lastViewData: null,
clientConfig: null
}
},
computed: {
Expand Down Expand Up @@ -320,9 +322,9 @@ export default {
*/
async getData() {
let data = await window.electronAPI.getFileContent(this.$route.params.id)
const clientConfig = await window.electronAPI.getClientConfig()
const defaultTheme = clientConfig.theme || 'classic4'
const defaultLayout = clientConfig.layout || 'logicalStructure'
this.clientConfig = await window.electronAPI.getClientConfig()
const defaultTheme = this.clientConfig.theme || 'classic4'
const defaultLayout = this.clientConfig.layout || 'logicalStructure'
let storeData = null
if (data) {
this.setFileName(data.name)
Expand Down Expand Up @@ -368,6 +370,15 @@ export default {
storeData(data)
})
this.$bus.$on('view_data_change', data => {
if (
(!this.clientConfig || !this.clientConfig.viewTranslateChangeTriggerAutoSave) &&
this.lastViewData.transform.scaleX === data.transform.scaleX &&
this.lastViewData.transform.scaleY === data.transform.scaleY
) {
this.lastViewData = simpleDeepClone(data)
return
}
this.lastViewData = simpleDeepClone(data)
this.autoSave()
this.setIsUnSave(true)
clearTimeout(this.storeConfigTimer)
Expand Down Expand Up @@ -621,6 +632,7 @@ export default {
// return el
// }
})
this.lastViewData = simpleDeepClone(this.mindMap.view.getTransformData())
if (this.openNodeRichText) this.addRichTextPlugin()
if (this.isShowScrollbar) this.addScrollbarPlugin()
if (this.isUseHandDrawnLikeStyle) this.addHandDrawnLikeStylePlugin()
Expand Down
15 changes: 13 additions & 2 deletions web/src/pages/Workbenche/components/SettingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
alt=""
/>
</div>
<div class="row">
<div class="label">拖动画布触发自动保存</div>
<el-checkbox
v-model="config.viewTranslateChangeTriggerAutoSave"
@change="onChange"
></el-checkbox>
</div>
</div>
</el-dialog>
</template>
Expand Down Expand Up @@ -80,7 +87,8 @@ export default {
dialogVisible: false,
config: {
layout: '',
theme: ''
theme: '',
viewTranslateChangeTriggerAutoSave: false
},
clientConfig: null
}
Expand All @@ -105,6 +113,8 @@ export default {
this.clientConfig = await window.electronAPI.getClientConfig()
this.config.layout = this.clientConfig.layout || 'logicalStructure'
this.config.theme = this.clientConfig.theme || 'classic4'
this.config.viewTranslateChangeTriggerAutoSave =
this.clientConfig.viewTranslateChangeTriggerAutoSave || false
},
onChange() {
Expand Down Expand Up @@ -132,7 +142,8 @@ export default {
margin-bottom: 12px;
.label {
width: 100px;
width: 90px;
margin-right: 12px;
}
img {
Expand Down

0 comments on commit a25b0f6

Please sign in to comment.