capacitor.config.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. CapacitorUpdater: {
  20. autoUpdate: false, // 自行控制
  21. statsUrl: '', // 统计上报: POST /api/stats 接收 JSON(内容是插件的事件日志),返回 200 即可。
  22. }
  23. },
  24. // iOS专属配置
  25. ios: {
  26. scheme: 'App',
  27. scrollEnabled: true,
  28. },
  29. // Android专属配置
  30. android: {
  31. allowMixedContent: true, // 允许混合HTTP/HTTPS内容
  32. useLegacyBridge: true, // 使用旧版桥接(兼容性)
  33. // 签名证书配置(建议通过环境变量注入敏感信息)
  34. buildOptions: {
  35. keystorePath: 'f62.keystore',
  36. keystoreAlias: 'f62', // // 生成时指定的别名
  37. keystorePassword: 'LkSvN1Ys', // 从环境变量读取
  38. keystoreAliasPassword: 'LkSvN1Ys'
  39. }
  40. }
  41. };
  42. // 开发服务器配置(热更新用)
  43. if (process.env.DAPP_BUILD != "1") {
  44. config.server = {
  45. url: 'http://192.168.0.59:5173',
  46. cleartext: true, // 允许HTTP明文通信(仅开发环境)
  47. allowNavigation: ['*'] // 允许任意URL导航
  48. }
  49. }
  50. export default config;