{{$t('overall.placeHolder')}} IP
-{{$t('ping.filter')}}
-Ping {{$t('config.terminallog.cmd.cmd')}}
@@ -156,7 +188,7 @@ export default { tableData: [], ruleForm: { // 超时时间 - timeout: '' + timeout: 30 }, formRules: { timeout: [{ validator: positiveInteger, trigger: 'blur' }] @@ -166,6 +198,22 @@ export default { created () { this.getDataCenter() }, + mounted () { + const tiInput = document.getElementsByClassName('ti-input')[0] + tiInput.addEventListener('click', (e) => { + const event = e || window.event + if (event && event.stopPropagation) { + event.stopPropagation() + } else { + event.cancelBubble = true + } + if (event.path[0].className === 'ti-input') { + const tiInputBox = document.getElementsByClassName('ti-new-tag-input')[0] + console.log(tiInputBox) + tiInputBox.focus() + } + }) + }, methods: { // 使用防抖是因为,防止标签输入框失去焦点校验和开始任务校验重复(连续两次message提示) validateHost: bus.debounce(function () { @@ -217,6 +265,16 @@ export default { this.checkAll = checkedCount === this.dataCenter.length this.isIndeterminate = checkedCount > 0 && checkedCount < this.dataCenter.length }, + // 删除选中 + removeCheckedItem (id, e) { + const event = e || window.event + if (event && event.stopPropagation) { + event.stopPropagation() + } else { + event.cancelBubble = true + } + this.checked = this.checked.filter(dcId => dcId !== id) + }, // 开始任务 startTask () { if (!this.flag) { diff --git a/nezha-fronted/src/components/page/tool/trace.vue b/nezha-fronted/src/components/page/tool/trace.vue index 2c3c67b47..a0ac50c1a 100644 --- a/nezha-fronted/src/components/page/tool/trace.vue +++ b/nezha-fronted/src/components/page/tool/trace.vue @@ -24,14 +24,46 @@{{$t('overall.placeHolder')}}IP
-{{$t('ping.filter')}}
-Trace {{$t('config.terminallog.cmd.cmd')}}
@@ -159,7 +187,7 @@ export default { // 最大跃点数 maxHops: '', // 超时时间 - timeout: '' + timeout: 30 }, formRules: { timeout: [{ validator: positiveInteger, trigger: 'blur' }], @@ -170,6 +198,22 @@ export default { created () { this.getDataCenter() }, + mounted () { + const tiInput = document.getElementsByClassName('ti-input')[0] + tiInput.addEventListener('click', (e) => { + const event = e || window.event + if (event && event.stopPropagation) { + event.stopPropagation() + } else { + event.cancelBubble = true + } + if (event.path[0].className === 'ti-input') { + const tiInputBox = document.getElementsByClassName('ti-new-tag-input')[0] + console.log(tiInputBox) + tiInputBox.focus() + } + }) + }, methods: { // 使用防抖是因为,防止标签输入框失去焦点校验和开始任务校验重复(连续两次message提示) validateHost: bus.debounce(function () { @@ -221,6 +265,16 @@ export default { this.checkAll = checkedCount === this.dataCenter.length this.isIndeterminate = checkedCount > 0 && checkedCount < this.dataCenter.length }, + // 删除选中 + removeCheckedItem (id, e) { + const event = e || window.event + if (event && event.stopPropagation) { + event.stopPropagation() + } else { + event.cancelBubble = true + } + this.checked = this.checked.filter(dcId => dcId !== id) + }, // 开始任务 startTask () { if (!this.flag) { diff --git a/nezha-fronted/src/entrance/app/App.vue b/nezha-fronted/src/entrance/app/App.vue index 13caa42e9..9949d28d3 100644 --- a/nezha-fronted/src/entrance/app/App.vue +++ b/nezha-fronted/src/entrance/app/App.vue @@ -22,7 +22,7 @@ export default { } const Timestamp = new Date().getTime() const url = 'static/config.json?Timestamp=' + Timestamp - const result = await this.$http.get(url) + const result = await this.$http.get(url) // 获取本地的config.json 判断是否需要清空localStorage 以及设备的宽 和 axios的baseUrl this.$axios.defaults.baseURL = result.body.baseUrl const version = result.body.version const defaultWindowWidth = result.body.width || 1024 diff --git a/nezha-fronted/src/entrance/app/main.js b/nezha-fronted/src/entrance/app/main.js index dc67b7271..00653f23a 100644 --- a/nezha-fronted/src/entrance/app/main.js +++ b/nezha-fronted/src/entrance/app/main.js @@ -50,14 +50,14 @@ Vue.use(vSelectPage, { }) } }) -Vue.use(myDatePicker) -Vue.component('Pagination', Pagination) -Vue.component('searchInput', searchInput) -Vue.component('element-set', elementSet) -Vue.component('loading', loading) -Vue.component('pick-time', pickTime) +Vue.use(myDatePicker) // 对element-ui的时间组件进行二次重构 +Vue.component('Pagination', Pagination) // 公用分页组件 +Vue.component('searchInput', searchInput) // 公用搜索组件 +Vue.component('element-set', elementSet) // 公用设置表头 +Vue.component('loading', loading)// 公用loading 除特殊情况使用 正常使用自定义指令 v-my-loading +Vue.component('pick-time', pickTime)// 时间组件 包含刷新 单位 同步等 Vue.component('myDatePicker', myDatePicker) -Vue.component('nzDataList', nzDataList) +Vue.component('nzDataList', nzDataList) // 公用表格父组件 Vue.component('chartList', chartList) Vue.prototype.$axios = axios @@ -65,11 +65,11 @@ Vue.prototype.$post = post Vue.prototype.$get = get Vue.prototype.$put = put Vue.prototype.$delete = del -Vue.prototype.$loadsh = loadsh +Vue.prototype.$loadsh = loadsh // JavaScript 实用工具库 https://www.lodashjs.com/ Vue.prototype.$CONSTANTS = constants Vue.prototype.$TOOLS = tools Vue.prototype.$bottomBoxWindow = bottomBoxWindow // 底部上滑框控制 -Vue.prototype.$stringTimeParseToUnix = stringTimeParseToUnix +Vue.prototype.$stringTimeParseToUnix = stringTimeParseToUnix // 处理string类型的时间为时间戳 单位s Vue.prototype.$unixTimeParseToString = unixTimeParseToString Vue.prototype.$chartResizeTool = chartResizeTool Vue.prototype.$tableSet = tableSet @@ -101,13 +101,13 @@ Vue.mixin({ } }, computed: { - timeFormatMain () { + timeFormatMain () { // 所有组件添加默认时间格式 return this.$store.getters.getTimeFormatMain }, - getMenuList () { + getMenuList () { // 所有的菜单权限 return this.$store.state.user.menuList }, - getButtonList () { + getButtonList () { // 所有的按钮权限 return this.$store.state.buttonList }, $routePath () { @@ -115,7 +115,7 @@ Vue.mixin({ } }, methods: { - hasButton (code) { + hasButton (code) { // 同v-has 主要判断button的权限 return hasButton(this.$store.getters.buttonList, code) }, ...mainMixin.methods diff --git a/nezha-fronted/src/libs/bus.js b/nezha-fronted/src/libs/bus.js index 64ace019b..b2101691a 100644 --- a/nezha-fronted/src/libs/bus.js +++ b/nezha-fronted/src/libs/bus.js @@ -248,6 +248,32 @@ export default new Vue({ }, delay) } }, + /** + * @desc 防抖函数 + * @param {需要防抖的函数} func + * @param {延迟时间} wait + * @param {是否立即执行} immediate + */ + debounceFn (func, wait, immediate) { + let timeout + return function (...args) { + const context = this + if (timeout) clearTimeout(timeout) + + if (immediate) { + const callNow = !timeout + timeout = setTimeout(function () { + timeout = null + }, wait) + if (callNow) func.apply(context, args) + } else { + timeout = setTimeout(function () { + func.apply(context, args) + }, wait) + } + } + }, + UTCTimeToConfigTimezone (utcTime) { let offset = localStorage.getItem('nz-sys-timezone') offset = moment.tz(offset).format('Z')