findme-miniprogram-frontend/config/config.js
2025-12-27 17:16:03 +08:00

253 lines
7.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 小程序配置文件 - 对应Fl`utter的app_config.dart
function mergeDeep(target = {}, source = {}) {
const result = Array.isArray(target) ? target.slice() : Object.assign({}, target);
if (!source || typeof source !== 'object') {
return result;
}
Object.keys(source).forEach((key) => {
const sourceValue = source[key];
const targetValue = result[key];
if (Array.isArray(sourceValue)) {
result[key] = sourceValue.slice();
} else if (
sourceValue &&
typeof sourceValue === 'object' &&
!Array.isArray(sourceValue) &&
targetValue &&
typeof targetValue === 'object' &&
!Array.isArray(targetValue)
) {
result[key] = mergeDeep(targetValue, sourceValue);
} else if (sourceValue !== undefined) {
result[key] = sourceValue;
}
});
return result;
}
let privateConfig = {};
try {
// eslint-disable-next-line global-require, import/no-unresolved
privateConfig = require('./config.private.js');
} catch (error) {
const message = error && error.message ? String(error.message) : '';
const isMissing = error?.code === 'MODULE_NOT_FOUND' || message.includes('not defined');
if (!isMissing) {
console.warn('加载私有配置失败:', error);
} else if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'development') {
console.info('未检测到 config.private.js使用默认配置');
}
}
const baseConfig = {
// 应用信息
appName: "FindMe",
appVersion: "1.0.30", // 全局版本检查功能版本
// API配置 - 使用正确的域名
api: {
baseUrl: "https://api.faxianwo.me",
baseAmapUrl: "https://restapi.amap.com/v3",
timeout: 15000
},
// scana配置
scana: {
textBusinessId: '2084889082944577806',
imageBusinessId: '2084888991278039310',
appId: '68ce8147f243650001486434',
secretKey: 'd5b263da-99b8-11f0-97a4-fa163e917534'
},
// WebSocket配置 - 使用正确的WebSocket路径
websocket: {
baseUrl: "wss://api.faxianwo.me",
url: "wss://api.faxianwo.me/api/v1/ws", // 🔥 恢复正确的WebSocket路径
heartbeatInterval: 30000, // 30秒
reconnectBaseDelay: 2000, // 重连基础延迟
maxReconnectAttempts: 10 // 最大重连次数
},
// 高德地图配置
// amapKey: '55e1d9a4c6c0f9fa4c75656fe3060641',
// amapKey: '9212b693317725fca66ae697ec444fd5',
amapKey: '9da0f2a1538b5857dba24ac9aa9f30cc',
// amapKey: '97320669caa10f1f8168b0f1aecc2c08',
// NIM配置
nim: {
appkey: '008ea0d044bd46e5b2281cb5fc3f627b',
apiVersion: 'v2',
enableV2CloudConversation: true
},
// 腾讯云COS配置 - 用于文件存储
cos: {
// 存储桶配置
bucket: 'findme-1375214531',
region: 'ap-guangzhou',
// 临时密钥服务地址 (后端提供)
stsUrl: '/api/v1/cos/sts',
// 文件检查接口 (检查文件是否已存在)
fileCheckUrl: '/api/v1/cos/file/check',
// 文件记录保存接口
fileRecordUrl: '/api/v1/cos/file/record',
// 是否使用全球加速
useAccelerate: false,
// 分块上传配置
sliceSize: 1024 * 1024 * 5, // 5MB 大于此大小使用分块上传
chunkSize: 1024 * 1024 * 1, // 1MB 分块大小
// 文件路径格式: user/{userId}/{fileType}/{timestamp}_{fileName}
pathFormat: 'user/{userId}/{fileType}/{timestamp}_{fileName}'
},
// 网络超时设置 (保持向后兼容)
networkTimeout: {
request: 15000,
upload: 60000,
download: 60000
},
// 位置刷新间隔
locationUpdateInterval: 30000, // 30秒
// 文件大小限制 (小程序有自己的限制,这里作为前端验证)
fileSizeLimit: {
image: 10 * 1024 * 1024, // 10MB
video: 50 * 1024 * 1024, // 50MB
audio: 5 * 1024 * 1024, // 5MB
file: 50 * 1024 * 1024 // 50MB
},
// 支持的文件类型
supportedFileTypes: {
image: ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'],
video: ['mp4', 'avi', 'wmv', 'mov', '3gp'],
audio: ['mp3', 'wav', 'ogg', 'aac', 'm4a']
},
// 缓存设置
cache: {
maxAge: 7 * 24 * 60 * 60, // 7天
resourceExpireTime: {
image: 4 * 3600, // 4小时
video: 2 * 3600, // 2小时
audio: 2 * 3600, // 2小时
file: 1 * 3600, // 1小时
avatar: 24 * 3600 // 24小时
},
// 版本管理配置
versionManagement: {
enableAutoClear: true, // 版本更新时自动清理缓存
periodicClearInterval: 7 * 24 * 60 * 60 * 1000, // 7天定期清理
showUpdateNotification: true // 显示更新通知
}
},
// API端点路径
apiPaths: {
// 身份验证相关统一使用user路径
auth: {
sendVerifyCode: '/api/v1/user/send-verify-code',
login: '/api/v1/user/login',
wechatLogin: '/api/v1/user/wechat-login',
refresh: '/api/v1/auth/refresh',
logout: '/api/v1/user/logout'
},
// 用户相关
user: {
profile: '/api/v1/user/profile',
updateProfile: '/api/v1/user/profile',
setting: '/api/v1/user/setting',
bindPhone: '/api/v1/user/bind-phone',
detectMerge: '/api/v1/user/detect-merge',
mergeAccount: '/api/v1/user/merge-account'
},
// 位置相关
location: {
update: '/api/v1/location/update',
getFriends: '/api/v1/location/friends',
getStrangers: '/api/v1/location/strangers',
privacy: '/api/v1/location/privacy'
},
// 聊天相关 - 根据接口文档修正API路径
chat: {
conversations: '/api/v1/chat/conversations',
history: '/api/v1/chat/history', // 修正:使用正确的历史消息接口
messages: '/api/v1/chat/history', // 保持向后兼容
send: '/api/v1/chat/send',
batchRead: '/api/v1/chat/batch-read', // 新增:批量已读
markAllRead: '/api/v1/chat/mark-all-read', // 新增:全部已读
unreadTotal: '/api/v1/chat/unread/total', // 新增:总未读数
settings: '/api/v1/chat/settings', // 新增:聊天设置
backup: '/api/v1/chat/backup', // 新增:备份
restore: '/api/v1/chat/restore', // 新增:恢复
danmaku: '/api/v1/chat/danmaku', // 新增:弹幕
emoji: '/api/v1/chat/emoji/packages', // 新增:表情包
syncPull: '/api/v1/chat/sync/pull', // 新增:同步拉取
syncAck: '/api/v1/chat/sync/ack', // 新增:同步确认
upload: '/api/v1/file/upload'
},
// 社交相关
social: {
friends: '/api/v1/social/friends',
addFriend: '/api/v1/social/friend/add',
acceptFriend: '/api/v1/social/friend/handle-request',
deleteFriend: '/api/v1/social/friend',
search: '/api/v1/social/search',
friendRequests: '/api/v1/social/friend/requests',
friendRequestsCount: '/api/v1/social/friend/requests/count',
groups: '/api/v1/social/groups',
groupsCount: '/api/v1/social/groups/count'
},
},
// 小程序特有配置
miniprogram: {
// 页面路径
pages: {
splash: '/pages/splash/splash',
login: '/pages/login/login',
main: '/pages/main/main',
map: '/pages/map/map',
friends: '/pages/social/friends/friends',
message: '/pages/message/message',
profile: '/subpackages/profile/profile/profile'
},
// 主题配置
theme: {
primaryColor: '#3cc51f',
backgroundColor: '#F5F5F5',
textColor: '#333333',
subTextColor: '#999999'
},
// 地图配置
map: {
defaultZoom: 16,
minZoom: 3,
maxZoom: 20,
showLocation: true,
showScale: true,
showCompass: true
}
},
// 调试配置
debug: {
enabled: true,
showLog: true,
mockData: false
}
};
module.exports = mergeDeep(baseConfig, privateConfig);