Fix: 修复平板设备下打开文件时无法选择本地文件
This commit is contained in:
@@ -25,46 +25,13 @@ const { File } = Web;
|
|||||||
File.obj = null;
|
File.obj = null;
|
||||||
|
|
||||||
File.open = async () => {
|
File.open = async () => {
|
||||||
if (window.location.protocol === 'https:') {
|
const filters = '.' + MFile.openFilters.join(',.');
|
||||||
let filters = [];
|
MFile.openFile(filters, 'text', (fileObj) => {
|
||||||
MFile.openFilters.map((data) => {
|
let { data, filename } = fileObj;
|
||||||
filters.push('.' + data);
|
const extname = path.extname(filename);
|
||||||
});
|
File.parseData(extname, data);
|
||||||
const fileConfig = {
|
Title.updateTitle(filename + ' - ' + Title.title);
|
||||||
multiple: false,
|
});
|
||||||
types: [{
|
|
||||||
description: 'Mixly File',
|
|
||||||
accept: {
|
|
||||||
'application/xml': filters
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
suggestedStartLocation: 'pictures-library'
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
const [ obj ] = await window.showOpenFilePicker(fileConfig);
|
|
||||||
if (!obj) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
File.obj = obj;
|
|
||||||
const extname = path.extname(obj.name);
|
|
||||||
const fileInfo = await File.obj.getFile();
|
|
||||||
if (!fileInfo) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
File.parseData(extname, await fileInfo.text());
|
|
||||||
Title.updateTitle(obj.name + ' - ' + Title.title);
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const filters = '.' + MFile.openFilters.join(',.');
|
|
||||||
MFile.openFile(filters, 'text', (fileObj) => {
|
|
||||||
let { data, filename } = fileObj;
|
|
||||||
const extname = path.extname(filename);
|
|
||||||
File.parseData(extname, data);
|
|
||||||
Title.updateTitle(filename + ' - ' + Title.title);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File.parseData = (extname, text) => {
|
File.parseData = (extname, text) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user