mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
refactor(client): relocate architecture mismatch checks
This commit is contained in:
parent
f6bba436f4
commit
b4d2d21620
@ -28,6 +28,7 @@ import type { NativeImage, TouchBar } from "electron";
|
||||
import TouchBarComponent from "./touch_bar.js";
|
||||
import type { CKTextEditor } from "@triliumnext/ckeditor5";
|
||||
import type CodeMirror from "@triliumnext/codemirror";
|
||||
import { StartupChecks } from "./startup_checks.js";
|
||||
|
||||
interface Layout {
|
||||
getRootWidget: (appContext: AppContext) => RootWidget;
|
||||
@ -474,7 +475,14 @@ export class AppContext extends Component {
|
||||
initComponents() {
|
||||
this.tabManager = new TabManager();
|
||||
|
||||
this.components = [this.tabManager, new RootCommandExecutor(), new Entrypoints(), new MainTreeExecutors(), new ShortcutComponent()];
|
||||
this.components = [
|
||||
this.tabManager,
|
||||
new RootCommandExecutor(),
|
||||
new Entrypoints(),
|
||||
new MainTreeExecutors(),
|
||||
new ShortcutComponent(),
|
||||
new StartupChecks()
|
||||
];
|
||||
|
||||
if (utils.isMobile()) {
|
||||
this.components.push(new MobileScreenSwitcherExecutor());
|
||||
|
23
apps/client/src/components/startup_checks.ts
Normal file
23
apps/client/src/components/startup_checks.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import server from "../services/server";
|
||||
import Component from "./component";
|
||||
|
||||
export class StartupChecks extends Component {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.checkRosetta2Warning();
|
||||
}
|
||||
|
||||
async checkRosetta2Warning() {
|
||||
try {
|
||||
// Check if running under Rosetta 2 by calling the server
|
||||
const response = await server.get("system-info/rosetta-check") as { isRunningUnderRosetta2: boolean };
|
||||
if (response.isRunningUnderRosetta2) {
|
||||
// Trigger the Rosetta 2 warning dialog
|
||||
this.triggerCommand("showRosettaWarning", {});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Could not check Rosetta 2 status:", error);
|
||||
}
|
||||
}
|
||||
}
|
@ -23,10 +23,7 @@ bundleService.getWidgetBundlesByParent().then(async (widgetBundles) => {
|
||||
const DesktopLayout = (await import("./layouts/desktop_layout.js")).default;
|
||||
|
||||
appContext.setLayout(new DesktopLayout(widgetBundles));
|
||||
appContext.start().then(() => {
|
||||
// Check for Rosetta 2 after the app has fully started
|
||||
checkRosetta2Warning();
|
||||
}).catch((e) => {
|
||||
appContext.start().catch((e) => {
|
||||
toastService.showPersistent({
|
||||
title: t("toast.critical-error.title"),
|
||||
icon: "alert",
|
||||
@ -118,18 +115,3 @@ function initDarkOrLightMode(style: CSSStyleDeclaration) {
|
||||
const { nativeTheme } = utils.dynamicRequire("@electron/remote") as typeof ElectronRemote;
|
||||
nativeTheme.themeSource = themeSource;
|
||||
}
|
||||
|
||||
async function checkRosetta2Warning() {
|
||||
if (!utils.isElectron()) return;
|
||||
|
||||
try {
|
||||
// Check if running under Rosetta 2 by calling the server
|
||||
const response = await server.get("api/system-info/rosetta-check") as { isRunningUnderRosetta2: boolean };
|
||||
if (response.isRunningUnderRosetta2) {
|
||||
// Trigger the Rosetta 2 warning dialog
|
||||
appContext.triggerCommand("showRosettaWarning", {});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Could not check Rosetta 2 status:", error);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user