Skip to content

Commit b78c9ae

Browse files
author
KX
committed
feat: 支持插件上传音乐;支持快捷搜索;桌面歌词自动隐藏(alpha)
1 parent 42fdbd6 commit b78c9ae

File tree

24 files changed

+343
-88
lines changed

24 files changed

+343
-88
lines changed

.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
arrowParens: 'avoid',
33
bracketSameLine: true,
4-
bracketSpacing: false,
4+
bracketSpacing: true,
55
singleQuote: true,
66
trailingComma: 'all',
77
tabWidth: 4,

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def jscFlavor = 'org.webkit:android-jsc:+'
8989

9090
// !! Add lines
9191
def keystoreProperties = new Properties()
92-
def keystorePropertiesFile = rootProject.file('keystore.properties')
92+
def keystorePropertiesFile = file('keystore.properties')
9393
if (keystorePropertiesFile.exists()) {
9494
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
9595
}
@@ -125,7 +125,7 @@ android {
125125
namespace "fun.upup.musicfree"
126126

127127
defaultConfig {
128-
applicationId "fun.upup.musicfree"
128+
applicationId "fun.upup.musicfree.kx"
129129
minSdkVersion rootProject.ext.minSdkVersion
130130
targetSdkVersion rootProject.ext.targetSdkVersion
131131
versionCode appVersionCode

android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<category android:name="android.intent.category.BROWSABLE" />
4141
<data android:scheme="musicfree" android:host="app"/>
4242
<data android:scheme="musicfree" android:host="install"/>
43-
</intent-filter>
43+
</intent-filter>
4444
<!-- 处理音频文件 -->
4545
<intent-filter>
4646
<action android:name="android.intent.action.VIEW" />
@@ -119,7 +119,7 @@
119119
<data android:mimeType="*/*" />
120120
<data android:pathPattern=".*\\.m4a" />
121121
<data android:pathPattern=".*\\.M4A" />
122-
</intent-filter>
122+
</intent-filter>
123123
<intent-filter>
124124
<action android:name="android.intent.action.VIEW" />
125125
<category android:name="android.intent.category.DEFAULT" />

android/app/src/main/java/fun/upup/musicfree/lyricUtil/LyricUtilModule.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class LyricUtilModule(private val reactContext: ReactApplicationContext): ReactC
8888
try {
8989
UiThreadUtil.runOnUiThread {
9090
lyricView?.hideLyricWindow()
91+
lyricView = null;
9192
}
9293
promise.resolve(true)
9394
} catch (e: Exception) {
@@ -179,4 +180,8 @@ class LyricUtilModule(private val reactContext: ReactApplicationContext): ReactC
179180
}
180181
}
181182

183+
@ReactMethod
184+
fun isShowStatusBar(promise: Promise) {
185+
promise.resolve(lyricView != null);
186+
}
182187
}

android/settings.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
2-
plugins { id("com.facebook.react.settings") }
1+
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
2+
plugins { id("com.facebook.react.settings") }
33
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex ->
44
def command = [
55
'node',
@@ -12,10 +12,10 @@ extensions.configure(com.facebook.react.ReactSettingsExtension){ ex ->
1212
'android'
1313
].toList()
1414
ex.autolinkLibrariesFromCommand(command)
15-
}
16-
rootProject.name = 'MusicFree'
17-
include ':app'
18-
includeBuild('../node_modules/@react-native/gradle-plugin')
19-
20-
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
21-
useExpoModules()
15+
}
16+
rootProject.name = 'MusicFree'
17+
include ':app'
18+
includeBuild('../node_modules/@react-native/gradle-plugin')
19+
20+
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
21+
useExpoModules()

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/panels/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import ImageViewer from "./imageViewer";
1919
import MusicComment from "./musicComment";
2020
import MusicItemLyricOptions from "./musicItemLyricOptions";
2121
import EditMusicSheetInfo from "./editMusicSheetInfo";
22+
import UploadMusicItem from "@/components/panels/types/uploadMusicItem";
2223

