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

运行机制

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

如何获取

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

示例:

Copy
Full screen
Small screen
     1<body>
     2  ...
     3  <script>
     4    const frame = document.createElement("IFRAME");
     5    frame.id = "xsolla-installer-renamer";
     6    frame.src = `https://installer.launcher.xsolla.com/launcher-installer-renamer-prod/v1/renamer.html?cache=${Date.now()}`;
     7    frame.style = "display: none";
     8    document.body.append(frame);
     9  </script>
    10  ...
    11<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
      1postMessage(
      2  {
      3    type: "download",
      4    href: "<LINK TO INSTALLER>",
      5    name: "<NEW INSTALLER NAME>",
      6  },
      7  "https://installer.launcher.xsolla.com"
      8)
      

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

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

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

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

        Copy
        Full screen
        Small screen
           1<body>
           2  ...
           3  <button id="button-download">Download</button>
           4  <script>
           5    const btn = document.getElementById("button-download");
           6    btn.onclick = () => {
           7      document
           8        .getElementById("xsolla-installer-renamer")
           9        .contentWindow.postMessage(
          10          {
          11            type: "download",
          12            href: "<LINK TO INSTALLER>",
          13            name: "<NEW INSTALLER NAME>",
          14          },
          15          "https://installer.launcher.xsolla.com"
          16        );
          17    };
          18  </script>
          19  ...
          20<body>
          
          本文对您的有帮助吗?
          谢谢!
          我们还有其他可改进之处吗? 留言
          非常抱歉
          请说明为何本文没有帮助到您。 留言
          感谢您的反馈!
          我们会查看您的留言并运用它改进用户体验。
          上次更新时间: 2025年7月9日

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

          报告问题
          我们非常重视内容质量。您的反馈将帮助我们做得更好。
          请留下邮箱以便我们后续跟进
          感谢您的反馈!
          无法发送您的反馈
          请稍后重试或发送邮件至doc_feedback@xsolla.com与我们联系。