pake-cli 0.1.1 → 0.1.3

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.
@@ -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}}} &apos;/install&apos;) -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
@@ -2,109 +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
- use wry::{
10
- application::{
11
- accelerator::{Accelerator, SysMods},
12
- event::{Event, StartCause, WindowEvent},
13
- event_loop::{ControlFlow, EventLoop},
14
- keyboard::KeyCode,
15
- menu::{MenuBar as Menu, MenuItem, MenuItemAttributes, MenuType},
16
- window::{Fullscreen, Window, WindowBuilder},
17
- },
18
- webview::WebViewBuilder,
19
- };
20
-
21
- #[cfg(target_os = "windows")]
22
5
  use wry::{
23
6
  application::{
24
7
  event::{Event, StartCause, WindowEvent},
25
8
  event_loop::{ControlFlow, EventLoop},
26
9
  menu::MenuType,
27
- window::{Fullscreen, Icon, Window, WindowBuilder},
10
+ window::{Fullscreen, Window, WindowBuilder},
28
11
  },
29
12
  webview::WebViewBuilder,
30
13
  };
31
14
 
32
- #[cfg(target_os = "linux")]
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},
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,
41
21
  };
42
22
 
43
- fn main() -> wry::Result<()> {
44
- #[cfg(target_os = "macos")]
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);
70
-
71
- #[cfg(target_os = "macos")]
72
- let close_item = first_menu.add_item(
73
- MenuItemAttributes::new("CloseWindow")
74
- .with_accelerators(&Accelerator::new(SysMods::Cmd, KeyCode::KeyW)),
75
- );
23
+ #[cfg(target_os = "windows")]
24
+ use wry::application::window::Icon;
76
25
 
77
- #[cfg(target_os = "macos")]
78
- first_menu.add_native_item(MenuItem::Quit);
26
+ #[cfg(any(target_os = "linux", target_os = "windows"))]
27
+ use wry::webview::WebContext;
79
28
 
29
+ fn main() -> wry::Result<()> {
80
30
  #[cfg(target_os = "macos")]
81
- menu_bar_menu.add_submenu("App", true, first_menu);
82
- #[cfg(target_os = "linux")]
83
- let (package_name, windows_config) = get_windows_config();
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
+ };
84
53
 
85
- #[cfg(target_os = "linux")]
86
- let package_name = package_name.expect("can't get package name in config file");
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
+ };
87
74
 
88
- #[cfg(target_os = "linux")]
89
- let WindowConfig {
90
- url,
91
- width,
92
- height,
93
- resizable,
94
- fullscreen,
95
- ..
96
- } = windows_config.unwrap_or_default();
97
- #[cfg(target_os = "windows")]
98
- let (package_name, windows_config) = get_windows_config();
99
- #[cfg(target_os = "windows")]
100
- let WindowConfig {
101
- url,
102
- width,
103
- height,
104
- resizable,
105
- fullscreen,
106
- ..
107
- } = windows_config.unwrap_or_default();
108
75
  #[cfg(target_os = "macos")]
109
76
  let WindowConfig {
110
77
  url,
@@ -127,19 +94,15 @@ fn main() -> wry::Result<()> {
127
94
  })
128
95
  .with_inner_size(wry::application::dpi::LogicalSize::new(width, height));
129
96
  #[cfg(target_os = "windows")]
130
- let package_name = package_name
131
- .expect("can't get package name in config file")
132
- .to_lowercase();
133
- #[cfg(target_os = "windows")]
134
- let icon_path = format!("png/{}_32.ico", package_name);
135
- #[cfg(target_os = "windows")]
136
- let icon = load_icon(std::path::Path::new(&icon_path));
137
- #[cfg(target_os = "windows")]
138
- let window = common_window
139
- .with_decorations(true)
140
- .with_window_icon(Some(icon))
141
- .build(&event_loop)
142
- .unwrap();
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
+ };
143
106
 
144
107
  #[cfg(target_os = "linux")]
145
108
  let window = common_window.build(&event_loop).unwrap();
