Skip to content

Commit

Permalink
1.0.3 修复了发布文章不刷新首页的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gogobody committed Jan 25, 2021
1 parent 5c18abe commit 716de64
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
15 changes: 10 additions & 5 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ public static function config(Typecho_Widget_Helper_Form $form)
<?php require_once('Backups.php'); ?>
</div>
</div>
<span id="j-version" style="display: none;">1.0.0</span>
<span id="j-version" style="display: none;">1.0.3</span>
<div class="j-setting-notice">请求数据中...</div>

<script src="<?php echo Helper::options()->rootUrl ?>/usr/plugins/TpCache/assets/js/joe.setting.min.js"></script>
<?

Expand Down Expand Up @@ -370,7 +371,9 @@ public static function post_update($contents, $class)
return;

self::initEnv();
if (!self::preCheck(false)) return;
if (self::$plugin_config->cache_driver == '0')
return;
self::$passed = true;

$type = $contents['type'];
$routeExists = (NULL != Typecho_Router::get($type));
Expand All @@ -388,13 +391,15 @@ public static function post_update($contents, $class)
->where('table.metas.type = ?', 'category')
->order('table.metas.order', Typecho_Db::SORT_ASC));
$contents['category'] = urlencode(current(Typecho_Common::arrayFlatten($contents['categories'], 'slug')));
$contents['slug'] = urlencode($contents['slug']);
$contents['slug'] = urlencode(empty($contents['slug'])?$class->slug:$contents['slug']);
$contents['date'] = new Typecho_Date($contents['created']);
$contents['year'] = $contents['date']->year;
$contents['month'] = $contents['date']->month;
$contents['day'] = $contents['date']->day;

self::initPath(Typecho_Router::url($type, $contents));

if (!self::initPath(Typecho_Router::url($type, $contents))){
throw new Typecho_Exception('初始化失败。url info:'.Typecho_Router::url($type, $contents));
}
self::delCache(self::$path);
// 同时,删除 markdown 的部分缓存
if ($class->cid)
Expand Down
5 changes: 3 additions & 2 deletions assets/js/joe.setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ document.addEventListener("DOMContentLoaded", function () {
}))
})) : (t[0].classList.add("active"), e.style.display = "block", s.style.display = "none");
const a = new XMLHttpRequest;
a.timeout = 2000;
a.onreadystatechange = (() => {
if (4 === a.readyState) if (a.status >= 200 && a.status < 300 || 304 === a.status) {
let t = JSON.parse(a.responseText);
let newest = t.tag_name;
if (newest > n.innerHTML) {
let s = '<h2 class="update">检测到版本更新!</h2><p>当前版本号:' + n.innerHTML + "</p><p>最新版本号:" + newest + "</p>";
let s = '<h2 class="update">检测到版本更新!</h2><p>当前版本号:' + n.innerHTML + "</p><p>最新版本号:" + newest + "</p><p>更新地址:<a href='https://github.com/gogobody/TpCache'>github</a><a href='https://ijkxs.com'>博客</a></p>";
e.innerHTML = s
} else {
let s = '<h2 class="no-update">当前已是最新版本!</h2><p>当前版本号:' + n.innerHTML + "</p><p>最新版本号:" + newest + "</p>";
let s = '<h2 class="no-update">当前已是最新版本!</h2><p>当前版本号:' + n.innerHTML + "</p><p>最新版本号:" + newest + "</p><p>更新地址:<a href='https://github.com/gogobody/TpCache'>github</a><a href='https://ijkxs.com'>博客</a></p>";
e.innerHTML = s
}
} else e.innerHTML = "请求失败!"
Expand Down
9 changes: 5 additions & 4 deletions assets/js/joe.setting.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 716de64

Please sign in to comment.