ソースを参照

forgotten files

Rodja Trappe 2 年 前
コミット
14b464884e
2 ファイル変更18 行追加6 行削除
  1. 4 0
      main.py
  2. 14 6
      nicegui/templates/index.html

+ 4 - 0
main.py

@@ -9,6 +9,10 @@ from website import demo_card, reference
 from website.constants import ACCENT_COLOR, HEADER_HEIGHT, STATIC
 from website.example import bash_window, python_window
 
+ACCENT_COLOR = '#428BF5'
+HEADER_HEIGHT = '70px'
+STATIC = Path(__file__).parent / 'website' / 'static'
+
 ui.add_static_files('/favicon', Path(__file__).parent / 'website' / 'favicon')
 
 

+ 14 - 6
nicegui/templates/index.html

@@ -2,16 +2,17 @@
 <html>
   <head>
     <title>{{ title }}</title>
-    <script src="/static/socket.io.min.js"></script>
+    <base href="{{ prefix | safe }}/" />
+    <script src="static/socket.io.min.js"></script>
     <link rel="shortcut icon" href="{{ favicon_url }}" />
-    <link href="/static/fonts.css" rel="stylesheet" type="text/css" />
-    <link href="/static/quasar.prod.css" rel="stylesheet" type="text/css" />
-    <script src="/static/tailwind.min.js"></script>
+    <link href="static/fonts.css" rel="stylesheet" type="text/css" />
+    <link href="static/quasar.prod.css" rel="stylesheet" type="text/css" />
+    <script src="static/tailwind.min.js"></script>
     {{ head_html | safe }}
   </head>
   <body>
-    <script src="/static/vue.global.prod.js"></script>
-    <script src="/static/quasar.umd.prod.js"></script>
+    <script src="static/vue.global.prod.js"></script>
+    <script src="static/quasar.umd.prod.js"></script>
 
     {{ body_html | safe }}
 
@@ -67,6 +68,13 @@
         }
       }
 
+      function get_websocket_url() {
+        const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
+        const port = window.location.port ? ':' + window.location.port : '';
+        const host = window.location.host;
+        return protocol + '//' + host + ':' + port;
+      }
+
       const app = Vue.createApp({
         data() {
           return {