diff --git a/node_modules/@types/noname-typings/index.d.ts b/node_modules/@types/noname-typings/index.d.ts
index 387ebd5ce..c89de0bb4 100644
--- a/node_modules/@types/noname-typings/index.d.ts
+++ b/node_modules/@types/noname-typings/index.d.ts
@@ -9,6 +9,8 @@
///
///
///
+///
+///
///
///
///
diff --git a/node_modules/@types/noname-typings/windowEx.d.ts b/node_modules/@types/noname-typings/windowEx.d.ts
index fca9c3721..f089f6478 100644
--- a/node_modules/@types/noname-typings/windowEx.d.ts
+++ b/node_modules/@types/noname-typings/windowEx.d.ts
@@ -70,4 +70,6 @@ declare interface Window {
initReadWriteFunction?(game: Game): Promise;
bannedKeyWords: string[];
+
+ device: Device;
}
diff --git a/noname/init/cordova.js b/noname/init/cordova.js
index 73e8904b2..97da9302a 100644
--- a/noname/init/cordova.js
+++ b/noname/init/cordova.js
@@ -1,10 +1,10 @@
-// @ts-nocheck
import { get } from "../get/index.js";
import { lib } from "../library/index.js";
import { game } from "../game/index.js";
import { _status } from "../status/index.js";
import { ui } from "../ui/index.js";
import { nonameInitialized } from "../util/index.js";
+import { checkVersion } from "../library/update.js";
export async function cordovaReady() {
if (lib.device == "android") {
@@ -49,18 +49,30 @@ export async function cordovaReady() {
if ("cordova" in window && "plugins" in window.cordova && "permissions" in window.cordova.plugins) {
const permissions = cordova.plugins.permissions;
const requests = ["WRITE_EXTERNAL_STORAGE", "READ_EXTERNAL_STORAGE"];
- requests.forEach((request) => {
- permissions.checkPermission(
- permissions[request],
- (status) => {
- if (!status.hasPermission) {
- permissions.requestPermission(
- permissions[request],
- lib.other.ignore,
- lib.other.ignore
- );
- }
- },
+ if (typeof device == 'object') {
+ // 安卓13或以上
+ if (checkVersion(device.version, "13") >= 0) {
+ requests.length = 0;
+ requests.push('READ_MEDIA_IMAGES', 'READ_MEDIA_VIDEO', 'READ_MEDIA_AUDIO');
+ }
+ }
+ Promise.all(requests.map(request => {
+ return new Promise((resolve, reject) => {
+ permissions.checkPermission(permissions[request], status => {
+ resolve({
+ request: request,
+ hasPermission: status.hasPermission
+ });
+ }, lib.other.ignore);
+ });
+ })).then(shouldRequestPermissions => {
+ return shouldRequestPermissions
+ .filter(({ hasPermission }) => !hasPermission)
+ .map(({ request }) => permissions[request]);
+ }).then(willRequestPermissions => {
+ permissions.requestPermissions(
+ willRequestPermissions,
+ lib.other.ignore,
lib.other.ignore
);
});