diff --git a/CHANGELOG.md b/CHANGELOG.md
index edb0a36..a90f726 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
* 功能优化:恢复关闭注册系统配置项,管理员可以在后台关闭用户注册,只允许内部添加账号
* 功能优化:兼用旧版本微信收款消息解析
* 功能优化:优化订单扫码支付状态轮询功能,当关闭二维码时取消轮询,节约网络资源
+* 功能新增:新增图片发布功能,画廊只显示用户已发布的图片
* 功能新增:后台新增配置微信客服二维码,可以上传自己的微信客服二维码
* 功能新增:新增网站公告,可以在管理后台自定义配置
* 功能新增:新增阿里通义千问大模型支持
diff --git a/api/handler/mj_handler.go b/api/handler/mj_handler.go
index d1e3d13..ea22f9c 100644
--- a/api/handler/mj_handler.go
+++ b/api/handler/mj_handler.go
@@ -13,12 +13,13 @@ import (
"chatplus/utils/resp"
"encoding/base64"
"fmt"
- "github.com/gin-gonic/gin"
- "github.com/gorilla/websocket"
- "gorm.io/gorm"
"net/http"
"strings"
"time"
+
+ "github.com/gin-gonic/gin"
+ "github.com/gorilla/websocket"
+ "gorm.io/gorm"
)
type MidJourneyHandler struct {
@@ -294,6 +295,7 @@ func (h *MidJourneyHandler) JobList(c *gin.Context) {
userId := h.GetInt(c, "user_id", 0)
page := h.GetInt(c, "page", 0)
pageSize := h.GetInt(c, "page_size", 0)
+ publish := h.GetBool(c, "publish")
session := h.db.Session(&gorm.Session{})
if status == 1 {
@@ -304,6 +306,9 @@ func (h *MidJourneyHandler) JobList(c *gin.Context) {
if userId > 0 {
session = session.Where("user_id = ?", userId)
}
+ if publish {
+ session = session.Where("publish = ?", publish)
+ }
if page > 0 && pageSize > 0 {
offset := (page - 1) * pageSize
session = session.Offset(offset).Limit(pageSize)
@@ -396,3 +401,23 @@ func (h *MidJourneyHandler) Notify(c *gin.Context) {
resp.SUCCESS(c)
}
+
+// Publish 发布图片到画廊显示
+func (h *MidJourneyHandler) Publish(c *gin.Context) {
+ var data struct {
+ Id uint `json:"id"`
+ Action bool `json:"action"` // 发布动作,true => 发布,false => 取消分享
+ }
+ if err := c.ShouldBindJSON(&data); err != nil {
+ resp.ERROR(c, types.InvalidArgs)
+ return
+ }
+
+ res := h.db.Model(&model.MidJourneyJob{Id: data.Id}).UpdateColumn("publish", data.Action)
+ if res.Error != nil {
+ resp.ERROR(c, "更新数据库失败")
+ return
+ }
+
+ resp.SUCCESS(c)
+}
diff --git a/api/handler/sd_handler.go b/api/handler/sd_handler.go
index 4e22ba5..171a57f 100644
--- a/api/handler/sd_handler.go
+++ b/api/handler/sd_handler.go
@@ -145,6 +145,7 @@ func (h *SdJobHandler) JobList(c *gin.Context) {
userId := h.GetInt(c, "user_id", 0)
page := h.GetInt(c, "page", 0)
pageSize := h.GetInt(c, "page_size", 0)
+ publish := h.GetBool(c, "publish")
session := h.db.Session(&gorm.Session{})
if status == 1 {
@@ -155,6 +156,9 @@ func (h *SdJobHandler) JobList(c *gin.Context) {
if userId > 0 {
session = session.Where("user_id = ?", userId)
}
+ if publish {
+ session = session.Where("publish", publish)
+ }
if page > 0 && pageSize > 0 {
offset := (page - 1) * pageSize
session = session.Offset(offset).Limit(pageSize)
@@ -224,3 +228,23 @@ func (h *SdJobHandler) Remove(c *gin.Context) {
resp.SUCCESS(c)
}
+
+// Publish 发布/取消发布图片到画廊显示
+func (h *SdJobHandler) Publish(c *gin.Context) {
+ var data struct {
+ Id uint `json:"id"`
+ Action bool `json:"action"` // 发布动作,true => 发布,false => 取消分享
+ }
+ if err := c.ShouldBindJSON(&data); err != nil {
+ resp.ERROR(c, types.InvalidArgs)
+ return
+ }
+
+ res := h.db.Model(&model.SdJob{Id: data.Id}).UpdateColumn("publish", true)
+ if res.Error != nil {
+ resp.ERROR(c, "更新数据库失败")
+ return
+ }
+
+ resp.SUCCESS(c)
+}
diff --git a/api/main.go b/api/main.go
index 8a0708f..0156255 100644
--- a/api/main.go
+++ b/api/main.go
@@ -240,12 +240,14 @@ func main() {
group.GET("jobs", h.JobList)
group.POST("remove", h.Remove)
group.POST("notify", h.Notify)
+ group.POST("publish", h.Publish)
}),
fx.Invoke(func(s *core.AppServer, h *handler.SdJobHandler) {
group := s.Engine.Group("/api/sd")
group.POST("image", h.Image)
group.GET("jobs", h.JobList)
group.POST("remove", h.Remove)
+ group.POST("publish", h.Publish)
}),
// 管理后台控制器
diff --git a/api/store/model/mj_job.go b/api/store/model/mj_job.go
index bb94906..33b055d 100644
--- a/api/store/model/mj_job.go
+++ b/api/store/model/mj_job.go
@@ -16,6 +16,7 @@ type MidJourneyJob struct {
Progress int
Prompt string
UseProxy bool // 是否使用反代加载图片
+ Publish bool //是否发布图片到画廊
CreatedAt time.Time
}
diff --git a/api/store/model/sd_job.go b/api/store/model/sd_job.go
index 65f3e6f..2613219 100644
--- a/api/store/model/sd_job.go
+++ b/api/store/model/sd_job.go
@@ -11,6 +11,7 @@ type SdJob struct {
Progress int
Prompt string
Params string
+ Publish bool //是否发布图片到画廊
CreatedAt time.Time
}
diff --git a/api/store/vo/mj_job.go b/api/store/vo/mj_job.go
index 3ffcb37..5ec37b0 100644
--- a/api/store/vo/mj_job.go
+++ b/api/store/vo/mj_job.go
@@ -16,5 +16,6 @@ type MidJourneyJob struct {
Progress int `json:"progress"`
Prompt string `json:"prompt"`
UseProxy bool `json:"use_proxy"`
+ Publish bool `json:"publish"`
CreatedAt time.Time `json:"created_at"`
}
diff --git a/api/store/vo/sd_job.go b/api/store/vo/sd_job.go
index 26b3be1..dfed014 100644
--- a/api/store/vo/sd_job.go
+++ b/api/store/vo/sd_job.go
@@ -14,5 +14,6 @@ type SdJob struct {
Params types.SdTaskParams `json:"params"`
Progress int `json:"progress"`
Prompt string `json:"prompt"`
+ Publish bool `json:"publish"`
CreatedAt time.Time `json:"created_at"`
}
diff --git a/database/update-v3.2.6.sql b/database/update-v3.2.6.sql
new file mode 100644
index 0000000..5afef27
--- /dev/null
+++ b/database/update-v3.2.6.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `chatgpt_mj_jobs` ADD `publish` TINYINT(1) NOT NULL COMMENT '是否发布' AFTER `use_proxy`;
+ALTER TABLE `chatgpt_sd_jobs` ADD `publish` TINYINT(1) NOT NULL COMMENT '是否发布' AFTER `progress`;
\ No newline at end of file
diff --git a/web/src/assets/iconfont/iconfont.css b/web/src/assets/iconfont/iconfont.css
index 3dece43..8f761cb 100644
--- a/web/src/assets/iconfont/iconfont.css
+++ b/web/src/assets/iconfont/iconfont.css
@@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 4125778 */
- src: url('iconfont.woff2?t=1705313263366') format('woff2'),
- url('iconfont.woff?t=1705313263366') format('woff'),
- url('iconfont.ttf?t=1705313263366') format('truetype');
+ src: url('iconfont.woff2?t=1705615887594') format('woff2'),
+ url('iconfont.woff?t=1705615887594') format('woff'),
+ url('iconfont.ttf?t=1705615887594') format('truetype');
}
.iconfont {
@@ -13,6 +13,14 @@
-moz-osx-font-smoothing: grayscale;
}
+.icon-share-bold:before {
+ content: "\e626";
+}
+
+.icon-cancel-share:before {
+ content: "\e682";
+}
+
.icon-xls:before {
content: "\e678";
}
diff --git a/web/src/assets/iconfont/iconfont.js b/web/src/assets/iconfont/iconfont.js
index 36dd6b7..89b3d06 100644
--- a/web/src/assets/iconfont/iconfont.js
+++ b/web/src/assets/iconfont/iconfont.js
@@ -1 +1 @@
-window._iconfont_svg_string_4125778='',function(a){var l=(l=document.getElementsByTagName("script"))[l.length-1],c=l.getAttribute("data-injectcss"),l=l.getAttribute("data-disable-injectsvg");if(!l){var t,h,i,o,z,v=function(l,c){c.parentNode.insertBefore(l,c)};if(c&&!a.__iconfont__svg__cssinject__){a.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(l){console&&console.log(l)}}t=function(){var l,c=document.createElement("div");c.innerHTML=a._iconfont_svg_string_4125778,(c=c.getElementsByTagName("svg")[0])&&(c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.width=0,c.style.height=0,c.style.overflow="hidden",c=c,(l=document.body).firstChild?v(c,l.firstChild):l.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(t,0):(h=function(){document.removeEventListener("DOMContentLoaded",h,!1),t()},document.addEventListener("DOMContentLoaded",h,!1)):document.attachEvent&&(i=t,o=a.document,z=!1,e(),o.onreadystatechange=function(){"complete"==o.readyState&&(o.onreadystatechange=null,m())})}function m(){z||(z=!0,i())}function e(){try{o.documentElement.doScroll("left")}catch(l){return void setTimeout(e,50)}m()}}(window);
\ No newline at end of file
+window._iconfont_svg_string_4125778='',function(a){var l=(l=document.getElementsByTagName("script"))[l.length-1],c=l.getAttribute("data-injectcss"),l=l.getAttribute("data-disable-injectsvg");if(!l){var t,h,i,o,z,m=function(l,c){c.parentNode.insertBefore(l,c)};if(c&&!a.__iconfont__svg__cssinject__){a.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(l){console&&console.log(l)}}t=function(){var l,c=document.createElement("div");c.innerHTML=a._iconfont_svg_string_4125778,(c=c.getElementsByTagName("svg")[0])&&(c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.width=0,c.style.height=0,c.style.overflow="hidden",c=c,(l=document.body).firstChild?m(c,l.firstChild):l.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(t,0):(h=function(){document.removeEventListener("DOMContentLoaded",h,!1),t()},document.addEventListener("DOMContentLoaded",h,!1)):document.attachEvent&&(i=t,o=a.document,z=!1,s(),o.onreadystatechange=function(){"complete"==o.readyState&&(o.onreadystatechange=null,v())})}function v(){z||(z=!0,i())}function s(){try{o.documentElement.doScroll("left")}catch(l){return void setTimeout(s,50)}v()}}(window);
\ No newline at end of file
diff --git a/web/src/assets/iconfont/iconfont.json b/web/src/assets/iconfont/iconfont.json
index 5094227..06eb9ce 100644
--- a/web/src/assets/iconfont/iconfont.json
+++ b/web/src/assets/iconfont/iconfont.json
@@ -5,6 +5,20 @@
"css_prefix_text": "icon-",
"description": "",
"glyphs": [
+ {
+ "icon_id": "1132455",
+ "name": "share-bold",
+ "font_class": "share-bold",
+ "unicode": "e626",
+ "unicode_decimal": 58918
+ },
+ {
+ "icon_id": "7567359",
+ "name": "cancel-share",
+ "font_class": "cancel-share",
+ "unicode": "e682",
+ "unicode_decimal": 59010
+ },
{
"icon_id": "12600976",
"name": "xls",
diff --git a/web/src/assets/iconfont/iconfont.ttf b/web/src/assets/iconfont/iconfont.ttf
index a00e66a..860d6be 100644
Binary files a/web/src/assets/iconfont/iconfont.ttf and b/web/src/assets/iconfont/iconfont.ttf differ
diff --git a/web/src/assets/iconfont/iconfont.woff b/web/src/assets/iconfont/iconfont.woff
index 0eb4791..9aa4b51 100644
Binary files a/web/src/assets/iconfont/iconfont.woff and b/web/src/assets/iconfont/iconfont.woff differ
diff --git a/web/src/assets/iconfont/iconfont.woff2 b/web/src/assets/iconfont/iconfont.woff2
index 1d906e0..1b52a11 100644
Binary files a/web/src/assets/iconfont/iconfont.woff2 and b/web/src/assets/iconfont/iconfont.woff2 differ
diff --git a/web/src/components/FileSelect.vue b/web/src/components/FileSelect.vue
index fe53994..58c59cc 100644
--- a/web/src/components/FileSelect.vue
+++ b/web/src/components/FileSelect.vue
@@ -1,10 +1,12 @@
-
-
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
@@ -442,7 +448,8 @@