Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
添加版本检测
Browse files Browse the repository at this point in the history
  • Loading branch information
Adoream committed Jul 16, 2019
1 parent 326294c commit 22fac1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @package LivePhotoKit
* @author Sora Jin
* @version 1.0.0
* @version 1.1.0
* @link https://jcl.moe
*/
class LivePhotoKit_Plugin implements Typecho_Plugin_Interface {
Expand Down Expand Up @@ -53,6 +53,12 @@ public static function deactivate() {
* @return void
*/
public static function config (Typecho_Widget_Helper_Form $form) {
$lversion = json_decode(Bootstrap::fetch (Plugin_Const::GITHUB_REPO_API))->tag_name;
if ($lversion > Plugin_Const::VERSION){
echo '<p style="font-size:18px;">你正在使用 <a>' . Plugin_Const::VERSION . '</a> 版本的 LivePhotoKit,最新版本为 <a style="color:red;">' . $lversion . '</a><a href="https://github.com/MoeLoli/LivePhotoKit-Typecho"><button type="submit" class="btn btn-warn" style="margin-left:10px;">前往更新</button></a></p>';
} else {
echo '<p style="font-size:18px;">你正在使用最新版的 LivePhotoKit!</p>';
}
$mode = new Typecho_Widget_Helper_Form_Element_Radio('mode',
[
'0' => '未开启',
Expand Down
2 changes: 1 addition & 1 deletion lib/Const.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
class Plugin_Const {
const VERSION = '1.0.0';
const VERSION = '1.1.0';

const GITHUB_REPO_API = 'https://api.github.com/repos/MoeLoli/LivephotoKit-Typecho/releases/latest';
}

0 comments on commit 22fac1f

Please sign in to comment.