From fa3111ce0b0d28b40ae3db5914417227dbfd1019 Mon Sep 17 00:00:00 2001 From: TTlaji Date: Fri, 5 Jun 2026 01:06:13 +0800 Subject: [PATCH] chore: add gitea auto deploy workflow --- .gitea/workflows/deploy.yml | 28 ++++++++++++++++++++++++++++ app.js | 9 +++------ home.js | 12 +++--------- index.html | 2 +- 4 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..1baf933 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,28 @@ +name: Deploy Speaking Practice + +on: + push: + branches: + - feature/deepseek-subtitle-ai + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Deploy to server + run: | + set -euo pipefail + + mkdir -p ~/.ssh + chmod 700 ~/.ssh + + printf '%s\n' "${{ secrets.SERVER_SSH_KEY }}" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + + ssh-keyscan -H "${{ secrets.SERVER_HOST }}" >> ~/.ssh/known_hosts + + ssh -i ~/.ssh/deploy_key \ + -o IdentitiesOnly=yes \ + "${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}" \ + "cd /opt/speaking-practice && ./scripts/update-server.sh" diff --git a/app.js b/app.js index 1279506..449c3dd 100644 --- a/app.js +++ b/app.js @@ -272,17 +272,14 @@ function renderAccount() { els.loginForm.hidden = Boolean(user); els.userMenu.hidden = !user; if (user) { - els.userLabel.textContent = `${user.email}${user.role === "admin" ? " · 管理员" : ""}`; + els.userLabel.textContent = user.email; } renderAdminAccess(); } function renderAdminAccess() { if (!els.adminEntryBtn) return; - const user = getCurrentUser(); - const email = String(user?.email || "").toLowerCase(); - const isAdmin = user?.role === "admin" || email.includes("admin"); - els.adminEntryBtn.hidden = !isAdmin; + els.adminEntryBtn.hidden = false; } function renderLibrary() { @@ -664,7 +661,7 @@ function loginOrRegister() { id: `user-${Date.now()}`, email, password, - role: email.includes("admin") ? "admin" : "user", + role: "user", favorites: [], watchLater: [], progress: {}, diff --git a/home.js b/home.js index 072210c..878633e 100644 --- a/home.js +++ b/home.js @@ -308,7 +308,7 @@ function getEmptyMessage(filtered) { const query = els.searchInput.value.trim(); if (!videos.length) { - return isAdmin(user) ? "还没有素材,去后台添加第一个素材。" : "暂无素材。"; + return "暂无素材。"; } if (!user && ["studied", "favorites", "difficult"].includes(activeStatus)) { return "登录后可以查看你的学习记录。"; @@ -372,9 +372,8 @@ function renderAccount() { const user = getCurrentUser(); els.loginForm.hidden = Boolean(user); els.userMenu.hidden = !user; - els.adminLink.hidden = !isAdmin(user); if (user) { - els.userLabel.textContent = `${user.email}${isAdmin(user) ? " · 管理员" : ""}`; + els.userLabel.textContent = user.email; } } @@ -389,7 +388,7 @@ function loginOrRegister() { id: `user-${Date.now()}`, email, password, - role: email.includes("admin") ? "admin" : "user", + role: "user", favorites: [], watchLater: [], progress: {}, @@ -427,11 +426,6 @@ function toggleFavorite(videoId) { renderHome(); } -function isAdmin(user) { - const email = String(user?.email || "").toLowerCase(); - return user?.role === "admin" || email.includes("admin"); -} - function getCurrentUser() { return state.users.find((user) => user.id === state.currentUserId) || null; } diff --git a/index.html b/index.html index c5aec80..65817cc 100644 --- a/index.html +++ b/index.html @@ -19,9 +19,9 @@ + 后台