日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【hta版】获取AppStore上架后的应用版本号

發布時間:2025/3/20 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【hta版】获取AppStore上架后的应用版本号 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

之前寫過一篇文章:獲取AppStore上架后的應用版本號,那一篇文章使用node.js實現,存在的問題就是如果在沒有安裝node.js運行環境下是無法運行的,而且該程序依賴request模塊,為了方便其它人也能使用,想到把它做成一個本地應用程序。然后想了一下,覺得最簡單的就是使用hta文件(它的Ajax請求可跨域^_^)。

?

因為我們手游產品已經有三款了,所以“應用地址”那一欄,我使用了下拉框,其它組的成員只需要點擊選中需要檢測的應用,然后點擊“檢測版本”按鈕,程序將開始運行。當匹配到版本為最新的版本時,登錄OA系統,向需要獲取版本更新信息的人員發送OA提醒。

?

原理比較簡單,代碼也并不復雜。將源碼本地另存為.hta后綴的文件,然后雙擊它就可以運行了。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>檢測App最新版本號</title>
<hta:application id="fetchFIle" applicationname="fetchFIle" singleinstance="yes" border="thin" scroll="no" maximizeButton="no">
<style type='text/css'>
h3 {border-left:3px solid 666; color:#666; text-indent:10px; margin:15px 0;}
textarea {border:2px solid #888; background-color:#222; font-family:'Courier New'; font-size:14px; color:#3c0;}
a {color:#657528;}
a:hover {background:#c8dc7b;}

.exec-btn {border:1px solid #666; background-color:#9c0; color:#360; padding:5px 5px 3px 5px; margin-left:10px; width:70px; height:30px; vertical-align:middle; cursor:pointer; display:inline-block;}

body {background-color:#eee; margin:0; padding:0; overflow:hidden; text-align:center;}

#wrapper {width:800px; margin:30px auto; padding:30px; border:1px solid #ccc; text-align:left;}
.ipt {width:600px; height:25px; line-height:22px; vertical-align:middle; padding:0 2px;}
</style>
</head>
<body>
<div id="wrapper">
<p>  應用的地址:<select id='ipt_url'>
<option value="">【請選擇一款應用】</option>
<option value="https://itunes.apple.com/cn/app/huang-di-jue-qi/id604615270?mt=8">【皇帝崛起】</option>
<option value="https://itunes.apple.com/cn/app/feng-liu-tian-zi/id670188672?mt=8">【風流天子】</option>
<option value="https://itunes.apple.com/cn/app/gong-ting-feng-yunhd/id543140000?mt=8">【宮廷風云】</option>
</select></p>
<p>應用的最新版本:<input type='text' class='ipt' value="1.0.2" style="width:100px;" id="ipt_ver"/></p>
<p> 輪詢間隔時長:<input type='text' class='ipt' value='3' style='width:100px;' id='ipt_duration'/>秒</p>
<p>需要通知的人員:<textarea style='width:600px; height:140px;' id="ipt_uids">zhangyi</textarea></p>
<p style='padding-left:118px;'><button class='exec-btn' οnclick="startCheck()" id='btn_check'>檢測版本</button><span style='padding-left:350px;color:#666;'>多人請使用回車進行分隔</span></p>
</div>

<div style='border:1px solid #ccc; width:800px; margin:30px auto; text-align:left; padding:10px;'>
<p>應用名稱:<span id='app_name'></span></p>
<p>當前版本:<span id='curr_ver'></span></p>
</div>

<div style='position:absolute; bottom:10px; right:30px;'>&copy;版本所有:<a href="http://www.cnblogs.com/meteoric_cry" target='_blank'>Meteoric_cry</a></div>

<script type="text/javascript">
String.prototype.trim = function(r){
return this.replace(r || /(^\s+)|(\s+$)/g, "");
}

function getEl(id) {
return typeof id == 'string' ? document.getElementById(id) : id;
}

var FWKAjax = function () {
return {
getXHR: function () {
var e = null;
try {
return (e = new XMLHttpRequest());
} catch (d) {
for (var c = 0, b = ["MSXML3", "MSXML2", "Microsoft"]; c < b.length; c++) {
try {
e = new ActiveXObject(b[c] + ".XMLHTTP");
break;
} catch (d) {}
}
}
return e;
},
request: function (b, c) {
var d = this.getXHR();
if (!d) {
throw new Error("cant't initialize xhr instance.");
}
var a = {};
a.method = (c.method || "get").toUpperCase();
a.asyn = true;
a.onSuccess = c.onSuccess || function () {};
a.onFailure = c.onFailure || function () {};
a.postData = c.postData || null;
d.open(a.method, b, a.asyn);

if ("POST" == a.method) {
d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
} else {
d.setRequestHeader('If-Modified-Since', new Date(0).toGMTString());
d.setRequestHeader('Cache-Control', 'no-cache');
}

d.onreadystatechange = function () {
if (d.readyState == 4) {
if (d.status == 0 || d.status == 200) {
a.onSuccess(d);
} else {
a.onFailure(d);
}

d = null;
a = null;
}
};

d.send(a.postData);
}
};
}();


function startCheck() {
var url = getEl('ipt_url').value.trim()
var ver = getEl('ipt_ver').value.trim()

if (!url) {
alert('請選擇要檢測的應用');
getEl('ipt_url').focus();
return false;
}

if (!ver) {
alert('請輸入要檢測的應用版本號');
return false;
}

var duration = getEl('ipt_duration').value * 1000 || 3 * 1000;
var uids = getEl('ipt_uids').value.trim().replace(/\r\n/g, ',');

if (!uids) {
alert("請輸入要通知的人員名單列表");
return ;
}

var btnElem = getEl('btn_check');
btnElem.setAttribute("disabled", "disabled");
btnElem.innerHTML = "正在檢測";

checkHandler(url, ver, duration, uids)
}

function checkHandler(url, ver, duration, uids) {
FWKAjax.request(url + "&t=" + new Date().getTime(), {
'method' : 'get',
'onSuccess' : ajaxCallback,
'onFailure' : ajaxCallback,
'postData' : null
});

function ajaxCallback(xhr) {
var htmlContent = xhr.responseText;
xhr = null;

if (/<h1>([^<]+)<\/h1>/.test(htmlContent)) {
var appName = RegExp["$1"];
getEl('app_name').innerHTML = appName;
}

if (/\<li\><span class=\"label\">版本\: <\/span>([^<]+)\<\/li\>/.test(htmlContent)) {
var currVer = RegExp["
$1"];

getEl('curr_ver').innerHTML = currVer;

var appDomainName = url.split('/app/')[1].split('/')[0];

if (currVer == ver) {
sendOA_Notification(appDomainName, currVer, uids);
return ;
}
}

setTimeout(function() {
checkHandler(url, ver, duration, uids)
}, duration);
}
}

function sendOA_Notification(appName, currVer, uids) {
FWKAjax.request("
http://oa.xx.net/logincheck.php?UNAME=xx1&PASSWORD=xx2", {
'method' : 'GET',
'onSuccess' : function(xhr) {
if (/location=\"general\"\;/.test(xhr.responseText)) {
sendMsg(appName, currVer, uids);
}
},
'onFailure' : null,
'postData' : null
});
}

function sendMsg(appName, currVer, uids) {

var data_str = "
uid=" + uids + "&cont=[" + appName + "] AppStore Latest Version:" + currVer;

FWKAjax.request("
http://oa.xx.net/general/reservation/sendsmsapi.php", {
'method' : 'post',
'onSuccess' : function(xhr) {
alert("版本更新提醒已發送!");

var btnElem = getEl('btn_check');
btnElem.removeAttribute("disabled");
btnElem.innerHTML = "檢測版本";
},
'onFailure' : null,
'postData' : data_str
});
}


!(function() {
var winsize = {
winwidth: 900,
winheight: 650,
scrnwidth: screen.availWidth,
scrnheight: screen.availHeight
};

window.resizeTo(winsize.winwidth, winsize.winheight);
})();

window.οnerrοr=function(a,b,c){
alert("檢測腳本發生了以下異常:"+a+"\n所在行:"+c);
return true;
}

</script>

</body>
</html>

轉載于:https://www.cnblogs.com/meteoric_cry/p/3311125.html

總結

以上是生活随笔為你收集整理的【hta版】获取AppStore上架后的应用版本号的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。