diff --git a/env/.env b/env/.env
index eb9419d..ea7f3de 100644
--- a/env/.env
+++ b/env/.env
@@ -2,7 +2,9 @@ VITE_APP_TITLE = '六纬中考通'
VITE_APP_PORT = 9000
VITE_UNI_APPID = 'H57F2ACE4'
-VITE_WX_APPID = 'wx4b925e36c17dd54a'
+# VITE_WX_APPID = 'wxc48ad15d58a3e417' 六纬中考通
+# VITE_WX_APPID = 'wx4b925e36c17dd54a' 六纬裂变
+VITE_WX_APPID = 'wxc48ad15d58a3e417'
# h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base
# https://uniapp.dcloud.net.cn/collocation/manifest.html#h5-router
diff --git a/pages.config.ts b/pages.config.ts
index 074c154..5d9649c 100644
--- a/pages.config.ts
+++ b/pages.config.ts
@@ -8,6 +8,10 @@ export default defineUniPages({
navigationBarBackgroundColor: '#FFFFFF',
navigationBarTextStyle: 'black',
backgroundColor: '#FFFFFF',
+ // 全局注册微信原生组件(仅 mp-weixin 编译器会读取此字段)
+ usingComponents: {
+ 'markdown-preview': '/wxcomponents/agent-ui/wd-markdown/index',
+ },
},
easycom: {
autoscan: true,
diff --git a/src/pages-ai/ai/index.vue b/src/pages-ai/ai/index.vue
new file mode 100644
index 0000000..702243f
--- /dev/null
+++ b/src/pages-ai/ai/index.vue
@@ -0,0 +1,292 @@
+
+
+
+
+
+
+
+ {{ agentConfig.botName }}
+
+
+ 清空对话
+
+
+
+
+
+
+
+
+
+
+ 你可以试试这样问:
+
+
+
+ {{ q }}
+
+
+
+
+
+
+
+
+
+
+
+
+ 你可能还想问:
+
+
+ {{ q }}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages-ai/components/AgentInput.vue b/src/pages-ai/components/AgentInput.vue
new file mode 100644
index 0000000..5c3666c
--- /dev/null
+++ b/src/pages-ai/components/AgentInput.vue
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+ 发送
+
+
+ 停止
+
+
+
+
+
+
+
+ 清
+
+
+
+
+
+
+
diff --git a/src/pages-ai/components/AgentMessage.vue b/src/pages-ai/components/AgentMessage.vue
new file mode 100644
index 0000000..6bd6185
--- /dev/null
+++ b/src/pages-ai/components/AgentMessage.vue
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+ AI
+
+
+
+
+
+
+
+
+ {{ props.message.content }}
+
+
+
+
+
+
+ {{ props.message.content || (props.message.pending ? '...' : '') }}
+
+
+
+
+ ▍
+
+
+
+
+ 生成失败,点击重试
+
+
+
+
+
+ U
+
+
+
+
+
diff --git a/src/pages-ai/components/agent-config.ts b/src/pages-ai/components/agent-config.ts
new file mode 100644
index 0000000..0aef16b
--- /dev/null
+++ b/src/pages-ai/components/agent-config.ts
@@ -0,0 +1,50 @@
+// AI Agent 相关运行时配置(页面、组件共享)
+
+export interface AgentConfig {
+ /** 微信云开发环境 ID,用于 wx.cloud.init */
+ cloudEnvId: string
+ /** Agent ID,对应 wx.cloud.extend.AI.bot.sendMessage 的 botId */
+ botId: string
+ /** 首屏欢迎语 */
+ welcomeMsg: string
+ /** 输入框 placeholder */
+ placeholder: string
+ /** 显示在 AI 头像位置的图标 / 文字 */
+ botName: string
+ /** 默认推荐问题,点击后直接发送 */
+ initQuestions: string[]
+}
+
+export interface ModelConfig {
+ /** 模型 provider,如 'cloudbase' / 'youtu' / 'hunyuan' */
+ modelProvider: string
+ /** 具体的模型 ID */
+ quickResponseModel: string
+ /** logo 图,可选 */
+ logo: string
+}
+
+export const defaultAgentConfig: AgentConfig = {
+ cloudEnvId: 'cloud1-d3g5q6bq61a240786',
+ botId: 'agent-wxai-4gl75um61026324f',
+ welcomeMsg: '你好,我是 AI 助手,有什么可以帮你?',
+ placeholder: '输入你的问题',
+ botName: 'AI 助手',
+ initQuestions: [
+ '帮我介绍一下志愿填报流程',
+ '中考分数线怎么查?',
+ '推荐几所适合的高中',
+ ],
+}
+
+export const defaultModelConfig: ModelConfig = {
+ modelProvider: 'youtu-intent-pro',
+ quickResponseModel: '',
+ logo: '',
+}
+
+export function generateMessageId() {
+ const timestamp = Date.now().toString().slice(-8)
+ const random = Math.floor(Math.random() * 10000).toString().padStart(4, '0')
+ return `${timestamp}${random}`
+}
diff --git a/src/pages-ai/components/agent-service.ts b/src/pages-ai/components/agent-service.ts
new file mode 100644
index 0000000..9ff2646
--- /dev/null
+++ b/src/pages-ai/components/agent-service.ts
@@ -0,0 +1,142 @@
+// 与 wx.cloud.extend.AI.bot 通讯的服务层
+// 把流式接收逻辑收敛到一个 streamMessage 函数,UI 只负责消费 onDelta
+
+import type { AiMessage } from '@/store/ai'
+import { generateMessageId } from './agent-config'
+
+interface BotEventData {
+ type: string
+ delta?: string
+ message?: string
+ [key: string]: unknown
+}
+
+export interface SendMessageOptions {
+ botId: string
+ threadId: string
+ /** 历史消息(最近若干轮),按 wx.cloud.extend.AI.bot 协议传 */
+ history: AiMessage[]
+ /** 当前用户输入 */
+ prompt: string
+ /** 流式增量回调 */
+ onDelta: (delta: string) => void
+ /** 错误回调,会拿到服务端返回的 message 字段 */
+ onError?: (message: string) => void
+}
+
+export async function streamMessage(options: SendMessageOptions): Promise {
+ const { botId, threadId, history, prompt, onDelta, onError } = options
+
+ // wx.cloud.extend.AI.bot 协议要求传入完整 messages 列表
+ // 这里把 store 里的历史拼到一起,最后追加当前用户消息
+ const messages = [
+ ...history
+ .filter(m => !m.error && (m.role === 'user' || m.role === 'assistant'))
+ .map(m => ({
+ id: m.id,
+ role: m.role,
+ content: m.content,
+ })),
+ {
+ id: generateMessageId(),
+ role: 'user',
+ content: prompt,
+ },
+ ]
+
+ // #ifdef MP-WEIXIN
+ // @ts-expect-error wx.cloud.extend 由微信小程序基础库注入
+ const res = await wx.cloud.extend.AI.bot.sendMessage({
+ data: {
+ botId,
+ threadId,
+ runId: `run_id_${generateMessageId()}`,
+ messages,
+ tools: [],
+ context: [],
+ state: {},
+ forwardedProps: {},
+ },
+ })
+
+ let response = ''
+ for await (const event of res.eventStream) {
+ let data: BotEventData
+ try {
+ data = JSON.parse(event.data) as BotEventData
+ }
+ catch {
+ continue
+ }
+ switch (data.type) {
+ case 'TEXT_MESSAGE_CONTENT':
+ if (data.delta) {
+ response += data.delta
+ onDelta(data.delta)
+ }
+ break
+ case 'RUN_ERROR':
+ onError?.(data.message || '请求出错,请稍后再试')
+ throw new Error(data.message || 'RUN_ERROR')
+ case 'RUN_FINISHED':
+ break
+ }
+ }
+
+ return response
+ // #endif
+
+ // #ifndef MP-WEIXIN
+ throw new Error('AI 助手仅在微信小程序内可用')
+ // #endif
+}
+
+interface RecommendOptions {
+ botId: string
+ /** 最近一对 user/assistant 消息,用于上下文 */
+ lastPair: { role: 'user' | 'assistant', content: string }[]
+ /** 触发追问的用户原问题 */
+ prompt: string
+ /** 最多返回多少条 */
+ max?: number
+ /** 流式返回时增量更新(用来做"边收边渲染"),可选 */
+ onProgress?: (questions: string[]) => void
+}
+
+/**
+ * 在一轮对话结束后,调用 getRecommendQuestions 获取追问建议。
+ * 取决于 agent 后台是否开启"智能体追问"。
+ */
+export async function fetchRecommendQuestions(options: RecommendOptions): Promise {
+ const { botId, lastPair, prompt, max = 3, onProgress } = options
+
+ // #ifdef MP-WEIXIN
+ // @ts-expect-error wx.cloud.extend 由微信小程序基础库注入
+ const res = await wx.cloud.extend.AI.bot.getRecommendQuestions({
+ data: {
+ botId,
+ history: lastPair.map(item => ({
+ role: item.role,
+ content: item.content,
+ })),
+ msg: prompt,
+ agentSetting: '',
+ introduction: '',
+ name: '',
+ },
+ })
+
+ let buffer = ''
+ for await (const chunk of res.textStream) {
+ buffer += chunk
+ const questions = buffer.split('\n').map(s => s.trim()).filter(Boolean).slice(0, max)
+ onProgress?.(questions)
+ }
+
+ return buffer.split('\n').map(s => s.trim()).filter(Boolean).slice(0, max)
+ // #endif
+
+ // #ifndef MP-WEIXIN
+ return []
+ // #endif
+}
diff --git a/src/pages-fg/login/login.vue b/src/pages-fg/login/login.vue
index e89df7b..0555cca 100644
--- a/src/pages-fg/login/login.vue
+++ b/src/pages-fg/login/login.vue
@@ -1,14 +1,13 @@
-
+
diff --git a/src/pages-sub/demo/index.vue b/src/pages-sub/demo/index.vue
index e0eb3eb..989f742 100644
--- a/src/pages-sub/demo/index.vue
+++ b/src/pages-sub/demo/index.vue
@@ -18,11 +18,14 @@ function navigateToVideoFn() {
}
onLoad(() => {
- uni.getChannelsLiveInfo({
+ uni.getChannelsLiveNoticeInfo({
finderUserName: 'sphju9MCfZetYHP',
success: (res) => {
console.log('res', res)
},
+ fail: (res) => {
+ console.log(res)
+ },
})
})
diff --git a/src/pages-sub/information/middleDetail.vue b/src/pages-sub/information/middleDetail.vue
index bcf01ac..6944ffe 100644
--- a/src/pages-sub/information/middleDetail.vue
+++ b/src/pages-sub/information/middleDetail.vue
@@ -1,39 +1,47 @@
-
- {{ newsDetail.title }}
- 发布时间: {{ newsDetail.publishTime }}
-
-
-
-
-
-
-
-
+
+
+ {{ newsDetail.title }}
+
+ 发布时间: {{ newsDetail.publishTime }}
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/src/pages-sub/invite/jump.vue b/src/pages-sub/invite/jump.vue
index bdade0f..c31763c 100644
--- a/src/pages-sub/invite/jump.vue
+++ b/src/pages-sub/invite/jump.vue
@@ -1,22 +1,18 @@