Skip to content

Commit

Permalink
chore(example): Update example for close app
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Mar 31, 2024
1 parent ef26b7f commit e315bda
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 56 deletions.
57 changes: 29 additions & 28 deletions README-ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

这个插件允许 Flutter **桌面** 应用自动更新自己 (基于 [sparkle](https://sparkle-project.org/)[winsparkle](https://winsparkle.com))。

<img src="screenshots/sparkle.png" width="732" alt="">
<img src="https://raw.githubusercontent.com/leanflutter/auto_updater/main/screenshots/sparkle.png" width="732" alt="">

---

Expand All @@ -20,33 +20,34 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [平台支持](#%E5%B9%B3%E5%8F%B0%E6%94%AF%E6%8C%81)
- [快速开始](#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)
- [安装](#%E5%AE%89%E8%A3%85)
- [⚠️ Windows requirements](#-windows-requirements)
- [用法](#%E7%94%A8%E6%B3%95)
- [发布你的应用](#%E5%8F%91%E5%B8%83%E4%BD%A0%E7%9A%84%E5%BA%94%E7%94%A8)
- [生成私钥](#%E7%94%9F%E6%88%90%E7%A7%81%E9%92%A5)
- [macOS](#macos)
- [Windows](#windows)
- [打包应用](#%E6%89%93%E5%8C%85%E5%BA%94%E7%94%A8)
- [macOS](#macos-1)
- [Windows](#windows-1)
- [获取签名](#%E8%8E%B7%E5%8F%96%E7%AD%BE%E5%90%8D)
- [macOS](#macos-2)
- [Windows](#windows-2)
- [分发应用](#%E5%88%86%E5%8F%91%E5%BA%94%E7%94%A8)
- [故障排除](#%E6%95%85%E9%9A%9C%E6%8E%92%E9%99%A4)
- [macOS](#macos-3)
- [谁在用使用它?](#%E8%B0%81%E5%9C%A8%E7%94%A8%E4%BD%BF%E7%94%A8%E5%AE%83)
- [API](#api)
- [AutoUpdater](#autoupdater)
- [Methods](#methods)
- [setFeedURL](#setfeedurl)
- [checkForUpdates](#checkforupdates)
- [setScheduledCheckInterval](#setscheduledcheckinterval)
- [相关链接](#%E7%9B%B8%E5%85%B3%E9%93%BE%E6%8E%A5)
- [许可证](#%E8%AE%B8%E5%8F%AF%E8%AF%81)
- [auto\_updater](#auto_updater)
- [平台支持](#平台支持)
- [快速开始](#快速开始)
- [安装](#安装)
- [⚠️ Windows requirements](#️-windows-requirements)
- [用法](#用法)
- [发布你的应用](#发布你的应用)
- [生成私钥](#生成私钥)
- [macOS](#macos)
- [Windows](#windows)
- [打包应用](#打包应用)
- [macOS](#macos-1)
- [Windows](#windows-1)
- [获取签名](#获取签名)
- [macOS](#macos-2)
- [Windows](#windows-2)
- [分发应用](#分发应用)
- [故障排除](#故障排除)
- [macOS](#macos-3)
- [谁在用使用它?](#谁在用使用它)
- [API](#api)
- [AutoUpdater](#autoupdater)
- [Methods](#methods)
- [setFeedURL](#setfeedurl)
- [checkForUpdates](#checkforupdates)
- [setScheduledCheckInterval](#setscheduledcheckinterval)
- [相关链接](#相关链接)
- [许可证](#许可证)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down
57 changes: 29 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

This plugin allows Flutter **desktop** apps to automatically update themselves (based on [sparkle](https://sparkle-project.org/) and [winsparkle](https://winsparkle.com)).

<img src="screenshots/sparkle.png" width="732" alt="">
<img src="https://raw.githubusercontent.com/leanflutter/auto_updater/main/screenshots/sparkle.png" width="732" alt="">

---

Expand All @@ -20,33 +20,34 @@ English | [简体中文](./README-ZH.md)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Platform Support](#platform-support)
- [Quick Start](#quick-start)
- [Installation](#installation)
- [⚠️ Windows requirements](#-windows-requirements)
- [Usage](#usage)
- [Publish your app](#publish-your-app)
- [Generate private key](#generate-private-key)
- [macOS](#macos)
- [Windows](#windows)
- [Packaging](#packaging)
- [macOS](#macos-1)
- [Windows](#windows-1)
- [Get signature](#get-signature)
- [macOS](#macos-2)
- [Windows](#windows-2)
- [Distributing](#distributing)
- [Troubleshooting](#troubleshooting)
- [macOS](#macos-3)
- [Who's using it?](#whos-using-it)
- [API](#api)
- [AutoUpdater](#autoupdater)
- [Methods](#methods)
- [setFeedURL](#setfeedurl)
- [checkForUpdates](#checkforupdates)
- [setScheduledCheckInterval](#setscheduledcheckinterval)
- [Related Links](#related-links)
- [License](#license)
- [auto\_updater](#auto_updater)
- [Platform Support](#platform-support)
- [Quick Start](#quick-start)
- [Installation](#installation)
- [⚠️ Windows requirements](#️-windows-requirements)
- [Usage](#usage)
- [Publish your app](#publish-your-app)
- [Generate private key](#generate-private-key)
- [macOS](#macos)
- [Windows](#windows)
- [Packaging](#packaging)
- [macOS](#macos-1)
- [Windows](#windows-1)
- [Get signature](#get-signature)
- [macOS](#macos-2)
- [Windows](#windows-2)
- [Distributing](#distributing)
- [Troubleshooting](#troubleshooting)
- [macOS](#macos-3)
- [Who's using it?](#whos-using-it)
- [API](#api)
- [AutoUpdater](#autoupdater)
- [Methods](#methods)
- [setFeedURL](#setfeedurl)
- [checkForUpdates](#checkforupdates)
- [setScheduledCheckInterval](#setscheduledcheckinterval)
- [Related Links](#related-links)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down
1 change: 1 addition & 0 deletions packages/auto_updater/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ void main() async {
await windowManager.ensureInitialized();

windowManager.waitUntilReadyToShow(null, () async {
await windowManager.setPreventClose(true);
await windowManager.show();
await windowManager.focus();
});
Expand Down
2 changes: 2 additions & 0 deletions packages/auto_updater/example/lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:preference_list/preference_list.dart';
import 'package:window_manager/window_manager.dart';

class HomePage extends StatefulWidget {
const HomePage({super.key});
Expand Down Expand Up @@ -136,5 +137,6 @@ class _HomePageState extends State<HomePage> with UpdaterListener {
if (kDebugMode) {
print('onUpdaterBeforeQuitForUpdate: ${item?.toJson()}');
}
windowManager.setPreventClose(false);
}
}
6 changes: 6 additions & 0 deletions packages/auto_updater/example/windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"auto_updater_example");
if (hwnd != NULL) {
::ShowWindow(hwnd, SW_NORMAL);
::SetForegroundWindow(hwnd);
return EXIT_FAILURE;
}
// Attach to console when present (e.g., 'flutter run') or create a
// new console when running with a debugger.
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
Expand Down

0 comments on commit e315bda

Please sign in to comment.