适配Web实验报告

This commit is contained in:
shenjianxing 2025-04-22 11:00:36 +08:00
parent 60b0c24b43
commit d0e07bc814
55 changed files with 18754 additions and 5 deletions

View File

@ -129,7 +129,7 @@ Material:
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:
- _BaseColor: {r: 0.18446434, g: 0.42922786, b: 0.6204994, a: 1} - _BaseColor: {r: 0.18446434, g: 0.42922786, b: 0.6204994, a: 1}
- _Color: {r: 0.18446434, g: 0.42922786, b: 0.6204994, a: 1} - _Color: {r: 0.1844643, g: 0.42922783, b: 0.6204993, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []

View File

@ -111,7 +111,7 @@ MonoBehaviour:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_FontData: m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} m_Font: {fileID: 12800000, guid: 20ebdb412ee9aec4a9d3005965d9c962, type: 3}
m_FontSize: 16 m_FontSize: 16
m_FontStyle: 0 m_FontStyle: 0
m_BestFit: 0 m_BestFit: 0

View File

@ -111,7 +111,7 @@ MonoBehaviour:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_FontData: m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} m_Font: {fileID: 12800000, guid: 20ebdb412ee9aec4a9d3005965d9c962, type: 3}
m_FontSize: 16 m_FontSize: 16
m_FontStyle: 0 m_FontStyle: 0
m_BestFit: 0 m_BestFit: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7bb6883646529814d8585e6baa691440
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1b7643cfda78b234985b0d046709991a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,188 @@
/* FileSaver.js
* A saveAs() FileSaver implementation.
* 1.3.2
* 2016-06-16 18:25:19
*
* By Eli Grey, http://eligrey.com
* License: MIT
* See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
*/
/*global self */
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs = saveAs || (function(view) {
"use strict";
// IE <10 is explicitly unsupported
if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
return;
}
var
doc = view.document
// only get URL when necessary in case Blob.js hasn't overridden it yet
, get_URL = function() {
return view.URL || view.webkitURL || view;
}
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
, can_use_save_link = "download" in save_link
, click = function(node) {
var event = new MouseEvent("click");
node.dispatchEvent(event);
}
, is_safari = /constructor/i.test(view.HTMLElement) || view.safari
, is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent)
, throw_outside = function(ex) {
(view.setImmediate || view.setTimeout)(function() {
throw ex;
}, 0);
}
, force_saveable_type = "application/octet-stream"
// the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
, arbitrary_revoke_timeout = 1000 * 40 // in ms
, revoke = function(file) {
var revoker = function() {
if (typeof file === "string") { // file is an object URL
get_URL().revokeObjectURL(file);
} else { // file is a File
file.remove();
}
};
setTimeout(revoker, arbitrary_revoke_timeout);
}
, dispatch = function(filesaver, event_types, event) {
event_types = [].concat(event_types);
var i = event_types.length;
while (i--) {
var listener = filesaver["on" + event_types[i]];
if (typeof listener === "function") {
try {
listener.call(filesaver, event || filesaver);
} catch (ex) {
throw_outside(ex);
}
}
}
}
, auto_bom = function(blob) {
// prepend BOM for UTF-8 XML and text/* types (including HTML)
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});
}
return blob;
}
, FileSaver = function(blob, name, no_auto_bom) {
if (!no_auto_bom) {
blob = auto_bom(blob);
}
// First try a.download, then web filesystem, then object URLs
var
filesaver = this
, type = blob.type
, force = type === force_saveable_type
, object_url
, dispatch_all = function() {
dispatch(filesaver, "writestart progress write writeend".split(" "));
}
// on any filesys errors revert to saving with object URLs
, fs_error = function() {
if ((is_chrome_ios || (force && is_safari)) && view.FileReader) {
// Safari doesn't allow downloading of blob urls
var reader = new FileReader();
reader.onloadend = function() {
var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');
var popup = view.open(url, '_blank');
if(!popup) view.location.href = url;
url=undefined; // release reference before dispatching
filesaver.readyState = filesaver.DONE;
dispatch_all();
};
reader.readAsDataURL(blob);
filesaver.readyState = filesaver.INIT;
return;
}
// don't create more object URLs than needed
if (!object_url) {
object_url = get_URL().createObjectURL(blob);
}
if (force) {
view.location.href = object_url;
} else {
var opened = view.open(object_url, "_blank");
if (!opened) {
// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
view.location.href = object_url;
}
}
filesaver.readyState = filesaver.DONE;
dispatch_all();
revoke(object_url);
}
;
filesaver.readyState = filesaver.INIT;
if (can_use_save_link) {
object_url = get_URL().createObjectURL(blob);
setTimeout(function() {
save_link.href = object_url;
save_link.download = name;
click(save_link);
dispatch_all();
revoke(object_url);
filesaver.readyState = filesaver.DONE;
});
return;
}
fs_error();
}
, FS_proto = FileSaver.prototype
, saveAs = function(blob, name, no_auto_bom) {
return new FileSaver(blob, name || blob.name || "download", no_auto_bom);
}
;
// IE 10+ (native saveAs)
if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
return function(blob, name, no_auto_bom) {
name = name || blob.name || "download";
if (!no_auto_bom) {
blob = auto_bom(blob);
}
return navigator.msSaveOrOpenBlob(blob, name);
};
}
FS_proto.abort = function(){};
FS_proto.readyState = FS_proto.INIT = 0;
FS_proto.WRITING = 1;
FS_proto.DONE = 2;
FS_proto.error =
FS_proto.onwritestart =
FS_proto.onprogress =
FS_proto.onwrite =
FS_proto.onabort =
FS_proto.onerror =
FS_proto.onwriteend =
null;
return saveAs;
}(
typeof self !== "undefined" && self
|| typeof window !== "undefined" && window
|| this.content
));
// `self` is undefined in Firefox for Android content script context
// while `this` is nsIContentFrameMessageManager
// with an attribute `content` that corresponds to the window
if (typeof module !== "undefined" && module.exports) {
module.exports.saveAs = saveAs;
} else if ((typeof define !== "undefined" && define !== null) && (define.amd !== null)) {
define("FileSaver.js", function() {
return saveAs;
});
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b553b668487059e46b20598af2094335
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 52a88145e15d97043b41a0ea7221595f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 095271581e49eaf449f5ebb880baea13
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,112 @@
"use strict";
const DocUtils = require("./docUtils");
const extensionRegex = /[^.]+\.([^.]+)/;
const rels = {
getPrefix(fileType) {
return fileType === "docx" ? "word" : "ppt";
},
getFileTypeName(fileType) {
return fileType === "docx" ? "document" : "presentation";
},
getRelsFileName(fileName) {
return fileName.replace(/^.*?([a-zA-Z0-9]+)\.xml$/, "$1") + ".xml.rels";
},
getRelsFilePath(fileName, fileType) {
const relsFileName = rels.getRelsFileName(fileName);
const prefix = fileType === "pptx" ? "ppt/slides" : "word";
return `${prefix}/_rels/${relsFileName}`;
},
};
module.exports = class ImgManager {
constructor(zip, fileName, xmlDocuments, fileType) {
this.fileName = fileName;
this.prefix = rels.getPrefix(fileType);
this.zip = zip;
this.xmlDocuments = xmlDocuments;
this.fileTypeName = rels.getFileTypeName(fileType);
this.mediaPrefix = fileType === "pptx" ? "../media" : "media";
const relsFilePath = rels.getRelsFilePath(fileName, fileType);
this.relsDoc = xmlDocuments[relsFilePath] || this.createEmptyRelsDoc(xmlDocuments, relsFilePath);
}
createEmptyRelsDoc(xmlDocuments, relsFileName) {
const mainRels = this.prefix + "/_rels/" + (this.fileTypeName) + ".xml.rels";
const doc = xmlDocuments[mainRels];
if (!doc) {
const err = new Error("Could not copy from empty relsdoc");
err.properties = {
mainRels,
relsFileName,
files: Object.keys(this.zip.files),
};
throw err;
}
const relsDoc = DocUtils.str2xml(DocUtils.xml2str(doc));
const relationships = relsDoc.getElementsByTagName("Relationships")[0];
const relationshipChilds = relationships.getElementsByTagName("Relationship");
for (let i = 0, l = relationshipChilds.length; i < l; i++) {
relationships.removeChild(relationshipChilds[i]);
}
xmlDocuments[relsFileName] = relsDoc;
return relsDoc;
}
loadImageRels() {
const iterable = this.relsDoc.getElementsByTagName("Relationship");
return Array.prototype.reduce.call(iterable, function (max, relationship) {
const id = relationship.getAttribute("Id");
if (/^rId[0-9]+$/.test(id)) {
return Math.max(max, parseInt(id.substr(3), 10));
}
return max;
}, 0);
}
// Add an extension type in the [Content_Types.xml], is used if for example you want word to be able to read png files (for every extension you add you need a contentType)
addExtensionRels(contentType, extension) {
const contentTypeDoc = this.xmlDocuments["[Content_Types].xml"];
const defaultTags = contentTypeDoc.getElementsByTagName("Default");
const extensionRegistered = Array.prototype.some.call(defaultTags, function (tag) {
return tag.getAttribute("Extension") === extension;
});
if (extensionRegistered) {
return;
}
const types = contentTypeDoc.getElementsByTagName("Types")[0];
const newTag = contentTypeDoc.createElement("Default");
newTag.namespaceURI = null;
newTag.setAttribute("ContentType", contentType);
newTag.setAttribute("Extension", extension);
types.appendChild(newTag);
}
// Add an image and returns it's Rid
addImageRels(imageName, imageData, i) {
if (i == null) {
i = 0;
}
const realImageName = i === 0 ? imageName : imageName + `(${i})`;
const imagePath = `${this.prefix}/media/${realImageName}`;
if (this.zip.files[imagePath] != null) {
return this.addImageRels(imageName, imageData, i + 1);
}
const image = {
name: imagePath,
data: imageData,
options: {
binary: true,
},
};
this.zip.file(image.name, image.data, image.options);
const extension = realImageName.replace(extensionRegex, "$1");
this.addExtensionRels(`image/${extension}`, extension);
const relationships = this.relsDoc.getElementsByTagName("Relationships")[0];
const newTag = this.relsDoc.createElement("Relationship");
newTag.namespaceURI = null;
const maxRid = this.loadImageRels() + 1;
newTag.setAttribute("Id", `rId${maxRid}`);
newTag.setAttribute("Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image");
newTag.setAttribute("Target", `${this.mediaPrefix}/${realImageName}`);
relationships.appendChild(newTag);
return maxRid;
}
};

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: db6aef5b5146b144e98c13ca162e5e5e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,176 @@
"use strict";
const templates = require("./templates");
const DocUtils = require("docxtemplater").DocUtils;
const DOMParser = require("xmldom").DOMParser;
function isNaN(number) {
return !(number === number);
}
const ImgManager = require("./imgManager");
const moduleName = "open-xml-templating/docxtemplater-image-module";
function getInnerDocx({part}) {
return part;
}
function getInnerPptx({part, left, right, postparsed}) {
const xmlString = postparsed.slice(left + 1, right).reduce(function (concat, item) {
return concat + item.value;
}, "");
const xmlDoc = new DOMParser().parseFromString("<xml>" + xmlString + "</xml>");
part.offset = {x: 0, y: 0};
part.ext = {cx: 0, cy: 0};
const offset = xmlDoc.getElementsByTagName("a:off");
const ext = xmlDoc.getElementsByTagName("a:ext");
if (ext.length > 0) {
part.ext.cx = parseInt(ext[ext.length - 1].getAttribute("cx"), 10);
part.ext.cy = parseInt(ext[ext.length - 1].getAttribute("cy"), 10);
}
if (offset.length > 0) {
part.offset.x = parseInt(offset[offset.length - 1].getAttribute("x"), 10);
part.offset.y = parseInt(offset[offset.length - 1].getAttribute("y"), 10);
}
return part;
}
class ImageModule {
constructor(options) {
this.name = "ImageModule";
this.options = options || {};
this.imgManagers = {};
if (this.options.centered == null) { this.options.centered = false; }
if (this.options.getImage == null) { throw new Error("You should pass getImage"); }
if (this.options.getSize == null) { throw new Error("You should pass getSize"); }
this.imageNumber = 1;
}
optionsTransformer(options, docxtemplater) {
const relsFiles = docxtemplater.zip.file(/\.xml\.rels/)
.concat(docxtemplater.zip.file(/\[Content_Types\].xml/))
.map((file) => file.name);
this.fileTypeConfig = docxtemplater.fileTypeConfig;
this.fileType = docxtemplater.fileType;
this.zip = docxtemplater.zip;
options.xmlFileNames = options.xmlFileNames.concat(relsFiles);
return options;
}
set(options) {
if (options.zip) {
this.zip = options.zip;
}
if (options.xmlDocuments) {
this.xmlDocuments = options.xmlDocuments;
}
}
parse(placeHolderContent) {
const module = moduleName;
const type = "placeholder";
if (this.options.setParser) {
return this.options.setParser(placeHolderContent);
}
if (placeHolderContent.substring(0, 2) === "%%") {
return {type, value: placeHolderContent.substr(2), module, centered: true};
}
if (placeHolderContent.substring(0, 1) === "%") {
return {type, value: placeHolderContent.substr(1), module, centered: false};
}
return null;
}
postparse(parsed) {
let expandTo;
let getInner;
if (this.fileType === "pptx") {
expandTo = "p:sp";
getInner = getInnerPptx;
}
else {
expandTo = this.options.centered ? "w:p" : "w:t";
getInner = getInnerDocx;
}
return DocUtils.traits.expandToOne(parsed, {moduleName, getInner, expandTo});
}
render(part, options) {
if (!part.type === "placeholder" || part.module !== moduleName) {
return null;
}
const tagValue = options.scopeManager.getValue(part.value, {
part: part,
});
if (!tagValue) {
return {value: this.fileTypeConfig.tagTextXml};
}
else if (typeof tagValue === "object") {
return this.getRenderedPart(part, tagValue.rId, tagValue.sizePixel);
}
const imgManager = new ImgManager(this.zip, options.filePath, this.xmlDocuments, this.fileType);
const imgBuffer = this.options.getImage(tagValue, part.value);
const rId = imgManager.addImageRels(this.getNextImageName(), imgBuffer);
const sizePixel = this.options.getSize(imgBuffer, tagValue, part.value);
return this.getRenderedPart(part, rId, sizePixel);
}
resolve(part, options) {
const imgManager = new ImgManager(this.zip, options.filePath, this.xmlDocuments, this.fileType);
if (!part.type === "placeholder" || part.module !== moduleName) {
return null;
}
const value = options.scopeManager.getValue(part.value, {
part: part,
});
if (!value) {
return {value: this.fileTypeConfig.tagTextXml};
}
return new Promise((resolve) => {
const imgBuffer = this.options.getImage(value, part.value);
resolve(imgBuffer);
}).then((imgBuffer) => {
const rId = imgManager.addImageRels(this.getNextImageName(), imgBuffer);
return new Promise((resolve) => {
const sizePixel = this.options.getSize(imgBuffer, value, part.value);
resolve(sizePixel);
}).then((sizePixel) => {
return {
rId: rId,
sizePixel: sizePixel,
};
});
});
}
getRenderedPart(part, rId, sizePixel) {
if (isNaN(rId)) {
throw new Error("rId is NaN, aborting");
}
const size = [DocUtils.convertPixelsToEmus(sizePixel[0]), DocUtils.convertPixelsToEmus(sizePixel[1])];
const centered = (this.options.centered || part.centered);
let newText;
if (this.fileType === "pptx") {
newText = this.getRenderedPartPptx(part, rId, size, centered);
}
else {
newText = this.getRenderedPartDocx(rId, size, centered);
}
return {value: newText};
}
getRenderedPartPptx(part, rId, size, centered) {
const offset = {x: parseInt(part.offset.x, 10), y: parseInt(part.offset.y, 10)};
const cellCX = parseInt(part.ext.cx, 10) || 1;
const cellCY = parseInt(part.ext.cy, 10) || 1;
const imgW = parseInt(size[0], 10) || 1;
const imgH = parseInt(size[1], 10) || 1;
if (centered) {
offset.x = Math.round(offset.x + (cellCX / 2) - (imgW / 2));
offset.y = Math.round(offset.y + (cellCY / 2) - (imgH / 2));
}
return templates.getPptxImageXml(rId, [imgW, imgH], offset);
}
getRenderedPartDocx(rId, size, centered) {
return centered ? templates.getImageXmlCentered(rId, size) : templates.getImageXml(rId, size);
}
getNextImageName() {
const name = `image_generated_${this.imageNumber}.png`;
this.imageNumber++;
return name;
}
}
module.exports = ImageModule;

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4adcc011b5c00c546bb56bb78c51b048
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4082be133e63a564fa250e363c74a70a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,42 @@
{
"name": "docxtemplater-image-module-free",
"version": "1.1.1",
"description": "Open Source Image Module for docxtemplater",
"main": "js/index.js",
"scripts": {
"test:coverage": "istanbul cover _mocha -- es6/test.js",
"compile": "rimraf js && mkdirp js && babel es6 --out-dir js",
"preversion": "npm test && npm run browserify && npm run uglify",
"test:compiled": "mocha js/test.js",
"test:es6": "mocha es6/test.js",
"lint": "eslint .",
"test": "npm run compile && npm run test:compiled",
"browserify": "rimraf build && mkdirp build && browserify --insert-global-vars __filename,__dirname -r ./js/index.js -s ImageModule > build/imagemodule.js",
"uglify": "uglifyjs build/imagemodule.js > build/imagemodule.min.js"
},
"devDependencies": {
"babel-cli": "^6.11.4",
"babel-eslint": "^7.1.1",
"babel-preset-es2015": "^6.3.13",
"browserify": "^14.0.0",
"chai": "^3.4.1",
"docxtemplater": "^3.0.0",
"eslint": "^3.15.0",
"image-size": "^0.5.1",
"istanbul": "^0.4.5",
"jszip": "^2.6.1",
"mkdirp": "^0.5.1",
"mocha": "^3.2.0",
"rimraf": "^2.5.4",
"uglifyjs": "^2.4.10"
},
"repository": {
"type": "git",
"url": "https://github.com/evilc0des/docxtemplater-image-module-free"
},
"author": "Dk Saha",
"license": "MIT",
"dependencies": {
"xmldom": "^0.1.27"
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c58b4a08eec032540a18c3556b4062c5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,112 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./es6/index_IE.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "../node_modules/webpack/buildin/global.js":
/*!*************************************************!*\
!*** ../node_modules/webpack/buildin/global.js ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack:///../node_modules/webpack/buildin/global.js?");
/***/ }),
/***/ "./es6/index_IE.js":
/*!*************************!*\
!*** ./es6/index_IE.js ***!
\*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(global) {/* global IEBinaryToArray_ByteStr, IEBinaryToArray_ByteStr_Last */\n // Adapted from http://stackoverflow.com/questions/1095102/how-do-i-load-binary-image-data-using-javascript-and-xmlhttprequest\n\nvar IEBinaryToArray_ByteStr_Script = \"<!-- IEBinaryToArray_ByteStr -->\\r\\n\" + \"<script type='text/vbscript'>\\r\\n\" + \"Function IEBinaryToArray_ByteStr(Binary)\\r\\n\" + \" IEBinaryToArray_ByteStr = CStr(Binary)\\r\\n\" + \"End Function\\r\\n\" + \"Function IEBinaryToArray_ByteStr_Last(Binary)\\r\\n\" + \" Dim lastIndex\\r\\n\" + \" lastIndex = LenB(Binary)\\r\\n\" + \" if lastIndex mod 2 Then\\r\\n\" + \" IEBinaryToArray_ByteStr_Last = Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\\r\\n\" + \" Else\\r\\n\" + \" IEBinaryToArray_ByteStr_Last = \" + '\"\"' + \"\\r\\n\" + \" End If\\r\\n\" + \"End Function\\r\\n\" + \"</script>\\r\\n\"; // inject VBScript\n\ndocument.write(IEBinaryToArray_ByteStr_Script);\n\nglobal.PizZipUtils._getBinaryFromXHR = function (xhr) {\n var binary = xhr.responseBody;\n var byteMapping = {};\n\n for (var i = 0; i < 256; i++) {\n for (var j = 0; j < 256; j++) {\n byteMapping[String.fromCharCode(i + (j << 8))] = String.fromCharCode(i) + String.fromCharCode(j);\n }\n }\n\n var rawBytes = IEBinaryToArray_ByteStr(binary);\n var lastChr = IEBinaryToArray_ByteStr_Last(binary);\n return rawBytes.replace(/[\\s\\S]/g, function (match) {\n return byteMapping[match];\n }) + lastChr;\n};\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ \"../node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack:///./es6/index_IE.js?");
/***/ })
/******/ });

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 68284ab593af17c4d975a9a59770c57c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,102 @@
window["PizZipUtils"] =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./es6/index.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./es6/index.js":
/*!**********************!*\
!*** ./es6/index.js ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nvar PizZipUtils = {}; // just use the responseText with xhr1, response with xhr2.\n// The transformation doesn't throw away high-order byte (with responseText)\n// because PizZip handles that case. If not used with PizZip, you may need to\n// do it, see https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data\n\nPizZipUtils._getBinaryFromXHR = function (xhr) {\n // for xhr.responseText, the 0xFF mask is applied by PizZip\n return xhr.response || xhr.responseText;\n}; // taken from jQuery\n\n\nfunction createStandardXHR() {\n try {\n return new window.XMLHttpRequest();\n } catch (e) {}\n}\n\nfunction createActiveXHR() {\n try {\n return new window.ActiveXObject(\"Microsoft.XMLHTTP\");\n } catch (e) {}\n} // Create the request object\n\n\nvar createXHR = window.ActiveXObject ?\n/* Microsoft failed to properly\n * implement the XMLHttpRequest in IE7 (can't request local files),\n * so we use the ActiveXObject when it is available\n * Additionally XMLHttpRequest can be disabled in IE7/IE8 so\n * we need a fallback.\n */\nfunction () {\n return createStandardXHR() || createActiveXHR();\n} : // For all other browsers, use the standard XMLHttpRequest object\ncreateStandardXHR;\n\nPizZipUtils.getBinaryContent = function (path, callback) {\n /*\n * Here is the tricky part : getting the data.\n * In firefox/chrome/opera/... setting the mimeType to 'text/plain; charset=x-user-defined'\n * is enough, the result is in the standard xhr.responseText.\n * cf https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Receiving_binary_data_in_older_browsers\n * In IE <= 9, we must use (the IE only) attribute responseBody\n * (for binary data, its content is different from responseText).\n * In IE 10, the 'charset=x-user-defined' trick doesn't work, only the\n * responseType will work :\n * http://msdn.microsoft.com/en-us/library/ie/hh673569%28v=vs.85%29.aspx#Binary_Object_upload_and_download\n *\n * I'd like to use jQuery to avoid this XHR madness, but it doesn't support\n * the responseType attribute : http://bugs.jquery.com/ticket/11461\n */\n try {\n var xhr = createXHR();\n xhr.open(\"GET\", path, true); // recent browsers\n\n if (\"responseType\" in xhr) {\n xhr.responseType = \"arraybuffer\";\n } // older browser\n\n\n if (xhr.overrideMimeType) {\n xhr.overrideMimeType(\"text/plain; charset=x-user-defined\");\n }\n\n xhr.onreadystatechange = function (evt) {\n var file, err; // use `xhr` and not `this`... thanks IE\n\n if (xhr.readyState === 4) {\n if (xhr.status === 200 || xhr.status === 0) {\n file = null;\n err = null;\n\n try {\n file = PizZipUtils._getBinaryFromXHR(xhr);\n } catch (e) {\n err = new Error(e);\n }\n\n callback(err, file);\n } else {\n callback(new Error(\"Ajax error for \" + path + \" : \" + this.status + \" \" + this.statusText), null);\n }\n }\n };\n\n xhr.send();\n } catch (e) {\n callback(new Error(e), null);\n }\n};\n\nmodule.exports = PizZipUtils;\n\n//# sourceURL=webpack://PizZipUtils/./es6/index.js?");
/***/ })
/******/ });

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d364e43be597f06488ecbd133c325c5a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 319996a31f07b28489f8ccda03d02992
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +1,3 @@
mergeInto(LibraryManager.library, { mergeInto(LibraryManager.library, {
WebGLDownloadWord : function(array,size,reportjson) WebGLDownloadWord : function(array,size,reportjson)
{ {

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 3c5db0930befe7d419f28aed73f4dcd9 guid: ed70045610a0a1646b52235bdb34810e
PluginImporter: PluginImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -103,6 +103,17 @@
} }
//添加功能---------
function HtmlDownloadWord(bytes, reportdata) {
var blob = new Blob([bytes]);
var url = window.URL.createObjectURL(blob);
generate(url, reportdata);
}
function LoadTextPDF(name, reportdata) { function LoadTextPDF(name, reportdata) {
reportdata = (reportdata.replace(/<(.|\n)*?>/g, '') || ' ') reportdata = (reportdata.replace(/<(.|\n)*?>/g, '') || ' ')

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ca7682e17f837a04b8d07ff56caeb717
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 91ccf9d64a1bf0a4ca1b0ac2cbf65334
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2da7d930a5ab01b458ca7df71f866fac
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f2665bcab28e22345a2bf37bbe0f2795
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 81e033af8edb73145bb263061bebe3d8
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 49d2c72c83498db418cc7b7999989df3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 56cb493fa5a4d8f4cb482da5c2ad961e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 B

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9e1b936f6306a1e4aa6f71ffe665f38a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
body { padding: 0; margin: 0 }
#unity-container { position: absolute }
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
#unity-container.unity-mobile { width: 100%; height: 100% }
#unity-canvas { background: #231F20 }
.unity-mobile #unity-canvas { width: 100%; height: 100% }
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
#unity-logo { width: 154px; height: 130px; background: url('unity-logo-dark.png') no-repeat center }
#unity-progress-bar-empty { width: 141px; height: 18px; margin-top: 10px; margin-left: 6.5px; background: url('progress-bar-empty-dark.png') no-repeat center }
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center }
#unity-footer { position: relative }
.unity-mobile #unity-footer { display: none }
#unity-webgl-logo { float:left; width: 204px; height: 38px; background: url('webgl-logo.png') no-repeat center }
#unity-build-title { float: right; margin-right: 10px; line-height: 38px; font-family: arial; font-size: 18px }
#unity-fullscreen-button { float: right; width: 38px; height: 38px; background: url('fullscreen-button.png') no-repeat center }
#unity-warning { position: absolute; left: 50%; top: 5%; transform: translate(-50%); background: white; padding: 10px; display: none }

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: acee3b9096daa234f91ebb3aa546a2ba
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2a5ef3c252e921a459ed647cde8c6310
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e64b57b6cb9372a49a9abff0f55f7521
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8eb20925618d17b42867a4a2063d98a7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,362 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>虚拟实验 | {{{ PRODUCT_NAME }}}</title>
<link rel="shortcut icon" href="TemplateData/favicon.ico">
<link rel="stylesheet" href="TemplateData/style.css">
<script type="text/javascript" src="StreamingAssets/WebGLDownloadWordJS/js/docxtemplater.js"></script>
<script type="text/javascript" src="StreamingAssets/WebGLDownloadWordJS/js/pizzip.js"></script>
<script type="text/javascript" src="StreamingAssets/WebGLDownloadWordJS/js/FileSaver.js"></script>
<script type="text/javascript" src="StreamingAssets/WebGLDownloadWordJS/js/pizzip-utils.js"></script>
<script type="text/javascript" src="StreamingAssets/WebGLDownloadWordJS/js/imagemodule.js"></script>
</head>
<body>
<div id="unity-container" class="unity-desktop">
<canvas id="unity-canvas" width=1280 height=720></canvas>
<div id="unity-loading-bar">
<div id="unity-progress-bar-empty">
<div id="unity-progress-bar-full"></div>
</div>
</div>
<div id="unity-warning"> </div>
<div id="unity-footer">
<div id="unity-fullscreen-button"></div>
<div id="unity-build-title">{{{ PRODUCT_NAME }}}</div>
</div>
</div>
<script>
var container = document.querySelector("#unity-container");
var canvas = document.querySelector("#unity-canvas");
var loadingBar = document.querySelector("#unity-loading-bar");
var progressBarFull = document.querySelector("#unity-progress-bar-full");
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
var warningBanner = document.querySelector("#unity-warning");
// Shows a temporary message banner/ribbon for a few seconds, or
// a permanent error message on top of the canvas if type=='error'.
// If type=='warning', a yellow highlight color is used.
// Modify or remove this function to customize the visually presented
// way that non-critical warnings and error messages are presented to the
// user.
function unityShowBanner(msg, type) {
function updateBannerVisibility() {
warningBanner.style.display = warningBanner.children.length ? 'block' : 'none';
}
var div = document.createElement('div');
div.innerHTML = msg;
warningBanner.appendChild(div);
if (type == 'error') div.style = 'background: red; padding: 10px;';
else {
if (type == 'warning') div.style = 'background: yellow; padding: 10px;';
setTimeout(function() {
warningBanner.removeChild(div);
updateBannerVisibility();
}, 5000);
}
updateBannerVisibility();
}
var buildUrl = "Build";
var loaderUrl = buildUrl + "/{{{ LOADER_FILENAME }}}";
var config = {
dataUrl: buildUrl + "/{{{ DATA_FILENAME }}}",
frameworkUrl: buildUrl + "/{{{ FRAMEWORK_FILENAME }}}",
codeUrl: buildUrl + "/{{{ CODE_FILENAME }}}",
streamingAssetsUrl: "StreamingAssets",
companyName: {{{ JSON.stringify(COMPANY_NAME) }}},
productName: {{{ JSON.stringify(PRODUCT_NAME) }}},
productVersion: {{{ JSON.stringify(PRODUCT_VERSION) }}},
showBanner: unityShowBanner,
};
// By default Unity keeps WebGL canvas render target size matched with
// the DOM size of the canvas element (scaled by window.devicePixelRatio)
// Set this to false if you want to decouple this synchronization from
// happening inside the engine, and you would instead like to size up
// the canvas DOM size and WebGL render target sizes yourself.
// config.matchWebGLToCanvasSize = false;
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
// Mobile device style: fill the whole browser client area with the game canvas:
var meta = document.createElement('meta');
meta.name = 'viewport';
meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes';
document.getElementsByTagName('head')[0].appendChild(meta);
container.className = "unity-mobile";
canvas.className = "unity-mobile";
// To lower canvas resolution on mobile devices to gain some
// performance, uncomment the following line:
// config.devicePixelRatio = 1;
unityShowBanner('WebGL builds are not supported on mobile devices.');
} else {
// Desktop style: Render the game canvas in a window that can be maximized to fullscreen:
canvas.style.width = "1280px";
canvas.style.height = "720px";
}
loadingBar.style.display = "block";
var script = document.createElement("script");
script.src = loaderUrl;
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
progressBarFull.style.width = 100 * progress + "%";
}).then((unityInstance) => {
loadingBar.style.display = "none";
fullscreenButton.onclick = () => {
unityInstance.SetFullscreen(1);
};
}).catch((message) => {
alert(message);
});
};
var inputObj;
function Test() {
console.log("1");
if (inputObj != null) document.body.removeChild(inputObj);
inputObj = document.createElement('input');
inputObj.setAttribute('id', '_ef');
inputObj.setAttribute('type', 'file');
inputObj.setAttribute("style", 'visibility:hidden');
document.body.appendChild(inputObj);
document.addEventListener('input', imgChange);
var file = document.getElementById("_ef");
file.click();
file.value;
console.log("2");
}
function imgChange(obj) {
console.log("3");
var file = document.getElementById("_ef");
var imgUrl = window.URL.createObjectURL(file.files[0]);
if (instance != null) {
instance.SendMessage("Web", "CallBack", imgUrl);
}
};
//添加功能---------
function HtmlDownloadWord(bytes, reportdata) {
var blob = new Blob([bytes]);
var url = window.URL.createObjectURL(blob);
generate(url, reportdata);
}
function loadFile(url, callback) {
PizZipUtils.getBinaryContent(url, callback);
}
//处理base64数据
const base64Regex =
/^data:image\/(png|jpg|svg|svg\+xml);base64,/;
const validBase64 =
/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
function base64Parser(dataURL) {
if (
typeof dataURL !== "string" ||
!base64Regex.test(dataURL)
) {
return false;
}
const stringBase64 = dataURL.replace(base64Regex, "");
if (!validBase64.test(stringBase64)) {
throw new Error(
"Error parsing base64 data, your data contains invalid characters"
);
}
// For nodejs, return a Buffer
if (typeof Buffer !== "undefined" && Buffer.from) {
return Buffer.from(stringBase64, "base64");
}
// For browsers, return a string (of binary content) :
const binaryString = window.atob(stringBase64);
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
const ascii = binaryString.charCodeAt(i);
bytes[i] = ascii;
}
return bytes.buffer;
}
const imageOptions = {
getImage(tag) {
return base64Parser(tag);
},
getSize() {
console.log("大小已被调用");
return [384, 216];
},
};
function generate(url, reportdata) {
loadFile(
url,
function (error, content) {
if (error) {
throw error;
}
//先处理unity传入的数据得到base64
reportdata = (reportdata.replace(/<(.|\n)*?>/g, '') || ' ')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>');
reportdata = JSON.parse(reportdata)
//var imageBytes = reportdata.imageData; // 图片字节数组数据
// 将图片数据转换为 base64 格式
//var imageBase64 = btoa(String.fromCharCode.apply(null, imageBytes));
//imageBase64 = "data:image/png;base64," + imageBase64;
//console.log(imageBase64);
var imageModule = new ImageModule(imageOptions);
var zip = new PizZip(content);
var doc = new window.docxtemplater(zip, {
paragraphLoop: true,
linebreaks: true,
modules: [imageModule]
});
//const image = doc.Media.addImage(doc, imageBytes, 230, 230);
doc.compile();
//const data = {
// eid: reportdata.eid,
// name: reportdata.name,
// scroe: reportdata.scroe,
// image: imageBase64,
//}
//渲染模板
doc.render(reportdata);
var out = doc.getZip().generate({
type: "blob",
mimeType:
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
compression: "DEFLATE",
});
saveAs(out, "实验报告.docx");
});
}
document.body.appendChild(script);
</script>
</body>
</html>

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1c5560ae5754d7e4ea960b323d4cf91a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".unityweb" mimeType="application/binary" />
<mimeMap fileExtension=".unity3d" mimeType="application/octet-stream"/>
</staticContent>
<urlCompression doDynamicCompression="false"/>
</system.webServer>
</configuration>

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4d2edd7711614ec49acc9aceb4093b2d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.