diff --git a/api/handler/admin/function_handler.go b/api/handler/admin/function_handler.go
index 8eff4cbd..816161b5 100644
--- a/api/handler/admin/function_handler.go
+++ b/api/handler/admin/function_handler.go
@@ -6,6 +6,7 @@ import (
"chatplus/handler"
"chatplus/store/model"
"chatplus/store/vo"
+ "chatplus/utils"
"chatplus/utils/resp"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
@@ -29,8 +30,18 @@ func (h *FunctionHandler) Save(c *gin.Context) {
return
}
- logger.Info(data)
- resp.SUCCESS(c)
+ var f = model.Function{
+ Id: data.Id,
+ Name: data.Name,
+ Description: data.Description,
+ Parameters: utils.JsonEncode(data.Parameters),
+ Required: utils.JsonEncode(data.Required),
+ Action: data.Action,
+ Enabled: false,
+ }
+
+ logger.Info(f)
+ resp.SUCCESS(c, data)
}
func (h *FunctionHandler) List(c *gin.Context) {
diff --git a/api/service/mj/bot.go b/api/service/mj/bot.go
index 2d78b65c..4e2b2f5a 100644
--- a/api/service/mj/bot.go
+++ b/api/service/mj/bot.go
@@ -25,7 +25,9 @@ type Bot struct {
func NewBot(name string, proxy string, config *types.MidJourneyConfig, service *Service) (*Bot, error) {
discord, err := discordgo.New("Bot " + config.BotToken)
+ logger.Info(config.BotToken)
if err != nil {
+ logger.Error(err)
return nil, err
}
diff --git a/api/service/mj/client.go b/api/service/mj/client.go
index 7eb15bb4..de4d7dc1 100644
--- a/api/service/mj/client.go
+++ b/api/service/mj/client.go
@@ -21,7 +21,6 @@ func NewClient(config types.MidJourneyConfig, proxy string) *Client {
if proxy != "" {
client.SetProxyURL(proxy)
}
- logger.Info(config)
return &Client{client: client, config: config}
}
diff --git a/web/src/views/admin/Functions.vue b/web/src/views/admin/Functions.vue
index fa28cb2a..b514004d 100644
--- a/web/src/views/admin/Functions.vue
+++ b/web/src/views/admin/Functions.vue
@@ -10,11 +10,10 @@
{{ scope.row.name }}
-
-
+
+
- 启用
- 禁用
+
@@ -163,7 +162,9 @@ onMounted(() => {
const fetch = () => {
httpGet('/api/admin/function/list').then((res) => {
- tableData.value = res.data
+ if (res.data) {
+ tableData.value = res.data
+ }
loading.value = false
}).catch(() => {
ElMessage.error("获取数据失败");
@@ -199,12 +200,12 @@ const save = function () {
item.value.parameters = {type: "object", "properties": properties, "required": required}
httpPost('/api/admin/function/save', item.value).then((res) => {
ElMessage.success('操作成功')
- // 更新当前数据行
- // if (item.value.id) {
- // tableData.value[curIndex.value] = item.value
- // } else {
- // tableData.value.push(res.data)
- // }
+ console.log(res.data)
+ if (item.value.id > 0) {
+ tableData.value[curIndex.value] = item.value
+ } else {
+ tableData.value.push(res.data)
+ }
}).catch((e) => {
ElMessage.error('操作失败,' + e.message)
})
@@ -225,13 +226,17 @@ const addParam = function () {
if (!params.value) {
item.value = []
}
- params.value.push({name: "", type: "", desc: "", required: false})
+ params.value.push({name: "", type: "string", desc: "", required: false})
}
const removeParam = function (index) {
params.value.splice(index, 1);
}
+const functionSet = (row) => {
+
+}
+