ZHIWEI666 commited on
Commit
1452ed3
·
verified ·
1 Parent(s): c796a73

新增手机访问地址

Browse files
Files changed (3) hide show
  1. app.py +10 -0
  2. 移动端网页/index.html +41 -0
  3. 移动端网页/web_main.js +23 -0
app.py CHANGED
@@ -711,3 +711,13 @@ async def set_system_config(config_key: str, value: dict, current_user: str = De
711
  # ==========================================
712
  from fastapi.staticfiles import StaticFiles
713
  app.mount("/admin", StaticFiles(directory="管理界面", html=True), name="admin")
 
 
 
 
 
 
 
 
 
 
 
711
  # ==========================================
712
  from fastapi.staticfiles import StaticFiles
713
  app.mount("/admin", StaticFiles(directory="管理界面", html=True), name="admin")
714
+
715
+ # ==========================================
716
+ # 📱 移动端网页静态挂载(复用前端的 Web 版)
717
+ # 部署约定:同步 HF Space 时,除本目录内容外,
718
+ # 须将仓库根目录的 前端页面/ 整个目录一并复制到 Space 仓库根目录
719
+ # /m/assets 提供共享前端模块;/m 返回 移动端网页/index.html
720
+ # ⚠️ 必须放在所有 API 路由之后;先挂载更具体的 /m/assets,再挂载 /m
721
+ # ==========================================
722
+ app.mount("/m/assets", StaticFiles(directory="前端页面"), name="web_assets")
723
+ app.mount("/m", StaticFiles(directory="移动端网页", html=True), name="mobile_web")
移动端网页/index.html ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <!-- 📱 移动端视口:禁止双击缩放,适配刘海屏安全区 -->
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover">
7
+ <!-- 空 icon 链接:抑制浏览器默认 favicon 请求产生的 404 -->
8
+ <link rel="icon" href="data:,">
9
+ <title>ComfyUI 社区精选</title>
10
+ <style>
11
+ /* 🎨 补齐 ComfyUI 同名 CSS 变量(前端组件统一引用这些变量渲染暗色主题) */
12
+ :root {
13
+ --comfy-menu-bg: #202020;
14
+ --comfy-input-bg: #2a2a2a;
15
+ --input-text: #eee;
16
+ --fg-color: #fff;
17
+ --border-color: #444;
18
+ color-scheme: dark;
19
+ }
20
+ html, body {
21
+ margin: 0;
22
+ padding: 0;
23
+ height: 100%;
24
+ background: #1a1a1a;
25
+ overscroll-behavior: none;
26
+ }
27
+ #hub-web-root {
28
+ height: 100vh;
29
+ height: 100dvh;
30
+ display: flex;
31
+ flex-direction: column;
32
+ }
33
+ </style>
34
+ <!-- ⚠️ 必须在任何 ES Module 求值前置位 Web 模式标记(全局配置.js 的 IS_WEB_MODE 在模块加载时读取) -->
35
+ <script>window.__RANKING_WEB_MODE__ = true;</script>
36
+ <script type="module" src="./web_main.js"></script>
37
+ </head>
38
+ <body>
39
+ <div id="hub-web-root"></div>
40
+ </body>
41
+ </html>
移动端网页/web_main.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // 云端Space代码/移动端网页/web_main.js
2
+ // ==========================================
3
+ // 📱 移动端网页版引导模块
4
+ // ==========================================
5
+ // 复用 /m/assets/ 下的共享前端(与本地 ComfyUI 侧边栏同一套代码),
6
+ // 直接调用主程序构建 DOM,不经过 侧边栏入口注册.js(该文件依赖 ComfyUI 扩展 API)。
7
+ // window.__RANKING_WEB_MODE__ 已由 index.html 内联脚本在模块求值前置位。
8
+ // ==========================================
9
+
10
+ import { buildSidebarDOM } from "/m/assets/core/侧边栏主程序.js";
11
+
12
+ const root = document.getElementById("hub-web-root");
13
+ try {
14
+ const dom = await buildSidebarDOM();
15
+ root.appendChild(dom);
16
+ } catch (e) {
17
+ console.error("移动端网页加载失败:", e);
18
+ const tip = document.createElement('div');
19
+ tip.style.cssText = "text-align:center; padding:40px; color:#F44336;";
20
+ tip.textContent = '⚠️ 加载失败,请刷新重试';
21
+ root.textContent = '';
22
+ root.appendChild(tip);
23
+ }