Skip to content

Commit

Permalink
Version1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
{{ouyangyanhuo} committed Jul 15, 2021
1 parent 811d039 commit d5ebf43
Show file tree
Hide file tree
Showing 102 changed files with 24,819 additions and 1,066 deletions.
402 changes: 201 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

236 changes: 236 additions & 0 deletions Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;

/**
* AdminMD是一款基于Material Design设计的typecho后台美化插件
*
* @package AdminMD
* @author Magneto
* @version 1.6
* @link https://www.symbk.cn
*/

class AdminMD_Plugin implements Typecho_Plugin_Interface
{
public static $file_map = [];

/**
* @return array
*/
public static function getFileMap()
{
return self::$file_map;
}

/**
* @param array $file_map
*/
public static function setFileMap($file_map)
{
self::$file_map = $file_map;
}

/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function activate()
{
$plugin_path = dirname(__FILE__);

Typecho_Plugin::factory('admin/header.php')->header_2000 = array('AdminMD_Plugin', 'renderHeader');
Typecho_Plugin::factory('admin/footer.php')->end_2000 = array('AdminMD_Plugin', 'renderFooter');
if(file_exists("var/Widget/Menu.php")){
//挂载menu.php
rename("var/Widget/Menu.php", "var/Widget/Menu.php.bak");
copy("usr/plugins/AdminMD/var/Widget/Menu.php", "var/Widget/Menu.php");
}


$admin_files = self::readdir($plugin_path.'/admin/');
self::setFileMap($admin_files);

foreach ($admin_files as $tmp_file){
$tmp_file_path = "usr/plugins/AdminMD/admin/".$tmp_file;
$target_file_path = "admin/".$tmp_file;
$target_file_bak = "admin/".$tmp_file.".bak";

if(file_exists($target_file_path)){
//挂载
rename($target_file_path, $target_file_bak);
copy($tmp_file_path, $target_file_path);
}
}

}

/**
* 禁用插件方法,如果禁用失败,直接抛出异常
*
* @static
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function deactivate()
{
//还原Menu.php
if(file_exists("var/Widget/Menu.php.bak")){
unlink("var/Widget/Menu.php");
rename("var/Widget/Menu.php.bak", "var/Widget/Menu.php");
}
$plugin_path = dirname(__FILE__);

$admin_files = self::readdir($plugin_path.'/admin/');

foreach ($admin_files as $tmp_file){
$target_file_path = "admin/".$tmp_file;
$target_file_bak = "admin/".$tmp_file.".bak";

if(file_exists($target_file_bak)){
unlink($target_file_path);
rename($target_file_bak, $target_file_path);
}
}
}

/**
* 获取插件配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form 配置面板
* @return void
*/
public static function config(Typecho_Widget_Helper_Form $form)
{

?>
<link rel="stylesheet" href="<?php Helper::options()->pluginUrl(); ?>/AdminMD/assets/css/login.css">
<?php

$url = Helper::options()->pluginUrl . '/AdminMD/';
$zz1 = '<div class="zz">Green</div>';
$zz2 = '<div class="zz">BlueSkyAndMountains</div>';
$zz3 = '<div class="zz">Default</div>';
$bgfengge = new Typecho_Widget_Helper_Form_Element_Radio(
'bgfengge', array(
'Green' => _t('<div class="kuai"><img src="http://p5.qhimg.com/bdm/960_593_0/t01573b4f467fdf51e2.jpg" loading="lazy">' . $zz1 . '</div>'),
'BlueSkyAndMountains' => _t('<div class="kuai"><img src="https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/07/15/0531f7895a5627b8737e0690d7dcb4e5.png" loading="lazy">' . $zz2 . '</div>'),
'Default' => _t('<div class="kuai"><img src="https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/07/15/05b54e433729eb89a067ff992176c442.png" loading="lazy">' . $zz3 . '</div>'),
), 'Green', _t('登陆/注册页面样式'), _t(''));
$bgfengge->setAttribute('id', 'yangshi');
$form->addInput($bgfengge);

$bgUrl = new Typecho_Widget_Helper_Form_Element_Text('bgUrl', NULL, NULL, _t('自定义背景图'), _t('选中上方的基础样式后,可以在这里填写图片地址自定义背景图'));
$form->addInput($bgUrl);

$diycss = new Typecho_Widget_Helper_Form_Element_Textarea('diycss', NULL, NULL, '自定义样式', _t('上边的样式选择【Default】,然后在这里自己写css美化注册/登录页面;<b>注意</b>:该功能与【自定义背景图】功能冲突,使用该功能时如果想设置背景图请写css里面。'));
$form->addInput($diycss);

}

/**
* 个人用户的配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form
* @return void
*/
public static function personalConfig(Typecho_Widget_Helper_Form $form)
{
}

/**
*
* 函数名:readdir($dir)
* 作用:读取目录所有的文件名
* 参数:$dir 目录地址
* 返回值:文件名数组
*
* */
public static function readdir($dir) {
$handle=opendir($dir);
$i=0;
while(!!$file = readdir($handle)) {
if (($file!=".")and($file!="..")) {
$list[$i]=$file;
$i=$i+1;
}
}
closedir($handle);
return $list;
}

/**
* 插件实现方法
*
* @access public
* @return string
*/
public static function renderHeader($hed)
{
$options = Helper::options();

$url = $options->pluginUrl . '/AdminMD/';
list($prefixVersion, $suffixVersion) = explode('/', $options->version);

if (!Typecho_Widget::widget('Widget_User')->hasLogin()) {
$skin = Typecho_Widget::widget('Widget_Options')->plugin('AdminMD')->bgfengge;
$diycss = Typecho_Widget::widget('Widget_Options')->plugin('AdminMD')->diycss;
if ($skin == 'kongbai') {
$hed = $hed . '<style>' . $diycss . '</style>';
} else {
if ($skin == 'heike') {
$hed = $hed . '<link rel="stylesheet" href="' . $url . 'assets/skin/' . $skin . '.css?20210715">';
} else {
$bgUrl = Typecho_Widget::widget('Widget_Options')->plugin('AdminMD')->bgUrl;
$zidingyi = "";
if ($bgUrl) {
$zidingyi = "<style>body{background-image: url(" . $bgUrl . ");}</style>";
}
$hed = $hed . '<link rel="stylesheet" href="' . $url . 'assets/skin/' . $skin . '.css?20210715">' . $zidingyi;
}
}

echo $hed;
}else{
/* 添加 Material Design style */
$hed = $hed . '<link rel="stylesheet" href="' . $url . 'assets/css/style.min.css?v=' . $suffixVersion.'">';
$hed = $hed.'<link rel="stylesheet" href="' . $url . 'assets/vendors/mdi/css/materialdesignicons.min.css?v=' . $suffixVersion.'">';
$hed = $hed.'<link rel="stylesheet" href="' . $url . 'assets/vendors/css/vendor.bundle.base.css?v=' . $suffixVersion.'">';
$hed = $hed.'<script src="' . $url . 'assets/vendors/js/vendor.bundle.base.js?v=' . $suffixVersion.'"></script>';
$hed = $hed.'<script src="' . $url . 'assets/js/off-canvas.js?v=' . $suffixVersion.'"></script>';
$hed = $hed.'<script src="' . $url . 'assets/js/hoverable-collapse.js?v=' . $suffixVersion.'"></script>';
}

return $hed;
}

public static function renderFooter()
{
$options = Helper::options();

$url = $options->pluginUrl . '/AdminMD/';
list($prefixVersion, $suffixVersion) = explode('/', $options->version);
if (!Typecho_Widget::widget('Widget_User')->hasLogin()) {
$url = Helper::options()->pluginUrl . '/AdminMD/';
$skin = Typecho_Widget::widget('Widget_Options')->plugin('AdminMD')->bgfengge;
$ft = '';
if ($skin == 'heike') {
$ft = '<canvas id="canvas"></canvas><script type="text/javascript">window.onload=function(){var canvas=document.getElementById("canvas");var context=canvas.getContext("2d");var W=window.innerWidth;var H=window.innerHeight;canvas.width=W;canvas.height=H;var fontSize=16;var colunms=Math.floor(W/fontSize);var drops=[];for(var i=0;i<colunms;i++){drops.push(0)}var str="111001101000100010010001111001111000100010110001111001001011110110100000";function draw(){context.fillStyle="rgba(0,0,0,0.05)";context.fillRect(0,0,W,H);context.font="700 "+fontSize+"px 微软雅黑";context.fillStyle="#00cc33";for(var i=0;i<colunms;i++){var index=Math.floor(Math.random()*str.length);var x=i*fontSize;var y=drops[i]*fontSize;context.fillText(str[index],x,y);if(y>=canvas.height&&Math.random()>0.99){drops[i]=0}drops[i]++}}function randColor(){var r=Math.floor(Math.random()*256);var g=Math.floor(Math.random()*256);var b=Math.floor(Math.random()*256);return"rgb("+r+","+g+","+b+")"}draw();setInterval(draw,30)};</script>';
}
if ($skin == 'lv') {
$ft = '<ul class="bg-bubbles"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>';
}
echo $ft;
}else{
echo '<script src="' . $url . 'assets/js/misc.js?v=' . $suffixVersion.'"></script>';
}

}


}
57 changes: 39 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,63 @@
# AdminMD

#### 介绍
## 介绍

为Typecho博客程序专门美化的后台,框架主要采用MDUI

#### 更新日志:
## 更新日志:

1.修复部分Bug
1.由覆盖式模板改为插件式后台模板,一定程度上增强了兼容性

2.网站概要页修改
2.新增了自定义后台登录页面一键自定义

3.MDUI核心版本升级为1.0.1
3.修复了部分已知Bug

4.去除非必要部分
4.新增了部分未知Bug(理论上是完美移植为插件版)

#### 编程语言
## 编程语言
PHP

#### 安装教程
## 安装教程

覆盖安装admin目录
导入到Typecho程序 usr/plugins/ 目录中,并解压

切记 一定要备份
解压后文件夹名称必须为AdminMD

#### 使用须知
## 使用须知

1.目前版本,部分内容不会根据网站所配置的内容进行变量
1.当前版本中仍存在部分不影响使用的未知Bug,一旦发现请务必反馈

2.目前版本,无法兼容几乎所有的后台外观增强插件
2.后台登录页面的背景图可以在插件设置中进行更改

3.后台登录页面的背景图需要到login.php里手动更改 在第18行即可看到URL
3.由于 Typecho 程序默认使用的 Gravatar 官方的头像线路已被 GWF 屏蔽,因此会导致使用本主题时使后台完全加载缓慢。

#### 下载渠道
#### 解决 使用须知->3 问题的方法

解决方法

修改 Typecho 程序源代码

需要修改文件地址:网站根目录 ``/var/Typecho/Common.php``第 937 行

修改前:

```
$url = $isSecure ? 'https://secure.gravatar.com' : 'http://www.gravatar.com';
```
修改后:
```
$url = $isSecure ? 'https://sdn.geekzu.org' : 'http://www.gravatar.com';
```

其中 ``https://sdn.geekzu.org`` 可以替换为别的 Gravatar 国内代理地址

## 下载渠道
1.Gitte [https://gitee.com/Magnetokuwan/AdminMD](https://gitee.com/Magnetokuwan/AdminMD) 适合国内(由GitHub同步至此)

2.GitHub [https://github.com/ouyangyanhuo/AdminMD](https://github.com/ouyangyanhuo/AdminMD) 适合国外(主仓库)
#### 使用截图
## 使用截图

![登录](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/01/08/3af177c1328c3d1fc3da5ff26602feee.png "登录")
![后台首页](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/01/08/b20a84a2ee83e7ffc11a0a9647526959.png "后台首页")
![文章撰写](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/01/08/b9d05b9232a840955576d480193d2cbe.png "文章撰写")
![后台首页](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/07/15/748ba291663f8cb917662b703825cb4d.png "后台首页")
![文章撰写](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/07/15/34c412ed6388b9ca1d72d65c89ce1f41.png "文章撰写")
![数据备份](https://cdn.jsdelivr.net/gh/fyhgay/CDNS@latest/2021/07/15/ff54bddcfd504694acaa493d67ee8eda.png "数据备份")
Loading

0 comments on commit d5ebf43

Please sign in to comment.