国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

基于wails、webman和static-php-cli項(xiàng)目,開發(fā)桌面程序

北月妖王

golang 部分主要是用來啟動(dòng)和結(jié)束 webman 進(jìn)程的,其他所有業(yè)務(wù)流程和前端部分都是由 webman 響應(yīng)的。

有興趣可以下載安裝體驗(yàn)一下,只支持 Windows,安裝包大?。?code>12.7MB。

下載地址 密碼:webman。

網(wǎng)盤里面有一個(gè) Windows 系統(tǒng)版本的 micro.sfx 文件,只打包了小部分?jǐn)U展,沒有帶 MySQL,只有sqlite3

// app.go
// App struct
type App struct {
    ctx    context.Context
    phpCmd *exec.Cmd
}

// NewApp creates a new App application struct
func NewApp() *App {
    return &App{}
}

// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
    a.ctx = ctx
    a.startPHPProcess()
    go a.monitorPHPProcess()
}
func (a *App) startPHPProcess() {
    exePath, _ := os.Executable()
    installDir := filepath.Dir(exePath)
    phpWebmanExePath := filepath.Join(installDir, "myapp.exe")
    fmt.Println(phpWebmanExePath)

    cmd := exec.Command(phpWebmanExePath)
    cmd.SysProcAttr = &syscall.SysProcAttr{
        HideWindow:    true,
        CreationFlags: 0x08000000, // CREATE_NO_WINDOW
    }

    err := cmd.Start()
    if err != nil {
        // 使用 Wails 彈窗提示用戶
        runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
            Type:    runtime.ErrorDialog,
            Title:   "Error",
            Message: "Failed to start PHP process. Please restart the application.",
        })
        return
    }

    time.Sleep(2 * time.Second)
    a.phpCmd = cmd
}
func (a *App) shutdown(ctx context.Context) {
    fmt.Println(a.phpCmd)
    if a.phpCmd != nil && a.phpCmd.Process != nil {
        a.phpCmd.Process.Kill()
    }
}

func (a *App) monitorPHPProcess() {
    if a.phpCmd == nil {
        return
    }
    for {
        // 等待進(jìn)程完成
        err := a.phpCmd.Wait()
        if err != nil {
            // 進(jìn)程已退出
            runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
                Type:    runtime.WarningDialog,
                Title:   "PHP Process Stopped",
                Message: "The PHP process has stopped. Please restart the application.",
            })
            break
        }
        // 每隔10秒檢查一次
        time.Sleep(10 * time.Second)
    }
}

安裝過程

安裝目錄

截圖

截圖

1049 2 2
2個(gè)評論

crazywhalecc

理論上如果用 libphp(embed)+go+wails 可以實(shí)現(xiàn)不依賴 micro.sfx 來編寫桌面程序,就像 frankenPHP 一樣,且可以實(shí)現(xiàn)可替換的代碼。有人有興趣可以研究一下。

  • 北月妖王 2024-08-16

    之前在 frankenPHP 的 discussions 上看到大佬你好像說過一次這種思路,后續(xù)有空我研究一下。

KingBes

同道中人,你的這個(gè)和我的webview-jacketing原理差不多,不過我沒把micro.sfx加入進(jìn)來,我用vlang來編譯個(gè)外殼

北月妖王

3620
積分
0
獲贊數(shù)
0
粉絲數(shù)
2021-12-01 加入
??