Skip to content

Commit 7cd6662

Browse files
committed
app: compress form fix
server: move task fix
1 parent d0f11ac commit 7cd6662

File tree

3 files changed

+44
-10
lines changed

3 files changed

+44
-10
lines changed

README.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
** 功能
2020
- 支持文件列表查看/复制/移动/删除/重命名/上传/下载
21+
- 支持桌面端拖拽上传(仅文件,不支持文件夹)
2122
- 支持文件多选及操作
2223
- 支持回收站
2324
- 支持视频、音频、图片和文本文件的预览

app/lib/api/file/widgets/repo/base.dart

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ extension CompressLevelExtension on CompressLevel {
2121
};
2222
return labels[this] ?? "unknown";
2323
}
24+
25+
int value() {
26+
final Map<CompressLevel, int> values = {
27+
CompressLevel.normal: -1,
28+
CompressLevel.best: 9,
29+
CompressLevel.fast: 1,
30+
};
31+
return values[this] ?? -1;
32+
}
2433
}
2534

2635
class BaseForm extends StatefulWidget {
@@ -110,6 +119,7 @@ class _BaseFormState extends State<BaseForm> {
110119
),
111120
ListTile(
112121
title: Text('文件加密'.tr()),
122+
subtitle: Text("文件加密创建后不可更改加密配置".tr()),
113123
trailing: Switch(
114124
value: _option["encrypt"] ?? false,
115125
onChanged: (result) {
@@ -142,6 +152,21 @@ class _BaseFormState extends State<BaseForm> {
142152
},
143153
),
144154
if (_option["encrypt"] ?? false)
155+
CustomFormField(
156+
type: CustomFormFieldType.password,
157+
label: "文件密码加密".tr(),
158+
value: _encryptOption["password_salt"],
159+
subtitle: Text("类似二次密码".tr()),
160+
onTap: (result) {
161+
setState(() {
162+
_encryptOption["password_salt"] = result;
163+
_option["encrypt_option"] = _encryptOption;
164+
});
165+
166+
widget.form.option = jsonEncode(_option);
167+
},
168+
),
169+
if (_option["encrypt"] ?? false)
145170
CustomFormField(
146171
label: "文件后缀".tr(),
147172
value: _encryptOption["suffix"],
@@ -186,6 +211,7 @@ class _BaseFormState extends State<BaseForm> {
186211
),
187212
ListTile(
188213
title: Text('文件压缩'.tr()),
214+
subtitle: Text("文件压缩创建后不可更改压缩配置".tr()),
189215
trailing: Switch(
190216
value: _option["compress"] ?? false,
191217
onChanged: (result) {
@@ -205,22 +231,16 @@ class _BaseFormState extends State<BaseForm> {
205231
if (_option["compress"] ?? false)
206232
CustomFormField(
207233
label: "压缩水平".tr(),
208-
value: _compressOption["level"],
234+
value: _compressValue(_compressOption['level']),
209235
type: CustomFormFieldType.option,
210236
options: CompressLevel.values.map((v) {
211237
return CustomFormFieldOption(label: v.label(), value: v.name);
212238
}).toList(),
213239
isRequired: true,
214240
onTap: (result) {
215241
setState(() {
216-
switch (result) {
217-
case "fast":
218-
_compressOption["level"] = 1;
219-
case "best":
220-
_compressOption["level"] = 9;
221-
default:
222-
_compressOption["level"] = -1;
223-
}
242+
_compressOption["level"] =
243+
CompressLevel.values.byName(result).value();
224244
_option["compress_option"] = _compressOption;
225245
});
226246

@@ -231,4 +251,17 @@ class _BaseFormState extends State<BaseForm> {
231251
),
232252
);
233253
}
254+
255+
String? _compressValue(int? value) {
256+
if (value == null) {
257+
return null;
258+
}
259+
if (value == 1) {
260+
return CompressLevel.fast.name;
261+
}
262+
if (value == 9) {
263+
return CompressLevel.best.name;
264+
}
265+
return CompressLevel.normal.name;
266+
}
234267
}

server/internal/api/file/fs/move.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (opt *MoveTaskOption) Execute(task runner.Task, fs FS) error {
3232
}
3333

3434
if srcFS == dstFS {
35-
return srcFS.Copy(task.Context(), srcPath, dstPath)
35+
return srcFS.Move(task.Context(), srcPath, dstPath)
3636
}
3737
return move(task, srcFS, srcPath, dstFS, dstPath)
3838
}

0 commit comments

Comments
 (0)