MCPcopy
hub / github.com/marktext/marktext / init

Method init

packages/desktop/src/main/app/index.ts:67–142  ·  view source on GitHub ↗

* The entry point into the application.

()

Source from the content-addressed store, hash-verified

65 * The entry point into the application.
66 */
67 init(): void {
68 // Enable these features to use `backdrop-filter` css rules!
69 if (isOsx) {
70 app.commandLine.appendSwitch('enable-experimental-web-platform-features', 'true')
71 }
72
73 app.on('second-instance', (_event, argv, workingDirectory) => {
74 const { _openFilesCache, _windowManager } = this
75 const args = parseArgs(argv.slice(1)) as CliArgs
76
77 const buf: PathInfo[] = []
78 for (const pathname of args._) {
79 // Ignore all unknown flags
80 if (pathname.startsWith('--')) {
81 continue
82 }
83
84 const info = normalizeMarkdownPath(path.resolve(workingDirectory, pathname))
85 if (info) {
86 buf.push(info as PathInfo)
87 }
88 }
89
90 if (args['--new-window']) {
91 this._openPathList(buf, true)
92 return
93 }
94
95 _openFilesCache.push(...buf)
96 if (_openFilesCache.length) {
97 this._openFilesToOpen()
98 } else {
99 const activeWindow = _windowManager.getActiveWindow()
100 if (activeWindow) {
101 activeWindow.bringToFront()
102 }
103 }
104 })
105
106 app.on('open-file', this.openFile) // macOS only
107
108 app.on('ready', this.ready)
109
110 app.on('window-all-closed', () => {
111 // Close all the image path watcher
112 for (const watcher of watchers.values()) {
113 watcher.close()
114 }
115 this._windowManager.closeWatcher()
116 if (!isOsx) {
117 app.quit()
118 }
119 })
120
121 app.on('activate', () => {
122 // macOS only
123 // On OS X it's common to re-create a window in the app when the
124 // dock icon is clicked and there are no other windows open.

Callers 2

index.tsFile · 0.45
constructorMethod · 0.45

Calls 11

_openPathListMethod · 0.95
_openFilesToOpenMethod · 0.95
normalizeMarkdownPathFunction · 0.90
parseArgsFunction · 0.85
resolveMethod · 0.80
pushMethod · 0.80
getActiveWindowMethod · 0.80
bringToFrontMethod · 0.80
closeWatcherMethod · 0.80
onMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected