Compare commits

...
5 Commits
Author SHA1 Message Date
github-actions[bot] febe890ecb chore: release v2.5.2 2023-03-19 11:49:07 +00:00
qwqcode 1be2ad4d6e perf(style): add !important for white-space css in code block (#467)
Signed-off-by: qwqcode <qwqcode@gmail.com>
2023-03-19 19:47:15 +08:00
qwqcode 848969edbc perf(notify): shorten the length of notify key (#466)
Signed-off-by: qwqcode <qwqcode@gmail.com>
2023-03-19 19:43:20 +08:00
qwqcode f0d93ad736 fix(ui): destroy instance when calling init func twice
Signed-off-by: qwqcode <qwqcode@gmail.com>
2023-03-17 15:54:08 +08:00
qwqcode 9fb17d0483 chore(typo): fix filename typo
Signed-off-by: qwqcode <qwqcode@gmail.com>
2023-03-17 09:13:53 +08:00
12 changed files with 35 additions and 15 deletions

No files matched your search

+12
View File
@@ -1,4 +1,16 @@
## [v2.5.2](https://github.com/ArtalkJS/Artalk/compare/v2.5.1...v2.5.2) (2023-03-19)
### Bug Fixes
* **ui:** destroy instance when calling init func twice
### Performance Improvements
* **notify:** shorten the length of notify key ([#466](https://github.com/ArtalkJS/Artalk/issues/466))
* **style:** add `!important` for white-space css in code block ([#467](https://github.com/ArtalkJS/Artalk/issues/467))
## [v2.5.1](https://github.com/ArtalkJS/Artalk/compare/v2.5.0...v2.5.1) (2023-03-16)
### Features
+1 -1
View File
@@ -1,3 +1,3 @@
{
"latest": "2.5.1"
"latest": "2.5.2"
}
+1 -1
View File
@@ -63,7 +63,7 @@ func Gen(genType string, specificPath string, overwrite bool) {
logrus.Info("File Generated: " + absPath)
}
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*")
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*1234567890")
func RandStringRunes(n int) string {
b := make([]rune, n)
+7 -3
View File
@@ -1,11 +1,10 @@
package entity
import (
"fmt"
"math/rand"
"sync"
"time"
"github.com/ArtalkJS/Artalk/internal/utils"
"gorm.io/gorm"
)
@@ -36,5 +35,10 @@ func (n *Notify) SetComment(comment Comment) {
// 操作时的验证密钥(判断是否本人操作)
func (n *Notify) GenerateKey() {
n.Key = utils.GetMD5Hash(fmt.Sprintf("%v %v %v", n.UserID, n.CommentID, time.Now().Unix()))
letterRunes := []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
b := make([]rune, 5)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
n.Key = string(b)
}
File renamed without changes.
+2 -2
View File
@@ -174,9 +174,9 @@ func FindNotify(userID uint, commentID uint) entity.Notify {
return notify
}
func FindNotifyByKey(key string) entity.Notify {
func FindNotifyForComment(commentID uint, key string) entity.Notify {
var notify entity.Notify
DB().Where(entity.Notify{Key: key}).First(&notify)
DB().Where(entity.Notify{CommentID: commentID, Key: key}).First(&notify)
return notify
}
+4 -2
View File
@@ -8,6 +8,7 @@ import (
)
type ParamsMarkRead struct {
CommentID uint `form:"comment_id"`
NotifyKey string `form:"notify_key"`
Name string `form:"name"`
@@ -22,7 +23,8 @@ type ParamsMarkRead struct {
// @Summary Notify Mark Read
// @Description Mark specific notification as read for user
// @Tags Notify
// @Param notify_key formData string true "the notify key you want to mark as read"
// @Param comment_id formData int true "the comment id of the notify you want to mark as read"
// @Param notify_key formData string true "the key of the notify"
// @Param name formData string false "the username"
// @Param email formData string false "the user email"
// @Param all_read formData bool false "the option if mark all user's notify as read"
@@ -55,7 +57,7 @@ func MarkRead(router fiber.Router) {
}
// find notify
notify := query.FindNotifyByKey(p.NotifyKey)
notify := query.FindNotifyForComment(p.CommentID, p.NotifyKey)
if notify.IsEmpty() {
return common.RespError(c, i18n.T("{{name}} not found", Map{"name": i18n.T("Notify")}))
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "artalk",
"version": "2.5.1",
"version": "2.5.2",
"license": "LGPL-3.0",
"description": "A Selfhosted Comment System",
"keywords": [
+3 -1
View File
@@ -56,12 +56,14 @@ export default class UserApi extends ApiBase {
}
/** 已读标记 */
public markRead(notifyKey: string, readAll = false) {
public markRead(commentID: number, notifyKey: string, readAll = false) {
const params: any = {
comment_id: commentID,
notify_key: notifyKey,
}
if (readAll) {
delete params.comment_id
delete params.notify_key
params.read_all = true
params.name = User.data.nick
+2 -2
View File
@@ -32,7 +32,7 @@ export default class Artalk {
public static DisabledComponents: string[] = []
constructor(conf: Partial<ArtalkConfig>) {
if (Artalk.instance) return Artalk.instance.update(conf)
if (Artalk.instance) Artalk.destroy()
// 初始化基本配置
this.conf = handelBaseConf(conf)
@@ -57,7 +57,7 @@ export default class Artalk {
/** Init Artalk */
public static init(conf: Partial<ArtalkConfig>): Artalk {
if (this.instance) return this.instance.update(conf) // 单例模式
if (this.instance) Artalk.destroy()
this.instance = new Artalk(conf)
return this.instance
}
+1 -1
View File
@@ -142,7 +142,7 @@ export default class List extends ListLite {
// 已阅 API
const notifyKey = Utils.getQueryParam('atk_notify_key')
if (notifyKey) {
this.ctx.getApi().user.markRead(notifyKey)
this.ctx.getApi().user.markRead(commentId, notifyKey)
.then(() => {
this.unread = this.unread.filter(o => o.comment_id !== commentId)
this.updateUnread(this.unread)
+1 -1
View File
@@ -51,7 +51,7 @@
line-height: $line-height;
display: block;
padding: 10px 15px;
white-space: pre-wrap;
white-space: pre-wrap !important;
background-color: var(--at-color-bg-grey);
color: var(--at-color-font);
margin: 0;