feat: announcement support html (#566)

* feat: announcement support html

* feat: update dependencies
This commit is contained in:
Dream Hunter
2025-01-20 13:53:40 +08:00
committed by GitHub
parent cf13236e7b
commit 3f81fbee6d
18 changed files with 933 additions and 3652 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "cloudflare_temp_email",
"version": "0.8.5",
"version": "0.8.6",
"private": true,
"type": "module",
"scripts": {
@@ -20,7 +20,7 @@
},
"dependencies": {
"@simplewebauthn/browser": "10.0.0",
"@unhead/vue": "^1.11.15",
"@unhead/vue": "^1.11.18",
"@vueuse/core": "^12.4.0",
"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^5.1.12",
@@ -47,6 +47,6 @@
"vite-plugin-wasm": "^3.4.1",
"workbox-build": "^7.3.0",
"workbox-window": "^7.3.0",
"wrangler": "^3.101.0"
"wrangler": "^3.103.2"
}
}

1762
frontend/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -61,24 +61,26 @@ onMounted(async () => {
<n-config-provider :locale="localeConfig" :theme="theme">
<n-global-style />
<n-spin description="loading..." :show="loading">
<n-message-provider container-style="margin-top: 20px;">
<n-grid x-gap="12" :cols="12">
<n-gi v-if="showSideMargin" span="1"></n-gi>
<n-gi :span="!showSideMargin ? 12 : 10">
<div class="main">
<n-space vertical>
<n-layout style="min-height: 80vh;">
<Header />
<router-view></router-view>
</n-layout>
<Footer />
</n-space>
</div>
</n-gi>
<n-gi v-if="showSideMargin" span="1"></n-gi>
</n-grid>
<n-back-top />
</n-message-provider>
<n-notification-provider container-style="margin-top: 60px;">
<n-message-provider container-style="margin-top: 20px;">
<n-grid x-gap="12" :cols="12">
<n-gi v-if="showSideMargin" span="1"></n-gi>
<n-gi :span="!showSideMargin ? 12 : 10">
<div class="main">
<n-space vertical>
<n-layout style="min-height: 80vh;">
<Header />
<router-view></router-view>
</n-layout>
<Footer />
</n-space>
</div>
</n-gi>
<n-gi v-if="showSideMargin" span="1"></n-gi>
</n-grid>
<n-back-top />
</n-message-provider>
</n-notification-provider>
</n-spin>
</n-config-provider>
</template>

View File

@@ -1,4 +1,5 @@
import { useGlobalState } from '../store'
import { h } from 'vue'
import axios from 'axios'
const API_BASE = import.meta.env.VITE_API_BASE || "";
@@ -52,7 +53,7 @@ const apiFetch = async (path, options = {}) => {
}
}
const getOpenSettings = async (message) => {
const getOpenSettings = async (message, notification) => {
try {
const res = await api.fetch("/open_api/settings");
const domainLabels = res["domainLabels"] || [];
@@ -89,10 +90,12 @@ const getOpenSettings = async (message) => {
}
if (openSettings.value.announcement && openSettings.value.announcement != announcement.value) {
announcement.value = openSettings.value.announcement;
message.info(announcement.value, {
showIcon: false,
duration: 0,
closable: true
notification.info({
content: () => {
return h("div", {
innerHTML: announcement.value
});
}
});
}
} catch (error) {

View File

@@ -15,6 +15,7 @@ import { api } from '../api'
import { getRouterPathWithLang } from '../utils'
const message = useMessage()
const notification = useNotification()
const {
toggleDark, isDark, isTelegram, showAdminPage,
@@ -223,7 +224,7 @@ const logoClick = async () => {
}
onMounted(async () => {
await api.getOpenSettings(message);
await api.getOpenSettings(message, notification);
// make sure user_id is fetched
if (!userSettings.value.user_id) await api.getUserSettings(message);
});

View File

@@ -1,10 +1,13 @@
<script setup>
import { GithubAlt, Discord, Telegram } from '@vicons/fa'
import { useGlobalState } from '../../store'
const { announcement } = useGlobalState()
</script>
<template>
<div class="center">
<n-card :bordered="false" embedded>
<div v-html="announcement"></div>
<n-button tag="a" target="_blank" href="https://github.com/dreamhunter2333/cloudflare_temp_email">
<template #icon>
<n-icon :component="GithubAlt" />

View File

@@ -34,6 +34,7 @@ const props = defineProps({
})
const message = useMessage()
const notification = useNotification()
const router = useRouter()
const {
@@ -195,7 +196,7 @@ const showNewAddressTab = computed(() => {
onMounted(async () => {
if (!openSettings.value.domains || openSettings.value.domains.length === 0) {
await api.getOpenSettings();
await api.getOpenSettings(message, notification);
}
emailDomain.value = domainsOptions.value ? domainsOptions.value[0]?.value : "";
});

View File

@@ -24,6 +24,7 @@ export default defineConfig({
{
'naive-ui': [
'useMessage',
'useNotification',
'NButton',
'NPopconfirm',
'NIcon',