diff --git a/README.md b/README.md index e27b19d..e0ca2ad 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ - **投稿圖片**:可以上傳你覺得適合放上小卡的圖,每天最多 5 張,可以附上出處;管理員審核通過後加入圖庫,出處會小小地寫在小卡圖片的右下角 - **個人頁**:名稱、大頭貼、自我介紹(支援 Markdown),在自己的個人頁按「編輯」修改 - **稱號**:管理員可以幫指定的 UID 加上顏色和稱號 +- **UID 搜尋**:在選單上方輸入 UID 按 Enter,直接打開那個人的個人頁 - **加到主畫面**:手機上可以安裝到桌面,像 App 一樣打開 - **語言**:繁體中文、简体中文、日本語、한국어、English @@ -46,3 +47,5 @@ clone 之後要改哪裡、怎麼部署:[make.md](make.md) ## 技術 FastAPI + SQLite,小卡用 Pillow 在伺服器端畫成 PNG;前端是不用框架的 HTML / CSS / JavaScript。整包跑在一個 Docker 容器裡,透過 Cloudflare Tunnel 對外。 + +原始碼:[GitHub](https://github.com/Sthkm3/ZhiwuProject)、[Gitea](https://gitea.sthkm3.org/sthkm3/ZhiwuProject) diff --git a/server/app/__init__.py b/server/app/__init__.py index 17a6e24..6b83ed6 100644 --- a/server/app/__init__.py +++ b/server/app/__init__.py @@ -1,2 +1,2 @@ """版本號只寫在這裡,頁尾會顯示;發布新版本時改這一行。""" -__version__ = "1.1.0" +__version__ = "1.2.0" diff --git a/server/tests/test_guest.py b/server/tests/test_guest.py index 36346d2..752dca0 100644 --- a/server/tests/test_guest.py +++ b/server/tests/test_guest.py @@ -127,3 +127,17 @@ def test_new_copy(client): for lang in config.LANGS: # 每個語系都要有新加的字 d = client.get(f"/assets/i18n/{lang}.json").json() assert set(zh) == set(d), (lang, set(zh) ^ set(d)) + + +def test_uid_search_and_oss_links(client): + html = client.get("/").text + assert 'id="uid-input"' in html + start = html.index('id="uid-search"') + assert start < html.index('id="menu-toggle"') # 在 ☰ 左邊 + form = html[start:html.index("", start)] + assert " { + ev.preventDefault(); + const n = $("uid-input").value.trim(); + if (!/^\d{1,8}$/.test(n)) return toast(t("search.invalid")); + location.href = `/u/${n.padStart(8, "0")}`; + }); +} + // ---------- 手機選單 ---------- function openMenu() { $("sidebar").classList.add("open"); } @@ -1245,6 +1256,7 @@ async function init() { bindUpload(); bindReview(); bindNotices(); + bindSearch(); $("menu-toggle").addEventListener("click", () => $("sidebar").classList.toggle("open")); diff --git a/web/i18n/en.json b/web/i18n/en.json index 42215fb..d6cb2c3 100644 --- a/web/i18n/en.json +++ b/web/i18n/en.json @@ -1,5 +1,9 @@ { "lang.label": "Language", + "search.label": "Search by UID", + "search.placeholder": "Enter UID", + "search.invalid": "Enter a UID of 1–8 digits", + "oss.label": "Source code", "menu": "Menu", "auth.heading": "Log in / Sign up", "auth.hint": "We'll email you a code. Your account is created the first time you log in.", diff --git a/web/i18n/ja.json b/web/i18n/ja.json index 2388821..bf986eb 100644 --- a/web/i18n/ja.json +++ b/web/i18n/ja.json @@ -1,5 +1,9 @@ { "lang.label": "言語", + "search.label": "UID で検索", + "search.placeholder": "UID を入力", + "search.invalid": "1〜8 桁の数字で UID を入力してください", + "oss.label": "ソースコード", "menu": "メニュー", "auth.heading": "ログイン / 登録", "auth.hint": "メールアドレスに認証コードを送ります。初回ログイン時にアカウントが作成されます。", diff --git a/web/i18n/ko.json b/web/i18n/ko.json index 9ad2378..fc82cc7 100644 --- a/web/i18n/ko.json +++ b/web/i18n/ko.json @@ -1,5 +1,9 @@ { "lang.label": "언어", + "search.label": "UID로 검색", + "search.placeholder": "UID 입력", + "search.invalid": "1~8자리 숫자 UID를 입력해 주세요", + "oss.label": "오픈 소스 링크", "menu": "메뉴", "auth.heading": "로그인 / 가입", "auth.hint": "이메일로 인증 코드를 보내드립니다. 처음 로그인하면 계정이 자동으로 만들어집니다.", diff --git a/web/i18n/zh-CN.json b/web/i18n/zh-CN.json index af4fe92..b86894d 100644 --- a/web/i18n/zh-CN.json +++ b/web/i18n/zh-CN.json @@ -1,5 +1,9 @@ { "lang.label": "语言", + "search.label": "用 UID 搜索", + "search.placeholder": "输入 UID", + "search.invalid": "请输入 1~8 位数字的 UID", + "oss.label": "开源链接", "menu": "菜单", "auth.heading": "登录 / 注册", "auth.hint": "输入邮箱接收验证码,第一次登录会自动创建账号。", diff --git a/web/i18n/zh-TW.json b/web/i18n/zh-TW.json index 3968178..6caa92c 100644 --- a/web/i18n/zh-TW.json +++ b/web/i18n/zh-TW.json @@ -1,5 +1,9 @@ { "lang.label": "語言", + "search.label": "用 UID 搜尋", + "search.placeholder": "輸入 UID", + "search.invalid": "請輸入 1~8 位數字的 UID", + "oss.label": "開源連結", "menu": "選單", "auth.heading": "登入 / 註冊", "auth.hint": "輸入信箱收驗證碼,第一次登入會自動建立帳號。", diff --git a/web/index.html b/web/index.html index dee8566..ee2721d 100644 --- a/web/index.html +++ b/web/index.html @@ -20,6 +20,9 @@ diff --git a/web/style.css b/web/style.css index fa77190..9bcb284 100644 --- a/web/style.css +++ b/web/style.css @@ -125,7 +125,15 @@ button.link:disabled { color: var(--muted); } .title-form .grow { flex: 1; min-width: 0; } .title-form input[type=color] { width: 64px; height: 44px; padding: 4px; cursor: pointer; } -.lang { margin-top: auto; } +/* UID 搜尋:電腦在品牌下面一整行;手機在 ☰ 左邊(見下面的 @media) */ +.brand { flex-wrap: wrap; gap: 12px; } +.uid-search { flex: 1 1 100%; } +.uid-search input { padding: 8px 12px; } + +/* 側欄最底下:語言與開源連結 */ +.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; } +.oss-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 14px; color: var(--muted); } +.oss-links span { width: 100%; } /* ---------- 主畫面 ---------- */ #main { flex: 1; min-width: 0; padding: 40px 24px 24px; display: flex; flex-direction: column; align-items: center; } @@ -421,6 +429,10 @@ dialog h2 { margin: 0 0 4px; } .layout { flex-direction: column; } #sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); padding: 12px 16px; gap: 12px; } .only-mobile { display: inline-flex; } + .brand { flex-wrap: nowrap; } + .uid-search { flex: 1 1 0; min-width: 80px; max-width: 160px; margin-left: auto; } + .brand a, .brand-text { min-width: 0; } /* 螢幕太窄時標語用「…」截斷,不擠掉搜尋框 */ + .brand-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } #sidebar:not(.open) #sidebar-body { display: none; } #sidebar-body { padding-bottom: 8px; } #main { padding: 24px 16px 20px; }