mirror of
https://github.com/Dreamer-Paul/Pio.git
synced 2025-04-22 19:22:36 +08:00
Fix Bugs
修复了在未添加自定义提示内容下,点击“信息”按钮后打开页面异常的问题,以及在添加了多条自定内容选择器的情况下内容显示错误的问题
This commit is contained in:
parent
0b34099e34
commit
924ade6167
67
Plugin.php
67
Plugin.php
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @package Pio
|
||||
* @author Dreamer-Paul
|
||||
* @version 2.2
|
||||
* @version 2.3
|
||||
* @link https://paugram.com
|
||||
*/
|
||||
|
||||
@ -39,7 +39,7 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
|
||||
echo "</div>";
|
||||
}
|
||||
paul_update("Pio", "2.2");
|
||||
paul_update("Pio", "2.3");
|
||||
|
||||
// 读取模型文件夹
|
||||
$models = array();
|
||||
@ -50,10 +50,14 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
$models[$single] = ucfirst($single);
|
||||
};
|
||||
|
||||
// 自定义模型选择
|
||||
// 选择模型
|
||||
$choose_models = new Typecho_Widget_Helper_Form_Element_Checkbox('choose_models', $models, 'pio', _t('选择模型'), _t('选择插件 Models 目录下的模型,每个模型为一个文件夹,并确定配置文件名为 <a>model.json</a>'));
|
||||
$form -> addInput($choose_models);
|
||||
|
||||
// 选择外链模型
|
||||
$custom_model = new Typecho_Widget_Helper_Form_Element_Text('custom_model', NULL, NULL, _t('选择外链模型'), _t('在这里填入一个模型配置文件 <a>model.json</a> 的地址,可供使用外链模型,不填则使用插件目录下的模型'));
|
||||
$form -> addInput($custom_model);
|
||||
|
||||
// 自定义定位
|
||||
$position = new Typecho_Widget_Helper_Form_Element_Radio('position',
|
||||
array(
|
||||
@ -70,10 +74,6 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
$custom_height = new Typecho_Widget_Helper_Form_Element_Text('custom_height', NULL, NULL, _t('自定义高度'), _t('在这里填入自定义高度,部分模型需要修改'));
|
||||
$form -> addInput($custom_height);
|
||||
|
||||
// 自定义模型
|
||||
$custom_model = new Typecho_Widget_Helper_Form_Element_Text('custom_model', NULL, NULL, _t('自定义配置文件地址'), _t('在这里填入一个模型 JSON 配置文件地址,可供使用外链模型,不填则使用插件目录下的模型'));
|
||||
$form -> addInput($custom_model);
|
||||
|
||||
// 夜间模式函数
|
||||
$night = new Typecho_Widget_Helper_Form_Element_Text('night', NULL, NULL, _t('夜间模式函数'), _t('如果你的主题支持夜间模式,请在这里填写主题对应的 JS 函数'));
|
||||
$form -> addInput($night);
|
||||
@ -107,11 +107,11 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
$form -> addInput($tips);
|
||||
|
||||
// 自定义文字配置
|
||||
$dialog = new Typecho_Widget_Helper_Form_Element_Textarea('dialog', NULL, NULL, _t('自定义提示内容'), _t('在这里填入你的自定义看板娘提示内容,如想保持默认,需要填写 "{}" 否则会导致插件无法运行'));
|
||||
$dialog = new Typecho_Widget_Helper_Form_Element_Textarea('dialog', NULL, NULL, _t('自定义提示内容'), _t('在这里填入你的自定义看板娘提示内容,如想保持默认,请留空'));
|
||||
$form -> addInput($dialog);
|
||||
|
||||
// 自定义选择器配置
|
||||
$selector = new Typecho_Widget_Helper_Form_Element_Textarea('selector', NULL, NULL, _t('自定义内容选择器'), _t('在这里填入部分功能所用到的自定义选择器,如不想启用此类功能,需要填写 "{}" 否则会导致插件无法运行'));
|
||||
$selector = new Typecho_Widget_Helper_Form_Element_Textarea('selector', NULL, NULL, _t('自定义内容选择器'), _t('在这里填入部分功能所用到的自定义选择器,如不想启用此类功能,请留空'));
|
||||
$form -> addInput($selector);
|
||||
}
|
||||
|
||||
@ -131,49 +131,6 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
return '<canvas id="pio" width="' . (!$width ? 280 : $width) . '" height="' . (!$height ? 250: $height) . '"></canvas>';
|
||||
}
|
||||
|
||||
// 生成配置
|
||||
function getConfig(){
|
||||
$plugin = Typecho_Widget::widget('Widget_Options') -> Plugin('Pio');
|
||||
|
||||
$mode = $plugin -> custom_mode;
|
||||
$hidden = $plugin -> hidden == 1 ? true : false;
|
||||
$tips = $plugin -> tips == 1 ? true : false;
|
||||
$content = $plugin -> dialog ? json_decode($plugin -> dialog, true) : "{}";
|
||||
$selector = $plugin -> selector ? json_decode($plugin -> selector, true) : "{}";
|
||||
|
||||
if($plugin -> custom_model){
|
||||
$model = array($plugin -> custom_model);
|
||||
}
|
||||
else if($plugin -> choose_models){
|
||||
$model = $plugin -> choose_models;
|
||||
|
||||
if(is_array($model)){
|
||||
foreach($model as &$item){
|
||||
$item = Helper::options() -> pluginUrl . "/Pio/models/" . $item . "/model.json";
|
||||
}
|
||||
}
|
||||
else{
|
||||
$model = array(Helper::options() -> pluginUrl . "/Pio/models/" . $model . "/model.json");
|
||||
}
|
||||
}
|
||||
else{
|
||||
$model = array(Helper::options() -> pluginUrl . "/Pio/models/pio/model.json");
|
||||
}
|
||||
|
||||
if($plugin -> night){
|
||||
$night = $plugin -> night;
|
||||
}
|
||||
else{
|
||||
$night = false;
|
||||
}
|
||||
|
||||
return str_replace(
|
||||
array("{mode}", "{hidden}", "{content}", "{selector}", "{model}", "{night}"),
|
||||
array("mode:'" . $mode . "'", "hidden:" . $hidden, "content:" . $content, "selector:" . $selector, "model:" . $model, "night:" . $night),
|
||||
"{mode},{hidden},{content},{selector},{model},{night}"
|
||||
);
|
||||
}
|
||||
|
||||
// 生成载入器
|
||||
function getLoader(){
|
||||
$plugin = Typecho_Widget::widget('Widget_Options') -> Plugin('Pio');
|
||||
@ -181,8 +138,8 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
$config = array(
|
||||
"mode" => $plugin -> custom_mode,
|
||||
"hidden" => $plugin -> hidden == 1 ? true : false,
|
||||
"content" => $plugin -> dialog ? json_decode($plugin -> dialog, true) : "{}",
|
||||
"selector" => $plugin -> selector ? json_decode($plugin -> selector, true) : "{}"
|
||||
"content" => $plugin -> dialog ? json_decode($plugin -> dialog, true) : array(),
|
||||
"selector" => $plugin -> selector ? json_decode($plugin -> selector, true) : array()
|
||||
);
|
||||
|
||||
if($plugin -> custom_model){
|
||||
@ -214,7 +171,7 @@ class Pio_Plugin implements Typecho_Plugin_Interface{
|
||||
|
||||
$config["model"] = $model;
|
||||
|
||||
return '<script>var pio = new Paul_Pio(' . json_encode($config, JSON_UNESCAPED_SLASHES) . ');</script>';
|
||||
return '<script>var pio = new Paul_Pio(' . json_encode($config, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . ');</script>';
|
||||
}
|
||||
|
||||
$canvas = getCanvas();
|
||||
|
20
README.md
20
README.md
@ -1,29 +1,37 @@
|
||||
# Pio
|
||||
|
||||
一个支持更换 Live2D 模型的 Typecho 插件。
|
||||
|
||||
本插件不存在任何依赖的样式和库,在后续版本当中我会逐渐实现一些有趣的功能。
|
||||
|
||||
## 使用方法
|
||||
|
||||
> 奇趣保罗自己搭建的 [梦象](https://mx-model.ga) 资源站上提供了较多可用于本插件的模型资源,如果你也想在这里提交自己的原创作品,不妨现在就和我 [取得联系](https://paul.ren) 吧!
|
||||
|
||||
1. Star 本项目
|
||||
2. 从这里 [下载](https://github.com/Dreamer-Paul/Pio/archive/master.zip) 本插件
|
||||
3. 将插件文件夹重命名为 `Pio`
|
||||
4. 上传本插件,并放置在 `usr/plugins/` 目录下
|
||||
5. 登录你的 Typecho 后台,选择启用插件即可食用~
|
||||
6. 如果你有自己的模型,可以将模型放在 `models` 目录下,并在插件设置里选择(需要确认模型的配置文件名称是否为 `model.json`)。或是在插件设置填写一个绝对链接
|
||||
7. 保罗自己搭建了一个模型资源收集站点 - [梦象](https://mx-model.ga),你可以在这里下载到更多的模型,如果你有能力的话欢迎为我提供更多资源~
|
||||
5. 登录你的 Typecho 后台,找到 `Pio` 选择启用插件
|
||||
6. 你可以通过 [选择](https://docs.paul.ren/pio/#/?id=选择模型) 或 [外链](https://docs.paul.ren/pio/#/?id=选择外链模型) 的方式引用你获得的模型资源
|
||||
7. 想了解更多的玩法,欢迎阅读 [插件文档](https://docs.paul.ren/pio)。如果对本项目有任何的建议和想法,欢迎随时提出~
|
||||
|
||||
## 项目故事
|
||||
|
||||
详见我的博文:[给你的博客增加动态看板娘](https://paugram.com/coding/add-poster-girl-with-plugin.html),帮助文档及常见问题均在这里即时更新。
|
||||
|
||||
## 开源协议
|
||||
|
||||
由于原项目使用 GPL 2.0 协议,故本项目也采用相同的开源协议进行授权。
|
||||
|
||||
原创不易!如果喜欢本项目,请 Star 它以示对我的支持~
|
||||
|
||||
同时欢迎前往 [我的博客](https://paugram.com/about.html#donate) 为我提供赞助,谢谢您!
|
||||
同时欢迎前往 [保罗的小窝](https://paul.ren/donate) 为我提供赞助,谢谢您!
|
||||
|
||||
## 使用的开源项目
|
||||
- [Live2D-Src](https://github.com/journey-ad/live2d_src)
|
||||
|
||||
- [Live2D-SRC](https://github.com/journey-ad/live2d_src)
|
||||
|
||||
## 感谢
|
||||
- [Live2D](https://www.live2d.com)
|
||||
|
||||
- [Live2D](https://www.live2d.com)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Pio Plugin
|
||||
# By: Dreamer-Paul
|
||||
# Last Update: 2019.2.1
|
||||
# Last Update: 2019.8.8
|
||||
|
||||
一个支持更换 Live2D 模型的 Typecho 插件。
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
.pio-container{
|
||||
bottom: 0;
|
||||
z-index: 52;
|
||||
color: #666;
|
||||
position: fixed;
|
||||
user-select: none;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Pio Plugin
|
||||
# By: Dreamer-Paul
|
||||
# Last Update: 2019.2.13
|
||||
# Last Update: 2019.8.8
|
||||
|
||||
一个支持更换 Live2D 模型的 Typecho 插件。
|
||||
|
||||
@ -121,12 +121,11 @@ var Paul_Pio = function (prop) {
|
||||
// 文章
|
||||
article: function () {
|
||||
if(prop.selector.articles){
|
||||
var a = document.querySelectorAll(prop.selector.articles), b;
|
||||
prop.content.article ? b = prop.content.article : b = "想阅读 %t 吗?";
|
||||
var obj = document.querySelectorAll(prop.selector.articles);
|
||||
|
||||
for(var i = 0; i < a.length; i++){
|
||||
a[i].onmouseover = function () {
|
||||
modules.render(b.replace(/%t/, "“" + this.innerText + "”"));
|
||||
for(var i = 0; i < obj.length; i++){
|
||||
obj[i].onmouseover = function () {
|
||||
modules.render("想阅读 %t 吗?".replace(/%t/, "“" + this.innerText + "”"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,18 +195,17 @@ var Paul_Pio = function (prop) {
|
||||
document.cookie = "posterGirl=false;" + "path=/";
|
||||
},
|
||||
custom: function () {
|
||||
for(var i = 0; i < prop.content.custom.length; i++){
|
||||
var e = document.querySelectorAll(prop.content.custom[i].s);
|
||||
var c = prop.content.custom[i].t;
|
||||
prop.content.custom.forEach(function (t) {
|
||||
var e = document.querySelectorAll(t.selector);
|
||||
|
||||
if(e[0]){
|
||||
if(e.length){
|
||||
for(var j = 0; j < e.length; j++){
|
||||
e[j].onmouseover = function () {
|
||||
modules.render(c);
|
||||
modules.render(t.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user