Skip to content

Commit

Permalink
Merge pull request #244 from 4x99/develop
Browse files Browse the repository at this point in the history
v1.6.3
  • Loading branch information
yoonper authored Jan 12, 2023
2 parents 179d051 + 1b9f5fd commit 7319940
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/JobRunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private function createGitHubService()
*/
private function takeJob()
{
if (!$job = QueueJob::orderBy('created_at')->first()) {
if (!$job = QueueJob::orderBy('id')->first()) {
return false;
}
return $job;
Expand Down
8 changes: 3 additions & 5 deletions app/Http/Controllers/ConfigJobController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Models\ConfigJob;
use App\Models\QueueJob;
use Cron\CronExpression;
use Illuminate\Http\Request;

class ConfigJobController extends Controller
Expand Down Expand Up @@ -119,7 +118,7 @@ public function batchDestroy(Request $request)
*/
public function queue()
{
$data = QueueJob::orderBy('created_at')->get();
$data = QueueJob::orderBy('id')->get()->toArray();
foreach ($data as $k => $v) {
$data[$k]['status'] = $k == 0 ? 1 : 0;
}
Expand All @@ -134,8 +133,7 @@ public function queue()
*/
private function getNextScanAt($interval)
{
$expression = "*/$interval * * * *";
$cron = CronExpression::factory($expression);
return $cron->getNextRunDate()->format('Y-m-d H:i:s');
$nextScanAt = floor(LARAVEL_START - LARAVEL_START % ($interval * 60) + ($interval * 60));
return date('Y-m-d H:i:s', $nextScanAt);
}
}
8 changes: 7 additions & 1 deletion app/Http/Controllers/MobileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

namespace App\Http\Controllers;

use App\Models\CodeLeak;
use Illuminate\Support\Facades\Request;

class MobileController extends Controller
{
public function home()
{
$data = ['title' => '码小六'];
$page = Request::query('page', 1);
$tab = Request::query('tab', 'all');
$count = CodeLeak::query()->count();
$data = ['title' => '码小六', 'page' => $page, 'tab' => $tab, 'count' => $count];
return view('mobile.home', $data);
}

Expand Down
49 changes: 34 additions & 15 deletions doctor.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ function console($item, $result, $err = '')

// MySQL 连接
try {
$err = '';
$dberr = '';
$dsn = "mysql:host={$env['DB_HOST']}:{$env['DB_PORT']};dbname={$env['DB_DATABASE']}";
$db = new PDO($dsn, $env['DB_USERNAME'], $env['DB_PASSWORD'], [PDO::ATTR_TIMEOUT => 3]);
} catch (Exception $e) {
$err = $e->getMessage();
$dberr = $e->getMessage();
}
console('MySQL 连接', $err ? '失败' : '成功', $err);
console('MySQL 连接', $dberr ? '失败' : '成功', $dberr);

// MySQL 数据表
try {
if ($err) {
throw new Exception($err);
if ($dberr) {
throw new Exception($dberr);
}
$err = '';
$err = false;
$tables = $db->query("show tables like 'code_leak'")->fetchAll(PDO::FETCH_ASSOC)[0];
if (!count($tables)) {
throw new Exception('请执行 php artisan migrate 导入数据表');
Expand All @@ -62,7 +62,34 @@ function console($item, $result, $err = '')
}
console('MySQL 数据表', $err ? '未导入' : '已导入', $err);

echo DIVIDER."[ 其他信息 ]\n";
// GitHub API
try {
$apierr = false;
$url = 'https://api.github.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_USERAGENT, 'code6');
$result = json_decode(curl_exec($ch), true);
if (empty($result)) {
throw new Exception("请求 $url 错误");
}
curl_close($ch);
} catch (Exception $e) {
$apierr = $e->getMessage();
}
console('GitHub API', $apierr ? '请求错误' : '请求成功', $apierr);

// PHP 禁用函数
$disFuns = get_cfg_var('disable_functions') ?: '';
echo "PHP 禁用函数:$disFuns\n";

// PHP 已编译模块
$exts = implode(',', get_loaded_extensions());
echo "PHP 已编译模块:$exts\n";

echo DIVIDER."[ 系统信息 ]\n";

// 码小六版本
$version = trim(file_get_contents(ROOT.'/version'));
Expand All @@ -76,12 +103,4 @@ function console($item, $result, $err = '')
$appDebug = $env['APP_DEBUG'] ?? '';
echo "框架调试开关:$appDebug\n";

// PHP 禁用函数
$disFuns = get_cfg_var('disable_functions') ?: '';
echo "PHP 禁用函数:$disFuns\n";

// PHP 已编译模块
$exts = implode(',', get_loaded_extensions());
echo "PHP 已编译模块:$exts\n";

echo DIVIDER."\n有任何问题和建议请联系-> https://github.com/4x99/code6/issues\n\n";
19 changes: 15 additions & 4 deletions resources/views/mobile/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
data: {
loading: true,
page: {
count: 0,
current: 1,
count: {{ $count }},
current: {{ $page }},
},
action: {
show: false,
Expand All @@ -100,7 +100,7 @@
selection: [],
},
tab: {
current: 'all',
current: '{{ $tab }}',
}
},
methods: {
Expand All @@ -117,6 +117,8 @@
me.page.count = rsp.data.last_page ? rsp.data.last_page : 0;
me.list.data = rsp.data.data;
me.loading = false;
var data = {page: me.page, data: me.list.data, tab: me.tab};
history.pushState(data, '', '/mobile?page=' + page + '&tab=' + me.tab.current);
}).catch(function (rsp) {
me.$toast.fail(rsp.message);
me.loading = false;
Expand Down Expand Up @@ -168,7 +170,16 @@
},
},
mounted: function () {
this.load(1);
var me = this;
me.load(me.page.current);
window.addEventListener('popstate', function (e) {
if (e.state && e.state.data) {
me.page = e.state.page;
me.list.data = e.state.data;
me.tab = e.state.tab;
me.loading = false;
}
})
}
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.2
1.6.3

0 comments on commit 7319940

Please sign in to comment.