diff --git a/admin/filter_clear_template_test.go b/admin/filter_clear_template_test.go new file mode 100644 index 0000000..ed2c54a --- /dev/null +++ b/admin/filter_clear_template_test.go @@ -0,0 +1,51 @@ +package main + +import ( + "os" + "strings" + "testing" +) + +func TestListFilterTemplates_清除入口紧邻搜索且只保留必要参数(t *testing.T) { + tests := []struct { + name string + path string + clearURL string + }{ + { + name: "蝦皮数据保留独立查看范围", + path: "templates/shopee/list.html", + clearURL: `/shopee?{{if .DeletedFilter}}deleted=1&{{end}}{{if .UnlinkedFilter}}unlinked=1&{{end}}page_size={{.CurrentPageSize}}`, + }, + {name: "PDD 商品", path: "templates/pdd/list.html", clearURL: `/pdd?page_size={{.CurrentPageSize}}`}, + {name: "采集采购", path: "templates/task/list.html", clearURL: `/tasks?page_size={{.CurrentPageSize}}`}, + {name: "客户端列表", path: "templates/client/list.html", clearURL: `/clients?page_size={{.CurrentPageSize}}`}, + {name: "用户管理", path: "templates/user/list.html", clearURL: `/users?page_size={{.CurrentPageSize}}`}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + raw, err := os.ReadFile(tt.path) + if err != nil { + t.Fatal(err) + } + page := string(raw) + clearLink := `class="button-link" href="` + tt.clearURL + `">清除` + clearIndex := strings.Index(page, clearLink) + if clearIndex < 0 { + t.Fatalf("缺少清除入口或链接参数不正确: %s", clearLink) + } + searchIndex := strings.Index(page[clearIndex:], ``) + if searchIndex < 0 { + t.Fatal("清除入口后没有搜索按钮") + } + between := page[clearIndex+len(clearLink) : clearIndex+searchIndex] + if strings.Contains(between, " + 清除 diff --git a/admin/templates/pdd/list.html b/admin/templates/pdd/list.html index 297fe42..950eca3 100644 --- a/admin/templates/pdd/list.html +++ b/admin/templates/pdd/list.html @@ -40,6 +40,7 @@ 用类名而不是改 .toolbar input[type="text"]——那条规则被 5 个页面共用。 */}} + 清除 diff --git a/admin/templates/shopee/list.html b/admin/templates/shopee/list.html index 1943ba7..992eafc 100644 --- a/admin/templates/shopee/list.html +++ b/admin/templates/shopee/list.html @@ -41,6 +41,7 @@ + 清除 diff --git a/admin/templates/task/list.html b/admin/templates/task/list.html index 2bd130d..47510c8 100644 --- a/admin/templates/task/list.html +++ b/admin/templates/task/list.html @@ -40,6 +40,7 @@ 用类名而不是改 .toolbar input[type="text"]——那条被五个页面共用。 */}} + 清除 diff --git a/admin/templates/user/list.html b/admin/templates/user/list.html index 59c62b8..24fe73d 100644 --- a/admin/templates/user/list.html +++ b/admin/templates/user/list.html @@ -13,6 +13,7 @@ + 清除 diff --git a/docs/admin/05-ui-specification.md b/docs/admin/05-ui-specification.md index 8a58f75..826e2a8 100644 --- a/docs/admin/05-ui-specification.md +++ b/docs/admin/05-ui-specification.md @@ -21,7 +21,7 @@ ┌────────────────────────────────────────────────────────────┐ │ [导航] 蝦皮数据 │ PDD 商品 │ 顺运宝数据 │ 采集采购 │ 客户端 │ ├────────────────────────────────────────────────────────────┤ -│ 顶部工具条:[操作按钮…] [搜索框] [搜索] [删除] │ +│ 顶部工具条:[操作按钮…] [搜索框] [清除] [搜索] [删除] │ ├────────────────────────────────────────────────────────────┤ │ ☐ │ 列1 │ 列2 │ 列3 │ … │ │ ☐ │ │ │ │ │ @@ -92,6 +92,11 @@ `[建议]` placeholder 要短。收到 30% 之后长文案显示不全—— 真装不下就缩短文案,**不要把宽度调回去**。 +`[必须]` 有搜索或筛选条件的主列表,在“搜索”按钮前提供常驻“清除”入口。清除后移除 +该列表的关键词、状态、类型、创建人等普通查询条件,省略 `page` 回到第 1 页,同时保留 +归一化后的 `page_size`。回收站、未登记商品等独立查看范围不是普通搜索条件,清除时应 +继续保留,避免操作员意外离开当前范围。该入口使用普通 GET 链接,不依赖 JavaScript。 + ### 3.2 分页 `[必须]` 使用公共分页的列表(蝦皮、PDD、顺运宝、采集采购、客户端、用户、 @@ -713,7 +718,7 @@ ID 和在线状态;所有可见 Client 都可选择且只有一个时自动选 ### 7.1 工具条 ```text -[类型▾ 全部] [状态▾ 全部] [创建人▾ 全部] 关键词[___] [搜索] [删除] +[类型▾ 全部] [状态▾ 全部] [创建人▾ 全部] 关键词[___] [清除] [搜索] [删除] ``` - **类型**:全部 / 采集 / 采购。 @@ -834,7 +839,7 @@ placeholder 写「任务编号 / 订单号 / 商品 ID」,**不要写全「PDD ## 8. 客户端列表页 -管理员工具条:`名称 [____] [搜索] [删除]`;采购员不显示删除按钮。 +管理员工具条:`名称 [____] [清除] [搜索] [删除]`;采购员不显示删除按钮。 管理员表格列:☐ / 名称 / 序列号 / 状态 / 当前负责人 / 最近活动 / 更新时间 / 操作 @@ -890,7 +895,7 @@ placeholder 写「任务编号 / 订单号 / 商品 ID」,**不要写全「PDD 只有管理员显示“用户管理”导航并可访问 `/users`。采购员访问时返回 `403`。 -工具条:`用户名 [____] 状态 [全部⌄] [搜索] [新增采购员]` +工具条:`用户名 [____] 状态 [全部⌄] [清除] [搜索] [新增采购员]` 表格列:用户名 / 角色 / 状态 / 最后登录 / 创建时间 / 操作