feat(API): 接口测试新旧版本切换功能

This commit is contained in:
wenyann 2020-12-09 16:48:57 +08:00
parent 6ce41bdbde
commit 092a79c1f1
6 changed files with 65 additions and 27 deletions

View File

@ -4,7 +4,8 @@
<el-col :span="14">
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router :default-active='$route.path'>
<el-submenu :class="{'deactivation':!isProjectActivation}" v-permission="['test_manager','test_user','test_viewer']" index="3">
<el-submenu :class="{'deactivation':!isProjectActivation}"
v-permission="['test_manager','test_user','test_viewer']" index="3">
<template v-slot:title>{{ $t('commons.project') }}</template>
<search-list ref="projectRecent" :options="projectRecent"/>
<el-divider class="menu-divider"/>
@ -19,19 +20,20 @@
{{ $t("i18n.home") }}
</el-menu-item>
<el-menu-item :index="'/api/definition'">
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/definition'">
{{ $t("i18n.definition") }}
</el-menu-item>
<el-menu-item :index="'/api/automation'">
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/automation'">
{{ $t("i18n.automation") }}
</el-menu-item>
<el-menu-item :index="'/api/automation/report'">
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/automation/report'">
{{ $t("i18n.report") }}
</el-menu-item>
<el-submenu v-permission="['test_manager','test_user','test_viewer']" index="4">
<el-submenu v-show="$store.state.switch.value=='old'"
v-permission="['test_manager','test_user','test_viewer']" index="4">
<template v-slot:title>{{ $t('commons.test') }}</template>
<ms-recent-list ref="testRecent" :options="testRecent"/>
<el-divider class="menu-divider"/>
@ -41,7 +43,8 @@
:title="$t('load_test.create')"/>
</el-submenu>
<el-submenu v-permission="['test_manager','test_user','test_viewer']" index="5">
<el-submenu v-show="$store.state.switch.value=='old'"
v-permission="['test_manager','test_user','test_viewer']" index="5">
<template v-slot:title>{{ $t('commons.report') }}</template>
<ms-recent-list ref="reportRecent" :options="reportRecent"/>
<el-divider class="menu-divider"/>
@ -49,7 +52,8 @@
</el-submenu>
<el-menu-item v-permission="['test_manager','test_user','test_viewer']" :index="'/api/monitor/view'">
<el-menu-item v-show="$store.state.switch.value=='new'"
v-permission="['test_manager','test_user','test_viewer']" :index="'/api/monitor/view'">
{{ $t('commons.monitor') }}
</el-menu-item>
</el-menu>
@ -112,10 +116,11 @@ export default {
apiTestProjectPath: '',
}
},
watch: {
'$route'(to) {
this.init();
}
},
},
methods: {
registerEvents() {

View File

@ -8,6 +8,12 @@
<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')">
{{ $t('commons.cut_back_old_version') }}
</el-dropdown-item>
<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>
</el-dropdown-menu>
</template>
@ -24,6 +30,11 @@
export default {
name: "MsUser",
components: {AboutUs},
data() {
return {
isReadOnly: true
}
},
computed: {
currentUser: () => {
return getCurrentUser();
@ -61,6 +72,10 @@
default:
break;
}
},
changeBar(item) {
this.isReadOnly = !this.isReadOnly
this.$store.commit('setValue', item);
}
}
}

View File

@ -28,9 +28,21 @@ const API = {
}
}
const Switch = {
state: {
value: "new"
},
mutations: {
setValue(state, value) {
state.value = value;
}
}
}
export default new Vuex.Store({
modules: {
api: API,
common: Common
common: Common,
switch: Switch,
}
})

View File

@ -1,5 +1,7 @@
export default {
commons: {
cut_back_old_version: 'Cut back to old version',
cut_back_new_version: 'Switch back to new version',
comment: 'comment',
examples: 'examples',
help_documentation: 'Help documentation',

View File

@ -1,5 +1,7 @@
export default {
commons: {
cut_back_old_version: '切回旧版',
cut_back_new_version: '切回新版',
comment: '评论',
examples: '示例',
help_documentation: '帮助文档',
@ -278,7 +280,7 @@ export default {
verified: '验证通过'
}
},
project: {
edit: {
recent: '最近的项目',
create: '创建项目',
edit: '编辑项目',

View File

@ -1,5 +1,7 @@
export default {
commons: {
cut_back_old_version: '切回舊版',
cut_back_new_version: '切回新版',
comment: '評論',
examples: '示例',
help_documentation: '幫助文檔',