From ebd109ea182a141dfdd678fbc95f72e9fe0025f5 Mon Sep 17 00:00:00 2001 From: Kenshin Date: Tue, 19 Jun 2018 16:07:54 +0800 Subject: [PATCH 01/75] Add exec logic and SR_addStyle(). --- src/service/plugin.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/service/plugin.js b/src/service/plugin.js index dc3d4cd9..4e33c446 100644 --- a/src/service/plugin.js +++ b/src/service/plugin.js @@ -25,7 +25,30 @@ function install( id ) { } function exec( str ) { + ( function ( $$version, $title, $desc, $content, $footer, $process, $toc, SR_addStyle ) { + const count = $content.text().length, + styles= `sr-plugin-count { + position: fixed; + display: block; + left: 5px; + bottom: 5px; + font-size: 12px; + }`, + html = ` + 共计:${count} 个字 + `; + $content.append( html ); + SR_addStyle( styles ); + })( "0.0.1", $( "sr-rd-title" ), $( "sr-rd-desc" ), $( "sr-rd-content" ), $( "sr-rd-footer" ), $( "read-process" ), $( "toc" ), addStyle ); +} +/** + * Add style + * + * @param {string} add css to head + */ +function addStyle( str ) { + $( "head" ).append(``); } export { From e6cd585dc00f5e6be75ce83d04e6e55e0e35a4fd Mon Sep 17 00:00:00 2001 From: Kenshin Date: Tue, 19 Jun 2018 17:00:47 +0800 Subject: [PATCH 02/75] Add exec() and func() logic. --- src/service/plugin.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/service/plugin.js b/src/service/plugin.js index 4e33c446..df1beff3 100644 --- a/src/service/plugin.js +++ b/src/service/plugin.js @@ -24,22 +24,25 @@ function install( id ) { } -function exec( str ) { - ( function ( $$version, $title, $desc, $content, $footer, $process, $toc, SR_addStyle ) { - const count = $content.text().length, - styles= `sr-plugin-count { - position: fixed; - display: block; - left: 5px; - bottom: 5px; - font-size: 12px; - }`, - html = ` - 共计:${count} 个字 - `; - $content.append( html ); - SR_addStyle( styles ); - })( "0.0.1", $( "sr-rd-title" ), $( "sr-rd-desc" ), $( "sr-rd-content" ), $( "sr-rd-footer" ), $( "read-process" ), $( "toc" ), addStyle ); +/** + * Execute + * + * @param {object} plugin object + */ +function exec( plugin ) { + new Function( func( plugin.script ) )(); + plugin.style != "" && addStyle( plugin.style ); +} + +/** + * Contact (function(){})() string + * + * @param {string} source + */ +function func( source ) { + return `( function ( $$version, $title, $desc, $content, $footer, $process, $toc ) { + ${ source } + })( "0.0.1", $( "sr-rd-title" ), $( "sr-rd-desc" ), $( "sr-rd-content" ), $( "sr-rd-footer" ), $( "read-process" ), $( "toc" ) );` } /** From 3f3aa0e1f05f7fa692380df946c02f799e56fd3f Mon Sep 17 00:00:00 2001 From: Kenshin Date: Tue, 19 Jun 2018 17:01:13 +0800 Subject: [PATCH 03/75] Add plug.exec() test source. --- src/read/read.jsx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/read/read.jsx b/src/read/read.jsx index 9d078e16..7d8a8936 100644 --- a/src/read/read.jsx +++ b/src/read/read.jsx @@ -14,6 +14,7 @@ import * as ss from 'stylesheet'; import {browser} from 'browser'; import * as msg from 'message'; import * as highlight from 'highlight'; +import * as plug from 'plugin'; import * as tooltip from 'tooltip'; import * as waves from 'waves'; @@ -83,6 +84,27 @@ class Read extends React.Component { tooltip.Render( rdclsjq ); waves.Render({ root: rdclsjq }); storage.Statistics( "read" ); + + // test code + const plugin = { + user : { + uid : "vdmq0t08-ehpe-v5x6-168w-r9e2xg25lung", + name : "Kenshin Wang", + email : "kenshin@ksria.com", + }, + version : "0.0.1", + id : "kw36BtjGu0", + name : "为阅读模式增加字数统计。", + icon : { + type : "", + bgColor : "#2196f3", + }, + category : 0, + site : "", + style : "sr-plugin-count{position:fixed;display:block;left:5px;bottom:5px;font-size:12px}", + script : "var count=$content.text().length,html=' 共计:'+count+' 个字 ';$content.append(html);", + }; + plug.Exec( plugin ); } } From e2514aca78d71f45763ab5c393125c8feae5aa90 Mon Sep 17 00:00:00 2001 From: Kenshin Date: Tue, 19 Jun 2018 17:08:58 +0800 Subject: [PATCH 04/75] Format source. --- src/read/read.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/read/read.jsx b/src/read/read.jsx index 7d8a8936..47605dd6 100644 --- a/src/read/read.jsx +++ b/src/read/read.jsx @@ -99,6 +99,9 @@ class Read extends React.Component { type : "", bgColor : "#2196f3", }, + create : "Tue Jun 19 2018 17:08:18 GMT+0800 (CST)", + update : "", + global : true, category : 0, site : "", style : "sr-plugin-count{position:fixed;display:block;left:5px;bottom:5px;font-size:12px}", From 6231c90fb545a677e661f8f0399dc86128488210 Mon Sep 17 00:00:00 2001 From: Kenshin Date: Tue, 19 Jun 2018 18:25:40 +0800 Subject: [PATCH 05/75] Add install() logic. --- src/read/read.jsx | 1 + src/service/plugin.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/read/read.jsx b/src/read/read.jsx index 47605dd6..9dec8d1f 100644 --- a/src/read/read.jsx +++ b/src/read/read.jsx @@ -107,6 +107,7 @@ class Read extends React.Component { style : "sr-plugin-count{position:fixed;display:block;left:5px;bottom:5px;font-size:12px}", script : "var count=$content.text().length,html=' 共计:'+count+' 个字 ';$content.append(html);", }; + plug.Install( "kw36BtjGu0" ); plug.Exec( plugin ); } } diff --git a/src/service/plugin.js b/src/service/plugin.js index df1beff3..da1476b3 100644 --- a/src/service/plugin.js +++ b/src/service/plugin.js @@ -20,8 +20,15 @@ function generateID( type ) { } } +/** + * Install plugin + * + * @param {string} plugin id. e.g. kw36BtjGu0 + */ function install( id ) { - + $.get( `http://simpread.ksria.cn/plugins/${id}.srplug`, result => { + console.log( "adfadfadf", result ) + }); } /** From 59f1845aaafa807cd0802df35eea87e804f40c9d Mon Sep 17 00:00:00 2001 From: Kenshin Date: Wed, 20 Jun 2018 10:31:34 +0800 Subject: [PATCH 06/75] Change plugin to runtime. --- src/options/options.js | 4 ++-- src/read/read.jsx | 6 +++--- src/service/{plugin.js => runtime.js} | 1 + webpack.config.js | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) rename src/service/{plugin.js => runtime.js} (97%) diff --git a/src/options/options.js b/src/options/options.js index 45ae464c..cdf9fb8d 100644 --- a/src/options/options.js +++ b/src/options/options.js @@ -29,7 +29,7 @@ import LabsOpt from 'labsopt'; import About from 'about'; import Unrdist from 'unrdist'; import * as welc from 'welcome'; -import * as plug from 'plugin'; +import * as run from 'runtime'; import PureRead from 'puread'; @@ -268,7 +268,7 @@ function sidebarRender() { * set user uid */ function setUserUID() { - storage.user.uid = plug.ID( "user" ); + storage.user.uid = run.ID( "user" ); storage.Write( () => { console.log( "current user info create!" ) watch.SendMessage( "option", true ); diff --git a/src/read/read.jsx b/src/read/read.jsx index 9dec8d1f..69722440 100644 --- a/src/read/read.jsx +++ b/src/read/read.jsx @@ -14,7 +14,7 @@ import * as ss from 'stylesheet'; import {browser} from 'browser'; import * as msg from 'message'; import * as highlight from 'highlight'; -import * as plug from 'plugin'; +import * as run from 'runtime'; import * as tooltip from 'tooltip'; import * as waves from 'waves'; @@ -107,8 +107,8 @@ class Read extends React.Component { style : "sr-plugin-count{position:fixed;display:block;left:5px;bottom:5px;font-size:12px}", script : "var count=$content.text().length,html=' 共计:'+count+' 个字 ';$content.append(html);", }; - plug.Install( "kw36BtjGu0" ); - plug.Exec( plugin ); + run.Install( "kw36BtjGu0" ); + run.Exec( plugin ); } } diff --git a/src/service/plugin.js b/src/service/runtime.js similarity index 97% rename from src/service/plugin.js rename to src/service/runtime.js index da1476b3..e28636d2 100644 --- a/src/service/plugin.js +++ b/src/service/runtime.js @@ -1,3 +1,4 @@ +console.log( "=== simpread runtime load ===" ) import nanoid from 'nanoid'; diff --git a/webpack.config.js b/webpack.config.js index 64b5f8d0..b74e2dff 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -249,7 +249,7 @@ const webpack = require( 'webpack' ), export : __dirname + '/src/service/export.js', highlight : __dirname + '/src/service/highlight.js', output : __dirname + '/src/service/output.js', - plugin : __dirname + '/src/service/plugin.js', + runtime : __dirname + '/src/service/runtime.js', focus : __dirname + '/src/focus/focus.js', controlbar : __dirname + '/src/focus/controlbar.jsx', From 7b089ef778678fb40994d3b531e9f44855dd249e Mon Sep 17 00:00:00 2001 From: Kenshin Date: Wed, 20 Jun 2018 10:54:14 +0800 Subject: [PATCH 07/75] Add plugins to option page. --- src/assets/css/options_page.css | 2 +- src/assets/images/plugins_icon.png | Bin 0 -> 333 bytes src/module/plugins.jsx | 25 +++++++++++++++++++++++++ src/options/options.js | 6 +++++- src/service/config.js | 15 +++++++++++---- webpack.config.js | 1 + 6 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 src/assets/images/plugins_icon.png create mode 100644 src/module/plugins.jsx diff --git a/src/assets/css/options_page.css b/src/assets/css/options_page.css index b991c0a2..32d16b17 100644 --- a/src/assets/css/options_page.css +++ b/src/assets/css/options_page.css @@ -3,7 +3,7 @@ --text-color: #333; --secondary-color: color(#333 alpha(-30%)); --background-color: #fff; - --width: 740px; + --width: 835px; } * { diff --git a/src/assets/images/plugins_icon.png b/src/assets/images/plugins_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..e4204fe69a1591830960bd2d6240708564894ce3 GIT binary patch literal 333 zcmV-T0kZyyP)GfkDz&H5lk5T>y8#4qR)YAHY7d?kwAFDX5XO zle7a)kD!uXV(cT}-hxvf7cTx4XN7b#sBKd8r1{wZbW2cQ2|WVC^PmPk0k3PJ$@$M) zX8?^gcq?hjRes45ad=6isc(B9)Yz@fnv9do$6V*cincXS%Y3dnlc=wRwvs|_amqII z-#~X$qYa84csF3N5bU|V`PshC#g+=dP&_Qmtfeki`7Yh~KZ=@wK8~|BZd0nAL1V=; f +
全局
+
+ +
+ +
管理
+
+ +
+ + + ) + } +} diff --git a/src/options/options.js b/src/options/options.js index cdf9fb8d..4fad4522 100644 --- a/src/options/options.js +++ b/src/options/options.js @@ -26,6 +26,7 @@ import FocusOpt from 'focusopt'; import ReadOpt from 'readopt'; import CommonOpt from 'commonopt'; import LabsOpt from 'labsopt'; +import PluginsOpt from 'pluginsopt'; import About from 'about'; import Unrdist from 'unrdist'; import * as welc from 'welcome'; @@ -181,7 +182,7 @@ function welcomeRender( first, version ) { function mainRender( idx ) { $( ".top" ).css( "background-color", conf.topColors[idx] ); $( ".header" ).css( "background-color", conf.topColors[idx] ).find( ".title" ).text( conf.tabsItem[idx].name ); - ( idx == 3 || idx == 5 ) ? $( '.main' ).addClass( "main_labs" ) : $( '.main' ).removeClass( "main_labs" ); + ( idx == 3 || idx == 4 || idx == 6 ) ? $( '.main' ).addClass( "main_labs" ) : $( '.main' ).removeClass( "main_labs" ); tabsRender( conf.headerColors[ idx ] ); } @@ -218,6 +219,9 @@ function tabsRender( color ) {
save(s) } />
+
+ +
{ return { ...item }} ) } />
welcomeRender(true)}/>
, diff --git a/src/service/config.js b/src/service/config.js index 378cec87..3ac9418e 100644 --- a/src/service/config.js +++ b/src/service/config.js @@ -566,6 +566,10 @@ const tabsItem = [{ name: "高级设定", value: "labs", route: "#labs", + },{ + name: "插件管理", + value: "plugins", + route: "#plugins", },{ name: "稍后读", value: "later", @@ -579,8 +583,8 @@ const tabsItem = [{ value: "help", route: "https://github.com/kenshin/simpread/wiki", }], - headerColors = [ "#64B5F6", "#81C784", "#9575CD", "#7986CB", "#BA68C8", "#4DB6AC" ], - topColors = [ "#2196F3", "#4CAF50", "#673AB7", "#3F51B5", "#9C27B0", "#009688" ], + headerColors = [ "#64B5F6", "#81C784", "#9575CD", "#7986CB", "#56d1d8", "#BA68C8", "#4DB6AC" ], + topColors = [ "#2196F3", "#4CAF50", "#673AB7", "#3F51B5", "#61ccd2", "#9C27B0", "#009688" ], menuItem = tabsItem.map( ( item, idx ) => { const menu = { ...item }; switch ( idx ) { @@ -598,12 +602,15 @@ const tabsItem = [{ menu.icon = ss.IconPath( "labs_icon" ); break; case 4: - menu.icon = ss.IconPath( "read_later_icon" ); + menu.icon = ss.IconPath( "plugins_icon" ); break; case 5: - menu.icon = ss.IconPath( "about_icon" ); + menu.icon = ss.IconPath( "read_later_icon" ); break; case 6: + menu.icon = ss.IconPath( "about_icon" ); + break; + case 7: menu.icon = ss.IconPath( "help_icon" ); break; } diff --git a/webpack.config.js b/webpack.config.js index b74e2dff..7826f1f7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -265,6 +265,7 @@ const webpack = require( 'webpack' ), focusopt : __dirname + '/src/module/focus.jsx', readopt : __dirname + '/src/module/read.jsx', commonopt : __dirname + '/src/module/common.jsx', + pluginsopt : __dirname + '/src/module/plugins.jsx', labsopt : __dirname + '/src/module/labs.jsx', about : __dirname + '/src/module/about.jsx', unrdist : __dirname + '/src/module/unrdist.jsx', From af89e4f8899414694331a2b143996f311ffaad37 Mon Sep 17 00:00:00 2001 From: Kenshin Date: Wed, 20 Jun 2018 11:02:40 +0800 Subject: [PATCH 08/75] Update slider width. --- src/module/focus.jsx | 2 +- src/module/read.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/module/focus.jsx b/src/module/focus.jsx index 632567c4..2936b8df 100644 --- a/src/module/focus.jsx +++ b/src/module/focus.jsx @@ -29,7 +29,7 @@ export default class FocusOpt extends React.Component { } render() { - const slider_width = location.protocol.includes( "extension" ) ? "565.8px" : undefined; + const slider_width = location.protocol.includes( "extension" ) ? "660.09px" : undefined; return ( diff --git a/src/module/read.jsx b/src/module/read.jsx index 9e5a58db..afd1b352 100644 --- a/src/module/read.jsx +++ b/src/module/read.jsx @@ -76,7 +76,7 @@ export default class ReadOpt extends React.Component { } render() { - const slider_width = location.protocol.includes( "extension" ) ? "565.8px" : undefined; + const slider_width = location.protocol.includes( "extension" ) ? "660.09px" : undefined; return ( From 94c74a9cd41879b9b340e763f891933b8abd383f Mon Sep 17 00:00:00 2001 From: Kenshin Date: Wed, 20 Jun 2018 11:18:46 +0800 Subject: [PATCH 09/75] Update plugins colors. --- src/service/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service/config.js b/src/service/config.js index 3ac9418e..8f36b77b 100644 --- a/src/service/config.js +++ b/src/service/config.js @@ -583,8 +583,8 @@ const tabsItem = [{ value: "help", route: "https://github.com/kenshin/simpread/wiki", }], - headerColors = [ "#64B5F6", "#81C784", "#9575CD", "#7986CB", "#56d1d8", "#BA68C8", "#4DB6AC" ], - topColors = [ "#2196F3", "#4CAF50", "#673AB7", "#3F51B5", "#61ccd2", "#9C27B0", "#009688" ], + headerColors = [ "#64B5F6", "#81C784", "#9575CD", "#7986CB", "#4DD0E1", "#BA68C8", "#4DB6AC" ], + topColors = [ "#2196F3", "#4CAF50", "#673AB7", "#3F51B5", "#00BCD4", "#9C27B0", "#009688" ], menuItem = tabsItem.map( ( item, idx ) => { const menu = { ...item }; switch ( idx ) { From 0008288063cdff380b369a984737aa3fe786ac26 Mon Sep 17 00:00:00 2001 From: Kenshin Date: Wed, 20 Jun 2018 11:19:55 +0800 Subject: [PATCH 10/75] Update some icons. --- src/assets/images/update_icon.png | Bin 0 -> 192 bytes src/assets/images/website_icon.png | Bin 393 -> 0 bytes src/module/common.jsx | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 src/assets/images/update_icon.png delete mode 100644 src/assets/images/website_icon.png diff --git a/src/assets/images/update_icon.png b/src/assets/images/update_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ee947b109130f42a4101fdac2ba3319d2226d5e8 GIT binary patch literal 192 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gj?Vc`obuapnzYl8g-jk>l)s86aD~)q&T#$5rt_0$T7v2F zo$Lu&n-8SMaaLTPx1P<#@PKUugWAW5sl}ruln5QKLtfD-5cQUUIO&_O!DbPzgl38sV4fvJGdfvF&&g3D|oGaijB3E2$y#~xd{ z@3i+2@yAB_H?s=B{lctwlHCB<0;mD(7lPaYXh?3yfQqC}GTY3o1JDHlW~P%oL@3WB z_s)rV>pn@=DZtT5r6_#c0B9ANnd$w;TcD`B6hKkE$cgWLywS|0^Od*ei)6nPz?VlX zRZg`CAXW(}fO7DmDwxQ@tIL5T^iLs)+7w{zdLk60;I-4a4J3I-vWWs_H^F5xMEgKL zOUK3=$#n{#^1CiP$#K+#lbsx@?_Az@4q%Q%s<6$!C%FM|o2!YpPMxed6|JJs5X
管理
From 2231e63104cc82fbf51540a0ff8d8e8e00ac925f Mon Sep 17 00:00:00 2001 From: Kenshin Date: Wed, 20 Jun 2018 13:52:44 +0800 Subject: [PATCH 17/75] Add Clear plugins logic. --- src/module/plugins.jsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/module/plugins.jsx b/src/module/plugins.jsx index 33476b11..98cb7733 100644 --- a/src/module/plugins.jsx +++ b/src/module/plugins.jsx @@ -38,6 +38,21 @@ export default class PluginsOpt extends React.Component { } } + clear() { + new Notify().Render({ mode: "snackbar", content: "是否清除本地全部插件?", action: "是的", cancel: "取消", callback: type => { + if ( type == "action" ) { + storage.option.plugins = []; + storage.Write(); + storage.Plugins( () => { + new Notify().Render( "snackbar", "清除成功,此页面需刷新后才能生效!", "刷新 ", ()=>{ + location.href = location.origin + location.pathname + "#plugins"; + location.reload(); + }); + }, {} ); + } + }}); + } + componentWillMount() { storage.Plugins( () => { storage.option.plugins = Object.keys( storage.plugins ); @@ -64,7 +79,7 @@ export default class PluginsOpt extends React.Component { icon={ ss.IconPath( "clear_icon" ) } color="#fff" backgroundColor="#757575" waves="md-waves-effect md-waves-button" - /> + onClick={ ()=>this.clear() } /> From dbd29dfeee26885462ee6ee1a2d2b0e90f16072c Mon Sep 17 00:00:00 2001 From: Kenshin Date: Wed, 20 Jun 2018 13:55:35 +0800 Subject: [PATCH 18/75] Format source. --- src/module/plugins.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/module/plugins.jsx b/src/module/plugins.jsx index 98cb7733..56331fc0 100644 --- a/src/module/plugins.jsx +++ b/src/module/plugins.jsx @@ -16,7 +16,11 @@ export default class PluginsOpt extends React.Component { const install = () => { storage.plugins[result.id] = result; storage.Plugins( result => { - new Notify().Render( "当前插件已安装成功。" ); + new Notify().Render( "当前插件已安装成功,2 秒后自动刷新当前页面。" ); + setTimeout( ()=> { + location.href = location.origin + location.pathname + "#plugins"; + location.reload(); + }, 2000 ); }, storage.plugins ); }; result = JSON.parse( result ); @@ -75,7 +79,7 @@ export default class PluginsOpt extends React.Component { color="#fff" backgroundColor="#FF5252" waves="md-waves-effect md-waves-button" /> -