xiaoyuan-assistant 0.5.47 → 0.5.48
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 +6 -0
- package/README.md +4 -0
- package/XIAOYUAN-BUSINESS-FLOW.md +5 -0
- package/package.json +1 -1
- package/src/components/XiaoyuanAssistant.vue +10 -3
- package/src/index.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -397,3 +397,9 @@ ls -lh /mnt/data/xiaoyuan-assistant-siliconflow-v0.5.29.zip
|
|
|
397
397
|
- 组件内部改为直接从共享 runtime context 获取 `manager / speech / options`。
|
|
398
398
|
- 保留对外 `useXiaoyuan()` API,不改变 `app.use(Xiaoyuan, ...)` 使用方式。
|
|
399
399
|
- 修复部分 Vite/NPM 环境下出现 `请先在 main.js 中 app.use(Xiaoyuan)` 的误报。
|
|
400
|
+
## v0.5.48
|
|
401
|
+
|
|
402
|
+
- 修复 Vue3 + Vite/NPM 场景下 `useXiaoyuan()` 偶发提示“请先在 main.js 中 app.use(Xiaoyuan)”的问题。
|
|
403
|
+
- `XiaoyuanAssistant.vue` 改为优先通过 `app.provide('xiaoyuan', runtime)` 获取运行时,避免 NPM 重复依赖/重复模块实例导致 singleton 不一致。
|
|
404
|
+
- `useXiaoyuan()` 对外返回 `runtime.api`,可直接调用 `registerData`、`registerFunction`、`setContext` 等 API。
|
|
405
|
+
|
package/README.md
CHANGED
|
@@ -1227,3 +1227,8 @@ AI 分析开始提示音与数据获取/模型分析并行;多个数据源采
|
|
|
1227
1227
|
5. Vue 渲染组件时直接从共享 context 读取 runtime,不再反向依赖入口 `index.js`。
|
|
1228
1228
|
|
|
1229
1229
|
这样可以避免 NPM/Vite 构建场景下 singleton 尚未可见而触发“请先在 main.js 中 app.use(Xiaoyuan)”的误报。
|
|
1230
|
+
|
|
1231
|
+
|
|
1232
|
+
## v0.5.48 运行时注入修复
|
|
1233
|
+
- 组件内部通过 Vue `app.provide('xiaoyuan', runtime)` 获取运行时,不再依赖可能被重复打包的模块级 singleton。
|
|
1234
|
+
- `useXiaoyuan()` 返回公开 API 对象,直接支持注册数据、注册函数、设置上下文等调用。
|
package/package.json
CHANGED
|
@@ -105,10 +105,17 @@
|
|
|
105
105
|
</template>
|
|
106
106
|
|
|
107
107
|
<script setup>
|
|
108
|
-
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
109
|
-
import { useXiaoyuanSingleton } from '../context.js'
|
|
108
|
+
import { computed, inject, nextTick, onBeforeUnmount, onMounted, ref, getCurrentInstance } from 'vue'
|
|
110
109
|
|
|
111
|
-
|
|
110
|
+
// 使用 Vue app.provide 的字符串 key 获取运行时,避免 NPM 被重复打包/解析时
|
|
111
|
+
// context.js 出现多份 singleton 导致‘请先 app.use(Xiaoyuan)’误报。
|
|
112
|
+
const runtime = inject('xiaoyuan', null) || getCurrentInstance()?.appContext.config.globalProperties.$xiaoyuan
|
|
113
|
+
|
|
114
|
+
if (!runtime) {
|
|
115
|
+
throw new Error('请先在 main.js 中 app.use(Xiaoyuan)')
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const { manager, speech, options } = runtime
|
|
112
119
|
const wakeWord = options.wakeWord || '你好小园'
|
|
113
120
|
const autoCollapseMs = options.autoCollapseMs ?? 0
|
|
114
121
|
|
package/src/index.js
CHANGED
|
@@ -9,7 +9,9 @@ import { HewoyiTTSProvider } from './voice/hewoyi.js'
|
|
|
9
9
|
import { KEY, getXiaoyuanSingleton, setXiaoyuanSingleton } from './context.js'
|
|
10
10
|
|
|
11
11
|
export function useXiaoyuan() {
|
|
12
|
-
|
|
12
|
+
const runtime = getXiaoyuanSingleton()
|
|
13
|
+
if (!runtime) throw new Error('请先在 main.js 中 app.use(Xiaoyuan)')
|
|
14
|
+
return runtime.api
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
const Xiaoyuan = {
|