koishi-plugin-media-luna 1.2.7 → 1.2.9

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.
@@ -7,7 +7,7 @@
7
7
  :teleported="false"
8
8
  @close="handleClose"
9
9
  >
10
- <div class="upload-form" v-loading="uploading">
10
+ <div class="upload-form">
11
11
  <!-- 预览图 -->
12
12
  <div class="preview-section" v-if="previewUrl">
13
13
  <img :src="previewUrl" class="preview-image" />
@@ -87,7 +87,7 @@
87
87
  <template #footer>
88
88
  <span class="dialog-footer">
89
89
  <el-button @click="handleClose">取消</el-button>
90
- <el-button type="primary" @click="handleUpload" :loading="uploading" :disabled="!canUpload">
90
+ <el-button type="primary" @click="handleUpload" :disabled="!canUpload">
91
91
  上传
92
92
  </el-button>
93
93
  </span>
@@ -133,7 +133,6 @@ const visible = computed({
133
133
  set: (val) => emit('update:modelValue', val)
134
134
  })
135
135
 
136
- const uploading = ref(false)
137
136
  const uploadConfig = ref<{ uploadUrl: string, defaultAuthor: string, enabled: boolean } | null>(null)
138
137
 
139
138
  const form = ref({
@@ -203,46 +202,50 @@ function initForm() {
203
202
  }
204
203
  }
205
204
 
206
- // 上传
205
+ // 上传(非阻塞式,提交后立即关闭对话框)
207
206
  async function handleUpload() {
208
207
  if (!canUpload.value) return
209
208
 
210
- uploading.value = true
209
+ // 收集上传数据
210
+ const uploadData = {
211
+ title: form.value.title.trim(),
212
+ category: form.value.category,
213
+ author: form.value.author.trim() || undefined,
214
+ description: form.value.description.trim() || undefined,
215
+ tags: form.value.tags.length > 0 ? form.value.tags : undefined
216
+ }
217
+
218
+ // 立即关闭对话框,不阻塞用户操作
219
+ handleClose()
220
+ emit('success')
221
+
222
+ // 显示提交中提示
223
+ message.info(`正在上传「${uploadData.title}」...`)
224
+
225
+ // 后台异步执行上传
211
226
  try {
212
227
  if (props.mode === 'preset' && props.presetData) {
213
228
  const hasRefImages = props.presetData.referenceImages && props.presetData.referenceImages.length > 0
214
229
  await presetApi.upload({
215
- title: form.value.title.trim(),
230
+ ...uploadData,
216
231
  prompt: props.presetData.promptTemplate,
217
232
  imageUrl: props.presetData.thumbnail,
218
- category: form.value.category,
219
233
  type: hasRefImages ? 'img2img' : 'txt2img',
220
- author: form.value.author.trim() || undefined,
221
- description: form.value.description.trim() || undefined,
222
- tags: form.value.tags.length > 0 ? form.value.tags : undefined,
223
234
  referenceImages: hasRefImages
224
235
  ? props.presetData.referenceImages!.map(url => ({ url }))
225
236
  : undefined
226
237
  })
227
238
  } else if (props.mode === 'task' && props.taskData) {
228
239
  await presetApi.uploadTask({
240
+ ...uploadData,
229
241
  taskId: props.taskData.taskId,
230
- assetIndex: props.taskData.assetIndex,
231
- title: form.value.title.trim(),
232
- category: form.value.category,
233
- author: form.value.author.trim() || undefined,
234
- description: form.value.description.trim() || undefined,
235
- tags: form.value.tags.length > 0 ? form.value.tags : undefined
242
+ assetIndex: props.taskData.assetIndex
236
243
  })
237
244
  }
238
245
 
239
- message.success('上传成功')
240
- emit('success')
241
- handleClose()
246
+ message.success(`「${uploadData.title}」上传成功`)
242
247
  } catch (e: any) {
243
- message.error(e.message || '上传失败')
244
- } finally {
245
- uploading.value = false
248
+ message.error(`「${uploadData.title}」上传失败: ${e.message || '未知错误'}`)
246
249
  }
247
250
  }
248
251