Skip to content

Commit bba90d2

Browse files
youngbeom-shin申永范-UX
andauthored
feat(models): enhance model settings UI and logic (#1349)
* feat(models): enhance model settings UI and logic * feat(models): enhance model settings UI and logic --------- Co-authored-by: 申永范-UX <[email protected]>
1 parent 07d325e commit bba90d2

File tree

1 file changed

+48
-22
lines changed

1 file changed

+48
-22
lines changed

frontend/src/components/models/ModelSettings.vue

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<div
3-
class="my-8 md:my-0 md:border-none py-6">
3+
class="flex flex-col gap-6 my-8 md:my-0 md:border-none py-6">
44
<!-- 展示英文名 -->
5-
<div class="flex xl:flex-col gap-8">
6-
<div class="w-[380px] sm:w-full flex flex-col">
5+
<div class="flex lg:flex-col gap-8 lg:gap-1">
6+
<div class="w-[380px] lg:w-[512px] sm:w-full flex flex-col">
77
<div class="text-sm text-gray-700 leading-5 font-medium">
88
{{ $t('models.modelName') }}
99
</div>
@@ -22,11 +22,9 @@
2222
</div>
2323
</div>
2424

25-
<el-divider />
26-
2725
<!-- 更新模型别名 -->
28-
<div class="flex xl:flex-col gap-8">
29-
<div class="w-[380px] sm:w-full flex flex-col">
26+
<div class="flex lg:flex-col gap-8 lg:gap-1">
27+
<div class="w-[380px] lg:w-[512px] sm:w-full flex flex-col">
3028
<div class="text-sm text-gray-700 leading-5 font-medium">
3129
{{ $t('models.modelNickName') }}
3230
</div>
@@ -41,18 +39,17 @@
4139
size="large"
4240
class="!w-[512px] sm:!w-full" />
4341
<CsgButton
42+
v-if="hasNicknameChanged"
4443
@click="updateNickname"
4544
class="btn btn-secondary-gray btn-sm w-fit"
4645
:name="$t('all.update')"
4746
/>
4847
</div>
4948
</div>
5049

51-
<el-divider />
52-
5350
<!-- 更新模型简介 -->
54-
<div class="flex xl:flex-col gap-8">
55-
<div class="w-[380px] sm:w-full flex flex-col">
51+
<div class="flex lg:flex-col gap-8 lg:gap-1">
52+
<div class="w-[380px] lg:w-[512px] sm:w-full flex flex-col">
5653
<div class="text-sm text-gray-700 leading-5 font-medium">
5754
{{ $t('models.modelDesc') }}
5855
</div>
@@ -68,6 +65,7 @@
6865
type="textarea"
6966
class="!w-[512px] sm:!w-full" />
7067
<CsgButton
68+
v-if="hasDescChanged"
7169
@click="updateModelDesc"
7270
class="btn btn-secondary-gray btn-sm w-fit"
7371
:name="$t('all.update')"
@@ -78,8 +76,8 @@
7876
<el-divider />
7977

8078
<!-- 模型标签 -->
81-
<div class="flex xl:flex-col gap-8">
82-
<div class="w-[380px] sm:w-full flex flex-col">
79+
<div class="flex lg:flex-col gap-8 lg:gap-1">
80+
<div class="w-[380px] lg:w-[512px] sm:w-full flex flex-col">
8381
<div class="text-sm text-gray-700 leading-5 font-medium">
8482
{{ $t('models.modelTag') }}
8583
</div>
@@ -125,6 +123,7 @@
125123
</p>
126124
</div>
127125
<CsgButton
126+
v-if="hasTagsChanged"
128127
@click="updateTags"
129128
class="btn btn-secondary-gray btn-sm w-fit"
130129
:name="$t('all.update')"
@@ -135,11 +134,9 @@
135134
</div>
136135
</div>
137136

138-
<el-divider />
139-
140137
<!-- 行业标签 -->
141-
<div class="flex xl:flex-col gap-8">
142-
<div class="w-[380px] sm:w-full flex flex-col">
138+
<div class="flex lg:flex-col gap-8 lg:gap-1">
139+
<div class="w-[380px] lg:w-[512px] sm:w-full flex flex-col">
143140
<div class="text-sm text-gray-700 leading-5 font-medium">
144141
{{ $t('models.modelIndustryTag') }}
145142
</div>
@@ -189,6 +186,7 @@
189186
</p>
190187
</div>
191188
<CsgButton
189+
v-if="hasIndustryTagsChanged"
192190
@click="updateIndustryTags"
193191
class="btn btn-secondary-gray btn-sm w-fit"
194192
:name="$t('all.update')"
@@ -202,8 +200,8 @@
202200
<el-divider />
203201

204202
<!-- 修改可见性 -->
205-
<div class="flex xl:flex-col gap-8">
206-
<div class="w-[380px] sm:w-full flex flex-col">
203+
<div class="flex lg:flex-col gap-8 lg:gap-1">
204+
<div class="w-[380px] lg:w-[512px] sm:w-full flex flex-col">
207205
<div class="text-sm text-gray-700 leading-5 font-medium">
208206
{{ $t('models.edit.changeVisibility') }}
209207
</div>
@@ -240,11 +238,10 @@
240238
</div>
241239
</div>
242240

243-
<el-divider />
244241

245242
<!-- 删除模型 -->
246-
<div class="flex xl:flex-col gap-8">
247-
<div class="w-[380px] sm:w-full flex flex-col gap-1.5">
243+
<div class="flex lg:flex-col gap-8 lg:gap-1">
244+
<div class="w-[380px] lg:w-[512px] sm:w-full flex flex-col gap-1.5">
248245
<div class="text-sm text-gray-700 leading-5 font-medium">
249246
{{ $t('models.edit.delModel') }}
250247
</div>
@@ -324,11 +321,33 @@
324321
],
325322
isUpdatingTags: false,
326323
isUpdatingIndustryTags: false,
324+
originalModelNickname: this.modelNickname || '',
325+
originalModelDesc: this.modelDesc || '',
326+
originalTags: [],
327+
originalIndustryTags: [],
327328
}
328329
},
329330
computed: {
330331
...mapState(useRepoDetailStore, ['isPrivate']),
331332
...mapWritableState(useRepoDetailStore, ['privateVisibility']),
333+
hasNicknameChanged() {
334+
return this.theModelNickname.trim() !== this.originalModelNickname.trim()
335+
},
336+
hasDescChanged() {
337+
return this.theModelDesc.trim() !== this.originalModelDesc.trim()
338+
},
339+
hasTagsChanged() {
340+
if (this.originalTags.length !== this.selectedTags.length) return true
341+
const originalTagIds = this.originalTags.map(tag => tag.uid).sort()
342+
const currentTagIds = this.selectedTags.map(tag => tag.uid).sort()
343+
return JSON.stringify(originalTagIds) !== JSON.stringify(currentTagIds)
344+
},
345+
hasIndustryTagsChanged() {
346+
if (this.originalIndustryTags.length !== this.selectedIndustryTags.length) return true
347+
const originalTagIds = this.originalIndustryTags.map(tag => tag.uid).sort()
348+
const currentTagIds = this.selectedIndustryTags.map(tag => tag.uid).sort()
349+
return JSON.stringify(originalTagIds) !== JSON.stringify(currentTagIds)
350+
},
332351
visibilityName: {
333352
get() {
334353
return !!this.privateVisibility ? 'Private' : 'Public'
@@ -408,6 +427,13 @@
408427
return tag
409428
})
410429
]
430+
// Store original values for comparison
431+
if (this.originalTags.length === 0) {
432+
this.originalTags = JSON.parse(JSON.stringify(this.selectedTags))
433+
}
434+
if (this.originalIndustryTags.length === 0) {
435+
this.originalIndustryTags = JSON.parse(JSON.stringify(this.selectedIndustryTags))
436+
}
411437
},
412438
clickDelete() {
413439
if (this.delDesc === this.modelPath) {

0 commit comments

Comments
 (0)