gpt4 book ai didi

visual-studio-2012 - WinJS System.Launcher 仅在 Debug模式下工作

转载 作者:行者123 更新时间:2023-12-02 02:10:24 24 4
gpt4 key购买 nike

以下代码在 Debug模式 (F5) 下运行时完美无缺......但在部署(作为应用程序磁贴)或在没有调试器 (ctl+f5) 的情况下运行时,它无法正常运行.

工作时的预期/行为:单击磁贴会立即启动 Steam URL 链接,而不会显示可见的 html 页面。

行为收到/不工作:点击磁贴启动应用程序,只呈现 html 页面,从不启动 steam url。

var mydefs = new Object();
mydefs = { url: 'steam://rungameid/200710' };

function launch(url) {
var uri = new Windows.Foundation.Uri(url);

Windows.System.Launcher.launchUriAsync(uri).then(
function (success) {
if (success) {
// File launched
window.close();
} else {
// File launch failed
}
});
}

(function () {
"use strict";

WinJS.Binding.optimizeBindingReferences = true;

var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;

app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
launch(mydefs.url);

args.setPromise(WinJS.UI.processAll());
}
};

app.oncheckpoint = function (args) {
window.close();
};

app.start();
})();

最佳答案

看起来像是时间问题。以下作为磁贴对我有用

(function () {
"use strict";
var mydefs = new Object();
mydefs = { url: 'steam://rungameid/200710' };

WinJS.Namespace.define("Steam", {
launch: function launch(url) {
var uri = new Windows.Foundation.Uri(url);

Windows.System.Launcher.launchUriAsync(uri).then(
function (success) {
if (success) {
// File launched
window.close();
} else {
// File launch failed
}
});
}
});


WinJS.Binding.optimizeBindingReferences = true;

var app = WinJS.Application;
var activation = Windows.ApplicationModel.Activation;

app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
setTimeout('Steam.launch("steam://rungameid/200710");', 2000);
args.setPromise(WinJS.UI.processAll());
}
};

app.start();
})();

关于visual-studio-2012 - WinJS System.Launcher 仅在 Debug模式下工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13244047/

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