🎉 搭完基本框架
This commit is contained in:
		
							
								
								
									
										35
									
								
								build/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								build/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
# Build Directory
 | 
			
		||||
 | 
			
		||||
The build directory is used to house all the build files and assets for your application. 
 | 
			
		||||
 | 
			
		||||
The structure is:
 | 
			
		||||
 | 
			
		||||
* bin - Output directory
 | 
			
		||||
* darwin - macOS specific files
 | 
			
		||||
* windows - Windows specific files
 | 
			
		||||
 | 
			
		||||
## Mac
 | 
			
		||||
 | 
			
		||||
The `darwin` directory holds files specific to Mac builds.
 | 
			
		||||
These may be customised and used as part of the build. To return these files to the default state, simply delete them
 | 
			
		||||
and
 | 
			
		||||
build with `wails build`.
 | 
			
		||||
 | 
			
		||||
The directory contains the following files:
 | 
			
		||||
 | 
			
		||||
- `Info.plist` - the main plist file used for Mac builds. It is used when building using `wails build`.
 | 
			
		||||
- `Info.dev.plist` - same as the main plist file but used when building using `wails dev`.
 | 
			
		||||
 | 
			
		||||
## Windows
 | 
			
		||||
 | 
			
		||||
The `windows` directory contains the manifest and rc files used when building with `wails build`.
 | 
			
		||||
These may be customised for your application. To return these files to the default state, simply delete them and
 | 
			
		||||
build with `wails build`.
 | 
			
		||||
 | 
			
		||||
- `icon.ico` - The icon used for the application. This is used when building using `wails build`. If you wish to
 | 
			
		||||
  use a different icon, simply replace this file with your own. If it is missing, a new `icon.ico` file
 | 
			
		||||
  will be created using the `appicon.png` file in the build directory.
 | 
			
		||||
- `installer/*` - The files used to create the Windows installer. These are used when building using `wails build`.
 | 
			
		||||
- `info.json` - Application details used for Windows builds. The data here will be used by the Windows installer,
 | 
			
		||||
  as well as the application itself (right click the exe -> properties -> details)
 | 
			
		||||
- `wails.exe.manifest` - The main application manifest file.
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								build/appicon.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/appicon.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 130 KiB  | 
							
								
								
									
										68
									
								
								build/darwin/Info.dev.plist
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								build/darwin/Info.dev.plist
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
			
		||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 | 
			
		||||
<plist version="1.0">
 | 
			
		||||
    <dict>
 | 
			
		||||
        <key>CFBundlePackageType</key>
 | 
			
		||||
        <string>APPL</string>
 | 
			
		||||
        <key>CFBundleName</key>
 | 
			
		||||
        <string>{{.Info.ProductName}}</string>
 | 
			
		||||
        <key>CFBundleExecutable</key>
 | 
			
		||||
        <string>{{.Name}}</string>
 | 
			
		||||
        <key>CFBundleIdentifier</key>
 | 
			
		||||
        <string>com.wails.{{.Name}}</string>
 | 
			
		||||
        <key>CFBundleVersion</key>
 | 
			
		||||
        <string>{{.Info.ProductVersion}}</string>
 | 
			
		||||
        <key>CFBundleGetInfoString</key>
 | 
			
		||||
        <string>{{.Info.Comments}}</string>
 | 
			
		||||
        <key>CFBundleShortVersionString</key>
 | 
			
		||||
        <string>{{.Info.ProductVersion}}</string>
 | 
			
		||||
        <key>CFBundleIconFile</key>
 | 
			
		||||
        <string>iconfile</string>
 | 
			
		||||
        <key>LSMinimumSystemVersion</key>
 | 
			
		||||
        <string>10.13.0</string>
 | 
			
		||||
        <key>NSHighResolutionCapable</key>
 | 
			
		||||
        <string>true</string>
 | 
			
		||||
        <key>NSHumanReadableCopyright</key>
 | 
			
		||||
        <string>{{.Info.Copyright}}</string>
 | 
			
		||||
        {{if .Info.FileAssociations}}
 | 
			
		||||
        <key>CFBundleDocumentTypes</key>
 | 
			
		||||
        <array>
 | 
			
		||||
          {{range .Info.FileAssociations}}
 | 
			
		||||
          <dict>
 | 
			
		||||
            <key>CFBundleTypeExtensions</key>
 | 
			
		||||
            <array>
 | 
			
		||||
              <string>{{.Ext}}</string>
 | 
			
		||||
            </array>
 | 
			
		||||
            <key>CFBundleTypeName</key>
 | 
			
		||||
            <string>{{.Name}}</string>
 | 
			
		||||
            <key>CFBundleTypeRole</key>
 | 
			
		||||
            <string>{{.Role}}</string>
 | 
			
		||||
            <key>CFBundleTypeIconFile</key>
 | 
			
		||||
            <string>{{.IconName}}</string>
 | 
			
		||||
          </dict>
 | 
			
		||||
          {{end}}
 | 
			
		||||
        </array>
 | 
			
		||||
        {{end}}
 | 
			
		||||
        {{if .Info.Protocols}}
 | 
			
		||||
        <key>CFBundleURLTypes</key>
 | 
			
		||||
        <array>
 | 
			
		||||
          {{range .Info.Protocols}}
 | 
			
		||||
            <dict>
 | 
			
		||||
                <key>CFBundleURLName</key>
 | 
			
		||||
                <string>com.wails.{{.Scheme}}</string>
 | 
			
		||||
                <key>CFBundleURLSchemes</key>
 | 
			
		||||
                <array>
 | 
			
		||||
                    <string>{{.Scheme}}</string>
 | 
			
		||||
                </array>
 | 
			
		||||
                <key>CFBundleTypeRole</key>
 | 
			
		||||
                <string>{{.Role}}</string>
 | 
			
		||||
            </dict>
 | 
			
		||||
          {{end}}
 | 
			
		||||
        </array>
 | 
			
		||||
        {{end}}
 | 
			
		||||
        <key>NSAppTransportSecurity</key>
 | 
			
		||||
        <dict>
 | 
			
		||||
            <key>NSAllowsLocalNetworking</key>
 | 
			
		||||
            <true/>
 | 
			
		||||
        </dict>
 | 
			
		||||
    </dict>
 | 
			
		||||
