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:
duanshuwen
2026-05-27 07:35:28 +08:00
parent 1a5a2ae6a9
commit dd36ccc118
13 changed files with 138 additions and 27 deletions

View File

@@ -72,8 +72,8 @@
<script setup>
import { ref, computed, onMounted, nextTick, defineProps, watch } from "vue";
import { SCROLL_TO_BOTTOM } from "@/constants/constant";
import { createWorkOrder } from "@/api/WorkOrder";
import { updateImageFile } from "@/request/api/UpdateFile";
import { createWorkOrder } from "@/api/workOrder";
import { updateImageFile } from "@/api/upload";
import { zniconsMap } from "@/assets/fonts/znicons";
const props = defineProps({

View File

@@ -48,7 +48,7 @@
import { ref, onMounted, nextTick, computed } from "vue";
import { SCROLL_TO_BOTTOM } from "@/constants/constant";
import { getCurrentConfig } from "@/constants/base";
import { submitFeedback } from "@/request/api/FeedbackApi";
import { submitFeedback } from "@/api/home";
const contactPhone = ref("");
const contactText = ref("");

59
src/constants/base.ts Normal file
View 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;

View File

@@ -32,8 +32,8 @@
import { defineProps, computed, watch, onBeforeUnmount } from "vue";
import ChatMarkdown from "../ChatMarkdown/index.vue";
import ChatLoading from "./ChatLoading/index.vue";
import StreamManager from '@/utils/StreamManager.js';
import ChatLoading from "../ChatLoading/index.vue";
import StreamManager from '@/utils/StreamManager';
import {
getLongTextPredivText,
getLongTextValue,

View File

@@ -16,8 +16,6 @@
</template>
<script setup>
import { ossChengduUrl } from "@/request/base/baseUrl";
import { chatGuideSubTitle } from "@/constant/local";
const props = defineProps({
hasMessage: {
@@ -27,7 +25,7 @@ const props = defineProps({
// 图片路径
imageSrc: {
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: {
@@ -37,7 +35,7 @@ const props = defineProps({
// 副标题
subTitle: {
type: String,
default: chatGuideSubTitle()
default: '点击开始聊天'
}
});
</script>

View File

@@ -61,19 +61,14 @@
<script setup>
import { ref, computed, watch, nextTick, onMounted, defineExpose, onUnmounted } from "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 speechProvider = "";
const isSpeechRecognitionEnabled = ref(true);
const isSpeechRecognitionSupported = ref(false);
let appSpeechOptions = {};
// #ifdef APP-PLUS
appSpeechOptions = appSpeechRecognitionOptions;
// #endif
// WechatSI 是微信小程序插件App 原生基座没有 requirePlugin。
// #ifdef MP-WEIXIN
@@ -109,9 +104,7 @@ const recordingWaveBtnRef = ref(null);
const appSpeechRef = ref(null);
const appSpeechKey = ref(0);
const appSpeechVisible = ref(true);
const placeholder = computed(() => {
return chatInputPlaceholder();
});
const placeholder = ref('请输入');
const inputMessage = ref(props.modelValue || "");
const isFocused = ref(false);
const keyboardHeight = ref(0);

View File

@@ -39,7 +39,7 @@ import TopNavBar from "@/components/TopNavBar/index.vue";
import ChatMarkdown from "../ChatMarkdown/index.vue";
import ParsedValuediv from "./ParsedValuediv.vue";
import { defineProps, ref, nextTick, computed } from "vue";
import StreamManager from "@/utils/StreamManager.js";
import StreamManager from "@/utils/StreamManager";
import {
LONG_TEXT_KEYS,
getLongTextSections,

View File

@@ -14,7 +14,7 @@
<script setup>
import { ref } from "vue";
import { Command } from "@/model/ChatModel";
import { Command } from "@/constants/ChatModel";
import { SEND_MESSAGE_COMMAND_TYPE } from "@/constants/constant";
import { checkToken } from "@/hooks/useGoLogin";

View File

@@ -26,9 +26,9 @@ import CardSwiper from "./components/CardSwiper/index.vue";
import QuickQuestions from "./components/QuickQuestions/index.vue";
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 { JumpType } from "../../model/ChatModel";
import { JumpType } from "@/constants/ChatModel";
const appStore = useAppStore();
const locationStore = useLocationStore();

View File

@@ -49,7 +49,7 @@
<script setup>
import { defineProps } from "vue";
import { closeWorkOrder } from "@/api/WorkOrder";
import { closeWorkOrder } from "@/api/workOrder";
import { ref } from "vue";
const isCancelWork = ref(false);

View File

@@ -24,7 +24,7 @@ import { ref } from "vue";
import TopNavBar from "@/components/TopNavBar/index.vue";
import CustomEmpty from "@/components/CustomEmpty/index.vue";
import OrderCard from "./components/OrderCard/index.vue";
import { userWorkOrderList } from "@/api/WorkOrder";
import { userWorkOrderList } from "@/api/workOrder";
const dataList = ref([]);
const paging = ref(null);

View 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,
};