@@ -171,64 +134,47 @@ fn main() -> wry::Result<()> {
171
134
 
172
135
  // 用于欺骗部分页面对于浏览器的强检测
173
136
 
174
- // #[cfg(target_os = "macos")]
175
- // 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";
176
-
177
137
  #[cfg(target_os = "macos")]
178
- let webview = WebViewBuilder::new(window)?
179
- // .with_user_agent(user_agent_string)
180
- // .with_accept_first_mouse(true)
181
- .with_url(&url.to_string())?
182
- .with_devtools(cfg!(feature = "devtools"))
183
- .with_initialization_script(include_str!("pake.js"))
184
- .with_ipc_handler(handler)
185
- // .with_back_forward_navigation_gestures(true)
186
- .build()?;
187
-
188
- #[cfg(target_os = "windows")]
189
- let webview = WebViewBuilder::new(window)?
190
- // .with_user_agent(user_agent_string)
191
- // .with_accept_first_mouse(true)
192
- .with_url(&url.to_string())?
193
- .with_devtools(cfg!(feature = "devtools"))
194
- .with_initialization_script(include_str!("pake.js"))
195
- .with_ipc_handler(handler)
196
- // .with_back_forward_navigation_gestures(true)
197
- .build()?;
198
- // 自定义cookie文件夹,仅用于Linux
199
- // Custom Cookie folder, only for Linux
200
- // #[cfg(target_os = "linux")]
201
- // let config_path = format!("/home/{}/.config/{}", env!("USER"), package_name);
202
- #[cfg(target_os = "linux")]
203
- let user = std::env::var_os("USER");
204
- #[cfg(target_os = "linux")]
205
- let config_path = match user {
206
- Some(v) => format!(
207
- "/home/{}/.config/{}", v.into_string().unwrap(), package_name
208
- ),
209
- None => panic!("can't found any user")
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()?
210
148
  };
211
- #[cfg(target_os = "linux")]
212
- let data_path = std::path::PathBuf::from(&config_path);
213
- #[cfg(target_os = "linux")]
214
- if !std::path::Path::new(&data_path).exists() {
215
- std::fs::create_dir(&data_path)
216
- .unwrap_or_else(|_| panic!("can't create dir {}", &config_path));
217
- }
218
- #[cfg(target_os = "linux")]
219
- let mut web_content = WebContext::new(Some(data_path));
220
- #[cfg(target_os = "linux")]
221
- let webview = WebViewBuilder::new(window)?
222
- // .with_user_agent(user_agent_string)
223
- // .with_accept_first_mouse(true)
224
- .with_url(&url.to_string())?
225
- .with_devtools(cfg!(feature = "devtools"))
226
- .with_initialization_script(include_str!("pake.js"))
227
- .with_ipc_handler(handler)
228
- .with_web_context(&mut web_content)
229
- // .with_back_forward_navigation_gestures(true)
230
- .build()?;
231
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
+ };
232
178
  #[cfg(feature = "devtools")]
233
179
  {
234
180
  webview.open_devtools();
@@ -55,6 +55,18 @@ window.addEventListener("DOMContentLoaded", (_event) => {
55
55
  padding-top: 20px;
56
56
  }
57
57
 
58
+ #__next .overflow-hidden .flex.flex-1.flex-col {
59
+ padding-left: 0;
60
+ }
61
+
62
+ #__next .overflow-hidden>.hidden.bg-gray-900 {
63
+ display: none;
64
+ }
65
+
66
+ #__next .overflow-hidden main .absolute .text-xs{
67
+ visibility: hidden;
68
+ }
69
+
58
70
  .lark > .dashboard-sidebar, .lark > .dashboard-sidebar > .sidebar-user-info , .lark > .dashboard-sidebar .index-module_wrapper_F-Wbq{
59
71
  padding-top:15px;
60
72
  }
@@ -200,10 +212,8 @@ window.addEventListener("DOMContentLoaded", (_event) => {
200
212
  left: 1px !important;
201
213
  }
202
214
 
203
- #react-root [data-testid="SideNav_NewTweet_Button"] {
204
- position: fixed !important;
205
- right: 16px !important;
206
- bottom: 24px !important;
215
+ #react-root [data-testid="SideNav_NewTweet_Button"], #react-root [aria-label="Twitter Blue"]{
216
+ display: none;
207
217
  }
208
218
  }
209
219
 
@@ -306,16 +316,16 @@ window.addEventListener("DOMContentLoaded", (_event) => {
306
316
  document.addEventListener("click", (e) => {
307
317
  const origin = e.target.closest("a");
308
318
  if (origin && origin.href) {
319
+ const target = origin.target
309
320
  origin.target = "_self";
321
+ const hrefUrl = new URL(origin.href)
310
322
 
311
- //额外处理下 twitter 的外跳,对于其他需要外跳的可以改这里成对应域名
312
- const href = origin.href;
313
323
  if (
314
- location.host === "twitter.com" &&
315
- href.indexOf("twitter.com") === -1
324
+ window.location.host !== hrefUrl.host && // 如果 a 标签内链接的域名和当前页面的域名不一致 且
325
+ target === '_blank' // a 标签内链接的 target 属性为 _blank 时
316
326
  ) {
317
327
  e.preventDefault();
318
- window.ipc.postMessage(`open_browser:${href}`);
328
+ window.ipc.postMessage(`open_browser:${origin.href}`);
319
329
  }
320
330
  }
321
331
  });