fix build macos
This commit is contained in:
30
client/internal/winapi/window_darwin.go
Normal file
30
client/internal/winapi/window_darwin.go
Normal file
@@ -0,0 +1,30 @@
|
||||
//go:build darwin
|
||||
|
||||
package winapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// ActivateAppWindow — đưa cửa sổ app lên trước
|
||||
func ActivateAppWindow(titleHint string) {
|
||||
pid := os.Getpid()
|
||||
script := fmt.Sprintf(`tell application "System Events" to set frontmost of first process whose unix id is %d to true`, pid)
|
||||
cmd := exec.Command("osascript", "-e", script)
|
||||
_ = cmd.Run()
|
||||
}
|
||||
|
||||
// PlayNotifySound — beep hệ thống macOS
|
||||
func PlayNotifySound() {
|
||||
cmd := exec.Command("osascript", "-e", "beep")
|
||||
_ = cmd.Run()
|
||||
}
|
||||
|
||||
// ShowWarningMessageBox hiển thị hộp thoại cảnh báo macOS bất đồng bộ
|
||||
func ShowWarningMessageBox(title, message string) {
|
||||
script := fmt.Sprintf(`display alert %q message %q`, title, message)
|
||||
cmd := exec.Command("osascript", "-e", script)
|
||||
_ = cmd.Start() // Run asynchronously
|
||||
}
|
||||
Reference in New Issue
Block a user