Просмотр исходного кода

issues #192 add MicrosoftEdgeWebview2Setup and fix the "VCRUNTIME140.dll Is Missing" error on windows server 2022

elilchen лет назад: 3
Родитель
Сommit
ad40d65070
10 измененных файлов с 35 добавлено и 8 удалено
  1. 7 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 3 0
      build.rs
  4. 7 0
      ui/Cargo.lock
  5. 2 1
      ui/Cargo.toml
  6. 2 1
      ui/build.rs
  7. 2 1
      ui/html/main.js
  8. 9 4
      ui/setup.nsi
  9. 1 0
      ui/src/adapter/view/desktop.rs
  10. 1 1
      ui/tauri.conf.json

+ 7 - 0
Cargo.lock

@@ -816,6 +816,7 @@ dependencies = [
816
  "serde_json",
816
  "serde_json",
817
  "sodiumoxide",
817
  "sodiumoxide",
818
  "sqlx",
818
  "sqlx",
819
+ "static_vcruntime",
819
  "tokio-tungstenite",
820
  "tokio-tungstenite",
820
  "tower-http",
821
  "tower-http",
821
  "tungstenite",
822
  "tungstenite",
@@ -2092,6 +2093,12 @@ version = "1.1.0"
2092
 source = "registry+https://github.com/rust-lang/crates.io-index"
2093
 source = "registry+https://github.com/rust-lang/crates.io-index"
2093
 checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
2094
 checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
2094
 
2095
 
2096
+[[package]]
2097
+name = "static_vcruntime"
2098
+version = "2.0.0"
2099
+source = "registry+https://github.com/rust-lang/crates.io-index"
2100
+checksum = "954e3e877803def9dc46075bf4060147c55cd70db97873077232eae0269dc89b"
2101
+
2095
 [[package]]
2102
 [[package]]
2096
 name = "stringprep"
2103
 name = "stringprep"
2097
 version = "0.1.2"
2104
 version = "0.1.2"

+ 1 - 0
Cargo.toml

@@ -54,6 +54,7 @@ ping = "0.4.0"
54
 
54
 
55
 [build-dependencies]
55
 [build-dependencies]
56
 hbb_common = { path = "libs/hbb_common" }
56
 hbb_common = { path = "libs/hbb_common" }
57
+static_vcruntime = "2.0"
57
 
58
 
58
 [workspace]
59
 [workspace]
59
 members = ["libs/hbb_common"]
60
 members = ["libs/hbb_common"]

+ 3 - 0
build.rs

@@ -1,3 +1,6 @@
1
 fn main() {
1
 fn main() {
2
     hbb_common::gen_version();
2
     hbb_common::gen_version();
3
+    if cfg!(target_os = "windows") {
4
+        static_vcruntime::metabuild();
5
+    }
3
 }
6
 }

+ 7 - 0
ui/Cargo.lock

@@ -2324,6 +2324,7 @@ dependencies = [
2324
  "once_cell",
2324
  "once_cell",
2325
  "serde",
2325
  "serde",
2326
  "serde_json",
2326
  "serde_json",
2327
+ "static_vcruntime",
2327
  "tauri",
2328
  "tauri",
2328
  "tauri-build",
2329
  "tauri-build",
2329
  "windows-service",
2330
  "windows-service",
@@ -2625,6 +2626,12 @@ dependencies = [
2625
  "loom",
2626
  "loom",
2626
 ]
2627
 ]
2627
 
2628
 
2629
+[[package]]
2630
+name = "static_vcruntime"
2631
+version = "2.0.0"
2632
+source = "registry+https://github.com/rust-lang/crates.io-index"
2633
+checksum = "954e3e877803def9dc46075bf4060147c55cd70db97873077232eae0269dc89b"
2634
+
2628
 [[package]]
2635
 [[package]]
2629
 name = "string_cache"
2636
 name = "string_cache"
2630
 version = "0.8.4"
2637
 version = "0.8.4"

+ 2 - 1
ui/Cargo.toml

@@ -1,6 +1,6 @@
1
 [package]
1
 [package]
2
 name = "rustdesk_server"
2
 name = "rustdesk_server"
3
-version = "0.1.1"
3
+version = "0.1.2"
4
 description = "rustdesk server gui"
4
 description = "rustdesk server gui"
5
 authors = ["elilchen"]
5
 authors = ["elilchen"]
6
 edition = "2021"
6
 edition = "2021"
@@ -8,6 +8,7 @@ edition = "2021"
8
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9
 
9
 
10
 [build-dependencies]
10
 [build-dependencies]
11
+static_vcruntime = "2.0"
11
 tauri-build = { version = "1.2", features = [] }
12
 tauri-build = { version = "1.2", features = [] }
12
 winres = "0.1"
13
 winres = "0.1"
13
 
14
 

+ 2 - 1
ui/build.rs

@@ -1,5 +1,5 @@
1
 fn main() {
1
 fn main() {
2
-  tauri_build::build();
2
+    tauri_build::build();
3
     if cfg!(target_os = "windows") {
3
     if cfg!(target_os = "windows") {
4
         let mut res = winres::WindowsResource::new();
4
         let mut res = winres::WindowsResource::new();
5
         res.set_icon("icons\\icon.ico");
5
         res.set_icon("icons\\icon.ico");
@@ -17,5 +17,6 @@ fn main() {
17
 "#,
17
 "#,
18
         );
18
         );
19
         res.compile().unwrap();
19
         res.compile().unwrap();
20
+        static_vcruntime::metabuild();
20
     }
21
     }
21
 }
22
 }