</plist>
 | 
			
		||||
							
								
								
									
										63
									
								
								build/darwin/Info.plist
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								build/darwin/Info.plist
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 | 
			
		||||
<plist version="1.0">
 | 
			
		||||
    <dict>
 | 
			
		||||
        <key>CFBundlePackageType</key>
 | 
			
		||||
        <string>APPL</string>
 | 
			
		||||
        <key>CFBundleName</key>
 | 
			
		||||
        <string>{{.Info.ProductName}}</string>
 | 
			
		||||
        <key>CFBundleExecutable</key>
 | 
			
		||||
        <string>{{.Name}}</string>
 | 
			
		||||
        <key>CFBundleIdentifier</key>
 | 
			
		||||
        <string>com.wails.{{.Name}}</string>
 | 
			
		||||
        <key>CFBundleVersion</key>
 | 
			
		||||
        <string>{{.Info.ProductVersion}}</string>
 | 
			
		||||
        <key>CFBundleGetInfoString</key>
 | 
			
		||||
        <string>{{.Info.Comments}}</string>
 | 
			
		||||
        <key>CFBundleShortVersionString</key>
 | 
			
		||||
        <string>{{.Info.ProductVersion}}</string>
 | 
			
		||||
        <key>CFBundleIconFile</key>
 | 
			
		||||
        <string>iconfile</string>
 | 
			
		||||
        <key>LSMinimumSystemVersion</key>
 | 
			
		||||
        <string>10.13.0</string>
 | 
			
		||||
        <key>NSHighResolutionCapable</key>
 | 
			
		||||
        <string>true</string>
 | 
			
		||||
        <key>NSHumanReadableCopyright</key>
 | 
			
		||||
        <string>{{.Info.Copyright}}</string>
 | 
			
		||||
        {{if .Info.FileAssociations}}
 | 
			
		||||
        <key>CFBundleDocumentTypes</key>
 | 
			
		||||
        <array>
 | 
			
		||||
          {{range .Info.FileAssociations}}
 | 
			
		||||
          <dict>
 | 
			
		||||
            <key>CFBundleTypeExtensions</key>
 | 
			
		||||
            <array>
 | 
			
		||||
              <string>{{.Ext}}</string>
 | 
			
		||||
            </array>
 | 
			
		||||
            <key>CFBundleTypeName</key>
 | 
			
		||||
            <string>{{.Name}}</string>
 | 
			
		||||
            <key>CFBundleTypeRole</key>
 | 
			
		||||
            <string>{{.Role}}</string>
 | 
			
		||||
            <key>CFBundleTypeIconFile</key>
 | 
			
		||||
            <string>{{.IconName}}</string>
 | 
			
		||||
          </dict>
 | 
			
		||||
          {{end}}
 | 
			
		||||
        </array>
 | 
			
		||||
        {{end}}
 | 
			
		||||
        {{if .Info.Protocols}}
 | 
			
		||||
        <key>CFBundleURLTypes</key>
 | 
			
		||||
        <array>
 | 
			
		||||
          {{range .Info.Protocols}}
 | 
			
		||||
            <dict>
 | 
			
		||||
                <key>CFBundleURLName</key>
 | 
			
		||||
                <string>com.wails.{{.Scheme}}</string>
 | 
			
		||||
                <key>CFBundleURLSchemes</key>
 | 
			
		||||
                <array>
 | 
			
		||||
                    <string>{{.Scheme}}</string>
 | 
			
		||||
                </array>
 | 
			
		||||
                <key>CFBundleTypeRole</key>
 | 
			
		||||
                <string>{{.Role}}</string>
 | 
			
		||||
            </dict>
 | 
			
		||||
          {{end}}
 | 
			
		||||
        </array>
 | 
			
		||||
        {{end}}
 | 
			
		||||
    </dict>
 | 
			
		||||
