mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 15:05:01 +08:00
模块化上传驱动,使用泛型优化工具库降低冗余
This commit is contained in:
@@ -3,11 +3,9 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package view
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hotgo/internal/consts"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
@@ -44,41 +42,6 @@ func (s *viewBuildIn) UrlPath() string {
|
||||
return s.httpRequest.URL.Path
|
||||
}
|
||||
|
||||
// FormatTime 格式化时间
|
||||
func (s *viewBuildIn) FormatTime(gt *gtime.Time) string {
|
||||
if gt == nil {
|
||||
return ""
|
||||
}
|
||||
n := gtime.Now().Timestamp()
|
||||
t := gt.Timestamp()
|
||||
|
||||
var ys int64 = 31536000
|
||||
var ds int64 = 86400
|
||||
var hs int64 = 3600
|
||||
var ms int64 = 60
|
||||
var ss int64 = 1
|
||||
|
||||
var rs string
|
||||
|
||||
d := n - t
|
||||
switch {
|
||||
case d > ys:
|
||||
rs = fmt.Sprintf("%d年前", int(d/ys))
|
||||
case d > ds:
|
||||
rs = fmt.Sprintf("%d天前", int(d/ds))
|
||||
case d > hs:
|
||||
rs = fmt.Sprintf("%d小时前", int(d/hs))
|
||||
case d > ms:
|
||||
rs = fmt.Sprintf("%d分钟前", int(d/ms))
|
||||
case d > ss:
|
||||
rs = fmt.Sprintf("%d秒前", int(d/ss))
|
||||
default:
|
||||
rs = "刚刚"
|
||||
}
|
||||
|
||||
return rs
|
||||
}
|
||||
|
||||
// Version 随机数 开发环境时间戳,线上为前端版本号
|
||||
func (s *viewBuildIn) Version() string {
|
||||
var rand string
|
||||
|
Reference in New Issue
Block a user