1 Star 0 Fork 128

wg / b0pass

forked from bitepeng / 百灵快传 b0pass 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
bitepeng 提交于 2019-10-30 16:32 . add cli args port(-p=3000)
package main
import (
"b0pass/boot"
_ "b0pass/boot"
"b0pass/library/openurl"
_ "b0pass/router"
"fmt"
"github.com/gogf/gf/frame/g"
"github.com/zserge/lorca"
"log"
"os"
"os/signal"
"runtime"
"strconv"
"time"
)
func main() {
//处理命令行参数
boot.ExecArgs()
fmt.Printf("[ServerUrl] http://127.0.0.1:%d\n",boot.ServPort)
fmt.Printf("[Work-Path] %s\n",boot.PathRoot)
//是否开启GUI模式
//判断是否安装谷歌浏览器
ChromeExe := lorca.ChromeExecutable()
if ChromeExe != "" {
//打开UI界面
execUI()
} else {
//打开浏览器
go func() {
time.Sleep(1000 * time.Millisecond)
_ = openurl.Open("http://127.0.0.1:" + strconv.Itoa(boot.ServPort))
}()
g.Wait()
}
}
func execUI() {
// Wait Server Run
time.Sleep(3 * time.Second)
// Cli Args
var args []string
if runtime.GOOS == "linux" {
args = append(args, "--class=Lorca")
}
if runtime.GOOS == "windows" {
args = append(args, "-ldflags '-H windowsgui'")
}
// New Lorca UI
ui, err := lorca.New(
`data:text/html,
<html><head><title>B0App</title></head></html>`,
"", 360, 640, args...,
)
if err != nil {
log.Fatal(err)
}
defer func() {
_ = ui.Close()
}()
// Load url
_ = ui.Load(fmt.Sprintf(
"http://%s",
"127.0.0.1:"+g.Config().GetString("setting.port")),
)
// Wait until the interrupt signal arrives
// or browser window is closed
sigc := make(chan os.Signal)
signal.Notify(sigc, os.Interrupt)
select {
case <-sigc:
case <-ui.Done():
}
// Close UI
log.Println("exiting...")
_ = g.Server().Shutdown()
}
Go
1
https://gitee.com/rhine_home/b0pass.git
git@gitee.com:rhine_home/b0pass.git
rhine_home
b0pass
b0pass
master

搜索帮助