Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
hackycy committed Jul 22, 2020
2 parents bb4caba + cc98d06 commit 1193b9a
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 14 deletions.
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Flutter-PicGo: 一个用于快速上传图片并获取图片URL链接的**手机
# 特色功能

- 长按相册列表项可**同步删除远端的文件**,也可配置仅删除本地列表
- 支持扫描二维码将PicGo(v2.3.0-beta.2以上版本)配置文件转换成Flutter-PicGo的配置,使用请移步[链接](https://github.com/Molunerfinn/PicGo/releases/tag/v2.3.0-beta.2)
- 支持扫描二维码将*PicGo(v2.3.0-beta.2以上版本)*配置文件转换成*Flutter-PicGo*的配置,使用请移步[链接](https://github.com/Molunerfinn/PicGo/releases/tag/v2.3.0-beta.2)
- 适配深色模式,可跟随系统或手动设置
- 支持将flutter-picgo的配置导出至剪切板
- 支持将*Flutter-PicGo*的配置导出至剪切板

> 基本使用配置与PicGo无异,可参考[配置文档](https://picgo.github.io/PicGo-Doc/zh/guide/config.html#%E5%9B%BE%E5%BA%8A%E5%8C%BA)
> 腾讯云COS仅支持v5版配置
Expand All @@ -49,14 +49,45 @@ Flutter-PicGo: 一个用于快速上传图片并获取图片URL链接的**手机
# 应用说明

目前仅支持iOS与Android端,由于部分插件例如[sqflite](https://pub.dev/packages/sqflite),所以并不支持Web端
目前仅支持iOS与Android端,由于部分插件例如[sqflite](https://pub.dev/packages/sqflite)不支持Web端,所以应用也并不支持Web端

# 致谢
# 有问题或者有更好的建议

- 欢迎提 [Issues](https://github.com/PicGo/flutter-picgo/issues)

> 如果项目有帮助到你或者喜欢这个项目,可以给个Star支持一下鸭
# 相关

- [PicGo](https://github.com/Molunerfinn/PicGo)

# 致谢

- [Flutter-Go](https://github.com/alibaba/flutter-go)

# License
# [License](https://github.com/hackycy/flutter-picgo/blob/master/LICENSE)

``` txt
MIT License
Copyright (c) 2020 Mr.Yang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
[MIT](https://github.com/hackycy/flutter-picgo/blob/master/LICENSE)
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

8 changes: 4 additions & 4 deletions docs/version.json
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"
}
}
1 change: 1 addition & 0 deletions docs/设计文档.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
| 4 | 新增Qiniu图床记录 |
| 5 | 新增阿里云OSS图床记录 |
| 6 | 新增腾讯云COS图床记录 |
| 7 | 新增牛图网图床记录 |

12 changes: 12 additions & 0 deletions lib/api/niupic_api.dart
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;
}
}
2 changes: 2 additions & 0 deletions lib/resources/pb_type_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ class PBTypeKeys {
static const aliyun = 'aliyun';

static const tcyun = 'tcyun';

static const niupic = 'niupic';
}
6 changes: 6 additions & 0 deletions lib/routers/router_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_picgo/views/pb_setting_page/aliyun_page/aliyun_page.dart
import 'package:flutter_picgo/views/pb_setting_page/gitee_page/gitee_page.dart';
import 'package:flutter_picgo/views/pb_setting_page/gitee_page/gitee_repo_page.dart';
import 'package:flutter_picgo/views/pb_setting_page/github_page/github_repo_page.dart';
import 'package:flutter_picgo/views/pb_setting_page/niupic_page/niupic_page.dart';
import 'package:flutter_picgo/views/pb_setting_page/pb_setting_page.dart';
import 'package:flutter_picgo/views/pb_setting_page/qiniu_page/qiniu_page.dart';
import 'package:flutter_picgo/views/pb_setting_page/smms_page/smms_page.dart';
Expand Down Expand Up @@ -120,6 +121,11 @@ var pbsettingTcyunHandler = new Handler(
handlerFunc: (context, parameters) => TcyunPage(),
);

// 牛图网图床设置页面
var pbsettingNiupicHandler = new Handler(
handlerFunc: (context, parameters) => NiupicPage(),
);

// picgo设置页面
var picgosettingHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) =>
Expand Down
6 changes: 5 additions & 1 deletion lib/routers/routers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ class Routes {
// --------- aliyun -------------------
static const String settingPbAliyun = '/setting/pb/aliyun';
// -----------------------------------
// --------- aliyun -------------------
// --------- tcyun -------------------
static const String settingPbTcyun = '/setting/pb/tcyun';
// -----------------------------------
// --------- niupic -------------------
static const String settingPbNiupic = '/setting/pb/niupic';
// -----------------------------------

static void configureRoutes(Router router) {
router.notFoundHandler = notfoundHandler;
Expand All @@ -50,5 +53,6 @@ class Routes {
router.define(settingPbQiniu, handler: pbsettingQiniuHandler);
router.define(settingPbAliyun, handler: pbsettingAliyunHandler);
router.define(settingPbTcyun, handler: pbsettingTcyunHandler);
router.define(settingPbNiupic, handler: pbsettingNiupicHandler);
}
}
7 changes: 5 additions & 2 deletions lib/utils/db_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DbProvider {
try {
db = await openDatabase(
path,
version: 6,
version: 7,
onCreate: (db, version) async {
// 创建pb_setting表
_initPb(db);
Expand All @@ -44,7 +44,7 @@ class DbProvider {
id INTEGER PRIMARY KEY AUTOINCREMENT,
path varchar(255) NOT NULL,
type varchar(20) NOT NULL,
info varchar(255) NOT NULL
info varchar(255)
)''');
},
onUpgrade: (db, oldVersion, newVersion) {
Expand Down Expand Up @@ -105,6 +105,9 @@ class DbProvider {
// 腾讯云COS
await db.rawInsert(
'INSERT INTO $TABLE_NAME_PBSETTING(type, path, name, config, visible) VALUES("${PBTypeKeys.tcyun}", "/setting/pb/tcyun", "腾讯云COS图床", NULL, 1)');
// 牛图网
await db.rawInsert(
'INSERT INTO $TABLE_NAME_PBSETTING(type, path, name, config, visible) VALUES("${PBTypeKeys.niupic}", "/setting/pb/niupic", "牛图网图床", NULL, 1)');
// copy data
// update authors set dynasty_index=(select id from dynasties where dynasties .name=authors.dynasty) where dynasty in (select name from dynasties )
if (isExists) {
Expand Down
53 changes: 53 additions & 0 deletions lib/utils/strategy/impl/niupic_image_upload.dart
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;
}
}
4 changes: 4 additions & 0 deletions lib/utils/strategy/upload_strategy_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_picgo/utils/strategy/impl/aliyun_image_upload.dart';
import 'package:flutter_picgo/utils/strategy/impl/gitee_image_upload.dart';
import 'package:flutter_picgo/utils/strategy/impl/github_image_upload.dart';
import 'package:flutter_picgo/utils/strategy/image_upload_strategy.dart';
import 'package:flutter_picgo/utils/strategy/impl/niupic_image_upload.dart';
import 'package:flutter_picgo/utils/strategy/impl/qiniu_image_upload.dart';
import 'package:flutter_picgo/utils/strategy/impl/smms_image_upload.dart';
import 'package:flutter_picgo/utils/strategy/impl/tcyun_image_upload.dart';
Expand Down Expand Up @@ -35,6 +36,9 @@ class UploadStrategyFactory {
} else if (type == PBTypeKeys.tcyun) {
/// 腾讯云
cache[type] = new TcyunImageUpload();
} else if (type == PBTypeKeys.niupic) {
/// 牛图网
cache[type] = new NiupicImageUpload();
}
}
return cache[type];
Expand Down
21 changes: 21 additions & 0 deletions lib/views/pb_setting_page/niupic_page/niupic_page.dart
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;
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.5.3+13
version: 1.6.0+14

environment:
sdk: ">=2.7.0 <3.0.0"
Expand Down

0 comments on commit 1193b9a

Please sign in to comment.