Files
oil-formula-calculator/frontend/src/composables/useDialog.js
Hera Zhao ee8ec23dc7 Refactor frontend to Vue 3 + Vite + Pinia + Cypress E2E
- Replace single-file 8441-line HTML with Vue 3 SPA
- Pinia stores: auth, oils, recipes, diary, ui
- Composables: useApi, useDialog, useSmartPaste, useOilTranslation
- 6 shared components: RecipeCard, RecipeDetailOverlay, TagPicker, etc.
- 9 page views: RecipeSearch, RecipeManager, Inventory, OilReference, etc.
- 14 Cypress E2E test specs (113 tests), all passing
- Multi-stage Dockerfile (Node build + Python runtime)
- Demo video generation scripts (TTS + subtitles + screen recording)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 18:35:00 +00:00

44 lines
1014 B
JavaScript

import { reactive } from 'vue'
export const dialogState = reactive({
visible: false,
type: 'alert', // 'alert', 'confirm', 'prompt'
message: '',
defaultValue: '',
resolve: null
})
export function showAlert(msg) {
return new Promise(resolve => {
dialogState.visible = true
dialogState.type = 'alert'
dialogState.message = msg
dialogState.resolve = resolve
})
}
export function showConfirm(msg) {
return new Promise(resolve => {
dialogState.visible = true
dialogState.type = 'confirm'
dialogState.message = msg
dialogState.resolve = resolve
})
}
export function showPrompt(msg, defaultVal = '') {
return new Promise(resolve => {
dialogState.visible = true
dialogState.type = 'prompt'
dialogState.message = msg
dialogState.defaultValue = defaultVal
dialogState.resolve = resolve
})
}
export function closeDialog(result) {
dialogState.visible = false
if (dialogState.resolve) dialogState.resolve(result)
dialogState.resolve = null
}