hxMac преди 1 месец
родител
ревизия
a37d2cd419

+ 5 - 2
UtilsApplication/app/app/build.gradle

@@ -2,7 +2,9 @@ plugins {
     alias(libs.plugins.android.application)
     alias(libs.plugins.jetbrains.kotlin.android)
 }
-
+Properties properties = new Properties()
+InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream()
+properties.load(inputStream)
 android {
     namespace 'com.hx.utils.application'
     compileSdk 35
@@ -13,7 +15,7 @@ android {
         targetSdk 35
         versionCode 1
         versionName "1.0"
-
+        buildConfigField('String', 'testUrl', properties.getProperty('testUrl'))
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     }
 
@@ -32,6 +34,7 @@ android {
     }
     buildFeatures {
         viewBinding true
+        buildConfig true
     }
 }
 

+ 3 - 2
UtilsApplication/app/app/src/main/java/com/hx/utils/application/ui/web/WebFragment.kt

@@ -9,6 +9,7 @@ import androidx.appcompat.app.AlertDialog
 import androidx.appcompat.app.AppCompatActivity
 import androidx.fragment.app.Fragment
 import androidx.lifecycle.ViewModelProvider
+import com.hx.utils.application.BuildConfig
 import com.hx.utils.application.base.BaseWebView
 import com.hx.utils.application.databinding.FragmentWebBinding
 
@@ -35,9 +36,9 @@ class WebFragment : Fragment() {
                 errorTip()
 
         }
-        webView?.loadUrl("初始默认地址") ?: run {
+        webView?.loadUrl(BuildConfig.testUrl) ?: run {
             webView = BaseWebView(requireActivity()).apply {
-                loadUrl("初始默认地址")
+                loadUrl(BuildConfig.testUrl)
             }
             binding.mainWeb.addView(
                 webView, LinearLayout.LayoutParams(