mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-02-15 01:32:17 +01:00
root level
This commit is contained in:
parent
f6cdd53fd4
commit
de21303fb1
@ -20,7 +20,7 @@ import { MainSideBar } from "./sidebar/main";
|
|||||||
import { RightSideBar } from "./sidebar/right";
|
import { RightSideBar } from "./sidebar/right";
|
||||||
import { DisconnectedModal, ClientStopModal } from "@/modals";
|
import { DisconnectedModal, ClientStopModal } from "@/modals";
|
||||||
import { ModalsProvider } from "@/modals/provider";
|
import { ModalsProvider } from "@/modals/provider";
|
||||||
import { Button } from "@/elements";
|
import { Button, StyleBlock } from "@/elements";
|
||||||
import { ErrorBoundary } from "@/common/error/errorboundary";
|
import { ErrorBoundary } from "@/common/error/errorboundary";
|
||||||
import cn from "classnames";
|
import cn from "classnames";
|
||||||
import "./app.less";
|
import "./app.less";
|
||||||
@ -124,9 +124,10 @@ class App extends React.Component<{}, {}> {
|
|||||||
const rightSidebarCollapsed = GlobalModel.rightSidebarModel.getCollapsed();
|
const rightSidebarCollapsed = GlobalModel.rightSidebarModel.getCollapsed();
|
||||||
const activeMainView = GlobalModel.activeMainView.get();
|
const activeMainView = GlobalModel.activeMainView.get();
|
||||||
const lightDarkClass = GlobalModel.isDarkTheme.get() ? "is-dark" : "is-light";
|
const lightDarkClass = GlobalModel.isDarkTheme.get() ? "is-dark" : "is-light";
|
||||||
|
const termTheme = GlobalModel.getTermTheme();
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={"version-" + renderVersion}
|
key={`version- + ${renderVersion}`}
|
||||||
id="main"
|
id="main"
|
||||||
className={cn(
|
className={cn(
|
||||||
"platform-" + platform,
|
"platform-" + platform,
|
||||||
@ -135,6 +136,12 @@ class App extends React.Component<{}, {}> {
|
|||||||
)}
|
)}
|
||||||
onContextMenu={this.handleContextMenu}
|
onContextMenu={this.handleContextMenu}
|
||||||
>
|
>
|
||||||
|
<StyleBlock
|
||||||
|
termTheme={termTheme}
|
||||||
|
themeSrcEl={document.documentElement}
|
||||||
|
themeKey="global"
|
||||||
|
className=":root"
|
||||||
|
/>
|
||||||
<If condition={mainSidebarCollapsed}>
|
<If condition={mainSidebarCollapsed}>
|
||||||
<div key="logo-button" className="logo-button-container">
|
<div key="logo-button" className="logo-button-container">
|
||||||
<div className="logo-button-spacer" />
|
<div className="logo-button-spacer" />
|
||||||
|
@ -43,7 +43,7 @@ class StyleBlock extends React.Component<
|
|||||||
.map(([key, value]) => `--term-${key}: ${value};`)
|
.map(([key, value]) => `--term-${key}: ${value};`)
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
|
||||||
this.styleRules.set(`.${className} { ${styleProperties} }`);
|
this.styleRules.set(`${className} { ${styleProperties} }`);
|
||||||
GlobalModel.bumpTermRenderVersion();
|
GlobalModel.bumpTermRenderVersion();
|
||||||
this.theme = currTheme;
|
this.theme = currTheme;
|
||||||
} else {
|
} else {
|
||||||
@ -56,6 +56,8 @@ class StyleBlock extends React.Component<
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
console.log("this.styleRules", this.styleRules.get());
|
||||||
|
|
||||||
if (isBlank(this.styleRules.get())) {
|
if (isBlank(this.styleRules.get())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ import { ErrorBoundary } from "@/common/error/errorboundary";
|
|||||||
import * as textmeasure from "@/util/textmeasure";
|
import * as textmeasure from "@/util/textmeasure";
|
||||||
import { boundMethod } from "autobind-decorator";
|
import { boundMethod } from "autobind-decorator";
|
||||||
import type { Screen } from "@/models";
|
import type { Screen } from "@/models";
|
||||||
import { Button } from "@/elements";
|
import { Button, StyleBlock } from "@/elements";
|
||||||
import { commandRtnHandler, isBlank } from "@/util/util";
|
import { commandRtnHandler } from "@/util/util";
|
||||||
import { getTermThemes } from "@/util/themeutil";
|
import { getTermThemes } from "@/util/themeutil";
|
||||||
import { Dropdown } from "@/elements/dropdown";
|
import { Dropdown } from "@/elements/dropdown";
|
||||||
import { getRemoteStrWithAlias } from "@/common/prompt/prompt";
|
import { getRemoteStrWithAlias } from "@/common/prompt/prompt";
|
||||||
@ -206,62 +206,6 @@ class TabSettings extends React.Component<{ screen: Screen }, {}> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@mobxReact.observer
|
|
||||||
class StyleBlock extends React.Component<
|
|
||||||
{ themeSrcEl: HTMLElement; themeKey: string; className: string; termTheme: TermThemeType },
|
|
||||||
{ styleRules: string }
|
|
||||||
> {
|
|
||||||
styleRules: OV<string> = mobx.observable.box("", { name: "StyleBlock-styleRules" });
|
|
||||||
theme: string;
|
|
||||||
|
|
||||||
componentDidMount(): void {
|
|
||||||
GlobalModel.termThemeSrcEl.set(this.props.themeSrcEl);
|
|
||||||
this.loadThemeStyles();
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate(prevProps): void {
|
|
||||||
const { themeKey, termTheme } = this.props;
|
|
||||||
const currTheme = termTheme[themeKey];
|
|
||||||
if (themeKey !== prevProps.themeKey || currTheme !== this.theme) {
|
|
||||||
this.loadThemeStyles();
|
|
||||||
}
|
|
||||||
if (this.props.themeSrcEl !== prevProps.themeSrcEl) {
|
|
||||||
GlobalModel.termThemeSrcEl.set(this.props.themeSrcEl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async loadThemeStyles() {
|
|
||||||
const { themeKey, className, termTheme } = this.props;
|
|
||||||
const currTheme = termTheme[themeKey];
|
|
||||||
|
|
||||||
if (currTheme !== this.theme && currTheme) {
|
|
||||||
const rtn = GlobalModel.getTermThemeJson(currTheme);
|
|
||||||
rtn.then((termThemeJson) => {
|
|
||||||
if (termThemeJson && typeof termThemeJson === "object") {
|
|
||||||
const styleProperties = Object.entries(termThemeJson)
|
|
||||||
.map(([key, value]) => `--term-${key}: ${value};`)
|
|
||||||
.join(" ");
|
|
||||||
|
|
||||||
this.styleRules.set(`.${className} { ${styleProperties} }`);
|
|
||||||
GlobalModel.bumpTermRenderVersion();
|
|
||||||
this.theme = currTheme;
|
|
||||||
} else {
|
|
||||||
console.error("termThemeJson is not an object:", termThemeJson);
|
|
||||||
}
|
|
||||||
}).catch((error) => {
|
|
||||||
console.error("error loading theme styles:", error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (isBlank(this.styleRules.get())) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return <style>{this.styleRules.get()}</style>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@mobxReact.observer
|
@mobxReact.observer
|
||||||
class WorkspaceView extends React.Component<{}, {}> {
|
class WorkspaceView extends React.Component<{}, {}> {
|
||||||
sessionRef = React.createRef<HTMLDivElement>();
|
sessionRef = React.createRef<HTMLDivElement>();
|
||||||
@ -359,7 +303,7 @@ class WorkspaceView extends React.Component<{}, {}> {
|
|||||||
themeSrcEl={this.sessionRef.current}
|
themeSrcEl={this.sessionRef.current}
|
||||||
themeKey={session.sessionId}
|
themeKey={session.sessionId}
|
||||||
termTheme={termTheme}
|
termTheme={termTheme}
|
||||||
className="session-view"
|
className=".session-view"
|
||||||
/>
|
/>
|
||||||
</If>
|
</If>
|
||||||
<If condition={!isHidden}>
|
<If condition={!isHidden}>
|
||||||
|
Loading…
Reference in New Issue
Block a user