This commit is contained in:
杜恒 2021-03-30 17:57:47 +08:00
parent e8ab5c4666
commit e7d6d4785f
16 changed files with 114 additions and 14272 deletions

File diff suppressed because one or more lines are too long

View File

@ -1791,7 +1791,6 @@
}
}
&-player {
width: 100%;
height: 500px;
}
&-protected {

View File

@ -10,7 +10,7 @@ document.addEventListener('DOMContentLoaded', () => {
this.render();
}
get template() {
return `<object style="display: block;margin: 0 auto;" width="${this.options.width}" height="450px" data="//music.163.com/outchain/player?type=0&id=${this.options.id}&auto=${this.options.autoplay}&height=430"></object>`;
return `<iframe allowfullscreen="true" style="display: block; margin: 0 auto; border: 0;" width="${this.options.width}" height="450px" src="//music.163.com/outchain/player?type=0&id=${this.options.id}&auto=${this.options.autoplay}&height=430"></iframe>`;
}
render() {
if (this.options.id) this.innerHTML = this.template;
@ -30,11 +30,11 @@ document.addEventListener('DOMContentLoaded', () => {
this.render();
}
get template() {
return `<object style="display: block;margin: 0 auto;" width="${this.options.width}" height="86px" data="//music.163.com/outchain/player?type=2&id=${this.options.id}&auto=${this.options.autoplay}&height=66"></object>`;
return `<iframe allowfullscreen="true" style="display: block; margin: 0 auto; border: 0;" width="${this.options.width}" height="86px" src="//music.163.com/outchain/player?type=2&id=${this.options.id}&auto=${this.options.autoplay}&height=66"></iframe>`;
}
render() {
if (this.options.id) this.innerHTML = this.template;
else this.innerHTML = '网易云歌ID未填写';
else this.innerHTML = '网易云歌ID未填写';
}
}
window.customElements.define('joe-music', JoeMusic);
@ -48,7 +48,7 @@ document.addEventListener('DOMContentLoaded', () => {
this.render();
}
get template() {
return `<object class="joe_detail__article-player" data="//player.bilibili.com/player.html?bvid=${this.options.bvid}"></object>`;
return `<iframe allowfullscreen="true" class="joe_detail__article-player" style="display: block; margin: 0 auto; border: 0;" width="100%" height="180px" src="//player.bilibili.com/player.html?bvid=${this.options.bvid}"></iframe>`;
}
render() {
if (this.options.bvid) this.innerHTML = this.template;
@ -57,6 +57,25 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-bilibili', JoeBilibili);
class JoeDplayer extends HTMLElement {
constructor() {
super();
this.options = {
src: this.getAttribute('src'),
player: this.getAttribute('player')
};
this.render();
}
get template() {
return `<iframe allowfullscreen="true" class="joe_detail__article-player" style="display: block; margin: 0 auto; border: 0;" width="100%" height="180px" src="${this.options.player + this.options.src}"></iframe>`;
}
render() {
if (this.options.src) this.innerHTML = this.template;
else this.innerHTML = '播放地址未填写!';
}
}
window.customElements.define('joe-dplayer', JoeDplayer);
@ -111,27 +130,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
window.customElements.define('joe-abtn', JoeAbtn);
/* Dplayer */
class JoeDplayer extends HTMLElement {
constructor() {
super();
this.options = {
src: this.getAttribute('src'),
player: this.getAttribute('player')
};
this.render();
}
get template() {
return `
<iframe class="joe_detail__article-player" allowfullscreen="true" src="${this.options.player + this.options.src}"></iframe>
`;
}
render() {
if (this.options.src) this.innerHTML = this.template;
else this.innerHTML = '播放地址未填写!';
}
}
window.customElements.define('joe-dplayer', JoeDplayer);
/* 居中标题 */
class JoeMtitle extends HTMLElement {
constructor() {

File diff suppressed because one or more lines are too long

View File

@ -48,6 +48,7 @@ class Editor
uploadAPI: '<?php Helper::security()->index('/action/upload'); ?>',
emojiAPI: '<?php Helper::options()->themeUrl('typecho/write/json/emoji.json') ?>',
characterAPI: '<?php Helper::options()->themeUrl('typecho/write/json/character.json') ?>',
playerAPI: '<?php Helper::options()->JCustomPlayer ? Helper::options()->JCustomPlayer() : Helper::options()->themeUrl('library/player.php?url=') ?>'
}
</script>
<script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.0.0/plugin/prism/prism.js"></script>

View File

@ -2,7 +2,7 @@
/* 获取主题当前版本号 */
function _getVersion()
{
return "6.2.1";
return "6.2.2";
};
/* 判断是否是手机 */

View File

@ -18,6 +18,10 @@ function _parseContent($post, $login)
if (strpos($content, '{bilibili') !== false) {
$content = preg_replace('/{bilibili([^\/}]*)\/}/SU', '<joe-bilibili $1></joe-bilibili>', $content);
}
if (strpos($content, '{dplayer') !== false) {
$player = Helper::options()->JCustomPlayer ? Helper::options()->JCustomPlayer : Helper::options()->themeUrl . '/library/player.php?url=';
$content = preg_replace('/{dplayer([^}]*)\/}/SU', '<joe-dplayer player="' . $player . '" $1></joe-dplayer>', $content);
}
@ -39,11 +43,7 @@ function _parseContent($post, $login)
}
/* 过滤dplayer播放器 */
if (strpos($content, '{dplayer') !== false) {
$player = Helper::options()->JCustomPlayer ? Helper::options()->JCustomPlayer : '/usr/themes/Joe/library/player.php?url=';
$content = preg_replace('/{dplayer(.*)\/}/SU', '<joe-dplayer player="' . $player . '" $1></joe-dplayer>', $content);
}
/* 过滤复制粘贴功能 */
if (strpos($content, '{copy') !== false) {

View File

@ -1,6 +1,6 @@
{
"name": "typecho-joe-next",
"version": "6.2.1",
"version": "6.2.2",
"description": "A Theme Of Typecho",
"main": "index.php",
"keywords": [

View File

@ -423,4 +423,22 @@ export default class JoeAction {
}
});
}
handleDplayer(cm) {
this._openModal({
title: 'M3U8/MP4视频',
innerHtml: `
<div class="fitem">
<label>视频地址</label>
<input autocomplete="off" name="src" placeholder="请输入视频地址"/>
</div>
`,
confirm: () => {
const src = $(".cm-modal input[name='src']").val();
const str = `{dplayer src="${src}"/}\n`;
if (this._getLineCh(cm)) this._replaceSelection(cm, '\n' + str);
else this._replaceSelection(cm, str);
cm.focus();
}
});
}
}

View File

@ -1,4 +1,5 @@
const parser = new HyperDown();
const player = window.JoeConfig.playerAPI;
export default function createPreviewHtml(str) {
str = parser.makeHtml(str);
@ -9,13 +10,16 @@ export default function createPreviewHtml(str) {
str = str.replace(/{ }/g, '<input type="checkbox" class="task" disabled></input>');
/* 网易云 - 歌单 */
str = str.replace(/{music-list([^/}]*)\/}/g, '<joe-mlist $1></joe-mlist>');
str = str.replace(/{music-list([^}]*)\/}/g, '<joe-mlist $1></joe-mlist>');
/* 网易云 - 歌曲 */
str = str.replace(/{music([^/}]*)\/}/g, '<joe-music $1></joe-music>');
str = str.replace(/{music([^}]*)\/}/g, '<joe-music $1></joe-music>');
/* BiliBili */
str = str.replace(/{bilibili([^/}]*)\/}/g, '<joe-bilibili $1></joe-bilibili>');
str = str.replace(/{bilibili([^}]*)\/}/g, '<joe-bilibili $1></joe-bilibili>');
/* dplayer */
str = str.replace(/{dplayer([^}]*)\/}/g, '<joe-dplayer player="' + player + '" $1></joe-dplayer>');
$('.cm-preview-content').html(str);
$('.cm-preview-content pre code').each((i, el) => Prism.highlightElement(el));

