| 34 | import { tracker } from "./tracker"; |
| 35 | |
| 36 | class Controller extends MainController { |
| 37 | win: WindowManager = new WindowManager(this); |
| 38 | menu: MenuManager = new MenuManager(this); |
| 39 | updater = new UpdateChecker(this); |
| 40 | shortcut: ShortcutManager = new ShortcutManager(); |
| 41 | l10n: L10N = l10n; |
| 42 | transCon = new TranslateController(this); |
| 43 | |
| 44 | constructor() { |
| 45 | super(); |
| 46 | this.config.load(); |
| 47 | // Lazy load to avoid circular dependencies |
| 48 | const { customTranslatorManager } = require("@/common/translate/custom-translators"); |
| 49 | customTranslatorManager.reload(); |
| 50 | observers.push(this); |
| 51 | observers.push(this.transCon); |
| 52 | this.bindLinks(actionLinks); |
| 53 | } |
| 54 | |
| 55 | set(identifier: Identifier, value: any): boolean { |
| 56 | return this.config.set(identifier, value); |
| 57 | } |
| 58 | |
| 59 | restoreMultiDefault(optionType: MenuActionType | Category) { |
| 60 | const keys = this.action.getKeys(optionType); |
| 61 | for (const key of keys) { |
| 62 | this.config.reset(key as Identifier); //带参时仅重置特定项 |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | enumerateLayouts(isLeft: boolean) { |
| 67 | const index = layoutTypes.findIndex( |
| 68 | (x) => x === this.config.get<LayoutType>("layoutType") |
| 69 | ); |
| 70 | let newIndex: number; |
| 71 | if (isLeft) { |
| 72 | newIndex = (index + 1) % layoutTypes.length; |
| 73 | } else { |
| 74 | newIndex = (index + layoutTypes.length - 1) % layoutTypes.length; |
| 75 | } |
| 76 | this.set("layoutType", layoutTypes[newIndex]); |
| 77 | } |
| 78 | |
| 79 | promptForName() { |
| 80 | const l = store.getters.locale; |
| 81 | electronPrompt( |
| 82 | { |
| 83 | title: l["snapshotPrompt"], |
| 84 | label: l["snapshotValidate"], |
| 85 | value: "", |
| 86 | inputAttrs: { |
| 87 | type: "text", |
| 88 | }, |
| 89 | type: "input", |
| 90 | icon: icon, |
| 91 | }, |
| 92 | this.win.mainWindow |
| 93 | ) |
nothing calls this directly
no outgoing calls
no test coverage detected