2021-09-29 23:57:09 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:pikapi/basic/Method.dart';
|
|
|
|
|
|
|
|
late String _autoCleanSec;
|
|
|
|
|
|
|
|
Future<dynamic> autoClean() async {
|
2021-10-13 13:57:35 +00:00
|
|
|
_autoCleanSec =
|
|
|
|
await method.loadProperty("autoCleanSec", "${3600 * 24 * 30}");
|
|
|
|
if ("0" != _autoCleanSec) {
|
|
|
|
await method.autoClean(_autoCleanSec);
|
|
|
|
}
|
2021-09-29 23:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var _autoCleanMap = {
|
|
|
|
"一个月前": "${3600 * 24 * 30}",
|
|
|
|
"一周前": "${3600 * 24 * 7}",
|
|
|
|
"一天前": "${3600 * 24 * 1}",
|
2021-10-13 13:57:35 +00:00
|
|
|
"不自动清理": "${0}",
|
2021-09-29 23:57:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
String currentAutoCleanSec() {
|
|
|
|
for (var value in _autoCleanMap.entries) {
|
|
|
|
if (value.value == _autoCleanSec) {
|
|
|
|
return value.key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> chooseAutoCleanSec(BuildContext context) async {
|
|
|
|
String? choose = await showDialog<String>(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return SimpleDialog(
|
2021-10-13 13:57:35 +00:00
|
|
|
title: Text('选择自动清理周期'),
|
2021-09-29 23:57:09 +00:00
|
|
|
children: <Widget>[
|
|
|
|
..._autoCleanMap.entries.map(
|
|
|
|
(e) => SimpleDialogOption(
|
|
|
|
child: Text(e.key),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop(e.value);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
if (choose != null) {
|
|
|
|
await method.saveProperty("autoCleanSec", choose);
|
|
|
|
_autoCleanSec = choose;
|
|
|
|
}
|
|
|
|
}
|