Skip to content

Commit

Permalink
优化路径,使其利用快捷键打开更顺畅
Browse files Browse the repository at this point in the history
  • Loading branch information
aveyuan committed Mar 7, 2020
1 parent abcc22e commit a521306
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"os"
"os/exec"
"path/filepath"
"sort"

"fyne.io/fyne"
Expand All @@ -15,13 +16,14 @@ import (
)

var cfg *ini.File
var path string
var err error

func main() {
_ = os.Setenv("FYNE_FONT", "./miniHei.ttf")
_ = os.Setenv("FYNE_FONT", path + "/miniHei.ttf")
app := app.New()
w := app.NewWindow("App")
f, err := os.Open("./icon.png")
f, err := os.Open(path + "/icon.png")
bit, _ := ioutil.ReadAll(f)
if err == nil {
w.SetIcon(&fyne.StaticResource{
Expand Down Expand Up @@ -88,14 +90,11 @@ func Lamda(v string) func() {
}

func init() {
pwd, err := os.Getwd()
path, err = filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}
var conf string = pwd + "/config.ini"
if len(os.Args) >= 2 {
conf = os.Args[1]
}
var conf string = path + "/config.ini"
cfg, err = ini.Load(conf)
if err != nil {
fmt.Printf("Fail to read file: %v", err)
Expand Down

0 comments on commit a521306

Please sign in to comment.