如何设置启动器安装程序名称

运行机制

默认情况下,独立版本的启动器安装程序命名为installer.exe,Web版本命名为web_installer.exe。您可以在网站代码中设置自己的名称。用户点击下载按钮或链接时,浏览器会自动替换安装文件的名称。

如何获取

  1. 在网站代码中添加一个不可见iframe,其中将会生成一个包含修改后名称的安装文件下载链接,如下方示例所示。

示例:

Copy
Full screen
Small screen
    <body>
      ...
      <script>
        const frame = document.createElement("IFRAME");
        frame.id = "xsolla-installer-renamer";
        frame.src = `https://installer.launcher.xsolla.com/launcher-installer-renamer-prod/v1/renamer.html?cache=${Date.now()}`;
        frame.style = "display: none";
        document.body.append(frame);
      </script>
      ...
    <body>
    

    1. 实现postMessage()方法,在点击链接或按钮时将参数传入iframe:
      • <LINK TO INSTALLER> — 安装文件的URL。位于发布商帐户启动器 > 设置 > 启动器编译版本部分。示例:https://installer.launcher.xsolla.com/xlauncher-builds/xsolla-launcher-update/123456789/bin/web_installer.exe
      • <NEW INSTALLER NAME> — 安装文件的名称。

    示例:

    Copy
    Full screen
    Small screen
      postMessage(
        {
          type: "download",
          href: "<LINK TO INSTALLER>",
          name: "<NEW INSTALLER NAME>",
        },
        "https://installer.launcher.xsolla.com"
      )
      

      下方是下载安装文件的下载链接和按钮的示例代码。

      安装文件下载链接的示例代码:

      Copy
      Full screen
      Small screen
        <body>
          ...
          <a
              href="#"
              onclick="document.getElementById('xsolla-installer-renamer').contentWindow.postMessage({ type: 'download', href: '<LINK TO INSTALLER>', name: '<NEW INSTALLER NAME>' }, 'https://installer.launcher.xsolla.com');"
          >
            Donwload
          </a>
          ...
        <body>
        

        安装文件下载按钮的示例代码:

        Copy
        Full screen
        Small screen
          <body>
            ...
            <button id="button-download">Download</button>
            <script>
              const btn = document.getElementById("button-download");
              btn.onclick = () => {
                document
                  .getElementById("xsolla-installer-renamer")
                  .contentWindow.postMessage(
                    {
                      type: "download",
                      href: "<LINK TO INSTALLER>",
                      name: "<NEW INSTALLER NAME>",
                    },
                    "https://installer.launcher.xsolla.com"
                  );
              };
            </script>
            ...
          <body>
          
          本文对您的有帮助吗?
          谢谢!
          我们还有其他可改进之处吗? 留言
          非常抱歉
          请说明为何本文没有帮助到您。 留言
          感谢您的反馈!
          我们会查看您的留言并运用它改进用户体验。
          为此页面评分
          为此页面评分
          我们还有其他可改进之处吗?

          不想回答

          感谢您的反馈!
          上次更新时间: 2024年1月22日

          发现了错别字或其他内容错误? 请选择文本,然后按Ctrl+Enter。

          报告问题
          我们非常重视内容质量。您的反馈将帮助我们做得更好。
          请留下邮箱以便我们后续跟进
          感谢您的反馈!