forked from lxm_tools/flutter-picgo
feat:upgrade lib & fix for suggestion
This commit is contained in:
@@ -144,7 +144,10 @@ class QiniuApi {
|
||||
/// 七牛管理验签拦截器
|
||||
class QiniuInterceptor extends InterceptorsWrapper {
|
||||
@override
|
||||
Future onRequest(RequestOptions options) async {
|
||||
Future onRequest(
|
||||
RequestOptions options,
|
||||
RequestInterceptorHandler handler,
|
||||
) async {
|
||||
if (options.path.contains(QiniuApi.BASE_URL)) {
|
||||
String ak = '${options.extra[QiniuApi.accessKey]}';
|
||||
String sk = '${options.extra[QiniuApi.secretKey]}';
|
||||
|
||||
@@ -88,7 +88,10 @@ class TcyunApi {
|
||||
/// TcYun验签拦截器
|
||||
class TcyunInterceptor extends InterceptorsWrapper {
|
||||
@override
|
||||
Future onRequest(RequestOptions options) async {
|
||||
Future onRequest(
|
||||
RequestOptions options,
|
||||
RequestInterceptorHandler handler,
|
||||
) async {
|
||||
if (options.path.contains(TcyunApi.BASE_URL)) {
|
||||
/// 生成 KeyTime
|
||||
var keytime = TcyunApi.buildKeyTime();
|
||||
|
||||
@@ -68,7 +68,10 @@ class UpyunApi {
|
||||
|
||||
class UpyunInterceptor extends InterceptorsWrapper {
|
||||
@override
|
||||
Future onRequest(RequestOptions options) async {
|
||||
Future onRequest(
|
||||
RequestOptions options,
|
||||
RequestInterceptorHandler handler,
|
||||
) async {
|
||||
if (options.path.contains(UpyunApi.BASE_URL.replaceFirst('http://', ''))) {
|
||||
/// 请求方式,如:GET、POST、PUT、HEAD 等
|
||||
String method = options.method.toUpperCase();
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:extended_image/extended_image.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_picgo/model/uploaded.dart';
|
||||
@@ -17,8 +18,8 @@ class ImagePreviewUtils {
|
||||
Navigator.push(
|
||||
context,
|
||||
Platform.isAndroid
|
||||
? TransparentMaterialPageRoute(builder: (_) => page)
|
||||
: TransparentCupertinoPageRoute(builder: (_) => page),
|
||||
? MaterialPageRoute(builder: (_) => page)
|
||||
: CupertinoPageRoute(builder: (_) => page),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,8 +31,8 @@ class ImagePreviewUtils {
|
||||
Navigator.push(
|
||||
context,
|
||||
Platform.isAndroid
|
||||
? TransparentMaterialPageRoute(builder: (_) => page)
|
||||
: TransparentCupertinoPageRoute(builder: (_) => page));
|
||||
? MaterialPageRoute(builder: (_) => page)
|
||||
: CupertinoPageRoute(builder: (_) => page));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class PermissionUtils {
|
||||
title: Text('警告'),
|
||||
content: Text(text),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text('去设置'),
|
||||
onPressed: () {
|
||||
openAppSettings();
|
||||
|
||||
@@ -77,7 +77,7 @@ class GiteeImageUpload implements ImageUploadStrategy {
|
||||
await ImageUploadUtils.saveUploadedItem(uploadedItem);
|
||||
return uploadedItem;
|
||||
} on DioError catch (e) {
|
||||
if (e.type == DioErrorType.RESPONSE &&
|
||||
if (e.type == DioErrorType.response &&
|
||||
e.error.toString().indexOf('400') > 0) {
|
||||
throw GiteeError(error: '文件已存在!');
|
||||
} else {
|
||||
|
||||
@@ -64,7 +64,7 @@ class GithubImageUpload implements ImageUploadStrategy {
|
||||
throw GithubError(error: '读取配置文件错误!请重试');
|
||||
}
|
||||
} on DioError catch (e) {
|
||||
if (e.type == DioErrorType.RESPONSE &&
|
||||
if (e.type == DioErrorType.response &&
|
||||
e.error.toString().indexOf('422') > 0) {
|
||||
throw GithubError(error: '文件已存在!');
|
||||
} else {
|
||||
|
||||
@@ -31,16 +31,16 @@ class QiniuImageUpload extends ImageUploadStrategy {
|
||||
}
|
||||
return uploaded;
|
||||
} on DioError catch (e) {
|
||||
if (e.type == DioErrorType.RESPONSE &&
|
||||
if (e.type == DioErrorType.response &&
|
||||
e.error.toString().indexOf('400') > 0) {
|
||||
throw QiniuError(error: '400 请求报文格式错误');
|
||||
} else if (e.type == DioErrorType.RESPONSE &&
|
||||
} else if (e.type == DioErrorType.response &&
|
||||
e.error.toString().indexOf('401') > 0) {
|
||||
throw QiniuError(error: '401 管理凭证无效');
|
||||
} else if (e.type == DioErrorType.RESPONSE &&
|
||||
} else if (e.type == DioErrorType.response &&
|
||||
e.error.toString().indexOf('599') > 0) {
|
||||
throw QiniuError(error: '599 服务端操作失败');
|
||||
} else if (e.type == DioErrorType.RESPONSE &&
|
||||
} else if (e.type == DioErrorType.response &&
|
||||
e.error.toString().indexOf('612') > 0) {
|
||||
throw QiniuError(error: '612 待删除资源不存在');
|
||||
} else {
|
||||
@@ -88,16 +88,16 @@ class QiniuImageUpload extends ImageUploadStrategy {
|
||||
await ImageUploadUtils.saveUploadedItem(uploadedItem);
|
||||
return uploadedItem;
|
||||
} on DioError catch (e) {
|
||||
if (e.type == DioErrorType.RESPONSE &&
|
||||
if (e.type == DioErrorType.response &&
|
||||
e.error.toString().indexOf('400') > 0) {
|
||||
throw QiniuError(error: '400 请求报文格式错误');
|
||||
} else if (e.type == DioErrorType.RESPONSE &&
|
||||
} else if (e.type == DioErrorType.response &&
|
||||
e.error.toString().indexOf('401') > 0) {
|
||||
throw QiniuError(error: '401 管理凭证无效');
|
||||
} else if (e.type == DioErrorType.RESPONSE &&
|
||||
} else if (e.type == DioErrorType.response &&
|
||||
e.error.toString().indexOf('599') > 0) {
|
||||
throw QiniuError(error: '599 服务端操作失败');
|
||||
} else if (e.type == DioErrorType.RESPONSE &&
|
||||
} else if (e.type == DioErrorType.response &&
|
||||
e.error.toString().indexOf('612') > 0) {
|
||||
throw QiniuError(error: '612 待删除资源不存在');
|
||||
} else {
|
||||
|
||||
@@ -10,8 +10,10 @@ class PageNotFound extends StatelessWidget {
|
||||
),
|
||||
body: Container(
|
||||
child: Center(
|
||||
child: OutlineButton(
|
||||
color: Colors.blue,
|
||||
child: OutlinedButton(
|
||||
style: ButtonStyle(
|
||||
side:
|
||||
MaterialStateProperty.all(BorderSide(color: Colors.blue))),
|
||||
child: Text('关闭'),
|
||||
onPressed: () {
|
||||
Application.router.pop(context);
|
||||
|
||||
@@ -215,7 +215,7 @@ class _AlbumPageState extends State<AlbumPage> implements AlbumPageContract {
|
||||
title: Text('确定删除吗'),
|
||||
content: Text('删除后无法恢复'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text('确定'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -92,9 +92,11 @@ class _GiteeRepoPageState extends BaseLoadingPageState<GiteeRepoPage>
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
color: Theme.of(context).accentColor,
|
||||
textColor: Colors.white,
|
||||
ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
foregroundColor: MaterialStateProperty.all(Colors.white),
|
||||
backgroundColor:
|
||||
MaterialStateProperty.all(Theme.of(context).accentColor)),
|
||||
child: Text('刷新'),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -164,7 +166,7 @@ class _GiteeRepoPageState extends BaseLoadingPageState<GiteeRepoPage>
|
||||
title: Text('确定删除吗'),
|
||||
content: Text('删除后无法恢复'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text('确定'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
|
||||
@@ -92,9 +92,11 @@ class _GithubRepoPageState extends BaseLoadingPageState<GithubRepoPage>
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
color: Theme.of(context).accentColor,
|
||||
textColor: Colors.white,
|
||||
ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
foregroundColor: MaterialStateProperty.all(Colors.white),
|
||||
backgroundColor:
|
||||
MaterialStateProperty.all(Theme.of(context).accentColor)),
|
||||
child: Text('刷新'),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -164,7 +166,7 @@ class _GithubRepoPageState extends BaseLoadingPageState<GithubRepoPage>
|
||||
title: Text('确定删除吗'),
|
||||
content: Text('删除后无法恢复'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text('确定'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
|
||||
@@ -47,9 +47,11 @@ class _LskyRepoPageState extends BaseLoadingPageState<LskyRepoPage>
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
color: Theme.of(context).accentColor,
|
||||
textColor: Colors.white,
|
||||
ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
foregroundColor: MaterialStateProperty.all(Colors.white),
|
||||
backgroundColor:
|
||||
MaterialStateProperty.all(Theme.of(context).accentColor)),
|
||||
child: Text('刷新'),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -136,7 +138,7 @@ class _LskyRepoPageState extends BaseLoadingPageState<LskyRepoPage>
|
||||
title: Text('确定删除吗'),
|
||||
content: Text('删除后无法恢复'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text('确定'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
|
||||
@@ -52,9 +52,11 @@ class _QiniuRepoPageState extends BaseLoadingPageState<QiniuRepoPage>
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
color: Theme.of(context).accentColor,
|
||||
textColor: Colors.white,
|
||||
ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
foregroundColor: MaterialStateProperty.all(Colors.white),
|
||||
backgroundColor:
|
||||
MaterialStateProperty.all(Theme.of(context).accentColor)),
|
||||
child: Text('刷新'),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -121,7 +123,7 @@ class _QiniuRepoPageState extends BaseLoadingPageState<QiniuRepoPage>
|
||||
title: Text('确定删除吗'),
|
||||
content: Text('删除后无法恢复'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text('确定'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
|
||||
@@ -120,9 +120,11 @@ class _SMMSRepoPageState extends BaseLoadingPageState<SMMSRepoPage>
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
color: Theme.of(context).accentColor,
|
||||
textColor: Colors.white,
|
||||
ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
foregroundColor: MaterialStateProperty.all(Colors.white),
|
||||
backgroundColor:
|
||||
MaterialStateProperty.all(Theme.of(context).accentColor)),
|
||||
child: Text('刷新'),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -181,7 +183,7 @@ class _SMMSRepoPageState extends BaseLoadingPageState<SMMSRepoPage>
|
||||
title: Text('确定删除吗'),
|
||||
content: Text('删除后无法恢复'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text('确定'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
|
||||
@@ -50,9 +50,12 @@ abstract class BasePBSettingPageState<T extends StatefulWidget>
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: RaisedButton(
|
||||
color: Theme.of(context).accentColor,
|
||||
textColor: Colors.white,
|
||||
child: ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
foregroundColor:
|
||||
MaterialStateProperty.all(Colors.white),
|
||||
backgroundColor: MaterialStateProperty.all(
|
||||
Theme.of(context).accentColor)),
|
||||
child: Text('保存'),
|
||||
onPressed: () {
|
||||
if (validate) {
|
||||
@@ -63,9 +66,12 @@ abstract class BasePBSettingPageState<T extends StatefulWidget>
|
||||
),
|
||||
SizedBox(width: 5.0),
|
||||
Expanded(
|
||||
child: RaisedButton(
|
||||
color: Colors.greenAccent,
|
||||
textColor: Colors.white,
|
||||
child: ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
foregroundColor:
|
||||
MaterialStateProperty.all(Colors.white),
|
||||
backgroundColor:
|
||||
MaterialStateProperty.all(Colors.greenAccent)),
|
||||
child: Text('设为默认图床'),
|
||||
onPressed: () {
|
||||
if (validate) {
|
||||
|
||||
@@ -50,7 +50,7 @@ class _PBSettingPageState extends State<PBSettingPage>
|
||||
'在PC端已经配置好的用户可以使用PicGo新版的生成图床配置二维码功能。\n\n' +
|
||||
'然后使用Flutter-PicGo直接扫描即可进行配置转换。'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text('已了解,去扫描'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -154,7 +154,7 @@ class _HandleUploadPageState extends State<HandleUploadPage> {
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
TextButton(
|
||||
child: Text('确定'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
|
||||
19
pubspec.yaml
19
pubspec.yaml
@@ -23,23 +23,22 @@ environment:
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
shared_preferences: ^0.5.12+4
|
||||
dio: ^3.0.9
|
||||
package_info: ^0.4.1
|
||||
shared_preferences: ^2.0.5
|
||||
dio: ^4.0.0
|
||||
package_info: ^2.0.0
|
||||
sqflite: ^1.3.2+1
|
||||
fluro: ^1.7.7
|
||||
fluro: ^2.0.3
|
||||
toast: ^0.1.5
|
||||
json_serializable: ^3.3.0
|
||||
url_launcher: ^5.7.10
|
||||
permission_handler: ^5.0.1
|
||||
barcode_scan: ^3.0.1
|
||||
provider: ^4.1.3
|
||||
crypto: ^2.1.4
|
||||
provider: ^5.0.0
|
||||
crypto: ^3.0.1
|
||||
flutter_local_notifications: ^3.0.1+4
|
||||
pull_to_refresh: ^1.6.2
|
||||
characters: ^1.0.0
|
||||
wechat_assets_picker: ^4.2.2
|
||||
extended_image: ^1.5.0
|
||||
pull_to_refresh: ^1.6.5
|
||||
wechat_assets_picker: ^5.1.3
|
||||
extended_image: ^4.0.1
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
|
||||
@@ -17,14 +17,14 @@ main() {
|
||||
var sign = AliyunApi.buildSignature('LTAIsXml0iczvY0J',
|
||||
'yw8eO9Fa9Py2GAPRGG8N3GPKCeKCXl', 'PUT', 'zjyzy', 'test.txt');
|
||||
try {
|
||||
Response res = await NetUtils.getInstance().put(
|
||||
await NetUtils.getInstance().put(
|
||||
'https://zjyzy.oss-cn-shenzhen.aliyuncs.com/test.txt',
|
||||
options: Options(headers: {
|
||||
'Authorization': sign,
|
||||
'Date': HttpDate.format(new DateTime.now()),
|
||||
}, contentType: 'application/x-www-form-urlencoded'),
|
||||
);
|
||||
} on DioError catch (e) {}
|
||||
} on DioError catch (_) {}
|
||||
});
|
||||
|
||||
test('测试FormData提交图片', () async {
|
||||
@@ -43,7 +43,7 @@ main() {
|
||||
var sign = hmacsha1.convert(utf8.encode(originSign));
|
||||
var encodeSign = base64.encode(sign.bytes);
|
||||
try {
|
||||
Response res = await NetUtils.getInstance().post(
|
||||
await NetUtils.getInstance().post(
|
||||
'https://zjyzy.oss-cn-shenzhen.aliyuncs.com',
|
||||
data: FormData.fromMap({
|
||||
'key': 'logo.png',
|
||||
@@ -53,6 +53,6 @@ main() {
|
||||
'file': await MultipartFile.fromFile(pathname, filename: 'logo.png')
|
||||
}),
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType));
|
||||
} on DioError catch (e) {}
|
||||
} on DioError catch (_) {}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,10 +4,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
main() {
|
||||
test('测试UpToken生成', () {
|
||||
String policy = QiniuApi.generatePutPolicy('image', 'test.png');
|
||||
var token = QiniuApi.generateUpToken(
|
||||
'CRd7Wa4PuSGvs4ArToPTLBMCigGGUY3sk3F8oc8W',
|
||||
'f2Jkrlyea5s8h8gLEToa9-k895GNM-BlmQ2RfxwU',
|
||||
policy);
|
||||
QiniuApi.generateUpToken('CRd7Wa4PuSGvs4ArToPTLBMCigGGUY3sk3F8oc8W',
|
||||
'f2Jkrlyea5s8h8gLEToa9-k895GNM-BlmQ2RfxwU', policy);
|
||||
});
|
||||
|
||||
test('测试AuthToken生成', () {
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_picgo/api/tcyun_api.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
main() {
|
||||
test('测试生成 KeyTime', () {});
|
||||
@@ -22,11 +19,11 @@ main() {
|
||||
|
||||
test('PostObjecy 提交', () async {
|
||||
try {
|
||||
String pathname = path.joinAll(
|
||||
[Directory.current.path, '..\\assets\\' 'images', 'logo.png']);
|
||||
String keyTime = TcyunApi.buildKeyTime();
|
||||
String policy = TcyunApi.buildPolicy('ap-nanjing', 'logo.png',
|
||||
'AKIDvb0B9rqfeOr44kt2ar46rO2cwzl6JwUk', keyTime);
|
||||
// String pathname = path.joinAll(
|
||||
// [Directory.current.path, '..\\assets\\' 'images', 'logo.png']);
|
||||
// String keyTime = TcyunApi.buildKeyTime();
|
||||
// String policy = TcyunApi.buildPolicy('ap-nanjing', 'logo.png',
|
||||
// 'AKIDvb0B9rqfeOr44kt2ar46rO2cwzl6JwUk', keyTime);
|
||||
// TcyunApi.postObject(
|
||||
// 'test-1253954259',
|
||||
// 'ap-nanjing',
|
||||
|
||||
Reference in New Issue
Block a user