|
@@ -70,7 +70,7 @@ export const api = !global.android
|
|
return URL.createObjectURL(base64ToBlob(base64));
|
|
return URL.createObjectURL(base64ToBlob(base64));
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- async photograph() {
|
|
|
|
|
|
+ async photograph(rotate = true) {
|
|
const file = await new Promise<File>((resolve) => {
|
|
const file = await new Promise<File>((resolve) => {
|
|
const input = document.createElement("input");
|
|
const input = document.createElement("input");
|
|
input.type = "file";
|
|
input.type = "file";
|
|
@@ -81,10 +81,10 @@ export const api = !global.android
|
|
});
|
|
});
|
|
|
|
|
|
const url = await this.uploadImage(file);
|
|
const url = await this.uploadImage(file);
|
|
- return await normalImage(url);
|
|
|
|
|
|
+ return rotate ? await normalImage(url) : url;
|
|
},
|
|
},
|
|
- async selectPhotoAlbum() {
|
|
|
|
- return await this.photograph();
|
|
|
|
|
|
+ async selectPhotoAlbum(rotate = true) {
|
|
|
|
+ return await this.photograph(rotate);
|
|
},
|
|
},
|
|
async closePage() {
|
|
async closePage() {
|
|
return router.push({ name: writeRouteName.scene });
|
|
return router.push({ name: writeRouteName.scene });
|
|
@@ -184,23 +184,31 @@ export const api = !global.android
|
|
global.android.downloadImage(file.name, data, apiName);
|
|
global.android.downloadImage(file.name, data, apiName);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- photograph() {
|
|
|
|
|
|
+ photograph(rotate = true) {
|
|
return new Promise<string>((resolve) => {
|
|
return new Promise<string>((resolve) => {
|
|
const apiName = `photograph${count++}`;
|
|
const apiName = `photograph${count++}`;
|
|
global[apiName] = (data) => {
|
|
global[apiName] = (data) => {
|
|
console.log("拍照后路径:", data);
|
|
console.log("拍照后路径:", data);
|
|
- data ? normalImage(data).then(resolve) : resolve(null);
|
|
|
|
|
|
+ data
|
|
|
|
+ ? rotate
|
|
|
|
+ ? normalImage(data).then(resolve)
|
|
|
|
+ : resolve(data)
|
|
|
|
+ : resolve(null);
|
|
delete global[apiName];
|
|
delete global[apiName];
|
|
};
|
|
};
|
|
global.android.cameraPhotograph(params.m, apiName);
|
|
global.android.cameraPhotograph(params.m, apiName);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- selectPhotoAlbum() {
|
|
|
|
|
|
+ selectPhotoAlbum(rotate = true) {
|
|
return new Promise<string>((resolve) => {
|
|
return new Promise<string>((resolve) => {
|
|
const apiName = `selectPhotoAlbum${count++}`;
|
|
const apiName = `selectPhotoAlbum${count++}`;
|
|
global[apiName] = (data) => {
|
|
global[apiName] = (data) => {
|
|
console.log("获得相册图片路径:", data);
|
|
console.log("获得相册图片路径:", data);
|
|
- data ? normalImage(data).then(resolve) : resolve(null);
|
|
|
|
|
|
+ data
|
|
|
|
+ ? rotate
|
|
|
|
+ ? normalImage(data).then(resolve)
|
|
|
|
+ : resolve(data)
|
|
|
|
+ : resolve(null);
|
|
delete global[apiName];
|
|
delete global[apiName];
|
|
};
|
|
};
|
|
global.android.selectPhotoAlbum(params.m, apiName);
|
|
global.android.selectPhotoAlbum(params.m, apiName);
|