2324
export default {
2425
/** 加入歌单 */
@@ -61,4 +62,5 @@ export default {
6162
MusicComment,
6263
MusicItemLyricOptions,
6364
EditMusicSheetInfo,
65+
UploadMusicItem,
6466
};

src/components/panels/types/musicItemOptions.tsx

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import FastImage from "@/components/base/fastImage";
1111
import Toast from "@/utils/toast";
1212
import LocalMusicSheet from "@/core/localMusicSheet";
1313
import { localMusicSheetId, musicHistorySheetId } from "@/constants/commonConst";
14-
import { ROUTE_PATH } from "@/core/router";
14+
import { ROUTE_PATH, useNavigate } from "@/core/router";
1515

1616
import { useSafeAreaInsets } from "react-native-safe-area-context";
1717
import PanelBase from "../base/panelBase";
@@ -48,6 +48,7 @@ interface IOption {
4848
title: string;
4949
onPress?: () => void;
5050
show?: boolean;
51+
onLongPress?: () => void;
5152
}
5253

5354
export default function MusicItemOptions(props: IMusicItemOptionsProps) {
@@ -58,6 +59,16 @@ export default function MusicItemOptions(props: IMusicItemOptionsProps) {
5859

5960
const downloaded = LocalMusicSheet.isLocalMusic(musicItem);
6061
const associatedLrc = getMediaExtraProperty(musicItem, "associatedLrc");
62+
const navigate = useNavigate();
63+
64+
const copyText = (text: string | any) => {
65+
try {
66+
Clipboard.setString(text.toString());
67+
Toast.success(t("toast.copiedToClipboard"));
68+
} catch {
69+
Toast.warn(t("toast.copiedToClipboardFailed"));
70+
}
71+
};
6172

6273
const options: IOption[] = [
6374
{
@@ -82,26 +93,20 @@ export default function MusicItemOptions(props: IMusicItemOptionsProps) {
8293
icon: "user",
8394
title: t("panel.musicItemOptions.author", { artist: musicItem.artist }),
8495
onPress: () => {
85-
try {
86-
Clipboard.setString(musicItem.artist.toString());
87-
Toast.success(t("toast.copiedToClipboard"));
88-
} catch {
89-
Toast.warn(t("toast.copiedToClipboardFailed"));
90-
}
96+
hidePanel();
97+
navigate(ROUTE_PATH.SEARCH_PAGE, { type: "artist", query: musicItem.artist });
9198
},
99+
onLongPress:() => copyText(musicItem.artist),
92100
},
93101
{
94102
icon: "album-outline",
95103
show: !!musicItem.album,
96104
title: t("panel.musicItemOptions.album", { album: musicItem.album }),
97105
onPress: () => {
98-
try {
99-
Clipboard.setString(musicItem.album.toString());
100-
Toast.success(t("toast.copiedToClipboard"));
101-
} catch {
102-
Toast.warn(t("toast.copiedToClipboardFailed"));
103-
}
106+
hidePanel();
107+
navigate(ROUTE_PATH.SEARCH_PAGE, { type: "album", query: musicItem.album });
104108
},
109+
onLongPress:() => copyText(musicItem.album),
105110
},
106111
{
107112
icon: "motion-play",
@@ -118,6 +123,20 @@ export default function MusicItemOptions(props: IMusicItemOptionsProps) {
118123
showPanel("AddToMusicSheet", { musicItem });
119124
},
120125
},
126+
{
127+
icon: "arrow-up-tray",
128+
title: t("common.upload"),
129+
onPress: async () => {
130+
console.log(musicItem);
131+
showPanel("MusicQuality", {
132+
musicItem,
133+
type: "upload",
134+
async onQualityPress(quality) {
135+
showPanel("UploadMusicItem",{ musicItem, quality });
136+
},
137+
});
138+
},
139+
},
121140
{
122141
icon: "arrow-down-tray",
123142
title: t("common.download"),
@@ -244,7 +263,14 @@ export default function MusicItemOptions(props: IMusicItemOptionsProps) {
244263
placeholderSource={ImgAsset.albumDefault}
245264
/>
246265
<View style={style.content}>
247-
<ThemeText numberOfLines={2} style={style.title}>
266+
<ThemeText numberOfLines={2} style={style.title} onPress={
267+
() => {
268+
hidePanel();
269+
navigate(ROUTE_PATH.SEARCH_PAGE, { type: "music", query: musicItem?.title });
270+
}
271+
}
272+
onLongPress={ ()=> copyText(musicItem?.title) }
273+
>
248274
{musicItem?.title}
249275
</ThemeText>
250276
<ThemeText
@@ -278,7 +304,8 @@ export default function MusicItemOptions(props: IMusicItemOptionsProps) {
278304
<ListItem
279305
withHorizontalPadding
280306
heightType="small"
281-
onPress={item.onPress}>
307+
onPress={item.onPress}
308+
onLongPress={item.onLongPress}>
282309
<ListItem.ListItemIcon
283310
width={rpx(48)}
284311
icon={item.icon}

src/components/panels/types/musicQuality.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import PanelHeader from "../base/panelHeader";
1414
import { useI18N } from "@/core/i18n";
1515

1616
interface IMusicQualityProps {
17-
type?: "play" | "download";
17+
type?: "play" | "download"| "upload";
1818
/** 歌曲信息 */
1919
musicItem: IMusic.IMusicItem;
2020
/** 点击回调 */
@@ -29,6 +29,15 @@ export default function MusicQuality(props: IMusicQualityProps) {
2929
const i18n = useI18N();
3030

3131
const { musicItem, onQualityPress, type = "play" } = props ?? {};
32+
const titles = {
33+
play: "common.play",
34+
download: "common.download",
35+
upload: "common.upload",
36+
};
37+
const showQualityKeys = qualityKeys.filter(quality => musicItem.qualities?.[quality]?.url);
38+
if (!showQualityKeys.length) {
39+
showQualityKeys.push("standard");
40+
}
3241

3342
return (
3443
<PanelBase
@@ -37,10 +46,7 @@ export default function MusicQuality(props: IMusicQualityProps) {
3746
<>
3847
<PanelHeader
3948
title={i18n.t("panel.musicQuality.title", {
40-
type:
41-
type === "play"
42-
? i18n.t("common.play")
43-
: i18n.t("common.download"),
49+
type: i18n.t(titles[type]),
4450
})}
4551
hideButtons
4652
/>
@@ -53,7 +59,7 @@ export default function MusicQuality(props: IMusicQualityProps) {
5359
marginBottom: safeAreaInsets.bottom,
5460
},
5561
]}>
56-
{qualityKeys.map(key => {
62+
{showQualityKeys.map(key => {
5763
return (
5864
<Fragment key={`frag-${key}`}>
5965
<Pressable

0 commit comments

Comments
 (0)