fixbug
This commit is contained in:
parent
6af5beb990
commit
f5255b51ae
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
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)),
|
||||
],
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -103,12 +103,12 @@
|
|||
|
||||
<div class="col-5">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" id="inputText" value="{{$rand_prefix}}"
|
||||
<input type="text" class="form-control" id="prefixInput" value="{{$rand_prefix}}"
|
||||
placeholder="Enter text">
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text">@</span>
|
||||
</div>
|
||||
<select class="form-control select2" id="selectOption" style="width: auto;">
|
||||
<select class="form-control select2" id="domainList" style="width: auto;">
|
||||
@foreach($domain_list as $domain)
|
||||
<option value="{{$domain}}">{{$domain}}</option>
|
||||
@endforeach
|
||||
|
|
@ -130,7 +130,7 @@
|
|||
<div class="col-4">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control alert alert-primary" id="auto-reload"
|
||||
value="距离下次刷新还有10秒" disabled readonly>
|
||||
value="距离下次刷新还有5秒" disabled readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
|
|
@ -162,9 +162,11 @@
|
|||
</div>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<a href="https://github.com/996icu/996.ICU/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-Anti%20996-blue.svg" alt="996 license" /></a>
|
||||
<a href="https://github.com/996icu/996.ICU/blob/master/LICENSE"><img
|
||||
src="https://img.shields.io/badge/license-Anti%20996-blue.svg" alt="996 license" /></a>
|
||||
<span class="text-muted">© 2023 临时邮箱. All rights reserved.</span>
|
||||
<a href="https://996.icu"><img src="https://img.shields.io/badge/link-996.icu-red.svg" alt="996.icu" /></a>
|
||||
<a href="https://996.icu"><img src="https://img.shields.io/badge/link-996.icu-red.svg"
|
||||
alt="996.icu" /></a>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
|
@ -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 = '<tr><td>' + v.from + '</td><td>' + v.title + '</td><td>' + dateFmt(v.received_at) + '</td><td><button class="btn btn-primary info-btn btn-sm" data-key="' + v.key + '" type="button">查看</button></td></tr>';
|
||||
$('#default-note').parent().append(temp_html);
|
||||
if ($('#mail-list tr[data-hash="' + v.hash + '"]').length <= 0) {
|
||||
let temp_html = '<tr data-hash="' + v.hash + '"><td>' + v.from + '</td><td>' + v.title + '</td><td>' + dateFmt(v.received_at) + '</td><td><button class="btn btn-primary info-btn btn-sm" data-key="' + v.key + '" type="button">查看</button></td></tr>';
|
||||
$('#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('<option value="' + savedDomain + '">' + savedDomain + '</option>');
|
||||
}
|
||||
$('#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('<div id="domainInvalidFeedback" class="invalid-feedback">请输入一个合法的域名</div>');
|
||||
$('#domainList').parent().append('<div id="domainInvalidFeedback" class="invalid-feedback">请输入一个合法的域名</div>');
|
||||
$('#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('<div id="perfixInvalidFeedback" class="invalid-feedback">长度必须在5到32位之间</div>');
|
||||
$('#prefixInput').parent().append('<div id="perfixInvalidFeedback" class="invalid-feedback">长度必须在5到32位之间</div>');
|
||||
$('#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('<div id="perfixInvalidFeedback" class="invalid-feedback">该前缀不被允许</div>');
|
||||
$('#prefixInput').parent().append('<div id="perfixInvalidFeedback" class="invalid-feedback">该前缀不被允许</div>');
|
||||
$('#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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user