diff --git a/Dockerfile b/Dockerfile
index 925bf8d..8d80523 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -30,12 +30,12 @@ COPY ./service .
# 中国国内源
# RUN sed -i "s@dl-cdn.alpinelinux.org@mirrors.aliyun.com@g" /etc/apk/repositories \
-# && go env -w GOPROXY=https://goproxy.cn,direct
RUN apk add --no-cache bash curl gcc git musl-dev
RUN go env -w GO111MODULE=on \
&& export PATH=$PATH:/go/bin \
+ && go env -w GOPROXY=https://goproxy.cn,direct \
&& go install -a -v github.com/go-bindata/go-bindata/...@latest \
&& go install -a -v github.com/elazarl/go-bindata-assetfs/...@latest \
&& go install -a -v github.com/gin-contrib/cors/...@latest \
diff --git a/index.html b/index.html
index b5df1c7..982656c 100644
--- a/index.html
+++ b/index.html
@@ -8,7 +8,7 @@
-
ZW-Panel
+ ZW Panel
diff --git a/public/favicon.ico b/public/favicon.ico
index 3e414ed..0b5169c 100644
Binary files a/public/favicon.ico and b/public/favicon.ico differ
diff --git a/public/favicon.svg b/public/favicon.svg
index 561e1f5..b44c514 100644
--- a/public/favicon.svg
+++ b/public/favicon.svg
@@ -1 +1,2 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/public/logo.png b/public/logo.png
index a3aac61..f4236ee 100644
Binary files a/public/logo.png and b/public/logo.png differ
diff --git a/service/api/api_v1/panel/itemIcon.go b/service/api/api_v1/panel/itemIcon.go
index 30228de..64d5860 100644
--- a/service/api/api_v1/panel/itemIcon.go
+++ b/service/api/api_v1/panel/itemIcon.go
@@ -6,6 +6,7 @@ import (
"net/url"
"os"
"path"
+ "path/filepath"
"strings"
"sun-panel/api/api_v1/common/apiData/commonApiStructs"
"sun-panel/api/api_v1/common/apiData/panelApiStructs"
@@ -243,12 +244,7 @@ func (a *ItemIcon) GetSiteFavicon(c *gin.Context) {
}
resp := panelApiStructs.ItemIconGetSiteFaviconResp{}
fullUrl := ""
- if iconUrl, err := siteFavicon.GetOneFaviconURL(req.Url); err != nil {
- apiReturn.Error(c, "acquisition failed: get ico error:"+err.Error())
- return
- } else {
- fullUrl = iconUrl
- }
+ fullUrl = siteFavicon.GetOneFaviconURL(req.Url)
parsedURL, err := url.Parse(req.Url)
if err != nil {
@@ -267,17 +263,7 @@ func (a *ItemIcon) GetSiteFavicon(c *gin.Context) {
// 如果URL既不以http://开头也不以https://开头,则默认为http协议
fullUrl = "http://" + fullUrl
}
- global.Logger.Debug("fullUrl:", fullUrl)
- // 去除图标的get参数
- {
- parsedIcoURL, err := url.Parse(fullUrl)
- if err != nil {
- apiReturn.Error(c, "acquisition failed: parsed ico URL :"+err.Error())
- return
- }
- fullUrl = parsedIcoURL.Scheme + "://" + parsedIcoURL.Host + parsedIcoURL.Path
- }
- global.Logger.Debug("fullUrl:", fullUrl)
+ global.Logger.Debug("fullUrl111:", fullUrl)
// 生成保存目录
configUpload := global.Config.GetValueString("base", "source_path")
@@ -290,13 +276,64 @@ func (a *ItemIcon) GetSiteFavicon(c *gin.Context) {
// 下载
var imgInfo *os.File
{
- var err error
- if imgInfo, err = siteFavicon.DownloadImage(fullUrl, savePath, 1024*1024); err != nil {
- apiReturn.Error(c, "acquisition failed: download"+err.Error())
- return
+ {
+ imgInfo, err = siteFavicon.DownloadImage(fullUrl, savePath, 1024*1024)
+ if err != nil {
+ u, err := url.Parse(fullUrl)
+ if err != nil {
+ // 处理 URL 解析错误
+ return
+ }
+
+ // 获取主机名
+ hostname := u.Hostname()
+
+ // 去掉子域名前缀
+ parts := strings.Split(hostname, ".")
+ if len(parts) > 2 {
+ hostname = strings.Join(parts[1:], ".")
+ }
+
+ // 构建新的 URL
+ newUrl := u.Scheme + "://" + hostname + u.RequestURI()
+ imgInfo, err = siteFavicon.DownloadImage(newUrl, savePath, 1024*1024)
+ // 重新尝试下载
+ if err != nil {
+ if iconUrl, err := siteFavicon.GetOneFaviconURLByhead(req.Url); err != nil {
+ apiReturn.Error(c, "acquisition failed: get ico error:"+err.Error())
+ return
+ } else {
+ fullUrl = iconUrl
+
+ u, err := url.Parse(fullUrl)
+ if err != nil {
+ // 处理 URL 解析错误
+ apiReturn.Error(c, "acquisition failed: get ico error:"+err.Error())
+
+ return
+ }
+
+ // 获取主机名
+ hostname := u.Hostname()
+ absolutePath := filepath.Clean(u.RequestURI())
+ // 构建新的 URL
+
+ newUrl := u.Scheme + "://" + hostname + absolutePath
+ newUrl = strings.ReplaceAll(newUrl, "\\", "/")
+ fmt.Println(newUrl)
+
+ imgInfo, err = siteFavicon.DownloadImage(newUrl, savePath, 1024*1024)
+ if err != nil {
+ fmt.Println(err)
+
+ apiReturn.Error(c, "acquisition failed: get ico error:"+err.Error())
+ return
+ }
+ }
+ }
+ }
}
}
-
// 保存到数据库
ext := path.Ext(fullUrl)
mFile := models.File{}
diff --git a/service/lib/siteFavicon/favico.go b/service/lib/siteFavicon/favico.go
index 38e1af7..796c470 100644
--- a/service/lib/siteFavicon/favico.go
+++ b/service/lib/siteFavicon/favico.go
@@ -26,7 +26,14 @@ func IsHTTPURL(url string) bool {
return match
}
-func GetOneFaviconURL(urlStr string) (string, error) {
+func GetOneFaviconURL(urlStr string) string {
+
+ urlInfo, _ := url.Parse(urlStr)
+ fullUrl := urlInfo.Scheme + "://" + urlInfo.Host + "/favicon.ico"
+ return fullUrl
+
+}
+func GetOneFaviconURLByhead(urlStr string) (string, error) {
iconURLs, err := getFaviconURL(urlStr)
if err != nil {
return "", err
diff --git a/src/assets/logo.svg b/src/assets/logo.svg
index 561e1f5..b44c514 100644
--- a/src/assets/logo.svg
+++ b/src/assets/logo.svg
@@ -1 +1,2 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/views/home/components/EditItem/index.vue b/src/views/home/components/EditItem/index.vue
index 639d6fd..83e51a0 100644
--- a/src/views/home/components/EditItem/index.vue
+++ b/src/views/home/components/EditItem/index.vue
@@ -6,13 +6,14 @@ import IconEditor from './IconEditor.vue'
import { edit, getSiteFavicon } from '@/api/panel/itemIcon'
import { getList as getGroupList } from '@/api/panel/itemIconGroup'
import { t } from '@/locales'
+import { useAuthStore } from '@/store'
interface Props {
visible: boolean
itemInfo: Panel.Info | null
itemGroupId?: number
}
-
+const authStore = useAuthStore()
const props = defineProps()
const emit = defineEmits()
const ms = useMessage()
@@ -195,7 +196,7 @@ function getGroupListOptions() {
-
+
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index 355c94a..1c68b6d 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -27,7 +27,6 @@ const ms = useMessage()
const dialog = useDialog()
const panelState = usePanelState()
const authStore = useAuthStore()
-console.log(panelState.panelConfig)
const scrollContainerRef = ref(undefined)
const editItemInfoShow = ref(false)