mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-26 19:16:24 +00:00
feat: add sidebar component with context and mobile support
- Implemented Sidebar component with collapsible functionality. - Added SidebarProvider for managing open state and keyboard shortcuts. - Created SidebarTrigger, SidebarRail, and various sidebar elements (Header, Footer, Content, etc.). - Integrated mobile responsiveness using Sheet component. - Added utility hooks for mobile detection. feat: create table component for structured data display - Developed Table component with subcomponents: TableHeader, TableBody, TableFooter, TableRow, TableCell, and TableCaption. - Enhanced styling for better readability and usability. feat: implement tabs component for navigation - Created Tabs component with TabsList, TabsTrigger, and TabsContent for tabbed navigation. - Ensured accessibility and responsive design. feat: add toggle group component for grouped toggle buttons - Developed ToggleGroup and ToggleGroupItem components for managing toggle states. - Integrated context for consistent styling and behavior. feat: create toggle component for binary state representation - Implemented Toggle component with variant and size options. - Enhanced user interaction with visual feedback. feat: add tooltip component for contextual information - Developed Tooltip, TooltipTrigger, and TooltipContent for displaying additional information on hover. - Integrated animations for a smoother user experience. feat: implement mobile detection hook - Created useIsMobile hook to determine if the user is on a mobile device. - Utilized matchMedia for responsive design adjustments.
This commit is contained in:
@ -22,7 +22,7 @@ type Post struct {
|
||||
LikeCount uint64
|
||||
CommentCount uint64
|
||||
ViewCount uint64
|
||||
Heat uint64 `gorm:"default:0"`
|
||||
Heat uint64
|
||||
}
|
||||
|
||||
// CalculateHeat 热度计算
|
||||
@ -34,17 +34,6 @@ func (p *Post) CalculateHeat() float64 {
|
||||
)
|
||||
}
|
||||
|
||||
// AfterUpdate 热度指标更新后更新热度
|
||||
func (p *Post) AfterUpdate(tx *gorm.DB) (err error) {
|
||||
if tx.Statement.Changed("LikeCount") || tx.Statement.Changed("CommentCount") || tx.Statement.Changed("ViewCount") {
|
||||
p.Heat = uint64(p.CalculateHeat())
|
||||
if err := tx.Model(p).Update("heat", p.Heat).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Post) ToDto() *dto.PostDto {
|
||||
return &dto.PostDto{
|
||||
ID: p.ID,
|
||||
@ -65,7 +54,7 @@ func (p *Post) ToDto() *dto.PostDto {
|
||||
LikeCount: p.LikeCount,
|
||||
CommentCount: p.CommentCount,
|
||||
ViewCount: p.ViewCount,
|
||||
Heat: p.Heat,
|
||||
Heat: uint64(p.CalculateHeat()),
|
||||
CreatedAt: p.CreatedAt,
|
||||
UpdatedAt: p.UpdatedAt,
|
||||
User: p.User.ToDto(),
|
||||
|
Reference in New Issue
Block a user