feat: 네이티브 alert/confirm/prompt → 공용 인앱 다이얼로그 (PC 'sb_pt' 제거)
CI / build (push) Failing after 15m30s
CI / build (push) Failing after 15m30s
- composables/dialog + components/ui/AppDialog(App 루트 마운트) - window.alert 전역 오버라이드로 모든 alert 인앱화 - confirm/prompt(동기)는 각 호출부를 await dialog.confirm/prompt 로 교체 (가계부·예산·고정지출·계좌·태그·관리자·게시판·설정 — 삭제/열람제한 등) - 웹/PC/APK 일관 UI, 의미있는 제목 부여 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { reactive } from 'vue'
|
||||
|
||||
// 앱 공용 인앱 다이얼로그 상태(싱글턴). 네이티브 alert/confirm/prompt 대체.
|
||||
// PC(Electron)에서 제목이 'sb_pt'로 뜨던 문제 + 웹/APK 일관 UI 제공.
|
||||
const state = reactive({
|
||||
open: false,
|
||||
type: 'alert', // 'alert' | 'confirm' | 'prompt'
|
||||
title: '',
|
||||
message: '',
|
||||
okText: '확인',
|
||||
cancelText: '취소',
|
||||
danger: false,
|
||||
inputValue: '',
|
||||
placeholder: '',
|
||||
_resolve: null,
|
||||
})
|
||||
|
||||
function settle(result) {
|
||||
const r = state._resolve
|
||||
state._resolve = null
|
||||
state.open = false
|
||||
if (r) r(result)
|
||||
}
|
||||
|
||||
function alert(message, { title = '알림', okText = '확인' } = {}) {
|
||||
return new Promise((resolve) => {
|
||||
Object.assign(state, { type: 'alert', title, message, okText, danger: false, _resolve: resolve, open: true })
|
||||
})
|
||||
}
|
||||
|
||||
function confirm(message, { title = '확인', okText = '확인', cancelText = '취소', danger = false } = {}) {
|
||||
return new Promise((resolve) => {
|
||||
Object.assign(state, { type: 'confirm', title, message, okText, cancelText, danger, _resolve: resolve, open: true })
|
||||
})
|
||||
}
|
||||
|
||||
function prompt(message, { title = '입력', okText = '확인', cancelText = '취소', defaultValue = '', placeholder = '' } = {}) {
|
||||
return new Promise((resolve) => {
|
||||
Object.assign(state, {
|
||||
type: 'prompt', title, message, okText, cancelText,
|
||||
inputValue: defaultValue, placeholder, danger: false, _resolve: resolve, open: true,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// AppDialog 컴포넌트에서 사용
|
||||
export const dialogState = state
|
||||
export function dialogConfirm() {
|
||||
settle(state.type === 'prompt' ? state.inputValue : true)
|
||||
}
|
||||
export function dialogCancel() {
|
||||
settle(state.type === 'prompt' ? null : false)
|
||||
}
|
||||
|
||||
export function useDialog() {
|
||||
return { alert, confirm, prompt }
|
||||
}
|
||||
Reference in New Issue
Block a user