44 *
55 * @package Pio
66 * @author Dreamer-Paul
7- * @version 1.2
7+ * @version 1.3
88 * @link https://paugram.com
99 */
1010
1111class Pio_Plugin implements Typecho_Plugin_Interface{
1212
1313 /* 激活插件方法 */
1414 public static function activate (){
15- Typecho_Plugin::factory ('Widget_Archive ' )-> header = array ('Pio_Plugin ' , 'header ' );
16- Typecho_Plugin::factory ('Widget_Archive ' )-> footer = array ('Pio_Plugin ' , 'footer ' );
15+ Typecho_Plugin::factory ('Widget_Archive ' ) -> header = array ('Pio_Plugin ' , 'header ' );
16+ Typecho_Plugin::factory ('Widget_Archive ' ) -> footer = array ('Pio_Plugin ' , 'footer ' );
1717 }
1818
1919 /* 禁用插件方法 */
@@ -39,7 +39,7 @@ function paul_update($name, $version){
3939
4040 echo "</div> " ;
4141 }
42- paul_update ("Pio " , "1.2 " );
42+ paul_update ("Pio " , "1.3 " );
4343
4444 // 读取模型文件夹
4545 $ models = array ();
@@ -52,30 +52,40 @@ function paul_update($name, $version){
5252
5353 // 自定义模型选择
5454 $ choose_models = new Typecho_Widget_Helper_Form_Element_Select ('choose_models ' , $ models , 'pio ' , _t ('选择模型 ' ), _t ('选择插件 Models 目录下的模型,每个模型为一个文件夹,并确定配置文件名为 <a>model.json</a> ' ));
55- $ form ->addInput ($ choose_models );
55+ $ form -> addInput ($ choose_models );
56+
57+ // 自定义定位
58+ $ position = new Typecho_Widget_Helper_Form_Element_Radio ('position ' ,
59+ array (
60+ 'left ' => _t ('靠左 ' ),
61+ 'right ' => _t ('靠右 ' ),
62+ ),
63+ 'left ' , _t ('自定义位置 ' ), _t ('自定义看板娘所在的位置 ' ));
64+ $ form -> addInput ($ position );
5665
5766 // 自定义宽高
5867 $ custom_width = new Typecho_Widget_Helper_Form_Element_Text ('custom_width ' , NULL , NULL , _t ('自定义宽度 ' ), _t ('在这里填入自定义宽度,部分模型需要修改 ' ));
59- $ form-> addInput ($ custom_width );
68+ $ form -> addInput ($ custom_width );
6069
6170 $ custom_height = new Typecho_Widget_Helper_Form_Element_Text ('custom_height ' , NULL , NULL , _t ('自定义高度 ' ), _t ('在这里填入自定义高度,部分模型需要修改 ' ));
62- $ form-> addInput ($ custom_height );
71+ $ form -> addInput ($ custom_height );
6372
6473 // 自定义模型
6574 $ custom_model = new Typecho_Widget_Helper_Form_Element_Text ('custom_model ' , NULL , NULL , _t ('自定义配置文件地址 ' ), _t ('在这里填入一个模型 JSON 配置文件地址,可供使用外链模型,不填则使用插件目录下的模型 ' ));
66- $ form-> addInput ($ custom_model );
75+ $ form -> addInput ($ custom_model );
6776 }
6877
6978 /* 个人用户的配置方法 */
7079 public static function personalConfig (Typecho_Widget_Helper_Form $ form ){}
7180
7281 /* 插件实现方法 */
7382 public static function header (){
74- echo "<style>#pio{ left: 0; bottom: 0; z-index: 520; position: fixed; pointer-events: none; } @media screen and (max-width: 768px){ #pio{ width: 8em; } }</style> " ;
83+ $ pos = Typecho_Widget::widget ('Widget_Options ' ) -> Plugin ('Pio ' ) -> position ;
84+ echo "<style>#pio{ $ pos: 0; bottom: 0; z-index: 520; position: fixed; pointer-events: none; } @media screen and (max-width: 768px){ #pio{ width: 8em; } }</style> " ;
7585 }
7686 public static function footer (){
77- $ height = Typecho_Widget::widget ('Widget_Options ' )-> Plugin ('Pio ' )-> custom_height ;
78- $ width = Typecho_Widget::widget ('Widget_Options ' )-> Plugin ('Pio ' )-> custom_width ;
87+ $ height = Typecho_Widget::widget ('Widget_Options ' ) -> Plugin ('Pio ' ) -> custom_height ;
88+ $ width = Typecho_Widget::widget ('Widget_Options ' ) -> Plugin ('Pio ' ) -> custom_width ;
7989
8090 if ($ height && $ width ){
8191 echo "<canvas id='pio' width=' " .$ width ."' height=' " .$ height ."'></canvas> " ;
@@ -90,16 +100,16 @@ public static function footer(){
90100 echo "<canvas id='pio' width='280' height='250'></canvas> " ;
91101 }
92102
93- echo "<script src=' " . Helper::options ()-> pluginUrl . "/Pio/l2d.js'></script> " . "\n" ;
103+ echo "<script src=' " . Helper::options () -> pluginUrl . "/Pio/l2d.js'></script> " . "\n" ;
94104
95- if (Typecho_Widget::widget ('Widget_Options ' )-> Plugin ('Pio ' )-> custom_model ){
96- echo "<script>loadlive2d('pio', ' " . Typecho_Widget::widget ('Widget_Options ' )-> Plugin ('Pio ' )-> custom_model . "');</script> " . "\n" ;
105+ if (Typecho_Widget::widget ('Widget_Options ' ) -> Plugin ('Pio ' ) -> custom_model ){
106+ echo "<script>loadlive2d('pio', ' " . Typecho_Widget::widget ('Widget_Options ' ) -> Plugin ('Pio ' ) -> custom_model . "');</script> " . "\n" ;
97107 }
98- else if (Typecho_Widget::widget ('Widget_Options ' )-> Plugin ('Pio ' )-> choose_models ){
99- echo "<script>loadlive2d('pio', ' " . Helper::options ()-> pluginUrl . "/Pio/models/ " . Typecho_Widget::widget ('Widget_Options ' )-> Plugin ('Pio ' )-> choose_models . "/model.json');</script> " . "\n" ;
108+ else if (Typecho_Widget::widget ('Widget_Options ' ) -> Plugin ('Pio ' ) -> choose_models ){
109+ echo "<script>loadlive2d('pio', ' " . Helper::options () -> pluginUrl . "/Pio/models/ " . Typecho_Widget::widget ('Widget_Options ' ) -> Plugin ('Pio ' ) -> choose_models . "/model.json');</script> " . "\n" ;
100110 }
101111 else {
102- echo "<script>loadlive2d('pio', ' " . Helper::options ()-> pluginUrl . "/Pio/models/pio/model.json');</script> " . "\n" ;
112+ echo "<script>loadlive2d('pio', ' " . Helper::options () -> pluginUrl . "/Pio/models/pio/model.json');</script> " . "\n" ;
103113 }
104114 }
105115}
0 commit comments