mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-21 19:24:25 +00:00
fetch api with current version param
This commit is contained in:
21
node_modules/api.js
generated
vendored
21
node_modules/api.js
generated
vendored
@@ -9,9 +9,20 @@ var Web = require('web');
|
|||||||
var Tags = db.tags;
|
var Tags = db.tags;
|
||||||
var needle = require('needle');
|
var needle = require('needle');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
var os = require('os');
|
||||||
var Evt = require('evt');
|
var Evt = require('evt');
|
||||||
var macAddr = require('node-getmac');
|
var macAddr = require('node-getmac');
|
||||||
|
|
||||||
|
// 当前版本
|
||||||
|
var vFile = Evt.getProjectBasePath() + '/data/version';
|
||||||
|
var currentVersion = os.platform() + '_' + os.arch();
|
||||||
|
try {
|
||||||
|
var v = JSON.parse(fs.readFileSync(vFile));
|
||||||
|
currentVersion += '_' + v.version
|
||||||
|
} catch(e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
function log(o) {
|
function log(o) {
|
||||||
// console.log(o);
|
// console.log(o);
|
||||||
}
|
}
|
||||||
@@ -27,6 +38,10 @@ needle.defaults({
|
|||||||
|
|
||||||
// 远程数据服务
|
// 远程数据服务
|
||||||
var Api = {
|
var Api = {
|
||||||
|
getVersion: function () {
|
||||||
|
return currentVersion
|
||||||
|
},
|
||||||
|
|
||||||
// 检查错误
|
// 检查错误
|
||||||
checkError: function(error, resp) {
|
checkError: function(error, resp) {
|
||||||
var me = this;
|
var me = this;
|
||||||
@@ -116,7 +131,7 @@ var Api = {
|
|||||||
// log({emai: email, pwd: pwd});
|
// log({emai: email, pwd: pwd});
|
||||||
// console.log(this.getUrl('auth/login', {email: email, pwd: pwd}));
|
// console.log(this.getUrl('auth/login', {email: email, pwd: pwd}));
|
||||||
// console.log('????????????')
|
// console.log('????????????')
|
||||||
needle.post(this.getUrl('auth/login', {macAddr: macAddr}), {email: email, pwd: pwd}, {timeout: 10000}, function(error, response) {
|
needle.post(this.getUrl('auth/login', {macAddr: macAddr, v: currentVersion}), {email: email, pwd: pwd}, {timeout: 10000}, function(error, response) {
|
||||||
me.checkError(error, response);
|
me.checkError(error, response);
|
||||||
if(error) {
|
if(error) {
|
||||||
return callback && callback(false);
|
return callback && callback(false);
|
||||||
@@ -140,7 +155,7 @@ var Api = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
logout: function (callback) {
|
logout: function (callback) {
|
||||||
needle.post(this.getUrl('auth/logout', {macAddr: macAddr}), {timeout: 10000}, function(error, response) {
|
needle.post(this.getUrl('auth/logout', {macAddr: macAddr, v: currentVersion}), {timeout: 10000}, function(error, response) {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -207,7 +222,7 @@ var Api = {
|
|||||||
},
|
},
|
||||||
getLastSyncState: function(callback) {
|
getLastSyncState: function(callback) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var url = this.getUrl('user/getSyncState', {macAddr: macAddr});
|
var url = this.getUrl('user/getSyncState', {macAddr: macAddr, v: currentVersion});
|
||||||
// console.log(url);
|
// console.log(url);
|
||||||
needle.get(url, {timeout: 10000}, function(error, response) {
|
needle.get(url, {timeout: 10000}, function(error, response) {
|
||||||
// console.log('user/getSyncState ret');
|
// console.log('user/getSyncState ret');
|
||||||
|
@@ -677,12 +677,12 @@ window.debug = false;
|
|||||||
<script>
|
<script>
|
||||||
window.require = window.requireNode;
|
window.require = window.requireNode;
|
||||||
</script>
|
</script>
|
||||||
<!-- 远程控制, 升级 -->
|
<!-- 升级 -->
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
var s = document.createElement('script');
|
var s = document.createElement('script');
|
||||||
s.type = 'text/javascript';
|
s.type = 'text/javascript';
|
||||||
s.src = 'http://app.leanote.com/js/app_electron.js?t=' + Math.ceil(new Date() / 3600000);
|
s.src = 'https://leanote.com/js/app_electron.js?t=' + Math.ceil(new Date() / 3600000);
|
||||||
document.getElementsByTagName('body')[0].appendChild(s);
|
document.getElementsByTagName('body')[0].appendChild(s);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user