Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/builtinComponent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^0.28.0",
"@opentiny/tiny-engine-meta-register": "workspace:*",
"vite-plugin-css-injected-by-js": "^3.3.1"
},
"devDependencies": {
Expand Down
53 changes: 26 additions & 27 deletions packages/builtinComponent/src/components/BaseForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import {
Row as TinyRow,
Col as TinyCol
} from '@opentiny/vue'
import axios from 'axios'
import { getMetaApi, META_SERVICE } from '@opentiny/tiny-engine-meta-register'

const props = defineProps({
style: {
Expand Down Expand Up @@ -115,13 +115,10 @@ const insertApi = (data = modelData.value) => {
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](apiInfo.url, data)
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, { nameEn: formModel.value.nameEn, params: data })
.then((res) => {
if (res.status === 200) {
return res.data
} else {
throw new Error('request fail')
}
return res
})
.catch((err) => {
throw new Error(err)
Expand All @@ -133,13 +130,16 @@ const updateApi = (data = modelData.value) => {
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](apiInfo.url, data)
const id = data.id
delete data.id
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, {
nameEn: formModel.value.nameEn,
data: data,
params: { id }
})
.then((res) => {
if (res.status === 200) {
return res.data
} else {
throw new Error('request fail')
}
return res
})
.catch((err) => {
throw new Error(err)
Expand All @@ -151,32 +151,31 @@ const queryApi = ({ currentPage, pageSize, data } = {}) => {
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](`${apiInfo.url}?currentPage=${currentPage || 1}&pageSize=${pageSize || 10}`, {
params: data || modelData.value
})
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, {
currentPage: currentPage || 1,
pageSize: pageSize || 10,
nameEn: formModel.value.nameEn,
nameCn: formModel.value.nameCn,
params: data || modelData.value
})
.then((res) => {
if (res.status === 200) {
return res.data
}
throw new Error('request fail')
return res
})
.catch((err) => {
throw new Error(err)
})
}

const deleteApi = (evidence = { id: modelData.value?.id }) => {
const deleteApi = () => {
const apiInfo = props.modelApis.find((api) => api.nameEn === 'deleteApi')
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](apiInfo.url, { params: evidence })
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, { id: modelData.value?.id, nameEn: formModel.value.nameEn })
.then((res) => {
if (res.status === 200) {
return res.data
} else {
throw new Error('request fail')
}
return res
})
.catch((err) => {
throw new Error(err)
Expand Down
87 changes: 43 additions & 44 deletions packages/builtinComponent/src/components/BasePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ import {
Notify
} from '@opentiny/vue'
import * as tinyVueIcon from '@opentiny/vue-icon'
import axios from 'axios'
import { getMetaApi, META_SERVICE } from '@opentiny/tiny-engine-meta-register'

const props = defineProps({
style: {
Expand Down Expand Up @@ -302,18 +302,15 @@ const insertApi = (data = addFormData.value) => {
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](apiInfo.url, data)
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, { nameEn: pageModel.value.nameEn, params: data })
.then((res) => {
if (res.status === 200) {
Notify({
type: 'success',
message: res.data.message,
position: 'top-right'
})
return res.data
} else {
throw new Error('request fail')
}
Notify({
type: 'success',
message: '新增成功',
position: 'top-right'
})
return res
})
.catch((err) => {
throw new Error(err)
Expand All @@ -325,18 +322,21 @@ const updateApi = (data = addFormData.value) => {
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](apiInfo.url, data)
const id = data.id
delete data.id
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, {
nameEn: pageModel.value.nameEn,
data: data,
params: { id }
})
.then((res) => {
if (res.status === 200) {
Notify({
type: 'success',
message: res.data.message,
position: 'top-right'
})
return res.data
} else {
throw new Error('request fail')
}
Notify({
type: 'success',
message: '修改成功',
position: 'top-right'
})
return res
})
.catch((err) => {
throw new Error(err)
Expand All @@ -348,17 +348,19 @@ const queryApi = ({ currentPage, pageSize, data } = {}) => {
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](`${apiInfo.url}?currentPage=${currentPage || 1}&pageSize=${pageSize || 10}`, {
params: data || formData.value
})
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, {
currentPage: currentPage || 1,
pageSize: pageSize || 10,
nameEn: pageModel.value.nameEn,
nameCn: pageModel.value.nameCn,
params: data
})
.then((res) => {
if (res.status === 200) {
tableData.value = res.data.data
pagerState.total = res.data.total
emit('update:tableData', tableData.value)
return res.data
}
throw new Error('request fail')
tableData.value = res.list
pagerState.total = res.total
emit('update:tableData', tableData.value)
return res
})
.catch((err) => {
throw new Error(err)
Expand All @@ -370,18 +372,15 @@ const deleteApi = (evidence) => {
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](apiInfo.url, { params: evidence })
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, { ...evidence, nameEn: pageModel.value.nameEn })
.then((res) => {
if (res.status === 200) {
Notify({
type: 'success',
message: res.data.message,
position: 'top-right'
})
return res.data
} else {
throw new Error('request fail')
}
Notify({
type: 'success',
message: '已删除',
position: 'top-right'
})
return res
})
.catch((err) => {
throw new Error(err)
Expand Down
55 changes: 27 additions & 28 deletions packages/builtinComponent/src/components/BaseTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import {
Popover as TinyPopover
} from '@opentiny/vue'
import * as tinyVueIcon from '@opentiny/vue-icon'
import axios from 'axios'
import { getMetaApi, META_SERVICE } from '@opentiny/tiny-engine-meta-register'

const props = defineProps({
style: {
Expand Down Expand Up @@ -169,13 +169,10 @@ const insertApi = (data = {}) => {
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](apiInfo.url, data)
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, { nameEn: tableModel.value.nameEn, params: data })
.then((res) => {
if (res.status === 200) {
return res.data
} else {
throw new Error('request fail')
}
return res
})
.catch((err) => {
throw new Error(err)
Expand All @@ -187,13 +184,16 @@ const updateApi = (data) => {
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](apiInfo.url, data)
const id = data.id
delete data.id
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, {
nameEn: tableModel.value.nameEn,
data: data,
params: { id }
})
.then((res) => {
if (res.status === 200) {
return res.data
} else {
throw new Error('request fail')
}
return res
})
.catch((err) => {
throw new Error(err)
Expand All @@ -207,16 +207,18 @@ const queryApi = (
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](`${apiInfo.url}?currentPage=${currentPage}&pageSize=${pageSize}`, { params: data })
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, {
currentPage: currentPage || 1,
pageSize: pageSize || 10,
nameEn: tableModel.value.nameEn,
nameCn: tableModel.value.nameCn,
params: data
})
.then((res) => {
if (res.status === 200) {
if (res.data.code === 200) {
tableData.value = res.data.data
pagerState.total = res.data.total
return res.data
}
}
throw new Error('request fail')
tableData.value = res.list
pagerState.total = res.total
return res
})
.catch((err) => {
throw new Error(err)
Expand All @@ -228,13 +230,10 @@ const deleteApi = (evidence) => {
if (!apiInfo) {
return undefined
}
return axios[apiInfo.method](apiInfo.url, { params: evidence })
return getMetaApi(META_SERVICE.Http)
.post(apiInfo.url, { ...evidence, nameEn: tableModel.value.nameEn })
.then((res) => {
if (res.status === 200) {
return res.data
} else {
throw new Error('request fail')
}
return res
})
.catch((err) => {
throw new Error(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const activeNames = ref(['request', 'response'])
const ruleFormRef = ref(null)
const methodBasicData = reactive({
url: '',
method: '',
method: 'post',
options: [
{
label: 'GET',
Expand Down Expand Up @@ -174,7 +174,7 @@ const closePopover = () => {

const getModel = (data) => {
selectedModel.value = data
methodBasicData.url = data.baseUrl
methodBasicData.method = 'post'
}
Comment on lines 175 to 178
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Reset selected function and URL on model change

Line 175‑178: getModel now only resets the method. If a previous function was selected, selectedFunction and methodBasicData.url can stay populated, showing stale data for a different model. Clear them when the model changes.

🛠️ Suggested adjustment
 const getModel = (data) => {
   selectedModel.value = data
   methodBasicData.method = 'post'
+  methodBasicData.url = ''
+  selectedFunction.value = null
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const getModel = (data) => {
selectedModel.value = data
methodBasicData.url = data.baseUrl
methodBasicData.method = 'post'
}
const getModel = (data) => {
selectedModel.value = data
methodBasicData.method = 'post'
methodBasicData.url = ''
selectedFunction.value = null
}
🤖 Prompt for AI Agents
In `@packages/configurator/src/model-api-configurator/ModelApiConfigurator.vue`
around lines 175 - 178, getModel currently only sets selectedModel and
methodBasicData.method, which can leave stale values in selectedFunction and
methodBasicData.url; update getModel to also clear selectedFunction (e.g. reset
selectedFunction or selectedFunction.value) and reset methodBasicData.url to an
empty string when switching models, keeping the existing methodBasicData.method
= 'post' behavior and ensuring you clear the reactive references
(selectedFunction and methodBasicData.url) so the UI does not show stale data.


const setModelFunction = async () => {
Expand Down Expand Up @@ -207,6 +207,7 @@ const removeApi = (apiItem) => {

const selectModelFunction = (data) => {
selectedFunction.value = data.row
methodBasicData.url = `${selectedModel.value.baseUrl}/${selectedFunction.value.nameEn}`
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@
<div v-else class="readonly-cell">{{ getFieldTypeLabel(row.type) }}</div>
</template>
</tiny-grid-column>
<tiny-grid-column field="defaultValue" title="默认值" width="120">
<template #default="{ row }">
<div v-if="row.isEditing" class="editing-cell">
<tiny-input v-model="row.defaultValue" placeholder="请输入默认值" size="small" />
</div>
<div v-else class="readonly-cell">{{ row.defaultValue }}</div>
</template>
Comment on lines +89 to +95
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Guard ModelRef defaultValue edits to avoid invalid IDs

Line 91-95: the new defaultValue column uses a free‑text input for all types. For ModelRef, this can conflict with the select in the expanded panel and persist invalid IDs; the read‑only view also shows the raw ID. Consider disabling the inline edit for ModelRef and rendering the label instead.

🛠️ Suggested adjustment
-            <div v-if="row.isEditing" class="editing-cell">
-              <tiny-input v-model="row.defaultValue" placeholder="请输入默认值" size="small" />
-            </div>
-            <div v-else class="readonly-cell">{{ row.defaultValue }}</div>
+            <div v-if="row.isEditing" class="editing-cell">
+              <tiny-input
+                v-model="row.defaultValue"
+                placeholder="请输入默认值"
+                size="small"
+                :disabled="row.type === 'ModelRef'"
+              />
+            </div>
+            <div v-else class="readonly-cell">
+              {{ row.type === 'ModelRef' ? getModelName(row.defaultValue) : row.defaultValue }}
+            </div>
🤖 Prompt for AI Agents
In `@packages/plugins/model-manager/src/components/FieldManager.vue` around lines
89 - 95, The inline edit for the defaultValue column must be disabled for
ModelRef types and the read-only cell should show the referenced model's label
instead of the raw ID: update the tiny-grid-column template (the block using
row.isEditing and row.defaultValue) to conditionally render the tiny-input only
when row.type !== 'ModelRef', and for ModelRef rows render the resolved label
(e.g., use an existing property like row.defaultValueLabel or call a resolver
method such as resolveModelLabel(row.defaultValue)). Ensure any v-model binding
to row.defaultValue is not applied for ModelRef in-line edits so the
expanded-panel select remains the single source of truth and invalid IDs cannot
be persisted.

</tiny-grid-column>
<tiny-grid-column field="required" title="必填" width="60">
<template #default="{ row }">
<div v-if="row.isEditing" class="editing-cell">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const props = defineProps({
})

// 创建本地副本,直接编辑本地数据
const localValue = ref(props.model)
const localValue = ref({ modelUrl: `${import.meta.env.VITE_ORIGIN}/platform-center/api/model-data`, ...props.model })

const ruleFormRef = ref()

Expand All @@ -53,10 +53,7 @@ const rules = ref({
{ min: 1, max: 32, message: '长度在1-32之间', trigger: 'blur' }
],
version: [{ required: true, message: '必填', trigger: 'blur' }],
modelUrl: [
{ required: true, message: '必填', trigger: 'blur' },
{ min: 1, max: 200, message: '长度在1-200之间', trigger: 'blur' }
]
modelUrl: [{ min: 1, max: 200, message: '长度在1-200之间', trigger: 'blur' }]
})

// 监听 props 变化,同步到本地(当选择不同模型时)
Expand Down