chore: 导入清理前的完整工程状态(含 Capacitor 原生壳,作为回滚备份点)
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { actionSheetController, alertController } from '@ionic/vue'
|
||||
import { yunleHaptic } from './yunleHost'
|
||||
|
||||
/**
|
||||
* iOS 风格的弹窗:替代 @capacitor/dialog(Web 上会退化成 window.alert / confirm / prompt)
|
||||
*/
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user