This commit is contained in:
1 parent
1e9228e50a
commit
fa3111ce0b
4 files changed
+35
-16
No files matched your search
@@ -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"
|
||||
@@ -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: {},
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,9 +19,9 @@
|
||||
<input id="homePasswordInput" type="password" placeholder="密码" autocomplete="current-password" required>
|
||||
<button id="homeLoginBtn" type="submit">登录 / 注册</button>
|
||||
</form>
|
||||
<a id="homeAdminLink" class="secondary-action" href="./admin.html">后台</a>
|
||||
<div id="homeUserMenu" class="user-menu" hidden>
|
||||
<span id="homeUserLabel"></span>
|
||||
<a id="homeAdminLink" class="secondary-action" href="./admin.html" hidden>管理</a>
|
||||
<button id="homeLogoutBtn" type="button">退出</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user