@weaccountsbot/sync 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +17 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -158,3 +158,20 @@ export function syncPosts(posts: SyncPost[]): void;
|
|
|
158
158
|
* ```
|
|
159
159
|
*/
|
|
160
160
|
export function syncImages(images: SyncImage[]): void;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 检查是否已安装「公众账号助手」浏览器扩展
|
|
164
|
+
*
|
|
165
|
+
* 通过检测全局的 WeAccountsBot 对象是否存在来判断扩展是否已安装。
|
|
166
|
+
*
|
|
167
|
+
* @returns {boolean} 是否已安装扩展
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* if (isExtensionInstalled()) {
|
|
171
|
+
* console.log('已安装「公众账号助手」扩展');
|
|
172
|
+
* } else {
|
|
173
|
+
* console.log('未安装「公众账号助手」扩展');
|
|
174
|
+
* }
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
export function isExtensionInstalled(): boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* we-accounts-extension-sdk v0.1.
|
|
2
|
+
* we-accounts-extension-sdk v0.1.2
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["we-accounts-extension-sdk"]=t():e["we-accounts-extension-sdk"]=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";var r,o=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},i=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),a=[];function s(e){for(var t=-1,n=0;n<a.length;n++)if(a[n].identifier===e){t=n;break}return t}function l(e,t){for(var n={},r=[],o=0;o<e.length;o++){var i=e[o],l=t.base?i[0]+t.base:i[0],c=n[l]||0,
|
|
5
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["we-accounts-extension-sdk"]=t():e["we-accounts-extension-sdk"]=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";var r,o=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},i=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),a=[];function s(e){for(var t=-1,n=0;n<a.length;n++)if(a[n].identifier===e){t=n;break}return t}function l(e,t){for(var n={},r=[],o=0;o<e.length;o++){var i=e[o],l=t.base?i[0]+t.base:i[0],c=n[l]||0,u="".concat(l," ").concat(c);n[l]=c+1;var d=s(u),f={css:i[1],media:i[2],sourceMap:i[3]};-1!==d?(a[d].references++,a[d].updater(f)):a.push({identifier:u,updater:v(f,t),references:1}),r.push(u)}return r}function c(e){var t=document.createElement("style"),r=e.attributes||{};if(void 0===r.nonce){var o=n.nc;o&&(r.nonce=o)}if(Object.keys(r).forEach((function(e){t.setAttribute(e,r[e])})),"function"==typeof e.insert)e.insert(t);else{var a=i(e.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(t)}return t}var u,d=(u=[],function(e,t){return u[e]=t,u.filter(Boolean).join("\n")});function f(e,t,n,r){var o=n?"":r.media?"@media ".concat(r.media," {").concat(r.css,"}"):r.css;if(e.styleSheet)e.styleSheet.cssText=d(t,o);else{var i=document.createTextNode(o),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(i,a[t]):e.appendChild(i)}}function p(e,t,n){var r=n.css,o=n.media,i=n.sourceMap;if(o?e.setAttribute("media",o):e.removeAttribute("media"),i&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleSheet)e.styleSheet.cssText=r;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(r))}}var h=null,b=0;function v(e,t){var n,r,o;if(t.singleton){var i=b++;n=h||(h=c(t)),r=f.bind(null,n,i,!1),o=f.bind(null,n,i,!0)}else n=c(t),r=p.bind(null,n,t),o=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)};return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else o()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=o());var n=l(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var r=0;r<n.length;r++){var o=s(n[r]);a[o].references--}for(var i=l(e,t),c=0;c<n.length;c++){var u=s(n[c]);0===a[u].references&&(a[u].updater(),a.splice(u,1))}n=i}}}},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n=e[1]||"",r=e[3];if(!r)return n;if(t&&"function"==typeof btoa){var o=(a=r,s=btoa(unescape(encodeURIComponent(JSON.stringify(a)))),l="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),"/*# ".concat(l," */")),i=r.sources.map((function(e){return"/*# sourceURL=".concat(r.sourceRoot).concat(e," */")}));return[n].concat(i).concat([o]).join("\n")}var a,s,l;return[n].join("\n")}(t,e);return t[2]?"@media ".concat(t[2],"{").concat(n,"}"):n})).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},o=0;o<this.length;o++){var i=this[o][0];null!=i&&(r[i]=!0)}for(var a=0;a<e.length;a++){var s=e[a];null!=s[0]&&r[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="(".concat(s[2],") and (").concat(n,")")),t.push(s))}},t}},function(e,t,n){var r=n(0),o=n(3);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var i={insert:"head",singleton:!1};r(o,i);e.exports=o.locals||{}},function(e,t,n){(e.exports=n(1)(!1)).push([e.i,"body{background-color:red}",""])},function(e,t,n){var r=n(0),o=n(5);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[e.i,o,""]]);var i={insert:"head",singleton:!1};r(o,i);e.exports=o.locals||{}},function(e,t,n){(e.exports=n(1)(!1)).push([e.i,".install-alert__wrapper{position:fixed;top:0;left:0;right:0;bottom:0;z-index:2000;display:flex;align-items:center;justify-content:center;animation:fadeIn .3s ease-out}.install-alert__mask{position:absolute;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.5);backdrop-filter:blur(2px);animation:fadeIn .3s ease-out}.install-alert{position:relative;width:90%;max-width:480px;background-color:#fff;border-radius:8px;box-shadow:0 4px 24px rgba(0,0,0,.15);overflow:hidden;animation:slideIn .3s ease-out}.install-alert__header{padding:20px 24px 16px;border-bottom:1px solid #f0f0f0;display:flex;align-items:center;justify-content:space-between}.install-alert__title{margin:0;font-size:18px;font-weight:600;color:#2a7fff;line-height:1.4}.install-alert__close{width:24px;height:24px;padding:0;border:none;background:transparent;cursor:pointer;border-radius:4px;display:flex;align-items:center;justify-content:center;transition:background-color .2s ease}.install-alert__close:hover{background-color:#f5f5f5}.install-alert__close span{font-size:24px;line-height:1;color:#909399;display:block}.install-alert__body{padding:24px}.install-alert__message{margin:0;font-size:14px;line-height:1.6;color:#303133;text-align:center}.install-alert__footer{padding:0 24px 24px;display:flex;justify-content:center}.install-alert__btn{padding:10px 24px;border-radius:4px;font-size:14px;font-weight:500;cursor:pointer;transition:all .2s ease;border:none;outline:none;box-shadow:0 2px 4px rgba(0,0,0,.1)}.install-alert__btn--primary{background-color:#2a7fff;color:#fff}.install-alert__btn--primary:hover{background-color:#4096ff;box-shadow:0 4px 8px rgba(42,127,255,.3);transform:translateY(-1px)}.install-alert__btn--primary:active{transform:translateY(0);box-shadow:0 2px 4px rgba(42,127,255,.2)}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes slideIn{from{opacity:0;transform:translateY(-20px) scale(0.95)}to{opacity:1;transform:translateY(0) scale(1)}}",""])},function(e,t,n){"use strict";n.r(t),n.d(t,"isExtensionInstalled",(function(){return i})),n.d(t,"syncPosts",(function(){return a})),n.d(t,"syncImages",(function(){return s}));n(2),n(4);var r=new class{constructor(){this.instance=null,this.installUrl="https://www.yuque.com/montisan/iikt7r/ggo5kbe4vehidpp3"}show(){if(this.instance)return;const e=this.createAlert();document.body.appendChild(e),this.instance=e,this.bindEvents(e)}createAlert(){const e=document.createElement("div");return e.className="install-alert__wrapper",e.innerHTML='\n <div class="install-alert__mask"></div>\n <div class="install-alert">\n <div class="install-alert__header">\n <h3 class="install-alert__title">提示</h3>\n <button class="install-alert__close" type="button" aria-label="关闭">\n <span>×</span>\n </button>\n </div>\n <div class="install-alert__body">\n <p class="install-alert__message">请先安装「公众账号助手」浏览器扩展后,刷新页面重试。</p>\n </div>\n <div class="install-alert__footer">\n <button class="install-alert__btn install-alert__btn--primary">去安装</button>\n </div>\n </div>\n ',e}bindEvents(e){const t=e.querySelector(".install-alert__mask"),n=e.querySelector(".install-alert__close"),r=e.querySelector(".install-alert__btn--primary"),o=()=>{this.hide()},i=()=>{window.open(this.installUrl,"_blank"),this.hide()};t.addEventListener("click",o),n.addEventListener("click",o),r.addEventListener("click",i);const a=e=>{"Escape"===e.key&&(o(),document.removeEventListener("keydown",a))};document.addEventListener("keydown",a),e._eventListeners={mask:{event:"click",handler:o},closeBtn:{event:"click",handler:o},installBtn:{event:"click",handler:i},esc:{event:"keydown",handler:a,target:document}}}hide(){if(!this.instance)return;const e=this.instance._eventListeners;e&&Object.values(e).forEach(({target:e=this.instance,event:t,handler:n})=>{e.removeEventListener(t,n)}),this.instance.parentNode.removeChild(this.instance),this.instance=null}};function o(){return"undefined"!=typeof window&&window.WeAccountsBot}function i(){return o()}function a(e){o()?window.WeAccountsBot.syncPosts(e):r.show()}function s(e){o()?window.WeAccountsBot.syncImages(e):r.show()}}])}));
|