Browse Source

ref: things

Sv443 7 tháng trước cách đây
mục cha
commit
fd650cff7f
2 tập tin đã thay đổi với 6 bổ sung12 xóa
  1. 3 3
      src/constants.ts
  2. 3 9
      src/dialogs/versionNotif.ts

+ 3 - 3
src/constants.ts

@@ -21,12 +21,12 @@ export const buildNumber = (buildNumberRaw.match(/^#{{.+}}$/) ? "BUILD_ERROR!" :
 /** The URL search parameters at the earliest possible time */
 export const initialParams = new URL(location.href).searchParams;
 
-/** Names of platforms by value of {@linkcode host} */
-export const platformNames: Record<typeof host, string> = {
+/** Names of platforms by key of {@linkcode host} */
+export const platformNames = {
   github: "GitHub",
   greasyfork: "GreasyFork",
   openuserjs: "OpenUserJS",
-};
+} as const;
 
 /** Default compression format used throughout BYTM */
 export const compressionFormat: CompressionFormat = "deflate-raw";

+ 3 - 9
src/dialogs/versionNotif.ts

@@ -1,4 +1,4 @@
-import { host, mode, scriptInfo } from "../constants.js";
+import { host, mode, platformNames, scriptInfo } from "../constants.js";
 import { getChangelogMd, getResourceUrl, onInteraction, parseMarkdown, setInnerHtml, t } from "../utils/index.js";
 import { BytmDialog, createToggleInput } from "../components/index.js";
 import { getFeature, getFeatures, setFeatures } from "../config.js";
@@ -57,16 +57,10 @@ async function renderBody({
 }) {
   disableUpdateCheck = false;
 
-  const hostPlatformNames: Record<typeof host, string> = {
-    github: "GitHub",
-    greasyfork: "GreasyFork",
-    openuserjs: "OpenUserJS",
-  };
-
   const wrapperEl = document.createElement("div");
 
   const pEl = document.createElement("p");
-  pEl.textContent = t("new_version_available", scriptInfo.name, scriptInfo.version, latestTag, hostPlatformNames[host]);
+  pEl.textContent = t("new_version_available", scriptInfo.name, scriptInfo.version, latestTag, platformNames[host]);
   wrapperEl.appendChild(pEl);
 
   const changelogDetailsEl = document.createElement("details");
@@ -151,7 +145,7 @@ async function renderBody({
   const btnUpdate = document.createElement("button");
   btnUpdate.classList.add("bytm-btn");
   btnUpdate.tabIndex = 0;
-  btnUpdate.textContent = t("open_update_page_install_manually", hostPlatformNames[host]);
+  btnUpdate.textContent = t("open_update_page_install_manually", platformNames[host]);
 
   onInteraction(btnUpdate, () => {
     window.open(pkg.updates[host]);