yz-yuki-plugin 2.0.4-7 → 2.0.4-8

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/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # 2.0.4
2
+ * 增加splitHeight配置项,其他优化
2
3
  * 优化B站风控相关,新增bili_tiket参数
3
4
  * fix Repeated Instantiation Puppeteer
4
5
  * 优化获取B站登录ck
@@ -37,5 +37,11 @@ pushMsgMode: 1
37
37
  # 是否启用九宫格样式:默认 1 启用,0 不启用。此为最高优先级,九宫格为动态模式,特定大小/长宽比的图片资源将会动态启用九宫格/四宫格/无宫格样式。
38
38
  boxGrid: 1
39
39
 
40
- # B站动态卡片分页截图模式:默认 1 启用 0 不启用。启用,将会推送每条动态的全部内容;不启用,动态内容过长时候将只推送7500px长度的动态卡片,需关闭宫格模式。
40
+ # B站动态卡片分片截图模式:默认 1 启用 0 不启用。启用,将会推送每条动态的全部内容;不启用,动态内容过长时候将只推送noSplitHeight长度的动态卡片,需关闭宫格模式。
41
41
  isSplit: 1
42
+
43
+ # 动态卡片非分片模式下的截图高度,默认7500px(仅填数字,无需填入单位),请勿设置过大或过小。关闭分片截图时生效。
44
+ noSplitHeight: 7500
45
+
46
+ # 动态卡片分页截图高度,默认8000px(仅填数字,无需填入单位),请勿设置过大或过小。启用分片截图时生效。
47
+ splitHeight: 8000
@@ -37,5 +37,11 @@ pushMsgMode: 1
37
37
  # 是否启用九宫格样式:默认 1 启用,0 不启用。此为最高优先级,九宫格为动态模式,特定大小/长宽比的图片资源将会动态启用九宫格/四宫格/无宫格样式。
38
38
  boxGrid: 1
39
39
 
40
- # 微博动态卡片分页截图模式:默认 1 启用 0 不启用。启用,将会推送每条动态的全部内容;不启用,动态内容过长时候将只推送7500px长度的动态卡片,需关闭宫格模式。
40
+ # 微博动态卡片分片截图模式:默认 1 启用 0 不启用。启用,将会推送每条动态的全部内容;不启用,动态内容过长时候将只推送noSplitHeight长度的动态卡片,需关闭宫格模式。
41
41
  isSplit: 1
42
+
43
+ # 动态卡片非分片模式下的截图高度,默认7500px(仅填数字,无需填入单位),请勿设置过大或过小。关闭分片截图时生效。
44
+ noSplitHeight: 7500
45
+
46
+ # 动态卡片分页截图高度,默认8000px(仅填数字,无需填入单位),请勿设置过大或过小。启用分片截图时生效。
47
+ splitHeight: 8000
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
2
  import LogoText from './LogoText.js';
3
- import { _paths } from '../../utils/paths.js';
4
- import path from 'path';
3
+ import { createRequire } from '../../utils/paths.js';
5
4
 
6
5
  // Account
7
6
  // up账户组件
