feat: add announcements page and publishing workflow
This commit is contained in:
@@ -45,7 +45,7 @@ go -C backend build -o ../.local/mirrorouc .
|
|||||||
./mirrorouc -static ./dist -data ./data -manager http://127.0.0.1:12345 -worker YOUR_WORKER_ID
|
./mirrorouc -static ./dist -data ./data -manager http://127.0.0.1:12345 -worker YOUR_WORKER_ID
|
||||||
```
|
```
|
||||||
|
|
||||||
默认监听 `127.0.0.1:8081`,可通过 `-listen` 修改。首页为 `/`,管理后台为 `/admin`,同步状态页为 `/status`。数据库与上传文件保存在 `data/`,更新时保留该目录。
|
默认监听 `127.0.0.1:8081`,可通过 `-listen` 修改。首页为 `/`,公告页为 `/announcements`,管理后台为 `/admin`,同步状态页为 `/status`。数据库与上传文件保存在 `data/`,更新时保留该目录。
|
||||||
|
|
||||||
镜像目录与下载由已有的 Web 服务器提供,路径为 `/mirrors/<源名>/`。自定义目录页的 Fancyindex 模板随前端构建生成在 `dist/fancy-index/` 中。
|
镜像目录与下载由已有的 Web 服务器提供,路径为 `/mirrors/<源名>/`。自定义目录页的 Fancyindex 模板随前端构建生成在 `dist/fancy-index/` 中。
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,128 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func publicArticles(t *testing.T, c *testClient, home bool) []Record {
|
||||||
|
t.Helper()
|
||||||
|
path := "/api/v1/announcements"
|
||||||
|
if home {
|
||||||
|
path = "/api/v1/public"
|
||||||
|
}
|
||||||
|
w := c.call("GET", path, nil, false)
|
||||||
|
status(t, w, 200)
|
||||||
|
var records []Record
|
||||||
|
if home {
|
||||||
|
var payload struct {
|
||||||
|
Announcements []Record `json:"announcements"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(w.Body.Bytes(), &payload); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
records = payload.Announcements
|
||||||
|
} else if err := json.Unmarshal(w.Body.Bytes(), &records); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return records
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAnnouncementsArchiveAndHome(t *testing.T) {
|
||||||
|
c := fixture(t)
|
||||||
|
// An archive must include older articles beyond the former 100-record cap.
|
||||||
|
for i := 0; i < 105; i++ {
|
||||||
|
_, err := c.app.saveRecord("announcements", fmt.Sprintf("history-%03d", i), Announcement{Title: "历史公告", Body: "## Markdown 正文\n\n保留全文。", Published: true, Date: "2020-01-01T00:00:00Z"}, 0)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for id, article := range map[string]Announcement{
|
||||||
|
"pinned": {Title: "置顶公告", Body: "置顶正文", Published: true, Pinned: true, Date: "2019-01-01T00:00:00Z"},
|
||||||
|
"newer": {Title: "较晚公告", Body: "较晚正文", Published: true, Date: "2026-10-31T18:00:00Z"},
|
||||||
|
"older": {Title: "较早公告", Body: "较早正文", Published: true, Date: "2026-11-01T01:00:00+08:00"},
|
||||||
|
"draft": {Title: "未公开标题", Body: "未公开正文", Pinned: true, Date: "2027-01-01T00:00:00Z"},
|
||||||
|
} {
|
||||||
|
if _, err := c.app.saveRecord("announcements", id, article, 0); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
archive := publicArticles(t, c, false)
|
||||||
|
if len(archive) != 108 {
|
||||||
|
t.Fatalf("archive omitted published articles: %d", len(archive))
|
||||||
|
}
|
||||||
|
for i, id := range []string{"pinned", "newer", "older"} {
|
||||||
|
if archive[i].ID != id {
|
||||||
|
t.Fatalf("incorrect pinned / chronological order: %+v", archive[:3])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, record := range archive {
|
||||||
|
if record.ID == "draft" {
|
||||||
|
t.Fatal("draft exposed in archive")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var last Announcement
|
||||||
|
if err := decodeData(archive[len(archive)-1].Data, &last); err != nil || last.Body != "## Markdown 正文\n\n保留全文。" {
|
||||||
|
t.Fatal("archive did not retain complete Markdown")
|
||||||
|
}
|
||||||
|
home := publicArticles(t, c, true)
|
||||||
|
if len(home) != 5 || home[0].ID != "pinned" || home[1].ID != "newer" {
|
||||||
|
t.Fatalf("home should show five recent, pinned-first links: %+v", home)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAnnouncementPublishingLifecycle(t *testing.T) {
|
||||||
|
c := fixture(t)
|
||||||
|
c.login("editor")
|
||||||
|
article := Announcement{Title: "维护通知", Date: "2026-11-01T00:00:00+08:00"}
|
||||||
|
save := func(revision, want int) {
|
||||||
|
t.Helper()
|
||||||
|
status(t, c.call("PUT", "/api/v1/admin/records/announcements/maintenance", map[string]any{"data": article, "revision": revision}, true), want)
|
||||||
|
}
|
||||||
|
assertVisible := func(want int) {
|
||||||
|
t.Helper()
|
||||||
|
for _, home := range []bool{false, true} {
|
||||||
|
if got := len(publicArticles(t, c, home)); got != want {
|
||||||
|
t.Fatalf("public visibility: want %d, got %d (home=%v)", want, got, home)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
save(0, 200) // Empty bodies may be saved as drafts.
|
||||||
|
assertVisible(0)
|
||||||
|
article.Published = true
|
||||||
|
save(1, 400) // Publishing an empty body must not alter the draft.
|
||||||
|
assertVisible(0)
|
||||||
|
article.Body = "## 维护安排\n\n- 时间:今晚\n- 影响:短暂中断\n\n`apt update`"
|
||||||
|
save(1, 200)
|
||||||
|
assertVisible(1)
|
||||||
|
save(1, 409) // Another editor cannot overwrite a newer revision.
|
||||||
|
article.Published = false
|
||||||
|
save(2, 200)
|
||||||
|
assertVisible(0)
|
||||||
|
article.Published = true
|
||||||
|
save(3, 200)
|
||||||
|
assertVisible(1)
|
||||||
|
status(t, c.call("DELETE", "/api/v1/admin/records/announcements/maintenance", map[string]int{"revision": 4}, true), 200)
|
||||||
|
assertVisible(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAnnouncementsDirectNavigation(t *testing.T) {
|
||||||
|
c := fixture(t)
|
||||||
|
if err := os.WriteFile(filepath.Join(c.app.cfg.Static, "index.html"), []byte("<!doctype html><title>MirrorOUC</title>"), 0600); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, path := range []string{"/announcements", "/announcements/"} {
|
||||||
|
for _, method := range []string{"GET", "HEAD"} {
|
||||||
|
w := c.call(method, path, nil, false)
|
||||||
|
status(t, w, 200)
|
||||||
|
if method == "HEAD" && w.Body.Len() != 0 {
|
||||||
|
t.Fatal("HEAD returned a response body")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status(t, c.call("POST", "/announcements", nil, false), 405)
|
||||||
|
status(t, c.call("GET", "/announcements/missing", nil, false), 404)
|
||||||
|
}
|
||||||
+29
-6
@@ -291,11 +291,23 @@ func (a *App) public(w http.ResponseWriter, r *http.Request) {
|
|||||||
mirrors = append(mirrors, publicMirror(job, meta))
|
mirrors = append(mirrors, publicMirror(job, meta))
|
||||||
}
|
}
|
||||||
sort.Slice(mirrors, func(i, j int) bool { return mirrors[i].Name < mirrors[j].Name })
|
sort.Slice(mirrors, func(i, j int) bool { return mirrors[i].Name < mirrors[j].Name })
|
||||||
announcements, err := a.records("announcements")
|
published, err := a.publishedAnnouncements()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.internal(w, err)
|
a.internal(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// The home page only needs recent links. The archive endpoint returns all bodies.
|
||||||
|
if len(published) > 5 {
|
||||||
|
published = published[:5]
|
||||||
|
}
|
||||||
|
respond(w, 200, map[string]any{"site": site.Data, "mirrors": mirrors, "announcements": published, "source": map[string]any{"updatedAt": updated, "stale": upstreamError != "" || updated == 0 || time.Now().UnixMilli()-updated > 60000, "code": upstreamError}})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) publishedAnnouncements() ([]Record, error) {
|
||||||
|
announcements, err := a.records("announcements")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
published := []Record{}
|
published := []Record{}
|
||||||
for _, record := range announcements {
|
for _, record := range announcements {
|
||||||
var d Announcement
|
var d Announcement
|
||||||
@@ -309,12 +321,23 @@ func (a *App) public(w http.ResponseWriter, r *http.Request) {
|
|||||||
if a.Pinned != b.Pinned {
|
if a.Pinned != b.Pinned {
|
||||||
return a.Pinned
|
return a.Pinned
|
||||||
}
|
}
|
||||||
return a.Date > b.Date
|
at, _ := time.Parse(time.RFC3339, a.Date)
|
||||||
})
|
bt, _ := time.Parse(time.RFC3339, b.Date)
|
||||||
if len(published) > 100 {
|
if !at.Equal(bt) {
|
||||||
published = published[:100]
|
return at.After(bt)
|
||||||
}
|
}
|
||||||
respond(w, 200, map[string]any{"site": site.Data, "mirrors": mirrors, "announcements": published, "source": map[string]any{"updatedAt": updated, "stale": upstreamError != "" || updated == 0 || time.Now().UnixMilli()-updated > 60000, "code": upstreamError}})
|
return published[i].ID < published[j].ID
|
||||||
|
})
|
||||||
|
return published, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) announcements(w http.ResponseWriter, r *http.Request) {
|
||||||
|
published, err := a.publishedAnnouncements()
|
||||||
|
if err != nil {
|
||||||
|
a.internal(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
respond(w, 200, published)
|
||||||
}
|
}
|
||||||
func (a *App) overview(w http.ResponseWriter, r *http.Request) {
|
func (a *App) overview(w http.ResponseWriter, r *http.Request) {
|
||||||
if _, ok := a.require(w, r, false); !ok {
|
if _, ok := a.require(w, r, false); !ok {
|
||||||
|
|||||||
+2
-1
@@ -103,6 +103,7 @@ func (a *App) handler() http.Handler {
|
|||||||
respond(w, 200, map[string]string{"status": "ok"})
|
respond(w, 200, map[string]string{"status": "ok"})
|
||||||
})
|
})
|
||||||
mux.HandleFunc("GET /api/v1/public", a.public)
|
mux.HandleFunc("GET /api/v1/public", a.public)
|
||||||
|
mux.HandleFunc("GET /api/v1/announcements", a.announcements)
|
||||||
mux.HandleFunc("GET /api/v1/monitoring", a.monitoring)
|
mux.HandleFunc("GET /api/v1/monitoring", a.monitoring)
|
||||||
mux.HandleFunc("GET /api/v1/job-speeds", a.jobSpeeds)
|
mux.HandleFunc("GET /api/v1/job-speeds", a.jobSpeeds)
|
||||||
mux.HandleFunc("POST /api/v1/auth/login", a.login)
|
mux.HandleFunc("POST /api/v1/auth/login", a.login)
|
||||||
@@ -140,7 +141,7 @@ func (a *App) handler() http.Handler {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
path := r.URL.Path
|
path := r.URL.Path
|
||||||
if path == "/" || path == "/status" || path == "/status/" || path == "/admin" || strings.HasPrefix(path, "/admin/") {
|
if path == "/" || path == "/status" || path == "/status/" || path == "/announcements" || path == "/announcements/" || path == "/admin" || strings.HasPrefix(path, "/admin/") {
|
||||||
http.ServeFile(w, r, filepath.Join(a.cfg.Static, "index.html"))
|
http.ServeFile(w, r, filepath.Join(a.cfg.Static, "index.html"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const t = (key: string) => i18n.global.t(key)
|
|||||||
const escape = (value: string) => value.replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char]!)
|
const escape = (value: string) => value.replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char]!)
|
||||||
const text = (key: string) => `<span data-i18n="${key}">${escape(t(key))}</span>`
|
const text = (key: string) => `<span data-i18n="${key}">${escape(t(key))}</span>`
|
||||||
const navigation = [
|
const navigation = [
|
||||||
['mirrors', '/'], ['news', 'https://www.itouc.cn/announcements/'], ['status', '/status'],
|
['mirrors', '/'], ['news', '/announcements'], ['status', '/status'],
|
||||||
['feedback', 'https://git.itouc.cn/ITStudio_OUC/OUCMirror-WebUI/issues'],
|
['feedback', 'https://git.itouc.cn/ITStudio_OUC/OUCMirror-WebUI/issues'],
|
||||||
].map(([key, href]) => `<a class="nav-link${key === 'mirrors' ? ' active' : ''}" href="${href}">${text(`common.nav.${key}`)}</a>`).join('')
|
].map(([key, href]) => `<a class="nav-link${key === 'mirrors' ? ' active' : ''}" href="${href}">${text(`common.nav.${key}`)}</a>`).join('')
|
||||||
const languages = Object.entries(directoryMessages).map(([locale, messages]) => `<button class="language-option" data-locale="${locale}" lang="${locale}">${escape(messages.common.languageName)}</button>`).join('')
|
const languages = Object.entries(directoryMessages).map(([locale, messages]) => `<button class="language-option" data-locale="${locale}" lang="${locale}">${escape(messages.common.languageName)}</button>`).join('')
|
||||||
|
|||||||
+21
-19
@@ -10,14 +10,16 @@ import RollingText from './components/RollingText.vue'
|
|||||||
import LanguagePicker from './components/LanguagePicker.vue'
|
import LanguagePicker from './components/LanguagePicker.vue'
|
||||||
import StatusPage from './components/StatusPage.vue'
|
import StatusPage from './components/StatusPage.vue'
|
||||||
import AdminPage from './components/AdminPage.vue'
|
import AdminPage from './components/AdminPage.vue'
|
||||||
|
import AnnouncementsPage from './components/AnnouncementsPage.vue'
|
||||||
import MarkdownContent from './components/MarkdownContent.vue'
|
import MarkdownContent from './components/MarkdownContent.vue'
|
||||||
import { content } from './api'
|
import { content } from './api'
|
||||||
|
import { announcementUrl } from './announcements'
|
||||||
import { usePublicData } from './usePublicData'
|
import { usePublicData } from './usePublicData'
|
||||||
import { useMirrorFormats } from './useMirrorFormats'
|
import { useMirrorFormats } from './useMirrorFormats'
|
||||||
import { type Mirror } from './data'
|
import { type Mirror } from './data'
|
||||||
import { datetimeFormats, readPreference, savePreference, type Locale } from './locales'
|
import { datetimeFormats, readPreference, savePreference, type Locale } from './locales'
|
||||||
|
|
||||||
const { t, d, locale } = useI18n()
|
const { t, locale } = useI18n()
|
||||||
const isAdminPage = window.location.pathname.startsWith('/admin')
|
const isAdminPage = window.location.pathname.startsWith('/admin')
|
||||||
const { site, mirrors, announcements: articleRecords, source, loading } = usePublicData()
|
const { site, mirrors, announcements: articleRecords, source, loading } = usePublicData()
|
||||||
const announcements = computed(() => articleRecords.value.map(row => ({ id: row.id, ...row.data })))
|
const announcements = computed(() => articleRecords.value.map(row => ({ id: row.id, ...row.data })))
|
||||||
@@ -38,9 +40,10 @@ const themeRoot = ref<HTMLElement>()
|
|||||||
const themes: Theme[] = ['light', 'dark', 'system']
|
const themes: Theme[] = ['light', 'dark', 'system']
|
||||||
const themeIcons = { light: Sun, dark: Moon, system: Monitor }
|
const themeIcons = { light: Sun, dark: Moon, system: Monitor }
|
||||||
const isStatusPage = window.location.pathname.replace(/\/$/, '') === '/status'
|
const isStatusPage = window.location.pathname.replace(/\/$/, '') === '/status'
|
||||||
|
const isAnnouncementsPage = window.location.pathname.replace(/\/$/, '') === '/announcements'
|
||||||
const navigation = [
|
const navigation = [
|
||||||
{ key: 'mirrors', href: '/', active: !isStatusPage && !isAdminPage },
|
{ key: 'mirrors', href: '/', active: !isStatusPage && !isAdminPage && !isAnnouncementsPage },
|
||||||
{ key: 'news', href: 'https://www.itouc.cn/announcements/', active: false },
|
{ key: 'news', href: '/announcements', active: isAnnouncementsPage },
|
||||||
{ key: 'status', href: '/status', active: isStatusPage },
|
{ key: 'status', href: '/status', active: isStatusPage },
|
||||||
{ key: 'feedback', href: 'https://git.itouc.cn/ITStudio_OUC/OUCMirror-WebUI/issues', active: false },
|
{ key: 'feedback', href: 'https://git.itouc.cn/ITStudio_OUC/OUCMirror-WebUI/issues', active: false },
|
||||||
]
|
]
|
||||||
@@ -55,7 +58,10 @@ watch(locale, (value) => {
|
|||||||
document.title = t('common.pageTitle')
|
document.title = t('common.pageTitle')
|
||||||
savePreference('mirrorouc.locale', value)
|
savePreference('mirrorouc.locale', value)
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
watch([locale, site], () => { document.title = site.value ? `MirrorOUC · ${content(site.value.name, locale.value)}` : t('common.pageTitle') })
|
watch([locale, site], () => {
|
||||||
|
const siteTitle = site.value ? `MirrorOUC · ${content(site.value.name, locale.value)}` : t('common.pageTitle')
|
||||||
|
document.title = isAnnouncementsPage ? `${t('announcements.title')} · ${siteTitle}` : siteTitle
|
||||||
|
}, { immediate: true })
|
||||||
function selectTheme(value: Theme) { theme.value = value; themeOpen.value = false }
|
function selectTheme(value: Theme) { theme.value = value; themeOpen.value = false }
|
||||||
|
|
||||||
const search = ref('')
|
const search = ref('')
|
||||||
@@ -86,22 +92,18 @@ function nextLabel(mirror: Mirror) {
|
|||||||
}
|
}
|
||||||
function resetSearch() { search.value = ''; searchInput.value?.focus() }
|
function resetSearch() { search.value = ''; searchInput.value?.focus() }
|
||||||
|
|
||||||
type Modal = 'help' | 'news' | 'about' | 'downloads' | 'mirror'
|
type Modal = 'help' | 'about' | 'downloads' | 'mirror'
|
||||||
const dialog = ref<HTMLDialogElement>()
|
const dialog = ref<HTMLDialogElement>()
|
||||||
const modal = ref<Modal | null>(null)
|
const modal = ref<Modal | null>(null)
|
||||||
const selectedMirror = ref<Mirror | null>(null)
|
const selectedMirror = ref<Mirror | null>(null)
|
||||||
const selectedNews = ref<string | null>(null)
|
|
||||||
const activeNews = computed(() => announcements.value.find(item => item.id === selectedNews.value))
|
|
||||||
const modalTitle = computed(() => {
|
const modalTitle = computed(() => {
|
||||||
if (modal.value === 'mirror') return selectedMirror.value?.name || ''
|
if (modal.value === 'mirror') return selectedMirror.value?.name || ''
|
||||||
if (modal.value === 'news' && activeNews.value) return activeNews.value.title
|
const keys = { help: 'mirrors.helpTitle', about: 'common.aboutTitle', downloads: 'announcements.downloadsTitle' }
|
||||||
const keys = { help: 'mirrors.helpTitle', news: 'announcements.title', about: 'common.aboutTitle', downloads: 'announcements.downloadsTitle' }
|
|
||||||
return modal.value && modal.value in keys ? t(keys[modal.value as keyof typeof keys]) : ''
|
return modal.value && modal.value in keys ? t(keys[modal.value as keyof typeof keys]) : ''
|
||||||
})
|
})
|
||||||
async function openModal(value: Modal, mirror?: Mirror, news?: string) {
|
async function openModal(value: Modal, mirror?: Mirror) {
|
||||||
modal.value = value
|
modal.value = value
|
||||||
selectedMirror.value = mirror || null
|
selectedMirror.value = mirror || null
|
||||||
selectedNews.value = news || null
|
|
||||||
mobileOpen.value = false
|
mobileOpen.value = false
|
||||||
themeOpen.value = false
|
themeOpen.value = false
|
||||||
await nextTick()
|
await nextTick()
|
||||||
@@ -114,7 +116,7 @@ watch(modal, value => { document.body.classList.toggle('dialog-open', value !==
|
|||||||
function onKeydown(event: KeyboardEvent) {
|
function onKeydown(event: KeyboardEvent) {
|
||||||
if (event.key === 'Escape') { themeOpen.value = false; mobileOpen.value = false }
|
if (event.key === 'Escape') { themeOpen.value = false; mobileOpen.value = false }
|
||||||
const target = event.target as HTMLElement
|
const target = event.target as HTMLElement
|
||||||
if (!dialog.value?.open && ((event.key === 'k' && (event.ctrlKey || event.metaKey))
|
if (!isAdminPage && !isAnnouncementsPage && !dialog.value?.open && ((event.key === 'k' && (event.ctrlKey || event.metaKey))
|
||||||
|| (event.key === '/' && !['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName) && !target.isContentEditable))) {
|
|| (event.key === '/' && !['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName) && !target.isContentEditable))) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
if (isStatusPage) statusPage.value?.focusSearch()
|
if (isStatusPage) statusPage.value?.focusSearch()
|
||||||
@@ -152,7 +154,7 @@ onBeforeUnmount(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<a class="skip-link" :href="isAdminPage ? '#administration' : isStatusPage ? '#site-status' : '#mirrors'">{{ t(isAdminPage ? 'common.skipAdmin' : isStatusPage ? 'common.skipStatus' : 'common.skip') }}</a>
|
<a class="skip-link" :href="isAdminPage ? '#administration' : isStatusPage ? '#site-status' : isAnnouncementsPage ? '#announcements' : '#mirrors'">{{ t(isAdminPage ? 'common.skipAdmin' : isStatusPage ? 'common.skipStatus' : isAnnouncementsPage ? 'common.skipAnnouncements' : 'common.skip') }}</a>
|
||||||
<header class="site-header">
|
<header class="site-header">
|
||||||
<a href="/" class="brand" :aria-label="content(site?.name, locale) || t('common.siteName')">
|
<a href="/" class="brand" :aria-label="content(site?.name, locale) || t('common.siteName')">
|
||||||
<span class="brand-logo"><img :src="brandLogo" alt="" width="2000" height="433" /></span>
|
<span class="brand-logo"><img :src="brandLogo" alt="" width="2000" height="433" /></span>
|
||||||
@@ -177,8 +179,9 @@ onBeforeUnmount(() => {
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main class="page-width">
|
<main class="page-width">
|
||||||
<p v-if="!isAdminPage && (loading || source.stale)" class="data-notice" role="status">{{ t(loading ? 'common.loading' : source.updatedAt ? 'common.stale' : 'common.unavailable') }}</p>
|
<p v-if="!isAdminPage && !isAnnouncementsPage && (loading || source.stale)" class="data-notice" role="status">{{ t(loading ? 'common.loading' : source.updatedAt ? 'common.stale' : 'common.unavailable') }}</p>
|
||||||
<AdminPage v-if="isAdminPage" />
|
<AdminPage v-if="isAdminPage" />
|
||||||
|
<AnnouncementsPage v-else-if="isAnnouncementsPage" />
|
||||||
<StatusPage v-else-if="isStatusPage" ref="statusPage" :mirrors="mirrors" :now="now" :cycle="boardCycle" :show-next-sync="showNextSync" @mirror="openModal('mirror', $event)" />
|
<StatusPage v-else-if="isStatusPage" ref="statusPage" :mirrors="mirrors" :now="now" :cycle="boardCycle" :show-next-sync="showNextSync" @mirror="openModal('mirror', $event)" />
|
||||||
<div v-else class="main-grid">
|
<div v-else class="main-grid">
|
||||||
<section id="mirrors" class="mirror-section" tabindex="-1">
|
<section id="mirrors" class="mirror-section" tabindex="-1">
|
||||||
@@ -213,11 +216,11 @@ onBeforeUnmount(() => {
|
|||||||
|
|
||||||
<aside class="sidebar">
|
<aside class="sidebar">
|
||||||
<section class="side-section announcements">
|
<section class="side-section announcements">
|
||||||
<div class="side-heading"><h2>{{ t('announcements.title') }}</h2><button class="sidebar-more" :aria-label="t('announcements.more')" @click="openModal('news')">{{ t('announcements.moreLabel') }}</button></div>
|
<div class="side-heading"><h2>{{ t('announcements.title') }}</h2><a class="sidebar-more" href="/announcements" :aria-label="t('announcements.more')">{{ t('announcements.moreLabel') }}</a></div>
|
||||||
<button v-for="item in announcements" :key="item.id" class="news-item" :title="item.title" :aria-label="`${announcementDate(item.date)} ${item.title}`" @click="openModal('news', undefined, item.id)">
|
<a v-for="item in announcements" :key="item.id" class="news-item" :href="announcementUrl(item.id)" :title="item.title" :aria-label="`${announcementDate(item.date)} ${item.title}`">
|
||||||
<time :datetime="item.date">{{ announcementDate(item.date) }}</time>
|
<time :datetime="item.date">{{ announcementDate(item.date) }}</time>
|
||||||
<span class="news-title" lang="zh-CN">{{ item.title }}</span>
|
<span class="news-title" lang="zh-CN">{{ item.title }}</span>
|
||||||
</button>
|
</a>
|
||||||
<p v-if="!announcements.length" class="dialog-hint">{{ t('common.noAnnouncements') }}</p>
|
<p v-if="!announcements.length" class="dialog-hint">{{ t('common.noAnnouncements') }}</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -275,11 +278,10 @@ onBeforeUnmount(() => {
|
|||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<dialog id="content-dialog" ref="dialog" class="content-dialog" aria-labelledby="dialog-title" @close="onDialogClose" @click="($event.target === $event.currentTarget) && closeModal()">
|
<dialog id="content-dialog" ref="dialog" class="content-dialog" aria-labelledby="dialog-title" @close="onDialogClose" @click="($event.target === $event.currentTarget) && closeModal()">
|
||||||
<div class="dialog-inner"><div class="dialog-heading"><h2 id="dialog-title" :lang="modal === 'news' && activeNews ? 'zh-CN' : undefined">{{ modalTitle }}</h2><button class="icon-button" :aria-label="t('common.close')" autofocus @click="closeModal"><X :size="21" /></button></div>
|
<div class="dialog-inner"><div class="dialog-heading"><h2 id="dialog-title">{{ modalTitle }}</h2><button class="icon-button" :aria-label="t('common.close')" autofocus @click="closeModal"><X :size="21" /></button></div>
|
||||||
<div class="dialog-content">
|
<div class="dialog-content">
|
||||||
<template v-if="modal === 'mirror' && selectedMirror"><p class="dialog-lead">{{ description(selectedMirror) }}</p><div class="mirror-facts"><span>{{ t('mirrors.columns.status') }}</span><span>{{ t(`mirrors.status.${selectedMirror.status}`) }}</span><span>{{ t('mirrors.columns.updated') }}</span><span>{{ relativeTime(selectedMirror.lastSuccess) }}</span><span>{{ t('mirrors.columns.next') }}</span><span>{{ nextLabel(selectedMirror) }}</span></div><MarkdownContent v-if="selectedMirror.help" :source="selectedMirror.help" lang="zh-CN" /><p v-else class="dialog-hint">{{ t('common.noHelp') }}</p><div class="dialog-actions"><a class="text-button" :href="selectedMirror.browseUrl">{{ t('common.openDirectory') }}<ArrowRight :size="15" /></a><a v-if="selectedMirror.website" :href="selectedMirror.website" target="_blank" rel="noopener noreferrer" class="text-button">{{ t('mirrors.official') }}<ExternalLink :size="14" /></a></div></template>
|
<template v-if="modal === 'mirror' && selectedMirror"><p class="dialog-lead">{{ description(selectedMirror) }}</p><div class="mirror-facts"><span>{{ t('mirrors.columns.status') }}</span><span>{{ t(`mirrors.status.${selectedMirror.status}`) }}</span><span>{{ t('mirrors.columns.updated') }}</span><span>{{ relativeTime(selectedMirror.lastSuccess) }}</span><span>{{ t('mirrors.columns.next') }}</span><span>{{ nextLabel(selectedMirror) }}</span></div><MarkdownContent v-if="selectedMirror.help" :source="selectedMirror.help" lang="zh-CN" /><p v-else class="dialog-hint">{{ t('common.noHelp') }}</p><div class="dialog-actions"><a class="text-button" :href="selectedMirror.browseUrl">{{ t('common.openDirectory') }}<ArrowRight :size="15" /></a><a v-if="selectedMirror.website" :href="selectedMirror.website" target="_blank" rel="noopener noreferrer" class="text-button">{{ t('mirrors.official') }}<ExternalLink :size="14" /></a></div></template>
|
||||||
<template v-else-if="modal === 'help'"><p class="dialog-lead">{{ t('mirrors.helpIntro') }}</p><div class="help-grid"><button v-for="mirror in mirrors" :key="mirror.name" @click="openModal('mirror', mirror)"><span class="distro-mark" :style="{ '--distro-color': mirror.color }" aria-hidden="true">{{ mirror.mark }}</span><span>{{ mirror.name }}</span><ArrowRight :size="15" /></button></div></template>
|
<template v-else-if="modal === 'help'"><p class="dialog-lead">{{ t('mirrors.helpIntro') }}</p><div class="help-grid"><button v-for="mirror in mirrors" :key="mirror.name" @click="openModal('mirror', mirror)"><span class="distro-mark" :style="{ '--distro-color': mirror.color }" aria-hidden="true">{{ mirror.mark }}</span><span>{{ mirror.name }}</span><ArrowRight :size="15" /></button></div></template>
|
||||||
<template v-else-if="modal === 'news'"><template v-if="activeNews"><time class="article-date" :datetime="activeNews.date">{{ d(new Date(activeNews.date), 'article') }}</time><MarkdownContent :source="activeNews.body" lang="zh-CN" /></template><template v-else><p class="dialog-lead">{{ t('announcements.newsIntro') }}</p><button v-for="item in announcements" :key="item.id" class="article-link" @click="selectedNews = item.id"><span lang="zh-CN">{{ item.title }}</span><ArrowRight :size="17" /></button></template></template>
|
|
||||||
<template v-else-if="modal === 'downloads'"><p class="dialog-lead">{{ t('announcements.downloadsIntro') }}</p><p v-if="!distributions.length" class="dialog-hint">{{ t('common.noDownloads') }}</p><div class="modal-downloads"><a v-for="distro in distributions" :key="distro.name" :href="distro.url" target="_blank" rel="noopener noreferrer"><span>{{ distro.name }} {{ distro.version }}</span><ArrowUpRight :size="18" /></a></div></template>
|
<template v-else-if="modal === 'downloads'"><p class="dialog-lead">{{ t('announcements.downloadsIntro') }}</p><p v-if="!distributions.length" class="dialog-hint">{{ t('common.noDownloads') }}</p><div class="modal-downloads"><a v-for="distro in distributions" :key="distro.name" :href="distro.url" target="_blank" rel="noopener noreferrer"><span>{{ distro.name }} {{ distro.version }}</span><ArrowUpRight :size="18" /></a></div></template>
|
||||||
<template v-else-if="modal === 'about'"><img class="about-seal" :src="site?.avatar || '/assets/ouc-seal.png'" alt="" width="80" height="80" /><p class="article-body">{{ t('common.aboutBody') }}</p><div class="about-links"><a href="https://www.itouc.cn/" target="_blank" rel="noopener noreferrer">{{ t('common.studio') }}<ArrowUpRight :size="15" /></a><a href="https://github.com/tuna/tunasync" target="_blank" rel="noopener noreferrer">{{ t('common.source') }} · tunasync<ArrowUpRight :size="15" /></a></div></template>
|
<template v-else-if="modal === 'about'"><img class="about-seal" :src="site?.avatar || '/assets/ouc-seal.png'" alt="" width="80" height="80" /><p class="article-body">{{ t('common.aboutBody') }}</p><div class="about-links"><a href="https://www.itouc.cn/" target="_blank" rel="noopener noreferrer">{{ t('common.studio') }}<ArrowUpRight :size="15" /></a><a href="https://github.com/tuna/tunasync" target="_blank" rel="noopener noreferrer">{{ t('common.source') }} · tunasync<ArrowUpRight :size="15" /></a></div></template>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export const announcementAnchor = (id: string) => `announcement-${id}`
|
||||||
|
export const announcementUrl = (id: string) => `/announcements#${encodeURIComponent(announcementAnchor(id))}`
|
||||||
@@ -3,6 +3,7 @@ import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'v
|
|||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { api, ApiError, jsonBody, setSession, type AdminSession, type AdminUser, type AnnouncementContent, type AuditPage, type ConfigVersion, type ContentRecord, type MirrorMetadata, type Overview, type SiteSettings, type SyncConfig, type SyncConfigMirror, type SyncJob } from '../api'
|
import { api, ApiError, jsonBody, setSession, type AdminSession, type AdminUser, type AnnouncementContent, type AuditPage, type ConfigVersion, type ContentRecord, type MirrorMetadata, type Overview, type SiteSettings, type SyncConfig, type SyncConfigMirror, type SyncJob } from '../api'
|
||||||
import { supportedLocales } from '../locales'
|
import { supportedLocales } from '../locales'
|
||||||
|
import { announcementUrl } from '../announcements'
|
||||||
import MarkdownContent from './MarkdownContent.vue'
|
import MarkdownContent from './MarkdownContent.vue'
|
||||||
|
|
||||||
const { t, te, d, n } = useI18n({ useScope: 'global' })
|
const { t, te, d, n } = useI18n({ useScope: 'global' })
|
||||||
@@ -24,6 +25,11 @@ const audit = ref<AuditPage>({ items: [], page: 1, pageSize: 10, total: 0, total
|
|||||||
const search = ref('')
|
const search = ref('')
|
||||||
const jobs = computed(() => (overview.value?.jobs || []).filter(job => `${job.name} ${job.upstream}`.toLowerCase().includes(search.value.toLowerCase())).sort((a, b) => a.name.localeCompare(b.name, 'en')))
|
const jobs = computed(() => (overview.value?.jobs || []).filter(job => `${job.name} ${job.upstream}`.toLowerCase().includes(search.value.toLowerCase())).sort((a, b) => a.name.localeCompare(b.name, 'en')))
|
||||||
const articlesEditor = ref<ContentRecord<AnnouncementContent> | null>(null)
|
const articlesEditor = ref<ContentRecord<AnnouncementContent> | null>(null)
|
||||||
|
const articleForm = ref<HTMLFormElement>()
|
||||||
|
const articleView = ref<'write' | 'preview'>('write')
|
||||||
|
const articlePublished = computed(() => articlesEditor.value?.data.published ?? false)
|
||||||
|
const sortedArticles = computed(() => [...articles.value].sort((a, b) => Number(b.data.pinned) - Number(a.data.pinned) || Date.parse(b.data.date) - Date.parse(a.data.date)))
|
||||||
|
const articleDate = computed(() => articlesEditor.value?.data.date ? new Intl.DateTimeFormat('en-CA', { year: 'numeric', month: '2-digit', day: '2-digit', timeZone: 'Asia/Shanghai' }).format(new Date(articlesEditor.value.data.date)) : '')
|
||||||
const mirrorEditor = ref<ContentRecord<MirrorMetadata> | null>(null)
|
const mirrorEditor = ref<ContentRecord<MirrorMetadata> | null>(null)
|
||||||
const editLocale = ref('zh-CN')
|
const editLocale = ref('zh-CN')
|
||||||
const logs = ref<{ name: string; text: string } | null>(null)
|
const logs = ref<{ name: string; text: string } | null>(null)
|
||||||
@@ -99,9 +105,29 @@ function confirmed() { const action = confirmation.value?.action; confirmDialog.
|
|||||||
function newArticle() {
|
function newArticle() {
|
||||||
const id = Array.from(crypto.getRandomValues(new Uint8Array(16)), byte => byte.toString(16).padStart(2, '0')).join('')
|
const id = Array.from(crypto.getRandomValues(new Uint8Array(16)), byte => byte.toString(16).padStart(2, '0')).join('')
|
||||||
articlesEditor.value = { id, revision: 0, updatedAt: 0, data: { title: '', body: '', published: false, pinned: false, date: new Date().toISOString() } }
|
articlesEditor.value = { id, revision: 0, updatedAt: 0, data: { title: '', body: '', published: false, pinned: false, date: new Date().toISOString() } }
|
||||||
|
void focusArticle()
|
||||||
|
}
|
||||||
|
async function focusArticle() {
|
||||||
|
articleView.value = 'write'
|
||||||
|
await nextTick()
|
||||||
|
articleForm.value?.scrollIntoView({ block: 'start' })
|
||||||
|
articleForm.value?.querySelector<HTMLInputElement>('[name="article-title"]')?.focus({ preventScroll: true })
|
||||||
|
}
|
||||||
|
function editArticle(record: ContentRecord<AnnouncementContent>) { articlesEditor.value = clone(record); articlesEditor.value.data.title ||= ''; articlesEditor.value.data.body ||= ''; void focusArticle() }
|
||||||
|
function submitArticle(event: Event) {
|
||||||
|
const published = ((event as SubmitEvent).submitter as HTMLButtonElement | null)?.value === 'publish'
|
||||||
|
void run(() => saveArticle(published))
|
||||||
|
}
|
||||||
|
async function saveArticle(published: boolean) {
|
||||||
|
if (!articlesEditor.value) return
|
||||||
|
const record = clone(articlesEditor.value)
|
||||||
|
const wasPublished = record.data.published
|
||||||
|
record.data.published = published
|
||||||
|
const saved = await saveRecord('announcements', record)
|
||||||
|
articlesEditor.value = saved
|
||||||
|
articles.value = [saved, ...articles.value.filter(row => row.id !== saved.id)]
|
||||||
|
notice.value = t(published ? wasPublished ? 'admin.articleUpdated' : 'admin.articlePublished' : wasPublished ? 'admin.articleWithdrawn' : 'admin.draftSaved')
|
||||||
}
|
}
|
||||||
function editArticle(record: ContentRecord<AnnouncementContent>) { articlesEditor.value = clone(record); articlesEditor.value.data.title ||= ''; articlesEditor.value.data.body ||= '' }
|
|
||||||
async function saveArticle() { if (!articlesEditor.value) return; articlesEditor.value = await saveRecord('announcements', articlesEditor.value); articles.value = await api('/admin/records/announcements') }
|
|
||||||
function deleteArticle(record: ContentRecord<AnnouncementContent>) {
|
function deleteArticle(record: ContentRecord<AnnouncementContent>) {
|
||||||
void ask(t('admin.deleteConfirm', { name: record.data.title }), async () => {
|
void ask(t('admin.deleteConfirm', { name: record.data.title }), async () => {
|
||||||
await api(`/admin/records/announcements/${record.id}`, { method: 'DELETE', body: jsonBody({ revision: record.revision }) })
|
await api(`/admin/records/announcements/${record.id}`, { method: 'DELETE', body: jsonBody({ revision: record.revision }) })
|
||||||
@@ -177,9 +203,21 @@ onBeforeUnmount(() => clearInterval(poll))
|
|||||||
<section v-if="logs" class="admin-editor"><div class="admin-toolbar"><h3>{{ logs.name }} · {{ t('admin.logs') }}</h3><div class="admin-actions"><button :disabled="busy" @click="run(() => showLogs(logs!.name))">{{ t('admin.refresh') }}</button><button @click="logs = null">{{ t('admin.close') }}</button></div></div><p>{{ t('admin.logTail') }}</p><pre class="admin-log">{{ logs.text }}</pre></section>
|
<section v-if="logs" class="admin-editor"><div class="admin-toolbar"><h3>{{ logs.name }} · {{ t('admin.logs') }}</h3><div class="admin-actions"><button :disabled="busy" @click="run(() => showLogs(logs!.name))">{{ t('admin.refresh') }}</button><button @click="logs = null">{{ t('admin.close') }}</button></div></div><p>{{ t('admin.logTail') }}</p><pre class="admin-log">{{ logs.text }}</pre></section>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="tab === 'announcements'">
|
<template v-if="tab === 'announcements'">
|
||||||
<button class="primary" @click="newArticle">{{ t('admin.newArticle') }}</button>
|
<div class="admin-actions"><button class="primary" :disabled="busy" @click="newArticle">{{ t('admin.newArticle') }}</button><a class="admin-public-link" href="/announcements" target="_blank" rel="noopener noreferrer">{{ t('admin.viewAnnouncements') }}</a></div>
|
||||||
<div class="admin-table-wrap"><table><thead><tr><th>{{ t('admin.articleTitle') }}</th><th>{{ t('admin.status') }}</th><th>{{ t('admin.date') }}</th><th>{{ t('admin.actions') }}</th></tr></thead><tbody><tr v-for="row in articles" :key="row.id"><td lang="zh-CN">{{ row.data.title }}</td><td>{{ t(row.data.published ? 'admin.published' : 'admin.draft') }}</td><td>{{ date(row.data.date) }}</td><td><div class="row-actions"><button @click="editArticle(row)">{{ t('admin.edit') }}</button><button @click="deleteArticle(row)">{{ t('admin.remove') }}</button></div></td></tr></tbody></table><p v-if="!articles.length">{{ t('admin.empty') }}</p></div>
|
<form v-if="articlesEditor" ref="articleForm" class="admin-editor admin-form announcement-editor" @submit.prevent="submitArticle">
|
||||||
<form v-if="articlesEditor" class="admin-editor admin-form" @submit.prevent="run(saveArticle)"><div class="admin-toolbar"><h3>{{ t('admin.edit') }}</h3><button type="button" @click="articlesEditor = null">{{ t('admin.close') }}</button></div><label>{{ t('admin.articleTitle') }}<input v-model="articlesEditor.data.title" maxlength="300" lang="zh-CN" required /></label><label>{{ t('admin.body') }}<textarea v-model="articlesEditor.data.body" lang="zh-CN" rows="12" /></label><h3>{{ t('admin.preview') }}</h3><MarkdownContent :source="articlesEditor.data.body" lang="zh-CN" /><label>{{ t('admin.date') }}<input :value="articlesEditor.data.date.slice(0, 10)" type="date" required @input="articlesEditor.data.date = `${($event.target as HTMLInputElement).value}T00:00:00+08:00`" /></label><div class="admin-actions"><label class="check"><input v-model="articlesEditor.data.published" type="checkbox" />{{ t('admin.published') }}</label><label class="check"><input v-model="articlesEditor.data.pinned" type="checkbox" />{{ t('admin.pinned') }}</label></div><button class="primary" :disabled="busy">{{ t('admin.save') }}</button></form>
|
<div class="admin-toolbar"><h3>{{ t(articlesEditor.revision ? 'admin.editArticle' : 'admin.newArticle') }}</h3><button type="button" :disabled="busy" @click="articlesEditor = null">{{ t('admin.close') }}</button></div>
|
||||||
|
<fieldset :disabled="busy">
|
||||||
|
<label>{{ t('admin.articleTitle') }}<input v-model="articlesEditor.data.title" name="article-title" maxlength="300" lang="zh-CN" required /></label>
|
||||||
|
<div class="article-options"><label>{{ t('admin.date') }}<input :value="articleDate" type="date" required @input="articlesEditor.data.date = ($event.target as HTMLInputElement).value ? `${($event.target as HTMLInputElement).value}T00:00:00+08:00` : ''" /></label><label class="check"><input v-model="articlesEditor.data.pinned" type="checkbox" />{{ t('admin.pinned') }}</label><span class="article-state">{{ t(articlePublished ? 'admin.published' : 'admin.draft') }}</span></div>
|
||||||
|
<div class="article-view-switch" :aria-label="t('admin.articleView')"><button type="button" :aria-pressed="articleView === 'write'" @click="articleView = 'write'">{{ t('admin.write') }}</button><button type="button" :aria-pressed="articleView === 'preview'" @click="articleView = 'preview'">{{ t('admin.preview') }}</button></div>
|
||||||
|
<div class="article-workspace" :data-view="articleView">
|
||||||
|
<label class="article-source">{{ t('admin.body') }}<textarea v-model="articlesEditor.data.body" lang="zh-CN" rows="18" maxlength="250000" spellcheck="false" /></label>
|
||||||
|
<section class="article-preview" :aria-label="t('admin.preview')"><h4>{{ t('admin.preview') }}</h4><h2 lang="zh-CN">{{ articlesEditor.data.title || t('admin.articleTitle') }}</h2><time v-if="articlesEditor.data.date" :datetime="articlesEditor.data.date">{{ d(new Date(articlesEditor.data.date), 'article') }}</time><MarkdownContent v-if="articlesEditor.data.body" :source="articlesEditor.data.body" lang="zh-CN" /><p v-else class="article-empty">{{ t('admin.previewEmpty') }}</p></section>
|
||||||
|
</div>
|
||||||
|
<div class="admin-actions article-submit"><button type="submit" value="publish" class="primary">{{ t(articlePublished ? 'admin.updateArticle' : 'admin.publishArticle') }}</button><button type="submit" value="draft">{{ t(articlePublished ? 'admin.withdrawArticle' : 'admin.saveDraft') }}</button><a v-if="articlePublished" class="admin-public-link" :href="announcementUrl(articlesEditor.id)" target="_blank" rel="noopener noreferrer">{{ t('admin.viewArticle') }}</a></div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
<div class="admin-table-wrap articles-table"><table><thead><tr><th>{{ t('admin.articleTitle') }}</th><th>{{ t('admin.status') }}</th><th>{{ t('admin.date') }}</th><th>{{ t('admin.actions') }}</th></tr></thead><tbody><tr v-for="row in sortedArticles" :key="row.id"><td class="article-list-title"><span lang="zh-CN">{{ row.data.title }}</span><span v-if="row.data.pinned" class="article-pin">{{ t('admin.pinned') }}</span></td><td>{{ t(row.data.published ? 'admin.published' : 'admin.draft') }}</td><td><time :datetime="row.data.date">{{ d(new Date(row.data.date), 'article') }}</time></td><td><div class="row-actions"><button :disabled="busy" @click="editArticle(row)">{{ t('admin.edit') }}</button><a v-if="row.data.published" class="admin-public-link" :href="announcementUrl(row.id)" target="_blank" rel="noopener noreferrer">{{ t('admin.viewArticle') }}</a><button :disabled="busy" @click="deleteArticle(row)">{{ t('admin.remove') }}</button></div></td></tr></tbody></table><p v-if="!articles.length">{{ t('admin.empty') }}</p></div>
|
||||||
</template>
|
</template>
|
||||||
<form v-if="tab === 'settings' && settings" class="admin-form" @submit.prevent="run(async () => { settings = await saveRecord('settings', settings!) })">
|
<form v-if="tab === 'settings' && settings" class="admin-form" @submit.prevent="run(async () => { settings = await saveRecord('settings', settings!) })">
|
||||||
<label>{{ t('admin.contentLanguage') }}<select v-model="editLocale"><option v-for="language in supportedLocales" :key="language" :value="language">{{ t('common.languageName', {}, { locale: language }) }}</option></select></label>
|
<label>{{ t('admin.contentLanguage') }}<select v-model="editLocale"><option v-for="language in supportedLocales" :key="language" :value="language">{{ t('common.languageName', {}, { locale: language }) }}</option></select></label>
|
||||||
@@ -244,6 +282,32 @@ input, textarea, select { width: 100%; min-width: 0; min-height: 40px; padding:
|
|||||||
textarea { resize: vertical; line-height: 1.7; } .check { flex-direction: row; align-items: center; gap: 8px; } .check input { width: 18px; min-height: 18px; accent-color: var(--blue); }
|
textarea { resize: vertical; line-height: 1.7; } .check { flex-direction: row; align-items: center; gap: 8px; } .check input { width: 18px; min-height: 18px; accent-color: var(--blue); }
|
||||||
.admin-form > button { justify-self: start; } .admin-columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; } .admin-array { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding: 14px 0; border-bottom: 1px solid var(--line); } .admin-array label { flex: 1; min-width: 160px; }
|
.admin-form > button { justify-self: start; } .admin-columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; } .admin-array { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding: 14px 0; border-bottom: 1px solid var(--line); } .admin-array label { flex: 1; min-width: 160px; }
|
||||||
.admin-related-links > button { margin-top: 16px; } .admin-related-links .admin-actions { gap: 6px; }
|
.admin-related-links > button { margin-top: 16px; } .admin-related-links .admin-actions { gap: 6px; }
|
||||||
|
.admin-public-link { color: var(--blue); font-size: 14px; text-underline-offset: 3px; } .admin-public-link:hover { text-decoration: underline; }
|
||||||
|
.announcement-editor { max-width: none; scroll-margin-top: 20px; }
|
||||||
|
.announcement-editor .admin-toolbar { margin-bottom: 0; } .announcement-editor h3 { margin: 0; }
|
||||||
|
.announcement-editor fieldset { display: grid; gap: 22px; min-width: 0; padding: 0; margin: 0; border: 0; }
|
||||||
|
.article-options { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; } .article-options > label:first-child { width: 200px; } .article-options .check { padding-top: 24px; }
|
||||||
|
.article-state { margin-left: auto; color: var(--muted); font-size: 14px; }
|
||||||
|
.article-workspace { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 28px; align-items: start; }
|
||||||
|
.article-source textarea { min-height: 380px; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
|
||||||
|
.article-preview { min-width: 0; overflow-wrap: anywhere; } .article-preview h4 { margin: 0 0 12px; font-size: 14px; font-weight: 500; }
|
||||||
|
.article-preview h2 { font-size: 24px; color: var(--blue); line-height: 1.5; } .article-preview time { display: block; margin: 10px 0 22px; color: var(--muted); font-size: 14px; }
|
||||||
|
.article-preview :deep(.markdown-content) { font-size: 16px; line-height: 1.9; } .article-empty { color: var(--muted); font-size: 14px; }
|
||||||
|
.article-view-switch { display: none; gap: 8px; } .article-view-switch [aria-pressed='true'] { color: var(--blue); border-color: var(--blue); }
|
||||||
|
.article-list-title { overflow-wrap: anywhere; } .article-pin { margin-left: 10px; color: var(--blue); font-size: 12px; }
|
||||||
|
.articles-table td:not(:first-child) { white-space: nowrap; }
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.article-workspace { display: block; } .article-view-switch { display: flex; }
|
||||||
|
.article-workspace[data-view='write'] .article-preview, .article-workspace[data-view='preview'] .article-source { display: none; }
|
||||||
|
.article-preview > h4 { display: none; }
|
||||||
|
}
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.article-options { gap: 16px; } .article-options > label:first-child { width: min(200px, 100%); } .article-options .check { padding-top: 0; }
|
||||||
|
.article-submit button { min-height: 44px; }
|
||||||
|
.articles-table table, .articles-table tbody { display: block; } .articles-table thead { display: none; }
|
||||||
|
.articles-table tr { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
|
||||||
|
.articles-table td { padding: 0; border: 0; } .articles-table td:first-child, .articles-table td:last-child { grid-column: 1 / -1; }
|
||||||
|
}
|
||||||
.admin-table-wrap { max-width: 100%; overflow: auto; margin: 20px 0; } table { width: 100%; border-collapse: collapse; font-size: 14px; } th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; } thead th { font-weight: 700; white-space: nowrap; } tbody th { font-weight: 500; }
|
.admin-table-wrap { max-width: 100%; overflow: auto; margin: 20px 0; } table { width: 100%; border-collapse: collapse; font-size: 14px; } th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; } thead th { font-weight: 700; white-space: nowrap; } tbody th { font-weight: 500; }
|
||||||
.admin-pagination, .admin-page-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
|
.admin-pagination, .admin-page-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
|
||||||
.admin-pagination { justify-content: space-between; font-size: 14px; }
|
.admin-pagination { justify-content: space-between; font-size: 14px; }
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { api, type AnnouncementContent, type ContentRecord } from '../api'
|
||||||
|
import { announcementAnchor, announcementUrl } from '../announcements'
|
||||||
|
import MarkdownContent from './MarkdownContent.vue'
|
||||||
|
|
||||||
|
const { t, d } = useI18n()
|
||||||
|
const articles = ref<ContentRecord<AnnouncementContent>[]>([])
|
||||||
|
const loading = ref(true)
|
||||||
|
const failed = ref(false)
|
||||||
|
|
||||||
|
async function locateArticle() {
|
||||||
|
await nextTick()
|
||||||
|
let anchor: string
|
||||||
|
try { anchor = decodeURIComponent(window.location.hash.slice(1)) } catch { return }
|
||||||
|
if (!articles.value.some(article => announcementAnchor(article.id) === anchor)) return
|
||||||
|
const target = document.getElementById(anchor)
|
||||||
|
target?.scrollIntoView({ block: 'start', behavior: 'instant' })
|
||||||
|
target?.focus({ preventScroll: true })
|
||||||
|
}
|
||||||
|
async function load() {
|
||||||
|
loading.value = true
|
||||||
|
failed.value = false
|
||||||
|
try {
|
||||||
|
articles.value = await api('/announcements')
|
||||||
|
await locateArticle()
|
||||||
|
} catch { failed.value = true }
|
||||||
|
finally { loading.value = false }
|
||||||
|
}
|
||||||
|
onMounted(() => {
|
||||||
|
void load()
|
||||||
|
window.addEventListener('hashchange', locateArticle)
|
||||||
|
})
|
||||||
|
onBeforeUnmount(() => window.removeEventListener('hashchange', locateArticle))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section id="announcements" class="announcements-page" tabindex="-1" :aria-busy="loading">
|
||||||
|
<h1>{{ t('announcements.title') }}</h1>
|
||||||
|
<p v-if="loading" role="status">{{ t('announcements.loading') }}</p>
|
||||||
|
<div v-else-if="failed" class="announcement-error" role="alert">
|
||||||
|
<p>{{ t('announcements.loadFailed') }}</p>
|
||||||
|
<button @click="load">{{ t('announcements.retry') }}</button>
|
||||||
|
</div>
|
||||||
|
<p v-else-if="!articles.length">{{ t('common.noAnnouncements') }}</p>
|
||||||
|
<article v-for="article in articles" :id="announcementAnchor(article.id)" :key="article.id" class="announcement" tabindex="-1" :aria-labelledby="`${announcementAnchor(article.id)}-title`">
|
||||||
|
<h2 :id="`${announcementAnchor(article.id)}-title`"><a :href="announcementUrl(article.id)" lang="zh-CN">{{ article.data.title }}</a></h2>
|
||||||
|
<div class="announcement-meta">
|
||||||
|
<time :datetime="article.data.date">{{ d(new Date(article.data.date), 'article') }}</time>
|
||||||
|
<span v-if="article.data.pinned">{{ t('announcements.pinned') }}</span>
|
||||||
|
</div>
|
||||||
|
<MarkdownContent :source="article.data.body" lang="zh-CN" />
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.announcements-page { max-width: 980px; min-height: 45vh; padding: 32px 0 80px; }
|
||||||
|
h1 { margin: 0 0 38px; color: var(--ink); font-size: 36px; font-weight: 600; line-height: 1.3; }
|
||||||
|
.announcement { margin: 0 0 48px; scroll-margin-top: 24px; overflow-wrap: anywhere; }
|
||||||
|
.announcement:last-child { margin-bottom: 0; }
|
||||||
|
h2 { margin: 0 0 10px; font-size: 26px; font-weight: 600; line-height: 1.5; }
|
||||||
|
h2 a { color: var(--blue); }
|
||||||
|
h2 a:hover { text-decoration: underline; text-underline-offset: 5px; }
|
||||||
|
.announcement-meta { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; color: var(--muted); font-size: 14px; }
|
||||||
|
.announcement-meta span { color: var(--blue); }
|
||||||
|
.announcement :deep(.markdown-content) { font-size: 16px; line-height: 1.9; }
|
||||||
|
.announcement-error button { padding: 8px 16px; border: 1px solid var(--line); border-radius: 4px; color: var(--blue); }
|
||||||
|
:root[data-theme='dark'] h1 { color: #fff; }
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.announcements-page { padding: 16px 0 48px; }
|
||||||
|
h1 { margin-bottom: 28px; font-size: 28px; }
|
||||||
|
h2 { font-size: 22px; }
|
||||||
|
.announcement { margin-bottom: 36px; }
|
||||||
|
.announcement-meta { margin-bottom: 16px; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
const pairs = {
|
const pairs = {
|
||||||
|
editArticle: ['编辑公告', 'Edit announcement'], write: ['编辑', 'Write'], articleView: ['公告编辑视图', 'Announcement editor view'], previewEmpty: ['输入 Markdown 正文后在这里预览。', 'Write Markdown to preview your announcement here.'],
|
||||||
|
saveDraft: ['保存草稿', 'Save draft'], publishArticle: ['发布公告', 'Publish announcement'], updateArticle: ['更新公告', 'Update announcement'], withdrawArticle: ['撤回为草稿', 'Unpublish as draft'], viewArticle: ['查看公告', 'View announcement'], viewAnnouncements: ['打开公告页', 'Open announcements'],
|
||||||
|
draftSaved: ['草稿已保存,尚未公开。', 'Draft saved. It is not public.'], articlePublished: ['公告已发布。', 'Announcement published.'], articleUpdated: ['公告已更新。', 'Announcement updated.'], articleWithdrawn: ['公告已撤回并保存为草稿。', 'Announcement unpublished and saved as a draft.'],
|
||||||
auditPagination: ['操作记录分页', 'Audit log pagination'], auditTotal: ['共 {total} 条记录', '{total} entries'], previousPage: ['上一页', 'Previous'], nextPage: ['下一页', 'Next'], pagePosition: ['第 {page} / {pages} 页', 'Page {page} of {pages}'],
|
auditPagination: ['操作记录分页', 'Audit log pagination'], auditTotal: ['共 {total} 条记录', '{total} entries'], previousPage: ['上一页', 'Previous'], nextPage: ['下一页', 'Next'], pagePosition: ['第 {page} / {pages} 页', 'Page {page} of {pages}'],
|
||||||
relatedLinks: ['首页相关链接', 'Home page related links'], linkType: ['链接类型', 'Link type'], urlLink: ['网址', 'URL'], helpLink: ['软件源使用帮助', 'Mirror usage guides'], linkEntry: ['相关链接 {index}', 'Related link {index}'], moveUp: ['上移', 'Move up'], moveDown: ['下移', 'Move down'],
|
relatedLinks: ['首页相关链接', 'Home page related links'], linkType: ['链接类型', 'Link type'], urlLink: ['网址', 'URL'], helpLink: ['软件源使用帮助', 'Mirror usage guides'], linkEntry: ['相关链接 {index}', 'Related link {index}'], moveUp: ['上移', 'Move up'], moveDown: ['下移', 'Move down'],
|
||||||
helpChinese: ['使用说明(中文,Markdown)', 'Usage guide (Chinese, Markdown)'], descriptionLanguage: ['介绍语言', 'Description language'],
|
helpChinese: ['使用说明(中文,Markdown)', 'Usage guide (Chinese, Markdown)'], descriptionLanguage: ['介绍语言', 'Description language'],
|
||||||
@@ -9,7 +12,7 @@ const pairs = {
|
|||||||
worker: ['同步节点', 'Worker'], total: ['镜像总数', 'Mirrors'], active: ['正在同步', 'Syncing'], failed: ['同步失败', 'Failed'], updated: ['最近采集', 'Last collected'], sourceError: ['同步节点暂时不可用,显示最近一次数据。', 'Worker unavailable. Showing the last collected data.'],
|
worker: ['同步节点', 'Worker'], total: ['镜像总数', 'Mirrors'], active: ['正在同步', 'Syncing'], failed: ['同步失败', 'Failed'], updated: ['最近采集', 'Last collected'], sourceError: ['同步节点暂时不可用,显示最近一次数据。', 'Worker unavailable. Showing the last collected data.'],
|
||||||
name: ['名称', 'Name'], status: ['状态', 'Status'], upstream: ['上游地址', 'Upstream'], size: ['大小', 'Size'], actions: ['操作', 'Actions'], search: ['搜索镜像', 'Search mirrors'], metadata: ['展示信息', 'Display information'], description: ['介绍', 'Description'], help: ['使用说明(Markdown)', 'Help (Markdown)'], website: ['官方网站', 'Official website'], visible: ['在首页显示', 'Show on home page'], category: ['分类', 'Category'], os: ['操作系统', 'Operating system'], language: ['语言与工具', 'Languages & tools'], other: ['其他', 'Other'],
|
name: ['名称', 'Name'], status: ['状态', 'Status'], upstream: ['上游地址', 'Upstream'], size: ['大小', 'Size'], actions: ['操作', 'Actions'], search: ['搜索镜像', 'Search mirrors'], metadata: ['展示信息', 'Display information'], description: ['介绍', 'Description'], help: ['使用说明(Markdown)', 'Help (Markdown)'], website: ['官方网站', 'Official website'], visible: ['在首页显示', 'Show on home page'], category: ['分类', 'Category'], os: ['操作系统', 'Operating system'], language: ['语言与工具', 'Languages & tools'], other: ['其他', 'Other'],
|
||||||
start: ['开始同步', 'Start sync'], stop: ['停止同步', 'Stop sync'], restart: ['重新同步', 'Restart sync'], disable: ['禁用同步', 'Disable sync'], logs: ['日志', 'Logs'], logTail: ['显示日志末尾,最多 64 KiB。', 'Showing the log tail, up to 64 KiB.'], commandConfirm: ['确认对 {name} 执行“{action}”?这会影响实际同步任务。', 'Run “{action}” for {name}? This affects the live sync task.'], submitted: ['命令已提交,实际状态稍后更新。', 'Command submitted. The live status will update shortly.'],
|
start: ['开始同步', 'Start sync'], stop: ['停止同步', 'Stop sync'], restart: ['重新同步', 'Restart sync'], disable: ['禁用同步', 'Disable sync'], logs: ['日志', 'Logs'], logTail: ['显示日志末尾,最多 64 KiB。', 'Showing the log tail, up to 64 KiB.'], commandConfirm: ['确认对 {name} 执行“{action}”?这会影响实际同步任务。', 'Run “{action}” for {name}? This affects the live sync task.'], submitted: ['命令已提交,实际状态稍后更新。', 'Command submitted. The live status will update shortly.'],
|
||||||
newArticle: ['新建公告', 'New announcement'], articleTitle: ['标题', 'Title'], body: ['正文(Markdown)', 'Body (Markdown)'], date: ['发布时间', 'Publication date'], published: ['发布', 'Published'], draft: ['草稿', 'Draft'], pinned: ['置顶', 'Pinned'], preview: ['预览', 'Preview'], deleteConfirm: ['确认删除 {name}?', 'Delete {name}?'],
|
newArticle: ['新建公告', 'New announcement'], articleTitle: ['标题', 'Title'], body: ['正文(Markdown)', 'Body (Markdown)'], date: ['发布时间', 'Publication date'], published: ['已发布', 'Published'], draft: ['草稿', 'Draft'], pinned: ['置顶', 'Pinned'], preview: ['预览', 'Preview'], deleteConfirm: ['确认删除 {name}?', 'Delete {name}?'],
|
||||||
siteName: ['站点名称', 'Site name'], email: ['联系邮箱', 'Contact email'], address: ['地址', 'Address'], logoLight: ['亮色主题 Logo', 'Light theme logo'], logoDark: ['暗色主题 Logo', 'Dark theme logo'], favicon: ['网站图标', 'Favicon'], avatar: ['站点头像', 'Site avatar'], upload: ['上传 PNG / JPEG', 'Upload PNG / JPEG'], links: ['友情链接', 'Footer links'], downloads: ['常用下载', 'Downloads'], url: ['链接', 'URL'], version: ['版本', 'Version'],
|
siteName: ['站点名称', 'Site name'], email: ['联系邮箱', 'Contact email'], address: ['地址', 'Address'], logoLight: ['亮色主题 Logo', 'Light theme logo'], logoDark: ['暗色主题 Logo', 'Dark theme logo'], favicon: ['网站图标', 'Favicon'], avatar: ['站点头像', 'Site avatar'], upload: ['上传 PNG / JPEG', 'Upload PNG / JPEG'], links: ['友情链接', 'Footer links'], downloads: ['常用下载', 'Downloads'], url: ['链接', 'URL'], version: ['版本', 'Version'],
|
||||||
currentPassword: ['当前密码', 'Current password'], newPassword: ['新密码', 'New password'], confirmPassword: ['确认新密码', 'Confirm new password'], changePassword: ['修改密码', 'Change password'], passwordHint: ['密码至少 12 个字符。修改后需重新登录。', 'Use at least 12 characters. Changing your password signs out all your sessions.'], passwordMismatch: ['两次输入的密码不同。', 'Passwords do not match.'], newUser: ['创建账户', 'Create account'], role: ['权限', 'Role'], admin: ['管理员', 'Administrator'], editor: ['公告编辑', 'Announcement editor'],
|
currentPassword: ['当前密码', 'Current password'], newPassword: ['新密码', 'New password'], confirmPassword: ['确认新密码', 'Confirm new password'], changePassword: ['修改密码', 'Change password'], passwordHint: ['密码至少 12 个字符。修改后需重新登录。', 'Use at least 12 characters. Changing your password signs out all your sessions.'], passwordMismatch: ['两次输入的密码不同。', 'Passwords do not match.'], newUser: ['创建账户', 'Create account'], role: ['权限', 'Role'], admin: ['管理员', 'Administrator'], editor: ['公告编辑', 'Announcement editor'],
|
||||||
concurrent: ['最大并发任务', 'Maximum concurrent jobs'], interval: ['同步间隔(分钟)', 'Sync interval (minutes)'], retry: ['失败重试次数', 'Retries'], timeout: ['超时(秒)', 'Timeout (seconds)'], global: ['全局调度', 'Global schedule'], mirrorConfig: ['单个镜像', 'Individual mirror'], newMirror: ['新增镜像', 'New mirror'], provider: ['同步方式', 'Provider'], intervalHint: ['同步间隔从上次同步结束后计算。配置应用时将通知 Worker 重新加载。', 'The interval starts when the previous sync finishes. Applying configuration asks the worker to reload.'], previewConfig: ['生成变更预览', 'Preview changes'], apply: ['应用配置', 'Apply configuration'], applyConfirm: ['确认应用此配置并通知 Worker 重新加载?', 'Apply this configuration and ask the worker to reload?'], before: ['修改前', 'Before'], after: ['修改后', 'After'], versions: ['配置历史', 'Configuration history'], rollback: ['恢复此版本之前的配置', 'Restore configuration before this version'], rollbackConfirm: ['确认恢复此变更前的配置并重新加载?后续有冲突时会拒绝恢复。', 'Restore the configuration before this change and reload? Conflicting subsequent changes will block the restore.'], applied: ['已应用', 'Applied'],
|
concurrent: ['最大并发任务', 'Maximum concurrent jobs'], interval: ['同步间隔(分钟)', 'Sync interval (minutes)'], retry: ['失败重试次数', 'Retries'], timeout: ['超时(秒)', 'Timeout (seconds)'], global: ['全局调度', 'Global schedule'], mirrorConfig: ['单个镜像', 'Individual mirror'], newMirror: ['新增镜像', 'New mirror'], provider: ['同步方式', 'Provider'], intervalHint: ['同步间隔从上次同步结束后计算。配置应用时将通知 Worker 重新加载。', 'The interval starts when the previous sync finishes. Applying configuration asks the worker to reload.'], previewConfig: ['生成变更预览', 'Preview changes'], apply: ['应用配置', 'Apply configuration'], applyConfirm: ['确认应用此配置并通知 Worker 重新加载?', 'Apply this configuration and ask the worker to reload?'], before: ['修改前', 'Before'], after: ['修改后', 'After'], versions: ['配置历史', 'Configuration history'], rollback: ['恢复此版本之前的配置', 'Restore configuration before this version'], rollbackConfirm: ['确认恢复此变更前的配置并重新加载?后续有冲突时会拒绝恢复。', 'Restore the configuration before this change and reload? Conflicting subsequent changes will block the restore.'], applied: ['已应用', 'Applied'],
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
export default {
|
export default {
|
||||||
"title": "Announcements",
|
"title": "Announcements",
|
||||||
|
"loading": "Loading announcements…",
|
||||||
|
"loadFailed": "Could not load announcements. Please try again.",
|
||||||
|
"retry": "Reload",
|
||||||
"more": "All announcements",
|
"more": "All announcements",
|
||||||
"moreLabel": "All",
|
"moreLabel": "All",
|
||||||
"downloads": "Downloads",
|
"downloads": "Downloads",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
|
skipAnnouncements: 'Skip to announcements',
|
||||||
skipAdmin: 'Skip to administration',
|
skipAdmin: 'Skip to administration',
|
||||||
loading: 'Loading mirrors…',
|
loading: 'Loading mirrors…',
|
||||||
stale: 'Connection interrupted. Showing the last collected data.',
|
stale: 'Connection interrupted. Showing the last collected data.',
|
||||||
@@ -16,7 +17,7 @@ export default {
|
|||||||
"skipStatus": "Skip to site status",
|
"skipStatus": "Skip to site status",
|
||||||
"nav": {
|
"nav": {
|
||||||
"mirrors": "Mirrors",
|
"mirrors": "Mirrors",
|
||||||
"news": "News",
|
"news": "Announcements",
|
||||||
"status": "Status",
|
"status": "Status",
|
||||||
"feedback": "ISSUE"
|
"feedback": "ISSUE"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
export default {
|
export default {
|
||||||
"title": "站点公告",
|
"title": "站点公告",
|
||||||
|
"loading": "正在加载公告…",
|
||||||
|
"loadFailed": "公告加载失败,请稍后重试。",
|
||||||
|
"retry": "重新加载",
|
||||||
"more": "全部公告",
|
"more": "全部公告",
|
||||||
"moreLabel": "全部",
|
"moreLabel": "全部",
|
||||||
"downloads": "常用下载",
|
"downloads": "常用下载",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
skipAdmin: '跳转到站点管理',
|
skipAdmin: '跳转到站点管理',
|
||||||
|
skipAnnouncements: '跳转到站点公告',
|
||||||
loading: '正在加载镜像数据…',
|
loading: '正在加载镜像数据…',
|
||||||
stale: '连接暂时中断,显示最近一次同步数据。',
|
stale: '连接暂时中断,显示最近一次同步数据。',
|
||||||
unavailable: '镜像数据暂时不可用,请稍后刷新。',
|
unavailable: '镜像数据暂时不可用,请稍后刷新。',
|
||||||
@@ -16,7 +17,7 @@ export default {
|
|||||||
"skipStatus": "跳转到站点状态",
|
"skipStatus": "跳转到站点状态",
|
||||||
"nav": {
|
"nav": {
|
||||||
"mirrors": "镜像列表",
|
"mirrors": "镜像列表",
|
||||||
"news": "新闻",
|
"news": "公告",
|
||||||
"status": "站点状态",
|
"status": "站点状态",
|
||||||
"feedback": "问题反馈"
|
"feedback": "问题反馈"
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -128,7 +128,7 @@ h2 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.04em; }
|
|||||||
.side-heading { gap: 12px; margin-bottom: 8px; }
|
.side-heading { gap: 12px; margin-bottom: 8px; }
|
||||||
.side-heading h2 { font-size: 22px; line-height: 1.3; }
|
.side-heading h2 { font-size: 22px; line-height: 1.3; }
|
||||||
:root[data-theme='dark'] :is(.section-heading, .mirror-table th, .sync-table thead th, .side-heading) { color: #fff; }
|
:root[data-theme='dark'] :is(.section-heading, .mirror-table th, .sync-table thead th, .side-heading) { color: #fff; }
|
||||||
.sidebar-more { flex-shrink: 0; min-height: 32px; padding: 4px 0 4px 8px; color: var(--blue); font-size: 13px; }
|
.sidebar-more { display: inline-flex; align-items: center; flex-shrink: 0; min-height: 32px; padding: 4px 0 4px 8px; color: var(--blue); font-size: 13px; }
|
||||||
.sidebar-more:hover { text-decoration: underline; text-underline-offset: 3px; }
|
.sidebar-more:hover { text-decoration: underline; text-underline-offset: 3px; }
|
||||||
.news-item { display: flex; align-items: baseline; gap: 8px; width: 100%; min-height: 30px; padding: 4px 0; color: var(--blue); font-size: 14px; font-weight: 500; text-align: left; }
|
.news-item { display: flex; align-items: baseline; gap: 8px; width: 100%; min-height: 30px; padding: 4px 0; color: var(--blue); font-size: 14px; font-weight: 500; text-align: left; }
|
||||||
.news-item time { flex-shrink: 0; font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
|
.news-item time { flex-shrink: 0; font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
|
||||||
|
|||||||
Reference in New Issue
Block a user