From 660c56db448b4ed0c2296e93201fe66459340409 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Sat, 25 Jul 2026 14:59:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B8=A0=E9=81=93=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.go | 35 ++++++++----- frontend/src/main.js | 78 +++++++++++++++++++++++++++- frontend/src/style.css | 98 ++++++++++++++++++++++++++++++++++- frontend/wailsjs/go/models.ts | 4 ++ internal/hfb/parser.go | 58 +++++++++++++++++++-- internal/hfb/parser_test.go | 30 ++++++++++- internal/hfb/types.go | 16 +++--- internal/hfb/upload_test.go | 2 +- 8 files changed, 292 insertions(+), 29 deletions(-) diff --git a/app.go b/app.go index 5941833..ac80d85 100644 --- a/app.go +++ b/app.go @@ -37,18 +37,20 @@ type App struct { } type DefaultSettings struct { - Server string `json:"server"` - Uploader string `json:"uploader"` - Secret string `json:"secret"` - Timeout string `json:"timeout"` + Server string `json:"server"` + Uploader string `json:"uploader"` + Secret string `json:"secret"` + Timeout string `json:"timeout"` + SourceChannel string `json:"sourceChannel"` } type UploadForm struct { - Server string `json:"server"` - Uploader string `json:"uploader"` - Secret string `json:"secret"` - Timeout string `json:"timeout"` - Data string `json:"data"` + Server string `json:"server"` + Uploader string `json:"uploader"` + Secret string `json:"secret"` + Timeout string `json:"timeout"` + SourceChannel string `json:"sourceChannel"` + Data string `json:"data"` } func NewApp() *App { @@ -61,10 +63,11 @@ func (a *App) startup(ctx context.Context) { func (a *App) DefaultSettings() DefaultSettings { return DefaultSettings{ - Server: envDefault("HFB_SERVER", "http://127.0.0.1:8080"), - Uploader: strings.TrimSpace(os.Getenv("HFB_UPLOADER_NAME")), - Secret: strings.TrimSpace(os.Getenv("HFB_UPLOAD_SECRET")), - Timeout: "15s", + Server: envDefault("HFB_SERVER", "http://127.0.0.1:8080"), + Uploader: strings.TrimSpace(os.Getenv("HFB_UPLOADER_NAME")), + Secret: strings.TrimSpace(os.Getenv("HFB_UPLOAD_SECRET")), + Timeout: "15s", + SourceChannel: strings.TrimSpace(os.Getenv("HFB_SOURCE_CHANNEL")), } } @@ -125,7 +128,11 @@ func buildUploadRequest(form UploadForm) (hfb.ExternalUploadRequest, error) { if uploaderName == "" { return hfb.ExternalUploadRequest{}, fmt.Errorf("缺少上传人名称:请展开“连接配置”填写上传人,或在文本中增加“上传人:姓名”") } - return hfb.NewExternalUploadRequest(uploaderName, parsed.Account, time.Now()), nil + sourceChannel := strings.TrimSpace(form.SourceChannel) + if sourceChannel == "" { + return hfb.ExternalUploadRequest{}, fmt.Errorf("请选择订单来源渠道") + } + return hfb.NewExternalUploadRequest(uploaderName, sourceChannel, parsed.Account, time.Now()), nil } func parseTimeout(raw string) (time.Duration, error) { diff --git a/frontend/src/main.js b/frontend/src/main.js index f2a8009..91dc970 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -2,6 +2,8 @@ import './style.css'; import { ClipboardGetText } from '../wailsjs/runtime/runtime.js'; const storageKey = 'hfb-upload-settings'; +const customChannelValue = '__custom__'; +const sourceChannelOptions = ['咸鱼', '淘宝', '京东', 'QQ', '微信']; const app = document.querySelector('#app'); @@ -37,6 +39,26 @@ app.innerHTML = ` +
+ 来源渠道 +
+ ${sourceChannelOptions + .map( + (item) => ` + ` + ) + .join('')} + + +
+
+