🎨 Improve dynamic icon api

This commit is contained in:
Daniel 2024-11-15 13:19:18 +08:00
parent 1f0db03f4a
commit 5a4d58b03a
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -18,6 +18,7 @@ package api
import (
"fmt"
"github.com/siyuan-note/siyuan/kernel/util"
"math"
"net/http"
"regexp"
@ -27,7 +28,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/util"
)
type ColorScheme struct {
@ -115,11 +115,20 @@ func darkenColor(hexColor string, factor float64) string {
func getDynamicIcon(c *gin.Context) {
// Add internal kernel API `/api/icon/getDynamicIcon` https://github.com/siyuan-note/siyuan/pull/12939
iconType := c.DefaultQuery("type", "1")
iconType := c.Query("type")
if "" == iconType {
iconType = "1"
}
color := c.Query("color") // 不要预设默认值不然type6返回星期就没法自动设置周末颜色了
date := c.Query("date")
lang := c.DefaultQuery("lang", util.Lang)
weekdayType := c.DefaultQuery("weekdayType", "1") // 设置星期几的格式zh_CH {1周日2周天 3星期日4星期天}, en_US {1: Mon, 2: MON3: Monday, 4. MONDAY,}
lang := c.Query("lang")
if "" == lang {
lang = util.Lang
}
weekdayType := c.Query("weekdayType") // 设置星期几的格式zh_CH {1周日2周天 3星期日4星期天}, en_US {1: Mon, 2: MON3: Monday, 4. MONDAY,}
if "" == weekdayType {
weekdayType = "1"
}
dateInfo := getDateInfo(date, lang, weekdayType)
var svg string