Skip to content

Conversation

@betterdancing
Copy link
Contributor

@betterdancing betterdancing commented Jan 30, 2026

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

原有模型驱动没有内置的增删改查接口,需要用户自定义接口

Issue Number: N/A

What is the new behavior?

后端内置了增删改查接口,前端改动自动匹配对应接口,如果需要修改为自己的接口就改动baseUrl即可

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added default value column to field configuration UI.
  • Refactor

    • Centralized API request handling across form and table components for improved consistency.
    • Updated model API configuration to default HTTP method to POST.
    • Made model URL field optional with automatic population.
  • Chores

    • Replaced internal dependency with centralized API registry module.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions github-actions bot added the enhancement New feature or request label Jan 30, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

Walkthrough

The pull request replaces direct axios HTTP calls with a centralized meta API abstraction (getMetaApi) across form and table components, updates API request/response handling patterns, adjusts default values and validation rules, and adds a default value field to the field management interface.

Changes

Cohort / File(s) Summary
Dependency Management
packages/builtinComponent/package.json
Replaced axios dependency with @opentiny/tiny-engine-meta-register workspace reference.
API Refactoring - CRUD Components
packages/builtinComponent/src/components/BaseForm.vue, BasePage.vue, BaseTable.vue
Systematically replaced direct axios calls with centralized getMetaApi(META_SERVICE.Http) for all CRUD operations (insert, update, query, delete). Restructured payloads to include nameEn, nameCn, and params; removed status-code checks; returns raw response objects. Each component has slight variations in payload structure and success notification handling.
API Configuration Updates
packages/configurator/src/model-api-configurator/ModelApiConfigurator.vue
Changed method default value from empty string to 'post'; adjusted URL composition logic to build URL from baseUrl and selected function's nameEn during function selection instead of model selection.
Field Management UI
packages/plugins/model-manager/src/components/FieldManager.vue
Added new "默认值" (default value) column to field grid with input binding in edit mode and readonly display otherwise.
Form Configuration
packages/plugins/model-manager/src/components/ModelBasicForm.vue
Introduced default modelUrl derived from VITE_ORIGIN environment variable; made modelUrl field optional by removing required validation constraint while retaining length constraints.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Our axios friends have taken flight,
A meta API shines so bright,
With nameEn and params in hand,
The refactored calls now stand,
Default values find their place,
In this cleaner, swifter space!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: optimizing the model driver and adding built-in CRUD interfaces, which aligns with all major changes across multiple component files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

🧪 Unit Test Generation v2 is now available!

We have significantly improved our unit test generation capabilities.

To enable: Add this to your .coderabbit.yaml configuration:

reviews:
  finishing_touches:
    unit_tests:
      enabled: true

Try it out by using the @coderabbitai generate unit tests command on your code files or under ✨ Finishing Touches on the walkthrough!

Have feedback? Share your thoughts on our Discord thread!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
packages/plugins/model-manager/src/components/ModelBasicForm.vue (1)

42-64: ⚠️ Potential issue | 🟡 Minor

Preserve the default modelUrl on model switches

Line 42 and Line 60‑64: localValue initially merges the default modelUrl, but the watcher replaces it with newModel, which drops the default when modelUrl is absent. That makes the field empty after switching models. Reapply the default in the watcher (and avoid undefined/... when the env var is missing).

🛠️ Suggested adjustment
-const localValue = ref({ modelUrl: `${import.meta.env.VITE_ORIGIN}/platform-center/api/model-data`, ...props.model })
+const origin = import.meta.env.VITE_ORIGIN ?? ''
+const defaultModelUrl = `${origin}/platform-center/api/model-data`
+const localValue = ref({ modelUrl: defaultModelUrl, ...props.model })
...
-  (newModel) => {
-    localValue.value = newModel
-  },
+  (newModel) => {
+    localValue.value = { modelUrl: defaultModelUrl, ...newModel }
+  },
packages/builtinComponent/src/components/BaseForm.vue (1)

128-140: ⚠️ Potential issue | 🟠 Major

Avoid mutating form state by deleting id

Line 133‑139: delete data.id mutates the reactive model (modelData.value) and can drop the id needed for later update/delete flows. Build a copy for the payload instead.

🛠️ Suggested adjustment
-  const id = data.id
-  delete data.id
+  const { id, ...payload } = data ? { ...data } : {}
   return getMetaApi(META_SERVICE.Http)
     .post(apiInfo.url, {
       nameEn: formModel.value.nameEn,
-      data: data,
+      data: payload,
       params: { id }
     })
packages/builtinComponent/src/components/BaseTable.vue (1)

167-175: ⚠️ Potential issue | 🔴 Critical

Fix undefined tableModel references in CRUD helpers

Line 173/191/214/234: tableModel is not declared (only TableModel exists). Any CRUD call will throw a ReferenceError. Use TableModel consistently.

🛠️ Suggested adjustment
-    .post(apiInfo.url, { nameEn: tableModel.value.nameEn, params: data })
+    .post(apiInfo.url, { nameEn: TableModel.value.nameEn, params: data })
...
-      nameEn: tableModel.value.nameEn,
+      nameEn: TableModel.value.nameEn,
...
-      nameEn: tableModel.value.nameEn,
-      nameCn: tableModel.value.nameCn,
+      nameEn: TableModel.value.nameEn,
+      nameCn: TableModel.value.nameCn,
...
-    .post(apiInfo.url, { ...evidence, nameEn: tableModel.value.nameEn })
+    .post(apiInfo.url, { ...evidence, nameEn: TableModel.value.nameEn })

Also applies to: 182-194, 203-216, 228-235

packages/builtinComponent/src/components/BasePage.vue (1)

320-332: ⚠️ Potential issue | 🟠 Major

Don’t delete id from edit form data

Line 325‑332: updateApi removes data.id in place, which mutates addFormData and can cause the dialog to lose the record id. Use a payload copy without mutating form state.

🛠️ Suggested adjustment
-  const id = data.id
-  delete data.id
+  const { id, ...payload } = data ? { ...data } : {}
   return getMetaApi(META_SERVICE.Http)
     .post(apiInfo.url, {
       nameEn: pageModel.value.nameEn,
-      data: data,
+      data: payload,
       params: { id }
     })
🤖 Fix all issues with AI agents
In `@packages/configurator/src/model-api-configurator/ModelApiConfigurator.vue`:
- Around line 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.

In `@packages/plugins/model-manager/src/components/FieldManager.vue`:
- Around line 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.

Comment on lines 175 to 178
const getModel = (data) => {
selectedModel.value = data
methodBasicData.url = data.baseUrl
methodBasicData.method = 'post'
}
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.

Comment on lines +89 to +95
<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>
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant