Skip to content

Commit bb7eb8f

Browse files
committed
Add Custom Content
支持自定义选择器与提示内容,并完善了部分细节
1 parent 6bb82fd commit bb7eb8f

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

Plugin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @package Pio
66
* @author Dreamer-Paul
7-
* @version 2.1.5
7+
* @version 2.2
88
* @link https://paugram.com
99
*/
1010

@@ -39,7 +39,7 @@ function paul_update($name, $version){
3939

4040
echo "</div>";
4141
}
42-
paul_update("Pio", "2.1.5");
42+
paul_update("Pio", "2.2");
4343

4444
// 读取模型文件夹
4545
$models = array();
@@ -214,7 +214,7 @@ function getLoader(){
214214

215215
$config["model"] = $model;
216216

217-
return '<script>var pio = new Paul_Girl(' . json_encode($config, JSON_UNESCAPED_SLASHES) . ');</script>';
217+
return '<script>var pio = new Paul_Pio(' . json_encode($config, JSON_UNESCAPED_SLASHES) . ');</script>';
218218
}
219219

220220
$canvas = getCanvas();

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Pio
2-
一个支持换模型的 Live2D 插件,供 Typecho 使用
2+
一个支持更换 Live2D 模型的 Typecho 插件
33

4-
本插件不存在任何依赖的样式和库,在后续版本当中我会逐渐实现一些交互功能
4+
本插件不存在任何依赖的样式和库,在后续版本当中我会逐渐实现一些有趣的功能
55

66
## 使用方法
77
1. Star 本项目
@@ -13,7 +13,7 @@
1313
7. 保罗自己搭建了一个模型资源收集站点 - [梦象](https://mx-model.ga),你可以在这里下载到更多的模型,如果你有能力的话欢迎为我提供更多资源~
1414

1515
## 项目故事
16-
详见我的博文:[给你的博客增加动态看板娘](https://paugram.com/coding/add-poster-girl-with-plugin.html)
16+
详见我的博文:[给你的博客增加动态看板娘](https://paugram.com/coding/add-poster-girl-with-plugin.html),帮助文档及常见问题均在这里即时更新。
1717

1818
## 开源协议
1919
由于原项目使用 GPL 2.0 协议,故本项目也采用相同的开源协议进行授权。

static/pio.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
# Pio Plugin
44
# By: Dreamer-Paul
5-
# Last Update: 2018.12.30
5+
# Last Update: 2019.2.1
66
7-
一个支持换模型的 Live2D 插件,供 Typecho 使用
7+
一个支持更换 Live2D 模型的 Typecho 插件
88
99
本代码为奇趣保罗原创,并遵守 MIT 开源协议。欢迎访问我的博客:https://paugram.com
1010
@@ -23,11 +23,12 @@
2323

2424
.pio-container .pio-action{
2525
top: 3em;
26-
right: 0;
2726
opacity: 0;
2827
position: absolute;
2928
transition: opacity .3s;
3029
}
30+
.pio-container.left .pio-action{ right: 0 }
31+
.pio-container.right .pio-action{ left: 0 }
3132
.pio-container:hover .pio-action{ opacity: 1 }
3233

3334
.pio-action span{

static/pio.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
33
# Pio Plugin
44
# By: Dreamer-Paul
5-
# Last Update: 2019.1.2
5+
# Last Update: 2019.2.1
66
7-
一个支持换模型的 Live2D 插件,供 Typecho 使用
7+
一个支持更换 Live2D 模型的 Typecho 插件
88
99
本代码为奇趣保罗原创,并遵守 MIT 开源协议。欢迎访问我的博客:https://paugram.com
1010
1111
---- */
1212

13-
var Paul_Girl = function (prop) {
13+
var Paul_Pio = function (prop) {
1414
var current = {
1515
idol: 0,
1616
menu: document.querySelector(".pio-container .pio-action"),
@@ -79,7 +79,7 @@ var Paul_Girl = function (prop) {
7979
if(document.referrer !== "" && document.referrer.indexOf(current.root) === -1){
8080
var referrer = document.createElement('a');
8181
referrer.href = document.referrer;
82-
prop.content.referer ? modules.render(prop.content.referer.replace(/%t/, "“" + referrer.hostname + "”")) : modules.render("欢迎来自 “" + document.referrer + "” 的朋友!");
82+
prop.content.referer ? modules.render(prop.content.referer.replace(/%t/, "“" + referrer.hostname + "”")) : modules.render("欢迎来自 “" + referrer.hostname + "” 的朋友!");
8383
}
8484
else if(prop.tips){
8585
var text, hour = new Date().getHours();
@@ -194,6 +194,23 @@ var Paul_Girl = function (prop) {
194194
};
195195
current.menu.appendChild(elements.close);
196196
document.cookie = "posterGirl=false;" + "path=/";
197+
},
198+
custom: function () {
199+
for(var i = 0; i < prop.content.custom.length; i++){
200+
var e = document.querySelectorAll(prop.content.custom[i].s);
201+
var c = prop.content.custom[i].t;
202+
203+
if(e[0]){
204+
for(var j = 0; j < e.length; j++){
205+
e[j].onmouseover = function () {
206+
modules.render(c);
207+
}
208+
}
209+
}
210+
else{
211+
console.error("Custom Element Not Found!");
212+
}
213+
}
197214
}
198215
};
199216

@@ -244,6 +261,8 @@ var Paul_Girl = function (prop) {
244261
case "draggable": begin.draggable(); break;
245262
}
246263

264+
if(prop.content.custom) action.custom();
265+
247266
loadlive2d("pio", prop.model[0]);
248267
}
249268
};

0 commit comments

Comments
 (0)