@weaccountsbot/sync 0.1.1
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/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/index.d.ts +160 -0
- package/dist/index.js +5 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WeAccountsBot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 同步到微信公众号的文章数据结构
|
|
3
|
+
*/
|
|
4
|
+
export interface SyncPost {
|
|
5
|
+
/**
|
|
6
|
+
* 文章标题
|
|
7
|
+
* @type {string}
|
|
8
|
+
* @required
|
|
9
|
+
*/
|
|
10
|
+
title: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 文章摘要
|
|
14
|
+
* @type {string}
|
|
15
|
+
* @optional
|
|
16
|
+
*/
|
|
17
|
+
summary?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 文章封面图 URL
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @optional
|
|
23
|
+
*/
|
|
24
|
+
cover?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 文章作者
|
|
28
|
+
* @type {string}
|
|
29
|
+
* @optional
|
|
30
|
+
*/
|
|
31
|
+
author?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 文章 HTML 内容
|
|
35
|
+
* @type {string}
|
|
36
|
+
* @optional
|
|
37
|
+
*/
|
|
38
|
+
html?: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 文章 Markdown 内容
|
|
42
|
+
* @type {string}
|
|
43
|
+
* @optional
|
|
44
|
+
*/
|
|
45
|
+
markdown?: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 文章自定义样式
|
|
49
|
+
* @type {string}
|
|
50
|
+
* @optional
|
|
51
|
+
*/
|
|
52
|
+
cssText?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 同步到微信公众号的图片数据结构
|
|
57
|
+
*/
|
|
58
|
+
export interface SyncImage {
|
|
59
|
+
/**
|
|
60
|
+
* 图片 URL 地址
|
|
61
|
+
* @type {string}
|
|
62
|
+
* @required
|
|
63
|
+
*/
|
|
64
|
+
url: string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 图片名称
|
|
68
|
+
* @type {string}
|
|
69
|
+
* @optional
|
|
70
|
+
*/
|
|
71
|
+
name?: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 图片格式(如: jpeg, png, gif 等)
|
|
75
|
+
* @type {string}
|
|
76
|
+
* @optional
|
|
77
|
+
*/
|
|
78
|
+
format?: string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 图片大小(如: "1024KB")
|
|
82
|
+
* @type {string}
|
|
83
|
+
* @optional
|
|
84
|
+
*/
|
|
85
|
+
size?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 公众账号助手浏览器扩展接口定义
|
|
90
|
+
* 用于与浏览器扩展进行通信,实现文章和图片的同步功能
|
|
91
|
+
*/
|
|
92
|
+
export interface WeAccountsBot {
|
|
93
|
+
/**
|
|
94
|
+
* 同步文章到微信公众号后台
|
|
95
|
+
* @param {SyncPost[]} posts - 要同步的文章数组
|
|
96
|
+
* @returns {void}
|
|
97
|
+
*/
|
|
98
|
+
syncPosts(posts: SyncPost[]): void;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 同步图片到微信公众号素材库
|
|
102
|
+
* @param {SyncImage[]} images - 要同步的图片数组
|
|
103
|
+
* @returns {void}
|
|
104
|
+
*/
|
|
105
|
+
syncImages(images: SyncImage[]): void;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 扩展全局 Window 接口
|
|
110
|
+
* 添加 WeAccountsBot 属性,用于访问浏览器扩展实例
|
|
111
|
+
*/
|
|
112
|
+
declare global {
|
|
113
|
+
interface Window {
|
|
114
|
+
/**
|
|
115
|
+
* 公众账号助手浏览器扩展实例
|
|
116
|
+
* @type {WeAccountsBot | undefined}
|
|
117
|
+
*/
|
|
118
|
+
WeAccountsBot?: WeAccountsBot;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 同步文章到微信公众号
|
|
124
|
+
*
|
|
125
|
+
* 如果浏览器已安装「公众账号助手」扩展,则调用扩展的同步功能;
|
|
126
|
+
* 如果未安装扩展,则会显示友好的安装提示弹窗。
|
|
127
|
+
*
|
|
128
|
+
* @param {SyncPost[]} posts - 要同步的文章数组
|
|
129
|
+
* @returns {void}
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* syncPosts([{
|
|
133
|
+
* title: "我的第一篇文章",
|
|
134
|
+
* summary: "这是文章摘要",
|
|
135
|
+
* html: "<p>文章内容</p>",
|
|
136
|
+
* cover: "https://example.com/cover.jpg"
|
|
137
|
+
* }]);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export function syncPosts(posts: SyncPost[]): void;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 同步图片到微信公众号素材库
|
|
144
|
+
*
|
|
145
|
+
* 如果浏览器已安装「公众账号助手」扩展,则调用扩展的同步功能;
|
|
146
|
+
* 如果未安装扩展,则会显示友好的安装提示弹窗。
|
|
147
|
+
*
|
|
148
|
+
* @param {SyncImage[]} images - 要同步的图片数组
|
|
149
|
+
* @returns {void}
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* syncImages([{
|
|
153
|
+
* url: "https://example.com/image.jpg",
|
|
154
|
+
* name: "示例图片",
|
|
155
|
+
* format: "jpeg",
|
|
156
|
+
* size: "1024KB"
|
|
157
|
+
* }]);
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export function syncImages(images: SyncImage[]): void;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* we-accounts-extension-sdk v0.1.1
|
|
3
|
+
*
|
|
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,d="".concat(l," ").concat(c);n[l]=c+1;var u=s(d),f={css:i[1],media:i[2],sourceMap:i[3]};-1!==u?(a[u].references++,a[u].updater(f)):a.push({identifier:d,updater:v(f,t),references:1}),r.push(d)}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 d,u=(d=[],function(e,t){return d[e]=t,d.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=u(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 d=s(n[c]);0===a[d].references&&(a[d].updater(),a.splice(d,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,"syncPosts",(function(){return i})),n.d(t,"syncImages",(function(){return a}));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(e){o()?window.WeAccountsBot.syncPosts(e):r.show()}function a(e){o()?window.WeAccountsBot.syncImages(e):r.show()}}])}));
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@weaccountsbot/sync",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Sync posts to WeChat official accounts.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/WeAccountsBot/"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/WeAccountsBot//issues",
|
|
13
|
+
"homepage": "https://github.com/WeAccountsBot/#readme",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "cross-env NODE_ENV=production webpack --config scripts/webpack.config.js",
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./*": [
|
|
30
|
+
"./*"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"copy-webpack-plugin": "^6.4.1",
|
|
35
|
+
"cross-env": "^7.0.3",
|
|
36
|
+
"css-loader": "3.0.0",
|
|
37
|
+
"file-loader": "^2.0.0",
|
|
38
|
+
"mini-css-extract-plugin": "0.8.0",
|
|
39
|
+
"sass": "1.26.8",
|
|
40
|
+
"sass-loader": "8.0.2",
|
|
41
|
+
"style-loader": "^1.0.0",
|
|
42
|
+
"url-loader": "^1.1.2",
|
|
43
|
+
"webpack": "^4.46.0",
|
|
44
|
+
"webpack-cli": "^3.3.12"
|
|
45
|
+
},
|
|
46
|
+
"presets": [
|
|
47
|
+
"@babel/react",
|
|
48
|
+
"@babel/env"
|
|
49
|
+
],
|
|
50
|
+
"dependencies": {},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public",
|
|
53
|
+
"registry": "https://registry.npmjs.org"
|
|
54
|
+
}
|
|
55
|
+
}
|