capacitor.config.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { CapacitorConfig } from '@capacitor/cli';
  2. import { updateVersion } from './scripts/sync-version';
  3. // 获取本地服务
  4. console.log("import.meta.env=", process.env.DAPP_BUILD)
  5. const config: CapacitorConfig = {
  6. appId: 'com.acc.app',
  7. appName: 'AngelTokens',
  8. webDir: 'dist',
  9. // 插件配置
  10. plugins: {
  11. CapacitorAssets: {
  12. iconBackgroundColor: '#ffffff' // 应用图标背景色
  13. },
  14. // 注意:原JSON中嵌套了重复的"plugins"键,已修正
  15. PushNotifications: {
  16. presentationOptions: ['badge', 'sound', 'alert']
  17. },
  18. CapacitorUpdater: {
  19. autoUpdate: false, // 自行控制
  20. statsUrl: '', // 统计上报: POST /api/stats 接收 JSON(内容是插件的事件日志),返回 200 即可。
  21. },
  22. LocalNotifications: {
  23. sound: "" // 为空:使用默认的系统通知声音。如果未提供,则 Android 系统将发出默认声音,iOS 系统则不发出声音。
  24. }
  25. },
  26. // iOS专属配置
  27. ios: {
  28. scheme: 'acc',
  29. scrollEnabled: true,
  30. },
  31. // Android专属配置
  32. android: {
  33. allowMixedContent: true, // 允许混合HTTP/HTTPS内容
  34. useLegacyBridge: true, // 使用旧版桥接(兼容性)
  35. // 签名证书配置(建议通过环境变量注入敏感信息)
  36. buildOptions: {
  37. keystorePath: 'f62.keystore',
  38. keystoreAlias: 'f62', // // 生成时指定的别名
  39. keystorePassword: 'LkSvN1Ys', // 从环境变量读取
  40. keystoreAliasPassword: 'LkSvN1Ys'
  41. }
  42. }
  43. };
  44. // 开发服务器配置(热更新用)
  45. if (process.env.DAPP_BUILD != "1") {
  46. config.server = {
  47. url: 'http://192.168.0.59:5173',
  48. cleartext: true, // 允许HTTP明文通信(仅开发环境)
  49. allowNavigation: ['*'] // 允许任意URL导航
  50. }
  51. }else{
  52. updateVersion()
  53. }
  54. export default config;