|
|
@ -5,6 +5,11 @@
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
|
|
|
|
<title>模拟接口</title>
|
|
|
|
<title>模拟接口</title>
|
|
|
|
<style>
|
|
|
|
<style>
|
|
|
|
|
|
|
|
body {
|
|
|
|
|
|
|
|
width: 100vw;
|
|
|
|
|
|
|
|
height: 100vh;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:root {
|
|
|
|
:root {
|
|
|
|
--width: 358px;
|
|
|
|
--width: 358px;
|
|
|
|
--height: 441px;
|
|
|
|
--height: 441px;
|
|
|
@ -53,6 +58,10 @@
|
|
|
|
<button id="folderBrowser">选择目录</button>
|
|
|
|
<button id="folderBrowser">选择目录</button>
|
|
|
|
<button id="readFile">读取图片</button>
|
|
|
|
<button id="readFile">读取图片</button>
|
|
|
|
<button id="saveFile">保存图片</button>
|
|
|
|
<button id="saveFile">保存图片</button>
|
|
|
|
|
|
|
|
<button id="getConfig">读取配置</button>
|
|
|
|
|
|
|
|
<button id="setConfig">保存配置</button>
|
|
|
|
|
|
|
|
<button id="removeConfig">移除配置</button>
|
|
|
|
|
|
|
|
<button id="getConfigs">查询配置</button>
|
|
|
|
<hr />
|
|
|
|
<hr />
|
|
|
|
<div class="videoWrapper">
|
|
|
|
<div class="videoWrapper">
|
|
|
|
<video id="webcam"></video>
|
|
|
|
<video id="webcam"></video>
|
|
|
@ -71,6 +80,7 @@
|
|
|
|
document.getElementById('idCard').src = card.image;
|
|
|
|
document.getElementById('idCard').src = card.image;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//文件夹浏览
|
|
|
|
document.getElementById("folderBrowser").onclick = function () {
|
|
|
|
document.getElementById("folderBrowser").onclick = function () {
|
|
|
|
var response = window.chrome.webview.hostObjects.sync.dotnet.Action(JSON.stringify({
|
|
|
|
var response = window.chrome.webview.hostObjects.sync.dotnet.Action(JSON.stringify({
|
|
|
|
command: "selectPath",
|
|
|
|
command: "selectPath",
|
|
|
@ -81,10 +91,26 @@
|
|
|
|
alert(result.message);
|
|
|
|
alert(result.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
alert(result.path);
|
|
|
|
alert(`选择的文件夹:${result.path}`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//读取文件base64
|
|
|
|
|
|
|
|
document.getElementById("readFile").onclick = function () {
|
|
|
|
|
|
|
|
var response = window.chrome.webview.hostObjects.sync.dotnet.Action(JSON.stringify({
|
|
|
|
|
|
|
|
command: 'readFile',
|
|
|
|
|
|
|
|
file: appBasePath + "asserts/test.webp"
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
var result = JSON.parse(response);
|
|
|
|
|
|
|
|
if (result.code) {
|
|
|
|
|
|
|
|
alert(result.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
document.getElementById('idCard').src = `data:image/webp;base64,${result.base64}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//写入文件
|
|
|
|
document.getElementById("saveFile").onclick = function () {
|
|
|
|
document.getElementById("saveFile").onclick = function () {
|
|
|
|
var response = window.chrome.webview.hostObjects.sync.dotnet.Action(JSON.stringify({
|
|
|
|
var response = window.chrome.webview.hostObjects.sync.dotnet.Action(JSON.stringify({
|
|
|
|
command: 'saveFile',
|
|
|
|
command: 'saveFile',
|
|
|
@ -95,19 +121,69 @@
|
|
|
|
if (result.code) {
|
|
|
|
if (result.code) {
|
|
|
|
alert(result.message);
|
|
|
|
alert(result.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
alert("写入文件成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
document.getElementById("readFile").onclick = function () {
|
|
|
|
//获取配置
|
|
|
|
|
|
|
|
document.getElementById("getConfig").onclick = function () {
|
|
|
|
var response = window.chrome.webview.hostObjects.sync.dotnet.Action(JSON.stringify({
|
|
|
|
var response = window.chrome.webview.hostObjects.sync.dotnet.Action(JSON.stringify({
|
|
|
|
command: 'readFile',
|
|
|
|
command: 'getConfig',
|
|
|
|
file: appBasePath + "asserts/test.webp"
|
|
|
|
key: "test"
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
var result = JSON.parse(response);
|
|
|
|
var result = JSON.parse(response);
|
|
|
|
if (result.code) {
|
|
|
|
if (result.code) {
|
|
|
|
alert(result.message);
|
|
|
|
alert(result.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
document.getElementById('idCard').src = `data:image/webp;base64,${result.base64}`;
|
|
|
|
alert(result.value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询配置
|
|
|
|
|
|
|
|
document.getElementById("getConfigs").onclick = function () {
|
|
|
|
|
|
|
|
var response = window.chrome.webview.hostObjects.sync.dotnet.Action(JSON.stringify({
|
|
|
|
|
|
|
|
command: 'getConfigs',
|
|
|
|
|
|
|
|
key: "test"
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
var result = JSON.parse(response);
|
|
|
|
|
|
|
|
if (result.code) {
|
|
|
|
|
|
|
|
alert(result.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
alert(JSON.stringify(result.value));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置配置
|
|
|
|
|
|
|
|
document.getElementById("setConfig").onclick = function () {
|
|
|
|
|
|
|
|
var response = window.chrome.webview.hostObjects.sync.dotnet.Action(JSON.stringify({
|
|
|
|
|
|
|
|
command: 'setConfig',
|
|
|
|
|
|
|
|
key: "test",
|
|
|
|
|
|
|
|
value: `当前时间:${new Date().toLocaleString()}`
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
var result = JSON.parse(response);
|
|
|
|
|
|
|
|
if (result.code) {
|
|
|
|
|
|
|
|
alert(result.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
alert("设置配置成功");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//删除配置,name和url不能删除
|
|
|
|
|
|
|
|
document.getElementById("removeConfig").onclick = function () {
|
|
|
|
|
|
|
|
var response = window.chrome.webview.hostObjects.sync.dotnet.Action(JSON.stringify({
|
|
|
|
|
|
|
|
command: 'removeConfig',
|
|
|
|
|
|
|
|
key: "test"
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
var result = JSON.parse(response);
|
|
|
|
|
|
|
|
if (result.code) {
|
|
|
|
|
|
|
|
alert(result.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
alert("删除配置成功");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|