From ec00f156f0f5d057f80e2cfc27e88616428e2eea Mon Sep 17 00:00:00 2001 From: RockYang Date: Wed, 6 Aug 2025 17:58:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=A7=BB=E5=8A=A8=E7=AB=AFSu?= =?UTF-8?q?no=E9=A1=B5=E9=9D=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/service/suno/service.go | 7 +- web/src/utils/dialog.js | 21 + .../views/mobile/components/CustomSelect.vue | 116 +++ .../mobile/components/CustomSelectOption.vue | 50 + web/src/views/mobile/pages/SunoCreate.vue | 946 +++++++++++------- 5 files changed, 791 insertions(+), 349 deletions(-) create mode 100644 web/src/views/mobile/components/CustomSelect.vue create mode 100644 web/src/views/mobile/components/CustomSelectOption.vue diff --git a/api/service/suno/service.go b/api/service/suno/service.go index 6bf11c5e..936b4ee4 100644 --- a/api/service/suno/service.go +++ b/api/service/suno/service.go @@ -112,6 +112,10 @@ type RespVo struct { Message string `json:"message"` Data string `json:"data"` Channel string `json:"channel,omitempty"` + Error struct { + Message string `json:"message"` + Type string `json:"type"` + } `json:"error,omitempty"` } func (s *Service) Create(task types.SunoTask) (RespVo, error) { @@ -154,13 +158,14 @@ func (s *Service) Create(task types.SunoTask) (RespVo, error) { } body, _ := io.ReadAll(r.Body) + logger.Debugf("API response: %s", string(body)) err = json.Unmarshal(body, &res) if err != nil { return RespVo{}, fmt.Errorf("解析API数据失败:%v, %s", err, string(body)) } if res.Code != "success" { - return RespVo{}, fmt.Errorf("API 返回失败:%s", res.Message) + return RespVo{}, fmt.Errorf("API 返回失败:%s", res.Error.Message) } // update the last_use_at for api key apiKey.LastUsedAt = time.Now().Unix() diff --git a/web/src/utils/dialog.js b/web/src/utils/dialog.js index 52a9b941..cba7c8df 100644 --- a/web/src/utils/dialog.js +++ b/web/src/utils/dialog.js @@ -56,3 +56,24 @@ export function showLoading(message = '正在处理...') { export function closeLoading() { closeToast() } + +// 自定义 Toast 消息系统 +export function showToastMessage(message, type = 'info', duration = 3000) { + const toast = document.createElement('div') + toast.className = `fixed top-20 left-1/2 transform -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-white font-medium ${ + type === 'error' ? 'bg-red-500' : type === 'success' ? 'bg-green-500' : 'bg-blue-500' + } animate-fade-in` + toast.textContent = message + document.body.appendChild(toast) + + if (duration > 0) { + setTimeout(() => { + toast.classList.add('animate-fade-out') + setTimeout(() => { + if (document.body.contains(toast)) { + document.body.removeChild(toast) + } + }, 300) + }, duration) + } +} diff --git a/web/src/views/mobile/components/CustomSelect.vue b/web/src/views/mobile/components/CustomSelect.vue new file mode 100644 index 00000000..b52fc5f6 --- /dev/null +++ b/web/src/views/mobile/components/CustomSelect.vue @@ -0,0 +1,116 @@ + + + + + diff --git a/web/src/views/mobile/components/CustomSelectOption.vue b/web/src/views/mobile/components/CustomSelectOption.vue new file mode 100644 index 00000000..8a16ec8e --- /dev/null +++ b/web/src/views/mobile/components/CustomSelectOption.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/web/src/views/mobile/pages/SunoCreate.vue b/web/src/views/mobile/pages/SunoCreate.vue index 9999d141..286574e4 100644 --- a/web/src/views/mobile/pages/SunoCreate.vue +++ b/web/src/views/mobile/pages/SunoCreate.vue @@ -1,235 +1,475 @@