forked from lxm_tools/flutter-picgo
Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1721efb56 | ||
|
|
4cc6206988 | ||
|
|
f739d49d58 | ||
|
|
65992a35a4 | ||
|
|
f52e15a103 | ||
|
|
f329352043 | ||
|
|
42e8ed0964 | ||
|
|
e966dd4eb5 | ||
|
|
4c6df6ec22 | ||
|
|
a7df525d54 | ||
|
|
73a73dad3f | ||
|
|
1193b9a4b1 | ||
|
|
cc98d06d83 | ||
|
|
41f595d872 | ||
|
|
6459b87665 | ||
|
|
0f901b0819 | ||
|
|
738b377a7d | ||
|
|
9018358d09 | ||
|
|
45ee39b52b | ||
|
|
dffbda8517 | ||
|
|
48ba971ef4 | ||
|
|
469fcfdf9d | ||
|
|
b8d74fb0ee | ||
|
|
4aee5c95c4 | ||
|
|
910a9cc17e | ||
|
|
bb4caba42b | ||
|
|
0ef0b596f4 | ||
|
|
be8bcc3465 | ||
|
|
70aec85c9b | ||
|
|
dcf36fc6f9 | ||
|
|
c6865199f1 | ||
|
|
66a81ac441 | ||
|
|
edec2215bd | ||
|
|
b9a96a2234 | ||
|
|
fc30112493 |
59
README.md
59
README.md
@@ -21,15 +21,16 @@ Flutter-PicGo: 一个用于快速上传图片并获取图片URL链接的**手机
|
||||
- 七牛云 [v1.3+]
|
||||
- 阿里云OSS [v1.4+]
|
||||
- 腾讯云COS [v1.5+]
|
||||
- 牛图网 [v1.6+]
|
||||
|
||||
> 开发进度可以查看 [Projects](https://github.com/PicGo/flutter-picgo/projects),会同步更新开发进度
|
||||
|
||||
# 特色功能
|
||||
|
||||
- 长按相册列表项可同步删除图床下的图片,也可配置仅删除本地列表
|
||||
- 支持扫描二维码将PicGo配置文件转换成Flutter-PicGo的配置
|
||||
- 长按相册列表项可**同步删除远端的文件**,也可配置仅删除本地列表
|
||||
- 支持扫描二维码将*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版配置
|
||||
@@ -40,24 +41,54 @@ Flutter-PicGo: 一个用于快速上传图片并获取图片URL链接的**手机
|
||||
|
||||
# 下载安装
|
||||
|
||||
点击此处下载应用[releases](https://github.com/hackycy/flutter-picgo/releases)或[蒲公英](https://www.pgyer.com/flutter-picgo)。
|
||||
|
||||
Android版直接下载apk安装包或扫码
|
||||
|
||||

|
||||
|
||||
iOS版本请扫描二维码下载或[点击链接](https://apps.apple.com/cn/app/flutter-picgo/id1519714305)。
|
||||
|
||||

|
||||
| | Android | iOS |
|
||||
| :----: | :----------------------------------------------------------: | :----------------------------------------------------------: |
|
||||
| 二维码 |  |  |
|
||||
| 链接 | [点击链接](https://github.com/hackycy/flutter-picgo/releases) | [点击链接](https://apps.apple.com/cn/app/flutter-picgo/id1519714305) |
|
||||
|
||||
> 感谢[Trevor-Lan](https://github.com/Trevor-Lan)提供的苹果开发者账户
|
||||
|
||||
# 致谢
|
||||
# 应用说明
|
||||
|
||||
目前仅支持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
|
||||
|
||||
[MIT](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.
|
||||
|
||||
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.
|
||||
```
|
||||
|
||||
|
||||
23
docs/static/location.html
vendored
Normal file
23
docs/static/location.html
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Flutter-Picgo Release</title>
|
||||
<script>
|
||||
// var u = navigator.userAgent;
|
||||
// var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //判断是否是 android终端
|
||||
// var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //判断是否是 iOS终端
|
||||
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
|
||||
window.location.href = 'https://apps.apple.com/cn/app/flutter-picgo/id1519714305'
|
||||
} else if (/(Android)/i.test(navigator.userAgent)) {
|
||||
window.location.href = 'https://www.pgyer.com/flutter-picgo'
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"iOS": {
|
||||
"versionName": "1.5.2",
|
||||
"versionCode": "12"
|
||||
"versionName": "1.7.0",
|
||||
"versionCode": "15"
|
||||
},
|
||||
"Android": {
|
||||
"versionName": "1.5.1",
|
||||
"versionCode": "12"
|
||||
"versionName": "1.7.0",
|
||||
"versionCode": "15"
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,12 @@
|
||||
|
||||
| 版本 | 描述 |
|
||||
| ---- | ------------------------------------------------ |
|
||||
| 1 | pb_setting,uploaded表初始化,增加Github图床记录 |
|
||||
| 1 | pb_setting,uploaded表初始化,增加Github图床记录 |
|
||||
| 2 | uploaded新增info列,新增SM.MS图床记录 |
|
||||
| 3 | 新增Gitee图床记录 |
|
||||
| 4 | 新增Qiniu图床记录 |
|
||||
| 3 | 新增Gitee图床记录 |
|
||||
| 4 | 新增Qiniu图床记录 |
|
||||
| 5 | 新增阿里云OSS图床记录 |
|
||||
| 6 | 新增腾讯云COS图床记录 |
|
||||
| 7 | 新增牛图网图床记录 |
|
||||
| 8 | 新增兰空图床记录 |
|
||||
|
||||
|
||||
27
lib/api/lsky_api.dart
Normal file
27
lib/api/lsky_api.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_picgo/utils/net.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
class LskyApi {
|
||||
static Future token(String email, String pwd, String host) async {
|
||||
String url = path.joinAll([host, 'api/token']);
|
||||
Response res = await NetUtils.getInstance().post(url, data: {
|
||||
'email': email,
|
||||
'password': pwd,
|
||||
});
|
||||
return res.data;
|
||||
}
|
||||
|
||||
static Future upload(String token, String host, FormData data) async {
|
||||
String url = path.joinAll([host, 'api/upload']);
|
||||
Response res = await NetUtils.getInstance()
|
||||
.post(url, data: data, options: buildCommonOptions(token));
|
||||
return res.data;
|
||||
}
|
||||
|
||||
static Options buildCommonOptions(String token) {
|
||||
return Options(headers: {
|
||||
'token': token,
|
||||
});
|
||||
}
|
||||
}
|
||||
12
lib/api/niupic_api.dart
Normal file
12
lib/api/niupic_api.dart
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ class PicgoApi {
|
||||
/// 获取App最新版本
|
||||
static Future getLatestVersion() async {
|
||||
Response res = await NetUtils.getInstance().get(
|
||||
'https://cdn.jsdelivr.net/gh/PicGo/flutter-picgo@dev/docs/version.json');
|
||||
'https://cdn.jsdelivr.net/gh/PicGo/flutter-picgo/docs/version.json');
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
24
lib/model/lsky_config.dart
Normal file
24
lib/model/lsky_config.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
class LskyConfig {
|
||||
String host;
|
||||
String email;
|
||||
String password;
|
||||
String token;
|
||||
|
||||
LskyConfig({this.host, this.email, this.password, this.token});
|
||||
|
||||
LskyConfig.fromJson(Map<String, dynamic> json) {
|
||||
host = json['host'];
|
||||
email = json['email'];
|
||||
password = json['password'];
|
||||
token = json['token'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['host'] = this.host;
|
||||
data['email'] = this.email;
|
||||
data['password'] = this.password;
|
||||
data['token'] = this.token;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,8 @@ class PBTypeKeys {
|
||||
static const aliyun = 'aliyun';
|
||||
|
||||
static const tcyun = 'tcyun';
|
||||
|
||||
static const niupic = 'niupic';
|
||||
|
||||
static const lsky = 'lsky';
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ 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/lsky_page/lsky_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';
|
||||
@@ -120,6 +122,16 @@ var pbsettingTcyunHandler = new Handler(
|
||||
handlerFunc: (context, parameters) => TcyunPage(),
|
||||
);
|
||||
|
||||
// 牛图网图床设置页面
|
||||
var pbsettingNiupicHandler = new Handler(
|
||||
handlerFunc: (context, parameters) => NiupicPage(),
|
||||
);
|
||||
|
||||
// 兰空图床设置页面
|
||||
var pbsettingLskyHandler = new Handler(
|
||||
handlerFunc: (context, parameters) => LskyPage(),
|
||||
);
|
||||
|
||||
// picgo设置页面
|
||||
var picgosettingHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) =>
|
||||
|
||||
@@ -28,9 +28,15 @@ 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';
|
||||
// -----------------------------------
|
||||
// --------- lsky -------------------
|
||||
static const String settingPbLsky = '/setting/pb/lsky';
|
||||
// -----------------------------------
|
||||
|
||||
static void configureRoutes(Router router) {
|
||||
router.notFoundHandler = notfoundHandler;
|
||||
@@ -50,5 +56,7 @@ class Routes {
|
||||
router.define(settingPbQiniu, handler: pbsettingQiniuHandler);
|
||||
router.define(settingPbAliyun, handler: pbsettingAliyunHandler);
|
||||
router.define(settingPbTcyun, handler: pbsettingTcyunHandler);
|
||||
router.define(settingPbNiupic, handler: pbsettingNiupicHandler);
|
||||
router.define(settingPbLsky, handler: pbsettingLskyHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class DbProvider {
|
||||
try {
|
||||
db = await openDatabase(
|
||||
path,
|
||||
version: 6,
|
||||
version: 8,
|
||||
onCreate: (db, version) async {
|
||||
// 创建pb_setting表
|
||||
_initPb(db);
|
||||
@@ -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) {
|
||||
@@ -105,6 +105,12 @@ 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)');
|
||||
// 兰空图床
|
||||
await db.rawInsert(
|
||||
'INSERT INTO $TABLE_NAME_PBSETTING(type, path, name, config, visible) VALUES("${PBTypeKeys.lsky}", "/setting/pb/lsky", "兰空图床", 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) {
|
||||
|
||||
59
lib/utils/strategy/impl/lsky_image_upload.dart
Normal file
59
lib/utils/strategy/impl/lsky_image_upload.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_picgo/api/lsky_api.dart';
|
||||
import 'package:flutter_picgo/model/lsky_config.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';
|
||||
import 'package:flutter_picgo/utils/strings.dart';
|
||||
|
||||
class LskyImageUpload implements ImageUploadStrategy {
|
||||
@override
|
||||
Future<Uploaded> delete(Uploaded uploaded) async {
|
||||
return uploaded;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Uploaded> upload(File file, String renameImage) async {
|
||||
String configStr = await ImageUploadUtils.getPBConfig(PBTypeKeys.lsky);
|
||||
if (isBlank(configStr)) {
|
||||
throw LskyError(error: '读取配置文件错误!请重试');
|
||||
}
|
||||
LskyConfig config = LskyConfig.fromJson(json.decode(configStr));
|
||||
FormData formData = FormData.fromMap({
|
||||
"image": await MultipartFile.fromFile(file.path, filename: renameImage),
|
||||
});
|
||||
var result = await LskyApi.upload(config.token, config.host, formData);
|
||||
if (result['code'] == 200) {
|
||||
var uploadedItem =
|
||||
Uploaded(-1, '${result['data']['url']}', PBTypeKeys.lsky, info: '');
|
||||
await ImageUploadUtils.saveUploadedItem(uploadedItem);
|
||||
return uploadedItem;
|
||||
} else {
|
||||
throw new LskyError(error: '${result['msg']}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LskyError implements Exception {
|
||||
LskyError({
|
||||
this.error,
|
||||
});
|
||||
|
||||
dynamic error;
|
||||
|
||||
String get message => (error?.toString() ?? '');
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
var msg = 'LskyError $message';
|
||||
if (error is Error) {
|
||||
msg += '\n${error.stackTrace}';
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
53
lib/utils/strategy/impl/niupic_image_upload.dart
Normal file
53
lib/utils/strategy/impl/niupic_image_upload.dart
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ 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/lsky_image_upload.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';
|
||||
@@ -35,6 +37,12 @@ class UploadStrategyFactory {
|
||||
} else if (type == PBTypeKeys.tcyun) {
|
||||
/// 腾讯云
|
||||
cache[type] = new TcyunImageUpload();
|
||||
} else if (type == PBTypeKeys.niupic) {
|
||||
/// 牛图网
|
||||
cache[type] = new NiupicImageUpload();
|
||||
} else if (type == PBTypeKeys.lsky) {
|
||||
/// 兰空
|
||||
cache[type] = new LskyImageUpload();
|
||||
}
|
||||
}
|
||||
return cache[type];
|
||||
|
||||
@@ -66,7 +66,7 @@ abstract class BasePBSettingPageState<T extends StatefulWidget>
|
||||
),
|
||||
Center(
|
||||
child: Text(
|
||||
'请先保存后再进行连接测试',
|
||||
tip,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey[400]),
|
||||
),
|
||||
@@ -152,6 +152,9 @@ abstract class BasePBSettingPageState<T extends StatefulWidget>
|
||||
/// 表单验证
|
||||
bool get validate => _formKey?.currentState?.validate() ?? true;
|
||||
|
||||
/// 子类可重写更改文本
|
||||
String get tip => '请先保存后再进行连接测试';
|
||||
|
||||
/// 保存配置
|
||||
save() async {
|
||||
if (isBlank(pbType)) {
|
||||
|
||||
93
lib/views/pb_setting_page/lsky_page/lsky_page.dart
Normal file
93
lib/views/pb_setting_page/lsky_page/lsky_page.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_picgo/api/lsky_api.dart';
|
||||
import 'package:flutter_picgo/model/config.dart';
|
||||
import 'package:flutter_picgo/model/lsky_config.dart';
|
||||
import 'package:flutter_picgo/resources/pb_type_keys.dart';
|
||||
import 'package:flutter_picgo/utils/strings.dart';
|
||||
import 'package:flutter_picgo/views/pb_setting_page/base_pb_page_state.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
class LskyPage extends StatefulWidget {
|
||||
_LskyPageState createState() => _LskyPageState();
|
||||
}
|
||||
|
||||
class _LskyPageState extends BasePBSettingPageState<LskyPage> {
|
||||
@override
|
||||
AppBar get appbar => AppBar(
|
||||
title: Text('兰空图床'),
|
||||
centerTitle: true,
|
||||
);
|
||||
|
||||
@override
|
||||
onLoadConfig(String config) {
|
||||
List<Config> configs = [];
|
||||
Map<String, dynamic> map;
|
||||
if (isBlank(config)) {
|
||||
map = LskyConfig().toJson();
|
||||
} else {
|
||||
map = LskyConfig.fromJson(json.decode(config)).toJson();
|
||||
}
|
||||
map.forEach((key, value) {
|
||||
Config config;
|
||||
if (key == 'host') {
|
||||
config = Config(
|
||||
label: '设定Host',
|
||||
placeholder: '例如:https://lsky.si-yee.com',
|
||||
needValidate: true,
|
||||
value: value);
|
||||
} else if (key == 'token') {
|
||||
config = Config(
|
||||
label: '设定Token',
|
||||
placeholder: 'Token',
|
||||
needValidate: false,
|
||||
value: value);
|
||||
} else if (key == 'email') {
|
||||
config = Config(
|
||||
label: '设定邮箱',
|
||||
placeholder: 'Email',
|
||||
needValidate: true,
|
||||
value: value);
|
||||
} else if (key == 'password') {
|
||||
config = Config(
|
||||
label: '设定密码',
|
||||
placeholder: '设定密码',
|
||||
needValidate: true,
|
||||
value: value);
|
||||
}
|
||||
config.name = key;
|
||||
configs.add(config);
|
||||
});
|
||||
setConfigs(configs);
|
||||
}
|
||||
|
||||
@override
|
||||
String get tip => '点击保存会自动获取Token,如果已填写字段则不会自动生成';
|
||||
|
||||
@override
|
||||
String get pbType => PBTypeKeys.lsky;
|
||||
|
||||
@override
|
||||
save() async {
|
||||
if (isBlank(controllers['token'].text.trim())) {
|
||||
// 如果Token为空,则自动获取
|
||||
String email = controllers['email'].value.text.trim();
|
||||
String pwd = controllers['password'].value.text.trim();
|
||||
String host = controllers['host'].value.text.trim();
|
||||
var result = await LskyApi.token(email, pwd, host);
|
||||
if (result["code"] == 200) {
|
||||
// controllers["token"].text = '${result["data"]["token"]}';
|
||||
setState(() {
|
||||
configs[3].value = '${result["data"]["token"]}';
|
||||
|
||||
super.save();
|
||||
});
|
||||
} else {
|
||||
Toast.show('Token获取失败,请检查配置', context);
|
||||
}
|
||||
} else {
|
||||
return super.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
21
lib/views/pb_setting_page/niupic_page/niupic_page.dart
Normal file
21
lib/views/pb_setting_page/niupic_page/niupic_page.dart
Normal file
@@ -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;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class _PicGoSettingPageState extends State<PicGoSettingPage> {
|
||||
// onTap: () {},
|
||||
// ),
|
||||
ListTile(
|
||||
title: Text('检查更新'),
|
||||
title: Text('版本更新'),
|
||||
onTap: () {
|
||||
_handleUpdateTap();
|
||||
},
|
||||
@@ -171,20 +171,15 @@ class _PicGoSettingPageState extends State<PicGoSettingPage> {
|
||||
this.isNeedUpdate = true;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
/// 无论有无更新都进行跳转,不允许放置蒲公英链接
|
||||
_handleUpdateTap() async {
|
||||
if (isNeedUpdate) {
|
||||
if (Platform.isAndroid) {
|
||||
launch('https://www.pgyer.com/flutter-picgo');
|
||||
} else if (Platform.isIOS) {
|
||||
launch('https://apps.apple.com/cn/app/flutter-picgo/id1519714305');
|
||||
}
|
||||
} else {
|
||||
Toast.show('当前已经是最新版本', context);
|
||||
if (Platform.isAndroid) {
|
||||
launch('https://github.com/PicGo/flutter-picgo/releases');
|
||||
} else if (Platform.isIOS) {
|
||||
launch('https://apps.apple.com/cn/app/flutter-picgo/id1519714305');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.2+12
|
||||
version: 1.7.0+15
|
||||
|
||||
environment:
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
|
||||
Reference in New Issue
Block a user