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