feat(v1.11.5-L): lite 精简版——移除大屏/客户自查/多用户/小键盘,套餐仅保留按日
需求与确认(用户逐项确认): - 老数据「按次 / 通行证 / 深渊」统一迁移成按日,代码里彻底删除三种模式 - 打手归属一并移除(只剩一个人,颜色与指派没有区分意义) - 盲水印做成完全不可见:只存在于 DOM / 源码,肉眼与截图都看不到 - 拼写采用更正后的 Powered by Baka春秋 - 版本号与品牌全站统一带 -L - screen_public / portal_public 保留解析但不起作用,保证旧 ini 能直接启动 - README 同步更新 品牌与版本(全站统一): - const version = "1.11.5-L":<title>、启动横幅、日志前缀 [代打台-L]、 设置页版本号、页脚版本号全部带 -L - 左上角导航品牌 代打台 → 代打台-L(登录页、初始化页同步) - 页脚新增可见署名 Powered by Baka春秋 盲水印: - _layout.html 在 <body> 起始处注入 .wm-blind 容器(含注释与 data-wm 双标记), 覆盖包括登录/初始化在内的所有页面 - app.css 用零尺寸 + 透明 + opacity:0 + clip-path:inset(50%) 四重隐藏, 同时留同名注释;不占位、不上色、不进无障碍树、不影响打印 功能移除: - 大屏:删除 handlers_screen.go、pages/screen.html、_screen_layout.html、 static/screen.css、static/screen.js、store.Stats/ScreenStats; 导航「大屏 ↗」、页脚「大屏」、设置页「大屏刷新/大屏」行、启动横幅大屏行一并删除 - 客户自查:删除 handlers_portal.go、pages/portal.html 与 .portal-*/.pcal-* 样式, 设置页「客户自助」行删除 - 多管理员:删除 handleUserCreate/Toggle/Color/UserEditPage/UserEditSave、 pages/user_form.html、store 侧 ActiveUsers/SetUserColor/SetUserActive/ UpdateUserByAdmin/NormalizeColor/AssigneePalette;设置页「管理员」整块移除, 只保留首次启动创建的那一个账户与「修改我的密码」 - 打手归属:删除 customers.assignee_id 相关读写与 UI(客户详情指派下拉、 客户表单「归属打手」、日历格左侧打手色竖条、任务卡打手标签、套餐详情客户列) - 登录页与初始化页的说明文案同步改为单账户口径(「只有一个管理员账户」 「创建后不能再添加其他管理员」),字数与 main 对齐,卡片不换行、高度不变 - 触摸小键盘:删除 3×4 键盘、⌨/触控开关、localStorage 记忆、.keypad* 样式 - 套餐计费方式:只保留按日。删除按次/通行证/深渊的 Package 与 Subscription 字段、 domain 里的 UnitCount/StateUsedUp/CycleIndex、package_form 计费方式单选与 通行证/深渊/有效期字段、日历整段色块(has-block/cell-block/season-band)、 追加次数分支、SeasonComplete/AddCount、CountActiveSubs 的次数条件 数据库迁移(幂等,Migrate 内自动执行): - normalizeLegacyData:套餐一律 unit='day' 并清 season/abyss/cycle_days/ default_validity_days/season_*;订阅清 season/abyss/cycle_days/season_done - 通行证、深渊当年就是 unit='day' 且起止日完整,仅清标记,服务区间原样保留 - 按次按「1 次 = 1 天」折算:结束日 = 开始日 + 总次数 − 1;仍缺结束日退回开始日 - 只动数据,不删表不删列:老库的 season/abyss/cycle_days/total_count/used_count 保留但不再使用,升级可逆、不会因为 DDL 失败卡住 - 新库 schema 干净:不再创建上述列,users.color / customers.assignee_id 也不创建 - 老库 ensureColumn 保留 calendar_separate / tag / archived 三项(真增量列) 兼容: - config 仍解析 screen_public / portal_public(结构体字段注明已废弃), 默认 ini 模板里改为「已废弃,写了不报错、不生效」 测试: - go vet ./... 通过;go test ./... 全部通过 (新增 TestNormalizeLegacyTypeData 验证三模式折算成按日; TestSingleUserAccount / TestSessionLifecycle 覆盖单用户与会话; 删除按次、深渊、打手颜色、多用户等已不存在的能力的用例) - 新增 scripts/smoke-lite.ps1:起隔离实例,19 个页面级请求全部 200, 已移除的 /screen、/customer、/api/screen/day 均 404, 水印/品牌/v1.11.5-L/无残留词 12 项断言通过, 真实数据下日历出现待打任务、「剩 30 天」、今天到期徽标 4 项断言通过, 本次 0 失败 README:改为 lite 版说明,删除大屏/客户自查/通行证/深渊/按次/小键盘/多用户章节, 新增「盲水印」与「与 main 分支的差异」两节(含老数据折算规则与列保留说明)。
This commit is contained in:
@@ -26,20 +26,10 @@ type DayCell struct {
|
||||
DoneCount int
|
||||
UrgentCnt int
|
||||
Heat int
|
||||
// 通行证 / 深渊色块
|
||||
BlockColor string
|
||||
BlockDone int
|
||||
BlockTotal int
|
||||
BlockText string
|
||||
BlockTitle string
|
||||
// BlockPercent 色块底色浓度:通行证固定 18%,深渊按周期依次减淡
|
||||
BlockPercent int
|
||||
// PendingCount 当日还没完成的单数(= TaskCount - DoneCount)
|
||||
PendingCount int
|
||||
Tickets []Ticket
|
||||
More int
|
||||
// Strip 是左侧的打手色竖条(按出现顺序去重,未指派为灰)
|
||||
Strip []string
|
||||
}
|
||||
|
||||
// Ticket 是日历格里的色签。
|
||||
@@ -53,8 +43,6 @@ type Ticket struct {
|
||||
Skipped bool
|
||||
IsDue bool
|
||||
Urgent bool
|
||||
// AssigneeColor 打手颜色(未指派为空,模板用 spanAssignee 兜底)
|
||||
AssigneeColor string
|
||||
}
|
||||
|
||||
// TaskRow 是当日待打清单的一行。
|
||||
@@ -124,7 +112,6 @@ type calSub struct {
|
||||
start time.Time
|
||||
end time.Time
|
||||
hasEnd bool
|
||||
eval domain.Eval
|
||||
pauses []store.Pause
|
||||
checkins map[string]store.Checkin
|
||||
}
|
||||
@@ -141,93 +128,13 @@ func (c calSub) pausedOn(date string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// isBlock 是否为通行证 / 深渊这种整段型订阅。
|
||||
func (c calSub) isBlock() bool { return c.sub.IsBlock() }
|
||||
|
||||
// blockCovers 只判断日期是否落在整段区间内(已完成也继续显示色块)。
|
||||
func (c calSub) blockCovers(date string) bool {
|
||||
if c.sub.Status == domain.StatusClosed || !c.hasEnd {
|
||||
return false
|
||||
}
|
||||
return date >= c.sub.StartDate && date <= c.sub.EndDate
|
||||
}
|
||||
|
||||
// blockDone 返回整段型订阅的已完成数。
|
||||
func (c calSub) blockDone() int { return c.sub.BlockDone() }
|
||||
|
||||
// blockTotal 返回整段型订阅的总数。
|
||||
func (c calSub) blockTotal() int { return c.sub.BlockTotal() }
|
||||
|
||||
// cycleBounds 返回 date 所在深渊周期的起止日。
|
||||
func (c calSub) cycleBounds(date string) (string, string, bool) {
|
||||
if !c.sub.Abyss || c.sub.CycleDays <= 0 {
|
||||
return "", "", false
|
||||
}
|
||||
d, err := domain.ParseDate(date)
|
||||
if err != nil {
|
||||
return "", "", false
|
||||
}
|
||||
idx := domain.CycleIndex(c.start, d, c.sub.CycleDays)
|
||||
if idx < 0 || idx >= c.sub.TotalCount {
|
||||
return "", "", false
|
||||
}
|
||||
return domain.Date(domain.CycleStart(c.start, c.sub.CycleDays, idx)),
|
||||
domain.Date(domain.CycleEnd(c.start, c.sub.CycleDays, idx)), true
|
||||
}
|
||||
|
||||
// cycleDone 判断 date 所在周期是否已经完成(周期内任意一天打卡即算)。
|
||||
func (c calSub) cycleDone(date string) bool {
|
||||
s, e, ok := c.cycleBounds(date)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
for d, ci := range c.checkins {
|
||||
if d >= s && d <= e && ci.Status == "done" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// blockNeedsWork 表示这一天是否需要出现在待完成清单里。
|
||||
func (c calSub) blockNeedsWork(date string) bool {
|
||||
if !c.blockCovers(date) || c.sub.Status == domain.StatusClosed {
|
||||
return false
|
||||
}
|
||||
if c.sub.Season {
|
||||
return c.sub.SeasonDone == ""
|
||||
}
|
||||
if c.sub.Abyss {
|
||||
if c.sub.TotalCount <= 0 || c.sub.UsedCount >= c.sub.TotalCount {
|
||||
return false
|
||||
}
|
||||
return !c.cycleDone(date)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c calSub) covers(date string) bool {
|
||||
if c.sub.Status == domain.StatusClosed || !c.hasEnd {
|
||||
return false
|
||||
}
|
||||
if c.sub.Season {
|
||||
if c.sub.SeasonDone != "" {
|
||||
return false
|
||||
}
|
||||
return date >= c.sub.StartDate && date <= c.sub.EndDate
|
||||
}
|
||||
if c.sub.Abyss {
|
||||
if c.sub.TotalCount > 0 && c.sub.UsedCount >= c.sub.TotalCount {
|
||||
return false
|
||||
}
|
||||
return date >= c.sub.StartDate && date <= c.sub.EndDate && !c.pausedOn(date)
|
||||
}
|
||||
if date < c.sub.StartDate || date > c.sub.EndDate {
|
||||
return false
|
||||
}
|
||||
if c.sub.Unit == domain.UnitCount && c.eval.RemainingCount <= 0 {
|
||||
return false
|
||||
}
|
||||
return !c.pausedOn(date)
|
||||
}
|
||||
|
||||
@@ -277,21 +184,6 @@ func buildCalendarTabs(pkgs []store.Package, subs []store.Subscription, total in
|
||||
return tabs, true
|
||||
}
|
||||
|
||||
// wideFrom/wideTo 把打卡查询范围放大,保证跨月的深渊周期也能判定完成。
|
||||
func wideFrom(s string) string {
|
||||
if t, err := domain.ParseDate(s); err == nil {
|
||||
return domain.Date(domain.AddDays(t, -400))
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func wideTo(s string) string {
|
||||
if t, err := domain.ParseDate(s); err == nil {
|
||||
return domain.Date(domain.AddDays(t, 400))
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// loadCalendarSubs 读取区间内与日历相交的订阅;pkgID>0 取该套餐,tag 非空取该标签下的所有套餐。
|
||||
func (s *Server) loadCalendarSubs(from, to string, pkgID int64, tag string) ([]store.Subscription, map[int64][]store.Pause, map[int64]map[string]store.Checkin, map[int64]map[string]bool, error) {
|
||||
subs, err := s.db.CalendarSubs(from, to)
|
||||
@@ -327,7 +219,7 @@ func (s *Server) loadCalendarSubs(from, to string, pkgID int64, tag string) ([]s
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
}
|
||||
checkins, err := s.db.CheckinsBetween(wideFrom(from), wideTo(to))
|
||||
checkins, err := s.db.CheckinsBetween(from, to)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
}
|
||||
@@ -380,7 +272,6 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
cs := calSub{
|
||||
sub: sub,
|
||||
start: domain.ParseDateOr(sub.StartDate, today),
|
||||
eval: sub.Eval(today, warn),
|
||||
pauses: pauses[sub.ID],
|
||||
checkins: checkins[sub.ID],
|
||||
}
|
||||
@@ -443,20 +334,6 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
if !cell.InMonth {
|
||||
continue
|
||||
}
|
||||
if cs.isBlock() {
|
||||
if cs.blockCovers(ds) && cell.BlockText == "" {
|
||||
cell.BlockColor = cs.sub.PackageColor
|
||||
cell.BlockText = blockCellText(cs, ds)
|
||||
cell.BlockDone = 0
|
||||
if cell.BlockText == "1/1" {
|
||||
cell.BlockDone = 1
|
||||
}
|
||||
cell.BlockTotal = 1
|
||||
cell.BlockTitle = cs.sub.PackageName + " · " + cell.BlockText
|
||||
cell.BlockPercent = blockCellPercent(cs, day)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !cs.covers(ds) {
|
||||
continue
|
||||
}
|
||||
@@ -467,16 +344,15 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
cell.UrgentCnt++
|
||||
}
|
||||
t := Ticket{
|
||||
SubID: cs.sub.ID,
|
||||
Tail: cs.sub.CustomerTail,
|
||||
Name: cs.sub.CustomerName,
|
||||
Pkg: shortName(cs.sub.PackageName),
|
||||
Color: cs.sub.PackageColor,
|
||||
Done: ci.Status == "done",
|
||||
Skipped: ci.Status == "skipped",
|
||||
IsDue: cs.sub.EndDate == ds,
|
||||
Urgent: isUrgent,
|
||||
AssigneeColor: cs.sub.AssigneeColor,
|
||||
SubID: cs.sub.ID,
|
||||
Tail: cs.sub.CustomerTail,
|
||||
Name: cs.sub.CustomerName,
|
||||
Pkg: shortName(cs.sub.PackageName),
|
||||
Color: cs.sub.PackageColor,
|
||||
Done: ci.Status == "done",
|
||||
Skipped: ci.Status == "skipped",
|
||||
IsDue: cs.sub.EndDate == ds,
|
||||
Urgent: isUrgent,
|
||||
}
|
||||
if t.Done || t.Skipped {
|
||||
cell.DoneCount++
|
||||
@@ -492,8 +368,6 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
return tickets[i].SubID < tickets[j].SubID
|
||||
})
|
||||
// 竖条按“当天全部任务”算,不能被色签的 3 条上限截断
|
||||
cell.Strip = assigneeStrip(tickets)
|
||||
if len(tickets) > 3 {
|
||||
cell.More = len(tickets) - 3
|
||||
tickets = tickets[:3]
|
||||
@@ -519,21 +393,6 @@ func (s *Server) handleCalendar(w http.ResponseWriter, r *http.Request) {
|
||||
if cs.sub.EndDate == sel {
|
||||
due = append(due, newSubView(cs.sub, today, warn))
|
||||
}
|
||||
if cs.isBlock() {
|
||||
if !cs.blockNeedsWork(sel) {
|
||||
continue
|
||||
}
|
||||
row := TaskRow{SubView: newSubView(cs.sub, today, warn), Urgent: urgent[cs.sub.ID][sel]}
|
||||
if ci, ok := checkins[cs.sub.ID][sel]; ok {
|
||||
row.CheckinID = ci.ID
|
||||
row.Done = ci.Status == "done"
|
||||
row.Skipped = ci.Status == "skipped"
|
||||
row.Note = ci.Note
|
||||
row.Operator = ci.OperatorName
|
||||
}
|
||||
tasks = append(tasks, row)
|
||||
continue
|
||||
}
|
||||
if !cs.covers(sel) {
|
||||
continue
|
||||
}
|
||||
@@ -642,70 +501,6 @@ func sortTasks(tasks []TaskRow) {
|
||||
})
|
||||
}
|
||||
|
||||
// assigneeStrip 把一格里所有任务的打手颜色去重后返回,未指派用灰色占位。
|
||||
func assigneeStrip(tickets []Ticket) []string {
|
||||
if len(tickets) == 0 {
|
||||
return nil
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
out := make([]string, 0, 4)
|
||||
for _, t := range tickets {
|
||||
c := t.AssigneeColor
|
||||
if c == "" {
|
||||
c = "#8A8F98"
|
||||
}
|
||||
if seen[c] {
|
||||
continue
|
||||
}
|
||||
seen[c] = true
|
||||
out = append(out, c)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// blockCellText 整段型订阅在 date 所在周期的完成文本:
|
||||
// 通行证 0/1 或 1/1;深渊按 date 所在的那一个周期 0/1 或 1/1,不显示全局 x/N。
|
||||
func blockCellText(cs calSub, date string) string {
|
||||
if cs.sub.Abyss {
|
||||
if cs.cycleDone(date) {
|
||||
return "1/1"
|
||||
}
|
||||
return "0/1"
|
||||
}
|
||||
if cs.sub.SeasonDone != "" {
|
||||
return "1/1"
|
||||
}
|
||||
return "0/1"
|
||||
}
|
||||
|
||||
// blockCellPercent 整段型色块浓度:通行证 18%;深渊按所在周期 34%→4%。
|
||||
func blockCellPercent(cs calSub, day time.Time) int {
|
||||
if cs.sub.Abyss && cs.sub.CycleDays > 0 {
|
||||
idx := domain.CycleIndex(cs.start, day, cs.sub.CycleDays)
|
||||
return abyssBlockPercent(idx, cs.sub.TotalCount)
|
||||
}
|
||||
return 18
|
||||
}
|
||||
|
||||
// abyssBlockPercent 深渊色块浓度:第一个周期 34%,之后每个周期依次减淡,
|
||||
// 最后一个周期 4%(周期数大于 1 时线性过渡);跨度比 v1.11.3 的 22%→10% 明显更大。
|
||||
func abyssBlockPercent(idx, total int) int {
|
||||
if total <= 1 {
|
||||
return 34
|
||||
}
|
||||
if idx < 0 {
|
||||
idx = 0
|
||||
}
|
||||
if idx >= total {
|
||||
idx = total - 1
|
||||
}
|
||||
pct := 34 - (idx*30)/(total-1)
|
||||
if pct < 4 {
|
||||
pct = 4
|
||||
}
|
||||
return pct
|
||||
}
|
||||
|
||||
func heatLevel(n int) int {
|
||||
switch {
|
||||
case n <= 0:
|
||||
|
||||
Reference in New Issue
Block a user