diff --git a/frontend/src/api/system/engine.js b/frontend/src/api/system/engine.js index a0dd8c9a4d..03d70b09e4 100644 --- a/frontend/src/api/system/engine.js +++ b/frontend/src/api/system/engine.js @@ -1,5 +1,5 @@ import request from '@/utils/request' -import {validateDs} from "@/api/system/datasource"; +import { validateDs } from '@/api/system/datasource' export function engineMode() { return request({ diff --git a/frontend/src/api/system/kettle.js b/frontend/src/api/system/kettle.js index 213ef62de7..e07517b0d3 100644 --- a/frontend/src/api/system/kettle.js +++ b/frontend/src/api/system/kettle.js @@ -1,7 +1,5 @@ import request from '@/utils/request' -import {validateDs} from "@/api/system/datasource"; - - +import { validateDs } from '@/api/system/datasource' export function validate(data) { return request({ @@ -37,8 +35,6 @@ export function deleteKettle(id) { }) } - - export function pageList(url, data) { return request({ url: url, diff --git a/frontend/src/components/canvas/components/Editor/StreamMediaLinks.vue b/frontend/src/components/canvas/components/Editor/StreamMediaLinks.vue index 4bc2e0f46f..82eb3526f8 100644 --- a/frontend/src/components/canvas/components/Editor/StreamMediaLinks.vue +++ b/frontend/src/components/canvas/components/Editor/StreamMediaLinks.vue @@ -166,7 +166,7 @@ export default { border-radius: 3px; } - > > > .el-popover { + >>> .el-popover { height: 200px; overflow: auto; } diff --git a/frontend/src/components/widget/DeWidget/customInput.js b/frontend/src/components/widget/DeWidget/customInput.js index 62198dafbb..e6d8ccf852 100644 --- a/frontend/src/components/widget/DeWidget/customInput.js +++ b/frontend/src/components/widget/DeWidget/customInput.js @@ -2,57 +2,57 @@ import { attrsMap, styleAttrs } from '@/components/widget/DeWidget/serviceNameFn.js' export default { - data() { - return { - attrsMap, - styleAttrs, - // 过滤组件名css变量映射 - refComNameMap: { - 'de-date': ['--BgDateColor', '--DateColor', '--BrDateColor'], - 'de-select': ['--BgSelectColor', '--SelectColor', '--BrSelectColor'], - 'de-select-tree': ['--BgSelectTreeColor', '--SelectTreeColor', '--BrSelectTreeColor'], - "de-input-search": ['--BgSearchColor', '--SearchColor', '--BrSearchColor'], - "de-number-range": ['--BgRangeColor', '--RangeColor', '--BrRangeColor'] - } - } - }, - watch: { - cssArr: { - handler() { - if (['de-select', 'de-select-tree'].includes(this.element.component)) { - if (!this.element.options.attrs.multiple) { - return - } - this.handleElTagStyle() - }; - }, - deep: true - }, - }, - computed: { - cssArr() { - const { brColor, wordColor, innerBgColor } = this.element.style; - return { brColor, wordColor, innerBgColor } - } - }, - mounted() { - this.handleCoustomStyle() - }, - methods: { - typeTransform() { - let refNode = this.refComNameMap[this.element.component]; - if (!refNode) return []; - return refNode - }, - handleCoustomStyle() { - // 判断组件是否是在仪表板内部 否则css样式取默认值 - const isPanelDe = this.$parent.handlerInputStyle; - const { brColor, wordColor, innerBgColor } = this.element.style; - const newValue = { brColor, wordColor, innerBgColor }; - const cssVar = this.typeTransform(); - this.styleAttrs.forEach((ele, index) => { - document.documentElement.style.setProperty(cssVar[index], !isPanelDe ? '' : newValue[ele]) - }) - }, + data() { + return { + attrsMap, + styleAttrs, + // 过滤组件名css变量映射 + refComNameMap: { + 'de-date': ['--BgDateColor', '--DateColor', '--BrDateColor'], + 'de-select': ['--BgSelectColor', '--SelectColor', '--BrSelectColor'], + 'de-select-tree': ['--BgSelectTreeColor', '--SelectTreeColor', '--BrSelectTreeColor'], + 'de-input-search': ['--BgSearchColor', '--SearchColor', '--BrSearchColor'], + 'de-number-range': ['--BgRangeColor', '--RangeColor', '--BrRangeColor'] + } } -} \ No newline at end of file + }, + watch: { + cssArr: { + handler() { + if (['de-select', 'de-select-tree'].includes(this.element.component)) { + if (!this.element.options.attrs.multiple) { + return + } + this.handleElTagStyle() + } + }, + deep: true + }, + }, + computed: { + cssArr() { + const { brColor, wordColor, innerBgColor } = this.element.style + return { brColor, wordColor, innerBgColor } + } + }, + mounted() { + this.handleCoustomStyle() + }, + methods: { + typeTransform() { + const refNode = this.refComNameMap[this.element.component] + if (!refNode) return [] + return refNode + }, + handleCoustomStyle() { + // 判断组件是否是在仪表板内部 否则css样式取默认值 + const isPanelDe = this.$parent.handlerInputStyle + const { brColor, wordColor, innerBgColor } = this.element.style + const newValue = { brColor, wordColor, innerBgColor } + const cssVar = this.typeTransform() + this.styleAttrs.forEach((ele, index) => { + document.documentElement.style.setProperty(cssVar[index], !isPanelDe ? '' : newValue[ele]) + }) + }, + } +} diff --git a/frontend/src/components/widget/DeWidget/inputStyleMixin.js b/frontend/src/components/widget/DeWidget/inputStyleMixin.js index d7bb962a61..cbcf72c892 100644 --- a/frontend/src/components/widget/DeWidget/inputStyleMixin.js +++ b/frontend/src/components/widget/DeWidget/inputStyleMixin.js @@ -1,90 +1,90 @@ // 通过控制 js 控制过滤组件输入框样式 如需额外处理 声明组件serviceName同名函数处理 import { timeDateRangeWidget, textInputWidget, attrsMap, styleAttrs } from '@/components/widget/DeWidget/serviceNameFn.js' export default { - data() { - return { - attrsMap, - styleAttrs, - // 过滤组件名ref映射 - refComNameMap: { - 'de-date': 'dateRef', - 'de-select-grid': 'de-select-grid', - 'de-select': 'deSelect', - 'de-select-tree': 'deSelectTree', - "de-input-search": "de-input-search", - "de-number-range": ['de-number-range-min', 'de-number-range-max'] - } - } - }, - watch: { - cssArr: { - handler(newValue) { - if (!this.isFilterComponent) return; - this.typeTransform().forEach(ele => { - this.handlerInputStyle(ele, newValue) - }) - }, - deep: true - }, - multiple: { - handler() { - if (!['de-select-tree', 'de-select'].includes(this.element.component)) return; - const time = setTimeout(() => { - clearTimeout(time) - this.typeTransform().forEach(ele => { - this.handlerInputStyle(ele, this.cssArr) - }) - }, 100) - }, - deep: true - } - }, - computed: { - cssArr() { - const { brColor, wordColor, innerBgColor } = this.element.style; - return { brColor, wordColor, innerBgColor } - }, - multiple() { - const { multiple = false } = this.element.options.attrs - return multiple; - } - }, - mounted() { - if (!this.isFilterComponent) return; - this.typeTransform().forEach(item => { - const nodeCache = this.$refs.deOutWidget.$refs[item].$el.querySelector('.el-input__inner') || this.$refs.deOutWidget.$refs[item].$el - this.styleAttrs.forEach(ele => { - nodeCache.style[this.attrsMap[ele]] = this.element.style[ele]; - this[this.element.serviceName] && this[this.element.serviceName](this.selectRange(item), ele, this.element.style[ele]) - }) - }) - }, - methods: { - handlerInputStyle(type, newValue) { - let nodeCache = ''; - this.styleAttrs.forEach(ele => { - if (!nodeCache) { - nodeCache = this.$refs.deOutWidget.$refs[type].$el.querySelector('.el-input__inner') || this.$refs.deOutWidget.$refs[type].$el - } - nodeCache.style[this.attrsMap[ele]] = newValue[ele]; - this[this.element.serviceName] && this[this.element.serviceName](this.selectRange(type), ele, newValue[ele]) - }) - }, - selectRange(item) { - if (this.element.component === 'de-select-grid') { - return this.$refs.deOutWidget.$el; - } - return this.$refs.deOutWidget.$refs[item].$el; - }, - timeDateRangeWidget: timeDateRangeWidget, - textInputWidget: textInputWidget, - typeTransform() { - let refNode = this.refComNameMap[this.element.component]; - if (!refNode) return []; - if (!Array.isArray(refNode)) { - refNode = [refNode] - } - return refNode - } + data() { + return { + attrsMap, + styleAttrs, + // 过滤组件名ref映射 + refComNameMap: { + 'de-date': 'dateRef', + 'de-select-grid': 'de-select-grid', + 'de-select': 'deSelect', + 'de-select-tree': 'deSelectTree', + 'de-input-search': 'de-input-search', + 'de-number-range': ['de-number-range-min', 'de-number-range-max'] + } } -} \ No newline at end of file + }, + watch: { + cssArr: { + handler(newValue) { + if (!this.isFilterComponent) return + this.typeTransform().forEach(ele => { + this.handlerInputStyle(ele, newValue) + }) + }, + deep: true + }, + multiple: { + handler() { + if (!['de-select-tree', 'de-select'].includes(this.element.component)) return + const time = setTimeout(() => { + clearTimeout(time) + this.typeTransform().forEach(ele => { + this.handlerInputStyle(ele, this.cssArr) + }) + }, 100) + }, + deep: true + } + }, + computed: { + cssArr() { + const { brColor, wordColor, innerBgColor } = this.element.style + return { brColor, wordColor, innerBgColor } + }, + multiple() { + const { multiple = false } = this.element.options.attrs + return multiple + } + }, + mounted() { + if (!this.isFilterComponent) return + this.typeTransform().forEach(item => { + const nodeCache = this.$refs.deOutWidget.$refs[item].$el.querySelector('.el-input__inner') || this.$refs.deOutWidget.$refs[item].$el + this.styleAttrs.forEach(ele => { + nodeCache.style[this.attrsMap[ele]] = this.element.style[ele] + this[this.element.serviceName] && this[this.element.serviceName](this.selectRange(item), ele, this.element.style[ele]) + }) + }) + }, + methods: { + handlerInputStyle(type, newValue) { + let nodeCache = '' + this.styleAttrs.forEach(ele => { + if (!nodeCache) { + nodeCache = this.$refs.deOutWidget.$refs[type].$el.querySelector('.el-input__inner') || this.$refs.deOutWidget.$refs[type].$el + } + nodeCache.style[this.attrsMap[ele]] = newValue[ele] + this[this.element.serviceName] && this[this.element.serviceName](this.selectRange(type), ele, newValue[ele]) + }) + }, + selectRange(item) { + if (this.element.component === 'de-select-grid') { + return this.$refs.deOutWidget.$el + } + return this.$refs.deOutWidget.$refs[item].$el + }, + timeDateRangeWidget: timeDateRangeWidget, + textInputWidget: textInputWidget, + typeTransform() { + let refNode = this.refComNameMap[this.element.component] + if (!refNode) return [] + if (!Array.isArray(refNode)) { + refNode = [refNode] + } + return refNode + } + } +} diff --git a/frontend/src/components/widget/DeWidget/serviceNameFn.js b/frontend/src/components/widget/DeWidget/serviceNameFn.js index 61444f0000..15de69ee3b 100644 --- a/frontend/src/components/widget/DeWidget/serviceNameFn.js +++ b/frontend/src/components/widget/DeWidget/serviceNameFn.js @@ -1,92 +1,91 @@ const attrsMap = { brColor: 'borderColor', wordColor: 'color', innerBgColor: 'backgroundColor' } const styleAttrs = ['innerBgColor', 'wordColor', 'brColor'] -function timeDateRangeWidget (nodeCache, name, value) { - const classList = ['.el-range-input', '.el-range-separator'] - classList.forEach(ele => { - let nodeList = nodeCache.querySelectorAll(ele); - if (!nodeList.length) return; - nodeList.forEach(ele => { - ele.style[attrsMap[name]] = value; - }) +function timeDateRangeWidget(nodeCache, name, value) { + const classList = ['.el-range-input', '.el-range-separator'] + classList.forEach(ele => { + const nodeList = nodeCache.querySelectorAll(ele) + if (!nodeList.length) return + nodeList.forEach(ele => { + ele.style[attrsMap[name]] = value }) + }) } -function textInputWidget (nodeCache, name, value) { - let groupAppend = nodeCache.querySelector('.el-input-group__append'); - groupAppend.style[attrsMap[name]] = value; - if (name === 'brColor') { - groupAppend.style.borderLeft = 'none' - } +function textInputWidget(nodeCache, name, value) { + const groupAppend = nodeCache.querySelector('.el-input-group__append') + groupAppend.style[attrsMap[name]] = value + if (name === 'brColor') { + groupAppend.style.borderLeft = 'none' + } } -function textSelectGridWidget (nodeCache, name, value) { - if (name === 'innerBgColor') { - nodeCache.querySelector('.list').style.backgroundColor = value; +function textSelectGridWidget(nodeCache, name, value) { + if (name === 'innerBgColor') { + nodeCache.querySelector('.list').style.backgroundColor = value + } + if (name === 'wordColor') { + const elRadio = nodeCache.querySelectorAll('.el-radio') + const elCheckbox = nodeCache.querySelectorAll('.el-checkbox') + if (elRadio.length) { + elRadio.forEach(ele => { + ele.style.color = value + }) } - if (name === 'wordColor') { - let elRadio = nodeCache.querySelectorAll('.el-radio') - let elCheckbox = nodeCache.querySelectorAll('.el-checkbox') - if (elRadio.length) { - elRadio.forEach(ele => { - ele.style.color = value; - }); - } - if (elCheckbox.length) { - elCheckbox.forEach(ele => { - ele.style.color = value; - }); - } + if (elCheckbox.length) { + elCheckbox.forEach(ele => { + ele.style.color = value + }) } + } } function textSelectTreeWidget(nodeCache, style) { - textSelectWidget(nodeCache, style) + textSelectWidget(nodeCache, style) } function textSelectWidget(nodeCache, style) { - let elTag = nodeCache.querySelectorAll('.el-tag.el-tag--info') - if (elTag.length) { - elTag.forEach(item => { - item.style.flexWrap = 'wrap' - item.style.padding = '0' - const textNode = item.querySelector('.el-select__tags-text'); - const closeNode = item.querySelector('.el-tag__close'); - textNode.style.width = '100%'; - item.style.position = 'relative'; - textNode.style.padding = '0 20px 0 8px'; - textNode.style.borderRadius = '3px'; - if (closeNode) { - closeNode.style.position = 'absolute'; - closeNode.style.top = '60%'; - closeNode.style.transform = 'translateY(-50%)'; - closeNode.style.right = '2px'; - } - styleAttrs.forEach((ele) => { - if (ele !== 'brColor' && closeNode) { - closeNode.style[attrsMap[ele]] = style[ele]; - } else { - item.style[attrsMap[ele]] = style[ele]; - } - textNode.style[attrsMap[ele]] = style[ele]; - }) - - }); - } + const elTag = nodeCache.querySelectorAll('.el-tag.el-tag--info') + if (elTag.length) { + elTag.forEach(item => { + item.style.flexWrap = 'wrap' + item.style.padding = '0' + const textNode = item.querySelector('.el-select__tags-text') + const closeNode = item.querySelector('.el-tag__close') + textNode.style.width = '100%' + item.style.position = 'relative' + textNode.style.padding = '0 20px 0 8px' + textNode.style.borderRadius = '3px' + if (closeNode) { + closeNode.style.position = 'absolute' + closeNode.style.top = '60%' + closeNode.style.transform = 'translateY(-50%)' + closeNode.style.right = '2px' + } + styleAttrs.forEach((ele) => { + if (ele !== 'brColor' && closeNode) { + closeNode.style[attrsMap[ele]] = style[ele] + } else { + item.style[attrsMap[ele]] = style[ele] + } + textNode.style[attrsMap[ele]] = style[ele] + }) + }) + } } -function handlerInputStyle (node, style) { - if (!node) return; - styleAttrs.forEach(ele => { - node.style[attrsMap[ele]] = style[ele]; - }) +function handlerInputStyle(node, style) { + if (!node) return + styleAttrs.forEach(ele => { + node.style[attrsMap[ele]] = style[ele] + }) } export { - attrsMap, - styleAttrs, - timeDateRangeWidget, - textInputWidget, - textSelectGridWidget, - textSelectTreeWidget, - textSelectWidget, - handlerInputStyle, -} \ No newline at end of file + attrsMap, + styleAttrs, + timeDateRangeWidget, + textInputWidget, + textSelectGridWidget, + textSelectTreeWidget, + textSelectWidget, + handlerInputStyle, +} diff --git a/frontend/src/directive/index.js b/frontend/src/directive/index.js index e44e82bfae..ebe3d87c5d 100644 --- a/frontend/src/directive/index.js +++ b/frontend/src/directive/index.js @@ -64,42 +64,41 @@ export const bottom2TopDrag = { } } -const closePress = { - inserted: function (el) { - el.querySelector('.el-drawer__close-btn').onmousedown = function (e) { - e.currentTarget.style.background = '#d2d3d4'; +const closePress = { + inserted: function(el) { + el.querySelector('.el-drawer__close-btn').onmousedown = function(e) { + e.currentTarget.style.background = '#d2d3d4' } - el.querySelector('.el-drawer__close-btn').onmouseup = function (e) { - e.currentTarget.style.background = 'none'; + el.querySelector('.el-drawer__close-btn').onmouseup = function(e) { + e.currentTarget.style.background = 'none' } } } -const btnPress = { - update: function (el, binding) { - el.onmousedown = function (e) { - e.currentTarget.style.setProperty('background', binding.value || '#EFF0F1', 'important'); +const btnPress = { + update: function(el, binding) { + el.onmousedown = function(e) { + e.currentTarget.style.setProperty('background', binding.value || '#EFF0F1', 'important') } - el.onmouseup = function (e) { - e.currentTarget.style.background = 'none'; + el.onmouseup = function(e) { + e.currentTarget.style.background = 'none' } }, } const customStyle = { - inserted: function (el, binding) { - const label = el.querySelector('.el-checkbox__label'); + inserted: function(el, binding) { + const label = el.querySelector('.el-checkbox__label') if (label) { - if (label.getAttribute("data-color") === binding.value.wordColor) { + if (label.getAttribute('data-color') === binding.value.wordColor) { return - }; - label.style.setProperty('color', binding.value.wordColor, 'important'); - label.setAttribute("data-color", binding.value.wordColor); + } + label.style.setProperty('color', binding.value.wordColor, 'important') + label.setAttribute('data-color', binding.value.wordColor) } }, } - export default { install(Vue) { // Vue.directive('data-permission', dataPermission) diff --git a/frontend/src/styles/deicon/iconfont.js b/frontend/src/styles/deicon/iconfont.js index 1c9d5cb024..4565258bc4 100644 --- a/frontend/src/styles/deicon/iconfont.js +++ b/frontend/src/styles/deicon/iconfont.js @@ -1 +1 @@ -!function(l){var c,a,h,i,v,t='',o=(o=document.getElementsByTagName("script"))[o.length-1].getAttribute("data-injectcss"),z=function(l,c){c.parentNode.insertBefore(l,c)};if(o&&!l.__iconfont__svg__cssinject__){l.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(l){console&&console.log(l)}}function m(){v||(v=!0,h())}function p(){try{i.documentElement.doScroll("left")}catch(l){return void setTimeout(p,50)}m()}c=function(){var l,c=document.createElement("div");c.innerHTML=t,t=null,(c=c.getElementsByTagName("svg")[0])&&(c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.width=0,c.style.height=0,c.style.overflow="hidden",c=c,(l=document.body).firstChild?z(c,l.firstChild):l.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(c,0):(a=function(){document.removeEventListener("DOMContentLoaded",a,!1),c()},document.addEventListener("DOMContentLoaded",a,!1)):document.attachEvent&&(h=c,i=l.document,v=!1,p(),i.onreadystatechange=function(){"complete"==i.readyState&&(i.onreadystatechange=null,m())})}(window); \ No newline at end of file +!(function(l) { var c; var a; var h; var i; var v; var t = ''; var o = (o = document.getElementsByTagName('script'))[o.length - 1].getAttribute('data-injectcss'); var z = function(l, c) { c.parentNode.insertBefore(l, c) }; if (o && !l.__iconfont__svg__cssinject__) { l.__iconfont__svg__cssinject__ = !0; try { document.write('') } catch (l) { console && console.log(l) } } function m() { v || (v = !0, h()) } function p() { try { i.documentElement.doScroll('left') } catch (l) { return void setTimeout(p, 50) }m() }c = function() { var l; var c = document.createElement('div'); c.innerHTML = t, t = null, (c = c.getElementsByTagName('svg')[0]) && (c.setAttribute('aria-hidden', 'true'), c.style.position = 'absolute', c.style.width = 0, c.style.height = 0, c.style.overflow = 'hidden', c = c, (l = document.body).firstChild ? z(c, l.firstChild) : l.appendChild(c)) }, document.addEventListener ? ~['complete', 'loaded', 'interactive'].indexOf(document.readyState) ? setTimeout(c, 0) : (a = function() { document.removeEventListener('DOMContentLoaded', a, !1), c() }, document.addEventListener('DOMContentLoaded', a, !1)) : document.attachEvent && (h = c, i = l.document, v = !1, p(), i.onreadystatechange = function() { i.readyState == 'complete' && (i.onreadystatechange = null, m()) }) }(window)) diff --git a/frontend/src/views/chart/chart/scatter/scatter.js b/frontend/src/views/chart/chart/scatter/scatter.js index 05dd41ba46..c77e0a08dc 100644 --- a/frontend/src/views/chart/chart/scatter/scatter.js +++ b/frontend/src/views/chart/chart/scatter/scatter.js @@ -1,6 +1,6 @@ import { hexColorToRGBA } from '@/views/chart/chart/util' import { componentStyle, seniorCfg } from '../common/common' -import {BASE_ECHARTS_SELECT, DEFAULT_TOOLTIP} from '@/views/chart/chart/chart' +import { BASE_ECHARTS_SELECT, DEFAULT_TOOLTIP } from '@/views/chart/chart/chart' let bubbleArray = [] let terminalType = 'pc' diff --git a/frontend/src/views/chart/components/senior/Threshold.vue b/frontend/src/views/chart/components/senior/Threshold.vue index 4f57464334..267906fb85 100644 --- a/frontend/src/views/chart/components/senior/Threshold.vue +++ b/frontend/src/views/chart/components/senior/Threshold.vue @@ -400,7 +400,7 @@ span{ .field-style{ display: flex; align-items: center; - justify-content: start; + justify-content: flex-start; } .field-text{ diff --git a/frontend/src/views/system/datasource/ApiTestModel.js b/frontend/src/views/system/datasource/ApiTestModel.js index 690f4263aa..dd5c98f2d5 100644 --- a/frontend/src/views/system/datasource/ApiTestModel.js +++ b/frontend/src/views/system/datasource/ApiTestModel.js @@ -1,14 +1,13 @@ export class BaseConfig { - set(options, notUndefined) { options = this.initOptions(options) - for (let name in options) { + for (const name in options) { if (options.hasOwnProperty(name)) { if (!(this[name] instanceof Array)) { if (notUndefined === true) { - this[name] = options[name] === undefined ? this[name] : options[name]; + this[name] = options[name] === undefined ? this[name] : options[name] } else { - this[name] = options[name]; + this[name] = options[name] } } } @@ -18,10 +17,10 @@ export class BaseConfig { sets(types, options) { options = this.initOptions(options) if (types) { - for (let name in types) { + for (const name in types) { if (types.hasOwnProperty(name) && options.hasOwnProperty(name)) { options[name].forEach(o => { - this[name].push(new types[name](o)); + this[name].push(new types[name](o)) }) } } @@ -29,137 +28,137 @@ export class BaseConfig { } initOptions(options) { - return options || {}; + return options || {} } isValid() { - return true; + return true } } export class KeyValue extends BaseConfig { constructor(options) { - options = options || {}; - options.enable = options.enable === undefined ? true : options.enable; + options = options || {} + options.enable = options.enable === undefined ? true : options.enable - super(); - this.name = undefined; - this.value = undefined; - this.type = undefined; - this.files = undefined; - this.enable = undefined; - this.uuid = undefined; - this.time = undefined; - this.contentType = undefined; - this.set(options); + super() + this.name = undefined + this.value = undefined + this.type = undefined + this.files = undefined + this.enable = undefined + this.uuid = undefined + this.time = undefined + this.contentType = undefined + this.set(options) } isValid() { - return (!!this.name || !!this.value) && this.type !== 'file'; + return (!!this.name || !!this.value) && this.type !== 'file' } isFile() { - return (!!this.name || !!this.value) && this.type === 'file'; + return (!!this.name || !!this.value) && this.type === 'file' } } export class Body extends BaseConfig { constructor(options) { - super(); - this.type = "KeyValue"; - this.raw = undefined; - this.kvs = []; - this.binary = []; - this.set(options); - this.sets({kvs: KeyValue}, {binary: KeyValue}, options); + super() + this.type = 'KeyValue' + this.raw = undefined + this.kvs = [] + this.binary = [] + this.set(options) + this.sets({ kvs: KeyValue }, { binary: KeyValue }, options) } isValid() { if (this.isKV()) { return this.kvs.some(kv => { - return kv.isValid(); + return kv.isValid() }) } else { - return !!this.raw; + return !!this.raw } } isKV() { - return [BODY_TYPE.FORM_DATA, BODY_TYPE.WWW_FORM, BODY_TYPE.BINARY].indexOf(this.type) > 0; + return [BODY_TYPE.FORM_DATA, BODY_TYPE.WWW_FORM, BODY_TYPE.BINARY].indexOf(this.type) > 0 } } -export const createComponent = function (name) { - let component = MODELS[name]; +export const createComponent = function(name) { + const component = MODELS[name] if (component) { - return new component(); + return new component() } else { return new UnsupportedComponent() } } export const BODY_TYPE = { - KV: "KeyValue", - FORM_DATA: "Form_Data", - RAW: "Raw", - WWW_FORM: "WWW_FORM", - XML: "XML", - JSON: "JSON" + KV: 'KeyValue', + FORM_DATA: 'Form_Data', + RAW: 'Raw', + WWW_FORM: 'WWW_FORM', + XML: 'XML', + JSON: 'JSON' } export class Scenario extends BaseConfig { constructor(options = {}) { - super(); - this.id = undefined; - this.name = undefined; - this.url = undefined; - this.variables = []; - this.headers = []; - this.requests = []; - this.environmentId = undefined; - this.dubboConfig = undefined; - this.environment = undefined; - this.enableCookieShare = false; - this.enable = true; - this.databaseConfigs = []; - this.tcpConfig = undefined; - this.set(options); + super() + this.id = undefined + this.name = undefined + this.url = undefined + this.variables = [] + this.headers = [] + this.requests = [] + this.environmentId = undefined + this.dubboConfig = undefined + this.environment = undefined + this.enableCookieShare = false + this.enable = true + this.databaseConfigs = [] + this.tcpConfig = undefined + this.set(options) this.sets({ variables: KeyValue, headers: KeyValue, requests: RequestFactory, databaseConfigs: DatabaseConfig - }, options); + }, options) } initOptions(options = {}) { - options.id = options.id || uuid(); - options.requests = options.requests || [new RequestFactory()]; - options.databaseConfigs = options.databaseConfigs || []; - options.dubboConfig = new DubboConfig(options.dubboConfig); - options.tcpConfig = new TCPConfig(options.tcpConfig); - return options; + options.id = options.id || uuid() + options.requests = options.requests || [new RequestFactory()] + options.databaseConfigs = options.databaseConfigs || [] + options.dubboConfig = new DubboConfig(options.dubboConfig) + options.tcpConfig = new TCPConfig(options.tcpConfig) + return options } clone() { - let clone = new Scenario(this); - clone.id = uuid(); - return clone; + const clone = new Scenario(this) + clone.id = uuid() + return clone } isValid() { if (this.enable) { for (let i = 0; i < this.requests.length; i++) { - let validator = this.requests[i].isValid(this.environmentId, this.environment); + const validator = this.requests[i].isValid(this.environmentId, this.environment) if (!validator.isValid) { - return validator; + return validator } } } - return {isValid: true}; + return { isValid: true } } isReference() { - return this.id.indexOf("#") !== -1 + return this.id.indexOf('#') !== -1 } } diff --git a/frontend/src/views/system/datasource/convert.js b/frontend/src/views/system/datasource/convert.js index 9057a08438..87ab7c8a4c 100644 --- a/frontend/src/views/system/datasource/convert.js +++ b/frontend/src/views/system/datasource/convert.js @@ -1,20 +1,19 @@ -const isBoolean = require("lodash.isboolean"); -const isEmpty = require("lodash.isempty"); -const isInteger = require("lodash.isinteger"); -const isNull = require("lodash.isnull"); -const isNumber = require("lodash.isnumber"); -const isObject = require("lodash.isobject"); -const isString = require("lodash.isstring"); -const isArray = Array.isArray; - +const isBoolean = require('lodash.isboolean') +const isEmpty = require('lodash.isempty') +const isInteger = require('lodash.isinteger') +const isNull = require('lodash.isnull') +const isNumber = require('lodash.isnumber') +const isObject = require('lodash.isobject') +const isString = require('lodash.isstring') +const isArray = Array.isArray class Convert { constructor() { this._option = { - $id: "http://example.com/root.json", - $schema: "http://json-schema.org/draft-07/schema#", + $id: 'http://example.com/root.json', + $schema: 'http://json-schema.org/draft-07/schema#', } - this._object = null; + this._object = null } /** @@ -25,22 +24,22 @@ class Convert { format(object, option = {}) { // 数据校验,确保传入的的object只能是对象或数组 if (!isObject(object)) { - throw new TypeError("传入参数只能是对象或数组"); + throw new TypeError('传入参数只能是对象或数组') } // 合并属性 - this._option = Object.assign(this._option, option); + this._option = Object.assign(this._option, option) // 需要转换的对象 - this._object = object; - let convertRes; + this._object = object + let convertRes // 数组类型和对象类型结构不一样 if (isArray(object)) { - convertRes = this._arrayToSchema(); + convertRes = this._arrayToSchema() } else { - convertRes = this._objectToSchema(); + convertRes = this._objectToSchema() } // 释放 - this._object = null; - return convertRes; + this._object = null + return convertRes } /** @@ -48,22 +47,22 @@ class Convert { */ _arrayToSchema() { // root节点基本信息 - let result = this._value2object(this._object, this._option.$id, "", true); + const result = this._value2object(this._object, this._option.$id, '', true) if (this._object.length > 0) { - let itemArr = []; + const itemArr = [] for (let index = 0; index < this._object.length; index++) { // 创建items对象的基本信息 - let objectItem = this._object[index] - let item = this._value2object(objectItem, `#/items`, 'items'); + const objectItem = this._object[index] + let item = this._value2object(objectItem, `#/items`, 'items') if (isObject(objectItem) && !isEmpty(objectItem)) { // 递归遍历 - let objectItemSchema = this._json2schema(objectItem, `#/items`); + const objectItemSchema = this._json2schema(objectItem, `#/items`) // 合并对象 - item = Object.assign(item, objectItemSchema); + item = Object.assign(item, objectItemSchema) } - itemArr.push(item); + itemArr.push(item) } - result["items"] = itemArr; + result['items'] = itemArr } return result } @@ -72,8 +71,8 @@ class Convert { * 对象类型转换成JSONSCHEMA */ _objectToSchema() { - let baseResult = this._value2object(this._object, this._option.$id, "", true) - let objectSchema = this._json2schema(this._object) + let baseResult = this._value2object(this._object, this._option.$id, '', true) + const objectSchema = this._json2schema(this._object) baseResult = Object.assign(baseResult, objectSchema) return baseResult } @@ -83,69 +82,69 @@ class Convert { * @param {*} object 需要转换对象 * @param {*} name $id值 */ - _json2schema(object, name = "") { + _json2schema(object, name = '') { // 如果递归值不是对象,那么return掉 if (!isObject(object)) { - return; + return } // 处理当前路径$id - if (name === "" || name == undefined) { - name = "#" + if (name === '' || name == undefined) { + name = '#' } - let result = {}; + const result = {} // 判断传入object是对象还是数组。 if (isArray(object)) { - result.items = {}; + result.items = {} } else { - result.properties = {}; + result.properties = {} } // 遍历传入的对象 for (const key in object) { if (object.hasOwnProperty(key)) { - const element = object[key]; + const element = object[key] // 如果只是undefined。跳过 if (element === undefined) { - continue; + continue } - let $id = `${name}/properties/${key}` + const $id = `${name}/properties/${key}` // 判断当前 element 的值 是否也是对象,如果是就继续递归,不是就赋值给result - if(!result["properties"]){ - continue; + if (!result['properties']) { + continue } if (isObject(element)) { // 创建当前属性的基本信息 - result["properties"][key] = this._value2object(element, $id, key) + result['properties'][key] = this._value2object(element, $id, key) if (isArray(element)) { // 针对空数组和有值的数组做不同处理 if (element.length > 0) { // 是数组 - let itemArr = []; + const itemArr = [] for (let index = 0; index < element.length; index++) { - let elementItem = element[index]; + const elementItem = element[index] // 创建items对象的基本信息 - let item = this._value2object(elementItem, `${$id}/items`, key + 'items'); + let item = this._value2object(elementItem, `${$id}/items`, key + 'items') // 判断第一项是否是对象,且对象属性不为空 if (isObject(elementItem) && !isEmpty(elementItem)) { // 新增的properties才合并进来 - item = Object.assign(item, this._json2schema(elementItem, `${$id}/items`)); + item = Object.assign(item, this._json2schema(elementItem, `${$id}/items`)) } - itemArr.push(item); + itemArr.push(item) } - result["properties"][key]["items"] = itemArr; + result['properties'][key]['items'] = itemArr } } else { // 不是数组,递归遍历获取,然后合并对象属性 - result["properties"][key] = Object.assign(result["properties"][key], this._json2schema(element, $id)); + result['properties'][key] = Object.assign(result['properties'][key], this._json2schema(element, $id)) } } else { // 一般属性直接获取基本信息 - if (result["properties"]) { - result["properties"][key] = this._value2object(element, $id, key); + if (result['properties']) { + result['properties'][key] = this._value2object(element, $id, key) } } } } - return result; + return result } /** @@ -155,39 +154,39 @@ class Convert { * @param {*} key */ _value2object(value, $id, key = '', root = false) { - let objectTemplate = { + const objectTemplate = { $id: $id, title: `The ${key} Schema`, mock: { - "mock": value + 'mock': value }, } // 判断是否为初始化root数据 if (root) { - objectTemplate["$schema"] = this._option.$schema; - objectTemplate["title"] = `The Root Schema`; - objectTemplate["mock"] = undefined; + objectTemplate['$schema'] = this._option.$schema + objectTemplate['title'] = `The Root Schema` + objectTemplate['mock'] = undefined } if (isBoolean(value)) { - objectTemplate.type = "boolean"; + objectTemplate.type = 'boolean' } else if (isInteger(value)) { - objectTemplate.type = "integer"; + objectTemplate.type = 'integer' } else if (isNumber(value)) { - objectTemplate.type = "number"; + objectTemplate.type = 'number' } else if (isString(value)) { - objectTemplate.type = "string"; + objectTemplate.type = 'string' } else if (isNull(value)) { - objectTemplate.type = "null"; + objectTemplate.type = 'null' } else if (isArray(value)) { - objectTemplate.type = "array"; - objectTemplate["mock"] = undefined; + objectTemplate.type = 'array' + objectTemplate['mock'] = undefined } else if (isObject(value)) { - objectTemplate.type = "object" - objectTemplate["mock"] = undefined; + objectTemplate.type = 'object' + objectTemplate['mock'] = undefined } - return objectTemplate; + return objectTemplate } } diff --git a/frontend/src/views/system/datasource/format-utils.js b/frontend/src/views/system/datasource/format-utils.js index b7ce6b4425..ff957f2fe9 100644 --- a/frontend/src/views/system/datasource/format-utils.js +++ b/frontend/src/views/system/datasource/format-utils.js @@ -1,142 +1,134 @@ -export function formatJson (json) { - let i = 0, - il = 0, - tab = " ", - newJson = "", - indentLevel = 0, - inString = false, - currentChar = null; - let flag = false; +export function formatJson(json) { + let i = 0 + let il = 0 + const tab = ' ' + let newJson = '' + let indentLevel = 0 + let inString = false + let currentChar = null + let flag = false for (i = 0, il = json.length; i < il; i += 1) { - currentChar = json.charAt(i); + currentChar = json.charAt(i) switch (currentChar) { case '{': if (i != 0 && json.charAt(i - 1) === '$') { - newJson += currentChar; - flag = true; + newJson += currentChar + flag = true } else if (!inString) { - newJson += currentChar + "\n" + repeat(tab, indentLevel + 1); + newJson += currentChar + '\n' + repeat(tab, indentLevel + 1) indentLevel += 1 } else { newJson += currentChar } - break; + break case '[': if (!inString) { - newJson += currentChar + "\n" + repeat(tab, indentLevel + 1); + newJson += currentChar + '\n' + repeat(tab, indentLevel + 1) indentLevel += 1 } else { newJson += currentChar } - break; + break case '}': if (flag) { - newJson += currentChar; - flag = false; + newJson += currentChar + flag = false } else if (!inString) { - indentLevel -= 1; - newJson += "\n" + repeat(tab, indentLevel) + currentChar + indentLevel -= 1 + newJson += '\n' + repeat(tab, indentLevel) + currentChar } else { newJson += currentChar } - break; + break case ']': if (!inString) { - indentLevel -= 1; - newJson += "\n" + repeat(tab, indentLevel) + currentChar + indentLevel -= 1 + newJson += '\n' + repeat(tab, indentLevel) + currentChar } else { newJson += currentChar } - break; + break case ',': if (!inString) { - newJson += ",\n" + repeat(tab, indentLevel) + newJson += ',\n' + repeat(tab, indentLevel) } else { newJson += currentChar } - break; + break case ':': if (!inString) { - newJson += ": " + newJson += ': ' } else { newJson += currentChar } - break; + break case ' ': - case "\n": - case "\t": + case '\n': + case '\t': if (inString) { newJson += currentChar } - break; + break case '"': if (i > 0 && json.charAt(i - 1) !== '\\') { inString = !inString } - newJson += currentChar; - break; + newJson += currentChar + break default: - newJson += currentChar; + newJson += currentChar break } } - return newJson; + return newJson } function repeat(s, count) { return new Array(count + 1).join(s) } - - export function formatXml(text) { - //去掉多余的空格 - text = '\n' + text.replace(/(<\w+)(\s.*?>)/g, function ($0, name, props) { - return name + ' ' + props.replace(/\s+(\w+=)/g, " $1"); - }); - //把注释编码 - text = text.replace(//g, function ($0, text) { - var ret = ''; - //alert(ret); - return ret; - }); - //调整格式 - var rgx = /\n(<(([^\?]).+?)(?:\s|\s*?>|\s*?(\/)>)(?:.*?(?:(?:(\/)>)|(?:<(\/)\2>)))?)/mg; - var nodeStack = []; - var output = text.replace(rgx, function ($0, all, name, isBegin, isCloseFull1, isCloseFull2, isFull1, isFull2) { - var isClosed = (isCloseFull1 == '/') || (isCloseFull2 == '/' ) || (isFull1 == '/') || (isFull2 == '/'); - //alert([all,isClosed].join('=')); - var prefix = ''; + // 去掉多余的空格 + text = '\n' + text.replace(/(<\w+)(\s.*?>)/g, function($0, name, props) { + return name + ' ' + props.replace(/\s+(\w+=)/g, ' $1') + }) + // 把注释编码 + text = text.replace(//g, function($0, text) { + var ret = '' + return ret + }) + // 调整格式 + var rgx = /\n(<(([^\?]).+?)(?:\s|\s*?>|\s*?(\/)>)(?:.*?(?:(?:(\/)>)|(?:<(\/)\2>)))?)/mg + var nodeStack = [] + var output = text.replace(rgx, function($0, all, name, isBegin, isCloseFull1, isCloseFull2, isFull1, isFull2) { + var isClosed = (isCloseFull1 == '/') || (isCloseFull2 == '/') || (isFull1 == '/') || (isFull2 == '/') + var prefix = '' if (isBegin == '!') { - prefix = getPrefix(nodeStack.length); - } - else { + prefix = getPrefix(nodeStack.length) + } else { if (isBegin != '/') { - prefix = getPrefix(nodeStack.length); + prefix = getPrefix(nodeStack.length) if (!isClosed) { - nodeStack.push(name); + nodeStack.push(name) } - } - else { - nodeStack.pop(); - prefix = getPrefix(nodeStack.length); + } else { + nodeStack.pop() + prefix = getPrefix(nodeStack.length) } } - var ret = '\n' + prefix + all; - return ret; - }); - var prefixSpace = -1; - var outputText = output.substring(1); - //把注释还原并解码,调格式 - outputText = outputText.replace(/(\s*)/g, function ($0, prefix, text) { - if (prefix.charAt(0) == '\r') - prefix = prefix.substring(1); - text = unescape(text).replace(/\r/g, '\n'); - var ret = '\n' + prefix + ''; - //alert(ret); - return ret; - }); - return outputText.replace(/\s+$/g, '').replace(/\r/g, '\r\n'); + var ret = '\n' + prefix + all + return ret + }) + var prefixSpace = -1 + var outputText = output.substring(1) + // 把注释还原并解码,调格式 + outputText = outputText.replace(/(\s*)/g, function($0, prefix, text) { + if (prefix.charAt(0) == '\r') { prefix = prefix.substring(1) } + text = unescape(text).replace(/\r/g, '\n') + var ret = '\n' + prefix + '' + return ret + }) + return outputText.replace(/\s+$/g, '').replace(/\r/g, '\r\n') } /** @@ -146,17 +138,17 @@ export function formatXml(text) { * @example formatTime('2018-1-29', '{y}/{m}/{d} {h}:{i}:{s}') // -> 2018/01/29 00:00:00 */ export function formatTime(time, cFormat) { - if (arguments.length === 0) return null; + if (arguments.length === 0) return null if ((time + '').length === 10) { - time = +time * 1000; + time = +time * 1000 } - let format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}', date; + const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'; let date if (typeof time === 'object') { - date = time; + date = time } else { - date = new Date(time); + date = new Date(time) } - let formatObj = { + const formatObj = { y: date.getFullYear(), m: date.getMonth() + 1, d: date.getDate(), @@ -164,22 +156,22 @@ export function formatTime(time, cFormat) { i: date.getMinutes(), s: date.getSeconds(), a: date.getDay() - }; + } return format.replace(/{([ymdhisa])+}/g, (result, key) => { - let value = formatObj[key]; - if (key === 'a') return ['一', '二', '三', '四', '五', '六', '日'][value - 1]; + let value = formatObj[key] + if (key === 'a') return ['一', '二', '三', '四', '五', '六', '日'][value - 1] if (result.length > 0 && value < 10) { - value = '0' + value; + value = '0' + value } - return value || 0; - }); + return value || 0 + }) } function getPrefix(prefixIndex) { - var span = ' '; - var output = []; + var span = ' ' + var output = [] for (var i = 0; i < prefixIndex; ++i) { - output.push(span); + output.push(span) } - return output.join(''); + return output.join('') } diff --git a/frontend/src/views/system/user/index.vue b/frontend/src/views/system/user/index.vue index 1f2d6df965..2d534cfe58 100644 --- a/frontend/src/views/system/user/index.vue +++ b/frontend/src/views/system/user/index.vue @@ -746,7 +746,7 @@ export default { text-align: right; display: flex; align-items: center; - justify-content: end; + justify-content: flex-end; .el-input--medium .el-input__icon { line-height: 32px;