fix: 订阅模式登录验证、永久会员类型区分、动态代码HTTP返回值修复、侧边栏滚动位置保持
- 修复订阅模式登录时错误检查余额的问题 - 区分无限余额和永久订阅两种永久会员类型 - 修复动态代码HTTP请求返回值在JS中无法正确访问的问题 - 添加侧边栏滚动位置保持功能 - 移除developer角色相关代码,统一使用admin - 添加缺失的i18n翻译key
This commit is contained in:
@@ -1,14 +1,57 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from "vue"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { ref, onMounted, onUnmounted, nextTick } from "vue"
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes["class"]
|
||||
}>()
|
||||
|
||||
const scrollRef = ref<HTMLElement | null>(null)
|
||||
const scrollPositionKey = 'sidebar-scroll-position'
|
||||
let saveTimeout: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
function saveScrollPosition() {
|
||||
if (scrollRef.value) {
|
||||
sessionStorage.setItem(scrollPositionKey, scrollRef.value.scrollTop.toString())
|
||||
}
|
||||
}
|
||||
|
||||
function handleScroll() {
|
||||
if (saveTimeout) {
|
||||
clearTimeout(saveTimeout)
|
||||
}
|
||||
saveTimeout = setTimeout(saveScrollPosition, 50)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const saved = sessionStorage.getItem(scrollPositionKey)
|
||||
if (saved) {
|
||||
nextTick(() => {
|
||||
if (scrollRef.value) {
|
||||
scrollRef.value.scrollTop = parseFloat(saved)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (scrollRef.value) {
|
||||
scrollRef.value.addEventListener('scroll', handleScroll, { passive: true })
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (scrollRef.value) {
|
||||
scrollRef.value.removeEventListener('scroll', handleScroll)
|
||||
}
|
||||
if (saveTimeout) {
|
||||
clearTimeout(saveTimeout)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
ref="scrollRef"
|
||||
data-slot="sidebar-content"
|
||||
data-sidebar="content"
|
||||
:class="cn('flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden', props.class)"
|
||||
|
||||
Reference in New Issue
Block a user