Skip to content

Commit 48b787f

Browse files
committed
Merge remote-tracking branch 'open-tiny-engine/develop' into fix/auth-refresh
2 parents c0b4a9e + 1e8cd29 commit 48b787f

17 files changed

Lines changed: 1536 additions & 1189 deletions

File tree

designer-demo/public/mock/bundle.json

Lines changed: 1276 additions & 13 deletions
Large diffs are not rendered by default.

mockServer/src/database/apps.db

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{"id":16,"createdBy":"6","lastUpdatedBy":"6","tenantId":"1","renterId":null,"siteId":null,"name":"dashboard","appWebsite":null,"platformHistoryId":"1","publishUrl":null,"editorUrl":null,"visitUrl":null,"assetsUrl":"template-cover-1","state":null,"homePage":null,"css":null,"config":{},"constants":null,"dataHandler":{},"description":"数据看板","latest":null,"gitGroup":null,"projectName":null,"branch":null,"isDemo":null,"isDefault":null,"templateType":null,"isTemplate":null,"industryId":null,"sceneId":null,"setTemplateTime":null,"setTemplateBy":null,"setDefaultBy":null,"framework":"Vue","defaultLang":null,"extendConfig":{},"dataHash":null,"canAssociate":null,"industry":[],"scene":[],"created_at":"2026-01-15 02:35:32","updated_at":"2026-01-15 02:35:32","platform":1,"image_url":null,"published":false,"global_state":[],"data_source_global":{},"_id":"epHKwpqjCPamtee4"}
2+
{"id":1,"createdBy":"1","lastUpdatedBy":"1","tenantId":"1","renterId":null,"siteId":"1","name":"portal-app","appWebsite":null,"platformHistoryId":"1","publishUrl":null,"editorUrl":null,"visitUrl":null,"assetsUrl":null,"state":null,"homePage":0,"css":null,"config":{},"constants":null,"dataHandler":{"type":"JSFunction","value":"function dataHanlder(res){\n return res;\n}"},"description":"demo应用","latest":"22","gitGroup":null,"projectName":null,"branch":"develop","isDemo":null,"isDefault":null,"templateType":"serviceDevelop","isTemplate":null,"industryId":null,"sceneId":null,"setTemplateTime":"2023-11-19T18:14:37","setTemplateBy":"1","setDefaultBy":"1","framework":"Vue","defaultLang":null,"extendConfig":{"business":{"serviceName":"","endpointName":"cce","endpointId":"ee","serviceId":"ee","router":"ee"},"env":{"alpha":{"regions":[{"name":"","baseUrl":"","isDefault":false}],"isDefault":true}},"type":"console"},"dataHash":"8b0eba6ad055532a586f9f669108fabb","canAssociate":"1","industry":[],"scene":[],"created_at":"2024-10-16 23:27:10","updated_at":"2024-10-16 23:27:10","platform":1,"image_url":null,"published":false,"global_state":[{"id":"test2","state":{"name1":"xxx1"},"getters":{"count":{"type":"JSFunction","value":"function count() {}"}},"actions":{"actions":{"type":"JSFunction","value":"function actions() {}"}}},{"id":"test3","state":{"name1":"xxx"},"getters":{"count":{"type":"JSFunction","value":"function count() {}"}},"actions":{"actions":{"type":"JSFunction","value":"function actions() {}"}}},{"id":"test4","state":{"region":"","scenario":"all","productId":"","planId":"","addEvs":false,"addHss":false,"addCbr":false,"period":{"value":1,"unit":"month"},"amount":1},"getters":{},"actions":{}},{"id":"test1","state":{"name1":"xxx"},"getters":{"count":{"type":"JSFunction","value":"function count() {}"}},"actions":{"actions":{"type":"JSFunction","value":"function actions() {}"}}}],"data_source_global":{"dataHandler":{"type":"JSFunction","value":"function dataHanlder(res){\n return res;\n}"}},"_id":"fBJD5wIbfFVsUdiQ"}

mockServer/src/database/appsSchema.db

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

mockServer/src/mock/get/app-center/v1/apps/schema/16.json

Lines changed: 1 addition & 971 deletions
Large diffs are not rendered by default.

mockServer/src/routes/main-routes.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ router.post('block-history/create', async (ctx) => {
225225
})
226226

227227
router.get('/app-center/api/apps/page', async (ctx) => {
228-
const { appId } = ctx.params
229-
ctx.body = await mockService.appsService.list(appId)
228+
const { name, orderBy, createdBy } = ctx.query
229+
ctx.body = await mockService.appsService.list(name, orderBy, createdBy)
230230
})
231231

