diff --git a/.gitignore b/.gitignore index 4bdd4f7..ce38e9a 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,5 @@ venv.bak/ # IDEs and editors idea/ -# etc \ No newline at end of file +# etc +config.toml \ No newline at end of file diff --git a/debug/test.html b/debug/test.html new file mode 100644 index 0000000..b3c37dc --- /dev/null +++ b/debug/test.html @@ -0,0 +1,18 @@ + + + + + + + Test Document + + + +
+ + + + + \ No newline at end of file diff --git a/server/main.py b/server/main.py index 5e9fc09..d34d3c5 100644 --- a/server/main.py +++ b/server/main.py @@ -125,9 +125,14 @@ async def init(key: str): return 0 +@app.get("/loader.js") +async def loader(): + return templates.TemplateResponse("loader.js", {"request": {}}) + + @app.get("/{route:path}") async def show(route: str = "", session: Annotated[str | None, Cookie()] = None): - if (await check_token(session) != ""): + if (session is not None and await check_token(session) != ""): islogin = 1 else: islogin = 0 diff --git a/src/loader.js b/src/loader.js new file mode 100644 index 0000000..c2a4c0b --- /dev/null +++ b/src/loader.js @@ -0,0 +1,11 @@ +window.addEventListener('message', function (event) { + if (event.data.sacn_height) { + const iframe = document.getElementById('sacn_comments'); + iframe.style.height = event.data.sacn_height + 'px'; + } +}); +function load_comments(route) { + var tmpl = `` + document.getElementById('sacn_comments').outerHTML = tmpl; +} \ No newline at end of file diff --git a/src/page.html b/src/page.html index 0b619b6..8ee65ed 100644 --- a/src/page.html +++ b/src/page.html @@ -18,6 +18,15 @@ padding: 0; min-width: 320px; max-width: 700px; + margin: 0 auto; + } + + .root { + margin: 0; + padding: 0; + min-width: 320px; + max-width: 700px; + margin: 0 auto; } .main-card { @@ -139,139 +148,149 @@ -
- -
- - - - - -
-
- -
+
+
+ +
+ + + + + +
+
+ +
+
+
+ + + 共 0 条评论 + 发送 + + {% if islogin==1 %} + + + {% else %} + + + {% endif %} +
+
+ 点我显示更多 +
- - - 共 0 条评论 - 发送 - - {% if islogin==1 %} - - - {% else %} - - - {% endif %} - -
-
- 点我显示更多 -
- - + function next_page() { + var xhr = new XMLHttpRequest(); + xhr.open("GET", "/api/comments?route={{route}}&page=" + page); + xhr.onreadystatechange = function () { + if (xhr.readyState == 4 && xhr.status == 200) { + var obj = JSON.parse(xhr.responseText); + add(obj); + document.getElementById("comments_show_cnt").innerHTML = "共 " + obj.count + " 条评论"; + + if (page * 5 >= obj.count) { + document.getElementsByClassName("show-more-card")[0].classList.add("hides") + } + page++; + } + } + xhr.send(); + } + next_page() + + + \ No newline at end of file