Browse Source

add warning of old version of web framework integration

wangweimin 4 năm trước cách đây
mục cha
commit
d1abb03299
3 tập tin đã thay đổi với 7 bổ sung0 xóa
  1. 4 0
      pywebio/html/index.html
  2. 2 0
      test/12.cors.py
  3. 1 0
      test/template.py

+ 4 - 0
pywebio/html/index.html

@@ -21,6 +21,10 @@
 <div class="pywebio">
     <div class="container no-fix-height" id="output-container">
         <div class="markdown-body" id="markdown-body">
+            <div class="alert alert-warning" role="alert">
+                警告:您正在使用旧版本的方式来实现PyWebIO与Web框架整合,此方式在当前版本中已经不被推荐,并在将来可能会被移除。<br/>
+                请访问<a href="https://pywebio.readthedocs.io/zh_CN/latest/guide.html#web" target="_blank" class="alert-link">此处</a>来查看新版本PyWebIO中与Web框架整合更简单的方式。
+            </div>
             <div id="pywebio-scope-ROOT"></div>
         </div>
         <div id="end-space"></div>

+ 2 - 0
test/12.cors.py

@@ -8,9 +8,11 @@ import template
 import util
 from pywebio.input import *
 from pywebio.utils import run_as_function
+from pywebio.session import run_js
 
 
 def target():
+    run_js("$('#markdown-body>.alert-warning').remove()")
     template.basic_output()
     template.background_output()
 

+ 1 - 0
test/template.py

@@ -741,6 +741,7 @@ def save_output(browser: Chrome, filename=None, process_func=None):
     html = re.sub(r"WebIO.pushData\(.*?\)", '', html)
     html = re.sub(r"</(.*?)>", r'</\g<1>>\n', html)  # 进行断行方便后续的diff判断
     html = html.replace('"opacity: 1;"', '').replace(' open=""', '')  # so wired
+    html = html.strip()
     if process_func:
         html = process_func(html)
     if filename: