1 Commits
Author SHA1 Message Date
Sahik 695e29324e 新增搜尋框,放兩個開源連結 2026-12-01 03:44:06 +08:00
11 changed files with 82 additions and 11 deletions

No files matched your search

+3
View File
@@ -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)
+1 -1
View File
@@ -1,2 +1,2 @@
"""版本號只寫在這裡,頁尾會顯示;發布新版本時改這一行。"""
__version__ = "1.1.0"
__version__ = "1.2.0"
+14
View File
@@ -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("</form>", start)]
assert "<button" not in form # 只有輸入框,按 Enter 送出
assert 'href="https://github.com/Sthkm3/ZhiwuProject"' in html
assert 'href="https://gitea.sthkm3.org/sthkm3/ZhiwuProject"' in html
zh = client.get("/assets/i18n/zh-TW.json").json()
assert zh["oss.label"] == "開源連結" and "search.go" not in zh
assert client.get("/u/00000001").status_code == 200
+12
View File
@@ -1209,6 +1209,17 @@ function setPreview(on) {
$("preview-toggle").textContent = on ? t("profile.edit_back") : t("profile.preview");
}
// ---------- UID 搜尋 ----------
function bindSearch() {
$("uid-search").addEventListener("submit", (ev) => {
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"));
+4
View File
@@ -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.",
+4
View File
@@ -1,5 +1,9 @@
{
"lang.label": "言語",
"search.label": "UID で検索",
"search.placeholder": "UID を入力",
"search.invalid": "1〜8 桁の数字で UID を入力してください",
"oss.label": "ソースコード",
"menu": "メニュー",
"auth.heading": "ログイン / 登録",
"auth.hint": "メールアドレスに認証コードを送ります。初回ログイン時にアカウントが作成されます。",
+4
View File
@@ -1,5 +1,9 @@
{
"lang.label": "언어",
"search.label": "UID로 검색",
"search.placeholder": "UID 입력",
"search.invalid": "1~8자리 숫자 UID를 입력해 주세요",
"oss.label": "오픈 소스 링크",
"menu": "메뉴",
"auth.heading": "로그인 / 가입",
"auth.hint": "이메일로 인증 코드를 보내드립니다. 처음 로그인하면 계정이 자동으로 만들어집니다.",
+4
View File
@@ -1,5 +1,9 @@
{
"lang.label": "语言",
"search.label": "用 UID 搜索",
"search.placeholder": "输入 UID",
"search.invalid": "请输入 1~8 位数字的 UID",
"oss.label": "开源链接",
"menu": "菜单",
"auth.heading": "登录 / 注册",
"auth.hint": "输入邮箱接收验证码,第一次登录会自动创建账号。",
+4
View File
@@ -1,5 +1,9 @@
{
"lang.label": "語言",
"search.label": "用 UID 搜尋",
"search.placeholder": "輸入 UID",
"search.invalid": "請輸入 1~8 位數字的 UID",
"oss.label": "開源連結",
"menu": "選單",
"auth.heading": "登入 / 註冊",
"auth.hint": "輸入信箱收驗證碼,第一次登入會自動建立帳號。",
+19 -9
View File
@@ -20,6 +20,9 @@
<aside id="sidebar">
<div class="brand">
<a href="/"><img class="logo" src="/assets/logo.png" alt="" width="32" height="32"><span class="brand-text"><b>吱鼯計畫</b><small data-i18n="site.tagline"></small></span></a>
<form id="uid-search" class="uid-search" role="search" novalidate>
<input id="uid-input" type="text" inputmode="numeric" enterkeyhint="go" maxlength="8" autocomplete="off" data-i18n-placeholder="search.placeholder" data-i18n-aria="search.label">
</form>
<button id="menu-toggle" class="icon-btn only-mobile" type="button" data-i18n-aria="menu">☰</button>
</div>
@@ -60,15 +63,22 @@
</nav>
</section>
<label class="lang"><span data-i18n="lang.label"></span>
<select id="lang">
<option value="zh-TW">繁體中文</option>
<option value="zh-CN">简体中文</option>
<option value="ja">日本語</option>
<option value="ko">한국어</option>
<option value="en">English</option>
</select>
</label>
<div class="sidebar-foot">
<label class="lang"><span data-i18n="lang.label"></span>
<select id="lang">
<option value="zh-TW">繁體中文</option>
<option value="zh-CN">简体中文</option>
<option value="ja">日本語</option>
<option value="ko">한국어</option>
<option value="en">English</option>
</select>
</label>
<div class="oss-links">
<span data-i18n="oss.label"></span>
<a href="https://github.com/Sthkm3/ZhiwuProject" target="_blank" rel="noopener noreferrer">GitHub</a>
<a href="https://gitea.sthkm3.org/sthkm3/ZhiwuProject" target="_blank" rel="noopener noreferrer">Gitea</a>
</div>
</div>
</div>
</aside>
+13 -1
View File
@@ -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; }