feat: 公告開關
This commit is contained in:
+16
-15
@@ -8,6 +8,7 @@
|
||||
:layout="formPositionLayout"
|
||||
:mobile-announcement="mobileAnnouncement"
|
||||
:toolbar="toolbar"
|
||||
:with-announcement="withAnnouncement"
|
||||
@captcha-change="handleCaptchaChange"
|
||||
@captcha-refresh="handleCaptchaRefresh"
|
||||
@change-locale="handleChangeLocale"
|
||||
@@ -52,18 +53,17 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import HyakkaouAcademyImage from '@/assets/logo.png'
|
||||
import PageLogin from '@/components/PageLogin.vue'
|
||||
import { useLoginCaptcha } from '@/composables/useLoginCaptcha'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import {
|
||||
type LoginAnnouncementListItem,
|
||||
useLoginAnnouncementsStore,
|
||||
} from '@/stores/loginAnnouncements'
|
||||
useLoginAnnouncements,
|
||||
} from '@/composables/useLoginAnnouncements'
|
||||
import { useLoginCaptcha } from '@/composables/useLoginCaptcha'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useMenuStore } from '@/stores/menu'
|
||||
import { useSnackbarStore } from '@/stores/snackbar'
|
||||
|
||||
@@ -74,15 +74,8 @@ const { t, locale } = useI18n()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const authStore = useAuthStore()
|
||||
const loginAnnouncementsStore = useLoginAnnouncementsStore()
|
||||
const menuStore = useMenuStore()
|
||||
const snackbarStore = useSnackbarStore()
|
||||
const {
|
||||
boardConfig: announcementBoard,
|
||||
mobileAnnouncementConfig: mobileAnnouncement,
|
||||
selectedAnnouncement,
|
||||
selectedAnnouncementDetail,
|
||||
} = storeToRefs(loginAnnouncementsStore)
|
||||
|
||||
// 語系選項
|
||||
const locales = ['zh-TW', 'en-US']
|
||||
@@ -92,10 +85,19 @@ const illustrationImage = ref(HyakkaouAcademyImage)
|
||||
|
||||
// 功能開關與版型
|
||||
const formPositionLayout = ref<LayoutType>('side-left')
|
||||
// 是否啟用公告
|
||||
const withAnnouncement = ref(true)
|
||||
|
||||
// 功能開關:是否啟用驗證碼
|
||||
const withCaptcha = ref(true)
|
||||
const loginCaptcha = useLoginCaptcha({ enabled: withCaptcha })
|
||||
const loginAnnouncements = useLoginAnnouncements({ enabled: withAnnouncement })
|
||||
const {
|
||||
boardConfig: announcementBoard,
|
||||
mobileAnnouncementConfig: mobileAnnouncement,
|
||||
selectedAnnouncement,
|
||||
selectedAnnouncementDetail,
|
||||
} = loginAnnouncements
|
||||
|
||||
// 文字內容(i18n)
|
||||
const title = computed(() => t('pages.login.title'))
|
||||
@@ -200,7 +202,7 @@ function handleToggleLayout() {
|
||||
}
|
||||
|
||||
function handleSelectAnnouncement(item: LoginAnnouncementListItem) {
|
||||
loginAnnouncementsStore.selectById(item.id)
|
||||
loginAnnouncements.selectById(item.id)
|
||||
announcementDialogVisible.value = true
|
||||
}
|
||||
|
||||
@@ -252,8 +254,7 @@ async function onLogin(data: Record<string, unknown>) {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loginAnnouncementsStore.hydrate()
|
||||
loginAnnouncementsStore.fetchMobileAnnouncements()
|
||||
void loginAnnouncements.load()
|
||||
void loginCaptcha.loadCaptcha().catch(() => undefined)
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user