</plist>
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								build/windows/icon.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build/windows/icon.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 20 KiB  | 
							
								
								
									
										15
									
								
								build/windows/info.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								build/windows/info.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
{
 | 
			
		||||
	"fixed": {
 | 
			
		||||
		"file_version": "{{.Info.ProductVersion}}"
 | 
			
		||||
	},
 | 
			
		||||
	"info": {
 | 
			
		||||
		"0000": {
 | 
			
		||||
			"ProductVersion": "{{.Info.ProductVersion}}",
 | 
			
		||||
			"CompanyName": "{{.Info.CompanyName}}",
 | 
			
		||||
			"FileDescription": "{{.Info.ProductName}}",
 | 
			
		||||
			"LegalCopyright": "{{.Info.Copyright}}",
 | 
			
		||||
			"ProductName": "{{.Info.ProductName}}",
 | 
			
		||||
			"Comments": "{{.Info.Comments}}"
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										114
									
								
								build/windows/installer/project.nsi
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								build/windows/installer/project.nsi
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,114 @@
 | 
			
		||||
Unicode true
 | 
			
		||||
 | 
			
		||||
####
 | 
			
		||||
## Please note: Template replacements don't work in this file. They are provided with default defines like
 | 
			
		||||
## mentioned underneath.
 | 
			
		||||
## If the keyword is not defined, "wails_tools.nsh" will populate them with the values from ProjectInfo.
 | 
			
		||||
## If they are defined here, "wails_tools.nsh" will not touch them. This allows to use this project.nsi manually
 | 
			
		||||
## from outside of Wails for debugging and development of the installer.
 | 
			
		||||
##
 | 
			
		||||
## For development first make a wails nsis build to populate the "wails_tools.nsh":
 | 
			
		||||
## > wails build --target windows/amd64 --nsis
 | 
			
		||||
## Then you can call makensis on this file with specifying the path to your binary:
 | 
			
		||||
## For a AMD64 only installer:
 | 
			
		||||
## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app.exe
 | 
			
		||||
## For a ARM64 only installer:
 | 
			
		||||
## > makensis -DARG_WAILS_ARM64_BINARY=..\..\bin\app.exe
 | 
			
		||||
## For a installer with both architectures:
 | 
			
		||||
## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app-amd64.exe -DARG_WAILS_ARM64_BINARY=..\..\bin\app-arm64.exe
 | 
			
		||||
####
 | 
			
		||||
## The following information is taken from the ProjectInfo file, but they can be overwritten here.
 | 
			
		||||
####
 | 
			
		||||
## !define INFO_PROJECTNAME    "MyProject" # Default "{{.Name}}"
 | 
			
		||||
## !define INFO_COMPANYNAME    "MyCompany" # Default "{{.Info.CompanyName}}"
 | 
			
		||||
## !define INFO_PRODUCTNAME    "MyProduct" # Default "{{.Info.ProductName}}"
 | 
			
		||||
## !define INFO_PRODUCTVERSION "1.0.0"     # Default "{{.Info.ProductVersion}}"
 | 
			
		||||
## !define INFO_COPYRIGHT      "Copyright" # Default "{{.Info.Copyright}}"
 | 
			
		||||
###
 | 
			
		||||
## !define PRODUCT_EXECUTABLE  "Application.exe"      # Default "${INFO_PROJECTNAME}.exe"
 | 
			
		||||
## !define UNINST_KEY_NAME     "UninstKeyInRegistry"  # Default "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}"
 | 
			
		||||
####
 | 
			
		||||
## !define REQUEST_EXECUTION_LEVEL "admin"            # Default "admin"  see also https://nsis.sourceforge.io/Docs/Chapter4.html
 | 
			
		||||
####
 | 
			
		||||
## Include the wails tools
 | 
			
		||||
####
 | 
			
		||||
!include "wails_tools.nsh"
 | 
			
		||||
 | 
			
		||||
# The version information for this two must consist of 4 parts
 | 
			
		||||
VIProductVersion "${INFO_PRODUCTVERSION}.0"
 | 
			
		||||
VIFileVersion    "${INFO_PRODUCTVERSION}.0"
 | 
			
		||||
 | 
			
		||||
VIAddVersionKey "CompanyName"     "${INFO_COMPANYNAME}"
 | 
			
		||||
VIAddVersionKey "FileDescription" "${INFO_PRODUCTNAME} Installer"
 | 
			
		||||
VIAddVersionKey "ProductVersion"  "${INFO_PRODUCTVERSION}"
 | 
			
		||||
VIAddVersionKey "FileVersion"     "${INFO_PRODUCTVERSION}"
 | 
			
		||||
VIAddVersionKey "LegalCopyright"  "${INFO_COPYRIGHT}"
 | 
			
		||||
VIAddVersionKey "ProductName"     "${INFO_PRODUCTNAME}"
 | 
			
		||||
 | 
			
		||||
# Enable HiDPI support. https://nsis.sourceforge.io/Reference/ManifestDPIAware
 | 
			
		||||
ManifestDPIAware true
 | 
			
		||||
 | 
			
		||||
!include "MUI.nsh"
 | 
			
		||||
 | 
			
		||||
!define MUI_ICON "..\icon.ico"
 | 
			
		||||
!define MUI_UNICON "..\icon.ico"
 | 
			
		||||
# !define MUI_WELCOMEFINISHPAGE_BITMAP "resources\leftimage.bmp" #Include this to add a bitmap on the left side of the Welcome Page. Must be a size of 164x314
 | 
			
		||||
!define MUI_FINISHPAGE_NOAUTOCLOSE # Wait on the INSTFILES page so the user can take a look into the details of the installation steps
 | 
			
		||||
!define MUI_ABORTWARNING # This will warn the user if they exit from the installer.
 | 
			
		||||
 | 
			
		||||
!insertmacro MUI_PAGE_WELCOME # Welcome to the installer page.
 | 
			
		||||
# !insertmacro MUI_PAGE_LICENSE "resources\eula.txt" # Adds a EULA page to the installer
 | 
			
		||||
!insertmacro MUI_PAGE_DIRECTORY # In which folder install page.
 | 
			
		||||
!insertmacro MUI_PAGE_INSTFILES # Installing page.
 | 
			
		||||
!insertmacro MUI_PAGE_FINISH # Finished installation page.
 | 
			
		||||
 | 
			
		||||
!insertmacro MUI_UNPAGE_INSTFILES # Uinstalling page
 | 
			
		||||
 | 
			
		||||
!insertmacro MUI_LANGUAGE "English" # Set the Language of the installer
 | 
			
		||||
 | 
			
		||||
## The following two statements can be used to sign the installer and the uninstaller. The path to the binaries are provided in %1
 | 
			
		||||
#!uninstfinalize 'signtool --file "%1"'
 | 
			
		||||
#!finalize 'signtool --file "%1"'
 | 
			
		||||
 | 
			
		||||
Name "${INFO_PRODUCTNAME}"
 | 
			
		||||
OutFile "..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file.
 | 
			
		||||
InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}" # Default installing folder ($PROGRAMFILES is Program Files folder).
 | 
			
		||||
ShowInstDetails show # This will always show the installation details.
 | 
			
		||||
 | 
			
		||||
Function .onInit
 | 
			
		||||
   !insertmacro wails.checkArchitecture
 | 
			
		||||
FunctionEnd
 | 
			
		||||
 | 
			
		||||
Section
 | 
			
		||||
    !insertmacro wails.setShellContext
 | 
			
		||||
 | 
			
		||||
    !insertmacro wails.webview2runtime
 | 
			
		||||
 | 
			
		||||
    SetOutPath $INSTDIR
 | 
			
		||||
 | 
			
		||||
    !insertmacro wails.files
 | 
			
		||||
 | 
			
		||||
    CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
 | 
			
		||||
    CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}"
 | 
			
		||||
 | 
			
		||||
    !insertmacro wails.associateFiles
 | 
			
		||||
    !insertmacro wails.associateCustomProtocols
 | 
			
		||||
 | 
			
		||||
    !insertmacro wails.writeUninstaller
 | 
			
		||||
SectionEnd
 | 
			
		||||
 | 
			
		||||
Section "uninstall"
 | 
			
		||||
    !insertmacro wails.setShellContext
 | 
			
		||||
 | 
			
		||||
    RMDir /r "$AppData\${PRODUCT_EXECUTABLE}" # Remove the WebView2 DataPath
 | 
			
		||||
 | 
			
		||||
    RMDir /r $INSTDIR
 | 
			
		||||
 | 
			
		||||
    Delete "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk"
 | 
			
		||||
    Delete "$DESKTOP\${INFO_PRODUCTNAME}.lnk"
 | 
			
		||||
 | 
			
		||||
    !insertmacro wails.unassociateFiles
 | 
			
		||||
    !insertmacro wails.unassociateCustomProtocols
 | 
			
		||||
 | 
			
		||||
    !insertmacro wails.deleteUninstaller
 | 
			
		||||
SectionEnd
 | 
			
		||||
							
								
								
									
										249
									
								
								build/windows/installer/wails_tools.nsh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										249
									
								
								build/windows/installer/wails_tools.nsh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,249 @@
 | 
			
		||||
# DO NOT EDIT - Generated automatically by `wails build`
 | 
			
		||||
 | 
			
		||||
!include "x64.nsh"
 | 
			
		||||
!include "WinVer.nsh"
 | 
			
		||||
!include "FileFunc.nsh"
 | 
			
		||||
 | 
			
		||||
!ifndef INFO_PROJECTNAME
 | 
			
		||||
    !define INFO_PROJECTNAME "{{.Name}}"
 | 
			
		||||
!endif
 | 
			
		||||
!ifndef INFO_COMPANYNAME
 | 
			
		||||
    !define INFO_COMPANYNAME "{{.Info.CompanyName}}"
 | 
			
		||||
!endif
 | 
			
		||||
!ifndef INFO_PRODUCTNAME
 | 
			
		||||
    !define INFO_PRODUCTNAME "{{.Info.ProductName}}"
 | 
			
		||||
!endif
 | 
			
		||||
!ifndef INFO_PRODUCTVERSION
 | 
			
		||||
    !define INFO_PRODUCTVERSION "{{.Info.ProductVersion}}"
 | 
			
		||||
!endif
 | 
			
		||||
!ifndef INFO_COPYRIGHT
 | 
			
		||||
    !define INFO_COPYRIGHT "{{.Info.Copyright}}"
 | 
			
		||||
!endif
 | 
			
		||||
!ifndef PRODUCT_EXECUTABLE
 | 
			
		||||
    !define PRODUCT_EXECUTABLE "${INFO_PROJECTNAME}.exe"
 | 
			
		||||
!endif
 | 
			
		||||
!ifndef UNINST_KEY_NAME
 | 
			
		||||
    !define UNINST_KEY_NAME "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}"
 | 
			
		||||
!endif
 | 
			
		||||
!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINST_KEY_NAME}"
 | 
			
		||||
 | 
			
		||||
