mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	feat: system notice function is ready
This commit is contained in:
		@@ -6,6 +6,7 @@
 | 
			
		||||
* 功能新增:后台新增配置微信客服二维码,可以上传自己的微信客服二维码
 | 
			
		||||
* 功能新增:新增网站公告,可以在管理后台自定义配置
 | 
			
		||||
* 功能新增:新增阿里通义千问大模型支持
 | 
			
		||||
* Bug修复:修复 MJ 放大任务失败时候 img_call 会增加的 Bug
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## v3.2.5
 | 
			
		||||
 
 | 
			
		||||
@@ -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())
 | 
			
		||||
 
 | 
			
		||||
@@ -227,37 +227,14 @@
 | 
			
		||||
    </el-dialog>
 | 
			
		||||
 | 
			
		||||
    <el-dialog
 | 
			
		||||
        v-model="showDemoNotice"
 | 
			
		||||
        v-model="showNotice"
 | 
			
		||||
        :show-close="true"
 | 
			
		||||
        custom-class="notice-dialog"
 | 
			
		||||
        title="网站公告"
 | 
			
		||||
    >
 | 
			
		||||
      <div class="notice">
 | 
			
		||||
        <el-text type="primary">
 | 
			
		||||
          注意:当前站点仅为开源项目
 | 
			
		||||
          <a style="color: #F56C6C" href="https://github.com/yangjian102621/chatgpt-plus" target="_blank">ChatPlus</a>
 | 
			
		||||
          的演示项目,本项目单纯就是给大家体验项目功能使用。<br/>
 | 
			
		||||
 | 
			
		||||
          体验额度用完之后请不要在当前站点进行任何充值操作!!!<br/>
 | 
			
		||||
          体验额度用完之后请不要在当前站点进行任何充值操作!!!<br/>
 | 
			
		||||
          体验额度用完之后请不要在当前站点进行任何充值操作!!!<br/>
 | 
			
		||||
 | 
			
		||||
          如果觉得好用你就花几分钟自己部署一套,没有API KEY 的同学可以去
 | 
			
		||||
          <a href="https://gpt.bemore.lol" target="_blank"
 | 
			
		||||
             style="font-size: 20px;color:#F56C6C">https://gpt.bemore.lol</a>
 | 
			
		||||
          购买,现在有超级优惠,价格远低于 OpenAI 官方。<br/>
 | 
			
		||||
          GPT-3.5,GPT-4,DALL-E3 绘图......你都可以随意使用,无需魔法。<br/>
 | 
			
		||||
 | 
			
		||||
          MidJourney API 购买地址:
 | 
			
		||||
          <a href="https://api.chat-plus.net" target="_blank"
 | 
			
		||||
             style="font-size: 20px;color:#F56C6C">https://api.chat-plus.net</a><br/>
 | 
			
		||||
 | 
			
		||||
          接入教程: <a href="https://ai.r9it.com/docs/install/" target="_blank"
 | 
			
		||||
                       style="font-size: 20px;color:#F56C6C">https://ai.r9it.com/docs/install/</a><br/>
 | 
			
		||||
 | 
			
		||||
          本项目源码地址:
 | 
			
		||||
          <a href="https://github.com/yangjian102621/chatgpt-plus" target="_blank">
 | 
			
		||||
            https://github.com/yangjian102621/chatgpt-plus
 | 
			
		||||
          </a>
 | 
			
		||||
          <div v-html="notice"></div>
 | 
			
		||||
        </el-text>
 | 
			
		||||
 | 
			
		||||
        <p style="text-align: right">
 | 
			
		||||
@@ -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) => {
 | 
			
		||||
 | 
			
		||||
<style scoped lang="stylus">
 | 
			
		||||
@import "@/assets/css/chat-plus.styl"
 | 
			
		||||
</style>
 | 
			
		||||
 | 
			
		||||
<style lang="stylus">
 | 
			
		||||
.notice-dialog {
 | 
			
		||||
  .el-dialog__body {
 | 
			
		||||
    padding 0 20px
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -261,6 +261,9 @@
 | 
			
		||||
      </el-tab-pane>
 | 
			
		||||
      <el-tab-pane label="公告配置" name="notice">
 | 
			
		||||
        <md-editor class="mgb20" v-model="notice" @on-upload-img="onUploadImg"/>
 | 
			
		||||
        <el-form-item>
 | 
			
		||||
          <el-button type="primary" @click="save('notice')">保存</el-button>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-tab-pane>
 | 
			
		||||
    </el-tabs>
 | 
			
		||||
  </div>
 | 
			
		||||
@@ -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)
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user