This commit is contained in:
杜恒 2021-05-21 17:27:27 +08:00
parent 5a56bfdc52
commit 71834710c8
11 changed files with 243 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@ -89,6 +89,7 @@
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 15px;
margin-bottom: 15px;
&-item {
background: var(--background);
box-shadow: var(--box-shadow);
@ -119,4 +120,129 @@
}
}
}
&__filing {
background: var(--background);
box-shadow: var(--box-shadow);
border-radius: var(--radius-wrap);
.title {
display: flex;
align-items: center;
height: 45px;
padding: 0 12px;
border-bottom: 1px solid var(--classC);
color: var(--main);
justify-content: space-between;
user-select: none;
}
.content {
padding: 15px;
.item {
position: relative;
&:last-child {
.wrapper {
padding-bottom: 0;
}
}
.head {
position: absolute;
top: 14px;
width: 13px;
height: 13px;
background: var(--classC);
border-radius: 50%;
}
.tail {
position: absolute;
left: 6px;
top: 0;
width: 1px;
height: 100%;
background: var(--classC);
}
.wrapper {
padding-left: 30px;
padding-bottom: 15px;
.panel {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
color: var(--routine);
cursor: pointer;
background: var(--classD);
padding: 10px;
height: 40px;
border-radius: 4px;
svg {
width: 10px;
height: 10px;
fill: var(--minor);
transform: rotate(180deg);
transition: transform 0.25s;
}
&.in {
svg {
transform: rotate(90deg);
}
}
&::before {
content: '';
position: absolute;
top: 50%;
transform: translateY(-50%);
left: -8px;
width: 0;
height: 0;
border-right: 8px solid var(--classD);
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
}
}
.panel-body {
display: none;
padding-left: 20px;
li {
margin-top: 20px;
a {
color: var(--routine);
&:hover {
color: var(--theme);
}
}
}
}
}
&.load {
padding-top: 15px;
.head {
top: 25px;
background: #2db7f5;
}
.button {
position: relative;
margin-left: 30px;
border: none;
background: #2db7f5;
color: #fff;
border-radius: 4px;
padding: 0 12px;
height: 34px;
font-size: 13px;
&::before {
content: '';
position: absolute;
top: 50%;
transform: translateY(-50%);
left: -8px;
width: 0;
height: 0;
border-right: 8px solid #2db7f5;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
}
}
}
}
}
}
}

View File