!ifndef REQUEST_EXECUTION_LEVEL
 | 
			
		||||
    !define REQUEST_EXECUTION_LEVEL "admin"
 | 
			
		||||
!endif
 | 
			
		||||
 | 
			
		||||
RequestExecutionLevel "${REQUEST_EXECUTION_LEVEL}"
 | 
			
		||||
 | 
			
		||||
!ifdef ARG_WAILS_AMD64_BINARY
 | 
			
		||||
    !define SUPPORTS_AMD64
 | 
			
		||||
!endif
 | 
			
		||||
 | 
			
		||||
!ifdef ARG_WAILS_ARM64_BINARY
 | 
			
		||||
    !define SUPPORTS_ARM64
 | 
			
		||||
!endif
 | 
			
		||||
 | 
			
		||||
!ifdef SUPPORTS_AMD64
 | 
			
		||||
    !ifdef SUPPORTS_ARM64
 | 
			
		||||
        !define ARCH "amd64_arm64"
 | 
			
		||||
    !else
 | 
			
		||||
        !define ARCH "amd64"
 | 
			
		||||
    !endif
 | 
			
		||||
!else
 | 
			
		||||
    !ifdef SUPPORTS_ARM64
 | 
			
		||||
        !define ARCH "arm64"
 | 
			
		||||
    !else
 | 
			
		||||
        !error "Wails: Undefined ARCH, please provide at least one of ARG_WAILS_AMD64_BINARY or ARG_WAILS_ARM64_BINARY"
 | 
			
		||||
    !endif
 | 
			
		||||
