浏览代码

fix the assets head path (#2267)

Evan Almloff 1 年之前
父节点
当前提交
40b576894f
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      packages/desktop/src/protocol.rs

+ 8 - 2
packages/desktop/src/protocol.rs

@@ -81,8 +81,14 @@ fn assets_head() -> Option<String> {
         target_os = "openbsd"
     ))]
     {
-        let head = crate::protocol::get_asset_root_or_default();
-        let head = head.join("dist").join("__assets_head.html");
+        let root = crate::protocol::get_asset_root_or_default();
+        let assets_head_path = "__assets_head.html";
+        let mut head = root.join(assets_head_path);
+        // If we can't find it, add the dist directory and try again
+        // When bundling we currently copy the whole dist directory to the output directory instead of the individual files because of a limitation of cargo bundle2
+        if !head.exists() {
+            head = root.join("dist").join(assets_head_path);
+        }
         match std::fs::read_to_string(&head) {
             Ok(s) => Some(s),
             Err(err) => {