Initial commit: Receipt Studio desktop application

This commit is contained in:
fuenmao
2026-10-19 11:09:09 +08:00
commit 2caac3c31f
77 changed files with 9846 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import { shallowRef } from 'vue'
import type { ConfirmationOptions } from '../shared/types'
export const confirmation=shallowRef<ConfirmationOptions|null>(null)
let resolvePending:((confirmed:boolean)=>void)|null=null
let previousFocus:HTMLElement|null=null
export function askConfirmation(options:ConfirmationOptions):Promise<boolean>{
if(resolvePending)return Promise.resolve(false)
previousFocus=document.activeElement instanceof HTMLElement?document.activeElement:null
confirmation.value=options
return new Promise(resolve=>{resolvePending=resolve})
}
export function answerConfirmation(confirmed:boolean):void{
const resolve=resolvePending
resolvePending=null;confirmation.value=null
resolve?.(confirmed)
}
export function restoreConfirmationFocus(event:Event):void{
event.preventDefault()
if(previousFocus?.isConnected&&previousFocus!==document.body&&!previousFocus.matches(':disabled'))previousFocus.focus({preventScroll:true})
else document.querySelector<HTMLButtonElement>('.nav-item.active')?.focus({preventScroll:true})
previousFocus=null
}