mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
feat: 添加初始加载时不显示toast的时间阈值
This commit is contained in:
parent
894eb2823e
commit
8f34721551
@ -41,3 +41,6 @@ export const TOAST_DURATION_CONFIG = {
|
||||
|
||||
// Toast显示类名
|
||||
export const TOAST_CLASS_NAME = 'be-video-scale-toast'
|
||||
|
||||
// 页面加载后不显示toast的时间阈值(毫秒)
|
||||
export const NO_TOAST_TIME_THRESHOLD = 3000
|
||||
|
||||
@ -4,7 +4,12 @@ import { componentsTags } from '@/components/component'
|
||||
import { videoChange } from '@/core/observer'
|
||||
import { ScaleState, applyScale, updateScaleFromSettings } from './scale-service'
|
||||
import { showScaleToast, cleanupToasts, handleError } from './ui-utils'
|
||||
import { CUSTOM_SCALE_CONFIG, SCALE_PRESETS, TOAST_DURATION_CONFIG } from './constants'
|
||||
import {
|
||||
CUSTOM_SCALE_CONFIG,
|
||||
SCALE_PRESETS,
|
||||
TOAST_DURATION_CONFIG,
|
||||
NO_TOAST_TIME_THRESHOLD,
|
||||
} from './constants'
|
||||
import { ScalePreset } from './types'
|
||||
import './styles.scss'
|
||||
|
||||
@ -55,6 +60,9 @@ export const component = defineComponentMetadata({
|
||||
// 缩放状态管理
|
||||
const scaleState = new ScaleState()
|
||||
|
||||
// 记录页面加载时间
|
||||
const pageLoadTime = Date.now()
|
||||
|
||||
// 初始化时根据showToast状态设置toastDuration的可见性
|
||||
toastDurationOption.hidden = !settings.options.showToast
|
||||
|
||||
@ -68,8 +76,11 @@ export const component = defineComponentMetadata({
|
||||
try {
|
||||
await applyScale(scale)
|
||||
|
||||
// 检查是否启用了toast显示
|
||||
if (settings.options.showToast) {
|
||||
// 检查是否启用了toast显示,且缩放比例不是100%,且已过3秒加载时间
|
||||
const currentTime = Date.now()
|
||||
const hasPassedInitialTime = currentTime - pageLoadTime >= NO_TOAST_TIME_THRESHOLD
|
||||
|
||||
if (settings.options.showToast && scale !== 100 && hasPassedInitialTime) {
|
||||
showScaleToast(scale, settings.options.toastDuration as number)
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user