gpt4 book ai didi

Javascript - Windows 应用商店 - 强制强制更新

转载 作者:行者123 更新时间:2023-12-03 04:24:06 25 4
gpt4 key购买 nike

Javascript:

我希望我的 Windows 应用商店应用检查更新,尤其是强制更新,然后提示用户更新。

我发现这涉及到 Windows.Services.Store,但我找不到任何 javascript 示例来说明如何完成此操作,只有常见的 c#/vb 示例。

有人知道代码模板吗?

最佳答案

I have found out this involves Windows.Services.Store, but I cannot find any javascript examples of how this is done, only the usual c#/vb ones.

我想你找到的例子是 Code examplesDownload and install package updates for your app 。虽然这些示例是用 C# 编写的,但我们可以轻松地将它们转换为 JavaScript,因为它们大多数都是 Windows 运行时 API。

例如,使用下载并安装所有软件包更新,JavaScript 版本将如下所示:

var context = Windows.Services.Store.StoreContext.getDefault();

context.getAppAndOptionalStorePackageUpdatesAsync().then(function (updates) {
if (updates.size > 0) {
var dialog = new Windows.UI.Popups.MessageDialog("Download and install updates now? This may cause the application to exit.", "Download and Install?");
dialog.commands.append(new Windows.UI.Popups.UICommand("Yes"));
dialog.commands.append(new Windows.UI.Popups.UICommand("No"));
dialog.showAsync().then(function (command) {
if (command.label === "Yes") {
context.requestDownloadAndInstallStorePackageUpdatesAsync(updates).then(function (result) {
// TODO
}, function (error) {
//TODO
}, function (progress) {
var downloadProgressBar = document.getElementById("downloadProgressBar");
downloadProgressBar.value = progress.packageDownloadProgress;
});
}
});
}
});

C# 和 JavaScript 版本之间的两个主要区别是 casing conventionsasynchronous methods 。更多信息请参见Using the Windows Runtime in JavaScript .

关于Javascript - Windows 应用商店 - 强制强制更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43819761/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com