feat: 增加公告栏并让用户自选学时判断
This commit is contained in:
@@ -0,0 +1,103 @@
|
|||||||
|
"""公告的发布和读取。"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
from fastapi import HTTPException
|
||||||
|
from sqlalchemy import select
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
from euniv.models import Announcement
|
||||||
|
from euniv.study_window import CN_TZ
|
||||||
|
|
||||||
|
|
||||||
|
def _minute(value: datetime) -> datetime:
|
||||||
|
if value.tzinfo is None:
|
||||||
|
value = value.replace(tzinfo=CN_TZ)
|
||||||
|
else:
|
||||||
|
value = value.astimezone(CN_TZ)
|
||||||
|
return value.replace(second=0, microsecond=0)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_published_at(raw: str) -> datetime:
|
||||||
|
text = (raw or "").strip()
|
||||||
|
if not text:
|
||||||
|
raise HTTPException(status_code=400, detail="请填写公告时间")
|
||||||
|
try:
|
||||||
|
parsed = datetime.fromisoformat(text.replace("Z", "+00:00"))
|
||||||
|
except ValueError as exc:
|
||||||
|
raise HTTPException(status_code=400, detail="公告时间无法识别") from exc
|
||||||
|
return _minute(parsed)
|
||||||
|
|
||||||
|
|
||||||
|
def clean_notice(title: str, body: str, link_url: str) -> tuple[str, str, str]:
|
||||||
|
title_text = (title or "").strip()
|
||||||
|
body_text = (body or "").strip()
|
||||||
|
link = (link_url or "").strip()
|
||||||
|
if not title_text or len(title_text) > 80:
|
||||||
|
raise HTTPException(status_code=400, detail="标题须为 1 到 80 个字")
|
||||||
|
if not body_text or len(body_text) > 4000:
|
||||||
|
raise HTTPException(status_code=400, detail="正文须为 1 到 4000 个字")
|
||||||
|
if link:
|
||||||
|
if len(link) > 300:
|
||||||
|
raise HTTPException(status_code=400, detail="链接过长")
|
||||||
|
parsed = urlparse(link)
|
||||||
|
if parsed.scheme not in {"http", "https"} or not parsed.netloc:
|
||||||
|
raise HTTPException(status_code=400, detail="链接须以 http 或 https 开头")
|
||||||
|
return title_text, body_text, link
|
||||||
|
|
||||||
|
|
||||||
|
def _view(row: Announcement) -> dict:
|
||||||
|
published = row.published_at
|
||||||
|
if published.tzinfo is None:
|
||||||
|
published = published.replace(tzinfo=CN_TZ)
|
||||||
|
return {
|
||||||
|
"id": row.id,
|
||||||
|
"title": row.title,
|
||||||
|
"body": row.body,
|
||||||
|
"link_url": row.link_url or "",
|
||||||
|
"published_at": published.isoformat(),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def list_notices(db: Session) -> list[dict]:
|
||||||
|
rows = db.scalars(select(Announcement).order_by(Announcement.published_at.desc(), Announcement.id.desc())).all()
|
||||||
|
return [_view(row) for row in rows]
|
||||||
|
|
||||||
|
|
||||||
|
def create_notice(db: Session, title: str, body: str, link_url: str, published_at: str) -> dict:
|
||||||
|
title_text, body_text, link = clean_notice(title, body, link_url)
|
||||||
|
row = Announcement(
|
||||||
|
title=title_text,
|
||||||
|
body=body_text,
|
||||||
|
link_url=link,
|
||||||
|
published_at=parse_published_at(published_at),
|
||||||
|
)
|
||||||
|
db.add(row)
|
||||||
|
db.commit()
|
||||||
|
db.refresh(row)
|
||||||
|
return _view(row)
|
||||||
|
|
||||||
|
|
||||||
|
def update_notice(db: Session, notice_id: int, title: str, body: str, link_url: str, published_at: str) -> dict:
|
||||||
|
row = db.get(Announcement, notice_id)
|
||||||
|
if row is None:
|
||||||
|
raise HTTPException(status_code=404, detail="公告不存在")
|
||||||
|
title_text, body_text, link = clean_notice(title, body, link_url)
|
||||||
|
row.title = title_text
|
||||||
|
row.body = body_text
|
||||||
|
row.link_url = link
|
||||||
|
row.published_at = parse_published_at(published_at)
|
||||||
|
db.commit()
|
||||||
|
return _view(row)
|
||||||
|
|
||||||
|
|
||||||
|
def delete_notice(db: Session, notice_id: int) -> dict:
|
||||||
|
row = db.get(Announcement, notice_id)
|
||||||
|
if row is None:
|
||||||
|
raise HTTPException(status_code=404, detail="公告不存在")
|
||||||
|
db.delete(row)
|
||||||
|
db.commit()
|
||||||
|
return {"ok": True}
|
||||||
@@ -44,6 +44,13 @@ class SettingsBody(BaseModel):
|
|||||||
hours_source: str = "api"
|
hours_source: str = "api"
|
||||||
|
|
||||||
|
|
||||||
|
class NoticeBody(BaseModel):
|
||||||
|
title: str
|
||||||
|
body: str
|
||||||
|
link_url: str = ""
|
||||||
|
published_at: str
|
||||||
|
|
||||||
|
|
||||||
class PauseBody(BaseModel):
|
class PauseBody(BaseModel):
|
||||||
paused: bool
|
paused: bool
|
||||||
|
|
||||||
@@ -204,6 +211,34 @@ def put_users_study_settings(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_router.get("/notices")
|
||||||
|
def get_notices(db: Session = Depends(get_db), _: str = Depends(require_admin)) -> list[dict]:
|
||||||
|
from admin.notices import list_notices
|
||||||
|
|
||||||
|
return list_notices(db)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_router.post("/notices")
|
||||||
|
def post_notice(body: NoticeBody, db: Session = Depends(get_db), _: str = Depends(require_admin)) -> dict:
|
||||||
|
from admin.notices import create_notice
|
||||||
|
|
||||||
|
return create_notice(db, body.title, body.body, body.link_url, body.published_at)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_router.put("/notices/{notice_id}")
|
||||||
|
def put_notice(notice_id: int, body: NoticeBody, db: Session = Depends(get_db), _: str = Depends(require_admin)) -> dict:
|
||||||
|
from admin.notices import update_notice
|
||||||
|
|
||||||
|
return update_notice(db, notice_id, body.title, body.body, body.link_url, body.published_at)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_router.delete("/notices/{notice_id}")
|
||||||
|
def remove_notice(notice_id: int, db: Session = Depends(get_db), _: str = Depends(require_admin)) -> dict:
|
||||||
|
from admin.notices import delete_notice
|
||||||
|
|
||||||
|
return delete_notice(db, notice_id)
|
||||||
|
|
||||||
|
|
||||||
@admin_router.get("/users/{employee_id}/credentials")
|
@admin_router.get("/users/{employee_id}/credentials")
|
||||||
def get_credentials(
|
def get_credentials(
|
||||||
employee_id: str, response: Response, db: Session = Depends(get_db), _: str = Depends(require_admin)
|
employee_id: str, response: Response, db: Session = Depends(get_db), _: str = Depends(require_admin)
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ def heartbeat_intervals() -> dict:
|
|||||||
|
|
||||||
|
|
||||||
def hours_source_of(row: SystemConfig | None = None) -> str:
|
def hours_source_of(row: SystemConfig | None = None) -> str:
|
||||||
"""api:接口本月学时;history:学时历史本月分钟合计。"""
|
"""管理端为新用户准备的默认依据。api:官方统计;history:历史统计。"""
|
||||||
if row is None:
|
if row is None:
|
||||||
from euniv.db import SessionLocal
|
from euniv.db import SessionLocal
|
||||||
|
|
||||||
@@ -154,6 +154,25 @@ def hours_source_of(row: SystemConfig | None = None) -> str:
|
|||||||
return value if value in ("api", "history") else "api"
|
return value if value in ("api", "history") else "api"
|
||||||
|
|
||||||
|
|
||||||
|
def account_hours_source(account) -> str:
|
||||||
|
value = str(getattr(account, "hours_source", "") or "").strip().lower()
|
||||||
|
return value if value in ("api", "history") else hours_source_of()
|
||||||
|
|
||||||
|
|
||||||
|
def source_for_employee(employee_id: str) -> str:
|
||||||
|
from euniv.db import SessionLocal
|
||||||
|
from euniv.models import Account
|
||||||
|
|
||||||
|
key = (employee_id or "").strip()
|
||||||
|
if not key:
|
||||||
|
return hours_source_of()
|
||||||
|
with SessionLocal() as db:
|
||||||
|
account = db.get(Account, key)
|
||||||
|
if account is None:
|
||||||
|
return hours_source_of()
|
||||||
|
return account_hours_source(account)
|
||||||
|
|
||||||
|
|
||||||
def settings_view(row: SystemConfig) -> dict:
|
def settings_view(row: SystemConfig) -> dict:
|
||||||
return {
|
return {
|
||||||
"refresh_interval_minutes": int(row.refresh_interval_minutes),
|
"refresh_interval_minutes": int(row.refresh_interval_minutes),
|
||||||
@@ -234,7 +253,6 @@ def save_settings(db: Session, payload: dict) -> SystemConfig:
|
|||||||
row = load_config(db)
|
row = load_config(db)
|
||||||
previous_interval = int(row.refresh_interval_minutes)
|
previous_interval = int(row.refresh_interval_minutes)
|
||||||
previous_username = row.admin_username
|
previous_username = row.admin_username
|
||||||
previous_source = hours_source_of(row)
|
|
||||||
row.refresh_interval_minutes = interval
|
row.refresh_interval_minutes = interval
|
||||||
row.show_manual_jigsaw = bool(payload.get("show_manual_jigsaw"))
|
row.show_manual_jigsaw = bool(payload.get("show_manual_jigsaw"))
|
||||||
row.manual_preference = bool(payload.get("manual_preference"))
|
row.manual_preference = bool(payload.get("manual_preference"))
|
||||||
@@ -261,8 +279,4 @@ def save_settings(db: Session, payload: dict) -> SystemConfig:
|
|||||||
from euniv.service import notify_refresh_interval_changed
|
from euniv.service import notify_refresh_interval_changed
|
||||||
|
|
||||||
notify_refresh_interval_changed()
|
notify_refresh_interval_changed()
|
||||||
if source != previous_source:
|
|
||||||
from euniv.service import notify_hours_source_changed
|
|
||||||
|
|
||||||
notify_hours_source_changed()
|
|
||||||
return row
|
return row
|
||||||
|
|||||||
@@ -62,10 +62,9 @@ def _iso_time(value: datetime | None) -> str | None:
|
|||||||
|
|
||||||
|
|
||||||
def list_users(db: Session) -> list[dict]:
|
def list_users(db: Session) -> list[dict]:
|
||||||
from admin.settings import hours_source_of
|
from admin.settings import account_hours_source
|
||||||
from euniv.autostudy import autostudy_status, work_running
|
from euniv.autostudy import autostudy_status, work_running
|
||||||
|
|
||||||
source = hours_source_of()
|
|
||||||
accounts = db.scalars(select(Account).order_by(Account.employee_id)).all()
|
accounts = db.scalars(select(Account).order_by(Account.employee_id)).all()
|
||||||
live_users = autostudy_status().get("users") or {}
|
live_users = autostudy_status().get("users") or {}
|
||||||
rows = []
|
rows = []
|
||||||
@@ -85,7 +84,7 @@ def list_users(db: Session) -> list[dict]:
|
|||||||
"credential_valid": _optional_bool(account.credential_valid),
|
"credential_valid": _optional_bool(account.credential_valid),
|
||||||
"month_hours": account.month_hours or "",
|
"month_hours": account.month_hours or "",
|
||||||
"official_month_hours": account.official_month_hours or "",
|
"official_month_hours": account.official_month_hours or "",
|
||||||
"hours_source": source,
|
"hours_source": account_hours_source(account),
|
||||||
"monthly_target": account.monthly_target if account.monthly_target is not None else 600,
|
"monthly_target": account.monthly_target if account.monthly_target is not None else 600,
|
||||||
"has_proxy": enabled(account),
|
"has_proxy": enabled(account),
|
||||||
"proxy": summary_of(account),
|
"proxy": summary_of(account),
|
||||||
@@ -116,7 +115,7 @@ def _require(db: Session, employee_id: str) -> Account:
|
|||||||
|
|
||||||
|
|
||||||
def _checked_hours(client) -> tuple[str, str]:
|
def _checked_hours(client) -> tuple[str, str]:
|
||||||
from admin.settings import hours_source_of
|
from admin.settings import source_for_employee
|
||||||
from euniv.service import _month_hours
|
from euniv.service import _month_hours
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -124,7 +123,7 @@ def _checked_hours(client) -> tuple[str, str]:
|
|||||||
except Exception:
|
except Exception:
|
||||||
hours = ""
|
hours = ""
|
||||||
official = ""
|
official = ""
|
||||||
if hours and hours_source_of() == "history":
|
if hours and source_for_employee(str(getattr(client, "login_name", "") or "")) == "history":
|
||||||
reader = getattr(client, "month_hours", None)
|
reader = getattr(client, "month_hours", None)
|
||||||
if callable(reader):
|
if callable(reader):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
"""账号自选学时判断依据,并增加公告。"""
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
revision = "0015_account_source_and_notices"
|
||||||
|
down_revision = "0014_official_month_hours"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
with op.batch_alter_table("accounts") as batch:
|
||||||
|
batch.add_column(sa.Column("hours_source", sa.String(length=16), server_default="api", nullable=False))
|
||||||
|
op.execute(
|
||||||
|
"UPDATE accounts SET hours_source = COALESCE("
|
||||||
|
"(SELECT hours_source FROM system_config ORDER BY id LIMIT 1), 'api')"
|
||||||
|
)
|
||||||
|
op.create_table(
|
||||||
|
"announcements",
|
||||||
|
sa.Column("id", sa.Integer(), primary_key=True),
|
||||||
|
sa.Column("title", sa.String(length=80), nullable=False),
|
||||||
|
sa.Column("body", sa.Text(), nullable=False),
|
||||||
|
sa.Column("link_url", sa.String(length=300), server_default="", nullable=False),
|
||||||
|
sa.Column("published_at", sa.DateTime(timezone=True), nullable=False),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
op.drop_table("announcements")
|
||||||
|
with op.batch_alter_table("accounts") as batch:
|
||||||
|
batch.drop_column("hours_source")
|
||||||
@@ -84,6 +84,7 @@ class StudyBundleBody(BaseModel):
|
|||||||
heartbeat_video_seconds: int | None = Field(default=None, strict=True, ge=0, le=300)
|
heartbeat_video_seconds: int | None = Field(default=None, strict=True, ge=0, le=300)
|
||||||
heartbeat_document_seconds: int | None = Field(default=None, strict=True, ge=0, le=600)
|
heartbeat_document_seconds: int | None = Field(default=None, strict=True, ge=0, le=600)
|
||||||
heartbeat_scorm_seconds: int | None = Field(default=None, strict=True, ge=0, le=600)
|
heartbeat_scorm_seconds: int | None = Field(default=None, strict=True, ge=0, le=600)
|
||||||
|
hours_source: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class StudyControlBody(BaseModel):
|
class StudyControlBody(BaseModel):
|
||||||
@@ -327,6 +328,14 @@ def _signed_in(request: Request, db: Session) -> str:
|
|||||||
return employee_id
|
return employee_id
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/api/announcements")
|
||||||
|
def announcements(request: Request, db: Session = Depends(get_db)) -> list[dict]:
|
||||||
|
from admin.notices import list_notices
|
||||||
|
|
||||||
|
_signed_in(request, db)
|
||||||
|
return list_notices(db)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/api/home/summary")
|
@app.get("/api/home/summary")
|
||||||
def home_summary(request: Request, db: Session = Depends(get_db)) -> dict:
|
def home_summary(request: Request, db: Session = Depends(get_db)) -> dict:
|
||||||
try:
|
try:
|
||||||
@@ -446,6 +455,11 @@ def _apply_study_bundle(account: Account, body: StudyBundleBody) -> None:
|
|||||||
body.heartbeat_document_seconds,
|
body.heartbeat_document_seconds,
|
||||||
body.heartbeat_scorm_seconds,
|
body.heartbeat_scorm_seconds,
|
||||||
)
|
)
|
||||||
|
if body.hours_source is not None:
|
||||||
|
chosen = str(body.hours_source).strip().lower()
|
||||||
|
if chosen not in {"api", "history"}:
|
||||||
|
raise HTTPException(status_code=400, detail="学时判断须为官方统计或历史统计")
|
||||||
|
account.hours_source = chosen
|
||||||
except (StudyWindowError, CourseWorkersError, HeartbeatError) as exc:
|
except (StudyWindowError, CourseWorkersError, HeartbeatError) as exc:
|
||||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||||
|
|
||||||
|
|||||||
@@ -889,9 +889,9 @@ class HoursWatcher:
|
|||||||
self.user_stop.set()
|
self.user_stop.set()
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
from admin.settings import hours_source_of
|
from admin.settings import source_for_employee
|
||||||
|
|
||||||
source = hours_source_of()
|
source = source_for_employee(self.employee_id)
|
||||||
official = ""
|
official = ""
|
||||||
if source == "history":
|
if source == "history":
|
||||||
current = int(await self.session.month_history_minutes())
|
current = int(await self.session.month_history_minutes())
|
||||||
@@ -2104,8 +2104,6 @@ class AutoStudyWorker:
|
|||||||
async def _run_account(self, job: tuple, course_list, generation: int) -> None:
|
async def _run_account(self, job: tuple, course_list, generation: int) -> None:
|
||||||
emp_id, target, pw, cred, proxy, workers, use_pool = job
|
emp_id, target, pw, cred, proxy, workers, use_pool = job
|
||||||
try:
|
try:
|
||||||
from admin.settings import hours_source_of
|
|
||||||
|
|
||||||
if int(target or 0) <= 0:
|
if int(target or 0) <= 0:
|
||||||
if use_pool:
|
if use_pool:
|
||||||
await asyncio.to_thread(_release_pool, emp_id, True)
|
await asyncio.to_thread(_release_pool, emp_id, True)
|
||||||
@@ -2115,10 +2113,9 @@ class AutoStudyWorker:
|
|||||||
if use_pool:
|
if use_pool:
|
||||||
await asyncio.to_thread(_release_pool, emp_id, True)
|
await asyncio.to_thread(_release_pool, emp_id, True)
|
||||||
return
|
return
|
||||||
hours_source = await asyncio.to_thread(hours_source_of)
|
|
||||||
await self._study_user(
|
await self._study_user(
|
||||||
emp_id, target, pw, cred, proxy, workers, use_pool,
|
emp_id, target, pw, cred, proxy, workers, use_pool,
|
||||||
course_list, hours_source,
|
course_list,
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
log.warning("用户 %s 自动学习失败: %s", emp_id, exc)
|
log.warning("用户 %s 自动学习失败: %s", emp_id, exc)
|
||||||
@@ -2139,8 +2136,7 @@ class AutoStudyWorker:
|
|||||||
|
|
||||||
async def _study_user(self, employee_id: str, target: int,
|
async def _study_user(self, employee_id: str, target: int,
|
||||||
password: str, credential: dict, proxy: str | None,
|
password: str, credential: dict, proxy: str | None,
|
||||||
workers: int, use_pool: bool, course_list: list,
|
workers: int, use_pool: bool, course_list: list) -> None:
|
||||||
hours_source: str) -> None:
|
|
||||||
assert self._async_stop is not None
|
assert self._async_stop is not None
|
||||||
user_stop = asyncio.Event()
|
user_stop = asyncio.Event()
|
||||||
with _halt_lock:
|
with _halt_lock:
|
||||||
|
|||||||
@@ -56,11 +56,14 @@ def _stored(value: object, default: int, high: int) -> int:
|
|||||||
|
|
||||||
|
|
||||||
def view_of(account) -> dict:
|
def view_of(account) -> dict:
|
||||||
|
from admin.settings import account_hours_source
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"heartbeat_mode": mode_of(account),
|
"heartbeat_mode": mode_of(account),
|
||||||
"heartbeat_video_seconds": video_of(account),
|
"heartbeat_video_seconds": video_of(account),
|
||||||
"heartbeat_document_seconds": document_of(account),
|
"heartbeat_document_seconds": document_of(account),
|
||||||
"heartbeat_scorm_seconds": scorm_of(account),
|
"heartbeat_scorm_seconds": scorm_of(account),
|
||||||
|
"hours_source": account_hours_source(account),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class Account(Base):
|
|||||||
study_opened_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
study_opened_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||||
study_schedule_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=sql_false())
|
study_schedule_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=sql_false())
|
||||||
heartbeat_mode: Mapped[str] = mapped_column(String(16), nullable=False, default="auto", server_default="auto")
|
heartbeat_mode: Mapped[str] = mapped_column(String(16), nullable=False, default="auto", server_default="auto")
|
||||||
|
hours_source: Mapped[str] = mapped_column(String(16), nullable=False, default="api", server_default="api")
|
||||||
heartbeat_video_seconds: Mapped[int] = mapped_column(nullable=False, default=30, server_default="30")
|
heartbeat_video_seconds: Mapped[int] = mapped_column(nullable=False, default=30, server_default="30")
|
||||||
heartbeat_document_seconds: Mapped[int] = mapped_column(nullable=False, default=120, server_default="120")
|
heartbeat_document_seconds: Mapped[int] = mapped_column(nullable=False, default=120, server_default="120")
|
||||||
heartbeat_scorm_seconds: Mapped[int] = mapped_column(nullable=False, default=120, server_default="120")
|
heartbeat_scorm_seconds: Mapped[int] = mapped_column(nullable=False, default=120, server_default="120")
|
||||||
@@ -87,3 +88,15 @@ class Account(Base):
|
|||||||
password_login_at: Mapped[datetime] = mapped_column(
|
password_login_at: Mapped[datetime] = mapped_column(
|
||||||
DateTime(timezone=True), nullable=False, server_default=text("CURRENT_TIMESTAMP")
|
DateTime(timezone=True), nullable=False, server_default=text("CURRENT_TIMESTAMP")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Announcement(Base):
|
||||||
|
"""面向用户的公告。时间精确到分钟。"""
|
||||||
|
|
||||||
|
__tablename__ = "announcements"
|
||||||
|
|
||||||
|
id: Mapped[int] = mapped_column(primary_key=True)
|
||||||
|
title: Mapped[str] = mapped_column(String(80), nullable=False, default="")
|
||||||
|
body: Mapped[str] = mapped_column(Text, nullable=False, default="")
|
||||||
|
link_url: Mapped[str] = mapped_column(String(300), nullable=False, default="", server_default=text("''"))
|
||||||
|
published_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
||||||
|
|||||||
@@ -135,7 +135,14 @@ def _persist_locked(db: Session, employee_id: str, password: str | None, client:
|
|||||||
client.authorize(profile)
|
client.authorize(profile)
|
||||||
account = db.get(Account, employee_id)
|
account = db.get(Account, employee_id)
|
||||||
if account is None:
|
if account is None:
|
||||||
account = Account(employee_id=employee_id, password_cipher="", credential_cipher="")
|
from admin.settings import hours_source_of
|
||||||
|
|
||||||
|
account = Account(
|
||||||
|
employee_id=employee_id,
|
||||||
|
password_cipher="",
|
||||||
|
credential_cipher="",
|
||||||
|
hours_source=hours_source_of(),
|
||||||
|
)
|
||||||
db.add(account)
|
db.add(account)
|
||||||
if password is None:
|
if password is None:
|
||||||
stored = ""
|
stored = ""
|
||||||
@@ -411,10 +418,10 @@ def fetch_study_history(db: Session, employee_id: str, client_factory=EunivClien
|
|||||||
|
|
||||||
|
|
||||||
def _apply_hours_source(client, summary: dict, items: list | None = None) -> dict:
|
def _apply_hours_source(client, summary: dict, items: list | None = None) -> dict:
|
||||||
from admin.settings import hours_source_of
|
from admin.settings import source_for_employee
|
||||||
|
|
||||||
data = dict(summary)
|
data = dict(summary)
|
||||||
source = hours_source_of()
|
source = source_for_employee(str(getattr(client, "login_name", "") or ""))
|
||||||
data["hours_source"] = source
|
data["hours_source"] = source
|
||||||
data["official_month_hours"] = data.get("month_hours")
|
data["official_month_hours"] = data.get("month_hours")
|
||||||
if source != "history":
|
if source != "history":
|
||||||
@@ -839,9 +846,9 @@ def start_credential_refresh() -> _RefreshGate:
|
|||||||
|
|
||||||
|
|
||||||
def _month_hours(client) -> str:
|
def _month_hours(client) -> str:
|
||||||
from admin.settings import hours_source_of
|
from admin.settings import source_for_employee
|
||||||
|
|
||||||
if hours_source_of() == "history":
|
if source_for_employee(str(getattr(client, "login_name", "") or "")) == "history":
|
||||||
reader = getattr(client, "month_history_minutes", None)
|
reader = getattr(client, "month_history_minutes", None)
|
||||||
if reader is None:
|
if reader is None:
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
@@ -996,3 +996,37 @@ def test_admin_can_switch_hours_source() -> None:
|
|||||||
bad = client.put("/api/admin/settings", json=_settings_body(hours_source="other"))
|
bad = client.put("/api/admin/settings", json=_settings_body(hours_source="other"))
|
||||||
assert bad.status_code == 400
|
assert bad.status_code == 400
|
||||||
assert bad.json()["detail"] == "学时达标依据须为 api 或 history"
|
assert bad.json()["detail"] == "学时达标依据须为 api 或 history"
|
||||||
|
|
||||||
|
|
||||||
|
def test_admin_can_publish_notices() -> None:
|
||||||
|
api = _app()
|
||||||
|
client = TestClient(api.app)
|
||||||
|
assert client.post("/api/login", json={"employee_id": "admin", "password": INITIAL_PASSWORD}).status_code == 200
|
||||||
|
created = client.post(
|
||||||
|
"/api/admin/notices",
|
||||||
|
json={
|
||||||
|
"title": "维护",
|
||||||
|
"body": "今晚更新",
|
||||||
|
"link_url": "https://euniv.asio.asia",
|
||||||
|
"published_at": "2026-11-19T04:00:00+08:00",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert created.status_code == 200
|
||||||
|
assert created.json()["title"] == "维护"
|
||||||
|
assert created.json()["published_at"].startswith("2026-11-19T04:00")
|
||||||
|
listed = client.get("/api/admin/notices")
|
||||||
|
assert listed.status_code == 200
|
||||||
|
assert listed.json()[0]["link_url"] == "https://euniv.asio.asia"
|
||||||
|
bad = client.post(
|
||||||
|
"/api/admin/notices",
|
||||||
|
json={
|
||||||
|
"title": "坏链接",
|
||||||
|
"body": "正文",
|
||||||
|
"link_url": "javascript:alert(1)",
|
||||||
|
"published_at": "2026-11-19T04:00:00+08:00",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert bad.status_code == 400
|
||||||
|
notice_id = created.json()["id"]
|
||||||
|
assert client.delete(f"/api/admin/notices/{notice_id}").status_code == 200
|
||||||
|
assert client.get("/api/admin/notices").json() == []
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ def test_login_stores_password_and_credential_only(monkeypatch) -> None:
|
|||||||
"study_opened_at",
|
"study_opened_at",
|
||||||
"study_schedule_enabled",
|
"study_schedule_enabled",
|
||||||
"heartbeat_mode",
|
"heartbeat_mode",
|
||||||
|
"hours_source",
|
||||||
"heartbeat_video_seconds",
|
"heartbeat_video_seconds",
|
||||||
"heartbeat_document_seconds",
|
"heartbeat_document_seconds",
|
||||||
"heartbeat_scorm_seconds",
|
"heartbeat_scorm_seconds",
|
||||||
@@ -593,7 +594,7 @@ def test_period_page_is_not_fetched_twice() -> None:
|
|||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
client.client = HTTP()
|
client.client = HTTP()
|
||||||
assert client._period_minutes() == {"year": "34", "month": "12"}
|
assert client._period_minutes() == {"year": "34", "month": "12", "total": ""}
|
||||||
assert len(calls) == 1
|
assert len(calls) == 1
|
||||||
|
|
||||||
|
|
||||||
@@ -1108,6 +1109,9 @@ def _set_hours_source(value: str) -> None:
|
|||||||
with SessionLocal() as db:
|
with SessionLocal() as db:
|
||||||
row = load_config(db)
|
row = load_config(db)
|
||||||
row.hours_source = value
|
row.hours_source = value
|
||||||
|
account = db.get(Account, "6650000146")
|
||||||
|
if account is not None:
|
||||||
|
account.hours_source = value
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -386,7 +386,7 @@ class _HourSession:
|
|||||||
|
|
||||||
def test_hours_watcher_stops_when_target_reached(monkeypatch) -> None:
|
def test_hours_watcher_stops_when_target_reached(monkeypatch) -> None:
|
||||||
saved: list[tuple[str, str]] = []
|
saved: list[tuple[str, str]] = []
|
||||||
monkeypatch.setattr("euniv.autostudy._update_month_hours", lambda eid, hours: saved.append((eid, hours)))
|
monkeypatch.setattr("euniv.autostudy._update_month_hours", lambda eid, hours, official="": saved.append((eid, hours)))
|
||||||
|
|
||||||
async def main() -> None:
|
async def main() -> None:
|
||||||
session = _HourSession("600")
|
session = _HourSession("600")
|
||||||
@@ -402,15 +402,15 @@ def test_hours_watcher_stops_when_target_reached(monkeypatch) -> None:
|
|||||||
|
|
||||||
def test_hours_watcher_history_source_uses_month_history(monkeypatch) -> None:
|
def test_hours_watcher_history_source_uses_month_history(monkeypatch) -> None:
|
||||||
saved: list[tuple[str, str]] = []
|
saved: list[tuple[str, str]] = []
|
||||||
monkeypatch.setattr("euniv.autostudy._update_month_hours", lambda eid, hours: saved.append((eid, hours)))
|
monkeypatch.setattr("euniv.autostudy._update_month_hours", lambda eid, hours, official="": saved.append((eid, hours)))
|
||||||
monkeypatch.setattr("admin.settings.hours_source_of", lambda: "history")
|
monkeypatch.setattr("admin.settings.source_for_employee", lambda _employee_id: "history")
|
||||||
|
|
||||||
class _HistorySession:
|
class _HistorySession:
|
||||||
async def month_history_minutes(self) -> int:
|
async def month_history_minutes(self) -> int:
|
||||||
return 600
|
return 600
|
||||||
|
|
||||||
async def month_hours_text(self) -> str:
|
async def month_hours_text(self) -> str:
|
||||||
raise AssertionError("history 模式不应读接口本月学时")
|
return "126"
|
||||||
|
|
||||||
async def main() -> None:
|
async def main() -> None:
|
||||||
user_stop = asyncio.Event()
|
user_stop = asyncio.Event()
|
||||||
|
|||||||
@@ -0,0 +1,196 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { apiFetch } from "../../shared/http";
|
||||||
|
import { onMounted, ref } from "vue";
|
||||||
|
import { NAlert, NButton, NDatePicker, NForm, NFormItem, NInput, NModal, useDialog } from "naive-ui";
|
||||||
|
import { isRecord, textOf } from "../../shared/text";
|
||||||
|
|
||||||
|
interface Notice {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
body: string;
|
||||||
|
link_url: string;
|
||||||
|
published_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dialog = useDialog();
|
||||||
|
const loading = ref(true);
|
||||||
|
const errorText = ref("");
|
||||||
|
const items = ref<Notice[]>([]);
|
||||||
|
const editorOpen = ref(false);
|
||||||
|
const saving = ref(false);
|
||||||
|
const editorError = ref("");
|
||||||
|
const editingId = ref<number | null>(null);
|
||||||
|
const title = ref("");
|
||||||
|
const body = ref("");
|
||||||
|
const linkUrl = ref("");
|
||||||
|
const publishedAt = ref<number | null>(Date.now());
|
||||||
|
|
||||||
|
function minuteText(value: string) {
|
||||||
|
const date = new Date(value);
|
||||||
|
if (Number.isNaN(date.getTime())) return value;
|
||||||
|
const pad = (part: number) => String(part).padStart(2, "0");
|
||||||
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function asNotice(value: unknown): Notice | null {
|
||||||
|
if (!isRecord(value) || typeof value.id !== "number") return null;
|
||||||
|
return {
|
||||||
|
id: value.id,
|
||||||
|
title: textOf(value.title),
|
||||||
|
body: textOf(value.body),
|
||||||
|
link_url: textOf(value.link_url),
|
||||||
|
published_at: textOf(value.published_at),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const response = await apiFetch("/api/admin/notices");
|
||||||
|
const payload: unknown = await response.json().catch(() => []);
|
||||||
|
if (!response.ok || !Array.isArray(payload)) {
|
||||||
|
errorText.value = "公告没有获取到。";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
errorText.value = "";
|
||||||
|
items.value = payload.map(asNotice).filter((item): item is Notice => item !== null);
|
||||||
|
} catch {
|
||||||
|
errorText.value = "公告没有获取到。";
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCreate() {
|
||||||
|
editingId.value = null;
|
||||||
|
title.value = "";
|
||||||
|
body.value = "";
|
||||||
|
linkUrl.value = "";
|
||||||
|
publishedAt.value = Date.now();
|
||||||
|
editorError.value = "";
|
||||||
|
editorOpen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEdit(row: Notice) {
|
||||||
|
editingId.value = row.id;
|
||||||
|
title.value = row.title;
|
||||||
|
body.value = row.body;
|
||||||
|
linkUrl.value = row.link_url;
|
||||||
|
const stamp = new Date(row.published_at).getTime();
|
||||||
|
publishedAt.value = Number.isNaN(stamp) ? Date.now() : stamp;
|
||||||
|
editorError.value = "";
|
||||||
|
editorOpen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
if (saving.value) return;
|
||||||
|
if (!title.value.trim() || !body.value.trim() || publishedAt.value == null) {
|
||||||
|
editorError.value = "请填写标题、正文和发布时间。";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
saving.value = true;
|
||||||
|
editorError.value = "";
|
||||||
|
const payload = {
|
||||||
|
title: title.value.trim(),
|
||||||
|
body: body.value.trim(),
|
||||||
|
link_url: linkUrl.value.trim(),
|
||||||
|
published_at: new Date(publishedAt.value).toISOString(),
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const path = editingId.value == null ? "/api/admin/notices" : `/api/admin/notices/${editingId.value}`;
|
||||||
|
const response = await apiFetch(path, {
|
||||||
|
method: editingId.value == null ? "POST" : "PUT",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
editorError.value = "没有保存。";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
editorOpen.value = false;
|
||||||
|
await load();
|
||||||
|
} catch {
|
||||||
|
editorError.value = "没有保存。";
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove(row: Notice) {
|
||||||
|
dialog.warning({
|
||||||
|
title: "删除公告",
|
||||||
|
content: `删除「${row.title}」?`,
|
||||||
|
positiveText: "删除",
|
||||||
|
negativeText: "取消",
|
||||||
|
onPositiveClick: async () => {
|
||||||
|
const response = await apiFetch(`/api/admin/notices/${row.id}`, { method: "DELETE" });
|
||||||
|
if (!response.ok) {
|
||||||
|
errorText.value = "没有删除。";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await load();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(load);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section class="page list-page">
|
||||||
|
<header class="page-head">
|
||||||
|
<div>
|
||||||
|
<h2>公告</h2>
|
||||||
|
<p v-if="!loading">共 {{ items.length }} 条</p>
|
||||||
|
</div>
|
||||||
|
<n-button type="primary" @click="openCreate">发布公告</n-button>
|
||||||
|
</header>
|
||||||
|
<n-alert v-if="errorText" class="admin-alert" type="error">{{ errorText }}</n-alert>
|
||||||
|
<p v-if="loading" class="admin-status">正在获取</p>
|
||||||
|
<p v-else-if="!items.length" class="admin-status">还没有公告</p>
|
||||||
|
<ol v-else class="notice-admin">
|
||||||
|
<li v-for="item in items" :key="item.id">
|
||||||
|
<div>
|
||||||
|
<time>{{ minuteText(item.published_at) }}</time>
|
||||||
|
<strong>{{ item.title }}</strong>
|
||||||
|
<p>{{ item.body }}</p>
|
||||||
|
<a v-if="item.link_url" :href="item.link_url" target="_blank" rel="noreferrer">{{ item.link_url }}</a>
|
||||||
|
</div>
|
||||||
|
<div class="notice-admin-actions">
|
||||||
|
<n-button size="small" quaternary @click="openEdit(item)">编辑</n-button>
|
||||||
|
<n-button size="small" quaternary type="error" @click="remove(item)">删除</n-button>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<n-modal
|
||||||
|
:show="editorOpen"
|
||||||
|
preset="card"
|
||||||
|
:title="editingId == null ? '发布公告' : '编辑公告'"
|
||||||
|
:style="{ width: 'min(640px, calc(100vw - 32px))' }"
|
||||||
|
:content-style="{ maxHeight: 'min(70vh, 640px)', overflow: 'auto' }"
|
||||||
|
@update:show="(show) => (editorOpen = show)"
|
||||||
|
>
|
||||||
|
<n-alert v-if="editorError" class="summary-error" type="error">{{ editorError }}</n-alert>
|
||||||
|
<n-form class="compact-nform" label-placement="left" label-align="left" :label-width="88" :show-feedback="false">
|
||||||
|
<n-form-item label="标题">
|
||||||
|
<n-input v-model:value="title" maxlength="80" placeholder="一句话说明" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="正文">
|
||||||
|
<n-input v-model:value="body" type="textarea" :autosize="{ minRows: 5, maxRows: 12 }" maxlength="4000" placeholder="公告内容" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="链接">
|
||||||
|
<n-input v-model:value="linkUrl" placeholder="可不填,须以 http 或 https 开头" />
|
||||||
|
</n-form-item>
|
||||||
|
<n-form-item label="发布时间">
|
||||||
|
<n-date-picker v-model:value="publishedAt" type="datetime" format="yyyy-MM-dd HH:mm" :time-picker-props="{ format: 'HH:mm' }" />
|
||||||
|
</n-form-item>
|
||||||
|
</n-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="modal-actions">
|
||||||
|
<n-button @click="editorOpen = false">取消</n-button>
|
||||||
|
<n-button type="primary" :loading="saving" @click="save">保存</n-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-modal>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
@@ -217,12 +217,12 @@ async function save() {
|
|||||||
<n-form class="compact-nform" label-placement="left" label-align="left" :label-width="176" :show-feedback="false" size="small" @submit.prevent="save">
|
<n-form class="compact-nform" label-placement="left" label-align="left" :label-width="176" :show-feedback="false" size="small" @submit.prevent="save">
|
||||||
<n-form-item label="判断依据">
|
<n-form-item label="判断依据">
|
||||||
<n-radio-group v-model:value="hoursSource" size="small">
|
<n-radio-group v-model:value="hoursSource" size="small">
|
||||||
<n-radio-button value="api">接口本月学时</n-radio-button>
|
<n-radio-button value="api">官方统计数据</n-radio-button>
|
||||||
<n-radio-button value="history">学时历史统计</n-radio-button>
|
<n-radio-button value="history">历史统计数据</n-radio-button>
|
||||||
</n-radio-group>
|
</n-radio-group>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-form>
|
</n-form>
|
||||||
<p class="form-hint">首页、学时历史和达标判断使用同一来源</p>
|
<p class="form-hint">新用户默认使用这里的选择,已有用户不受影响</p>
|
||||||
</n-collapse-item>
|
</n-collapse-item>
|
||||||
<n-collapse-item title="管理员" name="admin">
|
<n-collapse-item title="管理员" name="admin">
|
||||||
<n-form class="compact-nform" label-placement="left" label-align="left" :label-width="176" :show-feedback="false" size="small" @submit.prevent="save">
|
<n-form class="compact-nform" label-placement="left" label-align="left" :label-width="176" :show-feedback="false" size="small" @submit.prevent="save">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { apiFetch } from "../../shared/http";
|
|||||||
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
|
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
|
||||||
import { NAlert, NButton, NForm, NFormItem, NIcon, NInputNumber, NModal, NProgress, NRadioButton, NRadioGroup, NSelect, NSwitch, NTimePicker, NTooltip } from "naive-ui";
|
import { NAlert, NButton, NForm, NFormItem, NIcon, NInputNumber, NModal, NProgress, NRadioButton, NRadioGroup, NSelect, NSwitch, NTimePicker, NTooltip } from "naive-ui";
|
||||||
import { GlobeOutline, PlayOutline, RefreshOutline, StopOutline } from "@vicons/ionicons5";
|
import { GlobeOutline, PlayOutline, RefreshOutline, StopOutline } from "@vicons/ionicons5";
|
||||||
|
import NoticeRail from "./NoticeRail.vue";
|
||||||
import HoursCompare from "../../shared/HoursCompare.vue";
|
import HoursCompare from "../../shared/HoursCompare.vue";
|
||||||
import ProxyFields from "../../shared/ProxyFields.vue";
|
import ProxyFields from "../../shared/ProxyFields.vue";
|
||||||
import { STUDY_DAY_DEFAULT, STUDY_DAY_MAX, STUDY_DAY_MIN, dayOptions, workerOptions } from "../../shared/studyFields";
|
import { STUDY_DAY_DEFAULT, STUDY_DAY_MAX, STUDY_DAY_MIN, dayOptions, workerOptions } from "../../shared/studyFields";
|
||||||
@@ -161,8 +162,6 @@ function withMinutes(value: string) {
|
|||||||
return `${value} 分钟`;
|
return `${value} 分钟`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const historyHoursNote = "由于Euniv学时统计缺陷/统计延后,本系统已开启采用当月学习历史统计本月学时,可能会导致本系统中显示的本月学时与Euniv官方网站不一样。";
|
|
||||||
|
|
||||||
interface HourFact {
|
interface HourFact {
|
||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
@@ -399,6 +398,7 @@ async function loadStart() {
|
|||||||
const workersLoaded = ref(false);
|
const workersLoaded = ref(false);
|
||||||
const courseWorkers = ref<number | null>(1);
|
const courseWorkers = ref<number | null>(1);
|
||||||
const heartbeatLoaded = ref(false);
|
const heartbeatLoaded = ref(false);
|
||||||
|
const hoursSource = ref<"api" | "history">("api");
|
||||||
const heartbeatMode = ref("auto");
|
const heartbeatMode = ref("auto");
|
||||||
const heartbeatVideo = ref<number | null>(30);
|
const heartbeatVideo = ref<number | null>(30);
|
||||||
const heartbeatDocument = ref<number | null>(120);
|
const heartbeatDocument = ref<number | null>(120);
|
||||||
@@ -487,6 +487,7 @@ function scheduleBody(): Record<string, unknown> | null {
|
|||||||
heartbeat_video_seconds: heartbeatVideo.value ?? 30,
|
heartbeat_video_seconds: heartbeatVideo.value ?? 30,
|
||||||
heartbeat_document_seconds: heartbeatDocument.value ?? 120,
|
heartbeat_document_seconds: heartbeatDocument.value ?? 120,
|
||||||
heartbeat_scorm_seconds: heartbeatScorm.value ?? 120,
|
heartbeat_scorm_seconds: heartbeatScorm.value ?? 120,
|
||||||
|
hours_source: hoursSource.value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,6 +499,7 @@ async function saveSchedule() {
|
|||||||
try {
|
try {
|
||||||
await putJson("/api/settings/study", body, "没有保存定时配置。");
|
await putJson("/api/settings/study", body, "没有保存定时配置。");
|
||||||
await loadStudyControl();
|
await loadStudyControl();
|
||||||
|
refresh();
|
||||||
} catch (exc) {
|
} catch (exc) {
|
||||||
scheduleError.value = exc instanceof Error ? exc.message : "没有保存。";
|
scheduleError.value = exc instanceof Error ? exc.message : "没有保存。";
|
||||||
} finally {
|
} finally {
|
||||||
@@ -578,6 +580,7 @@ async function loadHeartbeat() {
|
|||||||
heartbeatVideo.value = typeof data.heartbeat_video_seconds === "number" ? data.heartbeat_video_seconds : 30;
|
heartbeatVideo.value = typeof data.heartbeat_video_seconds === "number" ? data.heartbeat_video_seconds : 30;
|
||||||
heartbeatDocument.value = typeof data.heartbeat_document_seconds === "number" ? data.heartbeat_document_seconds : 120;
|
heartbeatDocument.value = typeof data.heartbeat_document_seconds === "number" ? data.heartbeat_document_seconds : 120;
|
||||||
heartbeatScorm.value = typeof data.heartbeat_scorm_seconds === "number" ? data.heartbeat_scorm_seconds : 120;
|
heartbeatScorm.value = typeof data.heartbeat_scorm_seconds === "number" ? data.heartbeat_scorm_seconds : 120;
|
||||||
|
hoursSource.value = data.hours_source === "history" ? "history" : "api";
|
||||||
heartbeatLoaded.value = true;
|
heartbeatLoaded.value = true;
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
@@ -1028,7 +1031,6 @@ onUnmounted(() => {
|
|||||||
刷新数据
|
刷新数据
|
||||||
</n-tooltip>
|
</n-tooltip>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="summary?.hours_source === 'history'" class="hours-source-note">{{ historyHoursNote }}</p>
|
|
||||||
<dl class="facts">
|
<dl class="facts">
|
||||||
<div v-for="item in facts" :key="item.label">
|
<div v-for="item in facts" :key="item.label">
|
||||||
<dt>{{ item.label }}</dt>
|
<dt>{{ item.label }}</dt>
|
||||||
@@ -1044,6 +1046,7 @@ onUnmounted(() => {
|
|||||||
<p v-if="summary?.limited" class="study-live-hint">只统计了最近 50 页</p>
|
<p v-if="summary?.limited" class="study-live-hint">只统计了最近 50 页</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<div class="home-lower">
|
||||||
<section class="panel-card study-card" :class="{ 'is-busy': studyingWorkers.length > 0 }">
|
<section class="panel-card study-card" :class="{ 'is-busy': studyingWorkers.length > 0 }">
|
||||||
<header class="study-head">
|
<header class="study-head">
|
||||||
<h3>自动学习</h3>
|
<h3>自动学习</h3>
|
||||||
@@ -1135,10 +1138,19 @@ onUnmounted(() => {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
|
<n-form-item v-if="heartbeatLoaded" label="学时判断">
|
||||||
|
<n-radio-group v-model:value="hoursSource" size="small">
|
||||||
|
<n-radio-button value="api">官方统计数据</n-radio-button>
|
||||||
|
<n-radio-button value="history">历史统计数据</n-radio-button>
|
||||||
|
</n-radio-group>
|
||||||
|
</n-form-item>
|
||||||
</n-form>
|
</n-form>
|
||||||
<p v-if="heartbeatLoaded && heartbeatMode === 'manual'" class="study-config-hint">
|
<p v-if="heartbeatLoaded && heartbeatMode === 'manual'" class="study-config-hint">
|
||||||
间隔越短,发送越频繁。设为 0 时连续发送,课程列表不显示倒计时。
|
间隔越短,发送越频繁。设为 0 时连续发送,课程列表不显示倒计时。
|
||||||
</p>
|
</p>
|
||||||
|
<p v-if="heartbeatLoaded" class="study-config-hint">
|
||||||
|
{{ hoursSource === "history" ? "根据学习历史统计本月学时" : "根据官方接口返回进行判断(官方统计可能会延后,导致学时可能会多刷)" }}
|
||||||
|
</p>
|
||||||
<div class="study-actions">
|
<div class="study-actions">
|
||||||
<n-button v-if="proxyLoaded" size="small" quaternary @click="proxyOpen = true">
|
<n-button v-if="proxyLoaded" size="small" quaternary @click="proxyOpen = true">
|
||||||
<template #icon><n-icon><GlobeOutline /></n-icon></template>
|
<template #icon><n-icon><GlobeOutline /></n-icon></template>
|
||||||
@@ -1175,7 +1187,7 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<n-progress type="line" :percentage="monthProgress.pct" :show-indicator="false" :height="6" />
|
<n-progress type="line" :percentage="monthProgress.pct" :show-indicator="false" :height="6" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="studyingWorkers.length" class="study-courses" :class="{ 'no-countdown': !countdownOn }">
|
<div class="study-courses" :class="{ 'no-countdown': !countdownOn }">
|
||||||
<div class="study-course-head" aria-hidden="true">
|
<div class="study-course-head" aria-hidden="true">
|
||||||
<span>正在学习</span>
|
<span>正在学习</span>
|
||||||
<span></span>
|
<span></span>
|
||||||
@@ -1184,7 +1196,7 @@ onUnmounted(() => {
|
|||||||
<span v-if="countdownOn" class="num">下次心跳</span>
|
<span v-if="countdownOn" class="num">下次心跳</span>
|
||||||
<span></span>
|
<span></span>
|
||||||
</div>
|
</div>
|
||||||
<ul class="study-workers" aria-label="正在学习的课程">
|
<ul v-if="studyingWorkers.length" class="study-workers" aria-label="正在学习的课程">
|
||||||
<li v-for="row in studyingWorkers" :key="row.id" class="study-worker">
|
<li v-for="row in studyingWorkers" :key="row.id" class="study-worker">
|
||||||
<span class="study-worker-title" :title="workerTitle(row)">{{ workerTitle(row) }}</span>
|
<span class="study-worker-title" :title="workerTitle(row)">{{ workerTitle(row) }}</span>
|
||||||
<div class="study-worker-bar">
|
<div class="study-worker-bar">
|
||||||
@@ -1196,11 +1208,13 @@ onUnmounted(() => {
|
|||||||
<span class="study-dot" role="img" :class="row.ok ? 'up' : 'down'" :aria-label="row.ok ? '正常' : '异常'"></span>
|
<span class="study-dot" role="img" :class="row.ok ? 'up' : 'down'" :aria-label="row.ok ? '正常' : '异常'"></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<p v-else-if="studyHint" class="study-live-hint">{{ studyHint }}</p>
|
||||||
</div>
|
</div>
|
||||||
<p v-else-if="studyHint" class="study-live-hint">{{ studyHint }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<NoticeRail />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<n-modal
|
<n-modal
|
||||||
:show="proxyOpen"
|
:show="proxyOpen"
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { apiFetch } from "../../shared/http";
|
||||||
|
import { onMounted, ref } from "vue";
|
||||||
|
import { NIcon } from "naive-ui";
|
||||||
|
import { ChevronBackOutline, ChevronForwardOutline, MegaphoneOutline } from "@vicons/ionicons5";
|
||||||
|
|
||||||
|
interface Notice {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
body: string;
|
||||||
|
link_url: string;
|
||||||
|
published_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const STORAGE_KEY = "euniv-notice-collapsed";
|
||||||
|
const collapsed = ref(localStorage.getItem(STORAGE_KEY) === "1");
|
||||||
|
const items = ref<Notice[]>([]);
|
||||||
|
|
||||||
|
function minuteText(value: string) {
|
||||||
|
const date = new Date(value);
|
||||||
|
if (Number.isNaN(date.getTime())) return value;
|
||||||
|
const pad = (part: number) => String(part).padStart(2, "0");
|
||||||
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggle() {
|
||||||
|
collapsed.value = !collapsed.value;
|
||||||
|
localStorage.setItem(STORAGE_KEY, collapsed.value ? "1" : "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiFetch("/api/announcements");
|
||||||
|
const payload: unknown = await response.json().catch(() => []);
|
||||||
|
if (!response.ok || !Array.isArray(payload)) return;
|
||||||
|
items.value = payload.flatMap((item) => {
|
||||||
|
if (!item || typeof item !== "object") return [];
|
||||||
|
const row = item as Record<string, unknown>;
|
||||||
|
if (typeof row.id !== "number" || typeof row.title !== "string") return [];
|
||||||
|
return [{
|
||||||
|
id: row.id,
|
||||||
|
title: row.title,
|
||||||
|
body: typeof row.body === "string" ? row.body : "",
|
||||||
|
link_url: typeof row.link_url === "string" ? row.link_url : "",
|
||||||
|
published_at: typeof row.published_at === "string" ? row.published_at : "",
|
||||||
|
}];
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
items.value = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<aside class="notice-rail" :class="{ collapsed }">
|
||||||
|
<header class="notice-head">
|
||||||
|
<button type="button" class="notice-toggle" :aria-label="collapsed ? '展开公告' : '收起公告'" @click="toggle">
|
||||||
|
<n-icon><ChevronForwardOutline v-if="!collapsed" /><ChevronBackOutline v-else /></n-icon>
|
||||||
|
</button>
|
||||||
|
<h3 v-if="!collapsed">公告</h3>
|
||||||
|
<n-icon v-else class="notice-mark"><MegaphoneOutline /></n-icon>
|
||||||
|
<span v-if="collapsed && items.length" class="notice-count">{{ items.length }}</span>
|
||||||
|
</header>
|
||||||
|
<div v-if="!collapsed" class="notice-scroll">
|
||||||
|
<p v-if="!items.length" class="notice-empty">暂无公告</p>
|
||||||
|
<ol v-else class="notice-timeline">
|
||||||
|
<li v-for="item in items" :key="item.id">
|
||||||
|
<time>{{ minuteText(item.published_at) }}</time>
|
||||||
|
<strong>{{ item.title }}</strong>
|
||||||
|
<p>{{ item.body }}</p>
|
||||||
|
<a v-if="item.link_url" :href="item.link_url" target="_blank" rel="noreferrer">打开链接</a>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
</template>
|
||||||
@@ -6,6 +6,7 @@ import { isDark, toggleTheme } from "../shared/theme";
|
|||||||
import { adminNavOptions, type AdminPageKey } from "./adminNavigation";
|
import { adminNavOptions, type AdminPageKey } from "./adminNavigation";
|
||||||
import UsersView from "../features/admin/UsersView.vue";
|
import UsersView from "../features/admin/UsersView.vue";
|
||||||
import CoursesView from "../features/admin/CoursesView.vue";
|
import CoursesView from "../features/admin/CoursesView.vue";
|
||||||
|
import NoticesView from "../features/admin/NoticesView.vue";
|
||||||
import SettingsView from "../features/admin/SettingsView.vue";
|
import SettingsView from "../features/admin/SettingsView.vue";
|
||||||
|
|
||||||
defineProps<{ username: string }>();
|
defineProps<{ username: string }>();
|
||||||
@@ -13,7 +14,7 @@ const emit = defineEmits<{ logout: []; refresh: [] }>();
|
|||||||
const page = ref<AdminPageKey>(pageFromHash());
|
const page = ref<AdminPageKey>(pageFromHash());
|
||||||
const collapsed = ref(window.innerWidth < 800);
|
const collapsed = ref(window.innerWidth < 800);
|
||||||
const holdOpen = ref(false);
|
const holdOpen = ref(false);
|
||||||
const pages = new Set<AdminPageKey>(["users", "courses", "settings"]);
|
const pages = new Set<AdminPageKey>(["users", "courses", "notices", "settings"]);
|
||||||
|
|
||||||
function hashName() {
|
function hashName() {
|
||||||
return window.location.hash.replace(/^#\/?/, "");
|
return window.location.hash.replace(/^#\/?/, "");
|
||||||
@@ -21,7 +22,7 @@ function hashName() {
|
|||||||
|
|
||||||
function pageFromHash(): AdminPageKey {
|
function pageFromHash(): AdminPageKey {
|
||||||
const name = hashName();
|
const name = hashName();
|
||||||
if (name === "courses" || name === "settings" || name === "users") return name;
|
if (name === "courses" || name === "settings" || name === "users" || name === "notices") return name;
|
||||||
return "users";
|
return "users";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +73,7 @@ onUnmounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function onMenu(key: string) {
|
function onMenu(key: string) {
|
||||||
if (key === "users" || key === "courses" || key === "settings") show(key);
|
if (key === "users" || key === "courses" || key === "notices" || key === "settings") show(key);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -131,6 +132,7 @@ function onMenu(key: string) {
|
|||||||
<n-layout class="content" :native-scrollbar="false" content-style="height: 100%; min-height: 0; overflow: hidden; display: flex; flex-direction: column;">
|
<n-layout class="content" :native-scrollbar="false" content-style="height: 100%; min-height: 0; overflow: hidden; display: flex; flex-direction: column;">
|
||||||
<UsersView v-if="page === 'users'" />
|
<UsersView v-if="page === 'users'" />
|
||||||
<CoursesView v-else-if="page === 'courses'" />
|
<CoursesView v-else-if="page === 'courses'" />
|
||||||
|
<NoticesView v-else-if="page === 'notices'" />
|
||||||
<SettingsView v-else-if="page === 'settings'" @saved="emit('refresh')" />
|
<SettingsView v-else-if="page === 'settings'" @saved="emit('refresh')" />
|
||||||
</n-layout>
|
</n-layout>
|
||||||
</n-layout>
|
</n-layout>
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
import type { Component } from "vue";
|
import type { Component } from "vue";
|
||||||
import { h } from "vue";
|
import { h } from "vue";
|
||||||
import { NIcon } from "naive-ui";
|
import { NIcon } from "naive-ui";
|
||||||
import { LibraryOutline, PeopleOutline, SettingsOutline } from "@vicons/ionicons5";
|
import { LibraryOutline, MegaphoneOutline, PeopleOutline, SettingsOutline } from "@vicons/ionicons5";
|
||||||
|
|
||||||
function renderIcon(icon: Component) {
|
function renderIcon(icon: Component) {
|
||||||
return () => h(NIcon, null, { default: () => h(icon) });
|
return () => h(NIcon, null, { default: () => h(icon) });
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AdminPageKey = "users" | "courses" | "settings";
|
export type AdminPageKey = "users" | "courses" | "notices" | "settings";
|
||||||
|
|
||||||
export const adminNavOptions = [
|
export const adminNavOptions = [
|
||||||
{ label: "用户管理", key: "users" as const, icon: renderIcon(PeopleOutline) },
|
{ label: "用户管理", key: "users" as const, icon: renderIcon(PeopleOutline) },
|
||||||
{ label: "课程清单", key: "courses" as const, icon: renderIcon(LibraryOutline) },
|
{ label: "课程清单", key: "courses" as const, icon: renderIcon(LibraryOutline) },
|
||||||
|
{ label: "公告", key: "notices" as const, icon: renderIcon(MegaphoneOutline) },
|
||||||
{ label: "系统配置", key: "settings" as const, icon: renderIcon(SettingsOutline) },
|
{ label: "系统配置", key: "settings" as const, icon: renderIcon(SettingsOutline) },
|
||||||
];
|
];
|
||||||
|
|||||||
+203
-21
@@ -469,14 +469,21 @@ select {
|
|||||||
.home {
|
.home {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow-x: hidden;
|
overflow: hidden;
|
||||||
overflow-y: auto;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.home-lower {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
.panel-card {
|
.panel-card {
|
||||||
background: var(--panel);
|
background: var(--panel);
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--line);
|
||||||
@@ -573,7 +580,6 @@ select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.home-summary {
|
.home-summary {
|
||||||
position: relative;
|
|
||||||
flex: none;
|
flex: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -599,20 +605,6 @@ select {
|
|||||||
flex: 0 1 auto;
|
flex: 0 1 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hours-source-note {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 1;
|
|
||||||
top: 16px;
|
|
||||||
left: 240px;
|
|
||||||
right: 52px;
|
|
||||||
margin: 0;
|
|
||||||
color: #f5a524;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.55;
|
|
||||||
text-align: center;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.home-refresh.n-button {
|
.home-refresh.n-button {
|
||||||
flex: none;
|
flex: none;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
@@ -796,8 +788,10 @@ select {
|
|||||||
|
|
||||||
.study-card,
|
.study-card,
|
||||||
.study-card.is-busy {
|
.study-card.is-busy {
|
||||||
flex: 0 0 auto;
|
flex: 1 1 auto;
|
||||||
overflow: visible;
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
@@ -829,6 +823,7 @@ select {
|
|||||||
|
|
||||||
.study-live {
|
.study-live {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
min-height: calc(48px + 20px + 28px + 8 * 32px);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
@@ -869,9 +864,11 @@ select {
|
|||||||
|
|
||||||
.study-courses {
|
.study-courses {
|
||||||
--course-cols: minmax(7rem, 1.4fr) minmax(4rem, 1fr) 56px 88px 56px 8px;
|
--course-cols: minmax(7rem, 1.4fr) minmax(4rem, 1fr) 56px 88px 56px 8px;
|
||||||
|
height: calc(28px + 8 * 32px);
|
||||||
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.study-courses.no-countdown {
|
.study-courses.no-countdown {
|
||||||
@@ -888,6 +885,8 @@ select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.study-course-head {
|
.study-course-head {
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 28px;
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
border-bottom: 1px solid var(--line);
|
border-bottom: 1px solid var(--line);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
@@ -901,11 +900,18 @@ select {
|
|||||||
|
|
||||||
.study-workers {
|
.study-workers {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
overflow: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.study-worker {
|
||||||
|
min-height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.study-worker-title {
|
.study-worker-title {
|
||||||
@@ -1373,11 +1379,27 @@ select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 1100px), (max-height: 760px) {
|
@media (max-width: 1100px), (max-height: 760px) {
|
||||||
|
.home-lower {
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.study-card,
|
.study-card,
|
||||||
.study-card.is-busy {
|
.study-card.is-busy {
|
||||||
flex: none;
|
flex: none;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notice-rail,
|
||||||
|
.notice-rail.collapsed {
|
||||||
|
flex: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 240px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-rail.collapsed {
|
||||||
|
height: 44px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 1100px) {
|
@media (max-width: 1100px) {
|
||||||
@@ -1831,3 +1853,163 @@ body .n-base-select-menu .n-base-select-option__content {
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notice-rail {
|
||||||
|
flex: 0 0 280px;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-rail.collapsed {
|
||||||
|
flex-basis: 44px;
|
||||||
|
align-items: center;
|
||||||
|
padding: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
min-height: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-rail.collapsed .notice-head {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-head h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 650;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-toggle {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-mark {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-count {
|
||||||
|
min-width: 18px;
|
||||||
|
padding: 0 4px;
|
||||||
|
border-radius: 9px;
|
||||||
|
background: #f5a524;
|
||||||
|
color: #1b1b1b;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 18px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-scroll {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-empty {
|
||||||
|
margin: 8px 0 0;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-timeline {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0 0 0 14px;
|
||||||
|
border-left: 1px solid var(--line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-timeline li {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
margin: 0 0 16px;
|
||||||
|
padding-left: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-timeline li::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: -18px;
|
||||||
|
top: 6px;
|
||||||
|
width: 7px;
|
||||||
|
height: 7px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #f5a524;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-timeline time {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-timeline strong {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-timeline p {
|
||||||
|
margin: 0;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-timeline a {
|
||||||
|
color: var(--text);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-admin {
|
||||||
|
list-style: none;
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-admin li {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
padding: 12px 0;
|
||||||
|
border-bottom: 1px solid var(--line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-admin time {
|
||||||
|
display: block;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-admin p {
|
||||||
|
margin: 6px 0 0;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice-admin-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user