koishi-plugin-stock 1.0.9 → 1.0.10

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/README.md CHANGED
@@ -41,6 +41,9 @@ npm install koishi-plugin-stock
41
41
 
42
42
  ## 更新日志
43
43
 
44
+ ### v1.0.10
45
+ - 修复了"骑"指令,使用本地图片路径并返回base64编码的图片
46
+
44
47
  ### v1.0.9
45
48
  - 添加了"骑"指令,可返回本地图片
46
49
 
package/lib/index.js CHANGED
@@ -161,10 +161,17 @@ function apply(ctx, config) {
161
161
  return '您已被加入黑名单,无法使用此功能。';
162
162
  }
163
163
  try {
164
- // 使用Koishi的资源系统来访问本地图片
165
- const imagePath = './images/qi.jpeg';
166
- // 返回本地图片
167
- return `<img src="${imagePath}" />`;
164
+ // 读取本地图片文件并转换为base64
165
+ const fs = require('fs').promises;
166
+ const path = require('path');
167
+ // 构建图片的绝对路径
168
+ const imagePath = path.resolve(__dirname, '../images/qi.jpeg');
169
+ // 读取图片文件
170
+ const imageData = await fs.readFile(imagePath);
171
+ // 将图片数据转换为base64编码
172
+ const base64Image = imageData.toString('base64');
173
+ // 返回base64编码的图片
174
+ return `<img src="data:image/jpeg;base64,${base64Image}" />`;
168
175
  }
169
176
  catch (error) {
170
177
  console.error('获取骑图片失败:', error);
@@ -279,10 +286,17 @@ function apply(ctx, config) {
279
286
  return '您已被加入黑名单,无法使用此功能。';
280
287
  }
281
288
  try {
282
- // 使用Koishi的资源系统来访问本地图片
283
- const imagePath = './images/qi.jpeg';
284
- // 返回本地图片
285
- return `<img src="${imagePath}" />`;
289
+ // 读取本地图片文件并转换为base64
290
+ const fs = require('fs').promises;
291
+ const path = require('path');
292
+ // 构建图片的绝对路径
293
+ const imagePath = path.resolve(__dirname, '../images/qi.jpeg');
294
+ // 读取图片文件
295
+ const imageData = await fs.readFile(imagePath);
296
+ // 将图片数据转换为base64编码
297
+ const base64Image = imageData.toString('base64');
298
+ // 返回base64编码的图片
299
+ return `<img src="data:image/jpeg;base64,${base64Image}" />`;
286
300
  }
287
301
  catch (error) {
288
302
  console.error('获取骑图片失败:', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-stock",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "A Koishi plugin that fetches stock data and provides market analysis, including active market cap, stock alerts, limit-up board, and stock selection features with configurable blacklists for each command.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",