Browse Source

UI hide debugger sheet if debugger is not enabled

pull/1133/head
ph 4 years ago
parent
commit
e4476d0a29
2 changed files with 32 additions and 7 deletions
  1. +2
    -1
      mindinsight/ui/src/components/header.vue
  2. +30
    -6
      mindinsight/ui/src/main.js

+ 2
- 1
mindinsight/ui/src/components/header.vue View File

@@ -29,7 +29,7 @@ limitations under the License.
class="el-menu-demo"
mode="horizontal">
<el-menu-item index="/summary-manage">{{$t("summaryManage.summaryList")}}</el-menu-item>
<el-menu-item index="/debugger">{{$t("debugger.debugger")}}</el-menu-item>
<el-menu-item index="/debugger" v-if="showDebugger">{{$t("debugger.debugger")}}</el-menu-item>
<el-menu-item index="/explain">{{$t("explain.explain")}}</el-menu-item>
</el-menu>
</div>
@@ -107,6 +107,7 @@ export default {
isLanguage: true,
timeReloadValue: this.$store.state.timeReloadValue,
newReloadValue: this.$store.state.timeReloadValue,
showDebugger: window.enableDebugger,
};
},
computed: {


+ 30
- 6
mindinsight/ui/src/main.js View File

@@ -25,6 +25,7 @@ import i18n from './i18n';
import $ from 'jquery';
import locale from 'element-ui/lib/locale/lang/en';
import localezh from 'element-ui/lib/locale/lang/zh-CN';
import {basePath} from '@/services/fetcher';

let language = window.localStorage.getItem('milang');
const languageList = ['zh-cn', 'en-us'];
@@ -44,6 +45,10 @@ Vue.prototype.$bus = new Vue();

// Route interception
router.beforeEach((to, from, next) => {
if (!window.enableDebugger && to.path === '/debugger') {
next('/');
return;
}
// cancel request
if (from.path !== '/') {
store.commit('clearToken');
@@ -83,12 +88,10 @@ function isBrowserSupport() {
return false;
}
}

window.onload = function(e) {
if (isBrowserSupport()) {
Vue.prototype.$warmBrowser = true;
}
// Instantiation
/**
* Instantiate App
*/
function appInstantiation() {
setTimeout(() => {
new Vue({
router,
@@ -97,4 +100,25 @@ window.onload = function(e) {
render: (h) => h(App),
}).$mount('#app');
}, 100);
}

window.enableDebugger = true;
window.onload = function(e) {
if (isBrowserSupport()) {
Vue.prototype.$warmBrowser = true;
}
$.ajax({
url: `${basePath}v1/mindinsight/ui-config`,
type: 'GET',
dataType: 'json',
success: (data) => {
if (data) {
window.enableDebugger = data.enable_debugger;
}
appInstantiation();
},
error: ()=> {
appInstantiation();
},
});
};

Loading…
Cancel
Save