- 数据库与后端:announcements 表增加 is_popup 字段及迁移脚本,提供前台弹窗接口与多公告优先级选取,补全选优单测 - 管理后台:总后台与分销后台公告编辑新增「弹窗公告」开关与列表标签展示 - 前台交互:前台 PC/移动端首页引入 AnnouncementPopup,支持同一用户同一天同一公告仅弹一次的关闭记录 - 视觉优化:重构弹窗结构,顶栏镶嵌品牌橙流光细条与浅暖橙通知徽标,中间内嵌浅灰舒适阅读卡片,底部搭配大锤橙实心主操作按钮 - 验证方式:后端 announcement 单测通过,前端 npm run build 编译无报错,浏览器实机截图验证
36 lines
1.6 KiB
Go
36 lines
1.6 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
// 公告中心来源模式(distribution_sites.announcement_mode):
|
|
// - inherit:分站展示主站公告 + 本站公告(默认)
|
|
// - own_only:分站只展示本站公告
|
|
const (
|
|
AnnouncementModeInherit = "inherit"
|
|
AnnouncementModeOwnOnly = "own_only"
|
|
)
|
|
|
|
type Announcement struct {
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
// DistributionSiteID 公告归属站点:0=主站,>0=对应分站(分站公告中心按站点隔离)。
|
|
DistributionSiteID uint64 `gorm:"not null;default:0;index" json:"distribution_site_id"`
|
|
Title string `gorm:"size:255;not null" json:"title"`
|
|
Content string `gorm:"type:text;not null" json:"content"`
|
|
Category string `gorm:"size:32;not null;default:'notice'" json:"category"`
|
|
Priority int `gorm:"not null;default:0" json:"priority"`
|
|
IsPinned bool `gorm:"not null;default:false" json:"is_pinned"`
|
|
IsImportant bool `gorm:"not null;default:false" json:"is_important"`
|
|
// IsPopup 标记弹窗公告:前台首页弹出且需用户手动关闭,多条生效时只弹优先级最高的一条。
|
|
IsPopup bool `gorm:"not null;default:false" json:"is_popup"`
|
|
ViewCount int `gorm:"not null;default:0" json:"view_count"`
|
|
Status string `gorm:"size:32;not null;default:'draft'" json:"status"`
|
|
PublishedAt *time.Time `json:"published_at"`
|
|
CreatedBy *uint64 `json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (Announcement) TableName() string {
|
|
return "announcements"
|
|
}
|