Files
what-to-eat/apps/web/app/utils/dialog.ts
T
toor 76a5d71252 refactor: 只保留 Web,移除 Capacitor 原生壳
删除 android/、ios/ 两个 Capacitor 原生工程与 capacitor.config.ts、
ionic.config.json,以及 scripts/android、scripts/ios.sh 构建脚本;
根与 apps/web 的 @capacitor/* 依赖和相关 npm scripts 一并移除。

Web 侧去掉原生分支:登录只走云乐坊容器授权面板或顶层重定向,
暗色模式不再改原生状态栏,移除 Android 物理返回键处理。

保留 @nuxtjs/ionic(Web UI 框架)、云乐坊 window.ylf 桥接与 PWA。

决策记录见 docs/decisions/0004-web-only.md。
2026-10-21 12:27:50 +08:00

48 lines
1.6 KiB
TypeScript

import { actionSheetController, alertController } from '@ionic/vue'
import { yunleHaptic } from './yunleHost'
/**
* iOS 风格的弹窗:统一走 Ionic 的 alert / actionSheet
*/
export async function showAlert(header: string, message: string): Promise<void> {
const alert = await alertController.create({ header, message, buttons: ['好'] })
await alert.present()
await alert.onDidDismiss()
}
/**
* 破坏性操作的确认:底部操作表,确认项为红色
*/
export async function confirmDestructive(options: { header: string, confirmText: string }): Promise<boolean> {
void yunleHaptic('medium')
const sheet = await actionSheetController.create({
header: options.header,
buttons: [
{ text: options.confirmText, role: 'destructive' },
{ text: '取消', role: 'cancel' },
],
})
await sheet.present()
const { role } = await sheet.onDidDismiss()
return role === 'destructive'
}
/**
* 多行文本输入;取消时返回 undefined
*/
export async function promptText(options: { header: string, message?: string, placeholder?: string, okText: string }): Promise<string | undefined> {
const alert = await alertController.create({
header: options.header,
message: options.message,
inputs: [{ name: 'value', type: 'textarea', placeholder: options.placeholder }],
buttons: [
{ text: '取消', role: 'cancel' },
{ text: options.okText, role: 'confirm' },
],
})
await alert.present()
const { role, data } = await alert.onDidDismiss<{ values: { value?: string } }>()
return role === 'confirm' ? data?.values.value ?? '' : undefined
}