diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 8457aa0..9f4e302 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -12,7 +12,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule): void
{
- $schedule->command('app:mark-timeout-mail')->minutely();
+ $schedule->command('app:mark-timeout-mail')->everyMinute();
}
/**
diff --git a/app/Http/Controllers/MailController.php b/app/Http/Controllers/MailController.php
index 9f7b6f3..67d4e89 100644
--- a/app/Http/Controllers/MailController.php
+++ b/app/Http/Controllers/MailController.php
@@ -88,7 +88,7 @@ function ($attribute, $value, $fail) {
return abort(400, $th->getMessage());
}
- $new_email_list = Mail::where($where)
+ $email_list = Mail::where($where)
->select([
'id as key',
'from',
@@ -100,17 +100,23 @@ function ($attribute, $value, $fail) {
->orderBy('received_at', 'asc')
->get();
- $key = ['time' => time()];
+ // $mail_ids = array_column($email_list->toArray(), 'key');
- foreach ($new_email_list as $value) {
- $value->key = Crypt::encryptString($value->key);
+ foreach ($email_list as $value) {
+ $value->hash = hash('sha256', $value->key . $value->to . $value->received_at . $value->created_at);
+ $value->key = Crypt::encryptString($value->key);
}
+ // Mail::whereIn('id', $mail_ids)->update([
+ // 'is_read' => 1,
+ // ]);
+
+ $key = ['time' => time()];
return response()->json([
'code' => 1,
'msg' => '',
'data' => [
- 'list' => $new_email_list,
+ 'list' => $email_list,
'new_key' => Crypt::encryptString(json_encode($key)),
],
]);
diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php
index 16c55f7..566dacf 100644
--- a/resources/views/welcome.blade.php
+++ b/resources/views/welcome.blade.php
@@ -103,12 +103,12 @@
@@ -202,7 +204,10 @@
let email = "";
let key = "{{$key}}";
let isRequestPending = false;
- let countdown = 10;
+ let countdown = 5;
+ let savedPrefix = localStorage.getItem('prefix');
+ let savedDomain = localStorage.getItem('domain');
+
let csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
@@ -243,8 +248,11 @@ function fetchMail() {
$('#default-note').hide();
}
$.each(response.data.list, function (k, v) {
- let temp_html = '
| ' + v.from + ' | ' + v.title + ' | ' + dateFmt(v.received_at) + ' | |
';
- $('#default-note').parent().append(temp_html);
+ if ($('#mail-list tr[data-hash="' + v.hash + '"]').length <= 0) {
+ let temp_html = '
| ' + v.from + ' | ' + v.title + ' | ' + dateFmt(v.received_at) + ' | |
';
+ $('#mail-list').parent().append(temp_html);
+ }
+
})
// 在这里处理你的响应数据
},
@@ -267,61 +275,81 @@ function fetchMail() {
});
$('[data-toggle="tooltip"]').tooltip();
+
+
+ if (savedPrefix) {
+ $('#prefixInput').val(savedPrefix);
+ }
+
+ if (savedDomain) {
+ if ($('#domainList option[value="' + savedDomain + '"]').length <= 0) {
+ $('#domainList').append('
');
+ }
+ $('#domainList').val(savedDomain);
+
+ } else {
+ $('#domainList').val('{{$domain_list[0]}}');
+ }
+
+
+
+
$('.select2').select2({
tags: true
});
var clipboard = new ClipboardJS('.copy-btn');
clipboard.on('success', function (e) {
- console.info('Action:', e.action);
- console.info('Text:', e.text);
- console.info('Trigger:', e.trigger);
+ // console.info('Action:', e.action);
+ // console.info('Text:', e.text);
+ // console.info('Trigger:', e.trigger);
e.clearSelection();
});
clipboard.on('error', function (e) {
+ alert('复制失败');
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
- $('#selectOption').on('change keyup', function () {
- let domain = $('#selectOption').val();
+ $('#domainList').on('change keyup', function () {
+ let domain = $('#domainList').val();
if (!isValidDomain(domain)) {
- $('#selectOption').addClass('is-invalid');
+ $('#domainList').addClass('is-invalid');
$('#domainInvalidFeedback').remove();
- $('#selectOption').parent().append('
请输入一个合法的域名
');
+ $('#domainList').parent().append('
请输入一个合法的域名
');
$('#saveBtn').hide();
return false;
} else {
- $('#selectOption').removeClass('is-invalid');
+ $('#domainList').removeClass('is-invalid');
$('#domainInvalidFeedback').remove();
}
$('#saveBtn').show();
});
- $('#inputText').on('change keyup', function () {
+ $('#prefixInput').on('change keyup', function () {
this.value = this.value.toLowerCase().replace(/[^a-z0-9]/g, '');
- let textLength = $('#inputText').val().length;
+ let textLength = $('#prefixInput').val().length;
if (textLength < 5 || textLength > 32) {
- $('#inputText').addClass('is-invalid');
+ $('#prefixInput').addClass('is-invalid');
$('#perfixInvalidFeedback').remove();
- $('#inputText').parent().append('
长度必须在5到32位之间
');
+ $('#prefixInput').parent().append('
长度必须在5到32位之间
');
$('#saveBtn').hide();
return false;
- } else if (block_prefix.includes($('#inputText').val())) {
- $('#inputText').addClass('is-invalid');
+ } else if (block_prefix.includes($('#prefixInput').val())) {
+ $('#prefixInput').addClass('is-invalid');
$('#perfixInvalidFeedback').remove();
- $('#inputText').parent().append('
该前缀不被允许
');
+ $('#prefixInput').parent().append('
该前缀不被允许
');
$('#saveBtn').hide();
return false;
}
else {
- $('#inputText').removeClass('is-invalid');
+ $('#prefixInput').removeClass('is-invalid');
$('#perfixInvalidFeedback').remove();
}
$('#saveBtn').show();
@@ -332,15 +360,20 @@ function fetchMail() {
$('#saveBtn').click(function () {
- email = $('#inputText').val() + "@" + $('#selectOption').val();
+ email = $('#prefixInput').val() + "@" + $('#domainList').val();
$('#mailToCopy').val(email);
console.log("邮箱:" + email);
+ localStorage.setItem('prefix', $('#prefixInput').val());
+ localStorage.setItem('domain', $('#domainList').val());
+
$(this).hide();
});
- $('#selectOption').val('{{$domain_list[0]}}');
+
+
$('#saveBtn').click();
+ fetchMail();
var countdownTimer = setInterval(function () {
if (isRequestPending) {
$('#auto-reload').val('刷新中...');
@@ -351,7 +384,7 @@ function fetchMail() {
if (countdown <= 0) {
fetchMail();
$('#auto-reload').val('刷新中...');
- countdown = 11; // 重置为 11,因为下一次循环会立即减 1
+ countdown = 6; // 重置为 11,因为下一次循环会立即减 1
}
}, 1000);
@@ -370,12 +403,12 @@ function fetchMail() {
$('#myModal').on('shown.bs.modal', function () {
let iframeHeight = $('#modalIframe').contents().find("html").height();
- if (iframeHeight <= 600){
- $('#modalIframe').css('height',600);
- } else if (iframeHeight >= 800){
- $('#modalIframe').css('height',800);
+ if (iframeHeight <= 600) {
+ $('#modalIframe').css('height', 600);
+ } else if (iframeHeight >= 800) {
+ $('#modalIframe').css('height', 800);
} else {
- $('#modalIframe').css('height',iframeHeight);
+ $('#modalIframe').css('height', iframeHeight);
}
});
@@ -418,4 +451,4 @@ function fetchMail() {