sciter-sdk / rust-sciter

Rust bindings for Sciter
https://sciter.com
MIT License
806 stars 76 forks source link

Not support include relative_path in tiscript On Windows #116

Closed dobefore closed 3 years ago

dobefore commented 3 years ago
some.html
   <script  type="text/tiscript" >
 include "some.tis"
 </script >

It come with this

WARNING:DOM: failed to load "//chgetitle.tis" file, error=161
ERROR:TIS: Error: File not found - file://chgetitle.tis
ERROR:TIS:      at undefined

my file tree

├─src
│  ├─bin
│  └─ui
│      └─some.html
       |__some.tis
   |__main.rs (run app)

IS there some problem? Yet,using absolute path (like D:/A/B/some.tis) will work.

Thus,after packing it (exe),openning it somewhere else and losing original path will cause layout err,seem like no tis applied.

pravic commented 3 years ago

Yes, starting some Sciter version, it requires the main html (some.html in your case) to be loaded via an absolute path. Then its dependent resources (like some.tis or CSS) will be resolved properly.

pravic commented 3 years ago

Use load_file with absolute path or pack everything in a Sciter archive.

pravic commented 3 years ago

after packing it (exe),openning it somewhere else and losing original path

Pack not only some.html but everything. Either in a Sciter archive or as include_bytes! + a custom HostHandler.

dobefore commented 3 years ago

Thanks for your reply.It works. Yet,I run cargo build to pack ,then run it,.the app will still need external html dependency. Is there a way just to pack html.tis resources into a standalone exe> Will cargo-bundle be a choice?

dobefore commented 3 years ago

Pack not only some.html but everything. Either in a Sciter archive or as include_bytes! + a custom HostHandler.

Oh~~,This is fantastic!folowing your advice,a standalone exe can run perfectly. Thanks @pravic Here are my code just a bit dirrerent from doc from document

//use WindowBuilder instead of Window
let mut frame = sciter::WindowBuilder::main_window()
    .with_size((700, 500))
    .fixed()
        .debug()
        .create();

let archive=include_bytes!("../target/ui.rc");
    // frame.load_html(html, None);
    frame.archive_handler(archive).expect("Unable to load archive");

//use load_file instead of load() 
frame.load_file("this://app/ui.html");