Skip to content

Commit

Permalink
Merge Settings
Browse files Browse the repository at this point in the history
删除“自定内容选择器”功能,把它和“自定提示内容”整合到了一块,变为“交互提示扩展”
  • Loading branch information
Dreamer-Paul committed Aug 18, 2019
1 parent 924ade6 commit 4b943a7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 46 deletions.
17 changes: 6 additions & 11 deletions Plugin.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* 一个简易的 Live2D 插件,建立在 <a href="https://github.com/journey-ad/live2d_src">@Jad</a> 的项目上
* 一个简易的 Live2D 插件, <a href="https://github.com/journey-ad/live2d_src">@Jad</a> 的项目上增加交互功能
*
* @package Pio
* @author Dreamer-Paul
* @version 2.3
* @version 2.4
* @link https://paugram.com
*/

Expand Down Expand Up @@ -39,7 +39,7 @@ function paul_update($name, $version){

echo "</div>";
}
paul_update("Pio", "2.3");
paul_update("Pio", "2.4");

// 读取模型文件夹
$models = array();
Expand Down Expand Up @@ -106,13 +106,9 @@ function paul_update($name, $version){
'0', _t('时间小贴士'), _t('开启后将在没有访问来源的情况下展示,覆盖入站提示'));
$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('在这里填入部分功能所用到的自定义选择器,如不想启用此类功能,请留空'));
$form -> addInput($selector);
}

/* 个人用户的配置方法 */
Expand All @@ -138,8 +134,7 @@ function getLoader(){
$config = array(
"mode" => $plugin -> custom_mode,
"hidden" => $plugin -> hidden == 1 ? true : false,
"content" => $plugin -> dialog ? json_decode($plugin -> dialog, true) : array(),
"selector" => $plugin -> selector ? json_decode($plugin -> selector, true) : array()
"content" => $plugin -> dialog ? json_decode($plugin -> dialog, true) : array()
);

if($plugin -> custom_model){
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
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),帮助文档及常见问题均在这里即时更新。
- 开发故事:[给你的博客增加动态看板娘](https://paugram.com/coding/add-poster-girl-with-plugin.html)
- 帮助文档 & 常见问题:[传送门](https://docs.paul.ren/pio)

## 开源协议

Expand Down
61 changes: 28 additions & 33 deletions static/pio.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Pio Plugin
# By: Dreamer-Paul
# Last Update: 2019.8.8
# Last Update: 2019.8.18
一个支持更换 Live2D 模型的 Typecho 插件。
Expand Down Expand Up @@ -58,6 +58,7 @@ var Paul_Pio = function (prop) {
// 移除方法
destroy: function () {
current.body.parentNode.removeChild(current.body);
document.cookie = "posterGirl=false;" + "path=/";
}
};

Expand Down Expand Up @@ -115,33 +116,14 @@ var Paul_Pio = function (prop) {
modules.render(text);
}
else{
prop.content.welcome ? modules.render(prop.content.welcome) : modules.render("欢迎来到本站!");
}
},
// 文章
article: function () {
if(prop.selector.articles){
var obj = document.querySelectorAll(prop.selector.articles);

for(var i = 0; i < obj.length; i++){
obj[i].onmouseover = function () {
modules.render("想阅读 %t 吗?".replace(/%t/, "“" + this.innerText + "”"));
}
}
modules.render(prop.content.welcome || "欢迎来到本站!");
}
},
// 触摸
touch: function () {
if(prop.content.touch){
current.canvas.onclick = function () {
modules.render(prop.content.touch);
}
}
else{
current.canvas.onclick = function () {
modules.render(["你在干什么?", "再摸我就报警了!", "HENTAI!", "你够了喔!"]);
}
}
current.canvas.onclick = function () {
modules.render(prop.content.touch || ["你在干什么?", "再摸我就报警了!", "HENTAI!", "不可以这样欺负我啦!"]);
};
},
// 右侧按钮
buttons: function () {
Expand All @@ -150,7 +132,7 @@ var Paul_Pio = function (prop) {
location.href = current.root;
};
elements.home.onmouseover = function () {
prop.content.home ? modules.render(prop.content.home) : modules.render("点击这里回到首页!");
modules.render(prop.content.home || "点击这里回到首页!");
};
current.menu.appendChild(elements.home);

Expand All @@ -166,7 +148,7 @@ var Paul_Pio = function (prop) {

// 关于我
elements.info.onclick = function () {
prop.content.link ? window.open(prop.content.link) : window.open("https://paugram.com/coding/add-poster-girl-with-plugin.html");
window.open(prop.content.link || "https://paugram.com/coding/add-poster-girl-with-plugin.html");
};
elements.info.onmouseover = function () {
modules.render("想了解更多关于我的信息吗?");
Expand All @@ -189,19 +171,31 @@ var Paul_Pio = function (prop) {
modules.destroy();
};
elements.close.onmouseover = function () {
prop.content.close ? modules.render(prop.content.close) : modules.render("QWQ 下次再见吧~");
modules.render(prop.content.close || "QWQ 下次再见吧~");
};
current.menu.appendChild(elements.close);
document.cookie = "posterGirl=false;" + "path=/";
},
custom: function () {
prop.content.custom.forEach(function (t) {
if(!t.type) t.type = "default";
var e = document.querySelectorAll(t.selector);

if(e.length){
for(var j = 0; j < e.length; j++){
e[j].onmouseover = function () {
modules.render(t.text);
if(t.type === "read"){
e[j].onmouseover = function () {
modules.render("想阅读 %t 吗?".replace(/%t/, "“" + this.innerText + "”"));
}
}
else if(t.type === "link"){
e[j].onmouseover = function () {
modules.render("想了解一下 %t 吗?".replace(/%t/, "“" + this.innerText + "”"));
}
}
else if(t.text){
e[j].onmouseover = function () {
modules.render(t.text);
}
}
}
}
Expand All @@ -212,14 +206,13 @@ var Paul_Pio = function (prop) {
/* - 运行 */
var begin = {
static: function () {
action.welcome(); action.article();
current.body.classList.add("static");
},
fixed: function () {
action.welcome(); action.article(); action.touch(); action.buttons();
action.touch(); action.buttons();
},
draggable: function () {
action.welcome(); action.article(); action.touch(); action.buttons();
action.touch(); action.buttons();

var body = current.body;
body.onmousedown = function () {
Expand Down Expand Up @@ -250,6 +243,8 @@ var Paul_Pio = function (prop) {
current.body.classList.add("hidden");
}
else{
action.welcome();

switch (prop.mode){
case "static": begin.static(); break;
case "fixed": begin.fixed(); break;
Expand Down

0 comments on commit 4b943a7

Please sign in to comment.