+ 2 - 1
ui/html/main.js

@@ -22,13 +22,14 @@ class View {
22
         event.listen('__update__', this.appAction.bind(this));
22
         event.listen('__update__', this.appAction.bind(this));
23
         event.emit('__action__', '__init__');
23
         event.emit('__action__', '__init__');
24
         while (true) {
24
         while (true) {
25
+            let now = Date.now();
25
             try {
26
             try {
26
                 await this.update();
27
                 await this.update();
27
                 this.render();
28
                 this.render();
28
             } catch (e) {
29
             } catch (e) {
29
                 console.error(e);
30
                 console.error(e);
30
             }
31
             }
31
-            await new Promise(r => setTimeout(r, 100));
32
+            await new Promise(r => setTimeout(r, Math.max(0, 33 - (Date.now() - now))));
32
         }
33
         }
33
     }
34
     }
34
     async update() {
35
     async update() {

+ 9 - 4
ui/setup.nsi

@@ -67,7 +67,7 @@ Section "Install"
67
   nsExec::Exec 'sc stop hbbr'
67
   nsExec::Exec 'sc stop hbbr'
68
   nsExec::Exec 'sc stop hbbs'
68
   nsExec::Exec 'sc stop hbbs'
69
   nsExec::Exec 'taskkill /F /IM ${PRODUCT_NAME}.exe'
69
   nsExec::Exec 'taskkill /F /IM ${PRODUCT_NAME}.exe'
70
-  Sleep 500 ;
70
+  Sleep 500
71
 
71
 
72
   SetOutPath $INSTDIR
72
   SetOutPath $INSTDIR
73
   File /r "setup\*.*"
73
   File /r "setup\*.*"
@@ -77,12 +77,12 @@ Section "Install"
77
   CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
77
   CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
78
   CreateShortCut "$SMPROGRAMS\${APP_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe"
78
   CreateShortCut "$SMPROGRAMS\${APP_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe"
79
   CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
79
   CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
80
-  CreateShortCut "$SMSTARTUP\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
81
 
80
 
82
   nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=in action=allow program="$INSTDIR\hbbs.exe" enable=yes'
81
   nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=in action=allow program="$INSTDIR\hbbs.exe" enable=yes'
83
   nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=out action=allow program="$INSTDIR\hbbs.exe" enable=yes'
82
   nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=out action=allow program="$INSTDIR\hbbs.exe" enable=yes'
84
   nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=in action=allow program="$INSTDIR\hbbr.exe" enable=yes'
83
   nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=in action=allow program="$INSTDIR\hbbr.exe" enable=yes'
85
   nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=out action=allow program="$INSTDIR\hbbr.exe" enable=yes'
84
   nsExec::Exec 'netsh advfirewall firewall add rule name="${APP_NAME}" dir=out action=allow program="$INSTDIR\hbbr.exe" enable=yes'
85
+  ExecWait 'powershell.exe -NoProfile -windowstyle hidden try { [System.Net.ServicePointManager]::SecurityProtocol = [System.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 ($\'/silent$\', $\'/install$\') -Wait'
86
 SectionEnd
86
 SectionEnd
87
 
87
 
88
 Section "Uninstall"
88
 Section "Uninstall"
@@ -90,7 +90,7 @@ Section "Uninstall"
90
   nsExec::Exec 'sc stop hbbr'
90
   nsExec::Exec 'sc stop hbbr'
91
   nsExec::Exec 'sc stop hbbs'
91
   nsExec::Exec 'sc stop hbbs'
92
   nsExec::Exec 'taskkill /F /IM ${PRODUCT_NAME}.exe'
92
   nsExec::Exec 'taskkill /F /IM ${PRODUCT_NAME}.exe'
93
-  Sleep 500 ;
93
+  Sleep 500
94
 
94
 
95
   RMDir /r "$SMPROGRAMS\${APP_NAME}"
95
   RMDir /r "$SMPROGRAMS\${APP_NAME}"
96
   Delete "$SMSTARTUP\${APP_NAME}.lnk"
96
   Delete "$SMSTARTUP\${APP_NAME}.lnk"
@@ -98,11 +98,16 @@ Section "Uninstall"
98
   nsExec::Exec 'sc delete hbbr'
98
   nsExec::Exec 'sc delete hbbr'
99
   nsExec::Exec 'sc delete hbbs'
99
   nsExec::Exec 'sc delete hbbs'
100
   nsExec::Exec 'netsh advfirewall firewall delete rule name="${APP_NAME}"'
100
   nsExec::Exec 'netsh advfirewall firewall delete rule name="${APP_NAME}"'
101
+  RMDir /r "$INSTDIR\bin"
102
+  RMDir /r "$INSTDIR\logs"
103
+  RMDir /r "$INSTDIR\service"
104
+  Delete "$INSTDIR\${PRODUCT_NAME}.exe"
105
+  Delete "$INSTDIR\uninstall.exe"
101
 SectionEnd
106
 SectionEnd
102
 
107
 
103
 ####################################################################
108
 ####################################################################
104
 # Functions
109
 # Functions
105
 
110
 
106
 Function CreateStartupShortcut
111
 Function CreateStartupShortcut
107
-  CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
112
+  CreateShortCut "$SMSTARTUP\${APP_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe"
108
 FunctionEnd
113
 FunctionEnd

+ 1 - 0
ui/src/adapter/view/desktop.rs

@@ -59,6 +59,7 @@ pub async fn run(sender: Sender<Event>, receiver: Receiver<Event>) {
59
             // }
59
             // }
60
             WindowEvent::CloseRequested { api, .. } => {
60
             WindowEvent::CloseRequested { api, .. } => {
61
                 api.prevent_close();
61
                 api.prevent_close();
62
+                event.window().minimize().unwrap();
62
                 event.window().hide().unwrap();
63
                 event.window().hide().unwrap();
63
             }
64
             }
64
             _ => {}
65
             _ => {}

+ 1 - 1
ui/tauri.conf.json

@@ -47,7 +47,7 @@
47
         "icons/icon.icns",
47
         "icons/icon.icns",
48
         "icons/icon.ico"
48
         "icons/icon.ico"
49
       ],
49
       ],
50
-      "identifier": "rustdesk_server",
50
+      "identifier": "rustdesk.server",
51
       "longDescription": "",
51
       "longDescription": "",
52
       "macOS": {
52
       "macOS": {
53
         "entitlements": null,
53
         "entitlements": null,