-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
151 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"iOS": { | ||
"versionName": "1.5.3", | ||
"versionCode": "13" | ||
"versionName": "1.6.0", | ||
"versionCode": "14" | ||
}, | ||
"Android": { | ||
"versionName": "1.5.3", | ||
"versionCode": "13" | ||
"versionName": "1.6.0", | ||
"versionCode": "14" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,5 @@ | |
| 4 | 新增Qiniu图床记录 | | ||
| 5 | 新增阿里云OSS图床记录 | | ||
| 6 | 新增腾讯云COS图床记录 | | ||
| 7 | 新增牛图网图床记录 | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:flutter_picgo/utils/net.dart'; | ||
|
||
class NiupicApi { | ||
static const BASE_URL = 'https://www.niupic.com/'; | ||
|
||
static Future upload(FormData data) async { | ||
Response res = await NetUtils.getInstance() | ||
.post(BASE_URL + 'index/upload/process', data: data); | ||
return res.data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:flutter_picgo/api/niupic_api.dart'; | ||
import 'package:flutter_picgo/model/uploaded.dart'; | ||
import 'package:flutter_picgo/resources/pb_type_keys.dart'; | ||
import 'package:flutter_picgo/utils/image_upload.dart'; | ||
import 'dart:io'; | ||
|
||
import 'package:flutter_picgo/utils/strategy/image_upload_strategy.dart'; | ||
|
||
class NiupicImageUpload implements ImageUploadStrategy { | ||
/// 牛图网不支持删除 | ||
@override | ||
Future<Uploaded> delete(Uploaded uploaded) async { | ||
return uploaded; | ||
} | ||
|
||
@override | ||
Future<Uploaded> upload(File file, String renameImage) async { | ||
FormData formData = FormData.fromMap({ | ||
"image_field": | ||
await MultipartFile.fromFile(file.path, filename: renameImage), | ||
}); | ||
var result = await NiupicApi.upload(formData); | ||
if (result["code"] == 200) { | ||
var uploadedItem = Uploaded( | ||
-1, 'https://${result['data']}', PBTypeKeys.niupic, | ||
info: ''); | ||
await ImageUploadUtils.saveUploadedItem(uploadedItem); | ||
return uploadedItem; | ||
} else { | ||
throw new NiupicError(error: '${result['msg']}'); | ||
} | ||
} | ||
} | ||
|
||
class NiupicError implements Exception { | ||
NiupicError({ | ||
this.error, | ||
}); | ||
|
||
dynamic error; | ||
|
||
String get message => (error?.toString() ?? ''); | ||
|
||
@override | ||
String toString() { | ||
var msg = 'NiupicError $message'; | ||
if (error is Error) { | ||
msg += '\n${error.stackTrace}'; | ||
} | ||
return msg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_picgo/resources/pb_type_keys.dart'; | ||
import 'package:flutter_picgo/views/pb_setting_page/base_pb_page_state.dart'; | ||
|
||
class NiupicPage extends StatefulWidget { | ||
_NiupicPageState createState() => _NiupicPageState(); | ||
} | ||
|
||
class _NiupicPageState extends BasePBSettingPageState<NiupicPage> { | ||
@override | ||
AppBar get appbar => AppBar( | ||
title: Text('牛图网图床'), | ||
centerTitle: true, | ||
); | ||
|
||
@override | ||
onLoadConfig(String config) {} | ||
|
||
@override | ||
String get pbType => PBTypeKeys.niupic; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters