-
Notifications
You must be signed in to change notification settings - Fork 678
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into feature/lists-3
- Loading branch information
Showing
144 changed files
with
4,703 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
packages/shared/src/hono.ts | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type { BrowserWindow } from "electron" | ||
import { Menu } from "electron" | ||
|
||
import { t } from "./i18n" | ||
|
||
export const registerContextMenu = (window: BrowserWindow) => { | ||
const handler = (_event: Electron.Event, props: Electron.ContextMenuParams) => { | ||
const { selectionText, isEditable } = props | ||
|
||
const selectionMenu = Menu.buildFromTemplate([ | ||
{ role: "copy", label: t("menu.copy"), accelerator: "CmdOrCtrl+C" }, | ||
{ type: "separator" }, | ||
{ role: "selectAll", label: t("menu.selectAll"), accelerator: "CmdOrCtrl+A" }, | ||
]) | ||
|
||
const inputMenu = Menu.buildFromTemplate([ | ||
{ role: "undo", label: t("menu.undo"), accelerator: "CmdOrCtrl+Z" }, | ||
{ | ||
role: "redo", | ||
label: t("menu.redo"), | ||
accelerator: "CmdOrCtrl+Shift+Z", | ||
}, | ||
{ type: "separator" }, | ||
{ | ||
role: "cut", | ||
label: t("menu.cut"), | ||
accelerator: "CmdOrCtrl+X", | ||
}, | ||
{ | ||
role: "copy", | ||
label: t("menu.copy"), | ||
accelerator: "CmdOrCtrl+C", | ||
}, | ||
{ | ||
role: "paste", | ||
label: t("menu.paste"), | ||
accelerator: "CmdOrCtrl+V", | ||
}, | ||
{ | ||
type: "separator", | ||
}, | ||
{ role: "selectAll", label: t("menu.selectAll"), accelerator: "CmdOrCtrl+A" }, | ||
]) | ||
|
||
if (isEditable) { | ||
inputMenu.popup({ | ||
window, | ||
}) | ||
} else if (selectionText && selectionText.trim() !== "") { | ||
selectionMenu.popup({ window }) | ||
} | ||
} | ||
window.webContents.on("context-menu", handler) | ||
|
||
return () => { | ||
window.webContents.removeListener("context-menu", handler) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { session } from "electron" | ||
|
||
import { logger } from "../logger" | ||
import { store } from "./store" | ||
|
||
// Sets up the proxy configuration for the app. | ||
// | ||
// See https://www.electronjs.org/docs/latest/api/session#sessetproxyconfig | ||
// for more information about the proxy API. | ||
// | ||
// The open-source project [poooi/poi](https://github.com/poooi/poi) is doing well in proxy configuration | ||
// refer the following files for more details: | ||
// | ||
// https://github.com/poooi/poi/blob/5741d0d02c0a08626dd53196b094223457014491/lib/proxy.ts#L36 | ||
// https://github.com/poooi/poi/blob/5741d0d02c0a08626dd53196b094223457014491/views/components/settings/network/index.es | ||
|
||
export const setProxyConfig = (inputProxy: string) => { | ||
const proxyUri = normalizeProxyUri(inputProxy) | ||
if (!proxyUri) { | ||
return false | ||
} | ||
store.set("proxy", inputProxy) | ||
return true | ||
} | ||
|
||
export const getProxyConfig = () => { | ||
const proxyConfig = store.get("proxy") as string | undefined | ||
if (!proxyConfig) { | ||
return | ||
} | ||
const proxyUri = normalizeProxyUri(proxyConfig) | ||
return proxyUri | ||
} | ||
|
||
const URL_SCHEME = new Set(["http:", "https:", "ftp:", "socks:", "socks4:", "socks5:"]) | ||
|
||
const normalizeProxyUri = (userProxy: string) => { | ||
if (!userProxy) { | ||
return | ||
} | ||
try { | ||
const proxyUrl = new URL(userProxy) | ||
if (!URL_SCHEME.has(proxyUrl.protocol) || !proxyUrl.hostname || !proxyUrl.port) { | ||
return | ||
} | ||
// There are multiple ways to specify a proxy in Electron, | ||
// but for security reasons, we only support simple proxy URLs for now. | ||
return [ | ||
`${proxyUrl.protocol}//${proxyUrl.hostname}:${proxyUrl.port}`, | ||
// Failing over to using no proxy if the proxy is unavailable | ||
"direct://", | ||
].join(",") | ||
} catch { | ||
return | ||
} | ||
} | ||
|
||
const BYPASS_RULES = ["<local>"].join(";") | ||
|
||
export const updateProxy = () => { | ||
const proxyUri = getProxyConfig() | ||
if (!proxyUri) { | ||
session.defaultSession.setProxy({ | ||
// Note that the system mode is different from setting no proxy configuration. | ||
// In the latter case, Electron falls back to the system settings only if no command-line options influence the proxy configuration. | ||
mode: "system", | ||
}) | ||
return | ||
} | ||
|
||
logger.log(`Loading proxy: ${proxyUri}`) | ||
session.defaultSession.setProxy({ | ||
proxyRules: proxyUri, | ||
proxyBypassRules: BYPASS_RULES, | ||
}) | ||
} |
Oops, something went wrong.