mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-12-19 19:57:09 +08:00
User
refactor and update i18n, to be continue
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/beego/i18n"
|
||||
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
@@ -43,6 +45,8 @@ type Document struct {
|
||||
//是否展开子目录:0 否/1 是 /2 空间节点,单击时展开下一级
|
||||
IsOpen int `orm:"column(is_open);type(int);default(0)" json:"is_open"`
|
||||
AttachList []*Attachment `orm:"-" json:"attach"`
|
||||
//i18n
|
||||
Lang string `orm:"-"`
|
||||
}
|
||||
|
||||
// 多字段唯一键
|
||||
@@ -275,7 +279,7 @@ func (item *Document) Processor() *Document {
|
||||
//处理附件
|
||||
attachList, err := NewAttachment().FindListByDocumentId(item.DocumentId)
|
||||
if err == nil && len(attachList) > 0 {
|
||||
content := bytes.NewBufferString("<div class=\"attach-list\"><strong>附件</strong><ul>")
|
||||
content := bytes.NewBufferString("<div class=\"attach-list\"><strong>" + i18n.Tr(item.Lang, "doc.attachment") + "</strong><ul>")
|
||||
for _, attach := range attachList {
|
||||
if strings.HasPrefix(attach.HttpPath, "/") {
|
||||
attach.HttpPath = strings.TrimSuffix(conf.BaseUrl, "/") + attach.HttpPath
|
||||
@@ -305,7 +309,7 @@ func (item *Document) Processor() *Document {
|
||||
docCreator, err := NewMember().Find(item.MemberId, "real_name", "account")
|
||||
release := "<div class=\"wiki-bottom\">"
|
||||
|
||||
release += "作者:"
|
||||
release += i18n.Tr(item.Lang, "doc.ft_author")
|
||||
if err == nil && docCreator != nil {
|
||||
if docCreator.RealName != "" {
|
||||
release += docCreator.RealName
|
||||
@@ -313,19 +317,19 @@ func (item *Document) Processor() *Document {
|
||||
release += docCreator.Account
|
||||
}
|
||||
}
|
||||
release += " 创建时间:" + item.CreateTime.Local().Format("2006-01-02 15:04") + "<br>"
|
||||
release += " " + i18n.Tr(item.Lang, "doc.ft_create_time") + item.CreateTime.Local().Format("2006-01-02 15:04") + "<br>"
|
||||
|
||||
if item.ModifyAt > 0 {
|
||||
docModify, err := NewMember().Find(item.ModifyAt, "real_name", "account")
|
||||
if err == nil {
|
||||
if docModify.RealName != "" {
|
||||
release += "最后编辑:" + docModify.RealName
|
||||
release += i18n.Tr(item.Lang, "doc.ft_last_editor") + docModify.RealName
|
||||
} else {
|
||||
release += "最后编辑:" + docModify.Account
|
||||
release += i18n.Tr(item.Lang, "doc.ft_last_editor") + docModify.Account
|
||||
}
|
||||
}
|
||||
}
|
||||
release += " 更新时间:" + item.ModifyTime.Local().Format("2006-01-02 15:04") + "<br>"
|
||||
release += " " + i18n.Tr(item.Lang, "doc.ft_update_time") + item.ModifyTime.Local().Format("2006-01-02 15:04") + "<br>"
|
||||
release += "</div>"
|
||||
|
||||
if selector := docQuery.Find("div.markdown-article").First(); selector.Size() > 0 {
|
||||
|
||||
Reference in New Issue
Block a user