fix(API): 刷新恢复默认

This commit is contained in:
wenyann 2020-12-10 14:54:43 +08:00
parent 0660600aab
commit 0a88b7a481
4 changed files with 25 additions and 5 deletions

View File

@ -46,6 +46,14 @@ export default {
logoId: '_blank',
}
},
created() {
if (localStorage.getItem("store")) {
this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(localStorage.getItem("store"))))
}
window.addEventListener("beforeunload", () => {
localStorage.setItem("store", JSON.stringify(this.$store.state))
})
},
beforeCreate() {
this.$get("/isLogin").then(response => {
if (response.data.success) {

View File

@ -52,7 +52,7 @@
</el-submenu>
<el-menu-item v-show="$store.state.switch.value=='new'"
<el-menu-item v-show="$store.state.switch.value=='old'"
v-permission="['test_manager','test_user','test_viewer']" :index="'/api/monitor/view'">
{{ $t('commons.monitor') }}
</el-menu-item>
@ -116,7 +116,6 @@ export default {
apiTestProjectPath: '',
}
},
watch: {
'$route'(to) {
this.init();

View File

@ -8,10 +8,10 @@
<el-dropdown-item command="personal">{{ $t('commons.personal_information') }}</el-dropdown-item>
<el-dropdown-item command="about">{{ $t('commons.about_us') }} <i class="el-icon-info"/></el-dropdown-item>
<el-dropdown-item command="help">{{ $t('commons.help_documentation') }}</el-dropdown-item>
<el-dropdown-item command="old" :disabled=!isReadOnly @click.native="changeBar('old')">
<el-dropdown-item command="old" :disabled=isReadOnly @click.native="changeBar('old')">
{{ $t('commons.cut_back_old_version') }}
</el-dropdown-item>
<el-dropdown-item command="new" :disabled=isReadOnly @click.native="changeBar('new')">
<el-dropdown-item command="new" :disabled=!isReadOnly @click.native="changeBar('new')">
{{ $t('commons.cut_back_new_version') }}
</el-dropdown-item>
<el-dropdown-item command="logout">{{ $t('commons.exit_system') }}</el-dropdown-item>
@ -32,7 +32,7 @@
components: {AboutUs},
data() {
return {
isReadOnly: true
isReadOnly: this.$store.state.isReadOnly.flag
}
},
computed: {
@ -75,6 +75,7 @@
},
changeBar(item) {
this.isReadOnly = !this.isReadOnly
this.$store.commit('setFlag', this.isReadOnly);
this.$store.commit('setValue', item);
}
}

View File

@ -39,10 +39,22 @@ const Switch = {
}
}
const IsReadOnly = {
state: {
flag: true
},
mutations: {
setFlag(state, value) {
state.flag = value;
}
}
}
export default new Vuex.Store({
modules: {
api: API,
common: Common,
switch: Switch,
isReadOnly: IsReadOnly,
}
})