Comparing version 1.1.5 to 1.1.6
@@ -31,3 +31,3 @@ | ||
function release() { | ||
db.cacheFile(param.assetsUrl + "AB3DEngine.data").then((data) => { | ||
db.cacheFile(param.assetsUrl + "AB3DEngine.data").then((data) => { | ||
db.cacheFile(param.assetsUrl + "AB3DEngine.wasm").then((wasm) => { | ||
@@ -34,0 +34,0 @@ script.setAttribute('src', param.assetsUrl + 'AB3DEngine.loader.js'); |
@@ -25,5 +25,5 @@ import Event from "./System/Event.js"; | ||
inputFile.type = "file"; | ||
inputFile.style.width = 0 + "px"; | ||
inputFile.style.width = 100 + "px"; | ||
inputFile.onchange = onFileSelected; | ||
parentNode.appendChild(inputFile); | ||
// parentNode.appendChild(inputFile); | ||
@@ -77,3 +77,3 @@ var inputField = document.createElement("input"); | ||
// 使用 fetch 上传文件 | ||
fetch(pr.severUrl + '/api/thirdparty/oss/uploadFileApp', { // 替换成你的服务器URL | ||
fetch(pr.severUrl + '/api/thirdparty/oss/uploadFileApp', { | ||
method: 'POST', | ||
@@ -85,14 +85,71 @@ body: formData, | ||
console.log('Success:', data); | ||
var datapr = { | ||
instanceID: unityBack.instanceID, | ||
url: data.message | ||
if (data.code == 200) { | ||
var datapr = { | ||
instanceID: unityBack.instanceID, | ||
url: data.message | ||
} | ||
// 可以在这里处理上传成功后的逻辑,例如显示上传成功的提示 | ||
_unityInstance.SendMessage(unityBack.gameObjectName, unityBack.callBackName, JSON.stringify(datapr)); | ||
} else { | ||
alert('上传失败: ' + data.message); | ||
_unityInstance.SendMessage(unityBack.gameObjectName, unityBack.FailUpfileName); | ||
} | ||
_unityInstance.SendMessage(unityBack.gameObjectName, unityBack.callBackName, JSON.stringify(datapr)); | ||
// 可以在这里处理上传成功后的逻辑,例如显示上传成功的提示 | ||
}) | ||
.catch(error => { | ||
console.error('Error:', error); | ||
alert('上传失败: ' + error); | ||
// 可以在这里处理上传失败的逻辑,例如显示上传失败的提示 | ||
_unityInstance.SendMessage(unityBack.gameObjectName, unityBack.FailUpfileName); | ||
}); | ||
} | ||
function onFileSelected1(event) { | ||
var file = event.target.files[0]; | ||
var now = new Date(); | ||
var year = now.getFullYear(); | ||
var month = now.getMonth() + 1; | ||
var date = now.getDate(); | ||
var formData = new FormData(); | ||
formData.append('file', file); | ||
formData.append("filePath", "intelligent_coach/image/" + year + "/" + month + "/" + date + "/" + Math.floor(Date.now() / 1000)); | ||
// 使用 XMLHttpRequest 上传文件并监听进度 | ||
var xhr = new XMLHttpRequest(); | ||
// 设置上传的 URL | ||
xhr.open('POST', pr.severUrl + '/api/thirdparty/oss/uploadFileApp', true); | ||
// 监听上传进度 | ||
xhr.upload.onprogress = function (event) { | ||
if (event.lengthComputable) { | ||
var percentComplete = (event.loaded / event.total) * 100; | ||
console.log(`上传进度: ${percentComplete.toFixed(2)}%`); | ||
// 可以在这里更新进度条的显示 | ||
} | ||
}; | ||
// 上传完成后处理响应 | ||
xhr.onload = function () { | ||
if (xhr.status === 200) { | ||
var data = JSON.parse(xhr.responseText); | ||
console.log('Success:', data); | ||
var datapr = { | ||
instanceID: unityBack.instanceID, | ||
url: data.message | ||
}; | ||
_unityInstance.SendMessage(unityBack.gameObjectName, unityBack.callBackName, JSON.stringify(datapr)); | ||
} else { | ||
console.error('Error:', xhr.statusText); | ||
} | ||
}; | ||
// 处理上传失败 | ||
xhr.onerror = function () { | ||
console.error('Error:', xhr.statusText); | ||
}; | ||
// 发送请求 | ||
xhr.send(formData); | ||
} | ||
function onInputText(event) { | ||
@@ -99,0 +156,0 @@ |
{ | ||
"name": "abengine", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "引入 npm i ABengine", | ||
@@ -5,0 +5,0 @@ "main": "ab3d.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126959
751