新增: 全局对话框服务 AppDialog,Promise 风格 appAlert/appConfirm/appPrompt 替代原生弹窗

This commit is contained in:
lxy
2026-08-25 12:30:12 +08:00
parent 0907a104cf
commit 8eef4606c5
9 changed files with 253 additions and 25 deletions
+5 -4
View File
@@ -5,6 +5,7 @@
import { ref, computed, watch } from 'vue'
import type { LibItem, Slide } from '../../core/types'
import { store, resolveBg } from '../../core/store'
import { appPrompt, appConfirm } from '../../core/dialog'
import ElementView from '../editor/ElementView.vue'
const props = defineProps<{ visible: boolean }>()
@@ -91,9 +92,9 @@ function onOpen(id: string) {
}
}
function onRename(id: string) {
async function onRename(id: string) {
const cur = store.getLibrary().find(x => x.id === id)
const name = prompt('重命名', cur ? cur.name : '')
const name = await appPrompt('重命名', { defaultValue: cur ? cur.name : '' })
if (name != null && name.trim()) {
store.renameInLibrary(id, name.trim())
bump()
@@ -106,8 +107,8 @@ function onDuplicate(id: string) {
bump()
}
function onDelete(id: string) {
if (confirm('删除这份演示?此操作不可撤销')) {
async function onDelete(id: string) {
if (await appConfirm('删除这份演示?', '此操作不可撤销', { danger: true, okText: '删除' })) {
store.deleteFromLibrary(id)
toast('已删除')
bump()