Skip to content

Commit

Permalink
修复桌面微件更新偶尔不生效
Browse files Browse the repository at this point in the history
  • Loading branch information
nano71 committed Nov 13, 2024
1 parent e76ca62 commit 36b7e3b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .idea/runConfigurations/build.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/runConfigurations/run.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions lib/pages/layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,12 @@ class _LayoutState extends State<Layout> {

Future<void> updateAppwidget() async {
print('updateAppwidget');
await Workmanager().cancelAll();
await Workmanager().cancelByUniqueName("com.nano71.glutassistantn.updateHomeWidget");
bool isAdded = await HomeWidgetUtils.isWidgetAdded();

if (isAdded) {
print("桌面微件已经添加");
HomeWidgetUtils.updateWidgetContent();
Workmanager().registerPeriodicTask("task-identifier", "simpleTask", initialDelay: Duration(minutes: 15));
Workmanager().registerPeriodicTask("com.nano71.glutassistantn.updateHomeWidget", "updateHomeWidget", initialDelay: Duration(seconds: 0));
HomeWidget.registerInteractivityCallback(backgroundCallback);
} else {
print("桌面微件尚未添加");
Expand Down

0 comments on commit 36b7e3b

Please sign in to comment.