pake-cli 1.0.0-beta.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -95
- package/dist/cli.js +109 -71
- package/package.json +16 -5
- package/src-tauri/Cargo.lock +59 -188
- package/src-tauri/Cargo.toml +5 -4
- package/src-tauri/assets/main.wxs +310 -0
- package/src-tauri/icons/chatgpt.icns +0 -0
- package/src-tauri/icons/lizhi.icns +0 -0
- package/src-tauri/png/chatgpt_256.ico +0 -0
- package/src-tauri/png/chatgpt_32.ico +0 -0
- package/src-tauri/png/chatgpt_512.png +0 -0
- package/src-tauri/png/lizhi_256.ico +0 -0
- package/src-tauri/png/lizhi_32.ico +0 -0
- package/src-tauri/png/lizhi_512.png +0 -0
- package/src-tauri/src/main.rs +108 -136
- package/src-tauri/src/pake.js +19 -9
- package/src-tauri/tauri.conf.json +1 -1
- package/src-tauri/tauri.linux.conf.json +4 -2
- package/src-tauri/tauri.windows.conf.json +2 -1
- package/pake-default.icns +0 -0
- package/src-tauri/tauri.conf.json.bak +0 -30
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
<?if $(sys.BUILDARCH)="x86"?>
|
|
2
|
+
<?define Win64 = "no" ?>
|
|
3
|
+
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
|
|
4
|
+
<?elseif $(sys.BUILDARCH)="x64"?>
|
|
5
|
+
<?define Win64 = "yes" ?>
|
|
6
|
+
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
|
|
7
|
+
<?else?>
|
|
8
|
+
<?error Unsupported value of sys.BUILDARCH=$(sys.BUILDARCH)?>
|
|
9
|
+
<?endif?>
|
|
10
|
+
|
|
11
|
+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
|
12
|
+
<Product
|
|
13
|
+
Id="*"
|
|
14
|
+
Name="{{{product_name}}}"
|
|
15
|
+
UpgradeCode="{{{upgrade_code}}}"
|
|
16
|
+
Language="!(loc.TauriLanguage)"
|
|
17
|
+
Manufacturer="{{{manufacturer}}}"
|
|
18
|
+
Version="{{{version}}}">
|
|
19
|
+
|
|
20
|
+
<Package Id="*"
|
|
21
|
+
Keywords="Installer"
|
|
22
|
+
InstallerVersion="450"
|
|
23
|
+
Languages="0"
|
|
24
|
+
Compressed="yes"
|
|
25
|
+
InstallScope="perMachine"
|
|
26
|
+
SummaryCodepage="!(loc.TauriCodepage)"/>
|
|
27
|
+
|
|
28
|
+
<!-- https://docs.microsoft.com/en-us/windows/win32/msi/reinstallmode -->
|
|
29
|
+
<!-- reinstall all files; rewrite all registry entries; reinstall all shortcuts -->
|
|
30
|
+
<Property Id="REINSTALLMODE" Value="amus" />
|
|
31
|
+
|
|
32
|
+
{{#if allow_downgrades}}
|
|
33
|
+
<MajorUpgrade Schedule="afterInstallInitialize" AllowDowngrades="yes" />
|
|
34
|
+
{{else}}
|
|
35
|
+
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="!(loc.DowngradeErrorMessage)" AllowSameVersionUpgrades="yes" />
|
|
36
|
+
{{/if}}
|
|
37
|
+
|
|
38
|
+
<InstallExecuteSequence>
|
|
39
|
+
<RemoveShortcuts>Installed AND NOT UPGRADINGPRODUCTCODE</RemoveShortcuts>
|
|
40
|
+
</InstallExecuteSequence>
|
|
41
|
+
|
|
42
|
+
<Media Id="1" Cabinet="app.cab" EmbedCab="yes" />
|
|
43
|
+
|
|
44
|
+
{{#if banner_path}}
|
|
45
|
+
<WixVariable Id="WixUIBannerBmp" Value="{{{banner_path}}}" />
|
|
46
|
+
{{/if}}
|
|
47
|
+
{{#if dialog_image_path}}
|
|
48
|
+
<WixVariable Id="WixUIDialogBmp" Value="{{{dialog_image_path}}}" />
|
|
49
|
+
{{/if}}
|
|
50
|
+
{{#if license}}
|
|
51
|
+
<WixVariable Id="WixUILicenseRtf" Value="{{{license}}}" />
|
|
52
|
+
{{/if}}
|
|
53
|
+
|
|
54
|
+
<Icon Id="ProductIcon" SourceFile="{{{icon_path}}}"/>
|
|
55
|
+
<Property Id="ARPPRODUCTICON" Value="ProductIcon" />
|
|
56
|
+
<Property Id="ARPNOREPAIR" Value="yes" Secure="yes" /> <!-- Remove repair -->
|
|
57
|
+
<SetProperty Id="ARPNOMODIFY" Value="1" After="InstallValidate" Sequence="execute"/>
|
|
58
|
+
|
|
59
|
+
<!-- initialize with previous InstallDir -->
|
|
60
|
+
<Property Id="INSTALLDIR">
|
|
61
|
+
<RegistrySearch Id="PrevInstallDirReg" Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="InstallDir" Type="raw"/>
|
|
62
|
+
</Property>
|
|
63
|
+
|
|
64
|
+
<!-- launch app checkbox -->
|
|
65
|
+
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="!(loc.LaunchApp)" />
|
|
66
|
+
<Property Id="WixShellExecTarget" Value="[!Path]" />
|
|
67
|
+
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
|
|
68
|
+
|
|
69
|
+
<UI>
|
|
70
|
+
<!-- launch app checkbox -->
|
|
71
|
+
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
|
|
72
|
+
|
|
73
|
+
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
|
|
74
|
+
|
|
75
|
+
{{#unless license}}
|
|
76
|
+
<!-- Skip license dialog -->
|
|
77
|
+
<Publish Dialog="WelcomeDlg"
|
|
78
|
+
Control="Next"
|
|
79
|
+
Event="NewDialog"
|
|
80
|
+
Value="InstallDirDlg"
|
|
81
|
+
Order="2">1</Publish>
|
|
82
|
+
<Publish Dialog="InstallDirDlg"
|
|
83
|
+
Control="Back"
|
|
84
|
+
Event="NewDialog"
|
|
85
|
+
Value="WelcomeDlg"
|
|
86
|
+
Order="2">1</Publish>
|
|
87
|
+
{{/unless}}
|
|
88
|
+
</UI>
|
|
89
|
+
|
|
90
|
+
<UIRef Id="WixUI_InstallDir" />
|
|
91
|
+
|
|
92
|
+
<Directory Id="TARGETDIR" Name="SourceDir">
|
|
93
|
+
<Directory Id="DesktopFolder" Name="Desktop">
|
|
94
|
+
<Component Id="ApplicationShortcutDesktop" Guid="*">
|
|
95
|
+
<Shortcut Id="ApplicationDesktopShortcut" Name="{{{product_name}}}" Description="Runs {{{product_name}}}" Target="[!Path]" WorkingDirectory="INSTALLDIR" />
|
|
96
|
+
<RemoveFolder Id="DesktopFolder" On="uninstall" />
|
|
97
|
+
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="Desktop Shortcut" Type="integer" Value="1" KeyPath="yes" />
|
|
98
|
+
</Component>
|
|
99
|
+
</Directory>
|
|
100
|
+
<Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
|
|
101
|
+
<Directory Id="INSTALLDIR" Name="{{{product_name}}}"/>
|
|
102
|
+
</Directory>
|
|
103
|
+
<Directory Id="ProgramMenuFolder">
|
|
104
|
+
<Directory Id="ApplicationProgramsFolder" Name="{{{product_name}}}"/>
|
|
105
|
+
</Directory>
|
|
106
|
+
</Directory>
|
|
107
|
+
|
|
108
|
+
<DirectoryRef Id="INSTALLDIR">
|
|
109
|
+
<Component Id="RegistryEntries" Guid="*">
|
|
110
|
+
<RegistryKey Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}">
|
|
111
|
+
<RegistryValue Name="InstallDir" Type="string" Value="[INSTALLDIR]" KeyPath="yes" />
|
|
112
|
+
</RegistryKey>
|
|
113
|
+
</Component>
|
|
114
|
+
<Component Id="Path" Guid="{{{path_component_guid}}}" Win64="$(var.Win64)">
|
|
115
|
+
<File Id="Path" Source="{{{app_exe_source}}}" KeyPath="yes" Checksum="yes"/>
|
|
116
|
+
</Component>
|
|
117
|
+
{{#each binaries as |bin| ~}}
|
|
118
|
+
<Component Id="{{ bin.id }}" Guid="{{bin.guid}}" Win64="$(var.Win64)">
|
|
119
|
+
<File Id="Bin_{{ bin.id }}" Source="{{bin.path}}" KeyPath="yes"/>
|
|
120
|
+
</Component>
|
|
121
|
+
{{/each~}}
|
|
122
|
+
{{#if enable_elevated_update_task}}
|
|
123
|
+
<Component Id="UpdateTask" Guid="C492327D-9720-4CD5-8DB8-F09082AF44BE" Win64="$(var.Win64)">
|
|
124
|
+
<File Id="UpdateTask" Source="update.xml" KeyPath="yes" Checksum="yes"/>
|
|
125
|
+
</Component>
|
|
126
|
+
<Component Id="UpdateTaskInstaller" Guid="011F25ED-9BE3-50A7-9E9B-3519ED2B9932" Win64="$(var.Win64)">
|
|
127
|
+
<File Id="UpdateTaskInstaller" Source="install-task.ps1" KeyPath="yes" Checksum="yes"/>
|
|
128
|
+
</Component>
|
|
129
|
+
<Component Id="UpdateTaskUninstaller" Guid="D4F6CC3F-32DC-5FD0-95E8-782FFD7BBCE1" Win64="$(var.Win64)">
|
|
130
|
+
<File Id="UpdateTaskUninstaller" Source="uninstall-task.ps1" KeyPath="yes" Checksum="yes"/>
|
|
131
|
+
</Component>
|
|
132
|
+
{{/if}}
|
|
133
|
+
{{{resources}}}
|
|
134
|
+
<Component Id="CMP_UninstallShortcut" Guid="*">
|
|
135
|
+
|
|
136
|
+
<Shortcut Id="UninstallShortcut"
|
|
137
|
+
Name="Uninstall {{{product_name}}}"
|
|
138
|
+
Description="Uninstalls {{{product_name}}}"
|
|
139
|
+
Target="[System64Folder]msiexec.exe"
|
|
140
|
+
Arguments="/x [ProductCode]" />
|
|
141
|
+
|
|
142
|
+
<RemoveFolder Id="INSTALLDIR"
|
|
143
|
+
On="uninstall" />
|
|
144
|
+
|
|
145
|
+
<RegistryValue Root="HKCU"
|
|
146
|
+
Key="Software\\{{{manufacturer}}}\\{{{product_name}}}"
|
|
147
|
+
Name="Uninstaller Shortcut"
|
|
148
|
+
Type="integer"
|
|
149
|
+
Value="1"
|
|
150
|
+
KeyPath="yes" />
|
|
151
|
+
</Component>
|
|
152
|
+
</DirectoryRef>
|
|
153
|
+
|
|
154
|
+
<DirectoryRef Id="ApplicationProgramsFolder">
|
|
155
|
+
<Component Id="ApplicationShortcut" Guid="*">
|
|
156
|
+
<Shortcut Id="ApplicationStartMenuShortcut"
|
|
157
|
+
Name="{{{product_name}}}"
|
|
158
|
+
Description="Runs {{{product_name}}}"
|
|
159
|
+
Target="[!Path]"
|
|
160
|
+
Icon="ProductIcon"
|
|
161
|
+
WorkingDirectory="INSTALLDIR">
|
|
162
|
+
<ShortcutProperty Key="System.AppUserModel.ID" Value="{{{bundle_id}}}"/>
|
|
163
|
+
</Shortcut>
|
|
164
|
+
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
|
|
165
|
+
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="Start Menu Shortcut" Type="integer" Value="1" KeyPath="yes"/>
|
|
166
|
+
</Component>
|
|
167
|
+
</DirectoryRef>
|
|
168
|
+
|
|
169
|
+
{{#each merge_modules as |msm| ~}}
|
|
170
|
+
<DirectoryRef Id="TARGETDIR">
|
|
171
|
+
<Merge Id="{{ msm.name }}" SourceFile="{{ msm.path }}" DiskId="1" Language="!(loc.TauriLanguage)" />
|
|
172
|
+
</DirectoryRef>
|
|
173
|
+
|
|
174
|
+
<Feature Id="{{ msm.name }}" Title="{{ msm.name }}" AllowAdvertise="no" Display="hidden" Level="1">
|
|
175
|
+
<MergeRef Id="{{ msm.name }}"/>
|
|
176
|
+
</Feature>
|
|
177
|
+
{{/each~}}
|
|
178
|
+
|
|
179
|
+
<Feature
|
|
180
|
+
Id="MainProgram"
|
|
181
|
+
Title="Application"
|
|
182
|
+
Description="!(loc.InstallAppFeature)"
|
|
183
|
+
Level="1"
|
|
184
|
+
ConfigurableDirectory="INSTALLDIR"
|
|
185
|
+
AllowAdvertise="no"
|
|
186
|
+
Display="expand"
|
|
187
|
+
Absent="disallow">
|
|
188
|
+
|
|
189
|
+
<ComponentRef Id="RegistryEntries"/>
|
|
190
|
+
|
|
191
|
+
{{#each resource_file_ids as |resource_file_id| ~}}
|
|
192
|
+
<ComponentRef Id="{{ resource_file_id }}"/>
|
|
193
|
+
{{/each~}}
|
|
194
|
+
|
|
195
|
+
{{#if enable_elevated_update_task}}
|
|
196
|
+
<ComponentRef Id="UpdateTask" />
|
|
197
|
+
<ComponentRef Id="UpdateTaskInstaller" />
|
|
198
|
+
<ComponentRef Id="UpdateTaskUninstaller" />
|
|
199
|
+
{{/if}}
|
|
200
|
+
|
|
201
|
+
<Feature Id="ShortcutsFeature"
|
|
202
|
+
Title="Shortcuts"
|
|
203
|
+
Level="1">
|
|
204
|
+
<ComponentRef Id="Path"/>
|
|
205
|
+
<ComponentRef Id="CMP_UninstallShortcut" />
|
|
206
|
+
<ComponentRef Id="ApplicationShortcut" />
|
|
207
|
+
<ComponentRef Id="ApplicationShortcutDesktop" />
|
|
208
|
+
</Feature>
|
|
209
|
+
|
|
210
|
+
<Feature
|
|
211
|
+
Id="Environment"
|
|
212
|
+
Title="PATH Environment Variable"
|
|
213
|
+
Description="!(loc.PathEnvVarFeature)"
|
|
214
|
+
Level="1"
|
|
215
|
+
Absent="allow">
|
|
216
|
+
<ComponentRef Id="Path"/>
|
|
217
|
+
{{#each binaries as |bin| ~}}
|
|
218
|
+
<ComponentRef Id="{{ bin.id }}"/>
|
|
219
|
+
{{/each~}}
|
|
220
|
+
</Feature>
|
|
221
|
+
</Feature>
|
|
222
|
+
|
|
223
|
+
<Feature Id="External" AllowAdvertise="no" Absent="disallow">
|
|
224
|
+
{{#each component_group_refs as |id| ~}}
|
|
225
|
+
<ComponentGroupRef Id="{{ id }}"/>
|
|
226
|
+
{{/each~}}
|
|
227
|
+
{{#each component_refs as |id| ~}}
|
|
228
|
+
<ComponentRef Id="{{ id }}"/>
|
|
229
|
+
{{/each~}}
|
|
230
|
+
{{#each feature_group_refs as |id| ~}}
|
|
231
|
+
<FeatureGroupRef Id="{{ id }}"/>
|
|
232
|
+
{{/each~}}
|
|
233
|
+
{{#each feature_refs as |id| ~}}
|
|
234
|
+
<FeatureRef Id="{{ id }}"/>
|
|
235
|
+
{{/each~}}
|
|
236
|
+
{{#each merge_refs as |id| ~}}
|
|
237
|
+
<MergeRef Id="{{ id }}"/>
|
|
238
|
+
{{/each~}}
|
|
239
|
+
</Feature>
|
|
240
|
+
|
|
241
|
+
{{#if install_webview}}
|
|
242
|
+
<!-- WebView2 -->
|
|
243
|
+
<Property Id="WVRTINSTALLED">
|
|
244
|
+
<RegistrySearch Id="WVRTInstalledSystem" Root="HKLM" Key="SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw" Win64="no" />
|
|
245
|
+
<RegistrySearch Id="WVRTInstalledUser" Root="HKCU" Key="SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw"/>
|
|
246
|
+
</Property>
|
|
247
|
+
|
|
248
|
+
{{#if download_bootstrapper}}
|
|
249
|
+
<CustomAction Id='DownloadAndInvokeBootstrapper' Directory="INSTALLDIR" Execute="deferred" ExeCommand='powershell.exe -NoProfile -windowstyle hidden try [\{] [\[]Net.ServicePointManager[\]]::SecurityProtocol = [\[]Net.SecurityProtocolType[\]]::Tls12 [\}] catch [\{][\}]; Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -OutFile "$env:TEMP\MicrosoftEdgeWebview2Setup.exe" ; Start-Process -FilePath "$env:TEMP\MicrosoftEdgeWebview2Setup.exe" -ArgumentList ({{{webview_installer_args}}} '/install') -Wait' Return='check'/>
|
|
250
|
+
<InstallExecuteSequence>
|
|
251
|
+
<Custom Action='DownloadAndInvokeBootstrapper' Before='InstallFinalize'>
|
|
252
|
+
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
|
|
253
|
+
</Custom>
|
|
254
|
+
</InstallExecuteSequence>
|
|
255
|
+
{{/if}}
|
|
256
|
+
|
|
257
|
+
<!-- Embedded webview bootstrapper mode -->
|
|
258
|
+
{{#if webview2_bootstrapper_path}}
|
|
259
|
+
<Binary Id="MicrosoftEdgeWebview2Setup.exe" SourceFile="{{{webview2_bootstrapper_path}}}"/>
|
|
260
|
+
<CustomAction Id='InvokeBootstrapper' BinaryKey='MicrosoftEdgeWebview2Setup.exe' Execute="deferred" ExeCommand='{{{webview_installer_args}}} /install' Return='check' />
|
|
261
|
+
<InstallExecuteSequence>
|
|
262
|
+
<Custom Action='InvokeBootstrapper' Before='InstallFinalize'>
|
|
263
|
+
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
|
|
264
|
+
</Custom>
|
|
265
|
+
</InstallExecuteSequence>
|
|
266
|
+
{{/if}}
|
|
267
|
+
|
|
268
|
+
<!-- Embedded offline installer -->
|
|
269
|
+
{{#if webview2_installer_path}}
|
|
270
|
+
<Binary Id="MicrosoftEdgeWebView2RuntimeInstaller.exe" SourceFile="{{{webview2_installer_path}}}"/>
|
|
271
|
+
<CustomAction Id='InvokeStandalone' BinaryKey='MicrosoftEdgeWebView2RuntimeInstaller.exe' Execute="deferred" ExeCommand='{{{webview_installer_args}}} /install' Return='check' />
|
|
272
|
+
<InstallExecuteSequence>
|
|
273
|
+
<Custom Action='InvokeStandalone' Before='InstallFinalize'>
|
|
274
|
+
<![CDATA[NOT(REMOVE OR WVRTINSTALLED)]]>
|
|
275
|
+
</Custom>
|
|
276
|
+
</InstallExecuteSequence>
|
|
277
|
+
{{/if}}
|
|
278
|
+
|
|
279
|
+
{{/if}}
|
|
280
|
+
|
|
281
|
+
{{#if enable_elevated_update_task}}
|
|
282
|
+
<!-- Install an elevated update task within Windows Task Scheduler -->
|
|
283
|
+
<CustomAction
|
|
284
|
+
Id="CreateUpdateTask"
|
|
285
|
+
Return="check"
|
|
286
|
+
Directory="INSTALLDIR"
|
|
287
|
+
Execute="commit"
|
|
288
|
+
Impersonate="yes"
|
|
289
|
+
ExeCommand="powershell.exe -WindowStyle hidden .\install-task.ps1" />
|
|
290
|
+
<InstallExecuteSequence>
|
|
291
|
+
<Custom Action='CreateUpdateTask' Before='InstallFinalize'>
|
|
292
|
+
NOT(REMOVE)
|
|
293
|
+
</Custom>
|
|
294
|
+
</InstallExecuteSequence>
|
|
295
|
+
<!-- Remove elevated update task during uninstall -->
|
|
296
|
+
<CustomAction
|
|
297
|
+
Id="DeleteUpdateTask"
|
|
298
|
+
Return="check"
|
|
299
|
+
Directory="INSTALLDIR"
|
|
300
|
+
ExeCommand="powershell.exe -WindowStyle hidden .\uninstall-task.ps1" />
|
|
301
|
+
<InstallExecuteSequence>
|
|
302
|
+
<Custom Action="DeleteUpdateTask" Before='InstallFinalize'>
|
|
303
|
+
(REMOVE = "ALL") AND NOT UPGRADINGPRODUCTCODE
|
|
304
|
+
</Custom>
|
|
305
|
+
</InstallExecuteSequence>
|
|
306
|
+
{{/if}}
|
|
307
|
+
|
|
308
|
+
<SetProperty Id="ARPINSTALLLOCATION" Value="[INSTALLDIR]" After="CostFinalize"/>
|
|
309
|
+
</Product>
|
|
310
|
+
</Wix>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src-tauri/src/main.rs
CHANGED
|
@@ -2,101 +2,76 @@
|
|
|
2
2
|
#![windows_subsystem = "windows"]
|
|
3
3
|
extern crate image;
|
|
4
4
|
use tauri_utils::config::{Config, WindowConfig};
|
|
5
|
-
#[cfg(target_os = "macos")]
|
|
6
|
-
use wry::application::platform::macos::WindowBuilderExtMacOS;
|
|
7
|
-
|
|
8
|
-
#[cfg(target_os = "macos")]
|
|
9
5
|
use wry::{
|
|
10
6
|
application::{
|
|
11
|
-
accelerator::{Accelerator, SysMods},
|
|
12
7
|
event::{Event, StartCause, WindowEvent},
|
|
13
8
|
event_loop::{ControlFlow, EventLoop},
|
|
14
|
-
|
|
15
|
-
menu::{MenuBar as Menu, MenuItem, MenuItemAttributes, MenuType},
|
|
9
|
+
menu::MenuType,
|
|
16
10
|
window::{Fullscreen, Window, WindowBuilder},
|
|
17
11
|
},
|
|
18
12
|
webview::WebViewBuilder,
|
|
19
13
|
};
|
|
20
14
|
|
|
21
|
-
#[cfg(target_os = "
|
|
22
|
-
use wry::{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
window::{Fullscreen, Icon, Window, WindowBuilder},
|
|
28
|
-
},
|
|
29
|
-
webview::WebViewBuilder,
|
|
15
|
+
#[cfg(target_os = "macos")]
|
|
16
|
+
use wry::application::{
|
|
17
|
+
accelerator::{Accelerator, SysMods},
|
|
18
|
+
keyboard::KeyCode,
|
|
19
|
+
menu::{MenuBar as Menu, MenuItem, MenuItemAttributes},
|
|
20
|
+
platform::macos::WindowBuilderExtMacOS,
|
|
30
21
|
};
|
|
31
22
|
|
|
32
|
-
#[cfg(target_os = "
|
|
33
|
-
use wry::
|
|
34
|
-
application::{
|
|
35
|
-
event::{Event, StartCause, WindowEvent},
|
|
36
|
-
event_loop::{ControlFlow, EventLoop},
|
|
37
|
-
menu::MenuType,
|
|
38
|
-
window::{Fullscreen, Window, WindowBuilder},
|
|
39
|
-
},
|
|
40
|
-
webview::{WebContext, WebViewBuilder},
|
|
41
|
-
};
|
|
23
|
+
#[cfg(target_os = "windows")]
|
|
24
|
+
use wry::application::window::Icon;
|
|
42
25
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
let mut menu_bar_menu = Menu::new();
|
|
46
|
-
#[cfg(target_os = "macos")]
|
|
47
|
-
let mut first_menu = Menu::new();
|
|
48
|
-
#[cfg(target_os = "macos")]
|
|
49
|
-
first_menu.add_native_item(MenuItem::Hide);
|
|
50
|
-
#[cfg(target_os = "macos")]
|
|
51
|
-
first_menu.add_native_item(MenuItem::EnterFullScreen);
|
|
52
|
-
#[cfg(target_os = "macos")]
|
|
53
|
-
first_menu.add_native_item(MenuItem::Minimize);
|
|
54
|
-
#[cfg(target_os = "macos")]
|
|
55
|
-
first_menu.add_native_item(MenuItem::Separator);
|
|
56
|
-
#[cfg(target_os = "macos")]
|
|
57
|
-
first_menu.add_native_item(MenuItem::Copy);
|
|
58
|
-
#[cfg(target_os = "macos")]
|
|
59
|
-
first_menu.add_native_item(MenuItem::Cut);
|
|
60
|
-
#[cfg(target_os = "macos")]
|
|
61
|
-
first_menu.add_native_item(MenuItem::Paste);
|
|
62
|
-
#[cfg(target_os = "macos")]
|
|
63
|
-
first_menu.add_native_item(MenuItem::Undo);
|
|
64
|
-
#[cfg(target_os = "macos")]
|
|
65
|
-
first_menu.add_native_item(MenuItem::Redo);
|
|
66
|
-
#[cfg(target_os = "macos")]
|
|
67
|
-
first_menu.add_native_item(MenuItem::SelectAll);
|
|
68
|
-
#[cfg(target_os = "macos")]
|
|
69
|
-
first_menu.add_native_item(MenuItem::Separator);
|
|
26
|
+
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
|
27
|
+
use wry::webview::WebContext;
|
|
70
28
|
|
|
29
|
+
fn main() -> wry::Result<()> {
|
|
71
30
|
#[cfg(target_os = "macos")]
|
|
72
|
-
let close_item =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
31
|
+
let (menu_bar_menu, close_item) = {
|
|
32
|
+
let mut menu_bar_menu = Menu::new();
|
|
33
|
+
let mut first_menu = Menu::new();
|
|
34
|
+
first_menu.add_native_item(MenuItem::Hide);
|
|
35
|
+
first_menu.add_native_item(MenuItem::EnterFullScreen);
|
|
36
|
+
first_menu.add_native_item(MenuItem::Minimize);
|
|
37
|
+
first_menu.add_native_item(MenuItem::Separator);
|
|
38
|
+
first_menu.add_native_item(MenuItem::Copy);
|
|
39
|
+
first_menu.add_native_item(MenuItem::Cut);
|
|
40
|
+
first_menu.add_native_item(MenuItem::Paste);
|
|
41
|
+
first_menu.add_native_item(MenuItem::Undo);
|
|
42
|
+
first_menu.add_native_item(MenuItem::Redo);
|
|
43
|
+
first_menu.add_native_item(MenuItem::SelectAll);
|
|
44
|
+
first_menu.add_native_item(MenuItem::Separator);
|
|
45
|
+
let close_item = first_menu.add_item(
|
|
46
|
+
MenuItemAttributes::new("CloseWindow")
|
|
47
|
+
.with_accelerators(&Accelerator::new(SysMods::Cmd, KeyCode::KeyW)),
|
|
48
|
+
);
|
|
49
|
+
first_menu.add_native_item(MenuItem::Quit);
|
|
50
|
+
menu_bar_menu.add_submenu("App", true, first_menu);
|
|
51
|
+
(menu_bar_menu, close_item)
|
|
52
|
+
};
|
|
76
53
|
|
|
77
|
-
#[cfg(target_os = "
|
|
78
|
-
|
|
54
|
+
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
|
55
|
+
let (
|
|
56
|
+
package_name,
|
|
57
|
+
WindowConfig {
|
|
58
|
+
url,
|
|
59
|
+
width,
|
|
60
|
+
height,
|
|
61
|
+
resizable,
|
|
62
|
+
fullscreen,
|
|
63
|
+
..
|
|
64
|
+
},
|
|
65
|
+
) = {
|
|
66
|
+
let (package_name, windows_config) = get_windows_config();
|
|
67
|
+
(
|
|
68
|
+
package_name
|
|
69
|
+
.expect("can't get package name in config file")
|
|
70
|
+
.to_lowercase(),
|
|
71
|
+
windows_config.unwrap_or_default(),
|
|
72
|
+
)
|
|
73
|
+
};
|
|
79
74
|
|
|
80
|
-
#[cfg(target_os = "macos")]
|
|
81
|
-
menu_bar_menu.add_submenu("App", true, first_menu);
|
|
82
|
-
#[cfg(target_os = "linux")]
|
|
83
|
-
let WindowConfig {
|
|
84
|
-
url,
|
|
85
|
-
width,
|
|
86
|
-
height,
|
|
87
|
-
resizable,
|
|
88
|
-
fullscreen,
|
|
89
|
-
..
|
|
90
|
-
} = get_windows_config().unwrap_or_default();
|
|
91
|
-
#[cfg(target_os = "windows")]
|
|
92
|
-
let WindowConfig {
|
|
93
|
-
url,
|
|
94
|
-
width,
|
|
95
|
-
height,
|
|
96
|
-
resizable,
|
|
97
|
-
fullscreen,
|
|
98
|
-
..
|
|
99
|
-
} = get_windows_config().unwrap_or_default();
|
|
100
75
|
#[cfg(target_os = "macos")]
|
|
101
76
|
let WindowConfig {
|
|
102
77
|
url,
|
|
@@ -106,7 +81,7 @@ fn main() -> wry::Result<()> {
|
|
|
106
81
|
transparent,
|
|
107
82
|
fullscreen,
|
|
108
83
|
..
|
|
109
|
-
} = get_windows_config().unwrap_or_default();
|
|
84
|
+
} = get_windows_config().1.unwrap_or_default();
|
|
110
85
|
let event_loop = EventLoop::new();
|
|
111
86
|
|
|
112
87
|
let common_window = WindowBuilder::new()
|
|
@@ -119,14 +94,15 @@ fn main() -> wry::Result<()> {
|
|
|
119
94
|
})
|
|
120
95
|
.with_inner_size(wry::application::dpi::LogicalSize::new(width, height));
|
|
121
96
|
#[cfg(target_os = "windows")]
|
|
122
|
-
let
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
97
|
+
let window = {
|
|
98
|
+
let icon_path = format!("png/{}_32.ico", package_name);
|
|
99
|
+
let icon = load_icon(std::path::Path::new(&icon_path));
|
|
100
|
+
common_window
|
|
101
|
+
.with_decorations(true)
|
|
102
|
+
.with_window_icon(Some(icon))
|
|
103
|
+
.build(&event_loop)
|
|
104
|
+
.unwrap()
|
|
105
|
+
};
|
|
130
106
|
|
|
131
107
|
#[cfg(target_os = "linux")]
|
|
132
108
|
let window = common_window.build(&event_loop).unwrap();
|
|
@@ -158,53 +134,47 @@ fn main() -> wry::Result<()> {
|
|
|
158
134
|
|
|
159
135
|
// 用于欺骗部分页面对于浏览器的强检测
|
|
160
136
|
|
|
161
|
-
// #[cfg(target_os = "macos")]
|
|
162
|
-
// let user_agent_string = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15";
|
|
163
|
-
|
|
164
137
|
#[cfg(target_os = "macos")]
|
|
165
|
-
let webview =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
let webview = WebViewBuilder::new(window)?
|
|
177
|
-
// .with_user_agent(user_agent_string)
|
|
178
|
-
// .with_accept_first_mouse(true)
|
|
179
|
-
.with_url(&url.to_string())?
|
|
180
|
-
.with_devtools(cfg!(feature = "devtools"))
|
|
181
|
-
.with_initialization_script(include_str!("pake.js"))
|
|
182
|
-
.with_ipc_handler(handler)
|
|
183
|
-
// .with_back_forward_navigation_gestures(true)
|
|
184
|
-
.build()?;
|
|
185
|
-
// 自定义cookie文件夹,仅用于Linux
|
|
186
|
-
// Custom Cookie folder, only for Linux
|
|
187
|
-
#[cfg(target_os = "linux")]
|
|
188
|
-
let data_path =
|
|
189
|
-
std::path::PathBuf::from(concat!("/home/", env!("USER"), "/.config/com-tw93-weread/"));
|
|
190
|
-
#[cfg(target_os = "linux")]
|
|
191
|
-
if !std::path::Path::new(&data_path).exists() {
|
|
192
|
-
std::fs::create_dir(&data_path)?;
|
|
193
|
-
}
|
|
194
|
-
#[cfg(target_os = "linux")]
|
|
195
|
-
let mut web_content = WebContext::new(Some(data_path));
|
|
196
|
-
#[cfg(target_os = "linux")]
|
|
197
|
-
let webview = WebViewBuilder::new(window)?
|
|
198
|
-
// .with_user_agent(user_agent_string)
|
|
199
|
-
// .with_accept_first_mouse(true)
|
|
200
|
-
.with_url(&url.to_string())?
|
|
201
|
-
.with_devtools(cfg!(feature = "devtools"))
|
|
202
|
-
.with_initialization_script(include_str!("pake.js"))
|
|
203
|
-
.with_ipc_handler(handler)
|
|
204
|
-
.with_web_context(&mut web_content)
|
|
205
|
-
// .with_back_forward_navigation_gestures(true)
|
|
206
|
-
.build()?;
|
|
138
|
+
let webview = {
|
|
139
|
+
let user_agent_string = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15";
|
|
140
|
+
WebViewBuilder::new(window)?
|
|
141
|
+
.with_user_agent(user_agent_string)
|
|
142
|
+
.with_url(&url.to_string())?
|
|
143
|
+
.with_devtools(cfg!(feature = "devtools"))
|
|
144
|
+
.with_initialization_script(include_str!("pake.js"))
|
|
145
|
+
.with_ipc_handler(handler)
|
|
146
|
+
.with_back_forward_navigation_gestures(true)
|
|
147
|
+
.build()?
|
|
148
|
+
};
|
|
207
149
|
|
|
150
|
+
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
|
151
|
+
let webview = {
|
|
152
|
+
let home_dir = match home::home_dir() {
|
|
153
|
+
Some(path1) => path1,
|
|
154
|
+
None => panic!("Error, can't found you home dir!!"),
|
|
155
|
+
};
|
|
156
|
+
#[cfg(target_os = "windows")]
|
|
157
|
+
let data_dir = home_dir.join("AppData").join("Roaming").join(package_name);
|
|
158
|
+
#[cfg(target_os = "linux")]
|
|
159
|
+
let data_dir = home_dir.join(".config").join(package_name);
|
|
160
|
+
if !data_dir.exists() {
|
|
161
|
+
std::fs::create_dir(&data_dir)
|
|
162
|
+
.unwrap_or_else(|_| panic!("can't create dir {}", data_dir.display()));
|
|
163
|
+
}
|
|
164
|
+
let mut web_content = WebContext::new(Some(data_dir));
|
|
165
|
+
#[cfg(target_os = "windows")]
|
|
166
|
+
let user_agent_string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36";
|
|
167
|
+
#[cfg(target_os = "linux")]
|
|
168
|
+
let user_agent_string = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36";
|
|
169
|
+
WebViewBuilder::new(window)?
|
|
170
|
+
.with_user_agent(user_agent_string)
|
|
171
|
+
.with_url(&url.to_string())?
|
|
172
|
+
.with_devtools(cfg!(feature = "devtools"))
|
|
173
|
+
.with_initialization_script(include_str!("pake.js"))
|
|
174
|
+
.with_ipc_handler(handler)
|
|
175
|
+
.with_web_context(&mut web_content)
|
|
176
|
+
.build()?
|
|
177
|
+
};
|
|
208
178
|
#[cfg(feature = "devtools")]
|
|
209
179
|
{
|
|
210
180
|
webview.open_devtools();
|
|
@@ -236,11 +206,13 @@ fn main() -> wry::Result<()> {
|
|
|
236
206
|
});
|
|
237
207
|
}
|
|
238
208
|
|
|
239
|
-
fn get_windows_config() -> Option<WindowConfig> {
|
|
209
|
+
fn get_windows_config() -> (Option<String>, Option<WindowConfig>) {
|
|
240
210
|
let config_file = include_str!("../tauri.conf.json");
|
|
241
211
|
let config: Config = serde_json::from_str(config_file).expect("failed to parse windows config");
|
|
242
|
-
|
|
243
|
-
|
|
212
|
+
(
|
|
213
|
+
config.package.product_name.clone(),
|
|
214
|
+
config.tauri.windows.first().cloned(),
|
|
215
|
+
)
|
|
244
216
|
}
|
|
245
217
|
|
|
246
218
|
#[cfg(target_os = "windows")]
|