Skip to content

Commit bb20eb7

Browse files
committed
Merge branch 'dev'
2 parents 95a3dc3 + 8a2dcdc commit bb20eb7

36 files changed

+1464
-1241
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,4 @@ jobs:
3131
with:
3232
path: build/app/outputs/apk/release/*.apk
3333
- run: |
34-
curl -F "file=@build/app/outputs/apk/release/app-release.apk" -F "uKey=${{ secrets.PGY_USER_KEY }}" -F "_api_key=${{ secrets.PGY_API_KEY }}" https://upload.pgyer.com/apiv1/app/upload
35-
- uses: ncipollo/release-action@v1
36-
with:
37-
artifacts: "build/app/outputs/apk/release/*.apk"
38-
token: ${{ secrets.TOKEN }}
34+
curl -F "file=@build/app/outputs/apk/release/app-release.apk" -F "uKey=${{ secrets.PGY_USER_KEY }}" -F "_api_key=${{ secrets.PGY_API_KEY }}" https://upload.pgyer.com/apiv1/app/upload

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Flutter-PicGo: 一个用于快速上传图片并获取图片URL链接的**手机
3030
# 特色功能
3131

3232
- 长按相册列表项可**同步删除远端的文件**,也可配置仅删除本地列表
33+
- 支持管理(查看或删除)远端图床(内测中)[v1.9+]
3334
- 支持扫描二维码将*PicGo(v2.3.0-beta.2以上版本)*配置文件转换成*Flutter-PicGo*的配置,使用请移步[链接](https://github.com/Molunerfinn/PicGo/releases/tag/v2.3.0-beta.2)
3435
- 适配深色模式,可跟随系统或手动设置
3536
- 支持将*Flutter-PicGo*的配置导出至剪切板
@@ -45,7 +46,7 @@ Flutter-PicGo: 一个用于快速上传图片并获取图片URL链接的**手机
4546
| | Android | iOS |
4647
| :----: | :----------------------------------------------------------: | :----------------------------------------------------------: |
4748
| 二维码 | ![](https://github.static.si-yee.com/picgo/android.png) | ![](https://github.static.si-yee.com/picgo/appstore.png) |
48-
| 链接 | [点击链接](https://github.com/hackycy/flutter-picgo/releases) | [点击链接](https://apps.apple.com/cn/app/flutter-picgo/id1519714305) |
49+
| 链接 | [Release](https://github.com/hackycy/flutter-picgo/releases) / [蒲公英](https://www.pgyer.com/flutter-picgo) | [AppStore](https://apps.apple.com/cn/app/flutter-picgo/id1519714305) |
4950

5051
> 感谢[Trevor-Lan](https://github.com/Trevor-Lan)提供的苹果开发者账户
5152

lib/api/lsky_api.dart

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,33 @@ class LskyApi {
1919
return res.data;
2020
}
2121

22+
static Future images(String token, String host, int page,
23+
{int rows = 10}) async {
24+
String url = path.joinAll([host, 'api/images']);
25+
Response res = await NetUtils.getInstance().post(
26+
url,
27+
data: {
28+
'page': page,
29+
'rows': rows,
30+
},
31+
options: buildCommonOptions(token),
32+
);
33+
return res.data;
34+
}
35+
36+
static Future delete(String token, String host, String id) async {
37+
String url = path.joinAll([host, 'api/delete']);
38+
Response res = await NetUtils.getInstance().post(url,
39+
data: {
40+
'id': id,
41+
},
42+
options: buildCommonOptions(token));
43+
return res.data;
44+
}
45+
2246
static Options buildCommonOptions(String token) {
2347
return Options(headers: {
2448
'token': token,
25-
});
49+
}, contentType: Headers.formUrlEncodedContentType);
2650
}
2751
}

lib/api/smms_api.dart

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,35 @@ class SMMSApi {
1212

1313
static Future getProfile() async {
1414
var op = await oAuth();
15-
Response res = await NetUtils.getInstance().post(BASE_URL + 'profile', options: op);
15+
Response res =
16+
await NetUtils.getInstance().post(BASE_URL + 'profile', options: op);
1617
return res.data;
1718
}
1819

1920
static Future upload(FormData formData) async {
2021
var op = await oAuth();
21-
Response res = await NetUtils.getInstance().post(BASE_URL + 'upload', data: formData, options: op);
22+
Response res = await NetUtils.getInstance()
23+
.post(BASE_URL + 'upload', data: formData, options: op);
2224
return res.data;
2325
}
2426

2527
static Future delete(String hash) async {
2628
var op = await oAuth();
27-
Response res = await NetUtils.getInstance().get(BASE_URL + 'delete/' + hash ?? '', options: op);
29+
Response res = await NetUtils.getInstance()
30+
.get(BASE_URL + 'delete/' + hash ?? '', options: op);
31+
return res.data;
32+
}
33+
34+
static Future deleteByPath(String path) async {
35+
var op = await oAuth();
36+
Response res = await NetUtils.getInstance().get(path, options: op);
37+
return res.data;
38+
}
39+
40+
static Future getUploadHistory() async {
41+
var op = await oAuth();
42+
Response res = await NetUtils.getInstance()
43+
.get(BASE_URL + 'upload_history', options: op);
2844
return res.data;
2945
}
3046

lib/components/manage_item.dart

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
import 'package:cached_network_image/cached_network_image.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:path/path.dart';
4+
5+
typedef GestureTapCallback = void Function();
6+
typedef DismissDirectionCallback = void Function(DismissDirection direction);
7+
8+
class ManageItem extends StatelessWidget {
9+
final Key key;
10+
final String url;
11+
final String name;
12+
final String info;
13+
final FileContentType type;
14+
final GestureTapCallback onTap;
15+
final DismissDirectionCallback onDismiss;
16+
final ConfirmDismissCallback confirmDismiss;
17+
18+
ManageItem(
19+
this.key,
20+
this.url,
21+
this.name,
22+
this.info,
23+
this.type, {
24+
this.onTap,
25+
this.onDismiss,
26+
this.confirmDismiss,
27+
});
28+
29+
@override
30+
Widget build(BuildContext context) {
31+
return Dismissible(
32+
key: key,
33+
direction: DismissDirection.endToStart,
34+
child: Stack(
35+
children: <Widget>[
36+
ListTile(
37+
leading: buildLeading(),
38+
title: Text(
39+
this.name,
40+
maxLines: 1,
41+
overflow: TextOverflow.ellipsis,
42+
textWidthBasis: TextWidthBasis.parent,
43+
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
44+
),
45+
subtitle: Text(
46+
this.info,
47+
maxLines: 1,
48+
style: TextStyle(color: Colors.grey),
49+
),
50+
onTap: onTap,
51+
),
52+
Align(
53+
alignment: Alignment.bottomCenter,
54+
child: Divider(
55+
height: 1,
56+
color: Theme.of(context).dividerColor,
57+
indent: 80,
58+
),
59+
)
60+
],
61+
),
62+
onDismissed: onDismiss,
63+
confirmDismiss: confirmDismiss,
64+
background: Container(
65+
color: Colors.red,
66+
),
67+
);
68+
}
69+
70+
Widget buildLeading() {
71+
if (this.type == FileContentType.DIR) {
72+
return buildCenterIcon(Icon(IconData(0xe63f, fontFamily: 'iconfont')));
73+
}
74+
try {
75+
String path = Uri.parse(this.url).path;
76+
String suffix = extension(path).replaceFirst('.', '');
77+
var imageSuffixs = ['png', 'bmp', 'jpeg', 'gif', 'jpg'];
78+
if (imageSuffixs.contains(suffix)) {
79+
return SizedBox(
80+
height: 50,
81+
width: 50,
82+
child: Card(
83+
clipBehavior: Clip.antiAlias,
84+
shape: RoundedRectangleBorder(
85+
borderRadius: BorderRadiusDirectional.circular(2)),
86+
child: CachedNetworkImage(
87+
imageUrl: this.url,
88+
fit: BoxFit.cover,
89+
placeholder: (context, url) => Center(
90+
child: Container(
91+
width: 10,
92+
height: 10,
93+
child: CircularProgressIndicator(
94+
strokeWidth: 3,
95+
),
96+
),
97+
),
98+
errorWidget: (context, url, error) {
99+
return Container(
100+
color: Colors.grey,
101+
child: Center(
102+
child: Column(
103+
mainAxisAlignment: MainAxisAlignment.center,
104+
children: <Widget>[
105+
Icon(
106+
Icons.error,
107+
size: 12,
108+
),
109+
SizedBox(height: 2),
110+
Text(
111+
'加载失败',
112+
style: TextStyle(fontSize: 8),
113+
)
114+
],
115+
),
116+
),
117+
);
118+
},
119+
),
120+
),
121+
);
122+
} else {
123+
return buildCenterIcon(Icon(IconData(0xe654, fontFamily: 'iconfont')));
124+
}
125+
} catch (e) {
126+
return buildCenterIcon(Icon(IconData(0xe654, fontFamily: 'iconfont')));
127+
}
128+
}
129+
130+
Widget buildCenterIcon(Icon icon) {
131+
return SizedBox(
132+
height: 50,
133+
width: 50,
134+
child: Center(
135+
child: icon,
136+
),
137+
);
138+
}
139+
}
140+
141+
/// 文件类型
142+
enum FileContentType {
143+
/// 文件
144+
FILE,
145+
146+
/// 文件夹
147+
DIR,
148+
}

lib/model/gitee_content.dart

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import 'package:flutter_picgo/components/manage_item.dart';
2+
13
class GiteeContent {
2-
GiteeContentType type;
4+
FileContentType type;
35
int size;
46
String name;
57
String path;
@@ -19,8 +21,7 @@ class GiteeContent {
1921
this.downloadUrl});
2022

2123
GiteeContent.fromJson(Map<String, dynamic> json) {
22-
type =
23-
json['type'] == 'file' ? GiteeContentType.FILE : GiteeContentType.DIR;
24+
type = json['type'] == 'file' ? FileContentType.FILE : FileContentType.DIR;
2425
size = json['size'];
2526
name = json['name'];
2627
path = json['path'];
@@ -32,7 +33,7 @@ class GiteeContent {
3233

3334
Map<String, dynamic> toJson() {
3435
final Map<String, dynamic> data = new Map<String, dynamic>();
35-
data['type'] = this.type == GiteeContentType.FILE ? 'file' : 'dir';
36+
data['type'] = this.type == FileContentType.FILE ? 'file' : 'dir';
3637
data['size'] = this.size;
3738
data['name'] = this.name;
3839
data['path'] = this.path;
@@ -43,12 +44,3 @@ class GiteeContent {
4344
return data;
4445
}
4546
}
46-
47-
/// 文件类型
48-
enum GiteeContentType {
49-
/// 文件
50-
FILE,
51-
52-
/// 文件夹
53-
DIR,
54-
}

lib/model/github_content.dart

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import 'package:flutter_picgo/components/manage_item.dart';
2+
13
class GithubContent {
2-
GithubContentType type;
4+
FileContentType type;
35
String encoding;
46
int size;
57
String name;
@@ -26,7 +28,7 @@ class GithubContent {
2628
});
2729

2830
GithubContent.fromJson(Map<String, dynamic> json) {
29-
type = json['type'] == 'file' ? GithubContentType.FILE : GithubContentType.DIR;
31+
type = json['type'] == 'file' ? FileContentType.FILE : FileContentType.DIR;
3032
encoding = json['encoding'];
3133
size = json['size'];
3234
name = json['name'];
@@ -41,7 +43,7 @@ class GithubContent {
4143

4244
Map<String, dynamic> toJson() {
4345
final Map<String, dynamic> data = new Map<String, dynamic>();
44-
data['type'] = this.type == GithubContentType.FILE ? 'file' : 'dir';
46+
data['type'] = this.type == FileContentType.FILE ? 'file' : 'dir';
4547
data['encoding'] = this.encoding;
4648
data['size'] = this.size;
4749
data['name'] = this.name;
@@ -55,12 +57,3 @@ class GithubContent {
5557
return data;
5658
}
5759
}
58-
59-
/// 文件类型
60-
enum GithubContentType {
61-
/// 文件
62-
FILE,
63-
64-
/// 文件夹
65-
DIR,
66-
}

0 commit comments

Comments
 (0)