新增设置注册邮箱前缀最小位数

This commit is contained in:
eoao
2025-11-08 22:25:00 +08:00
parent d0c04cf2e9
commit 28f7814190
18 changed files with 192 additions and 43 deletions
@@ -12,7 +12,7 @@
<slot name="first"></slot>
<Icon class="icon reload" icon="ion:reload" width="18" height="18" @click="refresh"/>
<Icon v-perm="'email:delete'" class="icon" icon="uiw:delete" width="16" height="16"
<Icon v-perm="'email:delete'" class="icon delete" icon="uiw:delete" width="16" height="16"
v-if="getSelectedMailsIds().length > 0"
@click="handleDelete"/>
</div>
+5 -1
View File
@@ -191,6 +191,7 @@ const en = {
delSuccessMsg: 'Deleted successfully',
emptyEmailMsg: 'Email cannot be empty',
notEmailMsg: 'Invalid email',
minEmailPrefix: 'Email must be at least {msg} characters',
emptyPwdMsg: 'Password cannot be empty',
pwdLengthMsg: 'Password must be at least 6 characters',
confirmPwdFailMsg: 'The two passwords do not match',
@@ -303,7 +304,10 @@ const en = {
show: 'Show',
hide: 'Hide',
onlyName: 'Only name',
emailText: 'Email Text'
emailText: 'Email Text',
emailPrefix: 'Email Prefix',
atLeast: 'At Least',
character: ''
}
export default en
+5 -1
View File
@@ -193,6 +193,7 @@ const zh = {
notEmailMsg: '输入的邮箱不合法',
emptyPwdMsg: '密码不能为空',
pwdLengthMsg: '密码最少六位',
minEmailPrefix: '邮箱名不能小于{msg}位',
confirmPwdFailMsg: '两次密码输入不一致',
emptyRegKeyMsg: '注册码不能为空',
regSuccessMsg: '注册成功',
@@ -303,6 +304,9 @@ const zh = {
show: '显示',
hide: '隐藏',
onlyName: '仅名字',
emailText: '邮件文本'
emailText: '邮件文本',
emailPrefix: '邮箱前缀',
atLeast: '至少',
character: '位'
}
export default zh
+37
View File
@@ -646,3 +646,40 @@ addCollection({
}
}
})
addCollection({
"prefix": "mingcute",
"lastModified": 1754900188,
"aliases": {},
"width": 24,
"height": 24,
"icons": {
"github-line": {
"body": "<g fill=\"none\"><path d=\"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z\"/><path fill=\"currentColor\" d=\"M6.315 6.176c-.25-.638-.24-1.367-.129-2.034a6.8 6.8 0 0 1 2.12 1.07c.28.214.647.283.989.18A9.3 9.3 0 0 1 12 5c.961 0 1.874.14 2.703.391c.342.104.709.034.988-.18a6.8 6.8 0 0 1 2.119-1.07c.111.667.12 1.396-.128 2.033c-.15.384-.075.826.208 1.14C18.614 8.117 19 9.04 19 10c0 2.114-1.97 4.187-5.134 4.818c-.792.158-1.101 1.155-.495 1.726c.389.366.629.882.629 1.456v3a1 1 0 0 0 2 0v-3c0-.57-.12-1.112-.334-1.603C18.683 15.35 21 12.993 21 10c0-1.347-.484-2.585-1.287-3.622c.21-.82.191-1.646.111-2.28c-.071-.568-.17-1.312-.57-1.756c-.595-.659-1.58-.271-2.28-.032a9 9 0 0 0-2.125 1.045A11.4 11.4 0 0 0 12 3c-.994 0-1.953.125-2.851.356a9 9 0 0 0-2.125-1.045c-.7-.24-1.686-.628-2.281.031c-.408.452-.493 1.137-.566 1.719l-.005.038c-.08.635-.098 1.462.112 2.283C3.484 7.418 3 8.654 3 10c0 2.992 2.317 5.35 5.334 6.397A4 4 0 0 0 8 17.98l-.168.034c-.717.099-1.176.01-1.488-.122c-.76-.322-1.152-1.133-1.63-1.753c-.298-.385-.732-.866-1.398-1.088a1 1 0 0 0-.632 1.898c.558.186.944 1.142 1.298 1.566c.373.448.869.916 1.58 1.218c.682.29 1.483.393 2.438.276V21a1 1 0 0 0 2 0v-3c0-.574.24-1.09.629-1.456c.607-.572.297-1.568-.495-1.726C6.969 14.187 5 12.114 5 10c0-.958.385-1.881 1.108-2.684c.283-.314.357-.756.207-1.14\"/></g>"
}
}
})
addCollection({
"prefix": "hugeicons",
"lastModified": 1759033396,
"aliases": {},
"width": 24,
"height": 24,
"icons": {
"view": {
"body": "<g fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"><path d=\"M21.544 11.045c.304.426.456.64.456.955c0 .316-.152.529-.456.955C20.178 14.871 16.689 19 12 19c-4.69 0-8.178-4.13-9.544-6.045C2.152 12.529 2 12.315 2 12c0-.316.152-.529.456-.955C3.822 9.129 7.311 5 12 5c4.69 0 8.178 4.13 9.544 6.045Z\"/><path d=\"M15 12a3 3 0 1 0-6 0a3 3 0 0 0 6 0Z\"/></g>"
}
}
})
addCollection({
"prefix": "bitcoin-icons",
"lastModified": 1754898649,
"aliases": {},
"width": 24,
"height": 24,
"icons": {
"refresh-filled": {
"body": "<g fill=\"currentColor\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"><path d=\"M6.64 9.788a.75.75 0 0 1 .53.918a5 5 0 0 0 7.33 5.624a.75.75 0 1 1 .75 1.3a6.501 6.501 0 0 1-9.529-7.312a.75.75 0 0 1 .919-.53M8.75 6.37a6.5 6.5 0 0 1 9.529 7.312a.75.75 0 1 1-1.45-.388A5.001 5.001 0 0 0 9.5 7.67a.75.75 0 1 1-.75-1.3\"/><path d=\"M5.72 9.47a.75.75 0 0 1 1.06 0l2.5 2.5a.75.75 0 1 1-1.06 1.06l-1.97-1.97l-1.97 1.97a.75.75 0 0 1-1.06-1.06zm9 1.5a.75.75 0 0 1 1.06 0l1.97 1.97l1.97-1.97a.75.75 0 1 1 1.06 1.06l-2.5 2.5a.75.75 0 0 1-1.06 0l-2.5-2.5a.75.75 0 0 1 0-1.06\"/></g>"
}
}
})
+9
View File
@@ -377,6 +377,15 @@ function submit() {
return
}
if (addForm.email.length < settingStore.settings.minEmailPrefix) {
ElMessage({
message: t('minEmailPrefix', {msg: settingStore.settings.minEmailPrefix}),
type: 'error',
plain: true,
})
return
}
if (!isEmail(addForm.email + addForm.suffix)) {
ElMessage({
message: t('notEmailMsg'),
+10 -2
View File
@@ -397,7 +397,7 @@ function getEmailList(emailId, size) {
}
.clear {
@media (max-width: 407px) {
@media (max-width: 409px) {
position: absolute;
top: 41px;
left: 242px;
@@ -405,10 +405,18 @@ function getEmailList(emailId, size) {
}
:deep(.reload) {
@media (max-width: 407px) {
@media (max-width: 409px) {
position: absolute;
top: 42px;
left: 208px;
}
}
:deep(.delete) {
@media (max-width: 443px) {
position: absolute;
top: 43px;
left: 284px;
}
}
</style>
+21
View File
@@ -304,6 +304,16 @@ function bind() {
return
}
if (bindForm.email.length < settingStore.settings.minEmailPrefix) {
ElMessage({
message: t('minEmailPrefix', {msg: settingStore.settings.minEmailPrefix}),
type: 'error',
plain: true,
})
return
}
let email = bindForm.email + suffix.value;
@@ -407,6 +417,17 @@ function submitRegister() {
return
}
console.log(registerForm.email)
if (registerForm.email.length < settingStore.settings.minEmailPrefix) {
ElMessage({
message: t('minEmailPrefix', {msg: settingStore.settings.minEmailPrefix}),
type: 'error',
plain: true,
})
return
}
if (!isEmail(registerForm.email + suffix.value)) {
ElMessage({
message: t('notEmailMsg'),
+51 -8
View File
@@ -61,7 +61,16 @@
v-model="setting.manyEmail"/>
</div>
</div>
<div class="setting-item">
<div>
<span>{{ $t('emailPrefix') }}</span>
</div>
<div class="forward">
<el-button class="opt-button" size="small" type="primary" @click="openEmailPrefix">
<Icon icon="fluent:settings-48-regular" width="18" height="18"/>
</el-button>
</div>
</div>
</div>
</div>
@@ -349,7 +358,7 @@
<div class="concerning-item">
<span>{{ $t('version') }} :</span>
<el-badge is-dot :hidden="!hasUpdate">
<el-button @click="jump('https://github.com/eoao/maillab/releases')">
<el-button @click="jump('https://github.com/maillab/cloud-mail/releases')">
{{ currentVersion }}
<template #icon>
<Icon icon="qlementine-icons:version-control-16" style="font-size: 20px" color="#1890FF"/>
@@ -704,6 +713,16 @@
</div>
</form>
</el-dialog>
<el-dialog v-model="emailPrefixShow" :title="t('emailPrefix')" width="30" >
<div class="email-prefix">
<div>{{ t('atLeast') }}</div>
<el-input-number v-model="minEmailPrefix" :min="1" :max="20" @change="EmailPrefixChange" style="width: 150px" >
<template #suffix>
<span>{{ t('character') }}</span>
</template>
</el-input-number>
</div>
</el-dialog>
</el-scrollbar>
</div>
</template>
@@ -730,7 +749,7 @@ defineOptions({
name: 'sys-setting'
})
const currentVersion = 'v2.3.0'
const currentVersion = 'v2.4.0'
const hasUpdate = ref(false)
let getUpdateErrorCount = 1;
const {t, locale} = useI18n();
@@ -747,6 +766,7 @@ const tgSettingShow = ref(false)
const noticePopupShow = ref(false)
const thirdEmailShow = ref(false)
const forwardRulesShow = ref(false)
const emailPrefixShow = ref(false)
const showResendList = ref(false)
const settingStore = useSettingStore();
const uiStore = useUiStore();
@@ -756,6 +776,7 @@ const settingLoading = ref(false)
const clearS3Loading = ref(false)
const r2DomainInput = ref('')
const loginOpacity = ref(0)
const minEmailPrefix = ref(0)
const backgroundUrl = ref('')
let backgroundFile = {}
const showSetBackground = ref(false)
@@ -838,6 +859,7 @@ function getSettings() {
settingStore.domainList = settingData.domainList;
resendTokenForm.domain = setting.value.domainList[0]
loginOpacity.value = setting.value.loginOpacity
minEmailPrefix.value = setting.value.minEmailPrefix
firstLoading.value = false
backgroundUrl.value = setting.value.background?.startsWith('http') ? setting.value.background : ''
editTitle.value = setting.value.title
@@ -897,7 +919,7 @@ const resendList = computed(() => {
function getUpdate() {
if (getUpdateErrorCount > 5 || !getUpdateErrorCount) return
axios.get('https://api.github.com/repos/eoao/cloud-mail/releases/latest').then(({data}) => {
axios.get('https://api.github.com/repos/maillab/cloud-mail/releases/latest').then(({data}) => {
hasUpdate.value = data.name !== currentVersion
getUpdateErrorCount = 0
}).catch(e => {
@@ -993,6 +1015,10 @@ function openThirdEmailSetting() {
thirdEmailShow.value = true
}
function openEmailPrefix() {
emailPrefixShow.value = true
}
function openForwardRules() {
ruleType.value = setting.value.ruleType
ruleEmail.value = []
@@ -1111,6 +1137,17 @@ function doOpacityChange() {
editSetting(form, true)
}
function doEmailPrefix() {
const form = {}
form.minEmailPrefix = minEmailPrefix.value
editSetting(form, true)
}
const EmailPrefixChange = debounce(doEmailPrefix, 1000, {
leading: false,
trailing: true
})
const opacityChange = debounce(doOpacityChange, 1000, {
leading: false,
trailing: true
@@ -1279,6 +1316,7 @@ function editSetting(settingForm, refreshStatus = true) {
addS3Show.value = false
}).catch((e) => {
loginOpacity.value = setting.value.loginOpacity
minEmailPrefix.value = setting.value.minEmailPrefix
setting.value = {...setting.value, ...JSON.parse(backup)}
}).finally(() => {
settingLoading.value = false
@@ -1350,13 +1388,13 @@ function editSetting(settingForm, refreshStatus = true) {
}
.background {
width: 230px;
height: 120px;
width: 249px;
height: 140px;
border-radius: 4px;
border: 1px solid var(--light-border);
@media (max-width: 500px) {
width: 150px;
height: 83px;
width: 160px;
height: 90px;
}
}
@@ -1632,6 +1670,11 @@ function editSetting(settingForm, refreshStatus = true) {
width: fit-content !important;
}
.email-prefix {
display: flex;
justify-content: space-between;
}
.s3-button {
display: grid;
grid-template-columns: 80px 1fr;
+2 -1
View File
@@ -45,6 +45,7 @@ export const setting = sqliteTable('setting', {
customDomain: text('custom_domain').default('').notNull(),
tgMsgFrom: text('tg_msg_from').default('only-name').notNull(),
tgMsgTo: text('tg_msg_to').default('show').notNull(),
tgMsgText: text('tg_msg_text').default('hide').notNull()
tgMsgText: text('tg_msg_text').default('hide').notNull(),
minEmailPrefix: integer('min_email_prefix').default(0).notNull()
});
export default setting
+2 -1
View File
@@ -27,7 +27,8 @@ const en = {
notExistEmailReply: 'Mail does not exist and cannot be replied to',
pwdLengthLimit: 'Password length exceeds the limit',
emailLengthLimit: 'Email length exceeds the limit',
pwdMinLengthLimit: 'Password must be at least 6 characters',
minEmailPrefix: 'Email must be at least {{msg}} characters',
pwdMinLength: 'Password must be at least 6 characters',
notEmailDomain: 'Invalid email domain',
emptyRegKey: 'Invite code cannot be empty',
notExistRegKey: 'Invite code does not exist',
+1 -1
View File
@@ -25,6 +25,6 @@ i18next.init({
resources,
});
export const t = (key) => i18next.t(key)
export const t = (key, values) => i18next.t(key, values)
export default i18next;
+2 -1
View File
@@ -27,7 +27,8 @@ const zh = {
notExistEmailReply: '邮件不存在无法回复',
pwdLengthLimit: '密码长度超出限制',
emailLengthLimit: '邮箱长度超出限制',
pwdMinLengthLimit: '密码不能小于6位',
minEmailPrefix: '邮箱名不能小于{{msg}}位',
pwdMinLength: '密码不能小于6位',
notEmailDomain: '非法邮箱域名',
emptyRegKey: '注册码不能为空',
notExistRegKey: '注册码不存在',
+26 -15
View File
@@ -29,20 +29,31 @@ const init = {
},
async v2_4DB(c) {
await c.env.db.prepare(`
CREATE TABLE IF NOT EXISTS oauth (
oauth_id INTEGER PRIMARY KEY AUTOINCREMENT,
oauth_user_id TEXT,
username TEXT,
name TEXT,
avatar TEXT,
active INTEGER,
trust_level INTEGER,
silenced INTEGER,
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
user_id INTEGER NOT NULL DEFAULT 0
)
`).run();
try {
await c.env.db.prepare(`
CREATE TABLE IF NOT EXISTS oauth (
oauth_id INTEGER PRIMARY KEY AUTOINCREMENT,
oauth_user_id TEXT,
username TEXT,
name TEXT,
avatar TEXT,
active INTEGER,
trust_level INTEGER,
silenced INTEGER,
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
platform INTEGER NOT NULL DEFAULT 0,
user_id INTEGER NOT NULL DEFAULT 0
)
`).run();
} catch (e) {
console.error(e)
}
try {
await c.env.db.prepare(`ALTER TABLE setting ADD COLUMN min_email_prefix INTEGER NOT NULL DEFAULT 1;`).run();
} catch (e) {
console.error(e)
}
},
async v2_3DB(c) {
@@ -59,7 +70,7 @@ const init = {
}
try {
await c.env.db.prepare(`ALTER TABLE setting ADD COLUMN tg_msg_text TEXT NOT NULL DEFAULT 'hide';`).run();
await c.env.db.prepare(`ALTER TABLE setting ADD COLUMN tg_msg_text TEXT NOT NULL DEFAULT 'show';`).run();
} catch (e) {
console.error(e)
}
+4 -1
View File
@@ -17,7 +17,7 @@ const accountService = {
async add(c, params, userId) {
const {addEmailVerify , addEmail, manyEmail, addVerifyCount} = await settingService.query(c);
const {addEmailVerify , addEmail, manyEmail, addVerifyCount, minEmailPrefix} = await settingService.query(c);
let { email, token } = params;
@@ -39,6 +39,9 @@ const accountService = {
throw new BizError(t('notExistDomain'));
}
if (emailUtils.getName(email).length < minEmailPrefix) {
throw new BizError(t('minEmailPrefix', { msg: minEmailPrefix } ));
}
let accountRow = await this.selectByEmailIncludeDel(c, email);
+10 -6
View File
@@ -26,7 +26,7 @@ const loginService = {
const { email, password, token, code } = params;
let {regKey, register, registerVerify, regVerifyCount} = await settingService.query(c)
let {regKey, register, registerVerify, regVerifyCount, minEmailPrefix} = await settingService.query(c)
if (oauth) {
registerVerify = settingConst.registerVerify.CLOSE;
@@ -41,16 +41,20 @@ const loginService = {
throw new BizError(t('notEmail'));
}
if (emailUtils.getName(email).length < minEmailPrefix) {
throw new BizError(t('minEmailPrefix', { msg: minEmailPrefix } ));
}
if (emailUtils.getName(email).length > 64) {
throw new BizError(t('emailLengthLimit'));
}
if (password.length > 30) {
throw new BizError(t('pwdLengthLimit'));
}
if (emailUtils.getName(email).length > 30) {
throw new BizError(t('emailLengthLimit'));
}
if (password.length < 6) {
throw new BizError(t('pwdMinLengthLimit'));
throw new BizError(t('pwdMinLength'));
}
if (!c.env.domain.includes(emailUtils.getDomain(email))) {
+2 -1
View File
@@ -206,7 +206,8 @@ const settingService = {
loginDomain: settingRow.loginDomain,
linuxdoClientId: settingRow.linuxdoClientId,
linuxdoCallbackUrl: settingRow.linuxdoCallbackUrl,
linuxdoSwitch: settingRow.linuxdoSwitch
linuxdoSwitch: settingRow.linuxdoSwitch,
minEmailPrefix: settingRow.minEmailPrefix
};
}
};
+2 -1
View File
@@ -12,6 +12,7 @@ import emailMsgTemplate from '../template/email-msg';
import emailTextTemplate from '../template/email-text';
import emailHtmlTemplate from '../template/email-html';
import verifyUtils from '../utils/verify-utils';
import domainUtils from "../utils/domain-uitls";
const telegramService = {
@@ -50,7 +51,7 @@ const telegramService = {
const jwtToken = await jwtUtils.generateToken(c, { emailId: email.emailId })
const webAppUrl = verifyUtils.isDomain(customDomain) ? `https://${customDomain}/api/telegram/getEmail/${jwtToken}` : 'https://www.cloudflare.com/404'
const webAppUrl = customDomain ? `${domainUtils.toOssDomain(customDomain)}/api/telegram/getEmail/${jwtToken}` : 'https://www.cloudflare.com/404'
await Promise.all(tgChatIds.map(async chatId => {
try {
+2 -2
View File
@@ -53,7 +53,7 @@ const userService = {
const { password } = params;
if (password < 6) {
throw new BizError(t('pwdMinLengthLimit'));
throw new BizError(t('pwdMinLength'));
}
const { salt, hash } = await cryptoUtils.hashPassword(password);
await orm(c).update(user).set({ password: hash, salt: salt }).where(eq(user.userId, userId)).run();
@@ -304,7 +304,7 @@ const userService = {
}
if (password.length < 6) {
throw new BizError(t('pwdMinLengthLimit'));
throw new BizError(t('pwdMinLength'));
}
const accountRow = await accountService.selectByEmailIncludeDel(c, email);