mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-08-25 02:01:11 +08:00
fix: UI tab active icon wrong position (#416)
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
## main(v0.7.3)
|
## main(v0.7.3)
|
||||||
|
|
||||||
- feat: worker 增加 `ADDRESS_CHECK_REGEX`, address name 的正则表达式, 只用于检查,符合条件将通过检查
|
- feat: worker 增加 `ADDRESS_CHECK_REGEX`, address name 的正则表达式, 只用于检查,符合条件将通过检查
|
||||||
|
- fix: UI 修复登录页面 tab 激活图标错位
|
||||||
|
|
||||||
## v0.7.2
|
## v0.7.2
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ const getOpenSettings = async (message) => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error(error.message || "error");
|
message.error(error.message || "error");
|
||||||
|
} finally {
|
||||||
|
openSettings.value.fetched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,6 +124,8 @@ const getUserOpenSettings = async (message) => {
|
|||||||
Object.assign(userOpenSettings.value, res);
|
Object.assign(userOpenSettings.value, res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error(error.message || "fetch settings failed");
|
message.error(error.message || "fetch settings failed");
|
||||||
|
} finally {
|
||||||
|
userOpenSettings.value.fetched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export const useGlobalState = createGlobalState(
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const announcement = useLocalStorage('announcement', '');
|
const announcement = useLocalStorage('announcement', '');
|
||||||
const openSettings = ref({
|
const openSettings = ref({
|
||||||
|
fetched: false,
|
||||||
title: '',
|
title: '',
|
||||||
announcement: '',
|
announcement: '',
|
||||||
prefix: '',
|
prefix: '',
|
||||||
@@ -67,6 +68,7 @@ export const useGlobalState = createGlobalState(
|
|||||||
const globalTabplacement = useStorage('globalTabplacement', 'top');
|
const globalTabplacement = useStorage('globalTabplacement', 'top');
|
||||||
const useSideMargin = useStorage('useSideMargin', true);
|
const useSideMargin = useStorage('useSideMargin', true);
|
||||||
const userOpenSettings = ref({
|
const userOpenSettings = ref({
|
||||||
|
fetched: false,
|
||||||
enable: false,
|
enable: false,
|
||||||
enableMailVerify: false,
|
enableMailVerify: false,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ onMounted(async () => {
|
|||||||
<n-checkbox v-model:checked="userSettings.enableMailVerify" style="width: 20%;">
|
<n-checkbox v-model:checked="userSettings.enableMailVerify" style="width: 20%;">
|
||||||
{{ t('enable') }}
|
{{ t('enable') }}
|
||||||
</n-checkbox>
|
</n-checkbox>
|
||||||
<n-input v-model:value="userSettings.verifyMailSender" style="width: 80%;"
|
<n-input v-model:value="userSettings.verifyMailSender" v-if="userSettings.enableMailVerify"
|
||||||
:placeholder="t('verifyMailSender')" />
|
style="width: 80%;" :placeholder="t('verifyMailSender')" />
|
||||||
</n-input-group>
|
</n-input-group>
|
||||||
</n-form-item-row>
|
</n-form-item-row>
|
||||||
<n-form-item-row :label="t('enableMailAllowList')">
|
<n-form-item-row :label="t('enableMailAllowList')">
|
||||||
@@ -101,8 +101,9 @@ onMounted(async () => {
|
|||||||
<n-checkbox v-model:checked="userSettings.enableMailAllowList" style="width: 20%;">
|
<n-checkbox v-model:checked="userSettings.enableMailAllowList" style="width: 20%;">
|
||||||
{{ t('enable') }}
|
{{ t('enable') }}
|
||||||
</n-checkbox>
|
</n-checkbox>
|
||||||
<n-select v-model:value="userSettings.mailAllowList" filterable multiple tag style="width: 80%;"
|
<n-select v-model:value="userSettings.mailAllowList" v-if="userSettings.enableMailAllowList"
|
||||||
:options="mailAllowOptions" :placeholder="t('mailAllowList')" />
|
filterable multiple tag style="width: 80%;" :options="mailAllowOptions"
|
||||||
|
:placeholder="t('mailAllowList')" />
|
||||||
</n-input-group>
|
</n-input-group>
|
||||||
</n-form-item-row>
|
</n-form-item-row>
|
||||||
<n-form-item-row :label="t('maxAddressCount')">
|
<n-form-item-row :label="t('maxAddressCount')">
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ const { t } = useI18n({
|
|||||||
successTip: 'Success',
|
successTip: 'Success',
|
||||||
webhookAllowList: 'Webhook Allow List(Enter the address that is allowed to use webhook)',
|
webhookAllowList: 'Webhook Allow List(Enter the address that is allowed to use webhook)',
|
||||||
save: 'Save',
|
save: 'Save',
|
||||||
|
notEnabled: 'Webhook is not enabled',
|
||||||
},
|
},
|
||||||
zh: {
|
zh: {
|
||||||
successTip: '成功',
|
successTip: '成功',
|
||||||
webhookAllowList: 'Webhook 白名单(请输入允许使用webhook 的地址)',
|
webhookAllowList: 'Webhook 白名单(请输入允许使用webhook 的地址)',
|
||||||
save: '保存',
|
save: '保存',
|
||||||
|
notEnabled: 'Webhook 未开启',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -33,11 +35,13 @@ class WebhookSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const webhookSettings = ref(new WebhookSettings([]))
|
const webhookSettings = ref(new WebhookSettings([]))
|
||||||
|
const webhookEnabled = ref(false)
|
||||||
|
|
||||||
const getSettings = async () => {
|
const getSettings = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await api.fetch(`/admin/webhook/settings`)
|
const res = await api.fetch(`/admin/webhook/settings`)
|
||||||
Object.assign(webhookSettings.value, res)
|
Object.assign(webhookSettings.value, res)
|
||||||
|
webhookEnabled.value = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error((error as Error).message || "error");
|
message.error((error as Error).message || "error");
|
||||||
}
|
}
|
||||||
@@ -62,7 +66,7 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="center">
|
<div class="center">
|
||||||
<n-card :bordered="false" embedded style="max-width: 800px; overflow: auto;">
|
<n-card v-if="webhookEnabled" :bordered="false" embedded style="max-width: 800px; overflow: auto;">
|
||||||
<n-form-item-row :label="t('webhookAllowList')">
|
<n-form-item-row :label="t('webhookAllowList')">
|
||||||
<n-select v-model:value="webhookSettings.allowList" filterable multiple tag
|
<n-select v-model:value="webhookSettings.allowList" filterable multiple tag
|
||||||
:placeholder="t('webhookAllowList')" />
|
:placeholder="t('webhookAllowList')" />
|
||||||
@@ -71,6 +75,7 @@ onMounted(async () => {
|
|||||||
{{ t('save') }}
|
{{ t('save') }}
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-card>
|
</n-card>
|
||||||
|
<n-result v-else status="404" :title="t('notEnabled')" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ onMounted(async () => {
|
|||||||
<n-alert v-if="userSettings.user_email" :show-icon="false" :bordered="false" closable>
|
<n-alert v-if="userSettings.user_email" :show-icon="false" :bordered="false" closable>
|
||||||
<span>{{ t('bindUserInfo') }}</span>
|
<span>{{ t('bindUserInfo') }}</span>
|
||||||
</n-alert>
|
</n-alert>
|
||||||
<n-tabs v-model:value="tabValue" size="large" justify-content="space-evenly">
|
<n-tabs v-if="openSettings.fetched" v-model:value="tabValue" size="large" justify-content="space-evenly">
|
||||||
<n-tab-pane name="signin" :tab="t('login')">
|
<n-tab-pane name="signin" :tab="t('login')">
|
||||||
<n-form>
|
<n-form>
|
||||||
<n-form-item-row :label="t('credential')" required>
|
<n-form-item-row :label="t('credential')" required>
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="center">
|
<div class="center">
|
||||||
<n-tabs v-model:value="tabValue" size="large" justify-content="space-evenly">
|
<n-tabs v-model:value="tabValue" size="large" v-if="userOpenSettings.fetched" justify-content="space-evenly">
|
||||||
<n-tab-pane name="signin" :tab="t('login')">
|
<n-tab-pane name="signin" :tab="t('login')">
|
||||||
<n-form>
|
<n-form>
|
||||||
<n-form-item-row :label="t('email')" required>
|
<n-form-item-row :label="t('email')" required>
|
||||||
|
|||||||
@@ -2,16 +2,9 @@ import { Context } from "hono";
|
|||||||
import { HonoCustomType } from "../types";
|
import { HonoCustomType } from "../types";
|
||||||
import { CONSTANTS } from "../constants";
|
import { CONSTANTS } from "../constants";
|
||||||
import { WebhookSettings } from "../models";
|
import { WebhookSettings } from "../models";
|
||||||
import { getBooleanValue } from "../utils";
|
|
||||||
import { commonParseMail, sendWebhook } from "../common";
|
import { commonParseMail, sendWebhook } from "../common";
|
||||||
|
|
||||||
async function getWebhookSettings(c: Context<HonoCustomType>): Promise<Response> {
|
async function getWebhookSettings(c: Context<HonoCustomType>): Promise<Response> {
|
||||||
if (!c.env.KV) {
|
|
||||||
return c.text("KV is not available", 400);
|
|
||||||
}
|
|
||||||
if (!getBooleanValue(c.env.ENABLE_WEBHOOK)) {
|
|
||||||
return c.text("Webhook is disabled", 403);
|
|
||||||
}
|
|
||||||
const settings = await c.env.KV.get<WebhookSettings>(
|
const settings = await c.env.KV.get<WebhookSettings>(
|
||||||
CONSTANTS.WEBHOOK_KV_ADMIN_MAIL_SETTINGS_KEY, "json"
|
CONSTANTS.WEBHOOK_KV_ADMIN_MAIL_SETTINGS_KEY, "json"
|
||||||
) || new WebhookSettings();
|
) || new WebhookSettings();
|
||||||
|
|||||||
@@ -7,12 +7,6 @@ import { commonParseMail, sendWebhook } from "../common";
|
|||||||
|
|
||||||
|
|
||||||
async function getWebhookSettings(c: Context<HonoCustomType>): Promise<Response> {
|
async function getWebhookSettings(c: Context<HonoCustomType>): Promise<Response> {
|
||||||
if (!c.env.KV) {
|
|
||||||
return c.text("KV is not available", 400);
|
|
||||||
}
|
|
||||||
if (!getBooleanValue(c.env.ENABLE_WEBHOOK)) {
|
|
||||||
return c.text("Webhook is disabled", 403);
|
|
||||||
}
|
|
||||||
const { address } = c.get("jwtPayload")
|
const { address } = c.get("jwtPayload")
|
||||||
const adminSettings = await c.env.KV.get<AdminWebhookSettings>(CONSTANTS.WEBHOOK_KV_SETTINGS_KEY, "json");
|
const adminSettings = await c.env.KV.get<AdminWebhookSettings>(CONSTANTS.WEBHOOK_KV_SETTINGS_KEY, "json");
|
||||||
if (!adminSettings?.allowList.includes(address)) {
|
if (!adminSettings?.allowList.includes(address)) {
|
||||||
|
|||||||
@@ -42,9 +42,11 @@ app.use('/*', async (c, next) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// webhook check
|
||||||
if (
|
if (
|
||||||
c.req.path.startsWith("/api/webhook")
|
c.req.path.startsWith("/api/webhook")
|
||||||
|| c.req.path.startsWith("/admin/webhook")
|
|| c.req.path.startsWith("/admin/webhook")
|
||||||
|
|| c.req.path.startsWith("/admin/mail_webhook")
|
||||||
) {
|
) {
|
||||||
if (!c.env.KV) {
|
if (!c.env.KV) {
|
||||||
return c.text("KV is not available", 400);
|
return c.text("KV is not available", 400);
|
||||||
|
|||||||
Reference in New Issue
Block a user