232232
router.post('/app-center/api/apps/create', async (ctx) => {
@@ -238,6 +238,18 @@ router.get('/app-center/api/apps/delete/:id', async (ctx) => {
238238
ctx.body = await mockService.appsService.delete(id)
239239
})
240240

241+
// 获取app详情
242+
router.get('/app-center/api/apps/detail/:id', async (ctx) => {
243+
const { id } = ctx.params
244+
ctx.body = await mockService.appsService.find(id)
245+
})
246+
247+
// 获取appSchema
248+
router.get('/app-center/v1/api/apps/schema/:id', async (ctx) => {
249+
const { id } = ctx.params
250+
ctx.body = await mockService.appsService.findSchema(id)
251+
})
252+
241253
router.get('/app-center/api/app-template/list', async (ctx) => {
242254
ctx.body = await mockService.templateService.list(ctx.request.body)
243255
})

mockServer/src/services/apps.js

Lines changed: 84 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
*
1111
*/
1212

13-
import { getResponseData } from '../tool/Common'
14-
import list from '../assets/json/apps.json'
13+
import DateStore from '@seald-io/nedb'
14+
import { getDatabasePath, getResponseData } from '../tool/Common'
15+
import defaultAppSchema from '../mock/get/app-center/v1/apps/schema/16.json'
1516

1617
const defaultApp = {
1718
createdBy: '86',
@@ -62,41 +63,105 @@ const defaultApp = {
6263

6364
export default class AppsService {
6465
constructor() {
65-
this.appList = { ...list }
66+
this.db = new DateStore({
67+
filename: getDatabasePath('apps.db'),
68+
autoload: true
69+
})
70+
71+
this.db.ensureIndex({
72+
fieldName: '_id',
73+
unique: true
74+
})
75+
76+
this.schemaDb = new DateStore({
77+
filename: getDatabasePath('appsSchema.db'),
78+
autoload: true
79+
})
80+
81+
this.schemaDb.ensureIndex({
82+
fieldName: '_id',
83+
unique: true
84+
})
85+
86+
this.appList = []
6687
}
6788

6889
async create(params) {
69-
let mockId = this.appList.apps.length > 0 ? Math.max(...this.appList.apps.map((item) => item.id)) + 1 : 3
90+
let mockId = this.appList.length > 0 ? Math.max(...this.appList.map((item) => item.id)) + 1 : 3
7091
const newApp = {
7192
...defaultApp,
93+
created_at: new Date().toISOString(),
94+
updated_at: new Date().toISOString(),
7295
id: mockId++,
7396
...params
7497
}
75-
this.appList.apps.push(newApp)
98+
this.db.insert(newApp)
99+
100+
let resultStr = JSON.stringify(defaultAppSchema.data)
101+
resultStr = resultStr.replace(/"lowcode./g, '"lowcode_')
102+
const modifiedResult = JSON.parse(resultStr)
103+
const newAppSchema = {
104+
...modifiedResult,
105+
meta: {
106+
...modifiedResult.meta,
107+
name: params.name,
108+
description: params.description,
109+
appId: String(newApp.id),
110+
gmt_create: newApp.created_at,
111+
gmt_modified: newApp.updated_at
112+
},
113+
id: newApp.id
114+
}
115+
this.schemaDb.insert(newAppSchema)
76116
return getResponseData(newApp)
77117
}
78118

79119
async delete(id) {
80-
this.appList.apps = this.appList.apps.filter((item) => Number(item.id) !== Number(id))
81-
82-
return getResponseData(this.appList)
83-
}
120+
const result = await this.db.findOneAsync({ id: Number(id) })
121+
await this.db.removeAsync({ id: Number(id) })
84122

85-
async list() {
86-
return getResponseData(this.appList)
123+
await this.schemaDb.removeAsync({ id: Number(id) })
124+
return getResponseData(result)
87125
}
88126

89-
async update(id, params) {
90-
const index = this.appList.apps.findIndex((item) => Number(item.id) === Number(id))
91-
if (index === -1) {
92-
return getResponseData({ success: false, message: '未找到应用' })
127+
async list(name, orderBy, createdBy) {
128+
let query = {}
129+
130+
if (name) {
131+
query.name = { $regex: new RegExp(name, 'i') }
93132
}
94133

95-
this.appList.apps[index] = {
96-
...this.appList.apps[index],
97-
...params
134+
const result = await this.db.findAsync(query)
135+
this.appList = result.sort((a, b) => new Date(a.created_at) - new Date(b.created_at))
136+
137+
if (createdBy) {
138+
this.appList = this.appList.filter((item) => item.createdBy === '86')
98139
}
99140

100-
return getResponseData(this.appList.apps[index])
141+
if (orderBy === 'last_updated_time') {
142+
this.appList.sort((a, b) => new Date(a.updated_at) - new Date(b.updated_at))
143+
}
144+
145+
return getResponseData({ apps: this.appList })
146+
}
147+
148+
async update(id, params) {
149+
await this.db.updateAsync({ id: Number(id) }, { $set: params })
150+
const result = await this.db.findOneAsync({ id: Number(id) })
151+
return getResponseData(result)
152+
}
153+
154+
async find(id) {
155+
const result = await this.db.findOneAsync({ id: Number(id) })
156+
return getResponseData(result)
157+
}
158+
159+
async findSchema(id) {
160+
const result = await this.schemaDb.findOneAsync({ id: Number(id) })
161+
let resultStr = JSON.stringify(result)
162+
resultStr = resultStr.replace(/"lowcode_/g, '"lowcode.')
163+
const modifiedResult = JSON.parse(resultStr)
164+
165+
return { data: modifiedResult, locale: 'zh-cn' }
101166
}
102167
}

packages/builtinComponent/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"preview": "vite preview"
2323
},
2424
"dependencies": {
25-
"axios": "^0.28.0",
25+
"@opentiny/tiny-engine-meta-register": "workspace:*",
2626
"vite-plugin-css-injected-by-js": "^3.3.1"
2727
},
2828
"devDependencies": {

packages/builtinComponent/src/components/BaseForm.vue

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import {
6262
Row as TinyRow,
6363
Col as TinyCol
6464
} from '@opentiny/vue'
65-
import axios from 'axios'
65+
import { getMetaApi, META_SERVICE } from '@opentiny/tiny-engine-meta-register'
6666
6767
const props = defineProps({
6868
style: {
@@ -115,14 +115,8 @@ const insertApi = (data = modelData.value) => {
115115
if (!apiInfo) {
116116
return undefined
117117
}
118-
return axios[apiInfo.method](apiInfo.url, data)
119-
.then((res) => {
120-
if (res.status === 200) {
121-
return res.data
122-
} else {
123-
throw new Error('request fail')
124-
}
125-
})
118+
return getMetaApi(META_SERVICE.Http)
119+
.post(apiInfo.url, { nameEn: formModel.value.nameEn, params: data })
126120
.catch((err) => {
127121
throw new Error(err)
128122
})
@@ -133,13 +127,13 @@ const updateApi = (data = modelData.value) => {
133127
if (!apiInfo) {
134128
return undefined
135129
}
136-
return axios[apiInfo.method](apiInfo.url, data)
137-
.then((res) => {
138-
if (res.status === 200) {
139-
return res.data
140-
} else {
141-
throw new Error('request fail')
142-
}
130+
const id = data.id
131+
delete data.id
132+
return getMetaApi(META_SERVICE.Http)
133+
.post(apiInfo.url, {
134+
nameEn: formModel.value.nameEn,
135+
data: data,
136+
params: { id }
143137
})
144138
.catch((err) => {
145139
throw new Error(err)
@@ -151,33 +145,31 @@ const queryApi = ({ currentPage, pageSize, data } = {}) => {
151145
if (!apiInfo) {
152146
return undefined
153147
}
154-
return axios[apiInfo.method](`${apiInfo.url}?currentPage=${currentPage || 1}&pageSize=${pageSize || 10}`, {
155-
params: data || modelData.value
156-
})
157-
.then((res) => {
158-
if (res.status === 200) {
159-
return res.data
148+
// 处理查询参数
149+
const params = Object.fromEntries(formModel.value.parameters.map((item) => [item.prop, null]))
150+
return getMetaApi(META_SERVICE.Http)
151+
.post(apiInfo.url, {
152+
currentPage: currentPage || 1,
153+
pageSize: pageSize || 10,
154+
nameEn: formModel.value.nameEn,
155+
nameCn: formModel.value.nameCn,
156+
params: {
157+
...params,
158+
...(data || modelData.value)
160159
}
161-
throw new Error('request fail')
162160
})
163161
.catch((err) => {
164162
throw new Error(err)
165163
})
166164
}
167165
168-
const deleteApi = (evidence = { id: modelData.value?.id }) => {
166+
const deleteApi = () => {
169167
const apiInfo = props.modelApis.find((api) => api.nameEn === 'deleteApi')
170168
if (!apiInfo) {
171169
return undefined
172170
}
173-
return axios[apiInfo.method](apiInfo.url, { params: evidence })
174-
.then((res) => {
175-
if (res.status === 200) {
176-
return res.data
177-
} else {
178-
throw new Error('request fail')
179-
}
180-
})
171+
return getMetaApi(META_SERVICE.Http)
172+
.post(apiInfo.url, { id: modelData.value?.id, nameEn: formModel.value.nameEn })
181173
.catch((err) => {
182174
throw new Error(err)
183175
})

0 commit comments

Comments
 (0)