feat: add `folo` scheme

- Introduced `LEGACY_APP_PROTOCOL` to manage legacy protocol support alongside the new `APP_PROTOCOL`.
- Updated various files to utilize the new protocol constants, ensuring compatibility and consistency across the application.
- Enhanced mobile app configuration to support multiple schemes for better flexibility.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei 2025-05-20 20:46:12 +08:00
parent 6b4b1f37f3
commit 4fa171b418
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
6 changed files with 31 additions and 15 deletions

View File

@ -107,6 +107,10 @@ const config: ForgeConfig = {
name: "Folo",
schemes: ["follow"],
},
{
name: "Folo",
schemes: ["folo"],
},
],
afterCopy: [

View File

@ -2,7 +2,7 @@ import "./side-effects"
import { electronApp, optimizer } from "@electron-toolkit/utils"
import { callWindowExpose } from "@follow/shared/bridge"
import { APP_PROTOCOL, DEV } from "@follow/shared/constants"
import { DEV, LEGACY_APP_PROTOCOL } from "@follow/shared/constants"
import { env } from "@follow/shared/env.desktop"
import { createBuildSafeHeaders } from "@follow/utils/headers"
import { IMAGE_PROXY_URL } from "@follow/utils/img-proxy"
@ -101,7 +101,7 @@ function bootstrap() {
})
// Set app user model id for windows
electronApp.setAppUserModelId(`re.${APP_PROTOCOL}`)
electronApp.setAppUserModelId(`re.${LEGACY_APP_PROTOCOL}`)
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
details.requestHeaders = buildSafeHeaders({

View File

@ -2,7 +2,7 @@ import path from "node:path"
import { getRendererHandlers, registerIpcMain } from "@egoist/tipc/main"
import { PushReceiver } from "@eneris/push-receiver"
import { APP_PROTOCOL, DEV } from "@follow/shared/constants"
import { APP_PROTOCOL, DEV, LEGACY_APP_PROTOCOL } from "@follow/shared/constants"
import { env } from "@follow/shared/env.desktop"
import type { MessagingData } from "@follow/shared/hono"
import { app, nativeTheme, Notification, protocol, shell } from "electron"
@ -31,14 +31,16 @@ export function initializeAppStage0() {
initializeSentry()
}
export const initializeAppStage1 = () => {
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient(APP_PROTOCOL, process.execPath, [
path.resolve(process.argv[1]!),
])
const protocols = [LEGACY_APP_PROTOCOL, APP_PROTOCOL]
for (const protocol of protocols) {
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient(protocol, process.execPath, [path.resolve(process.argv[1]!)])
}
} else {
app.setAsDefaultProtocolClient(protocol)
}
} else {
app.setAsDefaultProtocolClient(APP_PROTOCOL)
}
registerIpcMain(router)

View File

@ -2,9 +2,9 @@ import path from "node:path"
import { fileURLToPath } from "node:url"
import { is } from "@electron-toolkit/utils"
import { APP_PROTOCOL } from "@follow/shared"
import { LEGACY_APP_PROTOCOL } from "@follow/shared"
import { callWindowExpose, WindowState } from "@follow/shared/bridge"
import { DEV } from "@follow/shared/constants"
import { APP_PROTOCOL, DEV } from "@follow/shared/constants"
import type { BrowserWindowConstructorOptions } from "electron"
import { app, BrowserWindow, screen, shell } from "electron"
import type { Event } from "electron/main"
@ -112,7 +112,16 @@ export function createWindow(
const handleExternalProtocol = async (e: Event, url: string, window: BrowserWindow) => {
const { protocol } = new URL(url)
const ignoreProtocols = ["http", "https", APP_PROTOCOL, "file", "code", "cursor", "app"]
const ignoreProtocols = [
"http",
"https",
LEGACY_APP_PROTOCOL,
APP_PROTOCOL,
"file",
"code",
"cursor",
"app",
]
if (ignoreProtocols.includes(protocol.slice(0, -1))) {
return
}

View File

@ -37,7 +37,7 @@ export default ({ config }: ConfigContext): ExpoConfig => {
version: PKG.version,
orientation: "portrait" as const,
icon: iconPath,
scheme: "follow",
scheme: ["follow", "folo"],
userInterfaceStyle: "automatic" as const,
newArchEnabled: true,
ios: {

View File

@ -21,7 +21,8 @@ export const { PROD } = import.meta.env
export const DEV =
"process" in globalThis ? process.env.NODE_ENV === "development" : import.meta.env.DEV
export const APP_PROTOCOL = DEV ? "follow-dev" : "follow"
export const LEGACY_APP_PROTOCOL = DEV ? "follow-dev" : "follow"
export const APP_PROTOCOL = DEV ? "folo-dev" : "folo"
export const DEEPLINK_SCHEME = `${APP_PROTOCOL}://` as const
export const SYSTEM_CAN_UNDER_BLUR_WINDOW = globalThis?.window?.electron