Compare commits
6 Commits
V1.1.0
...
d6c7ca7aec
| Author | SHA1 | Date | |
|---|---|---|---|
| d6c7ca7aec | |||
| 1408a97027 | |||
| d49bf738f8 | |||
| 8ea6546f04 | |||
| f70920a25c | |||
| d666dce813 |
@@ -24,6 +24,31 @@
|
|||||||
"theme-color-50": "#F0F8F3"
|
"theme-color-50": "#F0F8F3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nianhelper": {
|
||||||
|
"clientId": "11",
|
||||||
|
"appId": "wx6fcf7b3db3deee6c",
|
||||||
|
"name": "智念助手",
|
||||||
|
"placeholder": "快告诉智念助手您在想什么~",
|
||||||
|
"loginDesc": "您好,欢迎来到智念科技",
|
||||||
|
"logo": "https://one-feel-config-images-bucket.oss-cn-chengdu.aliyuncs.com/znjqzs.png",
|
||||||
|
"ipLargeImage": "https://oss.nianxx.cn/mp/static/version_101/zn/zn_large.png",
|
||||||
|
"ipLargeImageWidth": 395,
|
||||||
|
"ipLargeImageHeight": 335,
|
||||||
|
"ipLargeTotalFrames": 71,
|
||||||
|
"ipLargeColumns": 1,
|
||||||
|
"ipSmallImage": "https://oss.nianxx.cn/mp/static/version_101/dh/dh_small.png",
|
||||||
|
"ipSmallImageWidth": 128,
|
||||||
|
"ipSmallImageHeight": 128,
|
||||||
|
"ipSmallTotalFrames": 117,
|
||||||
|
"ipSmallColumns": 1,
|
||||||
|
"theme": {
|
||||||
|
"theme-color-800": "#174BB6",
|
||||||
|
"theme-color-700": "#145EE1",
|
||||||
|
"theme-color-500": "#2D91FF",
|
||||||
|
"theme-color-100": "#D9EEFF",
|
||||||
|
"theme-color-50": "#EEF8FF"
|
||||||
|
}
|
||||||
|
},
|
||||||
"duohua": {
|
"duohua": {
|
||||||
"clientId": "2",
|
"clientId": "2",
|
||||||
"appId": "wx23f86d809ae80259",
|
"appId": "wx23f86d809ae80259",
|
||||||
@@ -74,4 +99,4 @@
|
|||||||
"theme-color-50": "#EEF8FF"
|
"theme-color-50": "#EEF8FF"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"appid": "wx5e79df5996572539",
|
"appid": "wx6fcf7b3db3deee6c",
|
||||||
"compileType": "miniprogram",
|
"compileType": "miniprogram",
|
||||||
"libVersion": "3.8.10",
|
"libVersion": "3.8.10",
|
||||||
"packOptions": {
|
"packOptions": {
|
||||||
|
|||||||
@@ -44,11 +44,12 @@
|
|||||||
|
|
||||||
## 支持的客户端
|
## 支持的客户端
|
||||||
|
|
||||||
| 客户端名称 | 显示名称 | AppID |
|
| 客户端名称 | 显示名称 | AppID |
|
||||||
| ---------- | -------- | ------------------ |
|
| ------------ | -------- | ------------------ |
|
||||||
| `zhinian` | 智念 | wx5e79df5996572539 |
|
| `zhinian` | 智念 | wx5e79df5996572539 |
|
||||||
| `duohua` | 朵花 | wx23f86d809ae80259 |
|
| `duohua` | 朵花 | wx23f86d809ae80259 |
|
||||||
| `tianmu` | 天沐 | wx0be424e1d22065a9 |
|
| `tianmu` | 天沐 | wx0be424e1d22065a9 |
|
||||||
|
| `nianhelper` | 念念 | wx6fcf7b3db3deee6c |
|
||||||
|
|
||||||
## 使用方法
|
## 使用方法
|
||||||
|
|
||||||
@@ -58,6 +59,9 @@
|
|||||||
# 切换到智念客户端
|
# 切换到智念客户端
|
||||||
npm run switch-client zhinian
|
npm run switch-client zhinian
|
||||||
|
|
||||||
|
# 切换到念念助手客户端
|
||||||
|
npm run switch-client nianhelper
|
||||||
|
|
||||||
# 切换到朵花客户端
|
# 切换到朵花客户端
|
||||||
npm run switch-client duohua
|
npm run switch-client duohua
|
||||||
|
|
||||||
@@ -85,17 +89,14 @@ node scripts/update-appid.js tianmu
|
|||||||
## 更新的文件
|
## 更新的文件
|
||||||
|
|
||||||
1. **src/manifest.json**
|
1. **src/manifest.json**
|
||||||
|
|
||||||
- 更新 `mp-weixin.appid` 字段
|
- 更新 `mp-weixin.appid` 字段
|
||||||
- 保持文件中的注释不变
|
- 保持文件中的注释不变
|
||||||
|
|
||||||
2. **project.config.json**
|
2. **project.config.json**
|
||||||
|
|
||||||
- 更新根级别的 `appid` 字段
|
- 更新根级别的 `appid` 字段
|
||||||
- 保持 JSON 格式化
|
- 保持 JSON 格式化
|
||||||
|
|
||||||
3. **src/constant/base.js**
|
3. **src/constant/base.js**
|
||||||
|
|
||||||
- 更新 `getCurrentConfig()` 函数返回的客户端配置
|
- 更新 `getCurrentConfig()` 函数返回的客户端配置
|
||||||
|
|
||||||
4. **client-configs.json**
|
4. **client-configs.json**
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
class="checkbox-icon"
|
class="checkbox-icon"
|
||||||
:type="isChecked"
|
:type="isChecked"
|
||||||
:checked="isChecked"
|
:checked="isChecked"
|
||||||
:color="iconColor"
|
|
||||||
size="24"
|
size="24"
|
||||||
|
color="opacity"
|
||||||
/>
|
/>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</view>
|
</view>
|
||||||
@@ -28,11 +28,6 @@ const isChecked = computed(() => {
|
|||||||
return props.modelValue ? "checkbox-filled" : "circle";
|
return props.modelValue ? "checkbox-filled" : "circle";
|
||||||
});
|
});
|
||||||
|
|
||||||
// 计算图标颜色
|
|
||||||
const iconColor = computed(() => {
|
|
||||||
return props.modelValue ? "#1890FF" : "#00A6FF";
|
|
||||||
});
|
|
||||||
|
|
||||||
// 切换选中状态
|
// 切换选中状态
|
||||||
const onChange = () => {
|
const onChange = () => {
|
||||||
emit("update:modelValue", !props.modelValue);
|
emit("update:modelValue", !props.modelValue);
|
||||||
|
|||||||
@@ -5,5 +5,6 @@
|
|||||||
|
|
||||||
.checkbox-icon {
|
.checkbox-icon {
|
||||||
margin-right: 6px;
|
margin-right: 6px;
|
||||||
|
color: $theme-color-500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* 客户端配置管理模块
|
* 客户端配置管理模块
|
||||||
*
|
*
|
||||||
* 功能说明:
|
* 功能说明:
|
||||||
* 所有配置从根目录的 client-configs.json 文件中读取
|
* 所有配置从根目录的 client-configs.json 文件中读取
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 直接导入配置文件
|
// 直接导入配置文件
|
||||||
import rawConfigs from '../../client-configs.json' with { type: 'json' };
|
import rawConfigs from "../../client-configs.json" with { type: "json" };
|
||||||
|
|
||||||
// 所有用户端的配置 - 处理后的配置
|
// 所有用户端的配置 - 处理后的配置
|
||||||
export const CLIENT_CONFIGS = rawConfigs;
|
export const CLIENT_CONFIGS = rawConfigs;
|
||||||
|
|
||||||
// 获取当前用户端配置
|
// 获取当前用户端配置
|
||||||
export const getCurrentConfig = () => CLIENT_CONFIGS.zhinian;
|
export const getCurrentConfig = () => CLIENT_CONFIGS.nianhelper;
|
||||||
export const clientId = getCurrentConfig().clientId;
|
export const clientId = getCurrentConfig().clientId;
|
||||||
export const appId = getCurrentConfig().appId;
|
export const appId = getCurrentConfig().appId;
|
||||||
|
|
||||||
|
|
||||||
/// 客户端类型
|
/// 客户端类型
|
||||||
export const ClientType = {
|
export const ClientType = {
|
||||||
// 智念
|
// 智念
|
||||||
@@ -25,17 +24,21 @@ export const ClientType = {
|
|||||||
DUOHUA: "DUOHUA",
|
DUOHUA: "DUOHUA",
|
||||||
// 天沐
|
// 天沐
|
||||||
TIANMU: "TIANMU",
|
TIANMU: "TIANMU",
|
||||||
|
// 念念助手
|
||||||
|
NIANHELPER: "NIANHELPER",
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 获取当前客户端类型
|
/// 获取当前客户端类型
|
||||||
export const currentClientType = () => {
|
export const currentClientType = () => {
|
||||||
switch (getCurrentConfig().name) {
|
switch (getCurrentConfig().name) {
|
||||||
case '智念':
|
case "智念":
|
||||||
return ClientType.ZHINIAN;
|
return ClientType.ZHINIAN;
|
||||||
case '朵朵':
|
case "朵朵":
|
||||||
return ClientType.DUOHUA;
|
return ClientType.DUOHUA;
|
||||||
case '沐沐':
|
case "沐沐":
|
||||||
return ClientType.TIANMU;
|
return ClientType.TIANMU;
|
||||||
|
case "念念":
|
||||||
|
return ClientType.NIANHELPER;
|
||||||
default:
|
default:
|
||||||
return ClientType.ZHINIAN;
|
return ClientType.ZHINIAN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
朵花:wx23f86d809ae80259
|
朵花:wx23f86d809ae80259
|
||||||
*/
|
*/
|
||||||
"mp-weixin": {
|
"mp-weixin": {
|
||||||
"appid": "wx5e79df5996572539",
|
"appid": "wx6fcf7b3db3deee6c",
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": false,
|
"urlCheck": false,
|
||||||
"minified": true
|
"minified": true
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ const lookDetailAction = () => {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
});
|
});
|
||||||
|
|
||||||
uni.navigateTo({ url: `/pages/long-answer/index?streamId=${encodeURIComponent(streamId)}` });
|
// 传递 finished 参数,完成状态下不自动滚到底部
|
||||||
|
uni.navigateTo({ url: `/pages/long-answer/index?streamId=${encodeURIComponent(streamId)}&finished=${props.finish ? '1' : '0'}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- ✅ 滚动区域 -->
|
<!-- ✅ 滚动区域 -->
|
||||||
<scroll-view class="flex-full overflow-hidden" scroll-y :scroll-into-view="scrollIntoViewId" scroll-with-animation>
|
<scroll-view class="flex-full overflow-hidden chat-scroll" scroll-y :scroll-into-view="scrollIntoViewId" scroll-with-animation @scroll="onScroll" @touchstart="onTouchStart" @touchend="onTouchEnd" @touchcancel="onTouchEnd">
|
||||||
<view class="pt-12 px-12 pb-24 border-box">
|
<view class="pt-12 px-12 pb-24 border-box">
|
||||||
<!-- ✅ 答案内容,支持markdown -->
|
<!-- ✅ 内容,支持markdown -->
|
||||||
<ChatMarkdown :text="answerText" />
|
<ChatMarkdown :text="answerText" />
|
||||||
|
|
||||||
<!-- ✅ 底部锚点(必须存在) -->
|
<!-- ✅ 底部锚点(必须存在) -->
|
||||||
@@ -40,20 +40,91 @@ let unsubscribe = null;
|
|||||||
/** ✅ scroll-into-view 控制 */
|
/** ✅ scroll-into-view 控制 */
|
||||||
const scrollIntoViewId = ref("");
|
const scrollIntoViewId = ref("");
|
||||||
|
|
||||||
|
/** 滚动控制状态 */
|
||||||
|
const isNearBottom = ref(true);
|
||||||
|
const scrollViewHeight = ref(0);
|
||||||
|
const SCROLL_THRESHOLD = 150; // px
|
||||||
|
|
||||||
|
/** 用户交互状态,用户滚动/触摸时临时禁用自动滚动 */
|
||||||
|
const userInteracting = ref(false);
|
||||||
|
let interactionTimer = null;
|
||||||
|
|
||||||
|
/** 是否已完成(从 URL 参数判断),完成状态下不初始初自动滚到底部 */
|
||||||
|
let isFinishedOnInit = false;
|
||||||
|
|
||||||
/** ✅ 防抖 */
|
/** ✅ 防抖 */
|
||||||
let scrollTimer = null;
|
let scrollTimer = null;
|
||||||
|
|
||||||
function scrollToBottom() {
|
const measureScrollViewHeight = () => {
|
||||||
|
try {
|
||||||
|
// 使用 uni.createSelectorQuery 获取 scroll-view 的准确高度
|
||||||
|
uni.createSelectorQuery()
|
||||||
|
.select(".chat-scroll")
|
||||||
|
.boundingClientRect((rect) => {
|
||||||
|
if (rect && rect.height) {
|
||||||
|
scrollViewHeight.value = rect.height;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.exec();
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 生成展示用标题:去除前导 `#` 并截取前 6 字符(超过加省略号) */
|
||||||
|
const computeTitle = (text = "") => {
|
||||||
|
const t = (text || "").replace(/^#+\s*/, "");
|
||||||
|
return t.length > 8 ? t.substring(0, 8) + "..." : t;
|
||||||
|
}
|
||||||
|
|
||||||
|
const onScroll = (e) => {
|
||||||
|
try {
|
||||||
|
const { scrollTop = 0, scrollHeight = 0 } = e.detail || {};
|
||||||
|
|
||||||
|
// 计算距离底部的距离(使用准确的 scroll-view 高度)
|
||||||
|
const viewHeight = scrollViewHeight.value;
|
||||||
|
const distanceToBottom = scrollHeight - scrollTop - viewHeight;
|
||||||
|
|
||||||
|
// 判断是否在底部附近(允许 SCROLL_THRESHOLD 的误差范围)
|
||||||
|
// 注意:只更新 isNearBottom,不在滚动时强制改变 userInteracting
|
||||||
|
const atBottom = distanceToBottom <= SCROLL_THRESHOLD;
|
||||||
|
isNearBottom.value = atBottom;
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
const onTouchStart = () => {
|
||||||
|
// 触摸开始时,立即标记为用户交互状态
|
||||||
|
userInteracting.value = true;
|
||||||
|
clearTimeout(interactionTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
const onTouchEnd = () => {
|
||||||
|
// 触摸结束后延迟一段时间再取消交互状态
|
||||||
|
// 这样即使用户快速滚动,也不会被中途打断
|
||||||
|
clearTimeout(interactionTimer);
|
||||||
|
interactionTimer = setTimeout(() => {
|
||||||
|
userInteracting.value = false;
|
||||||
|
}, 600);
|
||||||
|
}
|
||||||
|
|
||||||
|
const scrollToBottom = () => {
|
||||||
if (scrollTimer) return;
|
if (scrollTimer) return;
|
||||||
|
if (isFinishedOnInit) return;
|
||||||
|
|
||||||
scrollTimer = setTimeout(() => {
|
scrollTimer = setTimeout(() => {
|
||||||
// ❗关键:强制触发滚动(小程序必须这样)
|
// ❗关键:强制触发滚动(小程序必须这样)
|
||||||
|
// 如果用户正在交互,则跳过本次自动滚动
|
||||||
|
if (userInteracting.value) {
|
||||||
|
scrollTimer = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
scrollIntoViewId.value = "";
|
scrollIntoViewId.value = "";
|
||||||
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
// 再次 nextTick + 延迟,兼容 markdown 渲染延迟
|
// 再次 nextTick + 延迟,兼容 markdown 渲染延迟
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
scrollIntoViewId.value = "bottom-anchor";
|
scrollIntoViewId.value = "bottom-anchor";
|
||||||
|
// 测量高度以便后续滚动判断准确
|
||||||
|
measureScrollViewHeight();
|
||||||
}, 50);
|
}, 50);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -61,32 +132,47 @@ function scrollToBottom() {
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoad(({ message = "", streamId = "" }) => {
|
onLoad(({ message = "", streamId = "", finished = "0" }) => {
|
||||||
|
// 记录初始完成状态
|
||||||
|
isFinishedOnInit = finished === "1";
|
||||||
|
|
||||||
|
console.log("LongAnswer onLoad with params:", { message, streamId, finished });
|
||||||
|
|
||||||
|
// 初次测量 scroll-view 高度
|
||||||
|
nextTick(() => {
|
||||||
|
measureScrollViewHeight();
|
||||||
|
});
|
||||||
|
|
||||||
if (streamId) {
|
if (streamId) {
|
||||||
// ✅ 流式数据
|
// ✅ 流式数据
|
||||||
unsubscribe = StreamManager.subscribe(
|
unsubscribe = StreamManager.subscribe(
|
||||||
streamId,
|
streamId,
|
||||||
(text = "", finished = false) => {
|
(text = "", finished = false) => {
|
||||||
answerText.value = text || "";
|
answerText.value = text || "";
|
||||||
|
title.value = computeTitle(answerText.value);
|
||||||
if (answerText.value.length > 6) {
|
|
||||||
title.value = answerText.value.substring(0, 6) + "...";
|
|
||||||
}
|
|
||||||
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
scrollToBottom();
|
// 每次接收数据都重新测量高度(content size 可能变化,比如加载图)
|
||||||
|
measureScrollViewHeight();
|
||||||
|
|
||||||
|
// 流式完成时强制滚动到底部
|
||||||
|
if (finished) {
|
||||||
|
scrollToBottom();
|
||||||
|
}
|
||||||
|
// 流式中的数据更新:只有在用户未交互且接近底部时才自动滚动
|
||||||
|
else if (!userInteracting.value && isNearBottom.value) {
|
||||||
|
scrollToBottom();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// ✅ 非流式
|
// ✅ 非流式
|
||||||
answerText.value = decodeURIComponent(message || "");
|
answerText.value = decodeURIComponent(message || "");
|
||||||
|
title.value = computeTitle(answerText.value);
|
||||||
if (answerText.value.length > 6) {
|
|
||||||
title.value = answerText.value.substring(0, 6) + "...";
|
|
||||||
}
|
|
||||||
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
// 只有在初始化为非完成状态时才自动滚到底部
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -96,6 +182,11 @@ onUnload(() => {
|
|||||||
try {
|
try {
|
||||||
unsubscribe && unsubscribe();
|
unsubscribe && unsubscribe();
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
|
// 清理定时器,避免内存泄漏
|
||||||
|
try { clearTimeout(scrollTimer); } catch (e) { }
|
||||||
|
try { clearTimeout(interactionTimer); } catch (e) { }
|
||||||
|
scrollTimer = null;
|
||||||
|
interactionTimer = null;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ import { devUrl, wssDevUrl } from "./baseUrl";
|
|||||||
import { getServiceUrl } from "../api/GetServiceUrlApi";
|
import { getServiceUrl } from "../api/GetServiceUrlApi";
|
||||||
|
|
||||||
/// 版本号, 每次发版本前增加
|
/// 版本号, 每次发版本前增加
|
||||||
const versionValue = "1.0.4";
|
const versionValue = "1.1.1";
|
||||||
|
|
||||||
/// 是否是测试版本, 测试版本为true, 发布版本为false
|
/// 是否是测试版本, 测试版本为true, 发布版本为false
|
||||||
const developVersion = true;
|
const developVersion = true;
|
||||||
|
|
||||||
// 获取服务地址
|
// 获取服务地址
|
||||||
const getEvnUrl = async () => {
|
const getEvnUrl = async () => {
|
||||||
/// 智念客户端不需要获取环境地址
|
/// 不需要获取环境地址
|
||||||
if (isZhiNian || developVersion) {
|
if (developVersion) {
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
appStore.setServerConfig({
|
appStore.setServerConfig({
|
||||||
baseUrl: devUrl, // 服务器基础地址
|
baseUrl: devUrl, // 服务器基础地址
|
||||||
|
|||||||
10
src/uni.scss
10
src/uni.scss
@@ -13,11 +13,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* 主题颜色(由 switch-client 命令自动更新) */
|
/* 主题颜色(由 switch-client 命令自动更新) */
|
||||||
$theme-color-800: #0B7034;
|
$theme-color-800: #174BB6;
|
||||||
$theme-color-700: #0B5C2D;
|
$theme-color-700: #145EE1;
|
||||||
$theme-color-500: #0CCD58;
|
$theme-color-500: #2D91FF;
|
||||||
$theme-color-100: #E8FFF1;
|
$theme-color-100: #D9EEFF;
|
||||||
$theme-color-50: #F0F8F3;
|
$theme-color-50: #EEF8FF;
|
||||||
|
|
||||||
// text 颜色
|
// text 颜色
|
||||||
$text-color-900: #181B25;
|
$text-color-900: #181B25;
|
||||||
|
|||||||
Reference in New Issue
Block a user