@zhin.js/core 1.0.8 → 1.0.9

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +28 -12
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @zhin.js/core
2
2
 
3
+ ## 1.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - c490260: fix: 更新脚手架结构,优化包依赖
8
+
3
9
  ## 1.0.8
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -19,16 +19,27 @@ Zhin 机器人框架核心包,基于 HMR(热模块替换)系统构建的
19
19
  应用核心类,继承自 `HMR<Plugin>`:
20
20
 
21
21
  ```typescript
22
- import { createApp } from '@zhin.js/core'
22
+ import { App } from '@zhin.js/core'
23
+
24
+ // 直接使用 App 类创建实例
25
+ const app = new App('./zhin.config.ts')
26
+
27
+ // 启动应用
28
+ await app.start()
29
+ ```
30
+
31
+ 或者使用主包的便捷方法:
32
+
33
+ ```typescript
34
+ import { createApp } from 'zhin.js'
23
35
 
24
36
  // 创建应用实例
25
37
  const app = await createApp({
26
38
  plugin_dirs: ['./plugins'],
27
39
  plugins: ['my-plugin'],
28
40
  bots: [{
29
- context: 'onebot11',
30
- name: 'my-bot',
31
- url: 'ws://localhost:8080'
41
+ context: 'process',
42
+ name: 'my-bot'
32
43
  }],
33
44
  debug: true
34
45
  })
@@ -337,19 +348,24 @@ addMiddleware(async (message, next) => {
337
348
 
338
349
  ```typescript
339
350
  // zhin.config.ts
340
- export default {
341
- plugin_dirs: ['./plugins', './node_modules'],
342
- plugins: ['my-plugin'],
351
+ import { defineConfig } from 'zhin.js'
352
+
353
+ export default defineConfig({
354
+ database: {
355
+ dialect: 'sqlite',
356
+ filename: './data/bot.db'
357
+ },
358
+ plugin_dirs: ['./src/plugins', 'node_modules', 'node_modules/@zhin.js'],
359
+ plugins: ['http', 'console', 'adapter-process'],
343
360
  bots: [
344
361
  {
345
- context: 'onebot11',
346
- name: 'bot1',
347
- url: 'ws://localhost:8080',
348
- access_token: 'your-token'
362
+ context: 'process',
363
+ name: 'console-bot'
349
364
  }
350
365
  ],
366
+ log_level: 1,
351
367
  debug: process.env.NODE_ENV === 'development'
352
- }
368
+ })
353
369
  ```
354
370
 
355
371
  ## 开发工具
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/core",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Zhin机器人核心框架",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",