r0x0r / pywebview

Build GUI for your Python program with JavaScript, HTML, and CSS
https://pywebview.flowrl.com
BSD 3-Clause "New" or "Revised" License
4.67k stars 544 forks source link

mermaid diagrams cannot be displayed locally #1412

Closed kxmatjob closed 1 month ago

kxmatjob commented 3 months ago

Specification

Description

# -*- coding: utf-8 -*-
import webview
webview.create_window('Hello world', 'test2.html')
webview.create_window('Hello world', 'test3.html')
webview.start()

test2.html used <script src="C:/Users/Administrator/node_modules/mermaid/dist/mermaid.min.js"></script> displayed failed, But it can be displayed in Chrome. the mermaid install by npm, it version is 9.0.1 then i cannot find reason, thanks for your help :)

test3.html used <script src="https://cdn.jsdelivr.net/npm/mermaid@8.13.4/dist/mermaid.min.js"></script> displayed success

   <!DOCTYPE html>
   <html lang="en">
   <head>
       <meta charset="UTF-8">
       <title>Mermaid in PyWebView</title>
       <!-- Mermaid JS -->
       <script src="https://cdn.jsdelivr.net/npm/mermaid@8.13.4/dist/mermaid.min.js"></script>
   </head>
   <body>
       <!-- Mermaid -->
       <div class="mermaid">
            graph TD
            start_proc[start]-->detecting[sys check]
            detecting-->reachable{dest ip is ok}
            reachable--IP ok-->detecting

            reachable--IP bad-->confirm[run program]

            confirm--switch-->wechat_or_sms{select sms or wechat}

            wechat_or_sms--0-->send_sms[send sms]
            wechat_or_sms--1-->send_wechat[send wechat]

            send_sms-->shutdown
            send_wechat-->shutdown[run]
            shutdown-->end_proc>end]
       </div>

       <script>
           // init
           mermaid.initialize({startOnLoad:true});
       </script>
   </body>
   </html>
r0x0r commented 3 months ago

test2 launches a http server so local path C:/Users/Administrator/node_modules/mermaid/dist/ is not available. You may access local paths by using a full path name of test3.html.

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 month ago

The message to post on the issue when closing it. If none provided, will not comment when closing an issue.