Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3f3481f4f | ||
|
|
1b19513efb | ||
|
|
935de13343 | ||
|
|
01a3b0101e | ||
|
|
d6df5fbe5f | ||
|
|
929b7f72f8 | ||
|
|
e028ca40b1 | ||
|
|
d206465ee1 | ||
|
|
9117bf58b8 | ||
|
|
bd826a9236 | ||
|
|
a5dbae7fff | ||
|
|
00405d2e3b | ||
|
|
72dcb92aca | ||
|
|
8d511933df | ||
|
|
06a2f6d7c0 | ||
|
|
0d785bf1f8 | ||
|
|
4c3acb047c | ||
|
|
d3dbc9f8dc | ||
|
|
4b97f89c0b | ||
|
|
6be024f86f | ||
|
|
6512808506 | ||
|
|
2d65cd3006 | ||
|
|
391b01e9d0 | ||
|
|
d4ce3a5d8b | ||
|
|
bf47c065c9 | ||
|
|
c6b3ca9311 | ||
|
|
a3d50eb935 | ||
|
|
188811fde6 | ||
|
|
37353dac15 | ||
|
|
350d16db75 | ||
|
|
0f27daf664 | ||
|
|
afdc4af2f2 | ||
|
|
1b50a73bfc | ||
|
|
978c309cd7 | ||
|
|
c0f65042e6 | ||
|
|
a7d01e0306 | ||
|
|
ed2cf4c18c | ||
|
|
db3e153409 | ||
|
|
810ca5bf9d | ||
|
|
84b24775d6 | ||
|
|
9039b27c7f | ||
|
|
30b43878ab | ||
|
|
e7afd316f8 | ||
|
|
f3dd4a9b5c | ||
|
|
94b37ef00f | ||
|
|
bea50ab32f | ||
|
|
63296d2a92 | ||
|
|
b291044acc | ||
|
|
ee4e573f4f | ||
|
|
e8f192ccf8 | ||
|
|
c8ec481fc9 | ||
|
|
1fc8c4924e | ||
|
|
55fc2796a9 | ||
|
|
4d3d067f77 | ||
|
|
bb2c729a7e | ||
|
|
54eb5a60a8 | ||
|
|
6667330ce0 | ||
|
|
440188f261 | ||
|
|
9d2d3b97a1 | ||
|
|
23e80dd637 | ||
|
|
ab4c246675 | ||
|
|
2a32dec183 | ||
|
|
5dafc68775 | ||
|
|
80c962a95c | ||
|
|
2fef7470e0 | ||
|
|
0cb0ab0613 | ||
|
|
70d8e0f982 | ||
|
|
48b4e67d34 | ||
|
|
a3a79f7068 | ||
|
|
04f034817c | ||
|
|
516593499c | ||
|
|
df36890b48 | ||
|
|
222bacdeeb | ||
|
|
b83b5799e3 | ||
|
|
d4ae8f427f | ||
|
|
98d7debfb5 | ||
|
|
b5e9deb4bd | ||
|
|
47df002d8e | ||
|
|
4f1feeadbd | ||
|
|
8b50b5bd06 | ||
|
|
8481611372 | ||
|
|
b1e95b370c | ||
|
|
0ef0d46919 | ||
|
|
b4d38f8e10 | ||
|
|
c034627fdb | ||
|
|
ef29fc5f15 | ||
|
|
671e0ce143 | ||
|
|
0f1f64a09f | ||
|
|
d29ae20491 | ||
|
|
12e08a89a4 | ||
|
|
e0ba54f23b | ||
|
|
5043d6c25b | ||
|
|
ab6800aba2 | ||
|
|
f8500bbaca | ||
|
|
9b1afbdb36 | ||
|
|
f4cf7bc2dd | ||
|
|
60489d6dca | ||
|
|
44d3bcba18 | ||
|
|
f206977ad8 | ||
|
|
f3d64f6fb5 | ||
|
|
6318ca24ec | ||
|
|
b513ac0a9c | ||
|
|
25d90e1383 | ||
|
|
7804809d83 | ||
|
|
5f278a3510 | ||
|
|
56d7abc6b1 | ||
|
|
345cc2ad28 | ||
|
|
41bd4683c3 | ||
|
|
d868ce9336 | ||
|
|
928ac1de19 | ||
|
|
6b3d870c93 | ||
|
|
281f13a810 | ||
|
|
8637f5da21 | ||
|
|
0319f8a6a8 | ||
|
|
9aa797504b | ||
|
|
933333b0fe | ||
|
|
bbc759473c | ||
|
|
9ddd7fc833 | ||
|
|
5794dd4e4d | ||
|
|
76c4b528d3 | ||
|
|
68ccfa21c0 | ||
|
|
78d0166eb7 | ||
|
|
4140c4eb50 | ||
|
|
e2cc409e5a | ||
|
|
9b83283689 | ||
|
|
a1c0af3f00 | ||
|
|
b5bfc1d7b2 | ||
|
|
1d2ba93e48 | ||
|
|
c08df9af40 | ||
|
|
be166f5856 | ||
|
|
e531c78997 | ||
|
|
8ed6cd9fd6 | ||
|
|
c1d55b91a2 | ||
|
|
3dcfa02372 | ||
|
|
b6826f7483 | ||
|
|
cd3d84cf9a | ||
|
|
010ce326ea | ||
|
|
2577797772 | ||
|
|
05e2952815 | ||
|
|
6ae9e8e043 | ||
|
|
182b7e3ac2 | ||
|
|
8bb365db2a | ||
|
|
0cb57d084d | ||
|
|
5c174b007c | ||
|
|
35364c949a | ||
|
|
814b2c0b7b | ||
|
|
3d0e0804ca |
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
<!-- Author: fruit.com.cn -->
|
||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission
|
||||||
|
android:name="android.permission.INTERNET"/>
|
||||||
<application
|
<application
|
||||||
android:label="FruitShorts"
|
android:label="FruitShorts"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
@@ -23,9 +23,8 @@
|
|||||||
while the Flutter UI initializes. After that, this theme continues
|
while the Flutter UI initializes. After that, this theme continues
|
||||||
to determine the Window background behind the Flutter UI. -->
|
to determine the Window background behind the Flutter UI. -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="io.flutter.embedding.android.NormalTheme"
|
android:name="io.flutter.embedding.android.NormalTheme"
|
||||||
android:resource="@style/NormalTheme"
|
android:resource="@style/NormalTheme"/>
|
||||||
/>
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
@@ -35,7 +34,7 @@
|
|||||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
android:value="2" />
|
android:value="2"/>
|
||||||
</application>
|
</application>
|
||||||
<!-- Required to query activities that can process text, see:
|
<!-- Required to query activities that can process text, see:
|
||||||
https://developer.android.com/training/package-visibility and
|
https://developer.android.com/training/package-visibility and
|
||||||
@@ -44,8 +43,10 @@
|
|||||||
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
|
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
|
||||||
<queries>
|
<queries>
|
||||||
<intent>
|
<intent>
|
||||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
<action
|
||||||
<data android:mimeType="text/plain"/>
|
android:name="android.intent.action.PROCESS_TEXT"/>
|
||||||
|
<data
|
||||||
|
android:mimeType="text/plain"/>
|
||||||
</intent>
|
</intent>
|
||||||
</queries>
|
</queries>
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -4,6 +4,7 @@ package com.stormg.lumadrama
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.app.PictureInPictureParams
|
import android.app.PictureInPictureParams
|
||||||
|
import android.content.Context
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.media.MediaMetadataRetriever
|
import android.media.MediaMetadataRetriever
|
||||||
@@ -12,6 +13,8 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.provider.Settings
|
||||||
|
import android.telephony.TelephonyManager
|
||||||
import android.util.Rational
|
import android.util.Rational
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
@@ -21,6 +24,7 @@ import io.flutter.embedding.android.FlutterActivity
|
|||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
import io.flutter.plugin.common.MethodChannel
|
import io.flutter.plugin.common.MethodChannel
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.util.Locale
|
||||||
import java.util.concurrent.ExecutorService
|
import java.util.concurrent.ExecutorService
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
@@ -36,6 +40,9 @@ class MainActivity : FlutterActivity() {
|
|||||||
private var imeInset = 0
|
private var imeInset = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
splashScreen.setOnExitAnimationListener { screen -> screen.remove() }
|
||||||
|
}
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
}
|
}
|
||||||
@@ -62,6 +69,23 @@ class MainActivity : FlutterActivity() {
|
|||||||
result.success(false)
|
result.success(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 设备标识:SSAID 免权限,卸载重装不变,避免客户端自己生成的 id 每次重装都变
|
||||||
|
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.stormg.lumadrama/device")
|
||||||
|
.setMethodCallHandler { call, result ->
|
||||||
|
when (call.method) {
|
||||||
|
"ssaid" -> {
|
||||||
|
val value = try {
|
||||||
|
Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||||
|
} catch (_: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
result.success(value)
|
||||||
|
}
|
||||||
|
// 设备区域:注册时作为服务端 IP 解析失败后的兜底
|
||||||
|
"region" -> result.success(currentRegion())
|
||||||
|
else -> result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.stormg.lumadrama/share")
|
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.stormg.lumadrama/share")
|
||||||
.setMethodCallHandler { call, result ->
|
.setMethodCallHandler { call, result ->
|
||||||
if (call.method != "shareText") {
|
if (call.method != "shareText") {
|
||||||
@@ -153,6 +177,28 @@ class MainActivity : FlutterActivity() {
|
|||||||
?.bottom
|
?.bottom
|
||||||
?: 0
|
?: 0
|
||||||
|
|
||||||
|
/** 网络运营商国家优先,其次 SIM 卡,最后系统语言;都拿不到返回空串。 */
|
||||||
|
private fun currentRegion(): String {
|
||||||
|
return try {
|
||||||
|
val telephony = getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager
|
||||||
|
val localeCountry = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
resources.configuration.locales.get(0).country
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
resources.configuration.locale.country
|
||||||
|
}
|
||||||
|
val candidates = listOfNotNull(
|
||||||
|
telephony?.networkCountryIso,
|
||||||
|
telephony?.simCountryIso,
|
||||||
|
localeCountry
|
||||||
|
)
|
||||||
|
candidates.firstOrNull { it.isNotBlank() }?.uppercase(Locale.ROOT) ?: ""
|
||||||
|
} catch (_: Exception) {
|
||||||
|
// 个别 ROM 读运营商信息会抛 SecurityException,别让注册流程卡住
|
||||||
|
""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun emitImeInset(value: Int) {
|
private fun emitImeInset(value: Int) {
|
||||||
if (value == imeInset) return
|
if (value == imeInset) return
|
||||||
imeInset = value
|
imeInset = value
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
@@ -1,4 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Author: fruit.com.cn -->
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:drawable="@color/splash_background" />
|
<item android:drawable="@color/splash_background" />
|
||||||
|
<item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@drawable/splash_screen" />
|
||||||
|
</item>
|
||||||
</layer-list>
|
</layer-list>
|
||||||
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 43 KiB |
@@ -1,4 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Author: fruit.com.cn -->
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:drawable="@color/splash_background" />
|
<item android:drawable="@color/splash_background" />
|
||||||
|
<item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@drawable/splash_screen" />
|
||||||
|
</item>
|
||||||
</layer-list>
|
</layer-list>
|
||||||
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 69 B After Width: | Height: | Size: 69 B |
@@ -1,9 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Author: fruit.com.cn -->
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@color/splash_background" />
|
||||||
<item>
|
<item>
|
||||||
<bitmap android:gravity="fill" android:src="@drawable/background"/>
|
<bitmap
|
||||||
</item>
|
android:gravity="center"
|
||||||
<item>
|
android:src="@drawable/splash_screen" />
|
||||||
<bitmap android:gravity="center" android:src="@drawable/splash"/>
|
|
||||||
</item>
|
</item>
|
||||||
</layer-list>
|
</layer-list>
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Author: fruit.com.cn -->
|
<!-- Author: fruit.com.cn -->
|
||||||
|
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:drawable="@color/splash_background" />
|
<item android:drawable="@color/splash_background" />
|
||||||
|
<item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@drawable/splash_screen" />
|
||||||
|
</item>
|
||||||
</layer-list>
|
</layer-list>
|
||||||
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 69 B After Width: | Height: | Size: 69 B |
@@ -1,9 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Author: fruit.com.cn -->
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@color/splash_background" />
|
||||||
<item>
|
<item>
|
||||||
<bitmap android:gravity="fill" android:src="@drawable/background"/>
|
<bitmap
|
||||||
</item>
|
android:gravity="center"
|
||||||
<item>
|
android:src="@drawable/splash_screen" />
|
||||||
<bitmap android:gravity="center" android:src="@drawable/splash"/>
|
|
||||||
</item>
|
</item>
|
||||||
</layer-list>
|
</layer-list>
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@mipmap/ic_launcher_background"/>
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
<foreground>
|
||||||
|
<inset
|
||||||
|
android:drawable="@drawable/ic_launcher_foreground"
|
||||||
|
android:inset="16%" />
|
||||||
|
</foreground>
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 6.3 KiB |
@@ -1,11 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Author: fruit.com.cn -->
|
<!-- Author: fruit.com.cn -->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||||
<item name="android:windowSplashScreenBackground">@color/splash_background</item>
|
<item name="android:forceDarkAllowed">false</item>
|
||||||
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
|
<item name="android:windowFullscreen">false</item>
|
||||||
|
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
||||||
|
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||||
|
<item name="android:windowSplashScreenBackground">#000000</item>
|
||||||
|
<item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_brand</item>
|
||||||
|
<item name="android:windowSplashScreenAnimationDuration">0</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
<item name="android:windowBackground">@color/splash_background</item>
|
<item name="android:windowBackground">@color/splash_background</item>
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Author: fruit.com.cn -->
|
<!-- Author: fruit.com.cn -->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||||
<item name="android:windowBackground">@drawable/launch_background</item>
|
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||||
<item name="android:windowSplashScreenBackground">@color/splash_background</item>
|
<item name="android:forceDarkAllowed">false</item>
|
||||||
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
|
<item name="android:windowFullscreen">false</item>
|
||||||
|
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
||||||
|
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||||
|
<item name="android:windowSplashScreenBackground">#000000</item>
|
||||||
|
<item name="android:windowSplashScreenAnimatedIcon">@drawable/splash_brand</item>
|
||||||
|
<item name="android:windowSplashScreenAnimationDuration">0</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||||
<item name="android:windowBackground">@color/splash_background</item>
|
<item name="android:windowBackground">@color/splash_background</item>
|
||||||
|
|||||||
@@ -2,5 +2,6 @@
|
|||||||
<!-- Author: fruit.com.cn -->
|
<!-- Author: fruit.com.cn -->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<color name="splash_background">#1F1B16</color>
|
<color name="splash_background">#000000</color>
|
||||||
</resources>
|
<color name="ic_launcher_background">#FF6B2C</color>
|
||||||
|
</resources>
|
||||||
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 42 KiB |
@@ -1288,3 +1288,34 @@ $ flutter test
|
|||||||
- 下拉刷新统一为 40×40、60% 黑底圆角指示器内嵌 20 白色加载圈,不再显示任何状态文字。
|
- 下拉刷新统一为 40×40、60% 黑底圆角指示器内嵌 20 白色加载圈,不再显示任何状态文字。
|
||||||
- 网络分页与本地分页 footer 统一仅显示白色加载圈,无更多状态完全隐藏;通知页补触底自动加载。
|
- 网络分页与本地分页 footer 统一仅显示白色加载圈,无更多状态完全隐藏;通知页补触底自动加载。
|
||||||
- 移除不再使用的刷新提示与无更多文案;`flutter analyze`:No issues found。
|
- 移除不再使用的刷新提示与无更多文案;`flutter analyze`:No issues found。
|
||||||
|
|
||||||
|
## 2026-10-22 首页热播榜重做
|
||||||
|
|
||||||
|
- 首页榜单 tab 改为独立领奖台 + 单列排行布局,不再复用三列网格。
|
||||||
|
- 前三名按 2/1/3 排列,冠军放大并上移;第 4 名起使用大号描边名次与横向信息行。
|
||||||
|
- 榜单沿用现有播放热度排序、分页和播放逻辑;`flutter analyze`:No issues found。
|
||||||
|
|
||||||
|
## 2026-10-22 播放器双击点赞与飘心
|
||||||
|
|
||||||
|
- 沉浸式播放器改用 onTapUp + 280ms Timer 判定双击,双击取消单击,长按左右倍速与中间更多保持不变。
|
||||||
|
- 双击和右侧心形共用点赞方法,成功后控制器通知并点亮红色实心心形,失败由 controller 回滚并使用 Toast。
|
||||||
|
- 飘心层使用独立 IgnorePointer Stack,动画完成后自动移除;`flutter analyze`:No issues found。
|
||||||
|
- `flutter test test/player/double_tap_like_test.dart`:2 项测试全部通过。
|
||||||
|
- 移除视频表面点击识别器,双击后增加 300ms 暂停防护;飘心收敛为 3~4 颗、20~26、±18、90~120dp、600~700ms。
|
||||||
|
- 双击窗口延长至 320ms,单击 Timer 使用点击序号校验,双击后保留 350ms 播放切换保护。
|
||||||
|
- `double_tap_like_test.dart` 覆盖 120/250/300ms 双击与 500ms 单击恢复:2 项测试全部通过。
|
||||||
|
|
||||||
|
## 2026-10-22 统一二级搜索页
|
||||||
|
|
||||||
|
- 首页与推荐/剧单/全部短剧搜索入口统一 push SearchPage,不再切换推荐 tab 聚焦。
|
||||||
|
- 搜索页提供返回、自动聚焦输入框与取消,复用 `/app/search` 逻辑和首页三列卡片。
|
||||||
|
- 清理旧的 searchRequest/focusSearch/syncSearch 参数;`flutter analyze`:No issues found。
|
||||||
|
- 搜索页结果改为独立两列卡片,左右 14、列距 12、行距 16,并移除 HomeFeedCard 复用。
|
||||||
|
- 搜索结果支持下拉刷新:保留旧结果按当前关键词重取第一页,空关键词直接回弹且不改变焦点。
|
||||||
|
|
||||||
|
## 2026-10-22 App 图标与开屏更新
|
||||||
|
|
||||||
|
- Launcher/Android 12 启动背景统一纯黑,自适应图标背景改为品牌橙。
|
||||||
|
- Android/iOS 图标与启动资源已重新生成;应用内开屏固定 splash_logo,宽 200 等比居中。
|
||||||
|
- `flutter analyze`:No issues found。
|
||||||
|
- 移除 Flutter 内 `_startupSplash` 与 `startup-splash`,只保留系统原生开屏;最新斜体字标素材已重新生成。
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
|
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
|
||||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||||
|
8C4E1A022F9A4B1000C636F3 /* WirelessDataPrompt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C4E1A012F9A4B1000C636F3 /* WirelessDataPrompt.swift */; };
|
||||||
7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */; };
|
7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */; };
|
||||||
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
|
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
|
||||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||||
@@ -49,6 +50,7 @@
|
|||||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
|
8C4E1A012F9A4B1000C636F3 /* WirelessDataPrompt.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WirelessDataPrompt.swift; sourceTree = "<group>"; };
|
||||||
7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||||
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; };
|
78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = "<group>"; };
|
||||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||||
@@ -122,6 +124,7 @@
|
|||||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
||||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||||
|
8C4E1A012F9A4B1000C636F3 /* WirelessDataPrompt.swift */,
|
||||||
7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */,
|
7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */,
|
||||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||||
);
|
);
|
||||||
@@ -282,6 +285,7 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||||
|
8C4E1A022F9A4B1000C636F3 /* WirelessDataPrompt.swift in Sources */,
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||||
7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */,
|
7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import Flutter
|
|||||||
import UIKit
|
import UIKit
|
||||||
import AVFoundation
|
import AVFoundation
|
||||||
|
|
||||||
|
private let thumbnailHTTPHeaderFieldsKey = "AVURLAssetHTTPHeaderFieldsKey"
|
||||||
|
|
||||||
private final class ThumbnailResponseGate {
|
private final class ThumbnailResponseGate {
|
||||||
private let lock = NSLock()
|
private let lock = NSLock()
|
||||||
private var completed = false
|
private var completed = false
|
||||||
@@ -29,12 +31,13 @@ final class RunnerFlutterViewController: FlutterViewController {
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
view.backgroundColor = UIColor(red: 16.0 / 255.0, green: 12.0 / 255.0, blue: 10.0 / 255.0, alpha: 1)
|
view.backgroundColor = .black
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@main
|
@main
|
||||||
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
|
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
|
||||||
|
private let wirelessDataPrompt = WirelessDataPrompt()
|
||||||
private let thumbnailQueue = DispatchQueue(
|
private let thumbnailQueue = DispatchQueue(
|
||||||
label: "com.stormg.lumadrama.thumbnail",
|
label: "com.stormg.lumadrama.thumbnail",
|
||||||
qos: .userInitiated
|
qos: .userInitiated
|
||||||
@@ -48,8 +51,19 @@ final class RunnerFlutterViewController: FlutterViewController {
|
|||||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func applicationDidBecomeActive(_ application: UIApplication) {
|
||||||
|
super.applicationDidBecomeActive(application)
|
||||||
|
requestWirelessDataPrompt()
|
||||||
|
}
|
||||||
|
|
||||||
|
func requestWirelessDataPrompt() {
|
||||||
|
wirelessDataPrompt.requestSystemPrompt()
|
||||||
|
}
|
||||||
|
|
||||||
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
|
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
|
||||||
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
|
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
|
||||||
|
registerWirelessDataChannel(engineBridge)
|
||||||
|
registerDeviceIdChannel(engineBridge)
|
||||||
let channel = FlutterMethodChannel(
|
let channel = FlutterMethodChannel(
|
||||||
name: "com.stormg.lumadrama/share",
|
name: "com.stormg.lumadrama/share",
|
||||||
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
||||||
@@ -104,7 +118,7 @@ final class RunnerFlutterViewController: FlutterViewController {
|
|||||||
|
|
||||||
let options: [String: Any]? = headers.isEmpty
|
let options: [String: Any]? = headers.isEmpty
|
||||||
? nil
|
? nil
|
||||||
: [AVURLAssetHTTPHeaderFieldsKey: headers]
|
: [thumbnailHTTPHeaderFieldsKey: headers]
|
||||||
let asset = AVURLAsset(url: assetUrl, options: options)
|
let asset = AVURLAsset(url: assetUrl, options: options)
|
||||||
let generator = AVAssetImageGenerator(asset: asset)
|
let generator = AVAssetImageGenerator(asset: asset)
|
||||||
generator.appliesPreferredTrackTransform = true
|
generator.appliesPreferredTrackTransform = true
|
||||||
@@ -130,4 +144,45 @@ final class RunnerFlutterViewController: FlutterViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 设备标识:IDFV 免权限,卸载本 App 不变,避免客户端自生成的 id 每次重装都变。
|
||||||
|
/// 同通道顺带提供设备区域(ISO-2),注册时作为服务端 IP 解析失败后的兜底。
|
||||||
|
private func registerDeviceIdChannel(_ engineBridge: FlutterImplicitEngineBridge) {
|
||||||
|
let channel = FlutterMethodChannel(
|
||||||
|
name: "com.stormg.lumadrama/device",
|
||||||
|
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
||||||
|
)
|
||||||
|
channel.setMethodCallHandler { call, result in
|
||||||
|
switch call.method {
|
||||||
|
case "idfv":
|
||||||
|
result(UIDevice.current.identifierForVendor?.uuidString)
|
||||||
|
case "region":
|
||||||
|
if #available(iOS 16.0, *) {
|
||||||
|
result(Locale.current.region?.identifier)
|
||||||
|
} else {
|
||||||
|
result(Locale.current.regionCode)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
result(FlutterMethodNotImplemented)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func registerWirelessDataChannel(_ engineBridge: FlutterImplicitEngineBridge) {
|
||||||
|
let channel = FlutterMethodChannel(
|
||||||
|
name: WirelessDataPrompt.channelName,
|
||||||
|
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
||||||
|
)
|
||||||
|
channel.setMethodCallHandler { [weak self] call, result in
|
||||||
|
guard call.method == WirelessDataPrompt.awaitDecisionMethod else {
|
||||||
|
result(FlutterMethodNotImplemented)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard let self else {
|
||||||
|
result(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.wirelessDataPrompt.awaitDecision(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 866 B After Width: | Height: | Size: 412 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 907 B |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 593 B |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 907 B |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 69 B After Width: | Height: | Size: 69 B |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 24 KiB |
@@ -16,18 +16,13 @@
|
|||||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" image="LaunchBackground" translatesAutoresizingMaskIntoConstraints="NO" id="tWc-Dq-wcI"/>
|
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"/>
|
||||||
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"></imageView>
|
|
||||||
</subviews>
|
</subviews>
|
||||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
<color key="backgroundColor" red="0" green="0" blue="0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstItem="YRO-k0-Ey4" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="3T2-ad-Qdv"/>
|
<constraint firstItem="YRO-k0-Ey4" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="3T2-ad-Qdv"/>
|
||||||
<constraint firstItem="tWc-Dq-wcI" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="RPx-PI-7Xg"/>
|
|
||||||
<constraint firstItem="tWc-Dq-wcI" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="SdS-ul-q2q"/>
|
|
||||||
<constraint firstAttribute="trailing" secondItem="tWc-Dq-wcI" secondAttribute="trailing" id="Swv-Gf-Rwn"/>
|
|
||||||
<constraint firstAttribute="trailing" secondItem="YRO-k0-Ey4" secondAttribute="trailing" id="TQA-XW-tRk"/>
|
<constraint firstAttribute="trailing" secondItem="YRO-k0-Ey4" secondAttribute="trailing" id="TQA-XW-tRk"/>
|
||||||
<constraint firstItem="YRO-k0-Ey4" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="duK-uY-Gun"/>
|
<constraint firstItem="YRO-k0-Ey4" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="duK-uY-Gun"/>
|
||||||
<constraint firstItem="tWc-Dq-wcI" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="kV7-tw-vXt"/>
|
|
||||||
<constraint firstItem="YRO-k0-Ey4" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="xPn-NY-SIU"/>
|
<constraint firstItem="YRO-k0-Ey4" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="xPn-NY-SIU"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
@@ -38,7 +33,6 @@
|
|||||||
</scene>
|
</scene>
|
||||||
</scenes>
|
</scenes>
|
||||||
<resources>
|
<resources>
|
||||||
<image name="LaunchImage" width="1152" height="1152"/>
|
<image name="LaunchImage" width="390" height="844"/>
|
||||||
<image name="LaunchBackground" width="1" height="1"/>
|
|
||||||
</resources>
|
</resources>
|
||||||
</document>
|
</document>
|
||||||
@@ -1,109 +1,111 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
|
||||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
|
||||||
<true/>
|
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
|
||||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
|
||||||
<key>CFBundleDisplayName</key>
|
|
||||||
<string>FruitShorts</string>
|
|
||||||
<key>CFBundleExecutable</key>
|
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
|
||||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
|
||||||
<string>6.0</string>
|
|
||||||
<key>CFBundleName</key>
|
|
||||||
<string>FruitShorts</string>
|
|
||||||
<key>CFBundlePackageType</key>
|
|
||||||
<string>APPL</string>
|
|
||||||
<key>CFBundleShortVersionString</key>
|
|
||||||
<string>$(FLUTTER_BUILD_NAME)</string>
|
|
||||||
<key>CFBundleSignature</key>
|
|
||||||
<string>????</string>
|
|
||||||
<key>CFBundleVersion</key>
|
|
||||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
|
||||||
<key>LSRequiresIPhoneOS</key>
|
|
||||||
<true/>
|
|
||||||
<key>NSAppTransportSecurity</key>
|
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSAllowsArbitraryLoads</key>
|
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSAllowsLocalNetworking</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>FruitShorts</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>FruitShorts</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>$(FLUTTER_BUILD_NAME)</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSExceptionDomains</key>
|
<key>NSAppTransportSecurity</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>127.0.0.1</key>
|
<key>NSAllowsArbitraryLoads</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSAllowsLocalNetworking</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSExceptionDomains</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
<key>127.0.0.1</key>
|
||||||
<true/>
|
|
||||||
<key>NSIncludesSubdomains</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
<key>localhost</key>
|
|
||||||
<dict>
|
|
||||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
|
||||||
<true/>
|
|
||||||
<key>NSIncludesSubdomains</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
<key>192.168.31.187</key>
|
|
||||||
<dict>
|
|
||||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
|
||||||
<true/>
|
|
||||||
<key>NSIncludesSubdomains</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
<key>39.162.50.99</key>
|
|
||||||
<dict>
|
|
||||||
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
|
||||||
<true/>
|
|
||||||
<key>NSIncludesSubdomains</key>
|
|
||||||
<true/>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
</dict>
|
|
||||||
<key>NSLocalNetworkUsageDescription</key>
|
|
||||||
<string>开发阶段需要访问同一局域网内的短剧内容服务。</string>
|
|
||||||
<key>UIApplicationSceneManifest</key>
|
|
||||||
<dict>
|
|
||||||
<key>UIApplicationSupportsMultipleScenes</key>
|
|
||||||
<false/>
|
|
||||||
<key>UISceneConfigurations</key>
|
|
||||||
<dict>
|
|
||||||
<key>UIWindowSceneSessionRoleApplication</key>
|
|
||||||
<array>
|
|
||||||
<dict>
|
<dict>
|
||||||
<key>UISceneClassName</key>
|
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||||
<string>UIWindowScene</string>
|
<true/>
|
||||||
<key>UISceneConfigurationName</key>
|
<key>NSIncludesSubdomains</key>
|
||||||
<string>flutter</string>
|
<true/>
|
||||||
<key>UISceneDelegateClassName</key>
|
|
||||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
|
||||||
<key>UISceneStoryboardFile</key>
|
|
||||||
<string>Main</string>
|
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
<key>localhost</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSIncludesSubdomains</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>192.168.31.243</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSIncludesSubdomains</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>39.162.50.99</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExceptionAllowsInsecureHTTPLoads</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSIncludesSubdomains</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>NSLocalNetworkUsageDescription</key>
|
||||||
|
<string>开发阶段需要访问同一局域网内的短剧内容服务。</string>
|
||||||
|
<key>UIApplicationSceneManifest</key>
|
||||||
|
<dict>
|
||||||
|
<key>UIApplicationSupportsMultipleScenes</key>
|
||||||
|
<false/>
|
||||||
|
<key>UISceneConfigurations</key>
|
||||||
|
<dict>
|
||||||
|
<key>UIWindowSceneSessionRoleApplication</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>UISceneClassName</key>
|
||||||
|
<string>UIWindowScene</string>
|
||||||
|
<key>UISceneConfigurationName</key>
|
||||||
|
<string>flutter</string>
|
||||||
|
<key>UISceneDelegateClassName</key>
|
||||||
|
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||||
|
<key>UISceneStoryboardFile</key>
|
||||||
|
<string>Main</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||||
|
<true/>
|
||||||
|
<key>UILaunchStoryboardName</key>
|
||||||
|
<string>LaunchScreen</string>
|
||||||
|
<key>UIMainStoryboardFile</key>
|
||||||
|
<string>Main</string>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UIStatusBarHidden</key>
|
||||||
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
|
||||||
<true/>
|
|
||||||
<key>UILaunchStoryboardName</key>
|
|
||||||
<string>LaunchScreen</string>
|
|
||||||
<key>UIMainStoryboardFile</key>
|
|
||||||
<string>Main</string>
|
|
||||||
<key>UISupportedInterfaceOrientations</key>
|
|
||||||
<array>
|
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
||||||
</array>
|
|
||||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
|
||||||
<array>
|
|
||||||
<string>UIInterfaceOrientationPortrait</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
</plist>
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import Flutter
|
import Flutter
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
class SceneDelegate: FlutterSceneDelegate {
|
class SceneDelegate: FlutterSceneDelegate {
|
||||||
|
override func sceneDidBecomeActive(_ scene: UIScene) {
|
||||||
|
super.sceneDidBecomeActive(scene)
|
||||||
|
(UIApplication.shared.delegate as? AppDelegate)?.requestWirelessDataPrompt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import CoreTelephony
|
||||||
|
import Flutter
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// 监听系统无线数据选择,并用 URLSession 唤起系统选择框。
|
||||||
|
final class WirelessDataPrompt {
|
||||||
|
static let channelName = "com.stormg.lumadrama/wireless-data"
|
||||||
|
static let awaitDecisionMethod = "awaitDecision"
|
||||||
|
|
||||||
|
/// 系统选择框由 URLSession 触发,Dart 的 Socket 请求不会弹出。
|
||||||
|
private static let promptURL = URL(string: "https://captive.apple.com/hotspot-detect.html")
|
||||||
|
|
||||||
|
private let cellularData = CTCellularData()
|
||||||
|
private let lock = NSLock()
|
||||||
|
private var pending: [FlutterResult] = []
|
||||||
|
private var decided = false
|
||||||
|
private var didRequestPrompt = false
|
||||||
|
|
||||||
|
init() {
|
||||||
|
cellularData.cellularDataRestrictionDidUpdateNotifier = { [weak self] state in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self?.completeIfDecided(state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 应用进入前台后请求一次,促使系统弹出无线数据选择。
|
||||||
|
func requestSystemPrompt() {
|
||||||
|
guard !didRequestPrompt, let promptURL = Self.promptURL else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
didRequestPrompt = true
|
||||||
|
_ = cellularData.restrictedState
|
||||||
|
URLSession.shared.dataTask(with: promptURL) { _, _, _ in }.resume()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 未允许前先挂起;用户允许无线数据后再放行。
|
||||||
|
func awaitDecision(_ result: @escaping FlutterResult) {
|
||||||
|
lock.lock()
|
||||||
|
if decided {
|
||||||
|
lock.unlock()
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
result(nil)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pending.append(result)
|
||||||
|
lock.unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func completeIfDecided(_ state: CTCellularDataRestrictedState) {
|
||||||
|
if state != .notRestricted {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
lock.lock()
|
||||||
|
if decided {
|
||||||
|
lock.unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
decided = true
|
||||||
|
let waiters = pending
|
||||||
|
pending.removeAll()
|
||||||
|
lock.unlock()
|
||||||
|
waiters.forEach { $0(nil) }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ import 'core/data/remote/catalog_api.dart';
|
|||||||
import 'core/data/remote/category_api.dart';
|
import 'core/data/remote/category_api.dart';
|
||||||
import 'core/data/remote/comment_api.dart';
|
import 'core/data/remote/comment_api.dart';
|
||||||
import 'core/data/remote/commerce_api.dart';
|
import 'core/data/remote/commerce_api.dart';
|
||||||
|
import 'core/data/remote/device_profile.dart';
|
||||||
import 'core/data/remote/download_api.dart';
|
import 'core/data/remote/download_api.dart';
|
||||||
import 'core/data/remote/interaction_api.dart';
|
import 'core/data/remote/interaction_api.dart';
|
||||||
import 'core/data/remote/library_api.dart';
|
import 'core/data/remote/library_api.dart';
|
||||||
@@ -30,6 +31,7 @@ import 'core/data/repositories/favorite_repository.dart';
|
|||||||
import 'core/data/repositories/interaction_repository.dart';
|
import 'core/data/repositories/interaction_repository.dart';
|
||||||
import 'core/data/repositories/notice_repository.dart';
|
import 'core/data/repositories/notice_repository.dart';
|
||||||
import 'core/data/repositories/playback_repository.dart';
|
import 'core/data/repositories/playback_repository.dart';
|
||||||
|
import 'core/data/repositories/playlist_repository.dart';
|
||||||
import 'core/data/repositories/search_repository.dart';
|
import 'core/data/repositories/search_repository.dart';
|
||||||
import 'core/data/repositories/store_repository.dart';
|
import 'core/data/repositories/store_repository.dart';
|
||||||
import 'core/data/repositories/watch_history_repository.dart';
|
import 'core/data/repositories/watch_history_repository.dart';
|
||||||
@@ -41,6 +43,7 @@ import 'core/data/services/download_controller.dart';
|
|||||||
import 'core/data/services/favorite_controller.dart';
|
import 'core/data/services/favorite_controller.dart';
|
||||||
import 'core/data/services/interaction_controller.dart';
|
import 'core/data/services/interaction_controller.dart';
|
||||||
import 'core/data/services/locale_controller.dart';
|
import 'core/data/services/locale_controller.dart';
|
||||||
|
import 'core/data/services/playlist_controller.dart';
|
||||||
import 'core/data/services/event_tracker.dart';
|
import 'core/data/services/event_tracker.dart';
|
||||||
import 'core/data/services/playback_position_cache.dart';
|
import 'core/data/services/playback_position_cache.dart';
|
||||||
import 'core/data/services/playback_session.dart';
|
import 'core/data/services/playback_session.dart';
|
||||||
@@ -83,6 +86,7 @@ class LumaDramaApp extends StatefulWidget {
|
|||||||
this.commerceRepository,
|
this.commerceRepository,
|
||||||
this.storeRepository,
|
this.storeRepository,
|
||||||
this.searchRepository,
|
this.searchRepository,
|
||||||
|
this.playlistRepository,
|
||||||
this.haptics = const FlutterHaptics(),
|
this.haptics = const FlutterHaptics(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -103,6 +107,7 @@ class LumaDramaApp extends StatefulWidget {
|
|||||||
final CommerceRepository? commerceRepository;
|
final CommerceRepository? commerceRepository;
|
||||||
final StoreRepository? storeRepository;
|
final StoreRepository? storeRepository;
|
||||||
final SearchRepository? searchRepository;
|
final SearchRepository? searchRepository;
|
||||||
|
final PlaylistRepository? playlistRepository;
|
||||||
final Haptics haptics;
|
final Haptics haptics;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -113,12 +118,13 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
late final AuthSessionStore _sessionStore = AuthSessionStore();
|
late final AuthSessionStore _sessionStore = AuthSessionStore();
|
||||||
|
|
||||||
/// 全 App 共用一个 ApiClient:这样目录、账号、后续的互动/进度请求
|
/// 全 App 共用一个 ApiClient:这样目录、账号、后续的互动/进度请求
|
||||||
/// 都自动带 `Authorization` 与 `X-Device-Id`,401 的刷新重试也只有一处实现。
|
/// 都自动带 `Authorization`、`X-Device-Id` 与平台头,401 的刷新重试也只有一处实现。
|
||||||
late final ApiClient _apiClient = ApiClient(
|
late final ApiClient _apiClient = ApiClient(
|
||||||
accessTokenReader: () => _auth.accessToken,
|
accessTokenReader: () => _auth.accessToken,
|
||||||
tokenRefresher: () => _auth.refresh(),
|
tokenRefresher: () => _auth.refresh(),
|
||||||
onUnauthorized: () => _auth.clear(),
|
onUnauthorized: () => _auth.clear(),
|
||||||
deviceIdReader: _sessionStore.deviceId,
|
deviceIdReader: _sessionStore.deviceId,
|
||||||
|
platformReader: clientPlatform,
|
||||||
);
|
);
|
||||||
|
|
||||||
late final AuthController _auth = AuthController(
|
late final AuthController _auth = AuthController(
|
||||||
@@ -126,8 +132,10 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
_sessionStore,
|
_sessionStore,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
late final CatalogApi _catalogApi = CatalogApi(_apiClient);
|
||||||
|
|
||||||
late final CatalogRepository _catalogRepository =
|
late final CatalogRepository _catalogRepository =
|
||||||
widget.catalogRepository ?? HttpCatalogRepository(CatalogApi(_apiClient));
|
widget.catalogRepository ?? HttpCatalogRepository(_catalogApi);
|
||||||
|
|
||||||
late final CategoryRepository _categoryRepository =
|
late final CategoryRepository _categoryRepository =
|
||||||
widget.categoryRepository ??
|
widget.categoryRepository ??
|
||||||
@@ -135,17 +143,11 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
|
|
||||||
late final WatchHistoryRepository _watchHistory =
|
late final WatchHistoryRepository _watchHistory =
|
||||||
widget.watchHistoryRepository ??
|
widget.watchHistoryRepository ??
|
||||||
HttpWatchHistoryRepository(
|
HttpWatchHistoryRepository(WatchApi(_apiClient));
|
||||||
WatchApi(_apiClient),
|
|
||||||
isSignedIn: () => _auth.isSignedIn,
|
|
||||||
);
|
|
||||||
|
|
||||||
late final FavoriteRepository _favorites =
|
late final FavoriteRepository _favorites =
|
||||||
widget.favoriteRepository ??
|
widget.favoriteRepository ??
|
||||||
HttpFavoriteRepository(
|
HttpFavoriteRepository(LibraryApi(_apiClient));
|
||||||
LibraryApi(_apiClient),
|
|
||||||
isSignedIn: () => _auth.isSignedIn,
|
|
||||||
);
|
|
||||||
|
|
||||||
late final PlaybackRepository _playback =
|
late final PlaybackRepository _playback =
|
||||||
widget.playbackRepository ??
|
widget.playbackRepository ??
|
||||||
@@ -177,6 +179,13 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
late final SearchRepository _searchRepository =
|
late final SearchRepository _searchRepository =
|
||||||
widget.searchRepository ?? HttpSearchRepository(CatalogApi(_apiClient));
|
widget.searchRepository ?? HttpSearchRepository(CatalogApi(_apiClient));
|
||||||
|
|
||||||
|
/// 测试注入了目录仓库时不打剧单接口,剧单页继续用本地分区。
|
||||||
|
late final PlaylistRepository? _playlistRepository =
|
||||||
|
widget.playlistRepository ??
|
||||||
|
(widget.catalogRepository == null
|
||||||
|
? HttpPlaylistRepository(CatalogApi(_apiClient))
|
||||||
|
: null);
|
||||||
|
|
||||||
late final StoreRepository _storeRepository =
|
late final StoreRepository _storeRepository =
|
||||||
widget.storeRepository ?? HttpStoreRepository(CommerceApi(_apiClient));
|
widget.storeRepository ?? HttpStoreRepository(CommerceApi(_apiClient));
|
||||||
|
|
||||||
@@ -206,7 +215,7 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
unawaited(_localeController.load());
|
unawaited(_localeController.load());
|
||||||
// 登录/登出时同步收藏状态:收藏属于账号,不能跨账号串联
|
// 登录/登出时同步收藏状态:收藏属于账号,不能跨账号串联
|
||||||
_auth.addListener(_onAuthChanged);
|
_auth.addListener(_onAuthChanged);
|
||||||
if (_auth.isSignedIn) unawaited(_favoriteController.load());
|
unawaited(_favoriteController.load());
|
||||||
if (_auth.isSignedIn) unawaited(_walletController.load());
|
if (_auth.isSignedIn) unawaited(_walletController.load());
|
||||||
unawaited(_downloadController.restore());
|
unawaited(_downloadController.restore());
|
||||||
}
|
}
|
||||||
@@ -222,6 +231,7 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
unawaited(_walletController.load());
|
unawaited(_walletController.load());
|
||||||
} else {
|
} else {
|
||||||
_favoriteController.clear();
|
_favoriteController.clear();
|
||||||
|
unawaited(_favoriteController.load());
|
||||||
_downloadController.reset();
|
_downloadController.reset();
|
||||||
_walletController.reset();
|
_walletController.reset();
|
||||||
}
|
}
|
||||||
@@ -239,14 +249,26 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CategoryController _createCategories() {
|
||||||
|
final controller = CategoryController(_categoryRepository);
|
||||||
|
if (widget.catalogRepository == null) {
|
||||||
|
controller.dramaPageLoader = CategoryApi(_apiClient).dramas;
|
||||||
|
}
|
||||||
|
controller.load();
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final playlists = _playlistRepository;
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
Provider(create: (_) => PlaybackCoordinator()),
|
Provider(create: (_) => PlaybackCoordinator()),
|
||||||
Provider<EventTracker>(create: (_) => EventTracker(_apiClient)),
|
Provider<EventTracker>(create: (_) => EventTracker(_apiClient)),
|
||||||
Provider<PlayerFactory>(create: (_) => widget.playerFactory),
|
Provider<PlayerFactory>(create: (_) => widget.playerFactory),
|
||||||
Provider<CatalogRepository>.value(value: _catalogRepository),
|
Provider<CatalogRepository>.value(value: _catalogRepository),
|
||||||
|
if (widget.catalogRepository == null)
|
||||||
|
Provider<CatalogApi>.value(value: _catalogApi),
|
||||||
Provider<PlaybackRepository>.value(value: _playback),
|
Provider<PlaybackRepository>.value(value: _playback),
|
||||||
Provider<PlaybackPositionCache>.value(value: _playbackPositionCache),
|
Provider<PlaybackPositionCache>.value(value: _playbackPositionCache),
|
||||||
Provider<WatchHistoryRepository>.value(value: _watchHistory),
|
Provider<WatchHistoryRepository>.value(value: _watchHistory),
|
||||||
@@ -260,11 +282,15 @@ class _LumaDramaAppState extends State<LumaDramaApp> {
|
|||||||
Provider<SearchRepository>.value(value: _searchRepository),
|
Provider<SearchRepository>.value(value: _searchRepository),
|
||||||
Provider<Haptics>.value(value: widget.haptics),
|
Provider<Haptics>.value(value: widget.haptics),
|
||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create: (_) => CatalogController(_catalogRepository)..load(),
|
create: (_) {
|
||||||
),
|
final catalog = CatalogController(_catalogRepository);
|
||||||
ChangeNotifierProvider(
|
if (widget.catalogRepository != null) catalog.load();
|
||||||
create: (_) => CategoryController(_categoryRepository)..load(),
|
return catalog;
|
||||||
|
},
|
||||||
),
|
),
|
||||||
|
ChangeNotifierProvider(create: (_) => _createCategories()),
|
||||||
|
if (playlists != null)
|
||||||
|
ChangeNotifierProvider(create: (_) => PlaylistController(playlists)),
|
||||||
ChangeNotifierProvider.value(value: _favoriteController),
|
ChangeNotifierProvider.value(value: _favoriteController),
|
||||||
ChangeNotifierProvider.value(value: _downloadController),
|
ChangeNotifierProvider.value(value: _downloadController),
|
||||||
ChangeNotifierProvider.value(value: _walletController),
|
ChangeNotifierProvider.value(value: _walletController),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class AppConfig {
|
|||||||
/// 开发调试默认服务地址,当前指向本机局域网 IP。
|
/// 开发调试默认服务地址,当前指向本机局域网 IP。
|
||||||
///
|
///
|
||||||
/// 换网络时只改这一行,地址不要带结尾斜杠。
|
/// 换网络时只改这一行,地址不要带结尾斜杠。
|
||||||
static const String devHostBaseUrl = 'http://192.168.31.187:8081';
|
static const String devHostBaseUrl = 'http://192.168.31.243:8081';
|
||||||
|
|
||||||
/// 本机后端地址:通过 `adb reverse tcp:8081 tcp:8081` 映射到开发机,
|
/// 本机后端地址:通过 `adb reverse tcp:8081 tcp:8081` 映射到开发机,
|
||||||
/// 探测可达时 App 直连本机服务;不可达时回落到公网地址。
|
/// 探测可达时 App 直连本机服务;不可达时回落到公网地址。
|
||||||
|
|||||||
@@ -1,17 +1,30 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'locale_text.dart';
|
||||||
|
|
||||||
/// 服务端内容分类。id 按契约保持字符串,避免雪花 ID 精度丢失。
|
/// 服务端内容分类。id 按契约保持字符串,避免雪花 ID 精度丢失。
|
||||||
class ContentCategory {
|
class ContentCategory {
|
||||||
const ContentCategory({required this.id, required this.name});
|
const ContentCategory({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
this.locales = const {},
|
||||||
|
});
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
|
|
||||||
|
/// 中文名称,与 locales 里的 zh 相同。
|
||||||
final String name;
|
final String name;
|
||||||
|
final Map<String, String> locales;
|
||||||
|
|
||||||
/// 解析 `GET /app/categories` 的单项。
|
/// 解析 `GET /app/categories` 的单项。
|
||||||
factory ContentCategory.fromJson(Map<String, dynamic> json) {
|
factory ContentCategory.fromJson(Map<String, dynamic> json) {
|
||||||
return ContentCategory(
|
final locales = localeMap(json['locales']);
|
||||||
id: (json['id'] ?? '').toString(),
|
final name = json['name'] as String? ?? locales['zh'] ?? '';
|
||||||
name: json['name'] as String? ?? '',
|
return ContentCategory(id: (json['id'] ?? '').toString(), name: name, locales: locales);
|
||||||
);
|
}
|
||||||
|
|
||||||
|
/// 按界面语言取名称。缺对应语言时回落到中文。
|
||||||
|
String localizedName(String languageCode) {
|
||||||
|
return localizedText(languageCode, name, locales);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'json_numbers.dart';
|
import 'json_numbers.dart';
|
||||||
|
import 'locale_text.dart';
|
||||||
|
|
||||||
/// 短剧与剧集,字段与后端 `/app/**` 的下发结构对应。
|
/// 短剧与剧集,字段与后端 `/app/**` 的下发结构对应。
|
||||||
///
|
///
|
||||||
@@ -18,6 +21,7 @@ class Episode {
|
|||||||
this.likeCount,
|
this.likeCount,
|
||||||
this.commentCount,
|
this.commentCount,
|
||||||
this.thumbnailsUrl,
|
this.thumbnailsUrl,
|
||||||
|
this.posterUrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
@@ -34,12 +38,14 @@ class Episode {
|
|||||||
final int? likeCount;
|
final int? likeCount;
|
||||||
final int? commentCount;
|
final int? commentCount;
|
||||||
final String? thumbnailsUrl;
|
final String? thumbnailsUrl;
|
||||||
|
final String? posterUrl;
|
||||||
|
|
||||||
Episode withVideoUrl(
|
Episode withVideoUrl(
|
||||||
String url, {
|
String url, {
|
||||||
int? likeCount,
|
int? likeCount,
|
||||||
int? commentCount,
|
int? commentCount,
|
||||||
String? thumbnailsUrl,
|
String? thumbnailsUrl,
|
||||||
|
String? posterUrl,
|
||||||
}) => Episode(
|
}) => Episode(
|
||||||
id: id,
|
id: id,
|
||||||
number: number,
|
number: number,
|
||||||
@@ -51,6 +57,21 @@ class Episode {
|
|||||||
likeCount: likeCount ?? this.likeCount,
|
likeCount: likeCount ?? this.likeCount,
|
||||||
commentCount: commentCount ?? this.commentCount,
|
commentCount: commentCount ?? this.commentCount,
|
||||||
thumbnailsUrl: thumbnailsUrl ?? this.thumbnailsUrl,
|
thumbnailsUrl: thumbnailsUrl ?? this.thumbnailsUrl,
|
||||||
|
posterUrl: posterUrl ?? this.posterUrl,
|
||||||
|
);
|
||||||
|
|
||||||
|
Episode withStats({int? likeCount, int? commentCount}) => Episode(
|
||||||
|
id: id,
|
||||||
|
number: number,
|
||||||
|
title: title,
|
||||||
|
isFree: isFree,
|
||||||
|
videoUrl: videoUrl,
|
||||||
|
durationSec: durationSec,
|
||||||
|
locked: locked,
|
||||||
|
likeCount: likeCount ?? this.likeCount,
|
||||||
|
commentCount: commentCount ?? this.commentCount,
|
||||||
|
thumbnailsUrl: thumbnailsUrl,
|
||||||
|
posterUrl: posterUrl,
|
||||||
);
|
);
|
||||||
|
|
||||||
factory Episode.fromJson(Map<String, dynamic> json) {
|
factory Episode.fromJson(Map<String, dynamic> json) {
|
||||||
@@ -65,6 +86,7 @@ class Episode {
|
|||||||
likeCount: _optionalInt(json['likeCount']),
|
likeCount: _optionalInt(json['likeCount']),
|
||||||
commentCount: _optionalInt(json['commentCount']),
|
commentCount: _optionalInt(json['commentCount']),
|
||||||
thumbnailsUrl: _optionalString(json['thumbnailsUrl']),
|
thumbnailsUrl: _optionalString(json['thumbnailsUrl']),
|
||||||
|
posterUrl: _optionalString(json['posterUrl']),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,7 +98,14 @@ class Drama {
|
|||||||
required this.synopsis,
|
required this.synopsis,
|
||||||
required this.posterUrl,
|
required this.posterUrl,
|
||||||
this.episodes = const [],
|
this.episodes = const [],
|
||||||
|
this.titleLocales = const {},
|
||||||
|
this.synopsisLocales = const {},
|
||||||
|
this.tag = '',
|
||||||
|
this.tagLocales = const {},
|
||||||
|
this.tagColor = '',
|
||||||
this.category = '',
|
this.category = '',
|
||||||
|
this.categoryLocales = const {},
|
||||||
|
this.types = const [],
|
||||||
this.genre = '',
|
this.genre = '',
|
||||||
this.totalEpisodes = 0,
|
this.totalEpisodes = 0,
|
||||||
this.freeEpisodes = 0,
|
this.freeEpisodes = 0,
|
||||||
@@ -94,9 +123,16 @@ class Drama {
|
|||||||
final String id;
|
final String id;
|
||||||
final String title;
|
final String title;
|
||||||
final String synopsis;
|
final String synopsis;
|
||||||
|
final Map<String, String> titleLocales;
|
||||||
|
final Map<String, String> synopsisLocales;
|
||||||
|
final String tag;
|
||||||
|
final Map<String, String> tagLocales;
|
||||||
|
final String tagColor;
|
||||||
final String posterUrl;
|
final String posterUrl;
|
||||||
final List<Episode> episodes;
|
final List<Episode> episodes;
|
||||||
final String category;
|
final String category;
|
||||||
|
final Map<String, String> categoryLocales;
|
||||||
|
final List<Map<String, String>> types;
|
||||||
final String genre;
|
final String genre;
|
||||||
final int totalEpisodes;
|
final int totalEpisodes;
|
||||||
final int freeEpisodes;
|
final int freeEpisodes;
|
||||||
@@ -127,19 +163,26 @@ class Drama {
|
|||||||
/// 列表卡片:带一集可播预览(首页直接起播),完整剧集进详情再取。
|
/// 列表卡片:带一集可播预览(首页直接起播),完整剧集进详情再取。
|
||||||
factory Drama.fromCardJson(Map<String, dynamic> json) {
|
factory Drama.fromCardJson(Map<String, dynamic> json) {
|
||||||
final preview = json['preview'];
|
final preview = json['preview'];
|
||||||
|
final text = _DramaText.fromJson(json);
|
||||||
return Drama(
|
return Drama(
|
||||||
id: (json['id'] ?? '').toString(),
|
id: (json['id'] ?? '').toString(),
|
||||||
title: json['title'] as String? ?? '',
|
title: text.title,
|
||||||
synopsis: json['synopsis'] as String? ?? '',
|
synopsis: text.synopsis,
|
||||||
|
titleLocales: text.titleLocales,
|
||||||
|
synopsisLocales: text.synopsisLocales,
|
||||||
|
tag: text.tag,
|
||||||
|
tagLocales: text.tagLocales,
|
||||||
|
tagColor: json['tagColor'] as String? ?? '',
|
||||||
posterUrl: json['cover'] as String? ?? '',
|
posterUrl: json['cover'] as String? ?? '',
|
||||||
episodes: preview is Map<String, dynamic>
|
episodes: preview is Map<String, dynamic>
|
||||||
? [Episode.fromJson(preview)]
|
? [Episode.fromJson(preview)]
|
||||||
: const [],
|
: const [],
|
||||||
category: json['category'] as String? ?? '',
|
category: text.category,
|
||||||
genre: json['genre'] as String? ?? '',
|
categoryLocales: text.categoryLocales,
|
||||||
|
types: text.types,
|
||||||
|
genre: text.genre,
|
||||||
totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0,
|
totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0,
|
||||||
isHot: json['isHot'] == true,
|
isHot: json['isHot'] == true,
|
||||||
// viewCount 后端是 Long,按字符串下发(见 json_numbers.dart)
|
|
||||||
viewCount: jsonToInt(json['viewCount']),
|
viewCount: jsonToInt(json['viewCount']),
|
||||||
likeCount: _optionalInt(json['likeCount']),
|
likeCount: _optionalInt(json['likeCount']),
|
||||||
favoriteCount: _optionalInt(json['favoriteCount']),
|
favoriteCount: _optionalInt(json['favoriteCount']),
|
||||||
@@ -152,13 +195,21 @@ class Drama {
|
|||||||
|
|
||||||
/// 详情:带剧集列表。
|
/// 详情:带剧集列表。
|
||||||
factory Drama.fromDetailJson(Map<String, dynamic> json) {
|
factory Drama.fromDetailJson(Map<String, dynamic> json) {
|
||||||
|
final text = _DramaText.fromJson(json);
|
||||||
return Drama(
|
return Drama(
|
||||||
id: (json['id'] ?? '').toString(),
|
id: (json['id'] ?? '').toString(),
|
||||||
title: json['title'] as String? ?? '',
|
title: text.title,
|
||||||
synopsis: json['synopsis'] as String? ?? '',
|
synopsis: text.synopsis,
|
||||||
|
titleLocales: text.titleLocales,
|
||||||
|
synopsisLocales: text.synopsisLocales,
|
||||||
|
tag: text.tag,
|
||||||
|
tagLocales: text.tagLocales,
|
||||||
|
tagColor: json['tagColor'] as String? ?? '',
|
||||||
posterUrl: json['cover'] as String? ?? '',
|
posterUrl: json['cover'] as String? ?? '',
|
||||||
category: json['category'] as String? ?? '',
|
category: text.category,
|
||||||
genre: json['genre'] as String? ?? '',
|
categoryLocales: text.categoryLocales,
|
||||||
|
types: text.types,
|
||||||
|
genre: text.genre,
|
||||||
totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0,
|
totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0,
|
||||||
freeEpisodes: (json['freeEpisodes'] as num?)?.toInt() ?? 0,
|
freeEpisodes: (json['freeEpisodes'] as num?)?.toInt() ?? 0,
|
||||||
isHot: json['isHot'] == true,
|
isHot: json['isHot'] == true,
|
||||||
@@ -176,6 +227,37 @@ class Drama {
|
|||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String localizedTitle(String languageCode) {
|
||||||
|
return localizedText(languageCode, title, titleLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
String localizedSynopsis(String languageCode) {
|
||||||
|
return localizedText(languageCode, synopsis, synopsisLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
String localizedTag(String languageCode) {
|
||||||
|
return localizedText(languageCode, tag, tagLocales);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 标签角标背景色。接口没给合法色值时用 fallback。
|
||||||
|
Color tagRibbonColor(Color fallback) {
|
||||||
|
final parsed = _colorFromHex(tagColor);
|
||||||
|
return parsed ?? fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 按当前语言取类型名称。接口没带语言表时返回空,调用方继续用中文 genre。
|
||||||
|
List<String> localizedTypeLabels(String languageCode) {
|
||||||
|
final labels = <String>[];
|
||||||
|
for (final item in types) {
|
||||||
|
final label = localizedText(languageCode, item['zh'] ?? '', item);
|
||||||
|
if (label.isNotEmpty && !labels.contains(label)) labels.add(label);
|
||||||
|
}
|
||||||
|
if (labels.isNotEmpty) return labels;
|
||||||
|
final primary = localizedText(languageCode, '', categoryLocales);
|
||||||
|
if (primary.isNotEmpty) return [primary];
|
||||||
|
return const [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int? _optionalInt(dynamic value) => value == null ? null : jsonToInt(value);
|
int? _optionalInt(dynamic value) => value == null ? null : jsonToInt(value);
|
||||||
@@ -184,3 +266,81 @@ String? _optionalString(dynamic value) {
|
|||||||
final text = value is String ? value.trim() : '';
|
final text = value is String ? value.trim() : '';
|
||||||
return text.isEmpty ? null : text;
|
return text.isEmpty ? null : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color? _colorFromHex(String raw) {
|
||||||
|
final text = raw.trim();
|
||||||
|
if (text.length != 7 || !text.startsWith('#')) return null;
|
||||||
|
final value = int.tryParse(text.substring(1), radix: 16);
|
||||||
|
if (value == null) return null;
|
||||||
|
return Color(0xFF000000 | value);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, String>> _typeLocales(Object? raw) {
|
||||||
|
if (raw is! List) return const [];
|
||||||
|
return raw.whereType<Map>().map(localeMap).toList(growable: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 从语言表还原中文展示字段。列表接口不再单独下发 title / synopsis / tag。
|
||||||
|
class _DramaText {
|
||||||
|
const _DramaText({
|
||||||
|
required this.title,
|
||||||
|
required this.synopsis,
|
||||||
|
required this.titleLocales,
|
||||||
|
required this.synopsisLocales,
|
||||||
|
required this.tag,
|
||||||
|
required this.tagLocales,
|
||||||
|
required this.category,
|
||||||
|
required this.categoryLocales,
|
||||||
|
required this.types,
|
||||||
|
required this.genre,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String title;
|
||||||
|
final String synopsis;
|
||||||
|
final Map<String, String> titleLocales;
|
||||||
|
final Map<String, String> synopsisLocales;
|
||||||
|
final String tag;
|
||||||
|
final Map<String, String> tagLocales;
|
||||||
|
final String category;
|
||||||
|
final Map<String, String> categoryLocales;
|
||||||
|
final List<Map<String, String>> types;
|
||||||
|
final String genre;
|
||||||
|
|
||||||
|
factory _DramaText.fromJson(Map<String, dynamic> json) {
|
||||||
|
final titleLocales = localeMap(json['titleLocales']);
|
||||||
|
final synopsisLocales = localeMap(json['synopsisLocales']);
|
||||||
|
final tagLocales = localeMap(json['tagLocales']);
|
||||||
|
final categoryLocales = localeMap(json['categoryLocales']);
|
||||||
|
final types = _typeLocales(json['types']);
|
||||||
|
final category = _firstText(categoryLocales, json['category'], types);
|
||||||
|
return _DramaText(
|
||||||
|
title: _firstText(titleLocales, json['title']),
|
||||||
|
synopsis: _firstText(synopsisLocales, json['synopsis'] ?? json['description']),
|
||||||
|
titleLocales: titleLocales,
|
||||||
|
synopsisLocales: synopsisLocales,
|
||||||
|
tag: _firstText(tagLocales, json['tag']),
|
||||||
|
tagLocales: tagLocales,
|
||||||
|
category: category,
|
||||||
|
categoryLocales: categoryLocales,
|
||||||
|
types: types,
|
||||||
|
genre: _genreText(types, json['genre']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _firstText(Map<String, String> locales, Object? fallback, [List<Map<String, String>>? types]) {
|
||||||
|
final chinese = locales['zh'] ?? '';
|
||||||
|
if (chinese.isNotEmpty) return chinese;
|
||||||
|
if (types != null && types.isNotEmpty) {
|
||||||
|
final label = types.first['zh'] ?? '';
|
||||||
|
if (label.isNotEmpty) return label;
|
||||||
|
}
|
||||||
|
return fallback is String ? fallback : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
String _genreText(List<Map<String, String>> types, Object? fallback) {
|
||||||
|
final names = types.map((item) => item['zh'] ?? '').where((value) => value.isNotEmpty);
|
||||||
|
final joined = names.join(' / ');
|
||||||
|
if (joined.isNotEmpty) return joined;
|
||||||
|
return fallback is String ? fallback : '';
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'json_numbers.dart';
|
||||||
|
|
||||||
|
/// 播放页轻量互动计数快照,不包含播放地址或票据信息。
|
||||||
|
class EpisodeStats {
|
||||||
|
const EpisodeStats({
|
||||||
|
required this.episodeId,
|
||||||
|
required this.dramaId,
|
||||||
|
required this.likeCount,
|
||||||
|
required this.commentCount,
|
||||||
|
required this.favoriteCount,
|
||||||
|
required this.liked,
|
||||||
|
required this.favorited,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String episodeId;
|
||||||
|
final String dramaId;
|
||||||
|
final int likeCount;
|
||||||
|
final int commentCount;
|
||||||
|
final int favoriteCount;
|
||||||
|
final bool liked;
|
||||||
|
final bool favorited;
|
||||||
|
|
||||||
|
EpisodeStats copyWith({
|
||||||
|
String? dramaId,
|
||||||
|
int? likeCount,
|
||||||
|
int? commentCount,
|
||||||
|
int? favoriteCount,
|
||||||
|
bool? liked,
|
||||||
|
bool? favorited,
|
||||||
|
}) {
|
||||||
|
return EpisodeStats(
|
||||||
|
episodeId: episodeId,
|
||||||
|
dramaId: dramaId ?? this.dramaId,
|
||||||
|
likeCount: likeCount ?? this.likeCount,
|
||||||
|
commentCount: commentCount ?? this.commentCount,
|
||||||
|
favoriteCount: favoriteCount ?? this.favoriteCount,
|
||||||
|
liked: liked ?? this.liked,
|
||||||
|
favorited: favorited ?? this.favorited,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
factory EpisodeStats.fromJson(Map<String, dynamic> json) {
|
||||||
|
return EpisodeStats(
|
||||||
|
episodeId: jsonToId(json['episodeId']),
|
||||||
|
dramaId: jsonToId(json['dramaId']),
|
||||||
|
likeCount: jsonToInt(json['likeCount']),
|
||||||
|
commentCount: jsonToInt(json['commentCount']),
|
||||||
|
favoriteCount: jsonToInt(json['favoriteCount']),
|
||||||
|
liked: json['liked'] == true,
|
||||||
|
favorited: json['favorited'] == true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,7 +48,7 @@ class FeedSection {
|
|||||||
factory FeedSection.fromJson(Map<String, dynamic> json) {
|
factory FeedSection.fromJson(Map<String, dynamic> json) {
|
||||||
return FeedSection(
|
return FeedSection(
|
||||||
code: json['code'] as String? ?? '',
|
code: json['code'] as String? ?? '',
|
||||||
title: json['title'] as String? ?? '',
|
title: _sectionTitle(json),
|
||||||
dramas: (json['dramas'] as List? ?? const [])
|
dramas: (json['dramas'] as List? ?? const [])
|
||||||
.whereType<Map<String, dynamic>>()
|
.whereType<Map<String, dynamic>>()
|
||||||
.map(Drama.fromCardJson)
|
.map(Drama.fromCardJson)
|
||||||
@@ -84,3 +84,12 @@ class FeedBanner {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _sectionTitle(Map<String, dynamic> json) {
|
||||||
|
final locales = json['titleLocales'];
|
||||||
|
if (locales is Map) {
|
||||||
|
final chinese = locales['zh']?.toString() ?? '';
|
||||||
|
if (chinese.isNotEmpty) return chinese;
|
||||||
|
}
|
||||||
|
return json['title'] as String? ?? '';
|
||||||
|
}
|
||||||
@@ -58,14 +58,16 @@ class LikeToggleResult {
|
|||||||
|
|
||||||
/// 控制器统一返回结果;失败消息可直接展示后端 `message`。
|
/// 控制器统一返回结果;失败消息可直接展示后端 `message`。
|
||||||
class OperationResult<T> {
|
class OperationResult<T> {
|
||||||
const OperationResult._(this.data, this.errorMessage);
|
const OperationResult._(this.data, this.errorMessage, this.errorCode);
|
||||||
|
|
||||||
const OperationResult.success([T? data]) : this._(data, null);
|
const OperationResult.success([T? data]) : this._(data, null, null);
|
||||||
|
|
||||||
const OperationResult.failure(this.errorMessage) : data = null;
|
const OperationResult.failure(this.errorMessage, {this.errorCode})
|
||||||
|
: data = null;
|
||||||
|
|
||||||
final T? data;
|
final T? data;
|
||||||
final String? errorMessage;
|
final String? errorMessage;
|
||||||
|
final int? errorCode;
|
||||||
|
|
||||||
bool get isSuccess => errorMessage == null;
|
bool get isSuccess => errorMessage == null;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
/// 把接口里的语言表解析成字符串映射。
|
||||||
|
Map<String, String> localeMap(Object? raw) {
|
||||||
|
if (raw is! Map) return const {};
|
||||||
|
return raw.map((key, value) => MapEntry('$key', value?.toString() ?? ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 按当前语言取文案。没有对应语言时用中文,中文也没有时用 fallback。
|
||||||
|
String localizedText(String languageCode, String fallback, Map<String, String> locales) {
|
||||||
|
final selected = locales[languageCode] ?? '';
|
||||||
|
if (selected.isNotEmpty) return selected;
|
||||||
|
final chinese = locales['zh'] ?? '';
|
||||||
|
if (chinese.isNotEmpty) return chinese;
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
@@ -14,7 +14,9 @@ class PlayTicket {
|
|||||||
this.unlockCoin = 0,
|
this.unlockCoin = 0,
|
||||||
this.previewSeconds = 0,
|
this.previewSeconds = 0,
|
||||||
this.qualities = const [],
|
this.qualities = const [],
|
||||||
|
this.tracks = const [],
|
||||||
this.thumbnailsUrl,
|
this.thumbnailsUrl,
|
||||||
|
this.posterUrl,
|
||||||
this.likeCount,
|
this.likeCount,
|
||||||
this.commentCount,
|
this.commentCount,
|
||||||
});
|
});
|
||||||
@@ -39,9 +41,13 @@ class PlayTicket {
|
|||||||
/// 试看秒数:仅 `COIN_REQUIRED` 时有意义(付费解锁在 B2 做)。
|
/// 试看秒数:仅 `COIN_REQUIRED` 时有意义(付费解锁在 B2 做)。
|
||||||
final int previewSeconds;
|
final int previewSeconds;
|
||||||
|
|
||||||
/// 后端下发的清晰度档位(如 AUTO / 720P / 1080P),HLS 由播放器自动切换。
|
/// 后端下发的清晰度档位(如 AUTO / 720p / 1080p)。
|
||||||
final List<String> qualities;
|
final List<String> qualities;
|
||||||
|
|
||||||
|
/// 各档签名地址。AUTO 是主列表,点选其它档位时换成对应地址。
|
||||||
|
final List<PlayQualityTrack> tracks;
|
||||||
final String? thumbnailsUrl;
|
final String? thumbnailsUrl;
|
||||||
|
final String? posterUrl;
|
||||||
final int? likeCount;
|
final int? likeCount;
|
||||||
final int? commentCount;
|
final int? commentCount;
|
||||||
|
|
||||||
@@ -64,7 +70,9 @@ class PlayTicket {
|
|||||||
.whereType<String>()
|
.whereType<String>()
|
||||||
.where((quality) => quality.isNotEmpty)
|
.where((quality) => quality.isNotEmpty)
|
||||||
.toList(),
|
.toList(),
|
||||||
|
tracks: _tracks(json['tracks'], json['playUrl'] as String? ?? ''),
|
||||||
thumbnailsUrl: _optionalString(json['thumbnailsUrl']),
|
thumbnailsUrl: _optionalString(json['thumbnailsUrl']),
|
||||||
|
posterUrl: _optionalString(json['posterUrl']),
|
||||||
likeCount: json['likeCount'] == null
|
likeCount: json['likeCount'] == null
|
||||||
? null
|
? null
|
||||||
: jsonToInt(json['likeCount']),
|
: jsonToInt(json['likeCount']),
|
||||||
@@ -75,6 +83,67 @@ class PlayTicket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<PlayQualityTrack> _tracks(dynamic raw, String playUrl) {
|
||||||
|
final tracks = <PlayQualityTrack>[];
|
||||||
|
if (raw is List) {
|
||||||
|
for (final item in raw) {
|
||||||
|
if (item is! Map) continue;
|
||||||
|
final quality = item['quality'] as String? ?? '';
|
||||||
|
final url = item['playUrl'] as String? ?? '';
|
||||||
|
if (quality.isEmpty || url.isEmpty) continue;
|
||||||
|
tracks.add(PlayQualityTrack(quality: quality, playUrl: url));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tracks.isEmpty && playUrl.isNotEmpty) {
|
||||||
|
tracks.add(PlayQualityTrack(quality: 'AUTO', playUrl: playUrl));
|
||||||
|
}
|
||||||
|
return tracks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 按票据里的分轨地址取播放地址;没有分轨时,从主列表路径推出同目录的单档地址。
|
||||||
|
String? qualityPlayUrl({
|
||||||
|
required String quality,
|
||||||
|
required List<PlayQualityTrack> tracks,
|
||||||
|
required String currentUrl,
|
||||||
|
}) {
|
||||||
|
final wanted = quality.toUpperCase();
|
||||||
|
for (final track in tracks) {
|
||||||
|
if (track.quality.toUpperCase() == wanted && track.playUrl.isNotEmpty) {
|
||||||
|
return track.playUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return siblingRenditionUrl(currentUrl, wanted);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `.../master.m3u8` 与 `.../720p/index.m3u8` 互相换算,查询参数原样保留。
|
||||||
|
String? siblingRenditionUrl(String currentUrl, String quality) {
|
||||||
|
final uri = Uri.tryParse(currentUrl);
|
||||||
|
if (uri == null || uri.path.isEmpty) return null;
|
||||||
|
final path = uri.path;
|
||||||
|
const masterSuffix = '/master.m3u8';
|
||||||
|
String? root;
|
||||||
|
if (path.endsWith(masterSuffix)) {
|
||||||
|
root = path.substring(0, path.length - masterSuffix.length);
|
||||||
|
} else {
|
||||||
|
final match = RegExp(r'/(\d+p)/index\.m3u8$').firstMatch(path);
|
||||||
|
if (match == null) return null;
|
||||||
|
root = path.substring(0, match.start);
|
||||||
|
}
|
||||||
|
final next = quality.toUpperCase() == 'AUTO'
|
||||||
|
? '$root$masterSuffix'
|
||||||
|
: '$root/${quality.toLowerCase()}/index.m3u8';
|
||||||
|
if (next == path) return currentUrl;
|
||||||
|
return uri.replace(path: next).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 一档清晰度的签名播放地址。
|
||||||
|
class PlayQualityTrack {
|
||||||
|
const PlayQualityTrack({required this.quality, required this.playUrl});
|
||||||
|
|
||||||
|
final String quality;
|
||||||
|
final String playUrl;
|
||||||
|
}
|
||||||
|
|
||||||
String? _optionalString(dynamic value) {
|
String? _optionalString(dynamic value) {
|
||||||
final text = value is String ? value.trim() : '';
|
final text = value is String ? value.trim() : '';
|
||||||
return text.isEmpty ? null : text;
|
return text.isEmpty ? null : text;
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'drama.dart';
|
||||||
|
import 'locale_text.dart';
|
||||||
|
|
||||||
|
/// C 端剧单:`GET /app/playlists` 与 `GET /app/playlists/{id}` 的同一结构。
|
||||||
|
class PlaylistDetail {
|
||||||
|
const PlaylistDetail({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
required this.description,
|
||||||
|
this.locales = const {},
|
||||||
|
this.descriptionLocales = const {},
|
||||||
|
required this.dramaCount,
|
||||||
|
required this.dramas,
|
||||||
|
this.pageIndex = 1,
|
||||||
|
this.pageSize = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
/// 中文名称,与 locales 里的 zh 相同。
|
||||||
|
final String name;
|
||||||
|
final Map<String, String> locales;
|
||||||
|
|
||||||
|
/// 中文描述,与 descriptionLocales 里的 zh 相同。
|
||||||
|
final String description;
|
||||||
|
final Map<String, String> descriptionLocales;
|
||||||
|
final int dramaCount;
|
||||||
|
final int pageIndex;
|
||||||
|
final int pageSize;
|
||||||
|
final List<Drama> dramas;
|
||||||
|
|
||||||
|
factory PlaylistDetail.fromJson(Map<String, dynamic> json) {
|
||||||
|
final dramas = _dramasOf(json['list']);
|
||||||
|
final locales = localeMap(json['locales']);
|
||||||
|
final descriptions = localeMap(json['descriptionLocales']);
|
||||||
|
return PlaylistDetail(
|
||||||
|
id: (json['id'] ?? '').toString(),
|
||||||
|
name: json['name'] as String? ?? locales['zh'] ?? '',
|
||||||
|
locales: locales,
|
||||||
|
description: json['description'] as String? ?? descriptions['zh'] ?? '',
|
||||||
|
descriptionLocales: descriptions,
|
||||||
|
dramaCount: (json['dramaCount'] as num?)?.toInt() ?? dramas.length,
|
||||||
|
pageIndex: (json['pageIndex'] as num?)?.toInt() ?? 1,
|
||||||
|
pageSize: (json['pageSize'] as num?)?.toInt() ?? dramas.length,
|
||||||
|
dramas: dramas,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 按界面语言取名称。缺对应语言时回落到中文。
|
||||||
|
String localizedName(String languageCode) {
|
||||||
|
return localizedText(languageCode, name, locales);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 按界面语言取描述。缺对应语言时回落到中文。
|
||||||
|
String localizedDescription(String languageCode) {
|
||||||
|
return localizedText(languageCode, description, descriptionLocales);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Drama> _dramasOf(Object? rows) {
|
||||||
|
if (rows is! List) return const [];
|
||||||
|
return rows
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((item) => Drama.fromCardJson(Map<String, dynamic>.from(item)))
|
||||||
|
.toList(growable: false);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import 'json_numbers.dart';
|
import 'json_numbers.dart';
|
||||||
|
import 'locale_text.dart';
|
||||||
|
|
||||||
/// 服务端续看记录:`GET /app/watch/progress?dramaId=` 与 `/app/watch/recent` 的下发结构。
|
/// 服务端续看记录:`GET /app/watch/progress?dramaId=` 与 `/app/watch/recent` 的下发结构。
|
||||||
///
|
///
|
||||||
@@ -13,17 +14,20 @@ class WatchProgress {
|
|||||||
required this.position,
|
required this.position,
|
||||||
required this.duration,
|
required this.duration,
|
||||||
this.dramaTitle,
|
this.dramaTitle,
|
||||||
|
this.titleLocales = const {},
|
||||||
this.dramaCover,
|
this.dramaCover,
|
||||||
this.episodeNumber,
|
this.episodeNumber,
|
||||||
this.totalEpisodes,
|
this.totalEpisodes,
|
||||||
this.finished = false,
|
this.finished = false,
|
||||||
this.playCount = 0,
|
this.playCount = 0,
|
||||||
|
this.viewCount,
|
||||||
this.updatedAt,
|
this.updatedAt,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String dramaId;
|
final String dramaId;
|
||||||
final String episodeId;
|
final String episodeId;
|
||||||
final String? dramaTitle;
|
final String? dramaTitle;
|
||||||
|
final Map<String, String> titleLocales;
|
||||||
final String? dramaCover;
|
final String? dramaCover;
|
||||||
final int? episodeNumber;
|
final int? episodeNumber;
|
||||||
final int? totalEpisodes;
|
final int? totalEpisodes;
|
||||||
@@ -31,6 +35,9 @@ class WatchProgress {
|
|||||||
final Duration duration;
|
final Duration duration;
|
||||||
final bool finished;
|
final bool finished;
|
||||||
final int playCount;
|
final int playCount;
|
||||||
|
|
||||||
|
/// 短剧热度。历史列表没下发时为空,不能拿用户自己的 playCount 冒充。
|
||||||
|
final int? viewCount;
|
||||||
final DateTime? updatedAt;
|
final DateTime? updatedAt;
|
||||||
|
|
||||||
bool get hasPosition => position > Duration.zero;
|
bool get hasPosition => position > Duration.zero;
|
||||||
@@ -41,11 +48,17 @@ class WatchProgress {
|
|||||||
return (position.inMilliseconds / duration.inMilliseconds).clamp(0.0, 1.0);
|
return (position.inMilliseconds / duration.inMilliseconds).clamp(0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 按当前语言取剧名。没有对应语言时回退中文,再回退 dramaTitle。
|
||||||
|
String localizedTitle(String languageCode) {
|
||||||
|
return localizedText(languageCode, dramaTitle ?? '', titleLocales);
|
||||||
|
}
|
||||||
|
|
||||||
factory WatchProgress.fromJson(Map<String, dynamic> json) {
|
factory WatchProgress.fromJson(Map<String, dynamic> json) {
|
||||||
return WatchProgress(
|
return WatchProgress(
|
||||||
dramaId: (json['dramaId'] ?? '').toString(),
|
dramaId: (json['dramaId'] ?? '').toString(),
|
||||||
episodeId: (json['episodeId'] ?? '').toString(),
|
episodeId: (json['episodeId'] ?? '').toString(),
|
||||||
dramaTitle: json['dramaTitle']?.toString(),
|
dramaTitle: json['dramaTitle']?.toString(),
|
||||||
|
titleLocales: localeMap(json['titleLocales']),
|
||||||
dramaCover: json['dramaCover']?.toString(),
|
dramaCover: json['dramaCover']?.toString(),
|
||||||
episodeNumber: json['episodeNumber'] == null
|
episodeNumber: json['episodeNumber'] == null
|
||||||
? null
|
? null
|
||||||
@@ -57,6 +70,9 @@ class WatchProgress {
|
|||||||
duration: Duration(milliseconds: jsonToInt(json['durationMs'])),
|
duration: Duration(milliseconds: jsonToInt(json['durationMs'])),
|
||||||
finished: json['finished'] == true,
|
finished: json['finished'] == true,
|
||||||
playCount: jsonToInt(json['playCount']),
|
playCount: jsonToInt(json['playCount']),
|
||||||
|
viewCount: json['viewCount'] == null
|
||||||
|
? null
|
||||||
|
: jsonToInt(json['viewCount']),
|
||||||
updatedAt: DateTime.tryParse(json['updatedAt'] as String? ?? ''),
|
updatedAt: DateTime.tryParse(json['updatedAt'] as String? ?? ''),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -65,6 +81,7 @@ class WatchProgress {
|
|||||||
'dramaId': dramaId,
|
'dramaId': dramaId,
|
||||||
'episodeId': episodeId,
|
'episodeId': episodeId,
|
||||||
if (dramaTitle != null) 'dramaTitle': dramaTitle,
|
if (dramaTitle != null) 'dramaTitle': dramaTitle,
|
||||||
|
if (titleLocales.isNotEmpty) 'titleLocales': titleLocales,
|
||||||
if (dramaCover != null) 'dramaCover': dramaCover,
|
if (dramaCover != null) 'dramaCover': dramaCover,
|
||||||
if (episodeNumber != null) 'episodeNumber': episodeNumber,
|
if (episodeNumber != null) 'episodeNumber': episodeNumber,
|
||||||
if (totalEpisodes != null) 'totalEpisodes': totalEpisodes,
|
if (totalEpisodes != null) 'totalEpisodes': totalEpisodes,
|
||||||
@@ -72,6 +89,7 @@ class WatchProgress {
|
|||||||
'durationMs': duration.inMilliseconds,
|
'durationMs': duration.inMilliseconds,
|
||||||
'finished': finished,
|
'finished': finished,
|
||||||
'playCount': playCount,
|
'playCount': playCount,
|
||||||
|
if (viewCount != null) 'viewCount': viewCount,
|
||||||
if (updatedAt != null) 'updatedAt': updatedAt!.toIso8601String(),
|
if (updatedAt != null) 'updatedAt': updatedAt!.toIso8601String(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,13 @@ class WatchRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 服务端分页标题优先,详情标题作为回退。
|
/// 服务端分页标题优先,详情标题作为回退。
|
||||||
String get displayTitle {
|
String get displayTitle => localizedDisplayTitle('zh');
|
||||||
final pageTitle = progress.dramaTitle?.trim() ?? '';
|
|
||||||
return pageTitle.isNotEmpty ? pageTitle : drama?.title.trim() ?? '';
|
/// 按当前语言取标题。分页语言表优先,详情语言表作为回退。
|
||||||
|
String localizedDisplayTitle(String languageCode) {
|
||||||
|
final pageTitle = progress.localizedTitle(languageCode).trim();
|
||||||
|
if (pageTitle.isNotEmpty) return pageTitle;
|
||||||
|
return drama?.localizedTitle(languageCode).trim() ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 服务端分页封面优先,详情封面作为回退。
|
/// 服务端分页封面优先,详情封面作为回退。
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class ApiClient {
|
|||||||
this.tokenRefresher,
|
this.tokenRefresher,
|
||||||
this.onUnauthorized,
|
this.onUnauthorized,
|
||||||
this.deviceIdReader,
|
this.deviceIdReader,
|
||||||
|
this.platformReader,
|
||||||
}) : _fixedBaseUrl = baseUrl {
|
}) : _fixedBaseUrl = baseUrl {
|
||||||
_dio = Dio(
|
_dio = Dio(
|
||||||
BaseOptions(
|
BaseOptions(
|
||||||
@@ -40,6 +41,7 @@ class ApiClient {
|
|||||||
AuthHeaderInterceptor(
|
AuthHeaderInterceptor(
|
||||||
accessTokenReader: accessTokenReader,
|
accessTokenReader: accessTokenReader,
|
||||||
deviceIdReader: deviceIdReader,
|
deviceIdReader: deviceIdReader,
|
||||||
|
platformReader: platformReader,
|
||||||
),
|
),
|
||||||
const EnvelopeInterceptor(),
|
const EnvelopeInterceptor(),
|
||||||
NetworkLogInterceptor(),
|
NetworkLogInterceptor(),
|
||||||
@@ -67,6 +69,9 @@ class ApiClient {
|
|||||||
/// 设备号(`X-Device-Id`):注册风控、后续下载绑定都要用
|
/// 设备号(`X-Device-Id`):注册风控、后续下载绑定都要用
|
||||||
final Future<String> Function()? deviceIdReader;
|
final Future<String> Function()? deviceIdReader;
|
||||||
|
|
||||||
|
/// 客户端平台(`X-Client-Platform`):后台区分 iOS / Android
|
||||||
|
final String Function()? platformReader;
|
||||||
|
|
||||||
Future<Object?> get(String path, {Map<String, String>? query}) {
|
Future<Object?> get(String path, {Map<String, String>? query}) {
|
||||||
return _request('GET', path, query: query);
|
return _request('GET', path, query: query);
|
||||||
}
|
}
|
||||||
@@ -148,7 +153,8 @@ class ApiClient {
|
|||||||
skipAuthRetry: skipAuthRetry,
|
skipAuthRetry: skipAuthRetry,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
onUnauthorized?.call();
|
final token = accessTokenReader?.call();
|
||||||
|
if (token == null || token.isEmpty) onUnauthorized?.call();
|
||||||
throw ApiException(401, cause.message ?? '登录已过期');
|
throw ApiException(401, cause.message ?? '登录已过期');
|
||||||
}
|
}
|
||||||
if (cause is ApiException) {
|
if (cause is ApiException) {
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ class TokenExpiredException implements Exception {
|
|||||||
///
|
///
|
||||||
/// 每个请求都重新取一次令牌,所以刷新成功后重发的那次会自动带上新令牌。
|
/// 每个请求都重新取一次令牌,所以刷新成功后重发的那次会自动带上新令牌。
|
||||||
class AuthHeaderInterceptor extends Interceptor {
|
class AuthHeaderInterceptor extends Interceptor {
|
||||||
AuthHeaderInterceptor({this.accessTokenReader, this.deviceIdReader});
|
AuthHeaderInterceptor({
|
||||||
|
this.accessTokenReader,
|
||||||
|
this.deviceIdReader,
|
||||||
|
this.platformReader,
|
||||||
|
});
|
||||||
|
|
||||||
/// 当前 access token;未登录返回 null 或空串。
|
/// 当前 access token;未登录返回 null 或空串。
|
||||||
final String? Function()? accessTokenReader;
|
final String? Function()? accessTokenReader;
|
||||||
@@ -40,6 +44,9 @@ class AuthHeaderInterceptor extends Interceptor {
|
|||||||
/// 设备号(`X-Device-Id`):注册风控、下载绑定都用它。
|
/// 设备号(`X-Device-Id`):注册风控、下载绑定都用它。
|
||||||
final Future<String> Function()? deviceIdReader;
|
final Future<String> Function()? deviceIdReader;
|
||||||
|
|
||||||
|
/// 客户端平台(`X-Client-Platform`):后台区分 iOS / Android,匿名请求同样要带。
|
||||||
|
final String Function()? platformReader;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onRequest(
|
Future<void> onRequest(
|
||||||
RequestOptions options,
|
RequestOptions options,
|
||||||
@@ -54,6 +61,10 @@ class AuthHeaderInterceptor extends Interceptor {
|
|||||||
if (deviceId != null && deviceId.isNotEmpty) {
|
if (deviceId != null && deviceId.isNotEmpty) {
|
||||||
options.headers['X-Device-Id'] = deviceId;
|
options.headers['X-Device-Id'] = deviceId;
|
||||||
}
|
}
|
||||||
|
final platform = platformReader?.call() ?? '';
|
||||||
|
if (platform.isNotEmpty) {
|
||||||
|
options.headers['X-Client-Platform'] = platform;
|
||||||
|
}
|
||||||
handler.next(options);
|
handler.next(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class AuthApi {
|
|||||||
required String code,
|
required String code,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
String platform = '',
|
String platform = '',
|
||||||
|
String osVersion = '',
|
||||||
String appVersion = '',
|
String appVersion = '',
|
||||||
}) async {
|
}) async {
|
||||||
final data = await _client.post(
|
final data = await _client.post(
|
||||||
@@ -43,6 +44,7 @@ class AuthApi {
|
|||||||
'code': code,
|
'code': code,
|
||||||
'deviceId': deviceId,
|
'deviceId': deviceId,
|
||||||
'platform': platform,
|
'platform': platform,
|
||||||
|
'osVersion': osVersion,
|
||||||
'appVersion': appVersion,
|
'appVersion': appVersion,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -54,7 +56,9 @@ class AuthApi {
|
|||||||
required String target,
|
required String target,
|
||||||
required String code,
|
required String code,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
|
String countryCode = '',
|
||||||
String platform = '',
|
String platform = '',
|
||||||
|
String osVersion = '',
|
||||||
String appVersion = '',
|
String appVersion = '',
|
||||||
}) async {
|
}) async {
|
||||||
final data = await _client.post(
|
final data = await _client.post(
|
||||||
@@ -63,8 +67,10 @@ class AuthApi {
|
|||||||
'targetType': 'PHONE',
|
'targetType': 'PHONE',
|
||||||
'target': target,
|
'target': target,
|
||||||
'code': code,
|
'code': code,
|
||||||
|
'countryCode': countryCode,
|
||||||
'deviceId': deviceId,
|
'deviceId': deviceId,
|
||||||
'platform': platform,
|
'platform': platform,
|
||||||
|
'osVersion': osVersion,
|
||||||
'appVersion': appVersion,
|
'appVersion': appVersion,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -75,7 +81,9 @@ class AuthApi {
|
|||||||
required String email,
|
required String email,
|
||||||
required String password,
|
required String password,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
|
String countryCode = '',
|
||||||
String platform = '',
|
String platform = '',
|
||||||
|
String osVersion = '',
|
||||||
String appVersion = '',
|
String appVersion = '',
|
||||||
}) async {
|
}) async {
|
||||||
final data = await _client.post(
|
final data = await _client.post(
|
||||||
@@ -84,9 +92,10 @@ class AuthApi {
|
|||||||
'targetType': 'EMAIL',
|
'targetType': 'EMAIL',
|
||||||
'target': email,
|
'target': email,
|
||||||
'password': password,
|
'password': password,
|
||||||
'countryCode': 'ID',
|
'countryCode': countryCode,
|
||||||
'deviceId': deviceId,
|
'deviceId': deviceId,
|
||||||
'platform': platform,
|
'platform': platform,
|
||||||
|
'osVersion': osVersion,
|
||||||
'appVersion': appVersion,
|
'appVersion': appVersion,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -98,6 +107,7 @@ class AuthApi {
|
|||||||
required String password,
|
required String password,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
String platform = '',
|
String platform = '',
|
||||||
|
String osVersion = '',
|
||||||
String appVersion = '',
|
String appVersion = '',
|
||||||
}) async {
|
}) async {
|
||||||
final data = await _client.post(
|
final data = await _client.post(
|
||||||
@@ -108,17 +118,25 @@ class AuthApi {
|
|||||||
'password': password,
|
'password': password,
|
||||||
'deviceId': deviceId,
|
'deviceId': deviceId,
|
||||||
'platform': platform,
|
'platform': platform,
|
||||||
|
'osVersion': osVersion,
|
||||||
'appVersion': appVersion,
|
'appVersion': appVersion,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<AuthSession> refresh(String refreshToken) async {
|
Future<AuthSession> refresh(
|
||||||
|
String refreshToken, {
|
||||||
|
String platform = '',
|
||||||
|
String osVersion = '',
|
||||||
|
}) async {
|
||||||
final data = await _client.post(
|
final data = await _client.post(
|
||||||
'/app/auth/refresh',
|
'/app/auth/refresh',
|
||||||
body: {'refreshToken': refreshToken},
|
body: {
|
||||||
// 刷新请求本身不带旧令牌重试,失败就是失败
|
'refreshToken': refreshToken,
|
||||||
|
'platform': platform,
|
||||||
|
'osVersion': osVersion,
|
||||||
|
},
|
||||||
skipAuthRetry: true,
|
skipAuthRetry: true,
|
||||||
);
|
);
|
||||||
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
return AuthSession.fromJson((data as Map).cast<String, dynamic>());
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
|
import '../models/content_category.dart';
|
||||||
import '../models/drama.dart';
|
import '../models/drama.dart';
|
||||||
import '../models/feed_page.dart';
|
import '../models/feed_page.dart';
|
||||||
import '../models/home_feed.dart';
|
import '../models/home_feed.dart';
|
||||||
|
import '../models/page_result.dart';
|
||||||
|
import '../models/playlist_detail.dart';
|
||||||
import '../models/search_result.dart';
|
import '../models/search_result.dart';
|
||||||
import 'api_client.dart';
|
import 'api_client.dart';
|
||||||
|
|
||||||
@@ -58,12 +61,95 @@ class CatalogApi {
|
|||||||
return SearchResult.fromJson(_asMap(data));
|
return SearchResult.fromJson(_asMap(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const int playlistPageSize = 10;
|
||||||
|
static const int playlistDramaPageSize = 20;
|
||||||
|
|
||||||
|
/// 已启用剧单,分页返回,每条带已上线短剧卡片。
|
||||||
|
Future<PageResult<PlaylistDetail>> playlists({
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = playlistPageSize,
|
||||||
|
}) async {
|
||||||
|
final data = await _client.get(
|
||||||
|
'/app/playlists',
|
||||||
|
query: {
|
||||||
|
'pageIndex': '$pageIndex',
|
||||||
|
'pageSize': '$pageSize',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return PageResult.parse(data, PlaylistDetail.fromJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 单个剧单详情。短剧按 pageIndex、pageSize 翻页。
|
||||||
|
Future<PlaylistDetail> playlist(
|
||||||
|
String id, {
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = playlistDramaPageSize,
|
||||||
|
}) async {
|
||||||
|
return PlaylistDetail.fromJson(
|
||||||
|
_asMap(
|
||||||
|
await _client.get(
|
||||||
|
'/app/playlists/$id',
|
||||||
|
query: {
|
||||||
|
'pageIndex': '$pageIndex',
|
||||||
|
'pageSize': '$pageSize',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 已启用首页分类,名称在 locales。
|
||||||
|
Future<List<ContentCategory>> classifications() async {
|
||||||
|
return _categories(await _client.get('/app/categories'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 已启用类型,名称在 locales。
|
||||||
|
Future<List<ContentCategory>> dramaCategories() async {
|
||||||
|
return _categories(await _client.get('/app/drama-categories'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 已启用标签,名称在 locales。
|
||||||
|
Future<List<ContentCategory>> tags() async {
|
||||||
|
return _categories(await _client.get('/app/tags'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static const int libraryPageSize = 20;
|
||||||
|
|
||||||
|
/// 全部短剧。同一组 id 多选为或,组与组之间为且。
|
||||||
|
Future<PageResult<Drama>> libraryDramas({
|
||||||
|
List<String> categoryIds = const [],
|
||||||
|
List<String> classificationIds = const [],
|
||||||
|
List<String> tagIds = const [],
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = libraryPageSize,
|
||||||
|
}) async {
|
||||||
|
final data = await _client.post(
|
||||||
|
'/app/dramas/page',
|
||||||
|
body: {
|
||||||
|
'pageIndex': pageIndex,
|
||||||
|
'pageSize': pageSize,
|
||||||
|
'categoryIds': categoryIds,
|
||||||
|
'classificationIds': classificationIds,
|
||||||
|
'tagIds': tagIds,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return PageResult.parse(data, Drama.fromCardJson);
|
||||||
|
}
|
||||||
|
|
||||||
Future<Drama> dramaDetail(String dramaId) async {
|
Future<Drama> dramaDetail(String dramaId) async {
|
||||||
return Drama.fromDetailJson(
|
return Drama.fromDetailJson(
|
||||||
_asMap(await _client.get('/app/dramas/$dramaId')),
|
_asMap(await _client.get('/app/dramas/$dramaId')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<ContentCategory> _categories(Object? data) {
|
||||||
|
if (data is! List) return const [];
|
||||||
|
return [
|
||||||
|
for (final item in data)
|
||||||
|
if (item is Map<String, dynamic>) ContentCategory.fromJson(item),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, dynamic> _asMap(Object? data) {
|
Map<String, dynamic> _asMap(Object? data) {
|
||||||
if (data is Map<String, dynamic>) return data;
|
if (data is Map<String, dynamic>) return data;
|
||||||
throw const ApiException(-1, '返回数据格式异常');
|
throw const ApiException(-1, '返回数据格式异常');
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
import '../models/content_category.dart';
|
import '../models/content_category.dart';
|
||||||
|
import '../models/drama.dart';
|
||||||
|
import '../models/page_result.dart';
|
||||||
import 'api_client.dart';
|
import 'api_client.dart';
|
||||||
|
|
||||||
/// 内容分类接口,对应契约 `GET /app/categories`。
|
/// 内容分类接口,对应契约 `GET /app/categories`。
|
||||||
class CategoryApi {
|
class CategoryApi {
|
||||||
const CategoryApi(this._client);
|
const CategoryApi(this._client);
|
||||||
|
|
||||||
|
static const int dramaPageSize = 20;
|
||||||
|
|
||||||
final ApiClient _client;
|
final ApiClient _client;
|
||||||
|
|
||||||
/// 拉取已启用分类,id 全程按字符串解析。
|
/// 拉取已启用分类,id 全程按字符串解析。
|
||||||
@@ -18,4 +22,20 @@ class CategoryApi {
|
|||||||
if (item is Map<String, dynamic>) ContentCategory.fromJson(item),
|
if (item is Map<String, dynamic>) ContentCategory.fromJson(item),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 分类下已上线短剧,pageIndex 从 1 开始。
|
||||||
|
Future<PageResult<Drama>> dramas(
|
||||||
|
String categoryId, {
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = dramaPageSize,
|
||||||
|
}) async {
|
||||||
|
final data = await _client.get(
|
||||||
|
'/app/categories/$categoryId/dramas',
|
||||||
|
query: {
|
||||||
|
'pageIndex': '$pageIndex',
|
||||||
|
'pageSize': '$pageSize',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return PageResult.parse(data, Drama.fromCardJson);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import 'dart:io' show Platform;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
|
/// 客户端平台,后台只用来区分 iOS / Android。
|
||||||
|
///
|
||||||
|
/// 系统版本、机型一律不上报:后台列表需要的只是「这台设备是安卓还是苹果」。
|
||||||
|
String clientPlatform() {
|
||||||
|
if (kIsWeb) return 'WEB';
|
||||||
|
if (Platform.isAndroid) return 'ANDROID';
|
||||||
|
if (Platform.isIOS) return 'IOS';
|
||||||
|
return '';
|
||||||
|
}
|
||||||
@@ -36,4 +36,9 @@ class LibraryApi {
|
|||||||
Future<void> removeFavorite(String dramaId) async {
|
Future<void> removeFavorite(String dramaId) async {
|
||||||
await _client.delete('/app/favorites/$dramaId');
|
await _client.delete('/app/favorites/$dramaId');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 一次取消多部短剧,请求体为 dramaIds 数组。
|
||||||
|
Future<void> removeFavorites(List<String> dramaIds) async {
|
||||||
|
await _client.post('/app/favorites/remove', body: {'dramaIds': dramaIds});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import '../models/episode_stats.dart';
|
||||||
import '../models/play_ticket.dart';
|
import '../models/play_ticket.dart';
|
||||||
import 'api_client.dart';
|
import 'api_client.dart';
|
||||||
|
|
||||||
@@ -17,4 +18,11 @@ class PlaybackApi {
|
|||||||
if (data is Map<String, dynamic>) return PlayTicket.fromJson(data);
|
if (data is Map<String, dynamic>) return PlayTicket.fromJson(data);
|
||||||
throw const ApiException(-1, '返回数据格式异常');
|
throw const ApiException(-1, '返回数据格式异常');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 轻量刷新互动计数:不签发地址,也不占用播放票据缓存。
|
||||||
|
Future<EpisodeStats> episodeStats(String episodeId) async {
|
||||||
|
final data = await _client.get('/app/episodes/$episodeId/stats');
|
||||||
|
if (data is Map<String, dynamic>) return EpisodeStats.fromJson(data);
|
||||||
|
throw const ApiException(-1, '返回数据格式异常');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import '../models/page_result.dart';
|
|||||||
import '../models/watch_progress.dart';
|
import '../models/watch_progress.dart';
|
||||||
import 'api_client.dart';
|
import 'api_client.dart';
|
||||||
|
|
||||||
/// 观看进度接口:`/app/watch/*`(契约 §1.5)。全部需要登录态。
|
/// 观看进度接口:`/app/watch/*`(契约 §1.5)。支持账号或设备身份。
|
||||||
class WatchApi {
|
class WatchApi {
|
||||||
const WatchApi(this._client);
|
const WatchApi(this._client);
|
||||||
|
|
||||||
|
|||||||
@@ -13,29 +13,30 @@ abstract interface class FavoriteRepository {
|
|||||||
Future<PageResult<Drama>> page({int pageIndex = 1, int pageSize = 20});
|
Future<PageResult<Drama>> page({int pageIndex = 1, int pageSize = 20});
|
||||||
|
|
||||||
Future<void> remove(String dramaId);
|
Future<void> remove(String dramaId);
|
||||||
|
|
||||||
|
/// 一次取消多部短剧。
|
||||||
|
Future<void> removeMany(List<String> dramaIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
class HttpFavoriteRepository implements FavoriteRepository {
|
class HttpFavoriteRepository implements FavoriteRepository {
|
||||||
const HttpFavoriteRepository(this._api, {this.isSignedIn});
|
const HttpFavoriteRepository(this._api);
|
||||||
|
|
||||||
final LibraryApi _api;
|
final LibraryApi _api;
|
||||||
|
|
||||||
/// 未登录时不请求:收藏属于账号,匿名浏览时列表按空处理(点收藏按钮会先引导登录)。
|
|
||||||
final bool Function()? isSignedIn;
|
|
||||||
|
|
||||||
bool get _signedIn => isSignedIn?.call() ?? true;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> toggle(String dramaId) => _api.toggleFavorite(dramaId);
|
Future<bool> toggle(String dramaId) => _api.toggleFavorite(dramaId);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PageResult<Drama>> page({int pageIndex = 1, int pageSize = 20}) async {
|
Future<PageResult<Drama>> page({int pageIndex = 1, int pageSize = 20}) async {
|
||||||
if (!_signedIn) return const PageResult();
|
|
||||||
return _api.favorites(pageIndex: pageIndex, pageSize: pageSize);
|
return _api.favorites(pageIndex: pageIndex, pageSize: pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> remove(String dramaId) => _api.removeFavorite(dramaId);
|
Future<void> remove(String dramaId) => _api.removeFavorite(dramaId);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> removeMany(List<String> dramaIds) =>
|
||||||
|
_api.removeFavorites(dramaIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 内存实现:单测与 widget 测试注入用。
|
/// 内存实现:单测与 widget 测试注入用。
|
||||||
@@ -51,6 +52,7 @@ class InMemoryFavoriteRepository implements FavoriteRepository {
|
|||||||
bool failRemove = false;
|
bool failRemove = false;
|
||||||
int toggleCalls = 0;
|
int toggleCalls = 0;
|
||||||
int pageCalls = 0;
|
int pageCalls = 0;
|
||||||
|
int removeManyCalls = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> toggle(String dramaId) async {
|
Future<bool> toggle(String dramaId) async {
|
||||||
@@ -80,4 +82,11 @@ class InMemoryFavoriteRepository implements FavoriteRepository {
|
|||||||
if (failRemove) throw StateError('favorite unavailable');
|
if (failRemove) throw StateError('favorite unavailable');
|
||||||
_saved.remove(dramaId);
|
_saved.remove(dramaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> removeMany(List<String> dramaIds) async {
|
||||||
|
removeManyCalls += 1;
|
||||||
|
if (failRemove) throw StateError('favorite unavailable');
|
||||||
|
_saved.removeAll(dramaIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
// Author: fruit.com.cn
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import '../models/episode_stats.dart';
|
||||||
import '../models/play_ticket.dart';
|
import '../models/play_ticket.dart';
|
||||||
import '../remote/playback_api.dart';
|
import '../remote/playback_api.dart';
|
||||||
|
|
||||||
@@ -10,6 +11,9 @@ import '../remote/playback_api.dart';
|
|||||||
abstract interface class PlaybackRepository {
|
abstract interface class PlaybackRepository {
|
||||||
Future<PlayTicket> ticketFor(String episodeId, {bool forceRefresh = false});
|
Future<PlayTicket> ticketFor(String episodeId, {bool forceRefresh = false});
|
||||||
|
|
||||||
|
/// 读取互动计数快照;与 [ticketFor] 分离,避免为了刷新计数重新签发地址。
|
||||||
|
Future<EpisodeStats> episodeStats(String episodeId);
|
||||||
|
|
||||||
/// 当前缓存的票据是否还在有效期内(用于"回前台发现过期就重新取")。
|
/// 当前缓存的票据是否还在有效期内(用于"回前台发现过期就重新取")。
|
||||||
bool isFresh(String episodeId);
|
bool isFresh(String episodeId);
|
||||||
}
|
}
|
||||||
@@ -42,6 +46,10 @@ class HttpPlaybackRepository implements PlaybackRepository {
|
|||||||
return ticket;
|
return ticket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<EpisodeStats> episodeStats(String episodeId) =>
|
||||||
|
_api.episodeStats(episodeId);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isFresh(String episodeId) {
|
bool isFresh(String episodeId) {
|
||||||
final cached = _cache[episodeId];
|
final cached = _cache[episodeId];
|
||||||
@@ -65,11 +73,22 @@ class _CachedTicket {
|
|||||||
|
|
||||||
/// 测试与离线场景用:按集返回固定票据,并记录被请求过几次。
|
/// 测试与离线场景用:按集返回固定票据,并记录被请求过几次。
|
||||||
class FakePlaybackRepository implements PlaybackRepository {
|
class FakePlaybackRepository implements PlaybackRepository {
|
||||||
FakePlaybackRepository({this.ticket, this.error, this.fresh = true});
|
FakePlaybackRepository({
|
||||||
|
this.ticket,
|
||||||
|
this.error,
|
||||||
|
this.fresh = true,
|
||||||
|
this.stats,
|
||||||
|
this.statsError,
|
||||||
|
Map<String, EpisodeStats>? statsByEpisode,
|
||||||
|
}) : statsByEpisode = statsByEpisode ?? {};
|
||||||
|
|
||||||
PlayTicket? ticket;
|
PlayTicket? ticket;
|
||||||
Object? error;
|
Object? error;
|
||||||
|
EpisodeStats? stats;
|
||||||
|
Object? statsError;
|
||||||
|
final Map<String, EpisodeStats> statsByEpisode;
|
||||||
final List<String> requests = [];
|
final List<String> requests = [];
|
||||||
|
final List<String> statsRequests = [];
|
||||||
final List<bool> forced = [];
|
final List<bool> forced = [];
|
||||||
|
|
||||||
/// 模拟"票据是否还有效":置 false 可验证回前台会重新取。
|
/// 模拟"票据是否还有效":置 false 可验证回前台会重新取。
|
||||||
@@ -95,4 +114,13 @@ class FakePlaybackRepository implements PlaybackRepository {
|
|||||||
qualities: const ['AUTO', '720P', '1080P'],
|
qualities: const ['AUTO', '720P', '1080P'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<EpisodeStats> episodeStats(String episodeId) async {
|
||||||
|
statsRequests.add(episodeId);
|
||||||
|
if (statsError != null) throw statsError!;
|
||||||
|
final value = statsByEpisode[episodeId] ?? stats;
|
||||||
|
if (value != null) return value;
|
||||||
|
throw StateError('episode stats not configured for $episodeId');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// Author: fruit.com.cn
|
||||||
|
|
||||||
|
import '../models/page_result.dart';
|
||||||
|
import '../models/playlist_detail.dart';
|
||||||
|
import '../remote/catalog_api.dart';
|
||||||
|
|
||||||
|
/// 剧单来源:列表分页拉取,详情用于打开单条时刷新。
|
||||||
|
abstract interface class PlaylistRepository {
|
||||||
|
Future<PageResult<PlaylistDetail>> fetchPlaylists({
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = CatalogApi.playlistPageSize,
|
||||||
|
});
|
||||||
|
|
||||||
|
Future<PlaylistDetail> fetchPlaylist(
|
||||||
|
String id, {
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = CatalogApi.playlistDramaPageSize,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class HttpPlaylistRepository implements PlaylistRepository {
|
||||||
|
HttpPlaylistRepository(this._api);
|
||||||
|
|
||||||
|
final CatalogApi _api;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<PageResult<PlaylistDetail>> fetchPlaylists({
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = CatalogApi.playlistPageSize,
|
||||||
|
}) => _api.playlists(pageIndex: pageIndex, pageSize: pageSize);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<PlaylistDetail> fetchPlaylist(
|
||||||
|
String id, {
|
||||||
|
int pageIndex = 1,
|
||||||
|
int pageSize = CatalogApi.playlistDramaPageSize,
|
||||||
|
}) => _api.playlist(id, pageIndex: pageIndex, pageSize: pageSize);
|
||||||
|
}
|
||||||
@@ -35,18 +35,12 @@ abstract interface class WatchHistoryRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class HttpWatchHistoryRepository implements WatchHistoryRepository {
|
class HttpWatchHistoryRepository implements WatchHistoryRepository {
|
||||||
const HttpWatchHistoryRepository(this._api, {this.isSignedIn});
|
const HttpWatchHistoryRepository(this._api);
|
||||||
|
|
||||||
final WatchApi _api;
|
final WatchApi _api;
|
||||||
|
|
||||||
/// 未登录时这些接口必然 401:直接短路成"没有记录",让浏览/试看保持匿名可用。
|
|
||||||
final bool Function()? isSignedIn;
|
|
||||||
|
|
||||||
bool get _signedIn => isSignedIn?.call() ?? true;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<WatchProgress?> progressFor(String dramaId) async {
|
Future<WatchProgress?> progressFor(String dramaId) async {
|
||||||
if (!_signedIn) return null;
|
|
||||||
return _api.progressOfDrama(dramaId);
|
return _api.progressOfDrama(dramaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +51,6 @@ class HttpWatchHistoryRepository implements WatchHistoryRepository {
|
|||||||
Duration? duration,
|
Duration? duration,
|
||||||
bool finished = false,
|
bool finished = false,
|
||||||
}) async {
|
}) async {
|
||||||
if (!_signedIn) return null;
|
|
||||||
return _api.saveProgress(
|
return _api.saveProgress(
|
||||||
episodeId: episodeId,
|
episodeId: episodeId,
|
||||||
position: position,
|
position: position,
|
||||||
@@ -71,19 +64,16 @@ class HttpWatchHistoryRepository implements WatchHistoryRepository {
|
|||||||
int pageIndex = 1,
|
int pageIndex = 1,
|
||||||
int pageSize = 20,
|
int pageSize = 20,
|
||||||
}) async {
|
}) async {
|
||||||
if (!_signedIn) return const PageResult();
|
|
||||||
return _api.recent(pageIndex: pageIndex, pageSize: pageSize);
|
return _api.recent(pageIndex: pageIndex, pageSize: pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> remove(String dramaId) async {
|
Future<void> remove(String dramaId) async {
|
||||||
if (!_signedIn) return;
|
|
||||||
await _api.removeProgress(dramaId);
|
await _api.removeProgress(dramaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> clear() async {
|
Future<void> clear() async {
|
||||||
if (!_signedIn) return;
|
|
||||||
await _api.clearProgress();
|
await _api.clearProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||