8
- const Bilibililogo = path.join(_paths.pluginResources, 'img/icon/dynamic/bilibili.svg');
9
- const Weibilogo = path.join(_paths.pluginResources, 'img/icon/dynamic/weibo.svg');
10
- const AccountCss = path.join(_paths.pluginResources, 'css/dynamic/Account.css');
7
+ const require = createRequire(import.meta.url);
8
+ const Bilibililogo = require('./../../../resources/img/icon/dynamic/bilibili.svg');
9
+ const Weibilogo = require('./../../../resources/img/icon/dynamic/weibo.svg');
10
+ const AccountCss = require('./../../../resources/css/dynamic/Account.css');
11
11
  const Account = ({ data }) => {
12
12
  const renderLogo = (logoSrc, className) => (React.createElement("img", { src: logoSrc, className: className, alt: "logo" }));
13
13
  return (React.createElement(React.Fragment, null,
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
- import { _paths } from '../../utils/paths.js';
3
- import path from 'path';
2
+ import { createRequire } from '../../utils/paths.js';
4
3
 
5
4
  // DynamicContent.tsx
6
- const ContentBoxGrid4Css = path.join(_paths.pluginResources, 'css/dynamic/Content.box.grid.4.css');
7
- const ContentBoxGrid9Css = path.join(_paths.pluginResources, 'css/dynamic/Content.box.grid.9.css');
8
- const ContentCss = path.join(_paths.pluginResources, 'css/dynamic/Content.css');
5
+ const require = createRequire(import.meta.url);
6
+ const ContentBoxGrid4Css = require('./../../resources/css/dynamic/Content.box.grid.4.css');
7
+ const ContentBoxGrid9Css = require('./../../resources/css/dynamic/Content.box.grid.9.css');
8
+ const ContentCss = require('./../../resources/css/dynamic/Content.css');
9
9
  const Content = ({ data }) => {
10
10
  const picItems = data.pics && (React.createElement("div", { className: 'pic-content' }, data.pics.map((item, index) => {
11
11
  if (item) {
@@ -1,15 +1,16 @@
1
1
  import React from 'react';
2
2
  import { ConfigController, BOT_NAME } from 'yunzai';
3
3
  import Config from '../../utils/config.js';
4
- import { _paths } from '../../utils/paths.js';
5
4
  import path from 'path';
5
+ import { _paths, createRequire } from '../../utils/paths.js';
6
6
 
7
7
  // Footer.tsx
8
+ const require = createRequire(import.meta.url);
8
9
  const botVersion = ConfigController.package?.version;
9
10
  const yukiPluginVersion = Config.getPackageJsonKey('version', path.join(_paths.pluginPath, 'package.json'));
10
- const bilibililogo = path.join(_paths.pluginResources, 'img/icon/dynamic/bilibili.svg');
11
- const weibilogo = path.join(_paths.pluginResources, 'img/icon/dynamic/weibo.svg');
12
- const FooterCss = path.join(_paths.pluginResources, 'css/dynamic/Footer.css');
11
+ const bilibililogo = require('./../../../resources/img/icon/dynamic/bilibili.svg');
12
+ const weibilogo = require('./../../../resources/img/icon/dynamic/weibo.svg');
13
+ const FooterCss = require('./../../../resources/css/dynamic/Footer.css');
13
14
  const Footer = ({ data }) => {
14
15
  return (React.createElement(React.Fragment, null,
15
16
  React.createElement("link", { rel: "stylesheet", href: FooterCss }),
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import Account from './Account.js';
3
3
  import Content from './Content.js';
4
- import { _paths } from '../../utils/paths.js';
5
- import path from 'path';
4
+ import { createRequire } from '../../utils/paths.js';
6
5
 
7
6
  // ForwardContent
8
7
  // 转发动态内容组件
9
- const ForwardContentCss = path.join(_paths.pluginResources, 'css/dynamic/ForwardContent.css');
8
+ const require = createRequire(import.meta.url);
9
+ const ForwardContentCss = require('./../../../resources/css/dynamic/ForwardContent.css');
10
10
  const ForwardContent = ({ data }) => (React.createElement(React.Fragment, null,
11
11
  React.createElement("link", { rel: "stylesheet", href: ForwardContentCss }),
12
12
  React.createElement("div", { className: "orig" },
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import { _paths } from '../../utils/paths.js';
3
- import path from 'path';
2
+ import { createRequire } from '../../utils/paths.js';
4
3
 
5
4
  // LogoText
6
5
  // Logo 文本组件
7
- const LogoTextCss = path.join(_paths.pluginResources, 'css/dynamic/LogoText.css');
6
+ const require = createRequire(import.meta.url);
7
+ const LogoTextCss = require('./../../../resources/css/dynamic/LogoText.css');
8
8
  const LogoText = ({ data }) => (React.createElement(React.Fragment, null,
9
9
  React.createElement("link", { rel: "stylesheet", href: LogoTextCss }),
10
10
  data.appName === 'bilibili' && (React.createElement("div", { className: "bilibili-logo-text" }, data.category)),
@@ -3,11 +3,11 @@ import Account from './Account.js';
3
3
  import Content from './Content.js';
4
4
  import ForwardContent from './ForwardContent.js';
5
5
  import Footer from './Footer.js';
6
- import { _paths } from '../../utils/paths.js';
7
- import path from 'path';
6
+ import { createRequire } from '../../utils/paths.js';
8
7
 
9
8
  // MainPage.tsx
10
- const MainPageCss = path.join(_paths.pluginResources, 'css/dynamic/MainPage.css');
9
+ const require = createRequire(import.meta.url);
10
+ const MainPageCss = require('./../../resources/css/dynamic/MainPage.css');
11
11
  function App({ data }) {
12
12
  return (React.createElement(React.Fragment, null,
13
13
  React.createElement("link", { rel: "stylesheet", href: MainPageCss }),
@@ -1,14 +1,15 @@
1
1
  import React from 'react';
2
2
  import { BOT_NAME, ConfigController } from 'yunzai';
3
3
  import Config from '../../utils/config.js';
4
- import { _paths } from '../../utils/paths.js';
5
4
  import path from 'path';
5
+ import { _paths, createRequire } from '../../utils/paths.js';
6
6
 
7
7
  //help.tsx
8
+ const require = createRequire(import.meta.url);
8
9
  const botVersion = ConfigController.package?.version;
9
10
  const yukiPluginVersion = Config.getPackageJsonKey('version', path.join(_paths.pluginPath, 'package.json'));
10
- const HelpCss = path.join(_paths.pluginResources, 'css/help/help.css');
11
- const iconPath = (iconName) => path.join(_paths.pluginResources, `img/icon/puplic/${iconName}.png`);
11
+ const HelpCss = require('./../../../resources/css/help/help.css');
12
+ const iconPath = (iconName) => require(`./../../../resources/img/icon/puplic/${iconName}.png`);
12
13
  function App({ data }) {
13
14
  return (React.createElement(React.Fragment, null,
14
15
  React.createElement("link", { rel: "stylesheet", href: HelpCss }),
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import { _paths } from '../../utils/paths.js';
3
- import path from 'path';
2
+ import { createRequire } from '../../utils/paths.js';
4
3
 
5
4
  // QrcodeLoginPage.tsx
6
- const LoginQrcodeCss = path.join(_paths.pluginResources, 'css/loginQrcode/Page.css');
5
+ const require = createRequire(import.meta.url);
6
+ const LoginQrcodeCss = require('./../../../resources/css/loginQrcode/Page.css');
7
7
  function App({ data }) {
8
8
  return (React.createElement(React.Fragment, null,
9
9
  React.createElement("link", { rel: "stylesheet", href: LoginQrcodeCss }),
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import { BOT_NAME, ConfigController } from 'yunzai';
3
3
  import Config from '../../utils/config.js';
4
- import { _paths } from '../../utils/paths.js';
5
4
  import path from 'path';
5
+ import { _paths, createRequire } from '../../utils/paths.js';
6
6
 
7
+ const require = createRequire(import.meta.url);
7
8
  const botVersion = ConfigController.package?.version;
8
9
  const yukiPluginVersion = Config.getPackageJsonKey('version', path.join(_paths.pluginPath, 'package.json'));
9
- const VersionCss = path.join(_paths.pluginResources, 'css/version/version.css');
10
+ const VersionCss = require('./../../../resources/css/version/version.css');
10
11
  function App({ data }) {
11
12
  return (React.createElement(React.Fragment, null,
12
13
  React.createElement("link", { rel: "stylesheet", href: VersionCss }),
@@ -178,7 +178,8 @@ class BiliTask {
178
178
  }
179
179
  let boxGrid = !!biliConfigData.boxGrid === false ? false : true; // 是否启用九宫格样式,默认为 true
180
180
  let isSplit = !!biliConfigData.isSplit === false ? false : true; // 是否启用分片截图,默认为 true
181
- let style = isSplit ? '' : '.unfold { height: 7500px; }'; // 不启用分片截图模式的样式
181
+ let style = isSplit ? '' : `.unfold { max-height: ${biliConfigData?.noSplitHeight ?? 7500}px; }`; // 不启用分片截图模式的样式
182
+ let splitHeight = biliConfigData?.splitHeight ?? 8000; // 分片截图高度,默认 8000, 单位 px,启用分片截图时生效
182
183
  const urlQrcodeData = await QRCode.toDataURL(extentData?.url);
183
184
  let renderData = this.buildRenderData(extentData, urlQrcodeData, boxGrid);
184
185
  const ScreenshotOptionsData = {
@@ -191,6 +192,7 @@ class BiliTask {
191
192
  quality: 98,
192
193
  },
193
194
  saveHtmlfile: false,
195
+ pageSplitHeight: splitHeight,
194
196
  };
195
197
  let imgs = await this.renderDynamicCard(uid, renderData, ScreenshotOptionsData);
196
198
  if (!imgs)
@@ -143,7 +143,8 @@ class WeiboTask {
143
143
  }
144
144
  let boxGrid = !!weiboConfigData.boxGrid === false ? false : true; // 是否启用九宫格样式,默认为 true
145
145
  let isSplit = !!weiboConfigData.isSplit === false ? false : true; // 是否启用分片截图,默认为 true
146
- let style = isSplit ? '' : '.unfold { height: 7500px; }'; // 不启用分片截图模式的样式
146
+ let style = isSplit ? '' : `.unfold { max-height: ${weiboConfigData?.noSplitHeight ?? 7500}px; }`; // 不启用分片截图模式的样式
147
+ let splitHeight = weiboConfigData?.splitHeight ?? 8000; // 分片截图高度,默认 8000, 单位 px,启用分片截图时生效
147
148
  const extentData = { ...data };
148
149
  const urlQrcodeData = await QRCode.toDataURL(extentData?.url);
149
150
  let renderData = this.buildRenderData(extentData, urlQrcodeData, boxGrid);
@@ -157,6 +158,7 @@ class WeiboTask {
157
158
  quality: 98,
158
159
  },
159
160
  saveHtmlfile: false,
161
+ pageSplitHeight: splitHeight,
160
162
  };
161
163
  let imgs = await this.renderDynamicCard(uid, renderData, ScreenshotOptionsData);
162
164
  if (!imgs)
@@ -8,3 +8,15 @@ export declare const _paths: {
8
8
  pluginResources: string;
9
9
  pluginName: string;
10
10
  };
11
+ /**
12
+ * 使用import.meta.url得到require
13
+ * @param basePath
14
+ * @returns
15
+ * 这并不是
16
+ * ***
17
+ * import { createRequire } from "module"
18
+ * ***
19
+ * 原型为
20
+ * new URL(path, import.meta.url).href
21
+ */
22
+ export declare const createRequire: (basePath: string) => (path: string) => string;
@@ -14,5 +14,26 @@ const _paths = {
14
14
  pluginResources: join(pluginPath, 'resources'), // yuki-plugin资源目录
15
15
  pluginName, // 插件所在文件夹名称
16
16
  };
17
+ /**
18
+ * 使用import.meta.url得到require
19
+ * @param basePath
20
+ * @returns
21
+ * 这并不是
22
+ * ***
23
+ * import { createRequire } from "module"
24
+ * ***
25
+ * 原型为
26
+ * new URL(path, import.meta.url).href
27
+ */
28
+ const createRequire = (basePath) => {
29
+ return (path) => {
30
+ if (process.platform === 'linux' || process.platform === 'android' || process.platform === 'darwin') {
31
+ return new URL(path, basePath).href.replace(/^file:\/\//, '');
32
+ }
33
+ else {
34
+ return new URL(path, basePath).href.replace(/^file:\/\/\//, ''); // windows
35
+ }
36
+ };
37
+ };
17
38
 
18
- export { _paths, pluginName };
39
+ export { _paths, createRequire, pluginName };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yz-yuki-plugin",
3
- "version": "2.0.4-7",
3
+ "version": "2.0.4-8",
4
4
  "description": "优纪插件,yunzaijs 关于 微博推送、B站推送 等功能的拓展插件",
5
5
  "author": "snowtafir",
6
6
  "type": "module",