refactor: restructure pinia stores, fix calendar, add utilities

- Restructure Pinia store organization from src/stores/ to src/store/ with modular stores
- Update main.ts to use locally created Pinia instance instead of imported pre-configured one
- Fix template syntax errors in Calendar component: correct missing class spacing and incorrect closing tags
- Remove unused calendar demo/example files and documentation
- Add new constant files, token management utilities, and client configuration constants
- Add custom hooks useGoHome and useGoLogin for navigation and login logic
This commit is contained in:
duanshuwen
2026-05-26 23:02:05 +08:00
parent ac8f5b5f64
commit c977c485ef
20 changed files with 344 additions and 1494 deletions

52
src/constants/base.ts Normal file
View File

@@ -0,0 +1,52 @@
/**
* 客户端配置管理模块
*
* 功能说明:
* 所有配置从根目录的 client-configs.json 文件中读取
*/
// 直接导入配置文件
import rawConfigs from "../../client-configs.json" with { type: "json" };
// 所有用户端的配置 - 处理后的配置
export const CLIENT_CONFIGS = rawConfigs;
// 获取当前用户端配置
export const getCurrentConfig = () => CLIENT_CONFIGS.xiaoqi;
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 = currentClientType() === ClientType.ZHINIAN;

19
src/constants/constant.ts Normal file
View File

@@ -0,0 +1,19 @@
// 登录成功
export const NOTICE_EVENT_LOGIN_SUCCESS = "NOTICE_EVENT_LOGIN_SUCCESS";
// 退出登录
export const NOTICE_EVENT_LOGOUT = "NOTICE_EVENT_LOGOUT";
// 滚动到底部
export const SCROLL_TO_BOTTOM = "SCROLL_TO_BOTTOM";
// 发送消息文本类型
export const SEND_MESSAGE_CONTENT_TEXT = "SEND_MESSAGE_CONTENT_TEXT";
// 发送消息命令类型
export const SEND_MESSAGE_COMMAND_TYPE = "SEND_MESSAGE_COMMAND_TYPE";
// 切换到伴游tab
export const SWITCH_TO_COMPANION_TAB = "SWITCH_TO_COMPANION_TAB";
// 切换到发现tab
export const SWITCH_TO_DISCOVERY_TAB = "SWITCH_TO_DISCOVERY_TAB";

7
src/constants/speech.ts Normal file
View File

@@ -0,0 +1,7 @@
// App 端 yao-asdRealSpeech 使用的阿里云 DashScope 实时语音识别配置。
// 将 apikey 填成实际的 DashScope API Key 后App 端语音识别即可发起连接。
export const appSpeechRecognitionOptions = {
apikey: "sk-2cab1c221b4b47749119d33ab991360a",
language_hints: ["zh"],
saveAudioFile: false,
};

35
src/constants/token.ts Normal file
View File

@@ -0,0 +1,35 @@
import { currentClientType } from "@/constant/base";
// 存储在本地的认证 token 键名
const CLIENT_TYPE = currentClientType();
const ACCESS_TOKEN = `${CLIENT_TYPE}_ACCESS_TOKEN`;
const REFRESH_ACCESS_TOKEN = `${CLIENT_TYPE}_REFRESH_ACCESS_TOKEN`;
// 设置本地存储的认证 token
export const setAccessToken = (token) => {
return uni.setStorageSync(ACCESS_TOKEN, token);
};
// 设置本地存储的刷新 token
export const setRefreshToken = (token) => {
return uni.setStorageSync(REFRESH_ACCESS_TOKEN, token);
};
// 获取本地存储的刷新 token
export const getRefreshToken = () => {
return uni.getStorageSync(REFRESH_ACCESS_TOKEN);
};
// 获取本地存储的认证 token
export const getAccessToken = () => {
return uni.getStorageSync(ACCESS_TOKEN);
};
// 移除本地存储的认证 token
export const removeAccessToken = () => {
return uni.removeStorageSync(ACCESS_TOKEN);
};
export const removeRefreshToken = () => {
return uni.removeStorageSync(REFRESH_ACCESS_TOKEN);
};

7
src/constants/type.ts Normal file
View File

@@ -0,0 +1,7 @@
// 商品类型
export const GOODS_TYPE = {
0: "客房",
1: "门票",
2: "餐饮",
3: "套餐",
};