@2kog/kacha 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +57 -2
  2. package/bin/init-project.js +63 -0
  3. package/bin/kacha.js +51 -0
  4. package/index.html +5 -0
  5. package/package.json +45 -4
  6. package/server/asset-directories.js +65 -0
  7. package/server/asset-watch.js +35 -0
  8. package/server/character-assets.js +399 -0
  9. package/server/image-assets.js +652 -0
  10. package/server/index.js +15 -0
  11. package/server/project-brand.js +56 -0
  12. package/server/project-paths.js +4 -0
  13. package/server/project-settings.js +55 -0
  14. package/src/App.vue +34 -0
  15. package/src/assets/css/workbench.css +272 -0
  16. package/src/assets/img/rabbit-mark.svg +1 -0
  17. package/src/components/AssetDeleteButton.vue +53 -0
  18. package/src/components/AssetHistory.vue +40 -0
  19. package/src/components/AssetStoryEditor.vue +32 -0
  20. package/src/components/AssetTagInput.vue +26 -0
  21. package/src/components/ProjectMarkdown.vue +33 -0
  22. package/src/i18n/en.json +163 -0
  23. package/src/i18n/index.js +40 -0
  24. package/src/layouts/WorkbenchLayout.vue +61 -0
  25. package/src/main.js +7 -0
  26. package/src/router/index.js +38 -0
  27. package/src/service/assets.js +13 -0
  28. package/src/service/project-markdown.js +26 -0
  29. package/src/views/assets/AudioAssets.vue +325 -0
  30. package/src/views/assets/CharacterAssets.vue +412 -0
  31. package/src/views/assets/ImageAssets.vue +456 -0
  32. package/src/views/settings/ProjectSettings.vue +80 -0
  33. package/templates/project/AGENTS.md +14 -0
  34. package/templates/project/README.md +7 -0
  35. package/templates/project/assets/audio/README.md +5 -0
  36. package/templates/project/assets/characters/README.md +5 -0
  37. package/templates/project/assets/other/README.md +3 -0
  38. package/templates/project/assets/props/README.md +3 -0
  39. package/templates/project/assets/scenes/README.md +3 -0
  40. package/vite.config.js +10 -0
