我正在尝试访问位于" sqlite"的局域网计算机上的sqlite文件。文件夹,在Windows文件资源管理器上我使用IP地址" 192.168.5.15/sqlite/db.sqlite"来访问它,但是当电子应用程序尝试访问它时,路径将转换为本地机器路径& #34; c:/ application ...... / 192.168 ...."。
请问如何直接使用静态IP地址指向文件而不将其转换为本地计算机路径?
这是代码:
// login_app.js
var route = require('../../libs/router.js'); //my lib
var dbPath = "192.168.5.15/sqlite/db.sqlite" // here is the path i want to keep it static
function login() {
var email = document.getElementById("email").value;
var password = document.getElementById("password").value;
if(email == "" || password == ""){
alert("Please Enter Your email & Password ...");
return;
} else{
var sql = require('sql.js'); //Import sqLite
var fs = require("fs"); //Import Files driver
var SHA256 = require("crypto-js/sha256"); //Crypting Library
try {
var filebuffer = fs.readFileSync(dbPath); //here is the problem it converts the file to local machine path c:/..../192....
if (filebuffer != null) {
var db = new SQL.Database(filebuffer);
} else {
var db = new SQL.Database();
console.log("No Database");
}
// Prepare an sql statement
var stmt = db.prepare("SELECT * FROM users WHERE email=:emailid");
// Bind values to the parameters and fetch the results of the query
var result = stmt.getAsObject({':emailid' : email});
if(result.password == null) alert('Account not existing, please contact Your Administrator ...');
else{
if(SHA256(password) == result.password) {
route.data.relocate('dashboard');
}
else alert('Wrong Login credentials, please try again ...');
}
} catch (e) {
console.log(e);
}
}
}