1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-29 05:41:37 +08:00

版本发布信息改用ajax异步获取

This commit is contained in:
koogua 2021-02-26 15:06:38 +08:00
parent ab3e04c8a2
commit 55401cf451
6 changed files with 51 additions and 16 deletions

View File

@ -39,12 +39,23 @@ class IndexController extends Controller
$todayStat = $indexService->getTodayStat(); $todayStat = $indexService->getTodayStat();
$appInfo = $indexService->getAppInfo(); $appInfo = $indexService->getAppInfo();
$serverInfo = $indexService->getServerInfo(); $serverInfo = $indexService->getServerInfo();
$releases = $indexService->getReleases();
$this->view->setVar('global_stat', $globalStat); $this->view->setVar('global_stat', $globalStat);
$this->view->setVar('today_stat', $todayStat); $this->view->setVar('today_stat', $todayStat);
$this->view->setVar('app_info', $appInfo); $this->view->setVar('app_info', $appInfo);
$this->view->setVar('server_info', $serverInfo); $this->view->setVar('server_info', $serverInfo);
}
/**
* @Get("/releases", name="admin.releases")
*/
public function releasesAction()
{
$indexService = new IndexService();
$releases = $indexService->getReleases();
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->setVar('releases', $releases); $this->view->setVar('releases', $releases);
} }

View File

@ -59,7 +59,7 @@ class Index extends Service
$client = new Client(); $client = new Client();
$response = $client->get($url, ['timeout' => 3]); $response = $client->get($url);
$content = json_decode($response->getBody(), true); $content = json_decode($response->getBody(), true);

View File

@ -29,3 +29,21 @@
</style> </style>
{% endblock %} {% endblock %}
{% block inline_js %}
<script>
layui.use(['jquery', 'layer', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $appTrend = $('#app-trend');
helper.ajaxLoadHtml($appTrend.data('url'), $appTrend.attr('id'));
});
</script>
{% endblock %}

View File

@ -1,19 +1,6 @@
<div class="layui-card layui-text"> <div class="layui-card layui-text">
<div class="layui-card-header">产品动态</div> <div class="layui-card-header">产品动态</div>
<div class="layui-card-body"> <div class="layui-card-body">
<table class="layui-table"> <div id="app-trend" data-url="{{ url({'for':'admin.releases'}) }}"></div>
<colgroup>
<col width="80%">
<col>
</colgroup>
<tbody>
{% for release in releases %}
<tr>
<td><a href="{{ release.url }}" target="_blank">{{ release.title }}</a></td>
<td>{{ release.date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div> </div>
</div> </div>

View File

@ -0,0 +1,14 @@
<table class="layui-table">
<colgroup>
<col width="80%">
<col>
</colgroup>
<tbody>
{% for release in releases %}
<tr>
<td><a href="{{ release.url }}" target="_blank">{{ release.title }}</a></td>
<td>{{ release.date }}</td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@ -34,6 +34,11 @@
list-style: decimal; list-style: decimal;
} }
.loading {
padding: 30px;
text-align: center;
}
.kg-layer-content { .kg-layer-content {
padding: 15px; padding: 15px;
} }