Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Failing after 1m21s
- Replace the inline brand-upload-hint bar in RecipeDetailOverlay with a confirm dialog (「去上传」/「取消」) that pops up when the card opens - Extend useDialog/CustomDialog to support custom ok/cancel button text - Add a 「← 返回配方卡片」banner in MyDiary brand tab when navigated from a recipe card, allowing return without uploading Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
import { reactive } from 'vue'
|
|
|
|
export const dialogState = reactive({
|
|
visible: false,
|
|
type: 'alert', // 'alert', 'confirm', 'prompt'
|
|
message: '',
|
|
defaultValue: '',
|
|
okText: '',
|
|
cancelText: '',
|
|
resolve: null
|
|
})
|
|
|
|
export function showAlert(msg) {
|
|
return new Promise(resolve => {
|
|
dialogState.visible = true
|
|
dialogState.type = 'alert'
|
|
dialogState.message = msg
|
|
dialogState.okText = ''
|
|
dialogState.cancelText = ''
|
|
dialogState.resolve = resolve
|
|
})
|
|
}
|
|
|
|
export function showConfirm(msg, opts = {}) {
|
|
return new Promise(resolve => {
|
|
dialogState.visible = true
|
|
dialogState.type = 'confirm'
|
|
dialogState.message = msg
|
|
dialogState.okText = opts.okText || ''
|
|
dialogState.cancelText = opts.cancelText || ''
|
|
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
|
|
}
|