mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-13 07:59:20 +00:00
🚀 Refactor Blade
- Optimize Blade JavaScript code. - Refactored multiple admin controllers for improved validation, error handling, and query efficiency. - Added ProxyConfig trait to centralize proxy configuration options. - Updated NodeStatusDetection to use model relationships for heartbeat checks. - Improved category, label, and country management logic and error logging. - Added new Blade components for admin UI and updated language files and assets for better localization and frontend support. - Bug fixed & introduced more bug :)
This commit is contained in:
@@ -16,30 +16,39 @@ class InviteController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{ // 邀请码列表
|
||||
return view('admin.aff.invite', [
|
||||
'inviteList' => Invite::with(['invitee:id,username', 'inviter:id,username'])->orderBy('status')->orderByDesc('id')->paginate(15)->appends(request('page')),
|
||||
]);
|
||||
return view('admin.aff.invite', ['inviteList' => Invite::with(['invitee:id,username', 'inviter:id,username'])->orderBy('status')->orderByDesc('id')->paginate(15)->appends(request('page'))]);
|
||||
}
|
||||
|
||||
public function generate(): JsonResponse
|
||||
{ // 生成邀请码
|
||||
$invites = [];
|
||||
$expirationDate = date('Y-m-d H:i:s', strtotime(sysConfig('admin_invite_days').' days'));
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$obj = new Invite;
|
||||
$obj->code = strtoupper(substr(md5(microtime().Str::random(6)), 8, 12));
|
||||
$obj->dateline = date('Y-m-d H:i:s', strtotime(sysConfig('admin_invite_days').' days'));
|
||||
$obj->save();
|
||||
$invites[] = [
|
||||
'code' => strtoupper(substr(md5(microtime().Str::random(6)), 8, 12)),
|
||||
'dateline' => $expirationDate,
|
||||
];
|
||||
}
|
||||
|
||||
Invite::insert($invites);
|
||||
|
||||
return response()->json(['status' => 'success', 'message' => trans('common.success_item', ['attribute' => trans('common.generate')])]);
|
||||
}
|
||||
|
||||
public function export(): void
|
||||
{ // 导出邀请码
|
||||
$inviteList = Invite::whereStatus(0)->orderBy('id')->get();
|
||||
$inviteList = Invite::whereStatus(0)->select(['code', 'dateline'])->get();
|
||||
|
||||
$filename = trans('user.invite.attribute').'_'.date('Ymd').'.xlsx';
|
||||
|
||||
$spreadsheet = new Spreadsheet;
|
||||
$spreadsheet->getProperties()->setCreator('ProxyPanel')->setLastModifiedBy('ProxyPanel')->setTitle(trans('user.invite.attribute'))->setSubject(trans('user.invite.attribute'));
|
||||
$spreadsheet->getProperties()
|
||||
->setCreator('ProxyPanel')
|
||||
->setLastModifiedBy('ProxyPanel')
|
||||
->setTitle(trans('user.invite.attribute'))
|
||||
->setSubject(trans('user.invite.attribute'));
|
||||
|
||||
$spreadsheet->setActiveSheetIndex(0);
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
$sheet->setTitle(trans('user.invite.attribute'));
|
||||
@@ -49,10 +58,10 @@ class InviteController extends Controller
|
||||
$sheet->fromArray([$vo->code, $vo->dateline], null, 'A'.($k + 2));
|
||||
}
|
||||
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); // 输出07Excel文件
|
||||
// header('Content-Type:application/vnd.ms-excel'); // 输出Excel03版本文件
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="'.$filename.'"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
try {
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
$writer->save('php://output');
|
||||
|
||||
Reference in New Issue
Block a user