Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(playerIntersectionActions): 播放器位置动作自动开灯未关闭星光动画 #4169

Draft
wants to merge 2 commits into
base: preview-fixes
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
},
"eslint.format.enable": true,
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[vue]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
Expand Down
2 changes: 1 addition & 1 deletion registry/lib/components/video/player/auto-light/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { lightOn, lightOff } from '@/components/video/player-light'
import { videoChange } from '@/core/observer'
import { allVideoUrls } from '@/core/utils/urls'
import type { PlayerAgent } from '@/components/video/player-agent/base'
import { StarAnim } from './animation'
import { StarAnim } from '@/components/video/player-animation'
import { defineComponentMetadata } from '@/components/define'

let playerAgentInstance: PlayerAgent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const component = defineComponentMetadata({
triggerLocation: IntersectionMode
pause: boolean
light: boolean
starAnim: boolean
}
Promise.resolve().then(async () => {
const {
Expand Down Expand Up @@ -144,5 +145,9 @@ export const component = defineComponentMetadata({
defaultValue: true,
displayName: '自动开灯',
},
starAnim: {
defaultValue: true,
displayName: '启用星光动画',
},
},
})
2 changes: 1 addition & 1 deletion registry/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"../src/**/*.d.ts",
"lib/**/*.ts"
],
}
}
6 changes: 3 additions & 3 deletions src/components/video/player-agent/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ export abstract class PlayerAgent {

/** true 开灯,false 关灯 */
async toggleLight(on: boolean) {
const checkbox = (await this.query.control.settings.lightOff()) as HTMLInputElement
const checkboxLight = (await this.query.control.settings.lightOff()) as HTMLInputElement
// 关灯状态 && 要开灯 -> 开灯
checkbox.checked && on && checkbox.click()
checkboxLight.checked && on && checkboxLight.click()
// 开灯状态 && 要关灯 -> 关灯
!checkbox.checked && !on && checkbox.click()
!checkboxLight.checked && !on && checkboxLight.click()
}

// eslint-disable-next-line class-methods-use-this
Expand Down
1 change: 1 addition & 0 deletions src/components/video/player-agent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface PlayerQuery<QueryResult> extends CustomNestedQuery<QueryResult>
settings: {
wrap: QueryResult
lightOff: QueryResult
starAnimEnable: QueryResult
}
}
toastWrap: QueryResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const CreateAnim = (): void => {
// 添加一段css 样式到document最后
const style = document.createElement('style')
// generate random stars
function generate(numCtrl) {
function generate(numCtrl: number) {
let star = ''
const max = window.innerWidth * window.innerHeight
for (let i = 0; i < max / numCtrl; i++) {
Expand Down
1 change: 1 addition & 0 deletions src/components/video/player-light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { matchUrlPattern, none } from '@/core/utils'
import { loadLazyPlayerSettingsPanel } from '@/core/utils/lazy-panel'
import { playerUrls } from '@/core/utils/urls'
import { playerAgent } from './player-agent'
import { StarAnim } from '@/components/video/player-animation'

// let initialized = false

Expand Down