From 6b2cf2227b3ca37c1458ca770199c1b84ab79287 Mon Sep 17 00:00:00 2001 From: wtetsu Date: Sat, 16 Oct 2021 18:42:39 +0900 Subject: [PATCH] Firefox optimization --- src/options/component/organism/Tips.tsx | 42 ++++++++++--------------- src/options/extern/env.ts | 2 +- src/options/resource/links.ts | 21 +++++++++++++ src/options/types.ts | 6 ++++ 4 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 src/options/resource/links.ts diff --git a/src/options/component/organism/Tips.tsx b/src/options/component/organism/Tips.tsx index dce3ae45..17c014c5 100644 --- a/src/options/component/organism/Tips.tsx +++ b/src/options/component/organism/Tips.tsx @@ -7,6 +7,7 @@ import React from "react"; import { res } from "../../logic"; import { ExternalLink } from "../atom/ExternalLink"; +import { Links } from "../../resource/links"; type TipsProps = { style: React.CSSProperties; @@ -22,35 +23,24 @@ const LINK_STYLE: React.CSSProperties = { }; export const Tips: React.VFC = (props) => { + const tips = [ + { text: res.get("windowManipulation"), href: Links.windowManipulation }, + { text: res.get("downloadDictData"), href: Links.downloadDictData }, + { text: res.get("setKeyboardShortcuts"), href: Links.setKeyboardShortcuts }, + ]; + return (
- - - {res.get("windowManipulation")} - -
- - - {res.get("downloadDictData")} - -
- - - {res.get("setKeyboardShortcuts")} - + {tips.map((e, i) => ( + <> + + + {e.text} + +
+ + ))}
); diff --git a/src/options/extern/env.ts b/src/options/extern/env.ts index d29a270c..2c4975ea 100644 --- a/src/options/extern/env.ts +++ b/src/options/extern/env.ts @@ -12,7 +12,7 @@ const optionsEnv = { ...env } as Env; if (BROWSER === "FIREFOX") { // Larger registerRecordsAtOnce causes memory hog // when loading large dictionary data in Firefox. - optionsEnv.registerRecordsAtOnce = 1000; + optionsEnv.registerRecordsAtOnce = 10000; optionsEnv.support = { localGetBytesInUse: false }; } else { optionsEnv.registerRecordsAtOnce = 100000; diff --git a/src/options/resource/links.ts b/src/options/resource/links.ts new file mode 100644 index 00000000..ac755c50 --- /dev/null +++ b/src/options/resource/links.ts @@ -0,0 +1,21 @@ +/** + * Mouse Dictionary (https://github.com/wtetsu/mouse-dictionary/) + * Copyright 2018-present wtetsu + * Licensed under MIT + */ + +import { BROWSER, ExternalLinks } from "../types"; + +const Links: ExternalLinks = { + windowManipulation: "https://github.com/wtetsu/mouse-dictionary/wiki/Window-manipulation", + downloadDictData: "https://github.com/wtetsu/mouse-dictionary/wiki/Download-dictionary-data", + setKeyboardShortcuts: "", +}; + +if (BROWSER === "FIREFOX") { + Links.setKeyboardShortcuts = "https://github.com/wtetsu/mouse-dictionary/wiki/Keyboard-shortcuts-(Firefox)"; +} else { + Links.setKeyboardShortcuts = "https://github.com/wtetsu/mouse-dictionary/wiki/Keyboard-shortcuts"; +} + +export { Links }; diff --git a/src/options/types.ts b/src/options/types.ts index 11f7969e..6214dde9 100644 --- a/src/options/types.ts +++ b/src/options/types.ts @@ -71,4 +71,10 @@ export type DictionaryFile = { format: DictionaryFileFormat; }; +export type ExternalLinks = { + windowManipulation: string; + downloadDictData: string; + setKeyboardShortcuts: string; +}; + export declare const BROWSER: "CHROME" | "FIREFOX" | "SAFARI";