refactor: standardize import paths and clean up unused code
Migrate legacy relative API imports to consistent absolute @/api paths across all components Remove unnecessary .js file extensions from ES module imports Add new StreamManager utility and base client configuration constants file Clean up unused imports and dynamic config calls in ChatGuide and ChatInputArea components Update the index.html page title to "nianxx" Replace dynamic OSS URL and local text imports in ChatGuide with hardcoded static values
This commit is contained in:
@@ -2,9 +2,12 @@
|
|||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1.0, viewport-fit=cover"
|
||||||
|
/>
|
||||||
<meta name="theme-color" content="#2D91FF" />
|
<meta name="theme-color" content="#2D91FF" />
|
||||||
<title>YGChatCS Web</title>
|
<title>nianxx</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
@@ -72,8 +72,8 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, nextTick, defineProps, watch } from "vue";
|
import { ref, computed, onMounted, nextTick, defineProps, watch } from "vue";
|
||||||
import { SCROLL_TO_BOTTOM } from "@/constants/constant";
|
import { SCROLL_TO_BOTTOM } from "@/constants/constant";
|
||||||
import { createWorkOrder } from "@/api/WorkOrder";
|
import { createWorkOrder } from "@/api/workOrder";
|
||||||
import { updateImageFile } from "@/request/api/UpdateFile";
|
import { updateImageFile } from "@/api/upload";
|
||||||
import { zniconsMap } from "@/assets/fonts/znicons";
|
import { zniconsMap } from "@/assets/fonts/znicons";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
import { ref, onMounted, nextTick, computed } from "vue";
|
import { ref, onMounted, nextTick, computed } from "vue";
|
||||||
import { SCROLL_TO_BOTTOM } from "@/constants/constant";
|
import { SCROLL_TO_BOTTOM } from "@/constants/constant";
|
||||||
import { getCurrentConfig } from "@/constants/base";
|
import { getCurrentConfig } from "@/constants/base";
|
||||||
import { submitFeedback } from "@/request/api/FeedbackApi";
|
import { submitFeedback } from "@/api/home";
|
||||||
|
|
||||||
const contactPhone = ref("");
|
const contactPhone = ref("");
|
||||||
const contactText = ref("");
|
const contactText = ref("");
|
||||||
|
|||||||
59
src/constants/base.ts
Normal file
59
src/constants/base.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
* 客户端配置管理模块
|
||||||
|
*
|
||||||
|
* 功能说明:
|
||||||
|
* 所有配置从根目录的 client-configs.json 文件中读取
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 获取当前用户端配置
|
||||||
|
export const getCurrentConfig = () => {
|
||||||
|
return {
|
||||||
|
clientId: "6",
|
||||||
|
appId: "wx5e79df5996572539",
|
||||||
|
name: "小七",
|
||||||
|
theme: {
|
||||||
|
"theme-color-800": "#0B7034",
|
||||||
|
"theme-color-700": "#0B5C2D",
|
||||||
|
"theme-color-500": "#0CCD58",
|
||||||
|
"theme-color-100": "#E8FFF1",
|
||||||
|
"theme-color-50": "#F0F8F3",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export const clientId = getCurrentConfig().clientId;
|
||||||
|
export const appId = getCurrentConfig().appId;
|
||||||
|
|
||||||
|
/// 客户端类型
|
||||||
|
export const ClientType = {
|
||||||
|
// 智念
|
||||||
|
ZHINIAN: "ZHINIAN",
|
||||||
|
// 小七
|
||||||
|
XIAOQI: "XIAOQI",
|
||||||
|
// 朵花
|
||||||
|
DUOHUA: "DUOHUA",
|
||||||
|
// 天沐
|
||||||
|
TIANMU: "TIANMU",
|
||||||
|
// 念念助手
|
||||||
|
NIANHELPER: "NIANHELPER",
|
||||||
|
};
|
||||||
|
|
||||||
|
/// 获取当前客户端类型
|
||||||
|
export const currentClientType = () => {
|
||||||
|
switch (getCurrentConfig().name) {
|
||||||
|
case "念念":
|
||||||
|
return ClientType.ZHINIAN;
|
||||||
|
case "小七":
|
||||||
|
return ClientType.XIAOQI;
|
||||||
|
case "朵朵":
|
||||||
|
return ClientType.DUOHUA;
|
||||||
|
case "沐沐":
|
||||||
|
return ClientType.TIANMU;
|
||||||
|
case "念念助手":
|
||||||
|
return ClientType.NIANHELPER;
|
||||||
|
default:
|
||||||
|
return ClientType.ZHINIAN;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 环境配置 - 智念客户端使用测试环境,其他客户端使用生产环境
|
||||||
|
export const isZhiNian = true;
|
||||||
@@ -32,8 +32,8 @@
|
|||||||
import { defineProps, computed, watch, onBeforeUnmount } from "vue";
|
import { defineProps, computed, watch, onBeforeUnmount } from "vue";
|
||||||
|
|
||||||
import ChatMarkdown from "../ChatMarkdown/index.vue";
|
import ChatMarkdown from "../ChatMarkdown/index.vue";
|
||||||
import ChatLoading from "./ChatLoading/index.vue";
|
import ChatLoading from "../ChatLoading/index.vue";
|
||||||
import StreamManager from '@/utils/StreamManager.js';
|
import StreamManager from '@/utils/StreamManager';
|
||||||
import {
|
import {
|
||||||
getLongTextPredivText,
|
getLongTextPredivText,
|
||||||
getLongTextValue,
|
getLongTextValue,
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ossChengduUrl } from "@/request/base/baseUrl";
|
|
||||||
import { chatGuideSubTitle } from "@/constant/local";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
hasMessage: {
|
hasMessage: {
|
||||||
@@ -27,7 +25,7 @@ const props = defineProps({
|
|||||||
// 图片路径
|
// 图片路径
|
||||||
imageSrc: {
|
imageSrc: {
|
||||||
type: String,
|
type: String,
|
||||||
default: `${ossChengduUrl()}come_chat_image.png`
|
default: `https://one-feel-config-images-bucket.oss-cn-chengdu.aliyuncs.com/XIAOQI/come_chat_image.png`
|
||||||
},
|
},
|
||||||
// 主标题
|
// 主标题
|
||||||
mainTitle: {
|
mainTitle: {
|
||||||
@@ -37,7 +35,7 @@ const props = defineProps({
|
|||||||
// 副标题
|
// 副标题
|
||||||
subTitle: {
|
subTitle: {
|
||||||
type: String,
|
type: String,
|
||||||
default: chatGuideSubTitle()
|
default: '点击开始聊天'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -61,19 +61,14 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, watch, nextTick, onMounted, defineExpose, onUnmounted } from "vue";
|
import { ref, computed, watch, nextTick, onMounted, defineExpose, onUnmounted } from "vue";
|
||||||
import RecordingWaveBtn from "@/components/Speech/RecordingWaveBtn.vue";
|
import RecordingWaveBtn from "@/components/Speech/RecordingWaveBtn.vue";
|
||||||
import { chatInputPlaceholder } from "@/constant/local";
|
|
||||||
// #ifdef APP-PLUS
|
|
||||||
import { appSpeechRecognitionOptions } from "@/constant/speech";
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
let manager = null;
|
let manager = null;
|
||||||
let speechProvider = "";
|
let speechProvider = "";
|
||||||
const isSpeechRecognitionEnabled = ref(true);
|
const isSpeechRecognitionEnabled = ref(true);
|
||||||
const isSpeechRecognitionSupported = ref(false);
|
const isSpeechRecognitionSupported = ref(false);
|
||||||
let appSpeechOptions = {};
|
let appSpeechOptions = {};
|
||||||
// #ifdef APP-PLUS
|
|
||||||
appSpeechOptions = appSpeechRecognitionOptions;
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// WechatSI 是微信小程序插件,App 原生基座没有 requirePlugin。
|
// WechatSI 是微信小程序插件,App 原生基座没有 requirePlugin。
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
@@ -109,9 +104,7 @@ const recordingWaveBtnRef = ref(null);
|
|||||||
const appSpeechRef = ref(null);
|
const appSpeechRef = ref(null);
|
||||||
const appSpeechKey = ref(0);
|
const appSpeechKey = ref(0);
|
||||||
const appSpeechVisible = ref(true);
|
const appSpeechVisible = ref(true);
|
||||||
const placeholder = computed(() => {
|
const placeholder = ref('请输入');
|
||||||
return chatInputPlaceholder();
|
|
||||||
});
|
|
||||||
const inputMessage = ref(props.modelValue || "");
|
const inputMessage = ref(props.modelValue || "");
|
||||||
const isFocused = ref(false);
|
const isFocused = ref(false);
|
||||||
const keyboardHeight = ref(0);
|
const keyboardHeight = ref(0);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import TopNavBar from "@/components/TopNavBar/index.vue";
|
|||||||
import ChatMarkdown from "../ChatMarkdown/index.vue";
|
import ChatMarkdown from "../ChatMarkdown/index.vue";
|
||||||
import ParsedValuediv from "./ParsedValuediv.vue";
|
import ParsedValuediv from "./ParsedValuediv.vue";
|
||||||
import { defineProps, ref, nextTick, computed } from "vue";
|
import { defineProps, ref, nextTick, computed } from "vue";
|
||||||
import StreamManager from "@/utils/StreamManager.js";
|
import StreamManager from "@/utils/StreamManager";
|
||||||
import {
|
import {
|
||||||
LONG_TEXT_KEYS,
|
LONG_TEXT_KEYS,
|
||||||
getLongTextSections,
|
getLongTextSections,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { Command } from "@/model/ChatModel";
|
import { Command } from "@/constants/ChatModel";
|
||||||
import { SEND_MESSAGE_COMMAND_TYPE } from "@/constants/constant";
|
import { SEND_MESSAGE_COMMAND_TYPE } from "@/constants/constant";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
import { checkToken } from "@/hooks/useGoLogin";
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ import CardSwiper from "./components/CardSwiper/index.vue";
|
|||||||
import QuickQuestions from "./components/QuickQuestions/index.vue";
|
import QuickQuestions from "./components/QuickQuestions/index.vue";
|
||||||
import discoveryCover from "@/components/ImageSwiper/images/2025-07-12_180248.jpg";
|
import discoveryCover from "@/components/ImageSwiper/images/2025-07-12_180248.jpg";
|
||||||
|
|
||||||
import { homeTabsData, getNearbyTags, homeTabContentData, homeQuickQuestionData } from "../../request/api/MainPageDataApi";
|
import { homeTabsData, getNearbyTags, homeTabContentData, homeQuickQuestionData } from "@/api/home";
|
||||||
import { useAppStore, useLocationStore } from "@/store";
|
import { useAppStore, useLocationStore } from "@/store";
|
||||||
import { JumpType } from "../../model/ChatModel";
|
import { JumpType } from "@/constants/ChatModel";
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const locationStore = useLocationStore();
|
const locationStore = useLocationStore();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps } from "vue";
|
import { defineProps } from "vue";
|
||||||
import { closeWorkOrder } from "@/api/WorkOrder";
|
import { closeWorkOrder } from "@/api/workOrder";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
const isCancelWork = ref(false);
|
const isCancelWork = ref(false);
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import { ref } from "vue";
|
|||||||
import TopNavBar from "@/components/TopNavBar/index.vue";
|
import TopNavBar from "@/components/TopNavBar/index.vue";
|
||||||
import CustomEmpty from "@/components/CustomEmpty/index.vue";
|
import CustomEmpty from "@/components/CustomEmpty/index.vue";
|
||||||
import OrderCard from "./components/OrderCard/index.vue";
|
import OrderCard from "./components/OrderCard/index.vue";
|
||||||
import { userWorkOrderList } from "@/api/WorkOrder";
|
import { userWorkOrderList } from "@/api/workOrder";
|
||||||
|
|
||||||
const dataList = ref([]);
|
const dataList = ref([]);
|
||||||
const paging = ref(null);
|
const paging = ref(null);
|
||||||
|
|||||||
58
src/utils/StreamManager.ts
Normal file
58
src/utils/StreamManager.ts
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
// 简单的流式数据管理器:开启流、更新流、订阅流、关闭流
|
||||||
|
const streams = {};
|
||||||
|
|
||||||
|
function notify(stream) {
|
||||||
|
stream.subs.forEach((cb) => cb(stream.text, stream.finished, stream.payload));
|
||||||
|
}
|
||||||
|
|
||||||
|
function openStream(id, initial = '', finished = false, payload = null) {
|
||||||
|
if (!id) return;
|
||||||
|
streams[id] = streams[id] || { text: '', finished: false, payload: null, subs: new Set() };
|
||||||
|
streams[id].text = initial || '';
|
||||||
|
streams[id].finished = !!finished;
|
||||||
|
streams[id].payload = payload || null;
|
||||||
|
// notify existing subscribers
|
||||||
|
notify(streams[id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateStream(id, text, finished = false, payload = null) {
|
||||||
|
if (!id || !streams[id]) return;
|
||||||
|
streams[id].text = text || '';
|
||||||
|
streams[id].finished = !!finished;
|
||||||
|
streams[id].payload = payload || null;
|
||||||
|
notify(streams[id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function subscribe(id, cb) {
|
||||||
|
if (!id) return () => {};
|
||||||
|
streams[id] = streams[id] || { text: '', finished: false, payload: null, subs: new Set() };
|
||||||
|
streams[id].subs.add(cb);
|
||||||
|
// send current snapshot immediately
|
||||||
|
cb(streams[id].text, streams[id].finished, streams[id].payload);
|
||||||
|
return () => {
|
||||||
|
streams[id] && streams[id].subs.delete(cb);
|
||||||
|
// 移除空流
|
||||||
|
if (streams[id] && streams[id].subs.size === 0 && streams[id].finished) {
|
||||||
|
delete streams[id];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeStream(id) {
|
||||||
|
if (!id || !streams[id]) return;
|
||||||
|
streams[id].subs.forEach((cb) => cb(streams[id].text, true, streams[id].payload));
|
||||||
|
delete streams[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSnapshot(id) {
|
||||||
|
if (!id || !streams[id]) return { text: '', finished: false, payload: null };
|
||||||
|
return { text: streams[id].text, finished: streams[id].finished, payload: streams[id].payload };
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
openStream,
|
||||||
|
updateStream,
|
||||||
|
subscribe,
|
||||||
|
closeStream,
|
||||||
|
getSnapshot,
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user