View File

@ -94,6 +94,11 @@ export default [
title: '任务 - 已完成',
innerHTML: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="18" height="18"><path d="M831.551 64.623h-639.11c-70.3 0-127.816 57.517-127.816 127.819v639.103c0 70.308 57.515 127.833 127.816 127.833h639.11c70.294 0 127.822-57.525 127.822-127.833V192.442c0-70.302-57.527-127.82-127.822-127.82zM646.217 486.44c-108.652 159.779-204.52 345.115-204.52 345.115L192.443 550.351l63.916-70.303 153.385 146.994s76.695-127.822 178.95-236.469c102.261-108.652 223.689-198.127 223.689-198.127l19.17 63.916c0-.001-102.255 108.646-185.337 230.078z"/></svg>'
},
{
type: 'dplayer',
title: 'M3U8/MP4视频',
innerHTML: '<svg viewBox="0 0 1170 1024" xmlns="http://www.w3.org/2000/svg" width="18" height="18"><path d="M508.197 298.642c-39.278-20.919-69.34-5.12-69.34 35.109v211.822c0 40.301 29.989 56.027 69.12 34.889L698.88 477.257c38.985-21.065 39.57-55.442.293-76.361L508.197 298.642z"/><path d="M1060.571 877.714H109.714C49.225 877.714 0 828.562 0 768V109.714C0 49.225 49.225 0 109.714 0h950.857c60.416 0 109.715 49.225 109.715 109.714V768c0 60.562-49.299 109.714-109.715 109.714zM109.714 73.143a36.571 36.571 0 0 0-36.571 36.571V768c0 20.114 16.457 36.571 36.571 36.571h950.857c20.115 0 36.572-16.457 36.572-36.571V109.714a36.571 36.571 0 0 0-36.572-36.571H109.714zM219.43 950.857h731.428V1024H219.43v-73.143z"/></svg>'
},
{
type: 'netease-list',
title: '网易云列表',

View File

@ -10,7 +10,7 @@ document.addEventListener('DOMContentLoaded', () => {
this.render();
}
get template() {
return `<object style="display: block;margin: 0 auto;" width="${this.options.width}" height="450px" data="//music.163.com/outchain/player?type=0&id=${this.options.id}&auto=${this.options.autoplay}&height=430"></object>`;
return `<iframe allowfullscreen="true" style="display: block; margin: 0 auto; border: 0;" width="${this.options.width}" height="450px" src="//music.163.com/outchain/player?type=0&id=${this.options.id}&auto=${this.options.autoplay}&height=430"></iframe>`;
}
render() {
if (this.options.id) this.innerHTML = this.template;
@ -18,6 +18,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
window.customElements.define('joe-mlist', JoeMlist);
class JoeMusic extends HTMLElement {
constructor() {
super();
@ -29,7 +30,7 @@ document.addEventListener('DOMContentLoaded', () => {
this.render();
}
get template() {
return `<object style="display: block;margin: 0 auto;" width="${this.options.width}" height="86px" data="//music.163.com/outchain/player?type=2&id=${this.options.id}&auto=${this.options.autoplay}&height=66"></object>`;
return `<iframe allowfullscreen="true" style="display: block; margin: 0 auto; border: 0;" width="${this.options.width}" height="86px" src="//music.163.com/outchain/player?type=2&id=${this.options.id}&auto=${this.options.autoplay}&height=66"></iframe>`;
}
render() {
if (this.options.id) this.innerHTML = this.template;
@ -37,6 +38,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
window.customElements.define('joe-music', JoeMusic);
class JoeBilibili extends HTMLElement {
constructor() {
super();
@ -46,7 +48,7 @@ document.addEventListener('DOMContentLoaded', () => {
this.render();
}
get template() {
return `<object style="display: block;margin: 0 auto;" width="100%" height="180px" data="//player.bilibili.com/player.html?bvid=${this.options.bvid}"></object>`;
return `<iframe allowfullscreen="true" class="joe_detail__article-player" style="display: block; margin: 0 auto; border: 0;" width="100%" height="180px" src="//player.bilibili.com/player.html?bvid=${this.options.bvid}"></iframe>`;
}
render() {
if (this.options.bvid) this.innerHTML = this.template;
@ -54,4 +56,23 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
window.customElements.define('joe-bilibili', JoeBilibili);
class JoeDplayer extends HTMLElement {
constructor() {
super();
this.options = {
src: this.getAttribute('src'),
player: this.getAttribute('player')
};
this.render();
}
get template() {
return `<iframe allowfullscreen="true" class="joe_detail__article-player" style="display: block; margin: 0 auto; border: 0;" width="100%" height="180px" src="${this.options.player + this.options.src}"></iframe>`
}
render() {
if (this.options.src) this.innerHTML = this.template;
else this.innerHTML = '播放地址未填写!';
}
}
window.customElements.define('joe-dplayer', JoeDplayer);
});

View File

@ -1 +1 @@
document.addEventListener("DOMContentLoaded",()=>{class t extends HTMLElement{constructor(){super(),this.options={id:this.getAttribute("id"),width:this.getAttribute("width")||"100%",autoplay:this.getAttribute("autoplay")?1:0},this.render()}get template(){return`<object style="display: block;margin: 0 auto;" width="${this.options.width}" height="450px" data="//music.163.com/outchain/player?type=0&id=${this.options.id}&auto=${this.options.autoplay}&height=430"></object>`}render(){this.options.id?this.innerHTML=this.template:this.innerHTML="网易云歌单ID未填写"}}window.customElements.define("joe-mlist",t);class i extends HTMLElement{constructor(){super(),this.options={id:this.getAttribute("id"),width:this.getAttribute("width")||"100%",autoplay:this.getAttribute("autoplay")?1:0},this.render()}get template(){return`<object style="display: block;margin: 0 auto;" width="${this.options.width}" height="86px" data="//music.163.com/outchain/player?type=2&id=${this.options.id}&auto=${this.options.autoplay}&height=66"></object>`}render(){this.options.id?this.innerHTML=this.template:this.innerHTML="网易云歌曲ID未填写"}}window.customElements.define("joe-music",i);class e extends HTMLElement{constructor(){super(),this.options={bvid:this.getAttribute("bvid")},this.render()}get template(){return`<object style="display: block;margin: 0 auto;" width="100%" height="180px" data="//player.bilibili.com/player.html?bvid=${this.options.bvid}"></object>`}render(){this.options.bvid?this.innerHTML=this.template:this.innerHTML="Bvid未填写"}}window.customElements.define("joe-bilibili",e)});
document.addEventListener("DOMContentLoaded",()=>{class t extends HTMLElement{constructor(){super(),this.options={id:this.getAttribute("id"),width:this.getAttribute("width")||"100%",autoplay:this.getAttribute("autoplay")?1:0},this.render()}get template(){return`<iframe allowfullscreen="true" style="display: block; margin: 0 auto; border: 0;" width="${this.options.width}" height="450px" src="//music.163.com/outchain/player?type=0&id=${this.options.id}&auto=${this.options.autoplay}&height=430"></iframe>`}render(){this.options.id?this.innerHTML=this.template:this.innerHTML="网易云歌单ID未填写"}}window.customElements.define("joe-mlist",t);class e extends HTMLElement{constructor(){super(),this.options={id:this.getAttribute("id"),width:this.getAttribute("width")||"100%",autoplay:this.getAttribute("autoplay")?1:0},this.render()}get template(){return`<iframe allowfullscreen="true" style="display: block; margin: 0 auto; border: 0;" width="${this.options.width}" height="86px" src="//music.163.com/outchain/player?type=2&id=${this.options.id}&auto=${this.options.autoplay}&height=66"></iframe>`}render(){this.options.id?this.innerHTML=this.template:this.innerHTML="网易云歌曲ID未填写"}}window.customElements.define("joe-music",e);class i extends HTMLElement{constructor(){super(),this.options={bvid:this.getAttribute("bvid")},this.render()}get template(){return`<iframe allowfullscreen="true" class="joe_detail__article-player" style="display: block; margin: 0 auto; border: 0;" width="100%" height="180px" src="//player.bilibili.com/player.html?bvid=${this.options.bvid}"></iframe>`}render(){this.options.bvid?this.innerHTML=this.template:this.innerHTML="Bvid未填写"}}window.customElements.define("joe-bilibili",i);class s extends HTMLElement{constructor(){super(),this.options={src:this.getAttribute("src"),player:this.getAttribute("player")},this.render()}get template(){return`<iframe allowfullscreen="true" class="joe_detail__article-player" style="display: block; margin: 0 auto; border: 0;" width="100%" height="180px" src="${this.options.player+this.options.src}"></iframe>`}render(){this.options.src?this.innerHTML=this.template:this.innerHTML="播放地址未填写!"}}window.customElements.define("joe-dplayer",s)});

File diff suppressed because one or more lines are too long

View File

@ -264,6 +264,9 @@ class Joe extends JoeAction {
case 'bilibili':
super.handleBilibili(this.cm);
break;
case 'dplayer':
super.handleDplayer(this.cm);
break;
}
});
$('.cm-tools').append(el);

View File

@ -6,5 +6,5 @@ export default {
file: './js/joe.write.chunk.js',
format: 'iife'
},
plugins: [nodeResolve()]
plugins: [nodeResolve(), uglify()]
};