Compare commits
5 Commits
V1.1.1
...
99b82810c2
| Author | SHA1 | Date | |
|---|---|---|---|
| 99b82810c2 | |||
| d2e650a434 | |||
| d6c7ca7aec | |||
| 1408a97027 | |||
| d49bf738f8 |
@@ -24,6 +24,31 @@
|
||||
"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": {
|
||||
"clientId": "2",
|
||||
"appId": "wx23f86d809ae80259",
|
||||
@@ -74,4 +99,4 @@
|
||||
"theme-color-50": "#EEF8FF"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"appid": "wx5e79df5996572539",
|
||||
"appid": "wx6fcf7b3db3deee6c",
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "3.8.10",
|
||||
"packOptions": {
|
||||
|
||||
@@ -44,11 +44,12 @@
|
||||
|
||||
## 支持的客户端
|
||||
|
||||
| 客户端名称 | 显示名称 | AppID |
|
||||
| ---------- | -------- | ------------------ |
|
||||
| `zhinian` | 智念 | wx5e79df5996572539 |
|
||||
| `duohua` | 朵花 | wx23f86d809ae80259 |
|
||||
| `tianmu` | 天沐 | wx0be424e1d22065a9 |
|
||||
| 客户端名称 | 显示名称 | AppID |
|
||||
| ------------ | -------- | ------------------ |
|
||||
| `zhinian` | 智念 | wx5e79df5996572539 |
|
||||
| `duohua` | 朵花 | wx23f86d809ae80259 |
|
||||
| `tianmu` | 天沐 | wx0be424e1d22065a9 |
|
||||
| `nianhelper` | 念念 | wx6fcf7b3db3deee6c |
|
||||
|
||||
## 使用方法
|
||||
|
||||
@@ -58,6 +59,9 @@
|
||||
# 切换到智念客户端
|
||||
npm run switch-client zhinian
|
||||
|
||||
# 切换到念念助手客户端
|
||||
npm run switch-client nianhelper
|
||||
|
||||
# 切换到朵花客户端
|
||||
npm run switch-client duohua
|
||||
|
||||
@@ -85,17 +89,14 @@ node scripts/update-appid.js tianmu
|
||||
## 更新的文件
|
||||
|
||||
1. **src/manifest.json**
|
||||
|
||||
- 更新 `mp-weixin.appid` 字段
|
||||
- 保持文件中的注释不变
|
||||
|
||||
2. **project.config.json**
|
||||
|
||||
- 更新根级别的 `appid` 字段
|
||||
- 保持 JSON 格式化
|
||||
|
||||
3. **src/constant/base.js**
|
||||
|
||||
- 更新 `getCurrentConfig()` 函数返回的客户端配置
|
||||
|
||||
4. **client-configs.json**
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
class="checkbox-icon"
|
||||
:type="isChecked"
|
||||
:checked="isChecked"
|
||||
:color="iconColor"
|
||||
size="24"
|
||||
color="opacity"
|
||||
/>
|
||||
<slot></slot>
|
||||
</view>
|
||||
@@ -28,11 +28,6 @@ const isChecked = computed(() => {
|
||||
return props.modelValue ? "checkbox-filled" : "circle";
|
||||
});
|
||||
|
||||
// 计算图标颜色
|
||||
const iconColor = computed(() => {
|
||||
return props.modelValue ? "#1890FF" : "#00A6FF";
|
||||
});
|
||||
|
||||
// 切换选中状态
|
||||
const onChange = () => {
|
||||
emit("update:modelValue", !props.modelValue);
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
|
||||
.checkbox-icon {
|
||||
margin-right: 6px;
|
||||
color: $theme-color-500;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.command-wrapper {
|
||||
background-color: #00a6ff;
|
||||
background-color: $theme-color-500;
|
||||
border-radius: 20px 4px 20px 20px;
|
||||
padding: 8px 24px;
|
||||
width: max-content;
|
||||
|
||||
@@ -188,7 +188,7 @@ const addForm = () => {
|
||||
font-weight: 600;
|
||||
margin-bottom: 20rpx;
|
||||
color: #333;
|
||||
border-left: 6rpx solid #00a6ff;
|
||||
border-left: 6rpx solid $theme-color-500;
|
||||
padding-left: 16rpx;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ const addForm = () => {
|
||||
.add-btn {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
background: #00a6ff;
|
||||
background: $theme-color-500;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8rpx;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<view class="form-wrapper">
|
||||
<view class="form-header">
|
||||
<uni-icons class="minus" color="#00A6FF" size="22" type="minus" />
|
||||
<uni-icons class="minus uni-color" color="opacity" size="22" type="minus" />
|
||||
<text class="form-title">{{ title }}</text>
|
||||
<uni-icons
|
||||
v-if="showDeleteIcon"
|
||||
class="delete"
|
||||
color="#00A6FF"
|
||||
class="delete uni-color"
|
||||
color="opacity"
|
||||
size="22"
|
||||
type="trash"
|
||||
@click="handleDelete"
|
||||
|
||||
@@ -29,6 +29,10 @@ $form-transition: all 0.2s ease;
|
||||
padding: 10px 12px;
|
||||
min-height: 44px;
|
||||
|
||||
.uni-color {
|
||||
color: $theme-color-500;
|
||||
}
|
||||
|
||||
.minus,
|
||||
.delete {
|
||||
height: 22px;
|
||||
@@ -50,7 +54,7 @@ $form-transition: all 0.2s ease;
|
||||
margin-left: 8px;
|
||||
font-size: $uni-font-size-lg;
|
||||
font-weight: 500;
|
||||
color: $form-primary-color;
|
||||
color: $theme-color-500;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@@ -110,7 +114,7 @@ $form-transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
&:focus {
|
||||
border-bottom-color: $form-primary-color;
|
||||
border-bottom-color: $theme-color-500;
|
||||
|
||||
&::placeholder {
|
||||
opacity: 0.5;
|
||||
|
||||
@@ -48,6 +48,6 @@
|
||||
);
|
||||
font-size: $uni-font-size-sm;
|
||||
font-weight: 500;
|
||||
color: #00a6ff;
|
||||
color: $theme-color-500;
|
||||
border-radius: $uni-border-radius-50px;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ defineExpose({
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #00a6ff;
|
||||
background-color: $theme-color-500;
|
||||
height: 44px;
|
||||
border-radius: $uni-border-radius-50px;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
border-radius: 10px;
|
||||
padding: 8px 16px;
|
||||
font-size: $uni-font-size-sm;
|
||||
color: #00a6ff;
|
||||
color: $theme-color-500;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
/**
|
||||
* 客户端配置管理模块
|
||||
*
|
||||
*
|
||||
* 功能说明:
|
||||
* 所有配置从根目录的 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 getCurrentConfig = () => CLIENT_CONFIGS.zhinian;
|
||||
export const getCurrentConfig = () => CLIENT_CONFIGS.nianhelper;
|
||||
export const clientId = getCurrentConfig().clientId;
|
||||
export const appId = getCurrentConfig().appId;
|
||||
|
||||
|
||||
/// 客户端类型
|
||||
export const ClientType = {
|
||||
// 智念
|
||||
@@ -25,17 +24,21 @@ export const ClientType = {
|
||||
DUOHUA: "DUOHUA",
|
||||
// 天沐
|
||||
TIANMU: "TIANMU",
|
||||
// 念念助手
|
||||
NIANHELPER: "NIANHELPER",
|
||||
};
|
||||
|
||||
/// 获取当前客户端类型
|
||||
export const currentClientType = () => {
|
||||
switch (getCurrentConfig().name) {
|
||||
case '智念':
|
||||
case "智念":
|
||||
return ClientType.ZHINIAN;
|
||||
case '朵朵':
|
||||
case "朵朵":
|
||||
return ClientType.DUOHUA;
|
||||
case '沐沐':
|
||||
case "沐沐":
|
||||
return ClientType.TIANMU;
|
||||
case "念念":
|
||||
return ClientType.NIANHELPER;
|
||||
default:
|
||||
return ClientType.ZHINIAN;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
朵花:wx23f86d809ae80259
|
||||
*/
|
||||
"mp-weixin": {
|
||||
"appid": "wx5e79df5996572539",
|
||||
"appid": "wx6fcf7b3db3deee6c",
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"minified": true
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
.confirm-btn {
|
||||
width: 160px;
|
||||
height: 48px;
|
||||
background: linear-gradient(179deg, #00a6ff 0%, #0256ff 100%);
|
||||
background: linear-gradient(179deg, $theme-color-500 0%, $theme-color-700 100%);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 24px;
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, watch, nextTick, onMounted, defineExpose } from "vue";
|
||||
import { ref, computed, watch, nextTick, onMounted, defineExpose, onUnmounted } from "vue";
|
||||
import RecordingWaveBtn from "@/components/Speech/RecordingWaveBtn.vue";
|
||||
import { getCurrentConfig } from "@/constant/base";
|
||||
|
||||
@@ -103,6 +103,32 @@ const isFocused = ref(false);
|
||||
const keyboardHeight = ref(0);
|
||||
const isVoiceMode = ref(false);
|
||||
const visibleWaveBtn = ref(false);
|
||||
const isRecording = ref(false);
|
||||
let watchDogTimer = null;
|
||||
|
||||
const resetUI = () => {
|
||||
isRecording.value = false;
|
||||
visibleWaveBtn.value = false;
|
||||
try {
|
||||
if (recordingWaveBtnRef.value) {
|
||||
recordingWaveBtnRef.value.stopAnimation();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("resetUI stopAnimation error", e);
|
||||
}
|
||||
if (watchDogTimer) {
|
||||
clearTimeout(watchDogTimer);
|
||||
watchDogTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
const startWatchDog = (timeout = 10000) => {
|
||||
if (watchDogTimer) clearTimeout(watchDogTimer);
|
||||
watchDogTimer = setTimeout(() => {
|
||||
console.warn("recording watchdog triggered, forcing UI reset");
|
||||
resetUI();
|
||||
}, timeout);
|
||||
};
|
||||
|
||||
// 保持和父组件同步
|
||||
watch(
|
||||
@@ -127,42 +153,65 @@ const toggleVoiceMode = () => {
|
||||
|
||||
// 处理语音按钮长按开始
|
||||
const handleVoiceTouchStart = () => {
|
||||
manager.start({ lang: "zh_CN" });
|
||||
try {
|
||||
manager.start({ lang: "zh_CN" });
|
||||
isRecording.value = true;
|
||||
visibleWaveBtn.value = true;
|
||||
|
||||
visibleWaveBtn.value = true;
|
||||
|
||||
// 启动音频条动画
|
||||
nextTick(() => {
|
||||
if (recordingWaveBtnRef.value) {
|
||||
recordingWaveBtnRef.value.startAnimation();
|
||||
}
|
||||
});
|
||||
// 启动音频条动画
|
||||
nextTick(() => {
|
||||
if (recordingWaveBtnRef.value) {
|
||||
recordingWaveBtnRef.value.startAnimation();
|
||||
}
|
||||
});
|
||||
startWatchDog(10000);
|
||||
} catch (err) {
|
||||
console.error("record start error:", err);
|
||||
// 保底清理
|
||||
resetUI();
|
||||
}
|
||||
};
|
||||
|
||||
// 处理语音按钮长按结束
|
||||
const handleVoiceTouchEnd = () => {
|
||||
manager.stop();
|
||||
|
||||
// 停止音频条动画
|
||||
if (recordingWaveBtnRef.value) {
|
||||
recordingWaveBtnRef.value.stopAnimation();
|
||||
// 如果本地状态不是录音中,也确保 UI 恢复
|
||||
if (!isRecording.value) {
|
||||
if (recordingWaveBtnRef.value) {
|
||||
recordingWaveBtnRef.value.stopAnimation();
|
||||
}
|
||||
visibleWaveBtn.value = false;
|
||||
if (watchDogTimer) {
|
||||
clearTimeout(watchDogTimer);
|
||||
watchDogTimer = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
visibleWaveBtn.value = false;
|
||||
try {
|
||||
manager.stop();
|
||||
} catch (err) {
|
||||
console.error("record stop error:", err);
|
||||
} finally {
|
||||
// 无论 stop 是否抛错,都保证 UI 恢复
|
||||
resetUI();
|
||||
}
|
||||
};
|
||||
|
||||
// 处理发送原语音
|
||||
const initRecord = () => {
|
||||
manager.onRecognize = (res) => {
|
||||
let text = res.result;
|
||||
let text = res.result || "";
|
||||
inputMessage.value = text;
|
||||
};
|
||||
// 识别结束事件
|
||||
manager.onStop = (res) => {
|
||||
console.log(res, 37);
|
||||
let text = res.result;
|
||||
let text = (res && res.result) || "";
|
||||
|
||||
if (text == "") {
|
||||
// 保证 UI 恢复(防止未走 handleVoiceTouchEnd)
|
||||
resetUI();
|
||||
|
||||
if (text === "") {
|
||||
console.log("没有说话");
|
||||
return;
|
||||
}
|
||||
@@ -171,6 +220,12 @@ const initRecord = () => {
|
||||
// 在语音识别完成后发送消息
|
||||
emit("send", text);
|
||||
};
|
||||
|
||||
// 错误处理,确保 UI 重置
|
||||
manager.onError = (err) => {
|
||||
console.error("record manager error", err);
|
||||
resetUI();
|
||||
};
|
||||
};
|
||||
|
||||
// 监听键盘高度变化
|
||||
@@ -188,6 +243,18 @@ onMounted(() => {
|
||||
initRecord();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
try {
|
||||
manager.stop && manager.stop();
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
manager.onRecognize = null;
|
||||
manager.onStop = null;
|
||||
manager.onError = null;
|
||||
resetUI();
|
||||
});
|
||||
|
||||
const sendMessage = () => {
|
||||
if (props.isSessionActive) {
|
||||
// 如果会话进行中,调用停止请求函数
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
}
|
||||
|
||||
.date-item.active {
|
||||
background-color: #00a6ff;
|
||||
background-color: $theme-color-500;
|
||||
}
|
||||
.date-item.active .label,
|
||||
.date-item.active .date {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { getServiceUrl } from "../api/GetServiceUrlApi";
|
||||
const versionValue = "1.1.1";
|
||||
|
||||
/// 是否是测试版本, 测试版本为true, 发布版本为false
|
||||
const developVersion = false;
|
||||
const developVersion = true;
|
||||
|
||||
// 获取服务地址
|
||||
const getEvnUrl = async () => {
|
||||
|
||||
10
src/uni.scss
10
src/uni.scss
@@ -13,11 +13,11 @@
|
||||
*/
|
||||
|
||||
/* 主题颜色(由 switch-client 命令自动更新) */
|
||||
$theme-color-800: #0B7034;
|
||||
$theme-color-700: #0B5C2D;
|
||||
$theme-color-500: #0CCD58;
|
||||
$theme-color-100: #E8FFF1;
|
||||
$theme-color-50: #F0F8F3;
|
||||
$theme-color-800: #174BB6;
|
||||
$theme-color-700: #145EE1;
|
||||
$theme-color-500: #2D91FF;
|
||||
$theme-color-100: #D9EEFF;
|
||||
$theme-color-50: #EEF8FF;
|
||||
|
||||
// text 颜色
|
||||
$text-color-900: #181B25;
|
||||
|
||||
Reference in New Issue
Block a user