first commit
This commit is contained in:
74
index.html
Normal file
74
index.html
Normal file
@@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>FFI-NAPI App</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
padding: 20px;
|
||||
background: #f0f0f0;
|
||||
}
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
button {
|
||||
padding: 10px 20px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
background: #007acc;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
button:hover {
|
||||
background: #005a9e;
|
||||
}
|
||||
#result {
|
||||
margin-top: 20px;
|
||||
padding: 10px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 4px;
|
||||
min-height: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>FFI-NAPI Application</h1>
|
||||
<button onclick="checkAuth()">检查授权</button>
|
||||
<pre id="result"></pre>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const { remote, app } = require('electron');
|
||||
const { checkAuthorizationSync } = require('./test.js');
|
||||
const path = require('path');
|
||||
|
||||
function checkAuth() {
|
||||
try {
|
||||
// 获取资源路径
|
||||
const currentApp = remote ? remote.app : require('electron').app;
|
||||
const resourcePath = currentApp.isPackaged
|
||||
? path.join(process.resourcesPath, 'exe')
|
||||
: path.join(process.cwd(), 'exe');
|
||||
|
||||
const exePath = path.join(resourcePath, 'Test.exe');
|
||||
const command = `"${exePath}" 10303 "${resourcePath}"`;
|
||||
|
||||
console.log('执行命令:', command);
|
||||
const result = checkAuthorizationSync(command);
|
||||
document.getElementById('result').textContent = JSON.stringify(result, null, 2);
|
||||
} catch (error) {
|
||||
document.getElementById('result').textContent = '错误: ' + error.message;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user