capacitor.config.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { CapacitorConfig } from '@capacitor/cli';
  2. import * as fs from 'fs';
  3. // 读取 package.json 的 version
  4. const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
  5. const appVersion = packageJson.version;
  6. const config: CapacitorConfig = {
  7. appId: 'com.example.app',
  8. appName: 'wallet_app',
  9. webDir: 'dist',
  10. // 开发服务器配置(热更新用)
  11. server: {
  12. url: 'http://192.168.0.59:5173',
  13. cleartext: true, // 允许HTTP明文通信(仅开发环境)
  14. allowNavigation: ['*'] // 允许任意URL导航
  15. },
  16. // 插件配置
  17. plugins: {
  18. SplashScreen: {
  19. launchShowDuration: 3000,
  20. launchAutoHide: true,
  21. backgroundColor: '#ffffffff', // ARGB格式白色背景
  22. androidScaleType: 'CENTER_CROP',
  23. showSpinner: false,
  24. androidSpinnerStyle: 'large',
  25. iosSpinnerStyle: 'small',
  26. spinnerColor: '#999999',
  27. splashFullScreen: true,
  28. splashImmersive: true,
  29. androidSplashResourceName: 'splash',
  30. useDialog: false
  31. },
  32. CapacitorAssets: {
  33. iconBackgroundColor: '#ffffff' // 应用图标背景色
  34. },
  35. // 注意:原JSON中嵌套了重复的"plugins"键,已修正
  36. PushNotifications: {
  37. presentationOptions: ['badge', 'sound', 'alert']
  38. },
  39. VersionSync: {
  40. version: appVersion, // 直接传递版本号
  41. },
  42. },
  43. // 资源文件配置
  44. // assets: {
  45. // splash: {
  46. // src: 'assets/splash.png', // 启动图路径
  47. // android: true,
  48. // ios: true
  49. // }
  50. // },
  51. // iOS专属配置
  52. ios: {
  53. scheme: 'App',
  54. scrollEnabled: true,
  55. },
  56. // Android专属配置
  57. android: {
  58. allowMixedContent: true, // 允许混合HTTP/HTTPS内容
  59. useLegacyBridge: true, // 使用旧版桥接(兼容性)
  60. // 签名证书配置(建议通过环境变量注入敏感信息)
  61. buildOptions: {
  62. keystorePath: 'f62.keystore',
  63. keystoreAlias: 'f62', // // 生成时指定的别名
  64. keystorePassword: 'LkSvN1Ys', // 从环境变量读取
  65. keystoreAliasPassword: 'LkSvN1Ys'
  66. }
  67. }
  68. };
  69. export default config;