From 479f94c372e77a6051d1cfb01a31e00cd42bfd4e Mon Sep 17 00:00:00 2001 From: RockYang Date: Fri, 19 Jan 2024 18:18:10 +0800 Subject: [PATCH] feat: system notice function is ready --- CHANGELOG.md | 1 + api/handler/admin/config_handler.go | 7 ++-- web/src/views/ChatPlus.vue | 63 +++++++++++++---------------- web/src/views/admin/SysConfig.vue | 18 ++++++++- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f916b18b..edb0a36f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * 功能新增:后台新增配置微信客服二维码,可以上传自己的微信客服二维码 * 功能新增:新增网站公告,可以在管理后台自定义配置 * 功能新增:新增阿里通义千问大模型支持 +* Bug修复:修复 MJ 放大任务失败时候 img_call 会增加的 Bug ## v3.2.5 diff --git a/api/handler/admin/config_handler.go b/api/handler/admin/config_handler.go index 41791464..8c5cbcbf 100644 --- a/api/handler/admin/config_handler.go +++ b/api/handler/admin/config_handler.go @@ -33,8 +33,9 @@ func (h *ConfigHandler) Update(c *gin.Context) { resp.ERROR(c, types.InvalidArgs) return } - str := utils.JsonEncode(&data.Config) - config := model.Config{Key: data.Key, Config: str} + + value := utils.JsonEncode(&data.Config) + config := model.Config{Key: data.Key, Config: value} res := h.db.FirstOrCreate(&config, model.Config{Key: data.Key}) if res.Error != nil { resp.ERROR(c, res.Error.Error()) @@ -42,7 +43,7 @@ func (h *ConfigHandler) Update(c *gin.Context) { } if config.Id > 0 { - config.Config = str + config.Config = value res := h.db.Updates(&config) if res.Error != nil { resp.ERROR(c, res.Error.Error()) diff --git a/web/src/views/ChatPlus.vue b/web/src/views/ChatPlus.vue index 0cfab75b..456a8ac4 100644 --- a/web/src/views/ChatPlus.vue +++ b/web/src/views/ChatPlus.vue @@ -227,37 +227,14 @@
- 注意:当前站点仅为开源项目 - ChatPlus - 的演示项目,本项目单纯就是给大家体验项目功能使用。
- - 体验额度用完之后请不要在当前站点进行任何充值操作!!!
- 体验额度用完之后请不要在当前站点进行任何充值操作!!!
- 体验额度用完之后请不要在当前站点进行任何充值操作!!!
- - 如果觉得好用你就花几分钟自己部署一套,没有API KEY 的同学可以去 - https://gpt.bemore.lol - 购买,现在有超级优惠,价格远低于 OpenAI 官方。
- GPT-3.5,GPT-4,DALL-E3 绘图......你都可以随意使用,无需魔法。
- - MidJourney API 购买地址: - https://api.chat-plus.net
- - 接入教程: https://ai.r9it.com/docs/install/
- - 本项目源码地址: - - https://github.com/yangjian102621/chatgpt-plus - +

@@ -323,8 +300,9 @@ const isLogin = ref(false) const showHello = ref(true) const textInput = ref(null) const showFeedbackDialog = ref(false) -const showDemoNotice = ref(false) -const showNoticeKey = ref("SHOW_DEMO_NOTICE_") +const showNotice = ref(false) +const notice = ref("") +const noticeKey = ref("SYSTEM_NOTICE") const wechatCardURL = ref("/images/wx.png") if (isMobile()) { @@ -372,16 +350,25 @@ onMounted(() => { ElMessage.error("加载会话列表失败!") }) + // 获取系统配置 httpGet("/api/admin/config/get?key=system").then(res => { title.value = res.data.title - const show = localStorage.getItem(showNoticeKey.value + loginUser.value.username) - if (!show) { - showDemoNotice.value = res.data['show_demo_notice'] - } wechatCardURL.value = res.data['wechat_card_url'] }).catch(e => { ElMessage.error("获取系统配置失败:" + e.message) }) + + // 获取系统公告 + httpGet("/api/admin/config/get?key=notice").then(res => { + notice.value = md.render(res.data['content']) + const oldNotice = localStorage.getItem(noticeKey.value); + // 如果公告有更新,则显示公告 + if (oldNotice !== notice.value) { + showNotice.value = true + } + }).catch(e => { + ElMessage.error("获取系统配置失败:" + e.message) + }) }).catch(() => { router.push('/login') }); @@ -900,8 +887,8 @@ const getModelValue = (model_id) => { const notShow = () => { - localStorage.setItem(showNoticeKey.value + loginUser.value.username, true) - showDemoNotice.value = false + localStorage.setItem(noticeKey.value, notice.value) + showNotice.value = false } // 插入文件路径 @@ -912,4 +899,12 @@ const insertURL = (url) => { + + \ No newline at end of file diff --git a/web/src/views/admin/SysConfig.vue b/web/src/views/admin/SysConfig.vue index 9449cad0..74266f2d 100644 --- a/web/src/views/admin/SysConfig.vue +++ b/web/src/views/admin/SysConfig.vue @@ -261,6 +261,9 @@ + + 保存 +

@@ -305,13 +308,20 @@ onMounted(() => { // 加载聊天配置 httpGet('/api/admin/config/get?key=chat').then(res => { chat.value = res.data - loading.value = false }).catch(e => { ElMessage.error("加载聊天配置失败: " + e.message) }) + // 加载聊天配置 + httpGet('/api/admin/config/get?key=notice').then(res => { + notice.value = res.data['content'] + }).catch(e => { + ElMessage.error("公告信息失败: " + e.message) + }) + httpGet('/api/admin/model/list').then(res => { models.value = res.data + loading.value = false }).catch(e => { ElMessage.error("获取模型失败:" + e.message) }) @@ -350,6 +360,12 @@ const save = function (key) { }) } }) + } else if (key === 'notice') { + httpPost('/api/admin/config/update', {key: key, config: {content: notice.value, updated: true}}).then(() => { + ElMessage.success("操作成功!") + }).catch(e => { + ElMessage.error("操作失败:" + e.message) + }) } }