@@ -0,0 +1,412 @@
1
+ <script>
2
+ import AssetDeleteButton from '@/components/AssetDeleteButton.vue'
3
+ import { ElSwitch } from 'element-plus'
4
+ import AssetHistory from '@/components/AssetHistory.vue'
5
+ import AssetStoryEditor from '@/components/AssetStoryEditor.vue'
6
+ import AssetTagInput from '@/components/AssetTagInput.vue'
7
+ import ProjectMarkdown from '@/components/ProjectMarkdown.vue'
8
+ import 'element-plus/es/components/switch/style/css'
9
+ import { AudioLines, Check, Image, Layers3, Pencil, Plus, RefreshCw, Search, Star, Upload, X } from 'lucide-vue-next'
10
+ import { requestAsset } from '@/service/assets.js'
11
+
12
+ const mediaTypes = [
13
+ { key: 'image2d', label: '2D 图', icon: 'Image', accept: '.png,.jpg,.jpeg,.webp,.avif' },
14
+ { key: 'image3d', label: '3D 图', icon: 'Layers3', accept: '.png,.jpg,.jpeg,.webp,.avif' },
15
+ // 3D 模型入口暂缓,启用时恢复此项和 Box 图标注册。
16
+ // { key: 'model3d', label: '3D 模型', icon: 'Box', accept: '.glb' },
17
+ { key: 'voice', label: '音色', icon: 'AudioLines', accept: '.mp3,.wav,.ogg,.m4a,.flac,.aac' },
18
+ ]
19
+ const tabs = [
20
+ { key: 'overview', label: '概览' }, ...mediaTypes,
21
+ { key: 'portraits', label: '特写' }, { key: 'skins', label: '皮肤' },
22
+ { key: 'story', label: '设定' }, { key: 'history', label: '历史版本' },
23
+ ]
24
+
25
+ export default {
26
+ name: 'CharacterAssets',
27
+ components: { AssetDeleteButton, AssetHistory, AssetStoryEditor, AssetTagInput, ProjectMarkdown, ElSwitch, AudioLines, Check, Image, Layers3, Pencil, Plus, RefreshCw, Search, Star, Upload, X },
28
+ data() {
29
+ return {
30
+ mediaTypes, tabs, characters: [], query: '', filters: [], missingVoiceOnly: false, coverPreview: '', cardPreviews: {},
31
+ active: null, activeTab: 'overview', galleryFile: '', creating: false, busy: false,
32
+ form: null, overviewDraft: {}, storyDraft: null, promptDraft: null, error: '', pageError: '', ready: false, refreshRevision: 0, openRevision: 0,
33
+ }
34
+ },
35
+ computed: {
36
+ tags() {
37
+ return [...new Set(this.characters.flatMap(character => character.tags))].sort((a, b) => a.localeCompare(b, 'zh-CN'))
38
+ },
39
+ canSwitchCovers() {
40
+ return this.visibleCharacters.some(character => this.canSwitchCover(character))
41
+ },
42
+ visibleCharacters() {
43
+ const query = this.query.trim().toLowerCase()
44
+ return this.characters.filter(character => (!this.missingVoiceOnly || !character.media.voice)
45
+ && this.filters.every(tag => character.tags.includes(tag))
46
+ && [character.name, ...character.tags].some(value => value.toLowerCase().includes(query)))
47
+ },
48
+ galleryImages() {
49
+ return (this.activeTab === 'skins' ? this.active?.skins : this.active?.portraits) ?? []
50
+ },
51
+ currentGalleryImage() {
52
+ return this.galleryImages.find(image => image.file === this.galleryFile) || this.galleryImages[0]
53
+ },
54
+ overviewTags() {
55
+ return this.overviewDraft.tags ?? this.active?.tags ?? []
56
+ },
57
+ mediaSlot() {
58
+ return this.mediaTypes.find(slot => slot.key === this.activeTab)
59
+ },
60
+ currentPrompt() {
61
+ return this.active?.prompts[this.mediaSlot?.key] || ''
62
+ },
63
+ activeImage() {
64
+ const slot = this.activeTab
65
+ return ['image2d', 'image3d'].includes(slot) ? this.active.media[slot] : null
66
+ },
67
+ },
68
+ beforeRouteLeave() {
69
+ if (this.busy) return false
70
+ },
71
+ deactivated() {
72
+ this.openRevision++
73
+ this.$refs.create.close()
74
+ this.$refs.detail.close()
75
+ },
76
+ mounted() {
77
+ this.refresh()
78
+ import.meta.hot?.on('workbench:characters:changed', this.refreshAssets)
79
+ },
80
+ beforeUnmount() {
81
+ import.meta.hot?.off('workbench:characters:changed', this.refreshAssets)
82
+ },
83
+ methods: {
84
+ async refreshAssets() {
85
+ await this.refresh()
86
+ const active = this.active
87
+ if (!active || this.busy || this.storyDraft !== null || this.promptDraft !== null || !this.characters.some(item => item.id === active.id)) return
88
+ try {
89
+ const detail = await requestAsset('characters', active.id)
90
+ if (this.active === active && !this.busy && this.storyDraft === null && this.promptDraft === null) this.active = detail
91
+ } catch (cause) {
92
+ if (this.active === active) this.error = cause.message
93
+ }
94
+ },
95
+ async refresh() {
96
+ const revision = ++this.refreshRevision
97
+ try {
98
+ const characters = await requestAsset('characters')
99
+ if (revision !== this.refreshRevision) return
100
+ this.characters = characters
101
+ this.filters = this.filters.filter(tag => this.tags.includes(tag))
102
+ this.ready = true
103
+ this.pageError = ''
104
+ } catch (error) {
105
+ if (revision === this.refreshRevision) this.pageError = error.message
106
+ }
107
+ },
108
+ toggleTag(tag) {
109
+ this.filters = this.filters.includes(tag) ? this.filters.filter(value => value !== tag) : [...this.filters, tag]
110
+ },
111
+ setCoverPreview(preview) {
112
+ this.coverPreview = preview
113
+ this.cardPreviews = {}
114
+ },
115
+ canSwitchCover(character) {
116
+ return Boolean(character.media.image2d && character.media.image3d)
117
+ },
118
+ cardImage(character) {
119
+ const preview = this.cardPreviews[character.id] || this.coverPreview
120
+ return character.media[preview] ? preview : character.main
121
+ },
122
+ async open(character) {
123
+ const revision = ++this.openRevision
124
+ try {
125
+ const detail = await requestAsset('characters', character.id)
126
+ if (revision !== this.openRevision) return
127
+ this.overviewDraft = {}
128
+ this.selectTab('overview')
129
+ this.active = detail
130
+ if (!this.$refs.detail.open) this.$refs.detail.showModal()
131
+ } catch (error) {
132
+ if (revision === this.openRevision) this.pageError = error.message
133
+ }
134
+ },
135
+ showCreate() {
136
+ this.error = ''
137
+ this.form = { name: '' }
138
+ this.creating = true
139
+ this.$refs.create.showModal()
140
+ },
141
+ closeDetail() {
142
+ this.openRevision++
143
+ this.active = null
144
+ this.storyDraft = null
145
+ this.overviewDraft = {}
146
+ this.error = ''
147
+ },
148
+ selectTab(tab) {
149
+ this.activeTab = tab
150
+ if (this.$refs.detailBody) this.$refs.detailBody.scrollTop = 0
151
+ this.storyDraft = null
152
+ this.galleryFile = ''
153
+ this.error = ''
154
+ this.promptDraft = null
155
+ },
156
+ async deleteAsset() {
157
+ if (this.busy || !this.active) return
158
+ this.busy = true
159
+ this.error = ''
160
+ try {
161
+ await requestAsset('characters', this.active.id, 'DELETE', {})
162
+ this.$refs.detail.close()
163
+ await this.refresh()
164
+ } catch (cause) {
165
+ this.error = cause.message
166
+ } finally {
167
+ this.busy = false
168
+ }
169
+ },
170
+ async saveOverview() {
171
+ if (Object.keys(this.overviewDraft).length && await this.save(this.overviewDraft)) this.overviewDraft = {}
172
+ },
173
+ async saveStory() {
174
+ if (this.storyDraft !== null && await this.save({ story: this.storyDraft })) this.storyDraft = null
175
+ },
176
+ async save(patch, create = false) {
177
+ this.busy = true
178
+ this.error = ''
179
+ try {
180
+ this.active = await requestAsset('characters', create ? null : this.active.id, create ? 'POST' : 'PATCH', patch)
181
+ if (create) {
182
+ this.$refs.create.close()
183
+ this.selectTab('overview')
184
+ this.$refs.detail.showModal()
185
+ }
186
+ await this.refresh()
187
+ return true
188
+ } catch (error) {
189
+ this.error = error.message
190
+ return false
191
+ } finally {
192
+ this.busy = false
193
+ }
194
+ },
195
+ async savePrompt() {
196
+ const prompts = { ...this.active.prompts, [this.mediaSlot.key]: this.promptDraft }
197
+ if (await this.save({ prompts })) this.promptDraft = null
198
+ },
199
+ async upload(event) {
200
+ const input = event.target
201
+ const file = input.files[0]
202
+ if (!file) return
203
+ const slot = this.mediaSlot.key
204
+ const prompt = this.promptDraft ?? ''
205
+ this.busy = true
206
+ try {
207
+ if (file.size > 60 * 1024 * 1024) throw new Error(this.$t('素材超过 60 MB'))
208
+ const reader = new FileReader()
209
+ const base64 = await new Promise((resolve, reject) => {
210
+ reader.onload = () => resolve(reader.result.split(',')[1])
211
+ reader.onerror = () => reject(new Error(this.$t('读取素材失败')))
212
+ reader.readAsDataURL(file)
213
+ })
214
+ if (await this.save({ upload: { slot, filename: file.name, base64, prompt } })) this.promptDraft = null
215
+ } catch (error) {
216
+ this.error = error.message
217
+ } finally {
218
+ this.busy = false
219
+ input.value = ''
220
+ }
221
+ },
222
+ },
223
+ }
224
+ </script>
225
+
226
+ <template>
227
+ <div>
228
+ <section class="content">
229
+ <div class="heading">
230
+ <div><h1>{{ $t('角色资产') }}</h1><p>{{ $t('{count} 个角色', { count: characters.length }) }}</p></div>
231
+ <button class="primary" @click="showCreate"><Plus :size="18" /> {{ $t('新建角色') }}</button>
232
+ </div>
233
+ <div class="tools">
234
+ <div class="character-toolbar">
235
+ <label class="search"><Search :size="17" /><input v-model="query" :placeholder="$t('搜索名称或标签')" :aria-label="$t('搜索名称或标签')"></label>
236
+ <div class="character-toolbar-actions">
237
+ <label class="voice-filter">
238
+ <span>{{ $t('音色缺失') }}</span>
239
+ <ElSwitch v-model="missingVoiceOnly" size="small" :aria-label="$t('音色缺失')" />
240
+ </label>
241
+ <div v-if="canSwitchCovers" class="cover-preview-control" role="group" :aria-label="$t('切换全部角色封面图')">
242
+ <span>{{ $t('封面图') }}</span>
243
+ <div class="cover-preview-options">
244
+ <button type="button" :aria-pressed="coverPreview === 'image2d'" @click="setCoverPreview('image2d')">2D</button>
245
+ <button type="button" :aria-pressed="coverPreview === 'image3d'" @click="setCoverPreview('image3d')">3D</button>
246
+ </div>
247
+ </div>
248
+ </div>
249
+ </div>
250
+ <div class="filter-list" :aria-label="$t('按标签筛选')">
251
+ <button class="tag" :class="{ chosen: !filters.length }" @click="filters = []">{{ $t('全部') }}</button>
252
+ <button v-for="tag in tags" :key="tag" class="tag" :class="{ chosen: filters.includes(tag) }" :aria-pressed="filters.includes(tag)" @click="toggleTag(tag)">{{ tag }}</button>
253
+ </div>
254
+ </div>
255
+ <p v-if="pageError" class="error" role="alert">{{ pageError }}</p>
256
+ <p v-if="ready && !visibleCharacters.length" class="empty">{{ $t('没有匹配的角色') }}</p>
257
+ <div class="grid">
258
+ <article v-for="character in visibleCharacters" :key="character.id" class="card">
259
+ <div class="card-preview">
260
+ <button class="cover" :aria-label="$t('查看 {name}', { name: character.name })" @click="open(character)">
261
+ <img v-if="character.main" :src="character.media[cardImage(character)]" loading="lazy" :alt="character.name">
262
+ <span v-else class="character-cover-empty" aria-hidden="true"></span>
263
+ </button>
264
+ <div v-if="canSwitchCover(character)" class="preview-toggle" role="group" :aria-label="$t('{name} 图片预览', { name: character.name })">
265
+ <button :aria-pressed="cardImage(character) === 'image2d'" @click="cardPreviews[character.id] = 'image2d'">2D</button>
266
+ <button :aria-pressed="cardImage(character) === 'image3d'" @click="cardPreviews[character.id] = 'image3d'">3D</button>
267
+ </div>
268
+ </div>
269
+ <div class="card-info">
270
+ <button class="character-name" @click="open(character)">{{ character.name }}</button>
271
+ <div class="card-tags"><button v-for="tag in character.tags" :key="tag" class="tag compact" @click="toggleTag(tag)">{{ tag }}</button></div>
272
+ <div class="indicators">
273
+ <span v-for="slot in mediaTypes" :key="slot.key" class="indicator"
274
+ :title="character.media[slot.key] ? $t('已配置') : $t('待补充')">
275
+ <span class="indicator-icon" aria-hidden="true">
276
+ <component :is="slot.icon" :size="14" />
277
+ <span v-if="character.media[slot.key]" class="status-check"><Check :size="6" :stroke-width="3" /></span>
278
+ </span>
279
+ <span>{{ $t(slot.label) }}</span>
280
+ <span class="visually-hidden">{{ character.media[slot.key] ? $t('已配置') : $t('待补充') }}</span>
281
+ </span>
282
+ </div>
283
+ </div>
284
+ </article>
285
+ </div>
286
+ </section>
287
+
288
+ <dialog ref="create" class="dialog small-dialog" @close="creating = false" @cancel.prevent="!busy && $refs.create.close()">
289
+ <form v-if="creating" @submit.prevent="save({ name: form.name }, true)">
290
+ <header class="dialog-head"><h2>{{ $t('新建角色') }}</h2><button type="button" class="icon-button" :aria-label="$t('关闭')" :disabled="busy" @click="$refs.create.close()"><X :size="20" /></button></header>
291
+ <div class="dialog-body"><label class="field">{{ $t('角色名') }}<input v-model="form.name" required autofocus></label>
292
+ <p v-if="error" class="error" role="alert">{{ error }}</p>
293
+ <div class="dialog-actions create-actions">
294
+ <button class="primary" :disabled="busy">{{ $t('创建角色') }}</button>
295
+ </div>
296
+ </div>
297
+ </form>
298
+ </dialog>
299
+
300
+ <dialog ref="detail" class="dialog asset-detail-dialog" @close="closeDetail" @cancel.prevent="!busy && !$event.currentTarget.querySelector('.asset-delete-message') && $refs.detail.close()">
301
+ <template v-if="active">
302
+ <header class="dialog-head">
303
+ <div><h2>{{ active.name }}</h2><div class="card-tags"><span v-for="tag in active.tags" :key="tag" class="tag compact">{{ tag }}</span></div></div>
304
+ <div class="dialog-actions">
305
+ <button class="icon-button" :aria-label="$t('关闭')" :disabled="busy" @click="$refs.detail.close()"><X :size="20" /></button>
306
+ </div>
307
+ </header>
308
+ <div class="tabs">
309
+ <button v-for="tab in tabs" :key="tab.key" :disabled="busy" :class="{ current: activeTab === tab.key }" @click="selectTab(tab.key)">{{ $t(tab.label) }}</button>
310
+ </div>
311
+ <div ref="detailBody" class="dialog-body">
312
+ <p v-if="error" class="error" role="alert">{{ error }}</p>
313
+ <form v-if="activeTab === 'overview'" class="edit-form" @submit.prevent="saveOverview">
314
+ <label class="field">{{ $t('名称') }}
315
+ <input :value="overviewDraft.name ?? active.name" required :disabled="busy"
316
+ @input="overviewDraft.name = $event.target.value">
317
+ </label>
318
+ <div class="asset-tag-field">
319
+ <label class="field" for="character-tag-input">{{ $t('标签') }}</label>
320
+ <AssetTagInput id="character-tag-input" :model-value="overviewTags" :disabled="busy"
321
+ @update:model-value="overviewDraft.tags = $event" />
322
+ </div>
323
+ <label class="field">{{ $t('备注') }}
324
+ <textarea :value="overviewDraft.note ?? active.note" rows="8" :placeholder="$t('写点笔记…')" :disabled="busy"
325
+ @input="overviewDraft.note = $event.target.value"></textarea>
326
+ </label>
327
+ <div class="dialog-actions overview-actions">
328
+ <AssetDeleteButton :asset-name="active.name" :busy="busy" @confirm="deleteAsset" />
329
+ <button class="primary overview-save-button" :disabled="busy">{{ $t('保存') }}</button>
330
+ </div>
331
+ </form>
332
+ <template v-else-if="activeTab === 'portraits' || activeTab === 'skins'">
333
+ <template v-if="currentGalleryImage">
334
+ <div class="scene-thumbnails contain-thumbnails" :aria-label="activeTab === 'skins' ? $t('皮肤图片') : $t('角色特写图片')">
335
+ <button v-for="image in galleryImages" :key="image.file" type="button"
336
+ :aria-pressed="image.file === currentGalleryImage.file" @click="galleryFile = image.file">
337
+ <img :src="image.url" alt="" loading="lazy"><span>{{ image.name }}</span>
338
+ </button>
339
+ </div>
340
+ <a :href="currentGalleryImage.url" target="_blank" rel="noopener noreferrer">
341
+ <img class="detail-image" :src="currentGalleryImage.url" :alt="currentGalleryImage.name">
342
+ </a>
343
+ <div class="scene-image-info"><strong>{{ currentGalleryImage.name }}</strong></div>
344
+ <section v-if="currentGalleryImage.prompt" class="prompt">
345
+ <strong>{{ $t('生成词') }}</strong>
346
+ <pre>{{ currentGalleryImage.prompt }}</pre>
347
+ </section>
348
+ </template>
349
+ <div v-else class="detail-placeholder">
350
+ <Image :size="25" />
351
+ {{ activeTab === 'portraits' ? $t('暂无特写') : $t('暂无皮肤') }}
352
+ </div>
353
+ </template>
354
+ <AssetStoryEditor v-else-if="activeTab === 'story'" v-model:draft="storyDraft" :busy="busy"
355
+ @edit="storyDraft = active.story; error = ''" @cancel="storyDraft = null; error = ''" @save="saveStory">
356
+ <ProjectMarkdown v-if="active.story" :source="active.story" />
357
+ <p v-else class="empty">{{ $t('还没有角色设定。') }}</p>
358
+ </AssetStoryEditor>
359
+ <AssetHistory v-else-if="activeTab === 'history'" :versions="active.history" group="character-history">
360
+ <template #description="{ version }">
361
+ <small v-if="version.changes.length">{{ version.changes.map(key => mediaTypes.find(slot => slot.key === key)?.label || ({ story: '设定', prompts: '生成词' }[key])).filter(Boolean).map(label => $t(label)).join(' · ') }}</small>
362
+ </template>
363
+ <template #default="{ version }">
364
+ <template v-for="file in version.files" :key="file.url">
365
+ <a v-if="file.type.startsWith('image/')" :href="file.url" target="_blank" rel="noopener noreferrer"><img :src="file.url" :alt="file.name" loading="lazy"></a>
366
+ <audio v-else-if="file.type.startsWith('audio/')" :src="file.url" controls></audio>
367
+ <a v-else :href="file.url" download>{{ file.name }}</a>
368
+ </template>
369
+ <ProjectMarkdown v-if="version.story" :source="version.story" />
370
+ <template v-for="(prompt, key) in version.prompts" :key="key">
371
+ <div v-if="prompt"><strong>{{ $t('{label}生成词', { label: $t(mediaTypes.find(slot => slot.key === key)?.label || '主图') }) }}</strong><pre>{{ prompt }}</pre></div>
372
+ </template>
373
+ </template>
374
+ </AssetHistory>
375
+ <template v-else>
376
+ <img v-if="activeImage" class="detail-image" :src="activeImage" :alt="active.name">
377
+ <audio v-else-if="activeTab === 'voice' && active.media.voice" :src="active.media.voice" controls></audio>
378
+ <a v-else-if="activeTab === 'model3d' && active.media.model3d" class="secondary" :href="active.media.model3d" download="model.glb">{{ $t('下载 GLB 模型') }}</a>
379
+ <div v-else class="detail-placeholder"><component :is="mediaSlot?.icon || 'Image'" :size="28" />{{ $t('待补{label}', { label: $t(mediaSlot?.label || '主图') }) }}</div>
380
+ <div v-if="mediaSlot" class="media-actions">
381
+ <label class="secondary upload"><component :is="active.media[mediaSlot.key] ? 'RefreshCw' : 'Upload'" :size="15" aria-hidden="true" />{{ $t(active.media[mediaSlot.key] ? '替换{label}' : '上传{label}', { label: $t(mediaSlot.label) }) }}<input type="file" :accept="mediaSlot.accept" :disabled="busy" @change="upload"></label>
382
+ <button v-if="activeImage" class="secondary" :disabled="busy || active.main === activeTab" @click="save({ mainImage: activeTab })">
383
+ <component :is="active.main === activeTab ? 'Check' : 'Star'" :size="15" aria-hidden="true" />
384
+ {{ active.main === activeTab ? $t('当前主图') : $t('设为主图') }}
385
+ </button>
386
+ </div>
387
+ <div v-if="activeTab === 'voice' && active.extraVoice.length" class="extra-voice">
388
+ <div v-for="voice in active.extraVoice" :key="voice.url"><p>{{ voice.name }}</p><audio :src="voice.url" controls preload="none"></audio></div>
389
+ </div>
390
+ <section v-if="mediaSlot || currentPrompt" class="prompt" :aria-label="$t('生成词')">
391
+ <div class="prompt-heading">
392
+ <strong>{{ $t('生成词') }}</strong>
393
+ <button v-if="mediaSlot && promptDraft === null" class="secondary" :disabled="busy" @click="promptDraft = currentPrompt">
394
+ <component :is="currentPrompt ? 'Pencil' : 'Plus'" :size="14" aria-hidden="true" />
395
+ {{ currentPrompt ? $t('编辑生成词') : $t('添加生成词') }}
396
+ </button>
397
+ </div>
398
+ <form v-if="promptDraft !== null" @submit.prevent="savePrompt">
399
+ <label class="field"><span class="visually-hidden">{{ $t('{label}生成词', { label: $t(mediaSlot.label) }) }}</span><textarea v-model="promptDraft" rows="4" :disabled="busy"></textarea></label>
400
+ <div class="dialog-actions">
401
+ <button class="primary" :disabled="busy">{{ $t('保存生成词') }}</button>
402
+ <button type="button" class="secondary" :disabled="busy" @click="promptDraft = null">{{ $t('取消') }}</button>
403
+ </div>
404
+ </form>
405
+ <pre v-else-if="currentPrompt">{{ currentPrompt }}</pre>
406
+ </section>
407
+ </template>
408
+ </div>
409
+ </template>
410
+ </dialog>
411
+ </div>
412
+ </template>