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
09ad186011
commit
0b6b15e9a8
@ -1,3 +1,7 @@
|
||||
### 新增
|
||||
|
||||
- 新增设置-基本设置-分享设置,它用于控制歌曲菜单的分享行为,默认使用系统分享
|
||||
|
||||
### 变更
|
||||
|
||||
- 歌曲菜单的“复制歌曲名”改为“分享歌曲”,点击后可以选择第三方应用分享歌曲详情页链接
|
||||
|
@ -3,7 +3,7 @@
|
||||
// const { isMac } = require('./utils')
|
||||
|
||||
const defaultSetting = {
|
||||
version: '1.16',
|
||||
version: '1.17',
|
||||
player: {
|
||||
togglePlayMethod: 'listLoop',
|
||||
highQuality: false,
|
||||
@ -100,6 +100,7 @@ const defaultSetting = {
|
||||
sourceId: 'kw',
|
||||
apiSource: 'temp',
|
||||
sourceNameType: 'alias',
|
||||
shareType: 'system',
|
||||
// randomAnimate: true,
|
||||
ignoreVersion: null,
|
||||
isAgreePact: false,
|
||||
|
@ -118,6 +118,9 @@
|
||||
"setting_basic": "General",
|
||||
"setting_basic_animation": "Random pop-up animation",
|
||||
"setting_basic_lang": "Language",
|
||||
"setting_basic_share_type": "Share",
|
||||
"setting_basic_share_type_clipboard": "copy to clipboard",
|
||||
"setting_basic_share_type_system": "Share using the system",
|
||||
"setting_basic_show_animation": "Show switching animation",
|
||||
"setting_basic_source": "Music source",
|
||||
"setting_basic_source_direct": "Direct API",
|
||||
|
@ -119,6 +119,9 @@
|
||||
"setting_basic": "基本设置",
|
||||
"setting_basic_animation": "弹出层随机动画",
|
||||
"setting_basic_lang": "语言",
|
||||
"setting_basic_share_type": "分享方式",
|
||||
"setting_basic_share_type_clipboard": "复制到剪贴板",
|
||||
"setting_basic_share_type_system": "使用系统分享",
|
||||
"setting_basic_show_animation": "显示切换动画",
|
||||
"setting_basic_source": "音乐来源",
|
||||
"setting_basic_source_direct": "试听接口(这是最后的选择...)",
|
||||
|
@ -10,7 +10,7 @@ import Button from '@/components/common/Button'
|
||||
import ExitMultipleModeBar from './components/ExitMultipleModeBar'
|
||||
import MyList from './components/MyList'
|
||||
import ListItem from './components/ListItem'
|
||||
import { getListScrollPosition, saveListScrollPosition } from '@/utils/tools'
|
||||
import { getListScrollPosition, saveListScrollPosition, clipboardWriteText, toast } from '@/utils/tools'
|
||||
import { shareText } from '@/utils/utils'
|
||||
import { useTranslation } from '@/plugins/i18n'
|
||||
import { LIST_ITEM_HEIGHT } from '@/config/constant'
|
||||
@ -37,6 +37,7 @@ const List = () => {
|
||||
const activeListId = useGetter('common', 'prevSelectListId')
|
||||
const activeListIdRef = useRef(activeListId)
|
||||
const downloadFileName = useGetter('common', 'downloadFileName')
|
||||
const shareType = useGetter('common', 'shareType')
|
||||
const [buttonPosition, setButtonPosition] = useState({ w: 0, h: 0, x: 0, y: 0 })
|
||||
const selectedDataRef = useRef({ data: null, index: -1 })
|
||||
const flatListRef = useRef()
|
||||
@ -216,11 +217,17 @@ const List = () => {
|
||||
: setVisibleMusicAddModal(true)
|
||||
break
|
||||
case 'copyName':
|
||||
shareText(t('share_card_title_music', { name: selectedDataRef.current.data.name }), t('share_title_music'), `${downloadFileName.replace('歌名', selectedDataRef.current.data.name)
|
||||
.replace('歌手', selectedDataRef.current.data.singer).replace(/\s/g, '')} ${music[selectedDataRef.current.data.source].getMusicDetailPageUrl(selectedDataRef.current.data)}`)
|
||||
// clipboardWriteText(`${downloadFileName.replace('歌名', selectedDataRef.current.data.name)
|
||||
// .replace('歌手', selectedDataRef.current.data.singer)} ${music[selectedDataRef.current.data.source].getMusicDetailPageUrl(selectedDataRef.current.data)}`)
|
||||
// toast(t('copy_name_tip'))
|
||||
switch (shareType) {
|
||||
case 'system':
|
||||
shareText(t('share_card_title_music', { name: selectedDataRef.current.data.name }), t('share_title_music'), `${downloadFileName.replace('歌名', selectedDataRef.current.data.name)
|
||||
.replace('歌手', selectedDataRef.current.data.singer).replace(/\s/g, '')}\n${music[selectedDataRef.current.data.source].getMusicDetailPageUrl(selectedDataRef.current.data)}`)
|
||||
break
|
||||
case 'clipboard':
|
||||
clipboardWriteText(`${downloadFileName.replace('歌名', selectedDataRef.current.data.name)
|
||||
.replace('歌手', selectedDataRef.current.data.singer)} ${music[selectedDataRef.current.data.source].getMusicDetailPageUrl(selectedDataRef.current.data)}`)
|
||||
toast(t('copy_name_tip'))
|
||||
break
|
||||
}
|
||||
break
|
||||
case 'changePosition':
|
||||
setVIsibleMusicPosition(true)
|
||||
@ -236,7 +243,7 @@ const List = () => {
|
||||
default:
|
||||
break
|
||||
}
|
||||
}, [downloadFileName, handleCancelMultiSelect, handlePlay, removeListItem, removeListMultiItem, setTempPlayList])
|
||||
}, [handlePlay, shareType, setTempPlayList, handleCancelMultiSelect, t, downloadFileName, removeListMultiItem, removeListItem])
|
||||
|
||||
const handleScroll = useCallback(({ nativeEvent }) => {
|
||||
saveListScrollPosition(currentListRef.current.id, nativeEvent.contentOffset.y)
|
||||
|
55
src/screens/Home/Setting/Basic/ShareType.js
Normal file
55
src/screens/Home/Setting/Basic/ShareType.js
Normal file
@ -0,0 +1,55 @@
|
||||
import React, { memo, useMemo } from 'react'
|
||||
|
||||
import { StyleSheet, View } from 'react-native'
|
||||
import { useGetter, useDispatch } from '@/store'
|
||||
|
||||
import SubTitle from '../components/SubTitle'
|
||||
import { useTranslation } from '@/plugins/i18n'
|
||||
import CheckBox from '@/components/common/CheckBox'
|
||||
|
||||
|
||||
const useActive = id => {
|
||||
const shareType = useGetter('common', 'shareType')
|
||||
const isActive = useMemo(() => shareType == id, [shareType, id])
|
||||
return isActive
|
||||
}
|
||||
|
||||
const Item = ({ id, name, change }) => {
|
||||
const isActive = useActive(id)
|
||||
// const [toggleCheckBox, setToggleCheckBox] = useState(false)
|
||||
return <CheckBox marginBottom={3} check={isActive} label={name} onChange={() => change(id)} need />
|
||||
}
|
||||
|
||||
export default memo(() => {
|
||||
const { t } = useTranslation()
|
||||
const setShareType = useDispatch('common', 'setShareType')
|
||||
const list = useMemo(() => [
|
||||
{
|
||||
id: 'system',
|
||||
name: t('setting_basic_share_type_system'),
|
||||
},
|
||||
{
|
||||
id: 'clipboard',
|
||||
name: t('setting_basic_share_type_clipboard'),
|
||||
},
|
||||
], [t])
|
||||
|
||||
return (
|
||||
<SubTitle title={t('setting_basic_share_type')}>
|
||||
<View style={styles.list}>
|
||||
{
|
||||
list.map(({ id, name }) => <Item name={name} id={id} key={id} change={setShareType} />)
|
||||
}
|
||||
</View>
|
||||
</SubTitle>
|
||||
)
|
||||
})
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
list: {
|
||||
flexGrow: 0,
|
||||
flexShrink: 1,
|
||||
flexDirection: 'row',
|
||||
flexWrap: 'wrap',
|
||||
},
|
||||
})
|
@ -5,6 +5,7 @@ import Theme from './Theme'
|
||||
import Source from './Source'
|
||||
import SourceName from './SourceName'
|
||||
import Language from './Language'
|
||||
import ShareType from './ShareType'
|
||||
import { useTranslation } from '@/plugins/i18n'
|
||||
|
||||
export default memo(() => {
|
||||
@ -17,6 +18,7 @@ export default memo(() => {
|
||||
<Source />
|
||||
<Language />
|
||||
<SourceName />
|
||||
<ShareType />
|
||||
</Section>
|
||||
)
|
||||
})
|
||||
|
@ -26,7 +26,7 @@ export default memo(({ value, label, onChange, ...props }) => {
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
const handleKeyboardDidHide = () => {
|
||||
if (!inputRef.current.isFocused()) return
|
||||
if (!inputRef.current?.isFocused()) return
|
||||
onChange && onChange(textRef.current, value => {
|
||||
if (!isMountRef.current) return
|
||||
const newValue = String(value)
|
||||
|
@ -31,6 +31,7 @@ export const TYPES = {
|
||||
setTop: null,
|
||||
setIgnoreVersion: null,
|
||||
setVersionInfo: null,
|
||||
setShareType: null,
|
||||
setTimeoutExit: null,
|
||||
setIsHandleAudioFocus: null,
|
||||
setAddMusicLocationType: null,
|
||||
@ -398,3 +399,12 @@ export const setPlayerLandscapeStyle = style => async(dispatch, getState) => {
|
||||
const { common } = getState()
|
||||
await setData(settingKey, common.setting)
|
||||
}
|
||||
|
||||
export const setShareType = type => async(dispatch, getState) => {
|
||||
dispatch({
|
||||
type: TYPES.setShareType,
|
||||
payload: type,
|
||||
})
|
||||
const { common } = getState()
|
||||
await setData(settingKey, common.setting)
|
||||
}
|
||||
|
@ -71,3 +71,5 @@ export const supportQualitys = state => apiSourceInfo.find(s => s.id == state.co
|
||||
|
||||
export const playerPortraitStyle = state => state.common.setting.player.portrait.style
|
||||
export const playerLandscapeStyle = state => state.common.setting.player.landscape.style
|
||||
|
||||
export const shareType = state => state.common.setting.shareType
|
||||
|
@ -455,6 +455,15 @@ const mutations = {
|
||||
},
|
||||
}
|
||||
},
|
||||
[TYPES.setShareType](state, shareType) {
|
||||
return {
|
||||
...state,
|
||||
setting: {
|
||||
...state.setting,
|
||||
shareType,
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default (state = initialState, action) =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user