MCPcopy Create free account
hub / github.com/deta/surf / createSettingsWindow

Function createSettingsWindow

app/src/main/settingsWindow.ts:11–90  ·  view source on GitHub ↗
(tab?: SettingsWindowTab)

Source from the content-addressed store, hash-verified

9let settingsWindow: BrowserWindow | undefined
10
11export function createSettingsWindow(tab?: SettingsWindowTab) {
12 if (settingsWindow && !settingsWindow.isDestroyed()) {
13 settingsWindow.show()
14 return
15 }
16
17 const settingsWindowSession = session.fromPartition('persist:surf-app-session')
18
19 settingsWindow = new BrowserWindow({
20 width: 1000,
21 height: 800,
22 fullscreenable: false,
23 show: false,
24 resizable: false,
25 autoHideMenuBar: true,
26 title: 'Settings',
27 frame: !isMac(),
28 trafficLightPosition: { x: 24, y: 24 },
29 titleBarStyle: isMac() ? 'hidden' : 'default',
30 // ...(isLinux() ? { icon } : {}),
31 webPreferences: {
32 preload: join(__dirname, '../preload/core.js'),
33 additionalArguments: [
34 `--userDataPath=${app.getPath('userData')}`,
35 `--settings-window-entry-point=${SettingsWindowEntrypoint}`
36 ],
37 defaultFontSize: 14,
38 session: settingsWindowSession,
39 webviewTag: false,
40 sandbox: false,
41 nodeIntegration: false,
42 contextIsolation: true
43 }
44 })
45
46 applyCSPToSession(settingsWindowSession)
47
48 settingsWindow.on('ready-to-show', () => {
49 if (!is.dev) {
50 settingsWindow?.showInactive()
51 } else {
52 settingsWindow?.show()
53 }
54 })
55
56 settingsWindow.webContents.on('will-navigate', (event) => {
57 // TODO: should we handle new windows here?
58 event.preventDefault()
59 })
60
61 settingsWindow.webContents.setWindowOpenHandler((details) => {
62 const ALLOWED_DOMAINS = [
63 'https://deta.surf',
64 'https://deta.notion.site',
65 'https://github.com',
66 'https://ollama.com',
67 'https://openrouter.ai',
68 'https://platform.openai.com',

Callers 2

setupIpcHandlersFunction · 0.90
getSurfMenuMethod · 0.90

Calls 5

isMacFunction · 0.90
applyCSPToSessionFunction · 0.90
showMethod · 0.80
onMethod · 0.80
loadURLMethod · 0.45

Tested by

no test coverage detected