capacitor.config.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { CapacitorConfig } from '@capacitor/cli';
  2. // import { updateVersion } from './scripts/sync-version';
  3. // updateVersion()
  4. // 获取本地服务
  5. console.log("import.meta.env=", process.env.DAPP_BUILD)
  6. const config: CapacitorConfig = {
  7. appId: 'com.example.app',
  8. appName: 'AngelToken',
  9. webDir: 'dist',
  10. // 插件配置
  11. plugins: {
  12. CapacitorAssets: {
  13. iconBackgroundColor: '#ffffff' // 应用图标背景色
  14. },
  15. // 注意:原JSON中嵌套了重复的"plugins"键,已修正
  16. PushNotifications: {
  17. presentationOptions: ['badge', 'sound', 'alert']
  18. }
  19. },
  20. // iOS专属配置
  21. ios: {
  22. scheme: 'App',
  23. scrollEnabled: true,
  24. },
  25. // Android专属配置
  26. android: {
  27. allowMixedContent: true, // 允许混合HTTP/HTTPS内容
  28. useLegacyBridge: true, // 使用旧版桥接(兼容性)
  29. // 签名证书配置(建议通过环境变量注入敏感信息)
  30. buildOptions: {
  31. keystorePath: 'f62.keystore',
  32. keystoreAlias: 'f62', // // 生成时指定的别名
  33. keystorePassword: 'LkSvN1Ys', // 从环境变量读取
  34. keystoreAliasPassword: 'LkSvN1Ys'
  35. }
  36. }
  37. };
  38. // 开发服务器配置(热更新用)
  39. if (process.env.DAPP_BUILD != "1") {
  40. config.server = {
  41. url: 'http://192.168.0.70:5173',
  42. cleartext: true, // 允许HTTP明文通信(仅开发环境)
  43. allowNavigation: ['*'] // 允许任意URL导航
  44. }
  45. }
  46. export default config;