issues: 功能优化和体验优化 (#972)

* pref: 优化小屏幕下 cherry-markdown.css 样式

* fix: 修复 markdown 上传图片功能没有回显链接问题

* fix: #853 修复文章被删除后可以从缓存读取

* feat: #834 增加文章私有状态, 文章分类下不展示私有文章
pull/975/head
zhanzhenping 2024-07-24 09:20:06 +08:00 committed by GitHub
parent cd9667bba7
commit acf3c46e82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 52 additions and 36 deletions

View File

@ -128,7 +128,7 @@ func (c *BlogController) ManageList() {
pageIndex, _ := c.GetInt("page", 1)
blogList, totalCount, err := models.NewBlog().FindToPager(pageIndex, conf.PageSize, c.Member.MemberId, "")
blogList, totalCount, err := models.NewBlog().FindToPager(pageIndex, conf.PageSize, c.Member.MemberId, "all")
if err != nil {
c.ShowErrorPage(500, err.Error())
@ -168,7 +168,7 @@ func (c *BlogController) ManageSetting() {
if strings.Count(blogExcerpt, "") > 500 {
c.JsonResult(6008, i18n.Tr(c.Lang, "message.blog_digest_tips"))
}
if blogStatus != "public" && blogStatus != "password" && blogStatus != "draft" {
if blogStatus != "private" && blogStatus != "public" && blogStatus != "password" && blogStatus != "draft" {
blogStatus = "public"
}
if blogStatus == "password" && blogPassword == "" {

View File

@ -239,7 +239,7 @@ func (b *Blog) Save(cols ...string) error {
b.Modified = time.Now()
_, err = o.Update(b, cols...)
key := fmt.Sprintf("blog-id-%d", b.BlogId)
cache.Delete(key)
_ = cache.Delete(key)
} else {
@ -297,10 +297,14 @@ func (b *Blog) FindToPager(pageIndex, pageSize int, memberId int, status string)
if memberId > 0 {
query = query.Filter("member_id", memberId)
}
if status != "" {
if status != "" && status != "all" {
query = query.Filter("blog_status", status)
}
if status == "" {
query = query.Filter("blog_status__ne", "private")
}
_, err = query.OrderBy("-order_index", "-blog_id").Offset(offset).Limit(pageSize).All(&blogList)
if err != nil {
@ -328,6 +332,9 @@ func (b *Blog) FindToPager(pageIndex, pageSize int, memberId int, status string)
// 删除文章
func (b *Blog) Delete(blogId int) error {
// 删除文章缓存
key := fmt.Sprintf("blog-id-%d", blogId)
_ = cache.Delete(key)
o := orm.NewOrm()
_, err := o.QueryTable(b.TableNameWithPrefix()).Filter("blog_id", blogId).Delete()

View File

@ -6078,3 +6078,15 @@ span.change {
border-radius: 10px !important;
background-color: #b3d4fc !important;
}
@media screen and (max-width: 1400px) {
.cherry-toolbar-button {
padding: 0;
}
.cherry-toolbar .toolbar-left {
justify-content: space-between;
width: 95%;
}
}

View File

@ -51,7 +51,7 @@
"<label>" + imageLang.url + "</label>" +
"<input type=\"text\" data-url />" + (function() {
return (settings.imageUpload) ? "<div class=\"" + classPrefix + "file-input\">" +
// 3xxx 下行添加multiple=\"multiple\"
// 3xxx <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>multiple=\"multiple\"
"<input type=\"file\" name=\"" + classPrefix + "image-file\" accept=\"image/jpeg,image/png,image/gif,image/jpg\" multiple=\"multiple\" />" +
"<input type=\"submit\" value=\"" + imageLang.uploadButton + "\" />" +
"</div>" : "";
@ -78,7 +78,7 @@
opacity: settings.dialogMaskOpacity,
backgroundColor: settings.dialogMaskBgColor
},
// 这里将多图片地址改造后插入文档中
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>
buttons: {
enter: [lang.buttons.enter, function() {
var url = this.find("[data-url]").val();
@ -88,7 +88,7 @@
alert(imageLang.imageURLEmpty);
return false;
}
// 这里增加循环
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD>
let arr = url.split(";");
var altAttr = (alt !== "") ? " \"" + alt + "\"" : "";
for (let i = 0; i < arr.length; i++) {
@ -121,19 +121,19 @@
fileInput.bind("change", function() {
// 3xxx 20240602
// let formData = new FormData();
// 获取文本框dom
// <EFBFBD><EFBFBD>ȡ<EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>dom
// var doc = document.getElementById('doc');
// 获取上传控件dom
// <EFBFBD><EFBFBD>ȡ<EFBFBD>ϴ<EFBFBD><EFBFBD>ؼ<EFBFBD>dom
// var upload = document.getElementById('upload');
// let files = upload.files;
//遍历文件信息append到formData存储
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>Ϣappend<EFBFBD><EFBFBD>formData<EFBFBD>
// for (let i = 0; i < files.length; i++) {
// let file = files[i]
// formData.append('files', file)
// }
// 获取文件名
// <EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
// var fileName = upload.files[0].name;
// 获取文件路径
// <EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
// var filePath = upload.value;
// doc.value = fileName;
// 3xxx
@ -161,16 +161,10 @@
var json = (body.innerText) ? body.innerText : ((body.textContent) ? body.textContent : null);
json = (typeof JSON.parse !== "undefined") ? JSON.parse(json) : eval("(" + json + ")");
var url="";
for (let i = 0; i < json.length; i++) {
if (json[i].success === 1) {
if (i==0){
url=json[i].url;
if (json.success === 1) {
url=json.url;
} else {
url=url+";"+json[i].url;
}
} else {
alert(json[i].message);
}
alert(json.message);
}
dialog.find("[data-url]").val(url)
return false;

View File

@ -79,9 +79,12 @@
<label class="radio-inline">
<input type="radio" {{if eq .Model.BlogStatus "password"}}checked{{end}} name="status" value="password">{{i18n .Lang "blog.encryption"}}<span class="text"></span>
</label>
<label class="radio-inline">
<input type="radio" {{if eq .Model.BlogStatus "private"}}checked{{end}} name="status" value="private">{{i18n .Lang "blog.private"}}<span class="text"></span>
</label>
</div>
</div>
<div class="form-group"{{if eq .Model.BlogStatus "public"}} style="display: none;"{{end}} id="blogPassword">
<div class="form-group"{{if ne .Model.BlogStatus "password"}} style="display: none;"{{end}} id="blogPassword">
<label>{{i18n .Lang "blog.blog_pwd"}}</label>
<input type="password" class="form-control" name="password" id="password" placeholder="{{i18n .Lang "blog.blog_pwd"}}" value="{{.Model.Password}}" maxlength="20">
</div>