mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-03 15:12:10 +08:00
在设置界面返回时,不再直接返回桌面
This commit is contained in:
parent
ccff6596bd
commit
a316732622
@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
globalThis.lx_setup = (key, id, name, description, rawScript) => {
|
||||
globalThis.lx_setup = (key, id, name, description) => {
|
||||
delete globalThis.lx_setup
|
||||
const _nativeCall = globalThis.__lx_native_call__
|
||||
delete globalThis.__lx_native_call__
|
||||
@ -471,18 +471,6 @@ globalThis.lx_setup = (key, id, name, description, rawScript) => {
|
||||
globalThis.setTimeout = _setTimeout
|
||||
globalThis.clearTimeout = _clearTimeout
|
||||
globalThis.window = globalThis
|
||||
globalThis.document = {
|
||||
getElementsByTagName(name) {
|
||||
if (name == 'script') {
|
||||
return [
|
||||
Object.freeze({
|
||||
innerText: rawScript,
|
||||
}),
|
||||
]
|
||||
}
|
||||
return null
|
||||
},
|
||||
}
|
||||
|
||||
const freezeObject = (obj) => {
|
||||
if (typeof obj != 'object') return
|
||||
|
@ -123,7 +123,7 @@ public class QuickJS {
|
||||
});
|
||||
}
|
||||
|
||||
private boolean createJSEnv(String id, String name, String desc, String rawScript) {
|
||||
private boolean createJSEnv(String id, String name, String desc) {
|
||||
init();
|
||||
QuickJSContext quickJSContext = this.jsContext;
|
||||
if (quickJSContext != null) quickJSContext.destroy();
|
||||
@ -134,7 +134,7 @@ public class QuickJS {
|
||||
if (preloadScript == null) return false;
|
||||
createEnvObj(this.jsContext);
|
||||
this.jsContext.evaluate(preloadScript);
|
||||
this.jsContext.getGlobalObject().getJSFunction("lx_setup").call(this.key, id, name, desc, rawScript);
|
||||
this.jsContext.getGlobalObject().getJSFunction("lx_setup").call(this.key, id, name, desc);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -148,12 +148,11 @@ public class QuickJS {
|
||||
|
||||
public String loadScript(Bundle scriptInfo) {
|
||||
Log.d("UserApi", "UserApi Thread id: " + Thread.currentThread().getId());
|
||||
String script = scriptInfo.getString("script", "");
|
||||
if (createJSEnv(scriptInfo.getString("id", ""),
|
||||
scriptInfo.getString("name", "Unknown"),
|
||||
scriptInfo.getString("description", ""), script)) {
|
||||
scriptInfo.getString("description", ""))) {
|
||||
try {
|
||||
this.jsContext.evaluate(script);
|
||||
this.jsContext.evaluate(scriptInfo.getString("script", ""));
|
||||
return "";
|
||||
} catch (Exception e) {
|
||||
Log.e("UserApi", "load script error: " + e.getMessage());
|
||||
|
@ -6,6 +6,7 @@
|
||||
### 优化
|
||||
|
||||
- 添加是否忽略电池优化检查,用于提醒用户添加白名单,确保APP后台播放稳定性
|
||||
- 在设置界面返回时,不再直接返回桌面,将回到进入设置界面前的界面,再非设置界面返回时才会返回桌面
|
||||
|
||||
### 修复
|
||||
|
||||
|
@ -78,8 +78,11 @@ export const removeComponentId = (name: string) => {
|
||||
export const setNavActiveId = (id: Parameters<typeof commonActions.setNavActiveId>['0']) => {
|
||||
if (id == commonState.navActiveId) return
|
||||
commonActions.setNavActiveId(id)
|
||||
if (id != 'nav_setting') {
|
||||
commonActions.setLastNavActiveId(id)
|
||||
saveViewPrevState({ id })
|
||||
}
|
||||
}
|
||||
|
||||
export const showPactModal = () => {
|
||||
handleShowPactModal()
|
||||
|
@ -136,10 +136,10 @@ export function pushPlayDetailScreen(componentId: string) {
|
||||
style: getStatusBarStyle(theme.isDark),
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
// navigationBar: {
|
||||
// // visible: false,
|
||||
// backgroundColor: theme['c-content-background'],
|
||||
// },
|
||||
navigationBar: {
|
||||
// visible: false,
|
||||
backgroundColor: theme['c-content-background'],
|
||||
},
|
||||
layout: {
|
||||
componentBackgroundColor: theme['c-content-background'],
|
||||
},
|
||||
@ -231,10 +231,10 @@ export function pushSonglistDetailScreen(componentId: string, id: string) {
|
||||
style: getStatusBarStyle(theme.isDark),
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
// navigationBar: {
|
||||
// // visible: false,
|
||||
// backgroundColor: theme['c-content-background'],
|
||||
// },
|
||||
navigationBar: {
|
||||
// visible: false,
|
||||
backgroundColor: theme['c-content-background'],
|
||||
},
|
||||
layout: {
|
||||
componentBackgroundColor: theme['c-content-background'],
|
||||
},
|
||||
@ -366,10 +366,10 @@ export function pushCommentScreen(componentId: string) {
|
||||
style: getStatusBarStyle(theme.isDark),
|
||||
backgroundColor: 'transparent',
|
||||
},
|
||||
// navigationBar: {
|
||||
// // visible: false,
|
||||
// backgroundColor: theme['c-content-background'],
|
||||
// },
|
||||
navigationBar: {
|
||||
// visible: false,
|
||||
backgroundColor: theme['c-content-background'],
|
||||
},
|
||||
layout: {
|
||||
componentBackgroundColor: theme['c-content-background'],
|
||||
},
|
||||
|
@ -120,10 +120,12 @@ export default memo(({ componentId }: {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
if (!playerState.playMusicInfo.musicInfo) return
|
||||
let playerMusicInfo = playerState.playMusicInfo.musicInfo
|
||||
if ('progress' in playerMusicInfo) playerMusicInfo = playerMusicInfo.metadata.musicInfo
|
||||
setMusicInfo(playerMusicInfo)
|
||||
}, 300)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
|
@ -1,12 +1,23 @@
|
||||
import { useWindowSize } from '@/utils/hooks'
|
||||
import Vertical from './Vertical'
|
||||
import Horizontal from './Horizontal'
|
||||
import { useBackHandler } from '@/utils/hooks/useBackHandler'
|
||||
import { useCallback } from 'react'
|
||||
// import { AppColors } from '@/theme'
|
||||
import commonState from '@/store/common/state'
|
||||
import { setNavActiveId } from '@/core/common'
|
||||
|
||||
export type { SettingScreenIds } from './Main'
|
||||
|
||||
export default () => {
|
||||
const windowSize = useWindowSize()
|
||||
useBackHandler(useCallback(() => {
|
||||
if (Object.keys(commonState.componentIds).length == 1 && commonState.navActiveId == 'nav_setting') {
|
||||
setNavActiveId(commonState.lastNavActiveId)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}, []))
|
||||
|
||||
return windowSize.height > windowSize.width
|
||||
? <Vertical />
|
||||
|
@ -19,8 +19,12 @@ export default {
|
||||
},
|
||||
setNavActiveId(id: InitState['navActiveId']) {
|
||||
state.navActiveId = id
|
||||
if (id != 'nav_setting') state.lastNavActiveId = id
|
||||
global.state_event.navActiveIdUpdated(id)
|
||||
},
|
||||
setLastNavActiveId(id: InitState['navActiveId']) {
|
||||
state.lastNavActiveId = id
|
||||
},
|
||||
setSourceNames(names: InitState['sourceNames']) {
|
||||
state.sourceNames = names
|
||||
global.state_event.sourceNamesUpdated(names)
|
||||
|
@ -5,6 +5,7 @@ export interface InitState {
|
||||
fontSize: number
|
||||
componentIds: Partial<Record<COMPONENT_IDS, string>>
|
||||
navActiveId: NAV_ID_Type
|
||||
lastNavActiveId: NAV_ID_Type
|
||||
sourceNames: Record<LX.OnlineSource | 'all', string>
|
||||
}
|
||||
|
||||
@ -14,6 +15,7 @@ const state: InitState = {
|
||||
fontSize: global.lx.fontSize,
|
||||
componentIds: {},
|
||||
navActiveId: 'nav_search',
|
||||
lastNavActiveId: 'nav_search',
|
||||
sourceNames: initData as InitState['sourceNames'],
|
||||
}
|
||||
|
||||
|
12
src/utils/hooks/useBackHandler.ts
Normal file
12
src/utils/hooks/useBackHandler.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { useEffect } from 'react'
|
||||
import { BackHandler } from 'react-native'
|
||||
|
||||
export function useBackHandler(handler: () => boolean) {
|
||||
useEffect(() => {
|
||||
BackHandler.addEventListener('hardwareBackPress', handler)
|
||||
|
||||
return () => {
|
||||
BackHandler.removeEventListener('hardwareBackPress', handler)
|
||||
}
|
||||
}, [handler])
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user