Demo:修复只读模式下仍旧可以替换和编辑大纲的问题

This commit is contained in:
wanglin2 2023-11-20 15:15:38 +08:00
parent 9a7f827301
commit ad98c0f229
5 changed files with 18 additions and 13 deletions

View File

@ -119,21 +119,20 @@ export default {
version: pkg.version, version: pkg.version,
langList, langList,
lang: '', lang: '',
isReadonly: false,
openMiniMap: false openMiniMap: false
} }
}, },
computed: { computed: {
...mapState(['isDark']) ...mapState(['isDark', 'isReadonly'])
}, },
created() { created() {
this.lang = getLang() this.lang = getLang()
}, },
methods: { methods: {
...mapMutations(['setIsDark']), ...mapMutations(['setIsDark', 'setIsReadonly']),
readonlyChange() { readonlyChange() {
this.isReadonly = !this.isReadonly this.setIsReadonly(!this.isReadonly)
this.mindMap.setMode(this.isReadonly ? 'readonly' : 'edit') this.mindMap.setMode(this.isReadonly ? 'readonly' : 'edit')
}, },

View File

@ -24,7 +24,7 @@
> >
<span <span
class="nodeEdit" class="nodeEdit"
contenteditable="true" :contenteditable="!isReadonly"
:key="getKey()" :key="getKey()"
@keydown.stop="onNodeInputKeydown($event, node)" @keydown.stop="onNodeInputKeydown($event, node)"
@keyup.stop @keyup.stop
@ -69,7 +69,7 @@ export default {
} }
}, },
computed: { computed: {
...mapState(['isDark']) ...mapState(['isDark', 'isReadonly'])
}, },
created() { created() {
window.addEventListener('keydown', this.onKeyDown) window.addEventListener('keydown', this.onKeyDown)

View File

@ -32,7 +32,7 @@
> >
<span <span
class="nodeEdit" class="nodeEdit"
contenteditable="true" :contenteditable="!isReadonly"
:key="getKey()" :key="getKey()"
@blur="onBlur($event, node)" @blur="onBlur($event, node)"
@keydown.stop="onNodeInputKeydown($event, node)" @keydown.stop="onNodeInputKeydown($event, node)"
@ -76,7 +76,7 @@ export default {
} }
}, },
computed: { computed: {
...mapState(['isOutlineEdit', 'isDark']) ...mapState(['isOutlineEdit', 'isDark', 'isReadonly'])
}, },
watch: { watch: {
isOutlineEdit(val) { isOutlineEdit(val) {

View File

@ -44,10 +44,10 @@
}}</el-button> }}</el-button>
</el-input> </el-input>
<div class="btnList" v-if="showReplaceInput"> <div class="btnList" v-if="showReplaceInput">
<el-button size="small" @click="replace">{{ <el-button size="small" :disabled="isReadonly" @click="replace">{{
$t('search.replace') $t('search.replace')
}}</el-button> }}</el-button>
<el-button size="small" @click="replaceAll">{{ <el-button size="small" :disabled="isReadonly" @click="replaceAll">{{
$t('search.replaceAll') $t('search.replaceAll')
}}</el-button> }}</el-button>
</div> </div>
@ -78,7 +78,7 @@ export default {
} }
}, },
computed: { computed: {
...mapState(['isDark']) ...mapState(['isDark', 'isReadonly'])
}, },
watch: { watch: {
searchText() { searchText() {

View File

@ -21,7 +21,8 @@ const store = new Vuex.Store({
}, },
activeSidebar: '', // 当前显示的侧边栏 activeSidebar: '', // 当前显示的侧边栏
isDark: false,// 是否是暗黑模式 isDark: false,// 是否是暗黑模式
isOutlineEdit: false// 是否是大纲编辑模式 isOutlineEdit: false,// 是否是大纲编辑模式
isReadonly: false// 是否只读
}, },
mutations: { mutations: {
/** /**
@ -75,7 +76,12 @@ const store = new Vuex.Store({
// 设置大纲编辑模式 // 设置大纲编辑模式
setIsOutlineEdit(state, data) { setIsOutlineEdit(state, data) {
state.isOutlineEdit = data state.isOutlineEdit = data
} },
// 设置是否只读
setIsReadonly(state, data) {
state.isReadonly = data
},
}, },
actions: { actions: {
/** /**