Browse Source

最新版本1

master
dongchangxi 1 year ago
parent
commit
ff9315ba63
  1. 3
      .gitignore
  2. 8
      build/windows/installer/project.nsi
  3. 4
      initFunc/setupCert.go
  4. 12
      initFunc/startPiVideo.go
  5. 73
      main.go

3
.gitignore vendored

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
build/bin
build
node_modules
frontend/dist
frontend/node_modules/*
build/windows/installer
piVideo/web/static
static

8
build/windows/installer/project.nsi

@ -72,11 +72,12 @@ ManifestDPIAware true @@ -72,11 +72,12 @@ ManifestDPIAware true
Name "${INFO_PRODUCTNAME}"
OutFile "..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file.
InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}" # Default installing folder ($PROGRAMFILES is Program Files folder).
InstallDir "$PROGRAMFILES64\shop_main" # Default installing folder ($PROGRAMFILES is Program Files folder).
ShowInstDetails show # This will always show the installation details.
Function .onInit
!insertmacro wails.checkArchitecture
ExecWait '"taskkill" /F /IM "piVideo.exe"'
FunctionEnd
Section
@ -91,6 +92,11 @@ Section @@ -91,6 +92,11 @@ Section
CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}" "" "$INSTDIR\icon.ico"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer" "Shell Icons" ""
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer" "Shell Icons"
SendMessage 0xFFFF 0x0017 0 0 /TIMEOUT=5000
CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}" "" "$INSTDIR\icon.ico"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer" "Shell Icons" ""
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer" "Shell Icons"
SendMessage 0xFFFF 0x0017 0 0 /TIMEOUT=5000

4
initFunc/setupCert.go

@ -28,7 +28,7 @@ func SetupCert() { @@ -28,7 +28,7 @@ func SetupCert() {
//获取证书路径
dir, _ := os.Getwd()
certPath := dir+"/piserver_root.crt" // 替换为您的证书路径
certPath := dir+"/rootCA.crt" // 替换为您的证书路径
if CheckCertIsInstalled() == "yes"{
return
@ -119,7 +119,7 @@ func printCertificateInfo(pCertContext uintptr) string { @@ -119,7 +119,7 @@ func printCertificateInfo(pCertContext uintptr) string {
size, _, _ := procCertGetNameString.Call(pCertContext, 5, 0, 0, uintptr(unsafe.Pointer(&buffer)), 200)
issuer := syscall.UTF16ToString(buffer[:size])
fmt.Println("Certificate Issuer:", issuer)
if issuer == "mkcert pi@pi-laptop"{
if issuer == "SX"{
return "yes"
}
return "no"

12
initFunc/startPiVideo.go

@ -4,8 +4,8 @@ import ( @@ -4,8 +4,8 @@ import (
"fmt"
"os"
"os/exec"
"time"
"syscall"
"time"
)
// 执行exe 文件,开启视频监控的服务进程
@ -18,7 +18,8 @@ func RunPiServerExe() { @@ -18,7 +18,8 @@ func RunPiServerExe() {
//执行exe的路径
exePath := dir + "/piVideo/piVideo.exe"
fmt.Println("piVide 可执行路径:", exePath)
killPiServerExe()
killPiServerExe("piVideo.exe") //杀 piVideo 进程
killPiServerExe("RTSPtoWeb.exe") //杀 RRTSPtoWeb 进程
time.Sleep(3 * time.Second)
cmd := exec.Command(exePath) // 替换为您的可执行文件路径
// os.Chdir("piVideo")
@ -29,10 +30,11 @@ func RunPiServerExe() { @@ -29,10 +30,11 @@ func RunPiServerExe() {
fmt.Println("执行成功", string(output))
}
}
func killPiServerExe() {
func killPiServerExe(exeName string) {
// 定义要关闭的程序的名称(或路径)
exeName := "piVideo.exe"
if exeName == "" {
exeName = "piVideo.exe"
}
// 使用exec.Command函数创建一个Cmd结构体,用于执行命令
cmd := exec.Command("taskkill", "/f", "/im", exeName)
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow:true}

73
main.go

@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
"strings"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/menu"
@ -18,87 +19,44 @@ import ( @@ -18,87 +19,44 @@ import (
//go:embed all:frontend/dist
var assets embed.FS
//go:embed wails.json
var wailsjson embed.FS
var wailsConfig map[string]interface{}
func init() {
wailsConfig = make(map[string]interface{})
wailsConfig = make(map[string]interface{})
}
type App struct {
ctx context.Context
}
func main() {
// Create an instance of the app structure
app := NewApp()
//开启视频监控的exe
go initFunc.RunPiServerExe()
go initFunc.SetupCert()
wilsJon, _ := wailsjson.ReadFile("wails.json")
wilsJon,_ := wailsjson.ReadFile("wails.json")
wailsConfig = gconv.Map(wilsJon)
//读取wails.json配置文件
//读取wails.json配置文件
wailsConfigOem := initFunc.RequestOemSettingInfo(gconv.Map(wilsJon))
//将 wailsConfig 保存起来
if wailsConfigOem == nil {
wailsConfigOem = g.Map{
"brand_name": "Error-config",
"brand_name": "Error-config",
"website_url": "https://www.baidu.com",
}
}
//增加菜单
AppMenu := menu.NewMenu()
SubMenu := AppMenu.AddSubmenu("工具")
SubMenu.AddText("刷新", keys.CmdOrCtrl("F5"), func(_ *menu.CallbackData) {
runtime.WindowReloadApp(app.ctx)
})
SubMenu.AddText("检查", keys.CmdOrCtrl("F12"), func(_ *menu.CallbackData) {
runtime.WindowExecJS(app.ctx, `
(function(){
// 检查 vConsole 是否已经初始化
function isVConsoleInitialized() {
return typeof window.VConsole !== 'undefined';
}
SubMenu.AddText("刷新", keys.CmdOrCtrl("F5"), func(_ *menu.CallbackData) {
runtime.Reload(app.ctx)
})
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
err := wails.Run(&options.App{
Title: wailsConfigOem["brand_name"].(string),
@ -109,16 +67,17 @@ func main() { @@ -109,16 +67,17 @@ func main() {
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: app.startup,
Menu: AppMenu,
Menu: AppMenu,
Bind: []interface{}{
app,
},
})
if err != nil {
println("Error:", err.Error())
}
}
// NewApp creates a new App application struct
@ -141,7 +100,7 @@ func (a *App) ShopUrl() string { @@ -141,7 +100,7 @@ func (a *App) ShopUrl() string {
}
domain := wailsConfigOem["domain"].(string)
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())
}
Loading…
Cancel
Save