-
-
暂无函数
+
+
+
+
+
+ 函数库
+
+
+
+
{{ groupNameErrMessage }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ group.groupName }}
+
+
+
+
+
+ {{ (group.functionList || []).length }}
+
+
+ -
+ {{ func.funcName }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ delObj.name }}
+
-
-
-
-
-
-
- -
- 函数名:
- {{ selectMethod.funName }}
- 修改
-
- -
- 参数:
-
- {{ param }}
-
- 新增
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
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 @@
+
+
+ {{ item }}
+
+
+ ...
+
+ --
+
+
+
+
+
+
+
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.
-->
-
- props.change(`${props.name}`, val, props.type)" />
+
+
+
+
+
+
+
diff --git a/paas-ce/lesscode/lib/client/src/element-materials/modifier/props/components/strategy/remote.vue b/paas-ce/lesscode/lib/client/src/element-materials/modifier/props/components/strategy/remote.vue
index 537c4864d..6b32117a8 100644
--- a/paas-ce/lesscode/lib/client/src/element-materials/modifier/props/components/strategy/remote.vue
+++ b/paas-ce/lesscode/lib/client/src/element-materials/modifier/props/components/strategy/remote.vue
@@ -11,30 +11,27 @@
- 数据源 Api Url
-
- Api 方法
-
-
-
- 数据清洗函数
+ 远程函数
-
+ :name="option.funcName">
+ {{option.funcName}}
+
新增函数
- 获取接口数据
-
+ 获取数据
+
@@ -68,80 +65,78 @@
data () {
return {
remoteData: {
- url: '/api/test/getMockData',
- method: 'get',
methodId: ''
},
showMethod: false
}
},
computed: {
- ...mapGetters('drag', ['functionGroup'])
+ ...mapGetters('functions', ['funcGroups'])
},
created () {
- this.methodList = ['get', 'post', 'put', 'delete', 'update']
this.remoteData = Object.assign({}, this.remoteData, this.payload)
},
methods: {
saveChange () {
this.change(this.name, this.defaultValue, this.type, JSON.parse(JSON.stringify(this.remoteData)))
},
- genHackEval (methodId) {
- let methodCode = ''
- this.functionGroup.forEach((group) => {
- const funChildren = group.children || []
+
+ showMethodDialog () {
+ const eventChooseComp = this.$refs.eventChooseComp
+ if (eventChooseComp) {
+ eventChooseComp.close()
+ }
+ this.showMethod = true
+ },
+
+ getMethod (methodId) {
+ let returnMethod
+ this.funcGroups.forEach((group) => {
+ const funChildren = group.functionList || []
const method = funChildren.find(x => x.id === methodId)
- if (method) methodCode = method.code
+ if (method) {
+ returnMethod = method
+ }
})
const Fn = Function
- return new Fn('return ' + methodCode)()
+ let returnFun
+ if (returnMethod.funcType === 1) {
+ const remoteParams = (returnMethod.remoteParams || []).join(', ')
+ const data = { url: returnMethod.funcApiUrl, type: returnMethod.funcMethod, apiData: returnMethod.funcApiData }
+ returnFun = new Fn(`return this.$store.dispatch('getApiData', ${JSON.stringify(data)}).then((${remoteParams}) => { ${returnMethod.funcBody} })`).bind(this)
+ } else {
+ returnFun = new Fn(returnMethod.funcBody).bind(this)
+ }
+ return returnFun
},
- getApiData () {
- if (!this.remoteData.url) {
- this.$bkMessage({ theme: 'error', message: 'Api Url不能为空' })
+
+ async getApiData () {
+ if (!this.remoteData.methodId) {
+ this.$bkMessage({ theme: 'error', message: '请先选择函数' })
return
}
- let transformFunc = _ => _
- if (this.remoteData.methodId) {
- try {
- transformFunc = this.genHackEval(this.remoteData.methodId)
- } catch (error) {
- this.$bkMessage({ theme: 'error', message: error.message || '转换函数格式不正确', limit: 1 })
- return
- }
- }
- const data = {
- url: this.remoteData.url,
- type: this.remoteData.method
+ let method
+ try {
+ method = this.getMethod(this.remoteData.methodId)
+ } catch (error) {
+ this.$bkMessage({ theme: 'error', message: '函数格式有误,请修改后再试' })
+ return
}
- this.$store.dispatch('getApiData', data).then(res => {
- let resData = res
- try {
- resData = transformFunc(resData)
- } catch (error) {
- this.$bkMessage({ theme: 'error', message: `数据清洗函数执行失败: ${error.message || error}`, limit: 1 })
- return
- }
- const message = this.remoteValidate(resData)
+
+ try {
+ const res = await method()
+ const message = this.remoteValidate(res)
if (message) {
this.$bkMessage({ theme: 'error', message })
} else {
- this.change(this.name, resData, this.type, JSON.parse(JSON.stringify(this.remoteData)))
- this.$bkMessage({ theme: 'success', message: '接口数据获取成功', limit: 1 })
+ this.change(this.name, res, this.type, JSON.parse(JSON.stringify(this.remoteData)))
+ this.$bkMessage({ theme: 'success', message: '获取数据成功', limit: 1 })
}
- }).catch(e => {
- this.$bkMessage({ theme: 'error', message: '获取接口数据失败,请检查 url 是否正确', limit: 1 })
- })
- },
- showMethodDialog () {
- const eventChooseComp = this.$refs.eventChooseComp[0]
- if (eventChooseComp) {
- eventChooseComp.close()
+ } catch (error) {
+ this.$bkMessage({ theme: 'error', message: '获取数据失败,请检查函数是否正确', limit: 1 })
}
- this.showMethod = true
}
-
}
}
diff --git a/paas-ce/lesscode/lib/client/src/images/page-demo.png b/paas-ce/lesscode/lib/client/src/images/page-demo.png
new file mode 100644
index 000000000..80d56d663
Binary files /dev/null and b/paas-ce/lesscode/lib/client/src/images/page-demo.png differ
diff --git a/paas-ce/lesscode/lib/client/src/main.js b/paas-ce/lesscode/lib/client/src/main.js
index 3928adead..c2c86a0ee 100644
--- a/paas-ce/lesscode/lib/client/src/main.js
+++ b/paas-ce/lesscode/lib/client/src/main.js
@@ -23,9 +23,12 @@ import { bus } from '@/common/bus'
import header from '@/components/header.vue'
import '@/common/bkmagic'
import '@icon-cool/bk-icon-vue-drag-vis'
+import '@icon-cool/bk-icon-vue-drag-vis/src/index'
import VueContextMenu from '@xunlei/vue-context-menu'
import targetData from '@/common/targetData.js'
-
+import pureAxios from '@/api/pureAxios.js'
+// 用户调用接口使用,无业务逻辑,直接返回数据
+Vue.prototype.$http = pureAxios
Vue.prototype.$td = targetData
Vue.use(VueContextMenu)
diff --git a/paas-ce/lesscode/lib/client/src/router/index.js b/paas-ce/lesscode/lib/client/src/router/index.js
index f0a1d2afa..67b798d8c 100644
--- a/paas-ce/lesscode/lib/client/src/router/index.js
+++ b/paas-ce/lesscode/lib/client/src/router/index.js
@@ -18,6 +18,16 @@ import preload from '@/common/preload'
Vue.use(VueRouter)
+const SystemEntry = () => import(/* webpackChunkName: 'index' */'@/views/system')
+const Projects = () => import(/* webpackChunkName: 'projects' */'@/views/system/projects')
+const Account = () => import(/* webpackChunkName: 'account' */'@/views/system/account')
+const ComponentManage = () => import(/* webpackChunkName: 'index' */'@/views/system/component-manage')
+const FunctionManage = () => import(/* webpackChunkName: 'index' */'@/views/project/function-manage')
+
+const ProjectEntry = () => import(/* webpackChunkName: 'projectEntry' */'@/views/project')
+const Page = () => import(/* webpackChunkName: 'page' */'@/views/project/page')
+const Member = () => import(/* webpackChunkName: 'member' */'@/views/project/member')
+
const MainEntry = () => import(/* webpackChunkName: 'index' */'@/views')
const Index = () => import(/* webpackChunkName: 'index' */'@/views/index/index')
const Preview = () => import(/* webpackChunkName: 'preview' */'@/views/preview')
@@ -32,7 +42,77 @@ const Changelog = () => import(/* webpackChunkName: 'start' */'@/views/changelog
const routes = [
{
- path: `/${APP_CODE}`,
+ path: '/help',
+ component: MainHelpEntry,
+ children: [
+ { path: 'custom', name: 'custom', component: Custom },
+ { path: 'grid', name: 'grid', component: Grid },
+ { path: 'intro', name: 'intro', component: Intro, alias: '' },
+ { path: 'start', name: 'start', component: Start },
+ { path: 'changelog', name: 'changelog', component: Changelog }
+ ]
+ },
+ {
+ path: '/',
+ component: SystemEntry,
+ redirect: { name: 'projects' },
+ children: [
+ {
+ path: 'projects',
+ name: 'projects',
+ component: Projects,
+ meta: {
+ title: '项目列表'
+ }
+ },
+ {
+ path: 'account',
+ name: 'account',
+ component: Account,
+ meta: {
+ title: '账号管理'
+ }
+ },
+ {
+ path: 'component-manage',
+ name: 'componentManage',
+ component: ComponentManage,
+ meta: {
+ title: '自定义组件库'
+ }
+ }
+ ]
+ },
+ {
+ path: '/project/:projectId',
+ component: ProjectEntry,
+ children: [
+ {
+ path: '',
+ redirect: { name: 'pageList' }
+ },
+ {
+ path: 'pages',
+ name: 'pageList',
+ component: Page
+ },
+ {
+ path: 'functionManage',
+ name: 'functionManage',
+ component: FunctionManage,
+ meta: {
+ title: '函数库'
+ }
+ },
+ {
+ path: 'member',
+ name: 'memberManage',
+ component: Member
+ }
+ ]
+ },
+ {
+ path: `/project/:projectId/page/:pageId`,
component: MainEntry,
alias: '',
children: [
@@ -48,17 +128,6 @@ const routes = [
}
]
},
- {
- path: '/help',
- component: MainHelpEntry,
- children: [
- { path: 'custom', name: 'custom', component: Custom },
- { path: 'grid', name: 'grid', component: Grid },
- { path: 'intro', name: 'intro', component: Intro, alias: '' },
- { path: 'start', name: 'start', component: Start },
- { path: 'changelog', name: 'changelog', component: Changelog }
- ]
- },
{
path: '*',
name: '404',
diff --git a/paas-ce/lesscode/lib/client/src/store/index.js b/paas-ce/lesscode/lib/client/src/store/index.js
index 07d826166..43f05572f 100644
--- a/paas-ce/lesscode/lib/client/src/store/index.js
+++ b/paas-ce/lesscode/lib/client/src/store/index.js
@@ -14,6 +14,10 @@ import Vuex from 'vuex'
import drag from './modules/drag'
import vueCode from './modules/vue-code'
+import project from './modules/project'
+import components from './modules/components'
+import page from './modules/page'
+import functions from './modules/functions'
import http from '@/api'
import { unifyObjectStyle, json2Query } from '@/common/util'
@@ -23,7 +27,11 @@ const store = new Vuex.Store({
// 模块
modules: {
drag,
- vueCode
+ vueCode,
+ project,
+ components,
+ page,
+ functions
},
// 公共 store
state: {
@@ -84,7 +92,7 @@ const store = new Vuex.Store({
},
getApiData ({ state }, data) {
- return http.post('/data/getApiData', data).then(response => {
+ return http.post('/data/getApiData', data, { globalError: false }).then(response => {
return response
})
},
diff --git a/paas-ce/lesscode/lib/client/src/store/modules/components.js b/paas-ce/lesscode/lib/client/src/store/modules/components.js
new file mode 100644
index 000000000..3507359c9
--- /dev/null
+++ b/paas-ce/lesscode/lib/client/src/store/modules/components.js
@@ -0,0 +1,87 @@
+/**
+ * Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
+ * Copyright (C) 2017-2019 THL A29 Limited, a Tencent company. All rights reserved.
+ * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://opensource.org/licenses/MIT
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * 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 http from '@/api'
+
+export default {
+ namespaced: true,
+ state: {
+ },
+ mutations: {
+ },
+ getters: {
+ },
+ actions: {
+ list (state, params = {}) {
+ return http.get('/component/list', { params }).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ useing (state, params = {}) {
+ return http.get('/component/useing', { params }).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ detail (state, params) {
+ return http.get('/component/detail', { params }).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ create (state, params) {
+ return http.post('/component/create', params).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ update (state, params) {
+ return http.post('/component/update', params).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ upload () {
+ return http.get('/component/upload').then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+
+ categoryList (state) {
+ return http.get('/componentCategory/list').then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+
+ categoryCreate (state, params) {
+ return http.post('/componentCategory/create', params).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ categoryUpdate (state, params) {
+ return http.post('/componentCategory/update', params).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+
+ categoryDelete (stae, params) {
+ return http.delete('/componentCategory/delete', { params }).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ }
+ }
+}
diff --git a/paas-ce/lesscode/lib/client/src/store/modules/drag.js b/paas-ce/lesscode/lib/client/src/store/modules/drag.js
index 911d3de8b..3b40ace7c 100644
--- a/paas-ce/lesscode/lib/client/src/store/modules/drag.js
+++ b/paas-ce/lesscode/lib/client/src/store/modules/drag.js
@@ -35,7 +35,11 @@ export default {
}
},
- functionGroup: [],
+ copyData: {},
+
+ targetHistory: [],
+
+ curHistoryIndex: 0,
copyData: {},
@@ -50,10 +54,6 @@ export default {
setCopyData (state, selectedComponent) {
state.copyData = selectedComponent
},
- setFunctionGroup (state, functionGroup) {
- localStorage.setItem('functionGroup', JSON.stringify(functionGroup))
- state.functionGroup = functionGroup
- },
setDraggableSourceGroup (state, group) {
state.draggableSourceGroup = Object.assign({}, group)
},
@@ -154,72 +154,7 @@ export default {
copyData: state => state.copyData,
astData: state => state.astData,
curSelectedComponentData: state => state.curSelectedComponentData,
- pageData: state => state.pageData,
- functionGroup (state) {
- if (state.functionGroup && state.functionGroup.length) {
- return state.functionGroup
- } else {
- const res = JSON.parse(localStorage.getItem('functionGroup'))
- || [{
- name: '系统方法',
- id: 'system',
- children: [
- {
- name: 'getMockData',
- id: 'getMockData',
- funName: 'getMockData',
- funParam: [],
- funBody: [
- 'this.$http.get("/test/getMockData")',
- '.then((res) => {',
- '\tconst data = JSON.stringify(res)',
- '\talert(data)',
- '})'
- ].join('\n'),
- code: [
- 'function getMockData (res) {',
- '\tthis.$http.get("/test/getMockData")',
- '\t.then((res) => {',
- '\t\treturn res.data',
- '\t})',
- '}'
- ].join('\n')
- },
- {
- name: 'clearData',
- id: 'clearData',
- funName: 'clearData',
- funParam: ['res'],
- funBody: [
- 'return res.data'
- ].join('\n'),
- code: [
- 'function clearData (res) {',
- '\treturn res.data',
- '}'
- ].join('\n')
- }
- ]
- }]
- state.functionGroup = res
- return res
- }
- },
- getMethodById: (state) => (methodId) => {
- let returnMethod = {
- id: '',
- funName: '',
- code: 'function emptyFunc () {}'
- }
- state.functionGroup.forEach((group) => {
- const funChildren = group.children || []
- const method = funChildren.find(x => x.id === methodId)
- if (method) {
- returnMethod = method
- }
- })
- return returnMethod
- }
+ pageData: state => state.pageData
},
actions: {
diff --git a/paas-ce/lesscode/lib/client/src/store/modules/functions.js b/paas-ce/lesscode/lib/client/src/store/modules/functions.js
new file mode 100644
index 000000000..2d1499652
--- /dev/null
+++ b/paas-ce/lesscode/lib/client/src/store/modules/functions.js
@@ -0,0 +1,93 @@
+/**
+ * Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
+ * Copyright (C) 2017-2019 THL A29 Limited, a Tencent company. All rights reserved.
+ * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://opensource.org/licenses/MIT
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * 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 http from '@/api'
+const perfix = '/function'
+
+export default {
+ namespaced: true,
+ state: {
+ funcGroups: []
+ },
+ mutations: {
+ },
+ getters: {
+ funcGroups: state => state.funcGroups
+ },
+ actions: {
+ getAllGroupFuncs ({ state }, projectId) {
+ return http.get(`${perfix}/getAllGroupFunc`, { params: { projectId } }).then((res = {}) => {
+ state.funcGroups = res.data || []
+ })
+ },
+
+ addFunc ({ state }, { groupId, func }) {
+ return http.post(`${perfix}/addFunction`, func).then((res = {}) => {
+ const newFunc = res.data || {}
+ const curGroup = state.funcGroups.find((group) => (group.id === groupId)) || {}
+ curGroup.functionList.unshift(newFunc)
+ return newFunc
+ })
+ },
+
+ deleteFunc ({ state }, { groupId, funcId }) {
+ return http.delete(`${perfix}/deleteFunction`, { params: { id: funcId } }).then(() => {
+ const groups = state.funcGroups
+ const curGroup = groups.find(x => x.id === groupId)
+ const funcIndex = curGroup.functionList.findIndex((func) => (func.id === funcId))
+ curGroup.functionList.splice(funcIndex, 1)
+ })
+ },
+
+ editFunc ({ state }, { groupId, func }) {
+ return http.put(`${perfix}/editFunction`, func).then((res) => {
+ const data = res.data || []
+ const newFunc = data[0] || {}
+ if (newFunc.updateTime !== func.updateTime) {
+ const groups = state.funcGroups
+ const oldGroup = groups.find(x => x.id === groupId)
+ const curFunc = oldGroup.functionList.find(x => x.id === func.id)
+ Object.assign(curFunc, newFunc)
+ const curGroup = groups.find(x => x.id === func.funcGroupId)
+ const oldIndex = oldGroup.functionList.findIndex(x => x.id === func.id)
+ oldGroup.functionList.splice(oldIndex, 1)
+ curGroup.functionList.unshift(curFunc)
+ }
+ return newFunc
+ })
+ },
+
+ addGroup ({ state }, data) {
+ return http.post(`${perfix}/addFuncGroup`, data).then((res = {}) => {
+ const newGroup = res.data || {}
+ state.funcGroups.push(...newGroup)
+ })
+ },
+
+ deleteGroup ({ state }, params) {
+ return http.delete(`${perfix}/deleteFuncGroup`, { params }).then(() => {
+ const index = state.funcGroups.findIndex((group) => (group.id === params.id))
+ state.funcGroups.splice(index, 1)
+ })
+ },
+
+ editGroups ({ state }, groups) {
+ groups = JSON.parse(JSON.stringify(groups))
+ const copyGroups = state.funcGroups
+ groups.forEach((group) => {
+ const curGroup = copyGroups.find(x => x.id === group.id)
+ Object.assign(curGroup, group)
+ })
+ state.funcGroups.sort((pre, next) => (pre.order - next.order))
+ return http.put(`${perfix}/editFuncGroups`, groups)
+ }
+ }
+}
diff --git a/paas-ce/lesscode/lib/client/src/store/modules/page.js b/paas-ce/lesscode/lib/client/src/store/modules/page.js
new file mode 100644
index 000000000..50e28056d
--- /dev/null
+++ b/paas-ce/lesscode/lib/client/src/store/modules/page.js
@@ -0,0 +1,65 @@
+/**
+ * Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
+ * Copyright (C) 2017-2019 THL A29 Limited, a Tencent company. All rights reserved.
+ * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://opensource.org/licenses/MIT
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * 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 http from '@/api'
+
+export default {
+ namespaced: true,
+ state: {
+ },
+ mutations: {
+ },
+ getters: {
+ },
+ actions: {
+ create ({ commit }, { data = {} }) {
+ return http.post('/page/create', data).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ getList ({ commit }, { projectId }) {
+ return http.get(`/page/getList?projectId=${projectId}`).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ update ({ commit }, { data = {} }) {
+ return http.put('/page/update', data).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ copy ({ commit }, { data = {} }) {
+ return http.post('/page/copy', data).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ delete ({ commit }, { pageId }) {
+ return http.delete(`/page/delete?pageId=${pageId}`).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ checkName ({ commit }, { data = {} }) {
+ return http.post('/page/checkName', data).then(response => {
+ return response.data || ''
+ })
+ },
+ detail ({ commit }, { pageId }) {
+ return http.get(`/page/detail?pageId=${pageId}`).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ }
+ }
+}
diff --git a/paas-ce/lesscode/lib/client/src/store/modules/project.js b/paas-ce/lesscode/lib/client/src/store/modules/project.js
new file mode 100644
index 000000000..d127e7bb9
--- /dev/null
+++ b/paas-ce/lesscode/lib/client/src/store/modules/project.js
@@ -0,0 +1,70 @@
+/**
+ * Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
+ * Copyright (C) 2017-2019 THL A29 Limited, a Tencent company. All rights reserved.
+ * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://opensource.org/licenses/MIT
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * 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 http from '@/api'
+
+export default {
+ namespaced: true,
+ state: {
+ currentProject: {}
+ },
+ mutations: {
+ setCurrentProject (state, project) {
+ state.currentProject = Object.assign({}, project)
+ }
+ },
+ getters: {
+ getCurrentProject: state => state.currentProject
+ },
+ actions: {
+ create ({ commit }, { data, config }) {
+ return http.post('/project/create', data, config).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ query ({ commit }, { config }) {
+ return http.get('/project/query', config).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ update ({ commit }, { data, config }) {
+ return http.put('/project/update', data, config).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ delete ({ commit }, { config }) {
+ return http.delete('/project/delete', config).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ favorite ({ commit }, { data, config }) {
+ return http.post('/project/favorite', data, config).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ },
+ checkname ({ commit }, { data, config }) {
+ return http.post('/project/checkname', data, config).then(response => {
+ return response
+ })
+ },
+ detail ({ commit }, { projectId }) {
+ return http.get(`/project/detail?projectId=${projectId}`).then(response => {
+ const data = response.data || ''
+ return data
+ })
+ }
+ }
+}
diff --git a/paas-ce/lesscode/lib/client/src/views/changelog/index.md b/paas-ce/lesscode/lib/client/src/views/changelog/index.md
index 739527023..b1b587a58 100644
--- a/paas-ce/lesscode/lib/client/src/views/changelog/index.md
+++ b/paas-ce/lesscode/lib/client/src/views/changelog/index.md
@@ -2,7 +2,19 @@
-### 0.0.3
+### v0.0.4
+###### 2020.08.14
+
+* **[add]**:
+ - 新增项目管理模块
+ - 新增页面管理模块
+ - 新增函数管理模块
+* **[update]**:
+ - 拖拽画布中的函数管理优化
+
+---
+
+### v0.0.3
###### 2020.06.12
* **[add]**:
@@ -20,7 +32,7 @@
---
-### 0.0.2
+### v0.0.2
###### 2020.05.26
* **[add]**:
@@ -34,7 +46,7 @@
---
-### 0.0.1
+### v0.0.1
###### 2020.04.28
* **[add]**:
diff --git a/paas-ce/lesscode/lib/client/src/views/help/index.css b/paas-ce/lesscode/lib/client/src/views/help/index.css
index 1670bdff6..27adac06a 100644
--- a/paas-ce/lesscode/lib/client/src/views/help/index.css
+++ b/paas-ce/lesscode/lib/client/src/views/help/index.css
@@ -494,12 +494,11 @@ $headerHeight: 64px;
.page-name {
font-size: 16px;
color: #63656E;
- .back {
- font-size: 18px;
- margin-left: 5px;
- cursor: pointer;
- color: #3a84ff;
- }
+ padding-left: 12px;
+ }
+ .app-logo {
+ font-size: 0;
+ cursor: pointer;
}
}
}
diff --git a/paas-ce/lesscode/lib/client/src/views/help/index.vue b/paas-ce/lesscode/lib/client/src/views/help/index.vue
index c6d2bc491..c9da2db78 100644
--- a/paas-ce/lesscode/lib/client/src/views/help/index.vue
+++ b/paas-ce/lesscode/lib/client/src/views/help/index.vue
@@ -15,12 +15,14 @@