mirror of
https://github.com/quarkcloudio/quark-go.git
synced 2025-10-11 02:40:07 +08:00
chore: 新增获取多文件路径方法
This commit is contained in:
@@ -73,11 +73,11 @@ func (model *File) GetPath(id interface{}) string {
|
||||
json.Unmarshal([]byte(getId), &jsonData)
|
||||
// 如果为map
|
||||
if mapData, ok := jsonData.(map[string]interface{}); ok {
|
||||
path = mapData["path"].(string)
|
||||
path = mapData["url"].(string)
|
||||
}
|
||||
// 如果为数组,返回第一个key的path
|
||||
if arrayData, ok := jsonData.([]map[string]interface{}); ok {
|
||||
path = arrayData[0]["path"].(string)
|
||||
path = arrayData[0]["url"].(string)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,48 @@ func (model *File) GetPath(id interface{}) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// 获取多文件路径
|
||||
func (model *File) GetPaths(id interface{}) []string {
|
||||
var paths []string
|
||||
http, path := "", ""
|
||||
webSiteDomain := (&Config{}).GetValue("WEB_SITE_DOMAIN")
|
||||
WebConfig := (&Config{}).GetValue("SSL_OPEN")
|
||||
if webSiteDomain != "" {
|
||||
if WebConfig == "1" {
|
||||
http = "https://"
|
||||
} else {
|
||||
http = "http://"
|
||||
}
|
||||
}
|
||||
|
||||
if getId, ok := id.(string); ok {
|
||||
// json字符串
|
||||
if strings.Contains(getId, "{") {
|
||||
var jsonData interface{}
|
||||
json.Unmarshal([]byte(getId), &jsonData)
|
||||
// 如果为数组,返回第一个key的path
|
||||
if arrayData, ok := jsonData.([]map[string]interface{}); ok {
|
||||
for _, v := range arrayData {
|
||||
path = v["path"].(string)
|
||||
if strings.Contains(path, "//") {
|
||||
paths = append(paths, v["path"].(string))
|
||||
} else {
|
||||
if strings.Contains(path, "./") {
|
||||
path = strings.Replace(path, "./website/", "/", -1)
|
||||
}
|
||||
if path != "" {
|
||||
path = http + webSiteDomain + path
|
||||
}
|
||||
paths = append(paths, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return paths
|
||||
}
|
||||
|
||||
// 获取Excel文件数据
|
||||
func (model *File) GetExcelData(fileId int) (data [][]interface{}, Error error) {
|
||||
filePath := ""
|
||||
|
@@ -171,3 +171,45 @@ func (model *Picture) GetPath(id interface{}) string {
|
||||
|
||||
return http + webSiteDomain + "/admin/default.png"
|
||||
}
|
||||
|
||||
// 获取多图片路径
|
||||
func (model *Picture) GetPaths(id interface{}) []string {
|
||||
var paths []string
|
||||
http, path := "", ""
|
||||
webSiteDomain := (&Config{}).GetValue("WEB_SITE_DOMAIN")
|
||||
WebConfig := (&Config{}).GetValue("SSL_OPEN")
|
||||
if webSiteDomain != "" {
|
||||
if WebConfig == "1" {
|
||||
http = "https://"
|
||||
} else {
|
||||
http = "http://"
|
||||
}
|
||||
}
|
||||
|
||||
if getId, ok := id.(string); ok {
|
||||
// json字符串
|
||||
if strings.Contains(getId, "{") {
|
||||
var jsonData interface{}
|
||||
json.Unmarshal([]byte(getId), &jsonData)
|
||||
// 如果为数组,返回第一个key的path
|
||||
if arrayData, ok := jsonData.([]map[string]interface{}); ok {
|
||||
for _, v := range arrayData {
|
||||
path = v["url"].(string)
|
||||
if strings.Contains(path, "//") {
|
||||
paths = append(paths, v["url"].(string))
|
||||
} else {
|
||||
if strings.Contains(path, "./") {
|
||||
path = strings.Replace(path, "./website/", "/", -1)
|
||||
}
|
||||
if path != "" {
|
||||
path = http + webSiteDomain + path
|
||||
}
|
||||
paths = append(paths, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return paths
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ const (
|
||||
AppName = "QuarkGo"
|
||||
|
||||
// Version of current package
|
||||
Version = "1.1.23"
|
||||
Version = "1.1.24"
|
||||
|
||||
// 静态文件URL
|
||||
RespositoryURL = "https://github.com/quarkcms/quark-go/tree/main/website/"
|
||||
|
Reference in New Issue
Block a user