diff --git a/.eslintrc.js b/.eslintrc.js index b1f42868dfb8..2adc439e07cf 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -48,6 +48,7 @@ module.exports = { 'react/prop-types': 0, 'react/no-find-dom-node': 0, 'react/no-unknown-property': 0, + 'import/no-named-default': 'off', quotes: [2, 'single', { avoidEscape: true, allowTemplateLiterals: true }], semi: [2, 'never'], 'simple-import-sort/imports': [2, { diff --git a/client/android/.gitignore b/client/android/.gitignore new file mode 100644 index 000000000000..e8fa775bf1ef --- /dev/null +++ b/client/android/.gitignore @@ -0,0 +1,13 @@ +*.iml +.gradle +/local.properties +.idea/ +misc.xml +deploymentTargetDropDown.xml +render.experimental.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/client/android/README.md b/client/android/README.md new file mode 100644 index 000000000000..9312242a5bec --- /dev/null +++ b/client/android/README.md @@ -0,0 +1,5 @@ +# Taro小程序Android端SDK + +## 测试方式 + +把编译完成的小程序dist目录复制到android/library/src/main/assets目录下,重新运行此项目即可 \ No newline at end of file diff --git a/client/android/app/.gitignore b/client/android/app/.gitignore new file mode 100644 index 000000000000..42afabfd2abe --- /dev/null +++ b/client/android/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/client/android/app/build.gradle b/client/android/app/build.gradle new file mode 100644 index 000000000000..6499354759fa --- /dev/null +++ b/client/android/app/build.gradle @@ -0,0 +1,45 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +} + +android { + namespace 'com.taro.android.sample' + compileSdk 33 + + defaultConfig { + applicationId "com.taro.android.sample" + minSdk 21 + targetSdk 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.8.0' + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + implementation project(path: ':library') + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' +} \ No newline at end of file diff --git a/client/android/app/proguard-rules.pro b/client/android/app/proguard-rules.pro new file mode 100644 index 000000000000..481bb4348141 --- /dev/null +++ b/client/android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/client/android/app/src/androidTest/java/com/taro/android/sample/ExampleInstrumentedTest.kt b/client/android/app/src/androidTest/java/com/taro/android/sample/ExampleInstrumentedTest.kt new file mode 100644 index 000000000000..5b1d8f757011 --- /dev/null +++ b/client/android/app/src/androidTest/java/com/taro/android/sample/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.taro.android.sample + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.taro.android.sample", appContext.packageName) + } +} \ No newline at end of file diff --git a/client/android/app/src/main/AndroidManifest.xml b/client/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..d39dde645be0 --- /dev/null +++ b/client/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/client/android/app/src/main/java/com/taro/android/sample/MainActivity.kt b/client/android/app/src/main/java/com/taro/android/sample/MainActivity.kt new file mode 100644 index 000000000000..9c9eae32a274 --- /dev/null +++ b/client/android/app/src/main/java/com/taro/android/sample/MainActivity.kt @@ -0,0 +1,19 @@ +package com.taro.android.sample + +import android.content.Intent +import android.os.Bundle +import android.widget.Button +import androidx.appcompat.app.AppCompatActivity +import com.taro.android.TaroActivity + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + findViewById