feat: add ANNOUNCEMENT (#357)

This commit is contained in:
Dream Hunter
2024-07-22 13:01:38 +08:00
committed by GitHub
parent 384eb9b041
commit 60dda7e3fe
11 changed files with 29 additions and 6 deletions

View File

@@ -1,6 +1,12 @@
<!-- markdownlint-disable-file MD004 MD024 MD034 MD036 -->
# CHANGE LOG
## main branch(v0.6.1)
- pages github actions && 修复清理邮件天数为 0 不生效 by @tqjason (#355)
- fix: imap proxy server 不支持 密码 by @dreamhunter2333 (#356)
- worker 新增 `ANNOUNCEMENT` 配置, 用于配置公告信息 by @dreamhunter2333 (#357)
## v0.6.0
### Breaking Changes

View File

@@ -1,6 +1,6 @@
{
"name": "cloudflare_temp_email",
"version": "0.6.0",
"version": "0.6.1",
"private": true,
"type": "module",
"scripts": {

View File

@@ -54,7 +54,7 @@ onMounted(async () => {
<n-config-provider :locale="localeConfig" :theme="theme">
<n-global-style />
<n-spin description="loading..." :show="loading">
<n-message-provider>
<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">

View File

@@ -4,7 +4,7 @@ import axios from 'axios'
const API_BASE = import.meta.env.VITE_API_BASE || "";
const {
loading, auth, jwt, settings, openSettings,
userOpenSettings, userSettings,
userOpenSettings, userSettings, announcement,
showAuth, adminAuth, showAdminAuth, userJwt
} = useGlobalState();
@@ -56,6 +56,7 @@ const getOpenSettings = async (message) => {
const res = await api.fetch("/open_api/settings");
const domainLabels = res["domainLabels"] || [];
Object.assign(openSettings.value, {
...res,
title: res["title"] || "",
prefix: res["prefix"] || "",
minAddressLen: res["minAddressLen"] || 1,
@@ -81,6 +82,14 @@ const getOpenSettings = async (message) => {
if (openSettings.value.needAuth) {
showAuth.value = true;
}
if (openSettings.value.announcement && openSettings.value.announcement != announcement.value) {
announcement.value = openSettings.value.announcement;
message.info(announcement.value, {
showIcon: false,
duration: 0,
closable: true
});
}
} catch (error) {
message.error(error.message || "error");
}

View File

@@ -1,13 +1,15 @@
import { ref } from "vue";
import { createGlobalState, useStorage, useDark, useToggle } from '@vueuse/core'
import { createGlobalState, useStorage, useDark, useToggle, useLocalStorage } from '@vueuse/core'
export const useGlobalState = createGlobalState(
() => {
const isDark = useDark()
const toggleDark = useToggle(isDark)
const loading = ref(false);
const announcement = useLocalStorage('announcement', '');
const openSettings = ref({
title: '',
announcement: '',
prefix: '',
needAuth: false,
adminContact: '',
@@ -83,6 +85,7 @@ export const useGlobalState = createGlobalState(
loading,
settings,
sendMailModel,
announcement,
openSettings,
showAuth,
showAddressCredential,

View File

@@ -77,6 +77,7 @@ node_compat = true
# TITLE = "Custom Title" # The title of the site
PREFIX = "tmp" # The mailbox name prefix to be processed
# (min, max) length of the adderss, if not set, the default is (1, 30)
# ANNOUNCEMENT = "Custom Announcement"
# MIN_ADDRESS_LEN = 1
# MAX_ADDRESS_LEN = 30
# If you want your site to be private, uncomment below and change your password

View File

@@ -45,6 +45,7 @@ node_compat = true
# TITLE = "Custom Title" # 自定义网站标题
PREFIX = "tmp" # 要处理的邮箱名称前缀,不需要后缀可配置为空字符串
# (min, max) adderss的长度如果不设置默认为(1, 30)
# ANNOUNCEMENT = "Custom Announcement" # 自定义公告
# MIN_ADDRESS_LEN = 1
# MAX_ADDRESS_LEN = 30
# 如果你想要你的网站私有,取消下面的注释,并修改密码

View File

@@ -1,6 +1,6 @@
import { Hono } from 'hono'
import { getDomains, getPasswords, getBooleanValue, getIntValue, getStringArray, getDefaultDomains } from './utils';
import { getDomains, getPasswords, getBooleanValue, getIntValue, getStringArray, getDefaultDomains, getStringValue } from './utils';
import { CONSTANTS } from './constants';
import { HonoCustomType } from './types';
import { isS3Enabled } from './mails_api/s3_attachment';
@@ -17,6 +17,7 @@ api.get('/open_api/settings', async (c) => {
}
return c.json({
"title": c.env.TITLE,
"announcement": getStringValue(c.env.ANNOUNCEMENT),
"prefix": c.env.PREFIX,
"minAddressLen": getIntValue(c.env.MIN_ADDRESS_LEN, 1),
"maxAddressLen": getIntValue(c.env.MAX_ADDRESS_LEN, 30),

View File

@@ -1,5 +1,5 @@
export const CONSTANTS = {
VERSION: 'v0.6.0',
VERSION: 'v0.6.1',
// DB settings
ADDRESS_BLOCK_LIST_KEY: 'address_block_list',

View File

@@ -13,6 +13,7 @@ export type Bindings = {
// config
TITLE: string | undefined
ANNOUNCEMENT: string | undefined | null
PREFIX: string | undefined
MIN_ADDRESS_LEN: string | number | undefined
MAX_ADDRESS_LEN: string | number | undefined

View File

@@ -17,6 +17,7 @@ node_compat = true
[vars]
# TITLE = "Custom Title" # custom title
# ANNOUNCEMENT = "Custom Announcement"
PREFIX = "tmp"
# (min, max) length of the adderss, if not set, the default is (1, 30)
# MIN_ADDRESS_LEN = 1