Skip to content

Commit 4e1695a

Browse files
committed
feat(model): refactor model manager plugins component
1 parent 940d3c0 commit 4e1695a

13 files changed

Lines changed: 64 additions & 213 deletions

File tree

packages/configurator/src/model-api-configurator/ModelApiConfigurator.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@
1313
<span>选择模型方法</span>
1414
<div class="right">
1515
<tiny-button @click="closePopover">取消</tiny-button>
16-
<tiny-button type="primary" @click="setModelFunction">确定</tiny-button>
16+
<tiny-button type="primary" @click="setModelFunction" :disabled="!selectedFunction">确定</tiny-button>
1717
<tiny-icon-close class="tiny-svg-size" @click="closePopover"></tiny-icon-close>
1818
</div>
1919
</div>
2020
<div class="model-set-wrap">
2121
<div class="model-wrap">
2222
<div class="model-groups">
23-
<model-select :model-page-size="5" @model-select="getModel" :meta="meta" :isShow="isShow"></model-select>
23+
<model-select
24+
:model-page-size="5"
25+
@model-select="getModel"
26+
:meta="meta"
27+
:isShow="isShow"
28+
:isModelApi="true"
29+
></model-select>
2430
</div>
2531
<div class="model-parameters">
2632
<tiny-grid

packages/configurator/src/model-common/ModelSelect.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export default {
5454
isShow: {
5555
type: Boolean,
5656
default: false
57+
},
58+
isModelApi: {
59+
type: Boolean,
60+
default: false
5761
}
5862
},
5963
emits: ['modelSelect'],
@@ -90,8 +94,20 @@ export default {
9094
9195
const selectModel = async (data) => {
9296
// 处理parameters
93-
currentSelectedModel.value = await handleSelectedModelParameters(data.row)
94-
emit('modelSelect', currentSelectedModel.value)
97+
if (props.isModelApi) {
98+
emit('modelSelect', {
99+
id: data.row.id,
100+
name: data.row.nameCn,
101+
nameEn: data.row.nameEn,
102+
description: data.row.description,
103+
version: data.row.version,
104+
baseUrl: data.row.modelUrl ?? '',
105+
method: data.row.method
106+
})
107+
} else {
108+
currentSelectedModel.value = await handleSelectedModelParameters(data.row)
109+
emit('modelSelect', currentSelectedModel.value)
110+
}
95111
}
96112
97113
watch(

packages/configurator/src/model-common/utils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ export const handleSelectedModelParameters = async (model) => {
4646
description: model.description,
4747
version: model.version,
4848
baseUrl: model.modelUrl ?? '',
49-
parameters,
50-
method: model.method
49+
parameters
5150
}
5251
: parameters
5352
}

packages/configurator/src/model-configurator/ModelConfigurator.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ const searchUnused = ref('')
216216
const searchValue = ref('')
217217
218218
const selectedModel = ref()
219+
const originModelData = ref()
219220
220221
const getModel = (data) => {
221222
selectedModel.value = data
222223
}
223224
224-
const originModelData = ref()
225225
const modelDetail = ref(props.meta.widget.props.modelValue)
226226
227227
const unusedParameters = ref([])

packages/design-core/assets/plugin-icon-modelmanager.svg

Lines changed: 1 addition & 1 deletion
Loading

packages/plugins/model-manager/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import entry from './src/Main.vue'
22
import metaData from './meta'
3+
import './src/styles/vars.less'
34

45
export default {
56
...metaData,

packages/plugins/model-manager/meta.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ export default {
22
id: 'engine.plugins.modelmanager',
33
title: '模型管理',
44
type: 'plugins',
5-
width: 600,
5+
width: 280,
66
icon: 'plugin-icon-modelmanager'
77
}

packages/plugins/model-manager/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"license": "MIT",
3030
"homepage": "https://opentiny.design/tiny-engine",
3131
"dependencies": {
32-
"@opentiny/tiny-engine-meta-register": "workspace:*"
32+
"@opentiny/tiny-engine-meta-register": "workspace:*",
33+
"@opentiny/tiny-engine-common": "workspace:*"
3334
},
3435
"devDependencies": {
3536
"@opentiny/tiny-engine-vite-plugin-meta-comments": "workspace:*",

packages/plugins/model-manager/src/Main.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</div>
4343
</div>
4444
</template>
45-
<div v-else class="empty-tip">当前数据为空,请先添加模型</div>
45+
<search-empty v-else />
4646
</div>
4747
</template>
4848
</plugin-panel>
@@ -59,7 +59,7 @@
5959
import { ref, reactive, provide, computed, onMounted } from 'vue'
6060
import { TinySearch, Modal } from '@opentiny/vue'
6161
import { IconSearch } from '@opentiny/vue-icon'
62-
import { PluginPanel, SvgButton } from '@opentiny/tiny-engine-common'
62+
import { PluginPanel, SvgButton, SearchEmpty } from '@opentiny/tiny-engine-common'
6363
import { useLayout } from '@opentiny/tiny-engine-meta-register'
6464
import ModelSetting, { openModelSettingPanel, closeModelSettingPanel } from './components/ModelSetting.vue'
6565
import { getModelList, deleteModel, getModelSql, getModelSqlById } from './composable/useModelManager'
@@ -213,13 +213,13 @@ onMounted(async () => {
213213
align-items: center;
214214
215215
&:hover {
216-
background-color: var(--te-page-manage-draggable-row-bg-color-hover);
217-
color: var(--te-page-manage-draggable-text-color);
216+
background-color: var(--te-model-manage-draggable-row-bg-color-hover);
217+
color: var(--te-model-manage-draggable-text-color);
218218
}
219219
220220
&.active {
221-
background-color: var(--te-page-manage-draggable-row-bg-color-hover);
222-
color: var(--te-page-manage-draggable-text-color);
221+
background-color: var(--te-model-manage-draggable-row-bg-color-hover);
222+
color: var(--te-model-manage-draggable-text-color);
223223
}
224224
225225
svg {
@@ -239,7 +239,7 @@ onMounted(async () => {
239239
}
240240
.model-desc {
241241
font-size: 12px;
242-
color: var(--te-page-manage-tip-text-color);
242+
color: var(--te-model-manage-tip-text-color);
243243
display: -webkit-box;
244244
overflow: hidden;
245245
}

packages/plugins/model-manager/src/components/FieldManager.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,15 @@ defineExpose({
281281
}
282282
283283
:deep(.tiny-grid-body__expanded-row) {
284-
background-color: var(--te-page-manage-input-bg-color);
284+
background-color: var(--te-model-manage-input-bg-color);
285285
}
286286
.expand-section {
287287
margin-bottom: 16px;
288288
289289
h4 {
290290
font-size: 14px;
291291
font-weight: 600;
292-
color: var(--te-page-manage-title-text-color);
292+
color: var(--te-model-manage-title-text-color);
293293
margin: 0 0 8px 0;
294294
padding-bottom: 1px;
295295
}
@@ -299,7 +299,7 @@ defineExpose({
299299
align-items: center;
300300
margin-bottom: 8px;
301301
padding: 8px;
302-
background-color: var(--te-page-manage-input-bg-color);
302+
background-color: var(--te-model-manage-input-bg-color);
303303
border-radius: 4px;
304304
}
305305

0 commit comments

Comments
 (0)