Merge pull request #120 from 2311719626/feat/task-logs-virtual-scroll
feat(task-logs): 优化任务中心日志前端展示 & fix(auth): 移除安全漏洞
This commit is contained in:
@@ -240,6 +240,31 @@ function selectTask(taskId: string) {
|
|||||||
void loadLogs(taskId)
|
void loadLogs(taskId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrollToBottom() {
|
||||||
|
if (!autoScroll.value) return
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
if (logContainerRef.value) {
|
||||||
|
logContainerRef.value.scrollTop = logContainerRef.value.scrollHeight
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleScroll() {
|
||||||
|
if (!logContainerRef.value) return
|
||||||
|
|
||||||
|
const { scrollTop, scrollHeight, clientHeight } = logContainerRef.value
|
||||||
|
const distanceFromBottom = scrollHeight - scrollTop - clientHeight
|
||||||
|
|
||||||
|
// 距离底部小于 50px 时认为在底部,恢复自动滚动
|
||||||
|
if (distanceFromBottom < 50) {
|
||||||
|
autoScroll.value = true
|
||||||
|
} else if (distanceFromBottom > 100) {
|
||||||
|
// 用户向上滚动超过 100px 时暂停自动滚动
|
||||||
|
autoScroll.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function refreshCurrent() {
|
function refreshCurrent() {
|
||||||
void loadTasks()
|
void loadTasks()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ func AuthMiddleware(cfg config.Config) gin.HandlerFunc {
|
|||||||
tokenValue := ""
|
tokenValue := ""
|
||||||
if strings.HasPrefix(value, "Bearer ") {
|
if strings.HasPrefix(value, "Bearer ") {
|
||||||
tokenValue = strings.TrimPrefix(value, "Bearer ")
|
tokenValue = strings.TrimPrefix(value, "Bearer ")
|
||||||
} else {
|
|
||||||
tokenValue = strings.TrimSpace(c.Query("access_token"))
|
|
||||||
}
|
}
|
||||||
if tokenValue == "" {
|
if tokenValue == "" {
|
||||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "missing bearer token"})
|
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "missing bearer token"})
|
||||||
|
|||||||
Reference in New Issue
Block a user