!endif
 | 
			
		||||
 | 
			
		||||
!macro wails.checkArchitecture
 | 
			
		||||
    !ifndef WAILS_WIN10_REQUIRED
 | 
			
		||||
        !define WAILS_WIN10_REQUIRED "This product is only supported on Windows 10 (Server 2016) and later."
 | 
			
		||||
    !endif
 | 
			
		||||
 | 
			
		||||
    !ifndef WAILS_ARCHITECTURE_NOT_SUPPORTED
 | 
			
		||||
        !define WAILS_ARCHITECTURE_NOT_SUPPORTED "This product can't be installed on the current Windows architecture. Supports: ${ARCH}"
 | 
			
		||||
    !endif
 | 
			
		||||
 | 
			
		||||
    ${If} ${AtLeastWin10}
 | 
			
		||||
        !ifdef SUPPORTS_AMD64
 | 
			
		||||
            ${if} ${IsNativeAMD64}
 | 
			
		||||
                Goto ok
 | 
			
		||||
            ${EndIf}
 | 
			
		||||
        !endif
 | 
			
		||||
 | 
			
		||||
        !ifdef SUPPORTS_ARM64
 | 
			
		||||
            ${if} ${IsNativeARM64}
 | 
			
		||||
                Goto ok
 | 
			
		||||
            ${EndIf}
 | 
			
		||||
        !endif
 | 
			
		||||
 | 
			
		||||
        IfSilent silentArch notSilentArch
 | 
			
		||||
        silentArch:
 | 
			
		||||
            SetErrorLevel 65
 | 
			
		||||
            Abort
 | 
			
		||||
        notSilentArch:
 | 
			
		||||
            MessageBox MB_OK "${WAILS_ARCHITECTURE_NOT_SUPPORTED}"
 | 
			
		||||
            Quit
 | 
			
		||||
    ${else}
 | 
			
		||||
        IfSilent silentWin notSilentWin
 | 
			
		||||
        silentWin:
 | 
			
		||||
            SetErrorLevel 64
 | 
			
		||||
            Abort
 | 
			
		||||
        notSilentWin:
 | 
			
		||||
            MessageBox MB_OK "${WAILS_WIN10_REQUIRED}"
 | 
			
		||||
            Quit
 | 
			
		||||
    ${EndIf}
 | 
			
		||||
 | 
			
		||||
    ok:
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro wails.files
 | 
			
		||||
    !ifdef SUPPORTS_AMD64
 | 
			
		||||
        ${if} ${IsNativeAMD64}
 | 
			
		||||
            File "/oname=${PRODUCT_EXECUTABLE}" "${ARG_WAILS_AMD64_BINARY}"
 | 
			
		||||
        ${EndIf}
 | 
			
		||||
    !endif
 | 
			
		||||
 | 
			
		||||
    !ifdef SUPPORTS_ARM64
 | 
			
		||||
        ${if} ${IsNativeARM64}
 | 
			
		||||
            File "/oname=${PRODUCT_EXECUTABLE}" "${ARG_WAILS_ARM64_BINARY}"
 | 
			
		||||
        ${EndIf}
 | 
			
		||||
    !endif
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro wails.writeUninstaller
 | 
			
		||||
    WriteUninstaller "$INSTDIR\uninstall.exe"
 | 
			
		||||
 | 
			
		||||
    SetRegView 64
 | 
			
		||||
    WriteRegStr HKLM "${UNINST_KEY}" "Publisher" "${INFO_COMPANYNAME}"
 | 
			
		||||
    WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "${INFO_PRODUCTNAME}"
 | 
			
		||||
    WriteRegStr HKLM "${UNINST_KEY}" "DisplayVersion" "${INFO_PRODUCTVERSION}"
 | 
			
		||||
    WriteRegStr HKLM "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_EXECUTABLE}"
 | 
			
		||||
    WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
 | 
			
		||||
    WriteRegStr HKLM "${UNINST_KEY}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
 | 
			
		||||
 | 
			
		||||
    ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
 | 
			
		||||
    IntFmt $0 "0x%08X" $0
 | 
			
		||||
    WriteRegDWORD HKLM "${UNINST_KEY}" "EstimatedSize" "$0"
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro wails.deleteUninstaller
 | 
			
		||||
    Delete "$INSTDIR\uninstall.exe"
 | 
			
		||||
 | 
			
		||||
    SetRegView 64
 | 
			
		||||
    DeleteRegKey HKLM "${UNINST_KEY}"
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro wails.setShellContext
 | 
			
		||||
    ${If} ${REQUEST_EXECUTION_LEVEL} == "admin"
 | 
			
		||||
        SetShellVarContext all
 | 
			
		||||
    ${else}
 | 
			
		||||
        SetShellVarContext current
 | 
			
		||||
    ${EndIf}
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
# Install webview2 by launching the bootstrapper
 | 
			
		||||
