Merge branch 'master_hyx'
This commit is contained in:
commit
7c6f5883ce
@ -66,7 +66,7 @@ keytool -list -v -keystore android/app/sky.jks
|
|||||||
|
|
||||||
## 编译
|
## 编译
|
||||||
```bash
|
```bash
|
||||||
flutter build apk --split-per-abi --release --flavor sky -t lib/main_sky.dart
|
flutter build apk --release --flavor sky -t lib/main_sky_full.dart
|
||||||
```
|
```
|
||||||
编译后的包:
|
编译后的包:
|
||||||
通用:build/app/outputs/apk/sky/release/app-sky-universal-release.apk
|
通用:build/app/outputs/apk/sky/release/app-sky-universal-release.apk
|
||||||
|
|||||||
@ -11,13 +11,16 @@ enum Flavor {
|
|||||||
class StarLockAMapKey {
|
class StarLockAMapKey {
|
||||||
//iOS平台的key
|
//iOS平台的key
|
||||||
final String iosKey;
|
final String iosKey;
|
||||||
|
|
||||||
//Android平台的key
|
//Android平台的key
|
||||||
final String androidKey;
|
final String androidKey;
|
||||||
|
|
||||||
const StarLockAMapKey({required this.iosKey, required this.androidKey});
|
const StarLockAMapKey({required this.iosKey, required this.androidKey});
|
||||||
}
|
}
|
||||||
|
|
||||||
class F {
|
class F {
|
||||||
static Flavor? appFlavor;
|
static Flavor? appFlavor;
|
||||||
|
|
||||||
// 是否为精简模式(在一些应用商店场景下,需要精简掉一些功能)
|
// 是否为精简模式(在一些应用商店场景下,需要精简掉一些功能)
|
||||||
static bool isLite = false;
|
static bool isLite = false;
|
||||||
|
|
||||||
@ -75,22 +78,20 @@ class F {
|
|||||||
throw Exception('flavor[$name] apiPrefix not found');
|
throw Exception('flavor[$name] apiPrefix not found');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StarLockAMapKey
|
// StarLockAMapKey
|
||||||
static StarLockAMapKey get aMapKey {
|
static StarLockAMapKey get aMapKey {
|
||||||
switch (appFlavor) {
|
switch (appFlavor) {
|
||||||
case Flavor.local:
|
case Flavor.local:
|
||||||
case Flavor.dev:
|
case Flavor.dev:
|
||||||
return const StarLockAMapKey(
|
return const StarLockAMapKey(
|
||||||
androidKey: 'b56b681ee89f4db43a5aa1879ae8cbfe',
|
androidKey: 'b56b681ee89f4db43a5aa1879ae8cbfe', iosKey: 'bd4496e6598ef49796e3a80715035b4d');
|
||||||
iosKey: 'bd4496e6598ef49796e3a80715035b4d');
|
|
||||||
case Flavor.pre:
|
case Flavor.pre:
|
||||||
return const StarLockAMapKey(
|
return const StarLockAMapKey(
|
||||||
androidKey: '11d49b3f4fc09c04a02bbb7500925ba2',
|
androidKey: '11d49b3f4fc09c04a02bbb7500925ba2', iosKey: '883a3355d2d77c2fdc2667030dc97ffe');
|
||||||
iosKey: '883a3355d2d77c2fdc2667030dc97ffe');
|
|
||||||
case Flavor.sky:
|
case Flavor.sky:
|
||||||
return const StarLockAMapKey(
|
return const StarLockAMapKey(
|
||||||
androidKey: 'fb0d2a3e4208b36452cf636aa025a24f',
|
androidKey: 'fb0d2a3e4208b36452cf636aa025a24f', iosKey: '86ca725a12a629c280e116a317aaba19');
|
||||||
iosKey: '86ca725a12a629c280e116a317aaba19');
|
|
||||||
// case Flavor.xhj:
|
// case Flavor.xhj:
|
||||||
// return const StarLockAMapKey(
|
// return const StarLockAMapKey(
|
||||||
// androidKey: 'todo',
|
// androidKey: 'todo',
|
||||||
@ -99,5 +100,4 @@ class F {
|
|||||||
throw Exception('flavor[$name] aMapKey not found');
|
throw Exception('flavor[$name] aMapKey not found');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/webview/webview_logic.dart';
|
||||||
import 'package:webview_flutter/webview_flutter.dart';
|
import 'package:webview_flutter/webview_flutter.dart';
|
||||||
|
|
||||||
class LockMallState {
|
class LockMallState {
|
||||||
@ -7,5 +8,16 @@ class LockMallState {
|
|||||||
var webProgress = 0.0.obs;
|
var webProgress = 0.0.obs;
|
||||||
late WebViewController mallWebView = WebViewController()
|
late WebViewController mallWebView = WebViewController()
|
||||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
..setBackgroundColor(Colors.white);
|
..setBackgroundColor(Colors.white)
|
||||||
|
..setUserAgent(WebViewLogic.userAgent)
|
||||||
|
..setNavigationDelegate(NavigationDelegate(onNavigationRequest: onNavigationRequest));
|
||||||
|
|
||||||
|
//路由跳转逻辑
|
||||||
|
Future<NavigationDecision> onNavigationRequest(NavigationRequest request) async {
|
||||||
|
if (WebViewLogic.judgePaySchemes(request.url)) {
|
||||||
|
await WebViewLogic.runScheme(request.url);
|
||||||
|
return NavigationDecision.prevent;
|
||||||
|
}
|
||||||
|
return NavigationDecision.navigate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,9 +7,16 @@ import 'package:star_lock/login/login/entity/LoginData.dart';
|
|||||||
import '../tools/platform_info_services.dart';
|
import '../tools/platform_info_services.dart';
|
||||||
import '../tools/storage.dart';
|
import '../tools/storage.dart';
|
||||||
|
|
||||||
FutureOr<Request> requestInterceptor(Request request) async {
|
//公共获取UA
|
||||||
request.headers['User-Agent'] =
|
String getUserAgent() {
|
||||||
|
//赋值变量方便调试
|
||||||
|
String ua =
|
||||||
'StarLock/${PlatformInfoService.to.info.version}/${PlatformInfoService.to.info.buildNumber}/${GetPlatform.isAndroid ? 'Android' : 'iOS'}';
|
'StarLock/${PlatformInfoService.to.info.version}/${PlatformInfoService.to.info.buildNumber}/${GetPlatform.isAndroid ? 'Android' : 'iOS'}';
|
||||||
|
return ua;
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureOr<Request> requestInterceptor(Request request) async {
|
||||||
|
request.headers['User-Agent'] = getUserAgent();
|
||||||
request.headers['Accept-Language'] = 'zh-CN';
|
request.headers['Accept-Language'] = 'zh-CN';
|
||||||
// request.headers['Content-Type'] = 'application/json';
|
// request.headers['Content-Type'] = 'application/json';
|
||||||
// request.headers['token'] = StoreService.to.userToken!;
|
// request.headers['token'] = StoreService.to.userToken!;
|
||||||
|
|||||||
35
star_lock/lib/webview/webview_logic.dart
Normal file
35
star_lock/lib/webview/webview_logic.dart
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import 'package:star_lock/network/request_interceptor.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
///
|
||||||
|
/// webview的工具类
|
||||||
|
/// 功能:
|
||||||
|
/// * 管理Schemes的跳转
|
||||||
|
/// * webview的UA表示
|
||||||
|
///
|
||||||
|
class WebViewLogic {
|
||||||
|
//pay的Scheme 列表
|
||||||
|
static const List<String> paySchemes = ['weixin:', 'alipay:'];
|
||||||
|
|
||||||
|
//获取公共UA信息
|
||||||
|
static String get userAgent => getUserAgent();
|
||||||
|
|
||||||
|
//判断是否是支付的Scheme
|
||||||
|
static bool judgePaySchemes(String url) {
|
||||||
|
for (int i = 0, j = paySchemes.length; i < j; i++) {
|
||||||
|
if (url.contains(paySchemes[i])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//运行支付的Scheme业务逻辑
|
||||||
|
static Future<void> runScheme(String url) async {
|
||||||
|
if (await canLaunchUrl(Uri.parse(url))) {
|
||||||
|
await launchUrl(Uri.parse(url));
|
||||||
|
} else {
|
||||||
|
throw 'Could not launch $url';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user