mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-05 14:50:29 +02:00
Use Edge on Windows if Chrome not installed
This commit is contained in:
parent
12f5321107
commit
a88f9592d8
57
win/main.go
57
win/main.go
@ -5,6 +5,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
"github.com/gonutz/w32"
|
||||
"github.com/zserge/lorca"
|
||||
@ -36,6 +37,11 @@ func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cmd := runOctoTasks(ctx)
|
||||
|
||||
chromePath := locateChrome()
|
||||
if len(chromePath) > 0 {
|
||||
os.Setenv("LORCACHROME", chromePath)
|
||||
}
|
||||
|
||||
ui, err := lorca.New("http://localhost:8088", "", 1024, 768)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -61,3 +67,54 @@ func hideConsole() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This duplicates the logic in Lorca, but adds Edge as an option for Windows, fallback to standard logic for other OSes
|
||||
func locateChrome() string {
|
||||
// If env variable "LORCACHROME" specified and it exists
|
||||
if path, ok := os.LookupEnv("LORCACHROME"); ok {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return path
|
||||
}
|
||||
}
|
||||
|
||||
var paths []string
|
||||
switch runtime.GOOS {
|
||||
// case "darwin":
|
||||
// paths = []string{
|
||||
// "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
||||
// "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
|
||||
// "/Applications/Chromium.app/Contents/MacOS/Chromium",
|
||||
// "/usr/bin/google-chrome-stable",
|
||||
// "/usr/bin/google-chrome",
|
||||
// "/usr/bin/chromium",
|
||||
// "/usr/bin/chromium-browser",
|
||||
// }
|
||||
case "windows":
|
||||
paths = []string{
|
||||
os.Getenv("LocalAppData") + "/Google/Chrome/Application/chrome.exe",
|
||||
os.Getenv("ProgramFiles") + "/Google/Chrome/Application/chrome.exe",
|
||||
os.Getenv("ProgramFiles(x86)") + "/Google/Chrome/Application/chrome.exe",
|
||||
os.Getenv("LocalAppData") + "/Chromium/Application/chrome.exe",
|
||||
os.Getenv("ProgramFiles") + "/Chromium/Application/chrome.exe",
|
||||
os.Getenv("ProgramFiles(x86)") + "/Chromium/Application/chrome.exe",
|
||||
os.Getenv("ProgramFiles(x86)") + "/Microsoft/Edge/Application/msedge.exe",
|
||||
}
|
||||
// default:
|
||||
// paths = []string{
|
||||
// "/usr/bin/google-chrome-stable",
|
||||
// "/usr/bin/google-chrome",
|
||||
// "/usr/bin/chromium",
|
||||
// "/usr/bin/chromium-browser",
|
||||
// "/snap/bin/chromium",
|
||||
// }
|
||||
}
|
||||
|
||||
for _, path := range paths {
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user