# See https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#online-only-deployment
 | 
			
		||||
!macro wails.webview2runtime
 | 
			
		||||
    !ifndef WAILS_INSTALL_WEBVIEW_DETAILPRINT
 | 
			
		||||
        !define WAILS_INSTALL_WEBVIEW_DETAILPRINT "Installing: WebView2 Runtime"
 | 
			
		||||
    !endif
 | 
			
		||||
 | 
			
		||||
    SetRegView 64
 | 
			
		||||
	# If the admin key exists and is not empty then webview2 is already installed
 | 
			
		||||
	ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
 | 
			
		||||
    ${If} $0 != ""
 | 
			
		||||
        Goto ok
 | 
			
		||||
    ${EndIf}
 | 
			
		||||
 | 
			
		||||
    ${If} ${REQUEST_EXECUTION_LEVEL} == "user"
 | 
			
		||||
        # If the installer is run in user level, check the user specific key exists and is not empty then webview2 is already installed
 | 
			
		||||
	    ReadRegStr $0 HKCU "Software\Microsoft\EdgeUpdate\Clients{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
 | 
			
		||||
        ${If} $0 != ""
 | 
			
		||||
            Goto ok
 | 
			
		||||
        ${EndIf}
 | 
			
		||||
     ${EndIf}
 | 
			
		||||
 | 
			
		||||
	SetDetailsPrint both
 | 
			
		||||
    DetailPrint "${WAILS_INSTALL_WEBVIEW_DETAILPRINT}"
 | 
			
		||||
    SetDetailsPrint listonly
 | 
			
		||||
 | 
			
		||||
    InitPluginsDir
 | 
			
		||||
    CreateDirectory "$pluginsdir\webview2bootstrapper"
 | 
			
		||||
    SetOutPath "$pluginsdir\webview2bootstrapper"
 | 
			
		||||
    File "tmp\MicrosoftEdgeWebview2Setup.exe"
 | 
			
		||||
    ExecWait '"$pluginsdir\webview2bootstrapper\MicrosoftEdgeWebview2Setup.exe" /silent /install'
 | 
			
		||||
 | 
			
		||||
    SetDetailsPrint both
 | 
			
		||||
    ok:
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
# Copy of APP_ASSOCIATE and APP_UNASSOCIATE macros from here https://gist.github.com/nikku/281d0ef126dbc215dd58bfd5b3a5cd5b
 | 
			
		||||
!macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND
 | 
			
		||||
  ; Backup the previously associated file class
 | 
			
		||||
  ReadRegStr $R0 SHELL_CONTEXT "Software\Classes\.${EXT}" ""
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "${FILECLASS}_backup" "$R0"
 | 
			
		||||
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "" "${FILECLASS}"
 | 
			
		||||
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}" "" `${DESCRIPTION}`
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\DefaultIcon" "" `${ICON}`
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell" "" "open"
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell\open" "" `${COMMANDTEXT}`
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell\open\command" "" `${COMMAND}`
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro APP_UNASSOCIATE EXT FILECLASS
 | 
			
		||||
  ; Backup the previously associated file class
 | 
			
		||||
  ReadRegStr $R0 SHELL_CONTEXT "Software\Classes\.${EXT}" `${FILECLASS}_backup`
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "" "$R0"
 | 
			
		||||
 | 
			
		||||
  DeleteRegKey SHELL_CONTEXT `Software\Classes\${FILECLASS}`
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro wails.associateFiles
 | 
			
		||||
    ; Create file associations
 | 
			
		||||
    {{range .Info.FileAssociations}}
 | 
			
		||||
      !insertmacro APP_ASSOCIATE "{{.Ext}}" "{{.Name}}" "{{.Description}}" "$INSTDIR\{{.IconName}}.ico" "Open with ${INFO_PRODUCTNAME}" "$INSTDIR\${PRODUCT_EXECUTABLE} $\"%1$\""
 | 
			
		||||
 | 
			
		||||
      File "..\{{.IconName}}.ico"
 | 
			
		||||
    {{end}}
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro wails.unassociateFiles
 | 
			
		||||
    ; Delete app associations
 | 
			
		||||
    {{range .Info.FileAssociations}}
 | 
			
		||||
      !insertmacro APP_UNASSOCIATE "{{.Ext}}" "{{.Name}}"
 | 
			
		||||
 | 
			
		||||
      Delete "$INSTDIR\{{.IconName}}.ico"
 | 
			
		||||
    {{end}}
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro CUSTOM_PROTOCOL_ASSOCIATE PROTOCOL DESCRIPTION ICON COMMAND
 | 
			
		||||
  DeleteRegKey SHELL_CONTEXT "Software\Classes\${PROTOCOL}"
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}" "" "${DESCRIPTION}"
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}" "URL Protocol" ""
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\DefaultIcon" "" "${ICON}"
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell" "" ""
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell\open" "" ""
 | 
			
		||||
  WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell\open\command" "" "${COMMAND}"
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro CUSTOM_PROTOCOL_UNASSOCIATE PROTOCOL
 | 
			
		||||
  DeleteRegKey SHELL_CONTEXT "Software\Classes\${PROTOCOL}"
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro wails.associateCustomProtocols
 | 
			
		||||
    ; Create custom protocols associations
 | 
			
		||||
    {{range .Info.Protocols}}
 | 
			
		||||
      !insertmacro CUSTOM_PROTOCOL_ASSOCIATE "{{.Scheme}}" "{{.Description}}" "$INSTDIR\${PRODUCT_EXECUTABLE},0" "$INSTDIR\${PRODUCT_EXECUTABLE} $\"%1$\""
 | 
			
		||||
 | 
			
		||||
    {{end}}
 | 
			
		||||
