Browse Source

first-commit

master
jian 2 years ago
commit
2dfd358193
  1. 0
      index.css
  2. 21
      index.html
  3. 78
      index.js
  4. 0
      paper/paper_1.js
  5. 1
      paper/utils.js
  6. 1
      third/zip-no-worker-inflate.min.js

21
index.html

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel='stylesheet' type='text/css' href="./index.css" />
</head>
<body>
<div id="container">
<label>
<span class="form-label">choose a zip file</span>
<button id="file-input-button">Open...</button>
<input type="file" id="file-input" accept="application/zip" hidden>
</label>
</div>
<script src="./third/zip-no-worker-inflate.min.js"></script>
<script src="./index.js"></script>
</body>
</html>

78
index.js

@ -0,0 +1,78 @@
(() => {
window.BIScore = window.BIScore || {};
const model = (() => {
return {
getEntries(file) {
return (new zip.ZipReader(new zip.BlobReader(file))).getEntries();
},
async getContent(entry) {
const contentBlob = new TransformStream();
const contentBlobPromise = new Response(contentBlob.readable).text();
await entry.getData(contentBlob);
const content = await contentBlobPromise;
return content;
}
};
})();
(() => {
zip.configure({
useWebWorkers: false,
});
const fileInput = document.getElementById("file-input");
const fileInputButton = document.getElementById("file-input-button");
let entries;
let selectedFile;
fileInput.onchange = selectFile;
fileInputButton.onclick = clickInputButton;
function clickInputButton() {
fileInput.dispatchEvent(new MouseEvent("click"))
}
async function selectFile() {
try {
fileInputButton.disabled = true;
selectedFile = fileInput.files[0];
await getReportJson();
} catch (error) {
alert('zip 解析错误');
console.log(error);
} finally {
fileInputButton.disabled = false;
fileInput.value = "";
}
}
async function getReportJson() {
entries = await model.getEntries(selectedFile);
const reportEntries = [];
if (entries && entries.length) {
entries.forEach((entry) => {
if (entry.filename.indexOf('.fbi') > -1) {
reportEntries.push(entry);
}
});
}
if (reportEntries.length < 1) {
alert('未找到仪表板');
return;
}
if (reportEntries.lenght > 1) {
alert('只可导出一个仪表板');
}
model.getContent(reportEntries[0]).then((content) => {
console.log(JSON.parse(content));
});
}
})();
})();

0
paper/paper_1.js

1
paper/utils.js

@ -0,0 +1 @@
BIScore.Utils = {};

1
third/zip-no-worker-inflate.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save