diff --git a/paas-ce/lesscode/.babelrc b/paas-ce/lesscode/.babelrc index f9bfa61de..0beca1ece 100644 --- a/paas-ce/lesscode/.babelrc +++ b/paas-ce/lesscode/.babelrc @@ -18,6 +18,7 @@ "lodash", "@babel/plugin-syntax-dynamic-import", ["@babel/plugin-proposal-decorators", { "legacy": true }], + ["@babel/plugin-proposal-class-properties", { "loose" : true }], "@babel/plugin-proposal-function-sent", "@babel/plugin-proposal-export-namespace-from", "@babel/plugin-proposal-numeric-separator", @@ -32,6 +33,7 @@ "plugins": [ "istanbul", ["@babel/plugin-proposal-decorators", { "legacy": true }], + ["@babel/plugin-proposal-class-properties", { "loose" : true }], "@babel/plugin-proposal-function-sent", "@babel/plugin-proposal-export-namespace-from", "@babel/plugin-proposal-numeric-separator", diff --git a/paas-ce/lesscode/.eslintrc.js b/paas-ce/lesscode/.eslintrc.js index 4c059beb1..171060591 100644 --- a/paas-ce/lesscode/.eslintrc.js +++ b/paas-ce/lesscode/.eslintrc.js @@ -2,7 +2,10 @@ module.exports = { root: true, parserOptions: { parser: 'babel-eslint', - sourceType: 'module' + sourceType: 'module', + ecmaFeatures: { + legacyDecorators: true + } }, env: { browser: true @@ -23,7 +26,8 @@ module.exports = { APP_CODE: false, ENV: false, monaco: false, - ResizeSensor: false + ResizeSensor: false, + define: false }, // add your custom rules hered rules: { diff --git a/paas-ce/lesscode/.gitignore b/paas-ce/lesscode/.gitignore index de7b1fc8b..f3b76f6ce 100644 --- a/paas-ce/lesscode/.gitignore +++ b/paas-ce/lesscode/.gitignore @@ -26,3 +26,5 @@ lib/client/static/lib-manifest.json lib/client/static/lib.bundle.js lib/client/static/vue-layout-demo*.vue !lib/client/static/ResizeSensor.js +lib/server/conf/data-base.js +lib/server/conf/http.js diff --git a/paas-ce/lesscode/README.md b/paas-ce/lesscode/README.md index c3f6bb03d..19d064238 100644 --- a/paas-ce/lesscode/README.md +++ b/paas-ce/lesscode/README.md @@ -92,6 +92,7 @@ ## 安装部署 - [本地开发部署](./docs/install/dev_install.md) - [生产环境部署](./docs/install/prod_install.md) +- [数据库说明](./docs/install/database.md) ## 开发文档 - [自定义组件开发文档](./docs/develop/dev_com.md) diff --git a/paas-ce/lesscode/docs/install/database.md b/paas-ce/lesscode/docs/install/database.md new file mode 100644 index 000000000..fe6d9496f --- /dev/null +++ b/paas-ce/lesscode/docs/install/database.md @@ -0,0 +1,17 @@ +# 蓝鲸智云PaaS平台社区版之可视化开发平台 + +## 数据库说明 + +需要用户自己提供 MySQL 服务并做 db 授权。本地开发和生产环境的数据库初始化和变更流程是一样的,都需要自己执行SQL对数据库进行修改。执行 SQL 分两种,初始化时执行的 SQL 和升级时执行的 SQL。SQL 文件存放于 `lesscode/lib/server/model/sql` 文件夹下。 + +## 数据库配置说明 + +在本地开发和生产环境中,需要依照 [数据库配置示例](../../lib/server/conf/data-base.js.example) 在 `lesscode/lib/server/conf` 中新建 `data-base.js` 文件(复制 `data-base.js.example`,并删除 `.example`即可)。然后依照 `data-base.js.example` 的注释填写数据库的配置信息。 + +## 数据库初始化说明 + +在 `lesscode/lib/server/model/sql` 文件夹下,每次发版都会新建一个文件夹,以发布日期命名,里面的 `initial.sql` 为安装该版本需要的所有 SQL,包含了建表语句和初始化数据。初次安装的时候,需要手动执行该SQL,即完成了数据库初始化。注意:如果不是数据库初始化,执行该 SQL 会导致数据丢失。如果是升级,请按照数据库表结构变更来操作。 + +## 数据库表结构变更说明 + +在 `lesscode/lib/server/model/sql` 文件夹下,每次发布还会生成 `update.sql`,`update.sql` 是从上一个版本升级到这个版本的 SQL 语句,包含了修改表结构语句和初始化数据。如果这次升级数据库,跨越了3个版本,那么这3个版本的 `update.sql` 需要按照版本顺序都执行一次,即完成了数据库表结构变更。 diff --git a/paas-ce/lesscode/lib/client/build/webpack.base.conf.js b/paas-ce/lesscode/lib/client/build/webpack.base.conf.js index 8ece8b4d6..cd91c0263 100644 --- a/paas-ce/lesscode/lib/client/build/webpack.base.conf.js +++ b/paas-ce/lesscode/lib/client/build/webpack.base.conf.js @@ -97,8 +97,8 @@ module.exports = { resolve(__dirname, '..', 'src'), resolve(__dirname, '../../../node_modules', 'bk-magic-vue'), resolve(__dirname, '../../../node_modules', 'monaco-editor'), - resolve(__dirname, '../../../node_modules', 'vue-echarts'), - resolve(__dirname, '../../../node_modules', 'resize-detector') + resolve(__dirname, '../../../node_modules', 'vue-echarts') + // resolve(__dirname, '../../../node_modules', 'resize-detector') ], cacheDirectory: resolve(__dirname, '..', '.webpack_cache'), presets: [ diff --git a/paas-ce/lesscode/lib/client/src/App.vue b/paas-ce/lesscode/lib/client/src/App.vue index 0592c4863..970d8f791 100644 --- a/paas-ce/lesscode/lib/client/src/App.vue +++ b/paas-ce/lesscode/lib/client/src/App.vue @@ -21,11 +21,12 @@ - diff --git a/paas-ce/lesscode/lib/client/src/components/methods/funcForm.vue b/paas-ce/lesscode/lib/client/src/components/methods/funcForm.vue new file mode 100644 index 000000000..9c1358eb4 --- /dev/null +++ b/paas-ce/lesscode/lib/client/src/components/methods/funcForm.vue @@ -0,0 +1,291 @@ + + + + + diff --git a/paas-ce/lesscode/lib/client/src/components/methods/index.vue b/paas-ce/lesscode/lib/client/src/components/methods/index.vue index 4d3475897..9fc1baae8 100644 --- a/paas-ce/lesscode/lib/client/src/components/methods/index.vue +++ b/paas-ce/lesscode/lib/client/src/components/methods/index.vue @@ -1,395 +1,473 @@ - - + diff --git a/paas-ce/lesscode/lib/client/src/components/methods/label-list.vue b/paas-ce/lesscode/lib/client/src/components/methods/label-list.vue new file mode 100644 index 000000000..dbf94ee57 --- /dev/null +++ b/paas-ce/lesscode/lib/client/src/components/methods/label-list.vue @@ -0,0 +1,82 @@ + + + + + + diff --git a/paas-ce/lesscode/lib/client/src/components/methods/monaco.vue b/paas-ce/lesscode/lib/client/src/components/methods/monaco.vue new file mode 100644 index 000000000..e4838360f --- /dev/null +++ b/paas-ce/lesscode/lib/client/src/components/methods/monaco.vue @@ -0,0 +1,204 @@ + + + + + diff --git a/paas-ce/lesscode/lib/client/src/components/patch/chart/index.vue b/paas-ce/lesscode/lib/client/src/components/patch/chart/index.vue index d771a2586..0516927b6 100644 --- a/paas-ce/lesscode/lib/client/src/components/patch/chart/index.vue +++ b/paas-ce/lesscode/lib/client/src/components/patch/chart/index.vue @@ -11,9 +11,9 @@ + + diff --git a/paas-ce/lesscode/lib/client/src/components/ui/extra-links.vue b/paas-ce/lesscode/lib/client/src/components/ui/extra-links.vue new file mode 100644 index 000000000..c64ecafc5 --- /dev/null +++ b/paas-ce/lesscode/lib/client/src/components/ui/extra-links.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/paas-ce/lesscode/lib/client/src/components/ui/layout.vue b/paas-ce/lesscode/lib/client/src/components/ui/layout.vue new file mode 100644 index 000000000..c4ef5481b --- /dev/null +++ b/paas-ce/lesscode/lib/client/src/components/ui/layout.vue @@ -0,0 +1,178 @@ + + + diff --git a/paas-ce/lesscode/lib/client/src/components/vue-code/code-mixin.js b/paas-ce/lesscode/lib/client/src/components/vue-code/code-mixin.js index 60f54ed6f..751f8d663 100644 --- a/paas-ce/lesscode/lib/client/src/components/vue-code/code-mixin.js +++ b/paas-ce/lesscode/lib/client/src/components/vue-code/code-mixin.js @@ -8,7 +8,7 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ - +import { mapGetters } from 'vuex' import { paramCase, camelCase } from 'change-case' const codeMixin = { @@ -46,21 +46,37 @@ const codeMixin = { this.chartTypeArr = [] } }, + computed: { + ...mapGetters('functions', ['funcGroups']) + }, methods: { getMethodById (methodId) { let returnMethod = { id: '', - funName: '', - code: 'function emptyFunc () {}' + funcName: 'emptyFunc', + previewStr: '', + vueCodeStr: '' } - const functionGroup = JSON.parse(localStorage.getItem('functionGroup')) - functionGroup.forEach((group) => { - const funChildren = group.children || [] + this.funcGroups.forEach((group) => { + const funChildren = group.functionList || [] const method = funChildren.find(x => x.id === methodId) if (method) { returnMethod = method } }) + const paramsStr = (returnMethod.funcParams || []).join(', ') + function addFuncStr (funcBody) { + return `${returnMethod.funcName} (${paramsStr}) { ${funcBody} }` + } + if (returnMethod.funcType === 1) { + const remoteParams = (returnMethod.remoteParams || []).join(', ') + const data = { url: returnMethod.funcApiUrl, type: returnMethod.funcMethod, apiData: returnMethod.funcApiData } + returnMethod.previewStr = addFuncStr(`return this.$store.dispatch('getApiData', ${JSON.stringify(data)}).then((${remoteParams}) => { ${returnMethod.funcBody} }).catch((err) => { console.error(err) })`) + returnMethod.vueCodeStr = addFuncStr(`return this.$http.${returnMethod.funcMethod}('${returnMethod.funcApiUrl}'${returnMethod.funcApiData ? `, ${returnMethod.funcApiData}` : ''}).then((${remoteParams}) => { ${returnMethod.funcBody} }).catch((err) => { console.error(err) })`) + } else { + returnMethod.previewStr = addFuncStr(returnMethod.funcBody) + returnMethod.vueCodeStr = addFuncStr(returnMethod.funcBody) + } return returnMethod }, @@ -71,7 +87,7 @@ const codeMixin = { const widthStr = item.renderProps.width && item.renderProps.width.val ? `width: ${item.renderProps.width.val}px;` : '' const heightStr = `height:${item.renderProps.height.val || 0}px;` return `
- +
\n` } else { // item.componentId = item.componentId.replace('_', '') @@ -183,12 +199,13 @@ const codeMixin = { }, getPropsStr (type, props, compId) { let propsStr = '' - compId = camelCase(compId) + const preCompId = camelCase(compId) for (const i in props) { if (i !== 'slots') { let propsValue = '' let putToData = false + compId = `${preCompId}${camelCase(i)}` if (typeof props[i].val === 'object' && props[i].type === 'array') { this.dataTemplate(compId, JSON.stringify(props[i].val)) putToData = true @@ -245,12 +262,12 @@ const codeMixin = { if (typeof events === 'object' && Object.keys(events).length) { for (const key in events) { const fun = this.getMethodById(events[key]) - if (fun.funName) { - eventStr += `@${key}="${fun.funName}" ` + if (fun.id) { + eventStr += `@${key}="${fun.funcName}" ` + const contentStr = this.pageType === 'vueCode' ? fun.vueCodeStr : fun.previewStr if (this.existFunc.indexOf(events[key]) === -1) { this.existFunc.push(events[key]) - const code = fun.code.replace('function ', '') - this.methodsStr += `${code},` + this.methodsStr += `${ contentStr },` } } } @@ -371,17 +388,16 @@ const codeMixin = { }, remoteMethodsTemplate (key, payload) { const method = this.getMethodById(payload.methodId) - const data = { - url: payload.url, - type: payload.method - } - const previewStr = `this.${key} = await this.$store.dispatch('getApiData', ${JSON.stringify(data)}).then(${method.code})` - const vueCodeStr = `this.${key} = await this.$http.${payload.method}('${payload.url}').then(${method.code})` - const contentStr = this.pageType === 'vueCode' ? vueCodeStr : previewStr + const contentStr = this.pageType === 'vueCode' ? method.vueCodeStr : method.previewStr this.methodsStr += ` async get${key} () { - ${contentStr} - },\n` + this.${key} = await this.${method.funcName}() + },` + + if (this.existFunc.indexOf(method.id) === -1) { + this.existFunc.push(method.id) + this.methodsStr += `${contentStr},` + } }, createdTemplate (key) { this.createdStr += `this.get${key}()\n` diff --git a/paas-ce/lesscode/lib/client/src/css/bk-patch.css b/paas-ce/lesscode/lib/client/src/css/bk-patch.css index ad58df046..7fb66f51d 100644 --- a/paas-ce/lesscode/lib/client/src/css/bk-patch.css +++ b/paas-ce/lesscode/lib/client/src/css/bk-patch.css @@ -14,3 +14,23 @@ button.bk-button { vertical-align: baseline; } + +.function-option { + .icon-info { + position: absolute; + right: 0; + top: 3px; + font-size: 16px; + width: 26px; + height: 26px; + line-height: 26px; + text-align: center; + } + .funtion-name { + display: block; + width: calc(100% - 10px); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } +} diff --git a/paas-ce/lesscode/lib/client/src/css/common.css b/paas-ce/lesscode/lib/client/src/css/common.css new file mode 100644 index 000000000..01cb7d8c0 --- /dev/null +++ b/paas-ce/lesscode/lib/client/src/css/common.css @@ -0,0 +1,32 @@ +/* page */ +.page-content { + padding: 16px 24px; + display: flex; + flex-direction: column; + height: 100%; + + .page-head { + display: flex; + margin-bottom: 20px; + + .extra { + flex: none; + margin-left: auto; + } + } + .page-body { + display: flex; + flex: 1; + + .page-body-inner { + display: flex; + flex: 1; + } + + .empty { + flex: 1; + display: flex; + align-items: center; + } + } +} diff --git a/paas-ce/lesscode/lib/client/src/custom/x-table/index.vue b/paas-ce/lesscode/lib/client/src/custom/x-table/index.vue index 844460a6f..2f2e5802e 100644 --- a/paas-ce/lesscode/lib/client/src/custom/x-table/index.vue +++ b/paas-ce/lesscode/lib/client/src/custom/x-table/index.vue @@ -109,15 +109,15 @@ props: { getTableListAjaxUrl: { type: String, - default: '' + default: '/data/getXTableData' }, postEditTableListAjaxUrl: { type: String, - default: '' + default: '/data/getXTableData' }, delTableListAjaxUrl: { type: String, - default: '' + default: '/data/getXTableData' } }, data () { @@ -248,7 +248,8 @@ async getTableData () { if (this.getTableListAjaxUrl) { await this.$http.get(this.getTableListAjaxUrl, { ...this.systemInfo }).then(res => { - this.reloadTable.splice(0, this.reloadTable.length, ...res.data.info) + this.tableData = res.data.msg + this.reloadTable = false }) } else { try { @@ -299,12 +300,16 @@ this.dialog.show = true if (this.postEditTableListAjaxUrl) { await this.$http.post(this.postEditTableListAjaxUrl, { ...this.editSourceId }).then(res => { - this.properties.source_name = res.data.cluster_config.cluster_name - this.properties.es_host = res.data.msg.cluster_config.domain_name - this.number = this.properties.es_port = res.data.cluster_config.port - this.properties.es_user = res.data.msg.cluster_config.username - this.properties.es_password = '******' - this.cluster_config.cluster_id = this.editSourceId + this.tableData = res.data.msg + this.reloadTable = false + if (res.data.msg[this.editSourceId - 1]) { + this.properties.source_name = res.data.msg[this.editSourceId - 1].cluster_config.cluster_name + this.properties.es_host = res.data.msg[this.editSourceId - 1].cluster_config.domain_name + this.number = this.properties.es_port = res.data.msg[this.editSourceId - 1].cluster_config.port + this.properties.es_user = res.data.msg[this.editSourceId - 1].cluster_config.username + this.properties.es_password = '******' + this.cluster_config.cluster_id = this.editSourceId + } }) } else { try { @@ -338,7 +343,9 @@ }) if (this.delTableListAjaxUrl) { this.$http.get(this.delTableListAjaxUrl, { ...obj }).then(res => { - this.reloadTable.splice(0, this.reloadTable.length, ...res.data.info) + this.$bkLoading.hide() + this.reloadTable = true + this.getTableData() }) } else { try { diff --git a/paas-ce/lesscode/lib/client/src/element-materials/modifier/events/index.vue b/paas-ce/lesscode/lib/client/src/element-materials/modifier/events/index.vue index 202cdaba2..66dcca905 100644 --- a/paas-ce/lesscode/lib/client/src/element-materials/modifier/events/index.vue +++ b/paas-ce/lesscode/lib/client/src/element-materials/modifier/events/index.vue @@ -19,14 +19,17 @@ - + :name="option.funcName"> + {{option.funcName}} +
@@ -38,7 +41,7 @@
该组件暂无事件
- + @@ -76,7 +79,8 @@ } }, computed: { - ...mapGetters('drag', ['functionGroup', 'pageData', 'curSelectedComponentData']) + ...mapGetters('drag', ['pageData', 'curSelectedComponentData']), + ...mapGetters('functions', ['funcGroups']) }, watch: { materialConfig: { diff --git a/paas-ce/lesscode/lib/client/src/element-materials/modifier/props/components/strategy/boolean.vue b/paas-ce/lesscode/lib/client/src/element-materials/modifier/props/components/strategy/boolean.vue index f14c30754..7547d8b49 100644 --- a/paas-ce/lesscode/lib/client/src/element-materials/modifier/props/components/strategy/boolean.vue +++ b/paas-ce/lesscode/lib/client/src/element-materials/modifier/props/components/strategy/boolean.vue @@ -9,6 +9,44 @@ specific language governing permissions and limitations under the License. --> -