diff --git a/dashboard/src/i18n/locales/en-US/features/welcome.json b/dashboard/src/i18n/locales/en-US/features/welcome.json index 676e0f07f..670d0a66d 100644 --- a/dashboard/src/i18n/locales/en-US/features/welcome.json +++ b/dashboard/src/i18n/locales/en-US/features/welcome.json @@ -6,6 +6,9 @@ "newYear": "Happy New Year!" }, "subtitle": "You can complete the basic onboarding first. Platform and chat provider setup can both be skipped.", + "announcement": { + "title": "Announcement" + }, "onboard": { "title": "Quick Onboarding", "subtitle": "Complete initialization directly on the welcome page.", diff --git a/dashboard/src/i18n/locales/zh-CN/features/welcome.json b/dashboard/src/i18n/locales/zh-CN/features/welcome.json index 188445379..1eb23d7ca 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/welcome.json +++ b/dashboard/src/i18n/locales/zh-CN/features/welcome.json @@ -6,6 +6,9 @@ "newYear": "新年快乐!" }, "subtitle": "可以先完成基础引导,平台和对话提供商都支持稍后再配置。", + "announcement": { + "title": "公告" + }, "onboard": { "title": "快速引导", "subtitle": "欢迎页可直接完成初始化。", diff --git a/dashboard/src/views/WelcomePage.vue b/dashboard/src/views/WelcomePage.vue index 8d52131b1..5cabdc66a 100644 --- a/dashboard/src/views/WelcomePage.vue +++ b/dashboard/src/views/WelcomePage.vue @@ -116,6 +116,21 @@ + + + + + + {{ tm('announcement.title') }} + + + + + ('pending'); const providerStepState = ref('pending'); +const welcomeAnnouncementRaw = ref(null); + +function resolveWelcomeAnnouncement(raw: unknown, currentLocale: string) { + if (typeof raw === 'string') { + return raw.trim(); + } + + if (!raw || typeof raw !== 'object' || Array.isArray(raw)) { + return ''; + } + + const localeMap = raw as Record; + const normalized = currentLocale.replace('-', '_'); + const preferredKeys = + normalized.startsWith('zh') + ? [normalized, 'zh_CN', 'zh-CN', 'zh', 'en_US', 'en-US', 'en'] + : [normalized, 'en_US', 'en-US', 'en', 'zh_CN', 'zh-CN', 'zh']; + + for (const key of preferredKeys) { + const value = localeMap[key]; + if (typeof value === 'string' && value.trim().length > 0) { + return value.trim(); + } + } + + return ''; +} + +const welcomeAnnouncement = computed(() => + resolveWelcomeAnnouncement(welcomeAnnouncementRaw.value, locale.value) +); +const showAnnouncement = computed(() => welcomeAnnouncement.value.length > 0); const springFestivalDates: Record = { 2025: '01-29', @@ -285,7 +336,19 @@ async function syncDefaultConfigProviderIfNeeded() { showSuccess(tm('onboard.providerDefaultUpdated', { id: targetProviderId })); } +async function loadWelcomeAnnouncement() { + try { + const res = await axios.get('https://cloud.astrbot.app/api/v1/announcement'); + welcomeAnnouncementRaw.value = res?.data?.data?.notice?.welcome_page ?? null; + } catch (e) { + welcomeAnnouncementRaw.value = null; + console.error(e); + } +} + onMounted(async () => { + await loadWelcomeAnnouncement(); + try { await loadPlatformConfigBase(); if ((platformConfigData.value.platform || []).length > 0) { @@ -363,4 +426,8 @@ watch(showProviderDialog, async (visible, wasVisible) => { .welcome-card { border-radius: 16px; } + +.welcome-announcement-markdown { + line-height: 1.7; +}