13c4a2ca49
- 更新next.config.ts配置以优化图片和静态资源 - 优化字体加载策略,减少首屏阻塞 - 使用Next.js Image组件替换img标签并实现懒加载 - 重构移动端菜单交互,提升触摸体验 - 新增安全测试和可访问性测试用例 - 修复导航栏滚动定位问题 - 更新部署就绪测试脚本 - 添加相关文档说明优化细节
83 lines
2.0 KiB
TypeScript
83 lines
2.0 KiB
TypeScript
export interface EnvironmentConfig {
|
|
name: string;
|
|
baseURL: string;
|
|
apiURL: string;
|
|
timeout: number;
|
|
retries: number;
|
|
headless: boolean;
|
|
slowMo: number;
|
|
screenshot: 'on' | 'off' | 'only-on-failure';
|
|
video: 'on' | 'off' | 'retain-on-failure';
|
|
trace: 'on' | 'off' | 'retain-on-failure';
|
|
}
|
|
|
|
export const environments: Record<string, EnvironmentConfig> = {
|
|
development: {
|
|
name: 'development',
|
|
baseURL: 'http://localhost:3000',
|
|
apiURL: 'http://localhost:3000/api',
|
|
timeout: 120000,
|
|
retries: 0,
|
|
headless: false,
|
|
slowMo: 100,
|
|
screenshot: 'only-on-failure',
|
|
video: 'retain-on-failure',
|
|
trace: 'retain-on-failure',
|
|
},
|
|
staging: {
|
|
name: 'staging',
|
|
baseURL: 'https://staging.novalon.com',
|
|
apiURL: 'https://staging.novalon.com/api',
|
|
timeout: 120000,
|
|
retries: 1,
|
|
headless: true,
|
|
slowMo: 0,
|
|
screenshot: 'only-on-failure',
|
|
video: 'retain-on-failure',
|
|
trace: 'retain-on-failure',
|
|
},
|
|
production: {
|
|
name: 'production',
|
|
baseURL: 'https://novalon.com',
|
|
apiURL: 'https://novalon.com/api',
|
|
timeout: 120000,
|
|
retries: 2,
|
|
headless: true,
|
|
slowMo: 0,
|
|
screenshot: 'only-on-failure',
|
|
video: 'retain-on-failure',
|
|
trace: 'retain-on-failure',
|
|
},
|
|
};
|
|
|
|
export function getEnvironment(): EnvironmentConfig {
|
|
const envName = process.env.TEST_ENV || 'development';
|
|
const env = environments[envName];
|
|
|
|
if (!env) {
|
|
throw new Error(`Unknown environment: ${envName}. Valid environments: ${Object.keys(environments).join(', ')}`);
|
|
}
|
|
|
|
return env;
|
|
}
|
|
|
|
export function getBaseURL(): string {
|
|
return getEnvironment().baseURL;
|
|
}
|
|
|
|
export function getApiURL(): string {
|
|
return getEnvironment().apiURL;
|
|
}
|
|
|
|
export function isDevelopment(): boolean {
|
|
return getEnvironment().name === 'development';
|
|
}
|
|
|
|
export function isStaging(): boolean {
|
|
return getEnvironment().name === 'staging';
|
|
}
|
|
|
|
export function isProduction(): boolean {
|
|
return getEnvironment().name === 'production';
|
|
}
|