Skip to content

Commit

Permalink
optimiza - add dev log
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanyanwow committed Nov 12, 2022
1 parent 71f6ae0 commit 246c8ff
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions kernel/service/bat.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import (
"project/kernel/model"
)




// CreateSoftBat 添加版本的时候 检测文件是否存在 不存在则创建
func CreateSoftBat(data *model.Version){
func CreateSoftBat(data *model.Version) {
filePath := buildPath(data)
needDo, _ := PathExists(filePath)
needDo = !needDo
Expand All @@ -32,16 +29,25 @@ func SwitchSoftBat(data *model.Version) {
func DeleteSoftBat(data *model.Version) {
filePath := buildPath(data)
os.Remove(filePath)
if config.IsDev() {
fmt.Println("删除文件-->")
fmt.Println(filePath)
}
}


func writeBat(filePath string, softName string, softPath string ) {
func writeBat(filePath string, softName string, softPath string) {
if config.IsDev() {
fmt.Println("写入文件-->")
fmt.Println(filePath)
fmt.Println(softName)
fmt.Println(softPath)
}
file6, err := os.Create(filePath)
if err != nil {
fmt.Println(err)
return
}
data := "@echo OFF\n:: in case DelayedExpansion is on and a path contains ! \nsetlocal DISABLEDELAYEDEXPANSION\n" + softPath + softName + " %*"
data := "@echo OFF\n:: in case DelayedExpansion is on and a path contains ! \nsetlocal DISABLEDELAYEDEXPANSION\n" + softPath + softName + " %*"

_, err = file6.WriteString(data)
if err != nil {
Expand All @@ -57,17 +63,24 @@ func buildPath(data *model.Version) string {
BasePath := config.BatPath
BaseBatIdentify := config.BatIdentify

needInitDir,_ := PathExists(BasePath+"/"+BaseBatIdentify)
needInitDir, _ := PathExists(BasePath + "/" + BaseBatIdentify)
needInitDir = !needInitDir

//fmt.Println("需要创建目录 --> ")
//fmt.Println(needInitDir)
if config.IsDev() {
fmt.Println("需要创建目录 --> ")
fmt.Println(needInitDir)
}

if needInitDir {
err := os.Mkdir(BasePath+"/"+BaseBatIdentify, 0777)
if err != nil {
panic("软件初始化目录错误,请联系管理员")
}
}
return BasePath+"/"+BaseBatIdentify+"/"+data.SoftName+".bat"
}

if config.IsDev() {
fmt.Println(BasePath + "/" + BaseBatIdentify + "/" + data.SoftName + ".bat")
}

return BasePath + "/" + BaseBatIdentify + "/" + data.SoftName + ".bat"
}

0 comments on commit 246c8ff

Please sign in to comment.