!macroend
 | 
			
		||||
 | 
			
		||||
!macro wails.unassociateCustomProtocols
 | 
			
		||||
    ; Delete app custom protocol associations
 | 
			
		||||
    {{range .Info.Protocols}}
 | 
			
		||||
      !insertmacro CUSTOM_PROTOCOL_UNASSOCIATE "{{.Scheme}}"
 | 
			
		||||
    {{end}}
 | 
			
		||||
!macroend
 | 
			
		||||
							
								
								
									
										15
									
								
								build/windows/wails.exe.manifest
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								build/windows/wails.exe.manifest
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 | 
			
		||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
 | 
			
		||||
    <assemblyIdentity type="win32" name="com.wails.{{.Name}}" version="{{.Info.ProductVersion}}.0" processorArchitecture="*"/>
 | 
			
		||||
    <dependency>
 | 
			
		||||
        <dependentAssembly>
 | 
			
		||||
            <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
 | 
			
		||||
        </dependentAssembly>
 | 
			
		||||
    </dependency>
 | 
			
		||||
    <asmv3:application>
 | 
			
		||||
        <asmv3:windowsSettings>
 | 
			
		||||
            <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
 | 
			
		||||
            <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to per-monitor if per-monitor v2 is not supported -->
 | 
			
		||||
        </asmv3:windowsSettings>
 | 
			
		||||
    </asmv3:application>
 | 
			
		||||
</assembly>
 | 
			
		||||
		Reference in New Issue
	
	Block a user