Skip to content

Commit 220d515

Browse files
authored
feat(ai): support regenerating image (#1024)
1 parent 2475209 commit 220d515

File tree

4 files changed

+205
-90
lines changed

4 files changed

+205
-90
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151

5252
### 🎯 编辑体验
5353

54-
-**语法扩展** - 高亮(==文本==)、下划线(++文本++)、波浪线(~文本~)
5554
-**代码高亮** - 丰富的代码块高亮主题,提升代码可读性
5655
-**自定义样式** - 允许自定义主题色和 CSS 样式,灵活定制展示效果
5756
-**草稿保存** - 内置本地内容管理功能,支持草稿自动保存

apps/web/src/components/ai/image-generator/AIImageConfig.vue

Lines changed: 95 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ import { imageServiceOptions } from '@md/shared/configs'
33
import { DEFAULT_SERVICE_TYPE } from '@md/shared/constants'
44
import { Info } from 'lucide-vue-next'
55
import { Button } from '@/components/ui/button'
6+
import { Label } from '@/components/ui/label'
7+
import {
8+
Select,
9+
SelectContent,
10+
SelectItem,
11+
SelectTrigger,
12+
SelectValue,
13+
} from '@/components/ui/select'
614
import useAIImageConfigStore from '@/stores/AIImageConfig'
715
816
/* -------------------------- 基础数据 -------------------------- */
@@ -183,25 +191,28 @@ const styleOptions = [
183191

184192
<!-- 服务商选择 -->
185193
<div>
186-
<label class="text-sm font-medium">服务商</label>
187-
<select
188-
v-model="config.type"
189-
class="w-full mt-1 p-2 border rounded-md bg-background focus:ring-2 focus:ring-primary focus:border-primary transition-colors"
190-
@change="handleServiceChange"
191-
>
192-
<option
193-
v-for="option in imageServiceOptions"
194-
:key="option.value"
195-
:value="option.value"
196-
>
197-
{{ option.label }}
198-
</option>
199-
</select>
194+
<Label class="mb-1 block text-sm font-medium">服务商</Label>
195+
<Select v-model="config.type" @update:model-value="handleServiceChange">
196+
<SelectTrigger class="w-full">
197+
<SelectValue>
198+
{{ currentService.label }}
199+
</SelectValue>
200+
</SelectTrigger>
201+
<SelectContent>
202+
<SelectItem
203+
v-for="option in imageServiceOptions"
204+
:key="option.value"
205+
:value="option.value"
206+
>
207+
{{ option.label }}
208+
</SelectItem>
209+
</SelectContent>
210+
</Select>
200211
</div>
201212

202213
<!-- 端点配置 -->
203214
<div>
204-
<label class="text-sm font-medium">API 端点</label>
215+
<Label class="mb-1 block text-sm font-medium">API 端点</Label>
205216
<input
206217
v-model="config.endpoint"
207218
type="url"
@@ -213,7 +224,7 @@ const styleOptions = [
213224

214225
<!-- API Key -->
215226
<div v-if="config.type !== 'default'">
216-
<label class="text-sm font-medium">API Key</label>
227+
<Label class="mb-1 block text-sm font-medium">API Key</Label>
217228
<input
218229
v-model="config.apiKey"
219230
type="password"
@@ -224,70 +235,86 @@ const styleOptions = [
224235

225236
<!-- 模型选择 -->
226237
<div>
227-
<label class="text-sm font-medium">模型</label>
228-
<select
229-
v-model="config.model"
230-
class="w-full mt-1 p-2 border rounded-md bg-background focus:ring-2 focus:ring-primary focus:border-primary transition-colors"
231-
>
232-
<option
233-
v-for="modelName in currentService.models"
234-
:key="modelName"
235-
:value="modelName"
236-
>
237-
{{ modelName }}
238-
</option>
239-
</select>
238+
<Label class="mb-1 block text-sm font-medium">模型</Label>
239+
<Select v-model="config.model">
240+
<SelectTrigger class="w-full">
241+
<SelectValue>
242+
{{ config.model || '请选择模型' }}
243+
</SelectValue>
244+
</SelectTrigger>
245+
<SelectContent>
246+
<SelectItem
247+
v-for="modelName in currentService.models"
248+
:key="modelName"
249+
:value="modelName"
250+
>
251+
{{ modelName }}
252+
</SelectItem>
253+
</SelectContent>
254+
</Select>
240255
</div>
241256

242257
<!-- 图像尺寸 -->
243258
<div>
244-
<label class="text-sm font-medium">图像尺寸</label>
245-
<select
246-
v-model="config.size"
247-
class="w-full mt-1 p-2 border rounded-md bg-background focus:ring-2 focus:ring-primary focus:border-primary transition-colors"
248-
>
249-
<option
250-
v-for="option in sizeOptions"
251-
:key="option.value"
252-
:value="option.value"
253-
>
254-
{{ option.label }}
255-
</option>
256-
</select>
259+
<Label class="mb-1 block text-sm font-medium">图像尺寸</Label>
260+
<Select v-model="config.size">
261+
<SelectTrigger class="w-full">
262+
<SelectValue>
263+
{{ sizeOptions.find(opt => opt.value === config.size)?.label || config.size }}
264+
</SelectValue>
265+
</SelectTrigger>
266+
<SelectContent>
267+
<SelectItem
268+
v-for="option in sizeOptions"
269+
:key="option.value"
270+
:value="option.value"
271+
>
272+
{{ option.label }}
273+
</SelectItem>
274+
</SelectContent>
275+
</Select>
257276
</div>
258277

259278
<!-- 图像质量 -->
260279
<div v-if="config.model.includes('dall-e')">
261-
<label class="text-sm font-medium">图像质量</label>
262-
<select
263-
v-model="config.quality"
264-
class="w-full mt-1 p-2 border rounded-md bg-background focus:ring-2 focus:ring-primary focus:border-primary transition-colors"
265-
>
266-
<option
267-
v-for="option in qualityOptions"
268-
:key="option.value"
269-
:value="option.value"
270-
>
271-
{{ option.label }}
272-
</option>
273-
</select>
280+
<Label class="mb-1 block text-sm font-medium">图像质量</Label>
281+
<Select v-model="config.quality">
282+
<SelectTrigger class="w-full">
283+
<SelectValue>
284+
{{ qualityOptions.find(opt => opt.value === config.quality)?.label || config.quality }}
285+
</SelectValue>
286+
</SelectTrigger>
287+
<SelectContent>
288+
<SelectItem
289+
v-for="option in qualityOptions"
290+
:key="option.value"
291+
:value="option.value"
292+
>
293+
{{ option.label }}
294+
</SelectItem>
295+
</SelectContent>
296+
</Select>
274297
</div>
275298

276299
<!-- 图像风格 -->
277300
<div v-if="config.model.includes('dall-e')">
278-
<label class="text-sm font-medium">图像风格</label>
279-
<select
280-
v-model="config.style"
281-
class="w-full mt-1 p-2 border rounded-md bg-background focus:ring-2 focus:ring-primary focus:border-primary transition-colors"
282-
>
283-
<option
284-
v-for="option in styleOptions"
285-
:key="option.value"
286-
:value="option.value"
287-
>
288-
{{ option.label }}
289-
</option>
290-
</select>
301+
<Label class="mb-1 block text-sm font-medium">图像风格</Label>
302+
<Select v-model="config.style">
303+
<SelectTrigger class="w-full">
304+
<SelectValue>
305+
{{ styleOptions.find(opt => opt.value === config.style)?.label || config.style }}
306+
</SelectValue>
307+
</SelectTrigger>
308+
<SelectContent>
309+
<SelectItem
310+
v-for="option in styleOptions"
311+
:key="option.value"
312+
:value="option.value"
313+
>
314+
{{ option.label }}
315+
</SelectItem>
316+
</SelectContent>
317+
</Select>
291318
</div>
292319

293320
<!-- 说明 -->

0 commit comments

Comments
 (0)