diff --git a/mail-vue/src/axios/index.js b/mail-vue/src/axios/index.js
index 6d5ad08..c3fa85a 100644
--- a/mail-vue/src/axios/index.js
+++ b/mail-vue/src/axios/index.js
@@ -34,7 +34,7 @@ http.interceptors.response.use((res) => {
repeatNum: -4,
})
localStorage.removeItem('token')
- router.push('/login')
+ router.replace('/login')
reject(data)
} else if (data.code === 403) {
ElMessage({
diff --git a/mail-vue/src/components/email-scroll/index.vue b/mail-vue/src/components/email-scroll/index.vue
index 1d5a653..0cd2093 100644
--- a/mail-vue/src/components/email-scroll/index.vue
+++ b/mail-vue/src/components/email-scroll/index.vue
@@ -496,6 +496,8 @@ function updateCheckStatus() {
}
function jumpDetails(email) {
+ const sel = window.getSelection();
+ if (sel && !sel.isCollapsed) return;
emit('jump', email)
}
@@ -907,7 +909,7 @@ function loadData() {
.header-actions {
display: grid;
- grid-template-columns: auto 1fr auto auto;
+ grid-template-columns: auto 1fr auto;
align-items: center;
gap: 15px;
padding: 3px 15px;
diff --git a/mail-vue/src/components/tiny-editor/index.vue b/mail-vue/src/components/tiny-editor/index.vue
index 1783c3c..22f2c57 100644
--- a/mail-vue/src/components/tiny-editor/index.vue
+++ b/mail-vue/src/components/tiny-editor/index.vue
@@ -64,10 +64,6 @@ const language = computed(() => {
return 'zh_CN'
}
- if (locale.value === 'zhTW') {
- return 'zh_TW'
- }
-
return 'en'
})
diff --git a/mail-vue/src/enums/account-enum.js b/mail-vue/src/enums/account-enum.js
new file mode 100644
index 0000000..bb16b21
--- /dev/null
+++ b/mail-vue/src/enums/account-enum.js
@@ -0,0 +1,4 @@
+export const AccountAllReceiveEnum = {
+ DISABLED: 0,
+ ENABLED: 1
+}
\ No newline at end of file
diff --git a/mail-vue/src/i18n/en.js b/mail-vue/src/i18n/en.js
index 7e743b0..afc6b18 100644
--- a/mail-vue/src/i18n/en.js
+++ b/mail-vue/src/i18n/en.js
@@ -309,7 +309,8 @@ const en = {
atLeast: 'At Least',
character: '',
mustNotContain: 'Must Not Contain',
- mustNotContainDesc: 'Separate with commas'
+ mustNotContainDesc: 'Separate with commas',
+ setSuccess: 'Settings saved successfully'
}
export default en
diff --git a/mail-vue/src/i18n/zh.js b/mail-vue/src/i18n/zh.js
index 2d7fe30..4354bca 100644
--- a/mail-vue/src/i18n/zh.js
+++ b/mail-vue/src/i18n/zh.js
@@ -309,6 +309,7 @@ const zh = {
atLeast: '至少',
character: '位',
mustNotContain: '禁止包含',
- mustNotContainDesc: '输入多个值用,分开'
+ mustNotContainDesc: '输入多个值用,分开',
+ setSuccess: '设置成功'
}
export default zh
diff --git a/mail-vue/src/icons/index.js b/mail-vue/src/icons/index.js
index a36507d..287ce19 100644
--- a/mail-vue/src/icons/index.js
+++ b/mail-vue/src/icons/index.js
@@ -694,4 +694,16 @@ addCollection({
}
}
})
+addCollection({
+ "prefix": "flat-color-icons",
+ "lastModified": 1754899066,
+ "aliases": {},
+ "width": 48,
+ "height": 48,
+ "icons": {
+ "folder": {
+ "body": ""
+ }
+ }
+})
diff --git a/mail-vue/src/layout/account/index.vue b/mail-vue/src/layout/account/index.vue
index 80e5517..b538893 100644
--- a/mail-vue/src/layout/account/index.vue
+++ b/mail-vue/src/layout/account/index.vue
@@ -13,7 +13,8 @@
-
+
+
@@ -127,19 +128,22 @@
diff --git a/mail-vue/src/views/send/index.vue b/mail-vue/src/views/send/index.vue
index a562c0a..f5879c6 100644
--- a/mail-vue/src/views/send/index.vue
+++ b/mail-vue/src/views/send/index.vue
@@ -29,6 +29,7 @@ import {starAdd, starCancel} from "@/request/star.js";
import {defineOptions, onMounted, reactive, ref, watch} from "vue";
import router from "@/router/index.js";
import {Icon} from "@iconify/vue";
+import {AccountAllReceiveEnum} from "@/enums/account-enum.js";
defineOptions({
name: 'send'
@@ -71,7 +72,13 @@ function cancelStar(email) {
}
function getEmailList(emailId, size) {
- return emailList(accountStore.currentAccountId, emailId, params.timeSort, size, 1)
+ const accountId = accountStore.currentAccountId;
+ const allReceive = accountStore.currentAccount.allReceive;
+ return emailList(accountId, allReceive, emailId, params.timeSort, size, 1).then(data => {
+ data.latestEmail.reqAccountId = accountId;
+ data.latestEmail.allReceive = allReceive;
+ return data;
+ })
}
diff --git a/mail-vue/src/views/sys-setting/index.vue b/mail-vue/src/views/sys-setting/index.vue
index 59a3f06..80a736e 100644
--- a/mail-vue/src/views/sys-setting/index.vue
+++ b/mail-vue/src/views/sys-setting/index.vue
@@ -754,7 +754,7 @@ defineOptions({
name: 'sys-setting'
})
-const currentVersion = 'v2.5.0'
+const currentVersion = 'v2.6.0'
const hasUpdate = ref(false)
let getUpdateErrorCount = 1;
const {t, locale} = useI18n();
diff --git a/mail-worker/src/api/account-api.js b/mail-worker/src/api/account-api.js
index ddd58f6..c73797b 100644
--- a/mail-worker/src/api/account-api.js
+++ b/mail-worker/src/api/account-api.js
@@ -22,3 +22,8 @@ app.put('/account/setName', async (c) => {
await accountService.setName(c, await c.req.json(), userContext.getUserId(c));
return c.json(result.ok());
});
+
+app.put('/account/setAllReceive', async (c) => {
+ await accountService.setAllReceive(c, await c.req.json(), userContext.getUserId(c));
+ return c.json(result.ok());
+});
diff --git a/mail-worker/src/const/entity-const.js b/mail-worker/src/const/entity-const.js
index 6635af9..3afcb18 100644
--- a/mail-worker/src/const/entity-const.js
+++ b/mail-worker/src/const/entity-const.js
@@ -7,6 +7,13 @@ export const userConst = {
}
}
+export const accountConst = {
+ allReceive: {
+ CLOSE: 0,
+ OPEN: 1
+ }
+}
+
export const roleConst = {
isDefault: {
CLOSE: 0,
diff --git a/mail-worker/src/entity/account.js b/mail-worker/src/entity/account.js
index 96e2448..6d10b00 100644
--- a/mail-worker/src/entity/account.js
+++ b/mail-worker/src/entity/account.js
@@ -8,6 +8,7 @@ export const account = sqliteTable('account', {
latestEmailTime: text('latest_email_time'),
createTime: text('create_time').default(sql`CURRENT_TIMESTAMP`),
userId: integer('user_id').notNull(),
+ allReceive: integer('all_receive').default(0).notNull(),
isDel: integer('is_del').default(0).notNull(),
});
export default account
diff --git a/mail-worker/src/init/init.js b/mail-worker/src/init/init.js
index a0e4439..c1ce9be 100644
--- a/mail-worker/src/init/init.js
+++ b/mail-worker/src/init/init.js
@@ -25,10 +25,19 @@ const init = {
await this.v2_3DB(c);
await this.v2_4DB(c);
await this.v2_5DB(c);
+ await this.v2_6DB(c);
await settingService.refresh(c);
return c.text(t('initSuccess'));
},
+ async v2_6DB(c) {
+ try {
+ await c.env.db.prepare(`ALTER TABLE account ADD COLUMN all_receive INTEGER NOT NULL DEFAULT 0;`).run();
+ } catch (e) {
+ console.error(e)
+ }
+ },
+
async v2_5DB(c) {
try {
diff --git a/mail-worker/src/service/account-service.js b/mail-worker/src/service/account-service.js
index 76d347b..015241d 100644
--- a/mail-worker/src/service/account-service.js
+++ b/mail-worker/src/service/account-service.js
@@ -6,7 +6,7 @@ import emailService from './email-service';
import orm from '../entity/orm';
import account from '../entity/account';
import { and, asc, eq, gt, inArray, count, sql, ne } from 'drizzle-orm';
-import { isDel, settingConst } from '../const/entity-const';
+import {accountConst, isDel, settingConst} from '../const/entity-const';
import settingService from './setting-service';
import turnstileService from './turnstile-service';
import roleService from './role-service';
@@ -231,8 +231,18 @@ const accountService = {
const { accountId } = params
await emailService.physicsDeleteByAccountId(c, accountId)
await orm(c).delete(account).where(eq(account.accountId, accountId)).run();
- }
+ },
+ async setAllReceive(c, params, userId) {
+ let a = null
+ const { accountId } = params;
+ const accountRow = await this.selectById(c, accountId);
+ if (accountRow.userId !== userId) {
+ return;
+ }
+ await orm(c).update(account).set({ allReceive: accountConst.allReceive.CLOSE }).where(eq(account.userId, userId)).run();
+ await orm(c).update(account).set({ allReceive: accountRow.allReceive ? 0 : 1 }).where(eq(account.accountId, accountId)).run();
+ }
};
export default accountService;
diff --git a/mail-worker/src/service/email-service.js b/mail-worker/src/service/email-service.js
index 27d2ef4..11387df 100644
--- a/mail-worker/src/service/email-service.js
+++ b/mail-worker/src/service/email-service.js
@@ -19,17 +19,19 @@ import kvConst from '../const/kv-const';
import { t } from '../i18n/i18n'
import r2Service from './r2-service';
import domainUtils from '../utils/domain-uitls';
+import account from "../entity/account";
const emailService = {
async list(c, params, userId) {
- let { emailId, type, accountId, size, timeSort } = params;
+ let { emailId, type, accountId, size, timeSort, allReceive } = params;
size = Number(size);
emailId = Number(emailId);
timeSort = Number(timeSort);
accountId = Number(accountId);
+ allReceive = Number(allReceive);
if (size > 30) {
size = 30;
@@ -45,6 +47,10 @@ const emailService = {
}
+ if (isNaN(allReceive)) {
+ let accountRow = await accountService.selectById(c, accountId);
+ allReceive = accountRow.allReceive;
+ }
const query = orm(c)
.select({
@@ -58,14 +64,18 @@ const emailService = {
eq(star.emailId, email.emailId),
eq(star.userId, userId)
)
+ ).leftJoin(
+ account,
+ eq(account.accountId, email.accountId)
)
.where(
and(
+ allReceive ? eq(1,1) : eq(email.accountId, accountId),
eq(email.userId, userId),
- eq(email.accountId, accountId),
timeSort ? gt(email.emailId, emailId) : lt(email.emailId, emailId),
eq(email.type, type),
- eq(email.isDel, isDel.NORMAL)
+ eq(email.isDel, isDel.NORMAL),
+ eq(account.isDel, isDel.NORMAL)
)
);
@@ -77,23 +87,29 @@ const emailService = {
const listQuery = query.limit(size).all();
- const totalQuery = orm(c).select({ total: count() }).from(email).where(
- and(
- eq(email.accountId, accountId),
- eq(email.userId, userId),
- eq(email.type, type),
- eq(email.isDel, isDel.NORMAL)
+ const totalQuery = orm(c).select({ total: count() }).from(email)
+ .leftJoin(
+ account,
+ eq(account.accountId, email.accountId)
)
+ .where(
+ and(
+ allReceive ? eq(1,1) : eq(email.accountId, accountId),
+ eq(email.userId, userId),
+ eq(email.type, type),
+ eq(email.isDel, isDel.NORMAL),
+ eq(account.isDel, isDel.NORMAL)
+ )
).get();
const latestEmailQuery = orm(c).select().from(email).where(
and(
- eq(email.accountId, accountId),
+ allReceive ? eq(1,1) : eq(email.accountId, accountId),
eq(email.userId, userId),
eq(email.type, type),
eq(email.isDel, isDel.NORMAL)
))
- .orderBy(desc(email.emailId)).limit(1).get();
+ .orderBy(desc(email.emailId)).limit(size).get();
let [list, totalRow, latestEmail] = await Promise.all([listQuery, totalQuery, latestEmailQuery]);
@@ -445,15 +461,28 @@ const emailService = {
},
async latest(c, params, userId) {
- let { emailId, accountId } = params;
- const list = await orm(c).select().from(email).where(
- and(
- eq(email.userId, userId),
- eq(email.isDel, isDel.NORMAL),
- eq(email.accountId, accountId),
- eq(email.type, emailConst.type.RECEIVE),
- gt(email.emailId, emailId)
- ))
+ let { emailId, accountId, allReceive } = params;
+ allReceive = Number(allReceive);
+
+ if (isNaN(allReceive)) {
+ let accountRow = await accountService.selectById(c, accountId);
+ allReceive = accountRow.allReceive;
+ }
+
+ const list = await orm(c).select({...email}).from(email)
+ .leftJoin(
+ account,
+ eq(account.accountId, email.accountId)
+ )
+ .where(
+ and(
+ eq(email.userId, userId),
+ eq(email.isDel, isDel.NORMAL),
+ eq(account.isDel, isDel.NORMAL),
+ allReceive ? eq(1,1) : eq(email.accountId, accountId),
+ eq(email.type, emailConst.type.RECEIVE),
+ gt(email.emailId, emailId)
+ ))
.orderBy(desc(email.emailId))
.limit(20);