mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-11 23:45:11 +08:00
1.6.5
This commit is contained in:
@@ -8,9 +8,12 @@ import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.net.Uri;
|
||||
import android.content.Intent;
|
||||
import androidx.core.splashscreen.SplashScreen;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
@@ -18,6 +21,8 @@ import com.getcapacitor.BridgeActivity;
|
||||
|
||||
public class MainActivity extends BridgeActivity {
|
||||
private boolean isWebViewReady = false;
|
||||
private static final int FILE_CHOOSER_REQUEST_CODE = 1001;
|
||||
private ValueCallback<Uri[]> filePathCallback;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -94,7 +99,50 @@ public class MainActivity extends BridgeActivity {
|
||||
isWebViewReady = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
|
||||
FileChooserParams fileChooserParams) {
|
||||
// 清理之前的回调
|
||||
if (MainActivity.this.filePathCallback != null) {
|
||||
MainActivity.this.filePathCallback.onReceiveValue(null);
|
||||
}
|
||||
|
||||
MainActivity.this.filePathCallback = filePathCallback;
|
||||
|
||||
// 创建文件选择器 Intent
|
||||
Intent intent = fileChooserParams.createIntent();
|
||||
try {
|
||||
startActivityForResult(intent, FILE_CHOOSER_REQUEST_CODE);
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
MainActivity.this.filePathCallback = null;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (requestCode == FILE_CHOOSER_REQUEST_CODE) {
|
||||
if (filePathCallback == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Uri[] results = null;
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
String dataString = data.getDataString();
|
||||
if (dataString != null) {
|
||||
results = new Uri[]{Uri.parse(dataString)};
|
||||
}
|
||||
}
|
||||
|
||||
filePathCallback.onReceiveValue(results);
|
||||
filePathCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"private": true,
|
||||
"version": "1.6.5",
|
||||
"buildDate": "2026/1/23 01:10:25",
|
||||
"buildDate": "2026/1/23 02:22:24",
|
||||
"main": "dist-electron/main.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<p class="text-sm text-muted-foreground">{{ t('settings.importDataDesc') }}</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<input ref="fileInputRef" type="file" accept=".json" class="hidden" @change="handleFileSelect" />
|
||||
<input ref="fileInputRef" type="file" accept=".json,application/json,text/plain" class="hidden" @change="handleFileSelect" />
|
||||
<Button @click="triggerFileInput" variant="outline">
|
||||
<Upload class="mr-2 h-4 w-4" />
|
||||
{{ t('settings.selectFile') }}
|
||||
|
||||
Reference in New Issue
Block a user