@ -2,22 +2,20 @@ document.addEventListener('DOMContentLoaded', () => {
{
/* 转换字节 */
const bytesToSize = bytes => {
if (!bytes) return '0 B';
const k = 1024,
sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
};
const categories = [];
const upSeries = [];
const downSeries = [];
const flowDom = document.querySelector('#flow');
const workDom = document.querySelector('#work');
const flowChart = flowDom && echarts.init(flowDom);
const workChart = workDom && echarts.init(workDom);
if (flowDom && workDom) initChart();
function initChart() {
$.ajax({
url: Joe.BASE_API,
@ -27,6 +25,7 @@ document.addEventListener('DOMContentLoaded', () => {
routeType: 'server_status'
},
success(res) {
if (!res.status) Qmsg.warning('服务器接口异常!');
{
$('.joe_census__server-item .count .up').html(`总发送:${bytesToSize(res.upTotal)}`);
$('.joe_census__server-item .count .down').html(`总接收:${bytesToSize(res.downTotal)}`);
@ -48,7 +47,7 @@ document.addEventListener('DOMContentLoaded', () => {
grid: {
left: '3%',
right: '4%',
bottom: '0',
bottom: '3%',
containLabel: true
},
tooltip: {
@ -250,6 +249,9 @@ document.addEventListener('DOMContentLoaded', () => {
},
success(res) {
latelyChart.setOption({
title: {
subtext: '单位 数量'
},
tooltip: {
trigger: 'axis',
axisPointer: {
@ -294,4 +296,55 @@ document.addEventListener('DOMContentLoaded', () => {
}
});
}
/* 初始化归档 */
{
let page = 0;
initFiling();
function initFiling() {
if ($('.joe_census__filing .button').html() === 'loading...') return;
$.ajax({
url: Joe.BASE_API,
type: 'POST',
dataType: 'json',
data: {
routeType: 'article_filing',
page: ++page
},
success(res) {
if (!res.length) {
$('.joe_census__filing .item.load').remove();
return Qmsg.warning('没有更多内容了');
}
let htmlStr = '';
res.forEach(item => {
htmlStr += `
<div class="item">
<div class="tail"></div>
<div class="head"></div>
<div class="wrapper">
<div class="panel">${item.date}<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M21.6 772.8c28.8 28.8 74.4 28.8 103.2 0L512 385.6l387.2 387.2c28.8 28.8 74.4 28.8 103.2 0 28.8-28.8 28.8-74.4 0-103.2L615.2 282.4l-77.6-77.6c-14.4-14.4-37.6-14.4-51.2 0l-77.6 77.6L21.6 669.6c-28.8 28.8-28.8 75.2 0 103.2z" /></svg></div>
<ol class="panel-body">
${item.list.map(_ => `<li><a rel="noopener noreferrer" target="_blank" href="${_.permalink}">${_.title}</a></li>`).join('')}
</ol>
</div>
</div>
`;
});
$('#filing').append(htmlStr);
$('.joe_census__filing .button').html('加载更多');
}
});
}
$('.joe_census__filing .content').on('click', '.panel', function () {
const panelBox = $(this).parents('.content');
panelBox.find('.panel').not($(this)).removeClass('in');
panelBox.find('.panel-body').not($(this).siblings('.panel-body')).stop().hide('fast');
$(this).toggleClass('in').siblings('.panel-body').stop().toggle('fast');
});
$('.joe_census__filing .button').on('click', function () {
initFiling();
$(this).html('loading...');
});
}
});

File diff suppressed because one or more lines are too long

View File

@ -14,9 +14,9 @@
<head>
<?php $this->need('public/include.php'); ?>
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.census.min.css?v=20210521'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.census.min.css?v=202105211730'); ?>">
<script src="https://cdn.jsdelivr.net/npm/echarts@5.1.1/dist/echarts.min.js"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.census.min.js?v=20210521'); ?>"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.census.min.js?v=202105211730'); ?>"></script>
</head>
<body>
@ -106,6 +106,17 @@
</div>
</div>
<?php endif; ?>
<div class="joe_census__filing">
<div class="title">文章归档</div>
<div class="content">
<div id="filing"></div>
<div class="item load">
<div class="tail"></div>
<div class="head"></div>
<button class="button">加载更多</button>
</div>
</div>
</div>
</div>
</div>
<?php $this->need('public/footer.php'); ?>

View File

@ -2,7 +2,7 @@
/* 获取主题当前版本号 */
function _getVersion()
{
return "7.0.7";
return "7.0.8";
};
/* 判断是否是手机 */

View File

@ -294,6 +294,7 @@ function _getHuyaList($self)
}
}
/* 获取服务器状态 */
function _getServerStatus($self)
{
header("HTTP/1.1 200 OK");
@ -325,6 +326,8 @@ function _getServerStatus($self)
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
$self->response->throwJson(array(
/* 状态 */
"status" => $response ? true : false,
/* 上行流量KB */
"up" => $response["up"] ? $response["up"] : 0,
/* 下行流量KB */
@ -342,6 +345,7 @@ function _getServerStatus($self)
));
}
/* 获取最近评论 */
function _getCommentLately($self)
{
header("HTTP/1.1 200 OK");
@ -368,5 +372,37 @@ function _getCommentLately($self)
function _getArticleFiling($self)
{
header("HTTP/1.1 200 OK");
header('Access-Control-Allow-Origin:*');
header("Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept");
$page = $self->request->page;
$pageSize = 8;
if (!preg_match('/^\d+$/', $page)) return $self->response->throwJson(array("data" => "非法请求!已屏蔽!"));
if ($page == 0) $page = 1;
$offset = $pageSize * ($page - 1);
$time = time();
$db = Typecho_Db::get();
$prefix = $db->getPrefix();
$result = [];
$sql = "SELECT FROM_UNIXTIME(created, '%Y 年 %m 月') as date FROM `{$prefix}contents` WHERE created < {$time} AND (password is NULL or password = '') AND status = 'publish' AND type = 'post' GROUP BY FROM_UNIXTIME(created, '%Y 年 %m 月') DESC LIMIT {$pageSize} OFFSET {$offset}";
$temp = $db->fetchAll($sql);
$options = Typecho_Widget::widget('Widget_Options');
foreach ($temp as $item) {
$date = $item['date'];
$list = [];
$sql = "SELECT * FROM `{$prefix}contents` WHERE created < {$time} AND (password is NULL or password = '') AND status = 'publish' AND type = 'post' AND FROM_UNIXTIME(created, '%Y 年 %m 月') = '{$date}' ORDER BY created DESC";
$_list = $db->fetchAll($sql);
foreach ($_list as $_item) {
$type = $_item['type'];
$routeExists = (NULL != Typecho_Router::get($type));
$_item['pathinfo'] = $routeExists ? Typecho_Router::url($type, $_item) : '#';
$_item['permalink'] = Typecho_Common::url($_item['pathinfo'], $options->index);
$list[] = array(
"title" => date('m/d', $_item['created']) . '' . $_item['title'],
"permalink" => $_item['permalink'],
);
}
$result[] = array("date" => $date, "list" => $list);
}
$self->response->throwJson($result);
}

View File

@ -56,4 +56,4 @@ class Widget_Contents_Post extends Widget_Abstract_Contents
array($this, 'push')
);
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "typecho-joe-next",
"version": "7.0.7",
"version": "7.0.8",
"description": "A Theme Of Typecho",
"main": "index.php",
"keywords": [

View File

@ -199,15 +199,15 @@
</div>
<nav class="joe_dropdown__menu">
<?php if ($this->user->group == 'administrator' || $this->user->group == 'editor' || $this->user->group == 'contributor') : ?>
<a rel="noopener noreferrer nofollow" target="_balnk" href="<?php $this->options->adminUrl("manage-posts.php"); ?>">管理文章</a>
<a rel="noopener noreferrer nofollow" target="_blank" href="<?php $this->options->adminUrl("manage-posts.php"); ?>">管理文章</a>
<?php endif; ?>
<?php if ($this->user->group == 'administrator' || $this->user->group == 'editor') : ?>
<a rel="noopener noreferrer nofollow" target="_balnk" href="<?php $this->options->adminUrl("manage-comments.php"); ?>">管理评论</a>
<a rel="noopener noreferrer nofollow" target="_blank" href="<?php $this->options->adminUrl("manage-comments.php"); ?>">管理评论</a>
<?php endif; ?>
<?php if ($this->user->group == 'administrator') : ?>
<a rel="noopener noreferrer nofollow" target="_balnk" href="<?php $this->options->adminUrl("options-theme.php"); ?>">修改外观</a>
<a rel="noopener noreferrer nofollow" target="_blank" href="<?php $this->options->adminUrl("options-theme.php"); ?>">修改外观</a>
<?php endif; ?>
<a rel="noopener noreferrer nofollow" target="_balnk" href="<?php $this->options->adminUrl(); ?>">进入后台</a>
<a rel="noopener noreferrer nofollow" target="_blank" href="<?php $this->options->adminUrl(); ?>">进入后台</a>
<a rel="noopener noreferrer nofollow" href="<?php $this->options->logoutUrl(); ?>">退出登录</a>
</nav>
</div>

View File

@ -19,7 +19,7 @@
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.mode.min.css'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.normalize.min.css'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.global.min.css'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.responsive.min.css?v=20210521'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.responsive.min.css?v=202105211730'); ?>">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.0.0/plugin/qmsg/qmsg.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.7.2/animate.min.css" />