|
|
|
@ -7,6 +7,7 @@ import ( |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/frame/g" |
|
|
|
"github.com/gogf/gf/v2/frame/g" |
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/os/gtime" |
|
|
|
"github.com/gogf/gf/v2/util/gconv" |
|
|
|
"github.com/gogf/gf/v2/util/gconv" |
|
|
|
"github.com/wailsapp/wails/v2" |
|
|
|
"github.com/wailsapp/wails/v2" |
|
|
|
"github.com/wailsapp/wails/v2/pkg/menu" |
|
|
|
"github.com/wailsapp/wails/v2/pkg/menu" |
|
|
|
@ -18,19 +19,17 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
//go:embed all:frontend/dist
|
|
|
|
//go:embed all:frontend/dist
|
|
|
|
var assets embed.FS |
|
|
|
var assets embed.FS |
|
|
|
|
|
|
|
|
|
|
|
//go:embed wails.json
|
|
|
|
//go:embed wails.json
|
|
|
|
var wailsjson embed.FS |
|
|
|
var wailsjson embed.FS |
|
|
|
var wailsConfig map[string]interface{} |
|
|
|
var wailsConfig map[string]interface{} |
|
|
|
|
|
|
|
|
|
|
|
func init() { |
|
|
|
func init() { |
|
|
|
wailsConfig = make(map[string]interface{}) |
|
|
|
wailsConfig = make(map[string]interface{}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type App struct { |
|
|
|
type App struct { |
|
|
|
ctx context.Context |
|
|
|
ctx context.Context |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
|
|
|
|
|
|
|
|
// Create an instance of the app structure
|
|
|
|
// Create an instance of the app structure
|
|
|
|
@ -38,14 +37,14 @@ func main() { |
|
|
|
//开启视频监控的exe
|
|
|
|
//开启视频监控的exe
|
|
|
|
go initFunc.RunPiServerExe() |
|
|
|
go initFunc.RunPiServerExe() |
|
|
|
go initFunc.SetupCert() |
|
|
|
go initFunc.SetupCert() |
|
|
|
wilsJon, _ := wailsjson.ReadFile("wails.json") |
|
|
|
wilsJon,_ := wailsjson.ReadFile("wails.json") |
|
|
|
wailsConfig = gconv.Map(wilsJon) |
|
|
|
wailsConfig = gconv.Map(wilsJon) |
|
|
|
//读取wails.json配置文件
|
|
|
|
//读取wails.json配置文件
|
|
|
|
wailsConfigOem := initFunc.RequestOemSettingInfo(gconv.Map(wilsJon)) |
|
|
|
wailsConfigOem := initFunc.RequestOemSettingInfo(gconv.Map(wilsJon)) |
|
|
|
//将 wailsConfig 保存起来
|
|
|
|
//将 wailsConfig 保存起来
|
|
|
|
if wailsConfigOem == nil { |
|
|
|
if wailsConfigOem == nil { |
|
|
|
wailsConfigOem = g.Map{ |
|
|
|
wailsConfigOem = g.Map{ |
|
|
|
"brand_name": "Error-config", |
|
|
|
"brand_name": "Error-config", |
|
|
|
"website_url": "https://www.baidu.com", |
|
|
|
"website_url": "https://www.baidu.com", |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -53,52 +52,11 @@ func main() { |
|
|
|
//增加菜单
|
|
|
|
//增加菜单
|
|
|
|
AppMenu := menu.NewMenu() |
|
|
|
AppMenu := menu.NewMenu() |
|
|
|
SubMenu := AppMenu.AddSubmenu("工具") |
|
|
|
SubMenu := AppMenu.AddSubmenu("工具") |
|
|
|
SubMenu.AddText("刷新", keys.CmdOrCtrl("F5"), func(_ *menu.CallbackData) { |
|
|
|
SubMenu.AddText("刷新", keys.CmdOrCtrl("F5"), func(_ *menu.CallbackData) { |
|
|
|
runtime.WindowReloadApp(app.ctx) |
|
|
|
runtime.Reload(app.ctx) |
|
|
|
}) |
|
|
|
}) |
|
|
|
SubMenu.AddText("检查", keys.CmdOrCtrl("F12"), func(_ *menu.CallbackData) { |
|
|
|
|
|
|
|
runtime.WindowExecJS(app.ctx, ` |
|
|
|
|
|
|
|
(function(){ |
|
|
|
|
|
|
|
// 检查 vConsole 是否已经初始化
|
|
|
|
|
|
|
|
function isVConsoleInitialized() { |
|
|
|
|
|
|
|
return typeof window.VConsole !== 'undefined'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.vConsole = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadVConsole() { |
|
|
|
|
|
|
|
console.log('loadVConsole'); |
|
|
|
|
|
|
|
// 创建一个新的 script 元素
|
|
|
|
|
|
|
|
var script = document.createElement('script'); |
|
|
|
|
|
|
|
script.type = 'text/javascript'; |
|
|
|
|
|
|
|
script.src = 'https://3dview.suwa3d.com/libs/vConsole/3.15.1/vconsole.min.js'; // 请替换为 vConsole 的实际路径
|
|
|
|
|
|
|
|
// 将 script 元素添加到文档头部
|
|
|
|
|
|
|
|
document.head.appendChild(script); |
|
|
|
|
|
|
|
script.onload = function() { |
|
|
|
|
|
|
|
window.vConsole = new VConsole(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化 vConsole
|
|
|
|
|
|
|
|
function initVConsole() { |
|
|
|
|
|
|
|
console.log('isVConsoleInitialized()', isVConsoleInitialized()); |
|
|
|
|
|
|
|
if (!isVConsoleInitialized()) { |
|
|
|
|
|
|
|
// 如果 vConsole 未初始化,加载 vConsole
|
|
|
|
|
|
|
|
loadVConsole(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 如果 vConsole 已经初始化,直接打开
|
|
|
|
|
|
|
|
window.vConsole.show(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
initVConsole(); |
|
|
|
|
|
|
|
} catch(e) { |
|
|
|
|
|
|
|
console.log('e', e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
})() |
|
|
|
|
|
|
|
`) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
// Create application with options
|
|
|
|
// Create application with options
|
|
|
|
err := wails.Run(&options.App{ |
|
|
|
err := wails.Run(&options.App{ |
|
|
|
Title: wailsConfigOem["brand_name"].(string), |
|
|
|
Title: wailsConfigOem["brand_name"].(string), |
|
|
|
@ -109,7 +67,7 @@ func main() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, |
|
|
|
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, |
|
|
|
OnStartup: app.startup, |
|
|
|
OnStartup: app.startup, |
|
|
|
Menu: AppMenu, |
|
|
|
Menu: AppMenu, |
|
|
|
Bind: []interface{}{ |
|
|
|
Bind: []interface{}{ |
|
|
|
app, |
|
|
|
app, |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -119,6 +77,7 @@ func main() { |
|
|
|
println("Error:", err.Error()) |
|
|
|
println("Error:", err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NewApp creates a new App application struct
|
|
|
|
// NewApp creates a new App application struct
|
|
|
|
@ -141,7 +100,7 @@ func (a *App) ShopUrl() string { |
|
|
|
} |
|
|
|
} |
|
|
|
domain := wailsConfigOem["domain"].(string) |
|
|
|
domain := wailsConfigOem["domain"].(string) |
|
|
|
if !strings.Contains(domain, "http") { |
|
|
|
if !strings.Contains(domain, "http") { |
|
|
|
domain = "https://" + domain |
|
|
|
domain = "https://"+domain |
|
|
|
} |
|
|
|
} |
|
|
|
return domain + "?oem_id=" + gconv.String(wailsConfigOem["id"]) |
|
|
|
return domain+"?oem_id="+gconv.String(wailsConfigOem["id"])+"&t="+gconv.String(gtime.TimestampMilli()) |
|
|
|
} |
|
|
|
} |