-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
54 lines (45 loc) · 1.13 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"strconv"
"time"
)
// index.json
type IndexInfo struct {
Title string `json:"title"`
Width int `json:"width"`
Height int `json:"height"`
Port int `json:"port"`
AppId string `json:"appid"`
Resize bool `json:"resize"`
}
var GlobalInfo *IndexInfo
const DIR_WEBAPP = "webapp"
func ReadIndexJson() IndexInfo {
// index.json
var info IndexInfo = IndexInfo{Title: "なでしこ3", Width: 800, Height: 600, Port: 8888}
indexJson := filepath.Join(GetBokanPath(), "webapp", "index.json")
raw, err := os.ReadFile(indexJson)
if err == nil { // 読み込めた時
json.Unmarshal(raw, &info)
fmt.Printf("size=%d,%d\n", info.Width, info.Height)
}
checkPort(&info)
GlobalInfo = &info
return info
}
func GetIndexPageURL() string {
utime := strconv.FormatInt(time.Now().Unix(), 16)
return "http://127.0.0.1:" + strconv.Itoa(GlobalInfo.Port) + "/webapp/index.html?time=" + utime
}
func main() {
// Load Setting file (index.json)
info := ReadIndexJson()
// ローカルサーバーを起動
go StartServer(&info)
// ブラウザを起動
ShowBrowser(&info)
}