mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
new config preview:showhiddenfiles and term:theme (#981)
This commit is contained in:
parent
26fcbe0f0f
commit
447596b5e7
@ -19,11 +19,11 @@ import {
|
|||||||
getBlockComponentModel,
|
getBlockComponentModel,
|
||||||
getConnStatusAtom,
|
getConnStatusAtom,
|
||||||
getHostName,
|
getHostName,
|
||||||
|
getSettingsKeyAtom,
|
||||||
getUserName,
|
getUserName,
|
||||||
globalStore,
|
globalStore,
|
||||||
refocusNode,
|
refocusNode,
|
||||||
useBlockAtom,
|
useBlockAtom,
|
||||||
useSettingsKeyAtom,
|
|
||||||
WOS,
|
WOS,
|
||||||
} from "@/app/store/global";
|
} from "@/app/store/global";
|
||||||
import * as services from "@/app/store/services";
|
import * as services from "@/app/store/services";
|
||||||
@ -161,7 +161,7 @@ const BlockFrame_Header = ({
|
|||||||
}: BlockFrameProps & { changeConnModalAtom: jotai.PrimitiveAtom<boolean>; error?: Error }) => {
|
}: BlockFrameProps & { changeConnModalAtom: jotai.PrimitiveAtom<boolean>; error?: Error }) => {
|
||||||
const [blockData] = WOS.useWaveObjectValue<Block>(WOS.makeORef("block", nodeModel.blockId));
|
const [blockData] = WOS.useWaveObjectValue<Block>(WOS.makeORef("block", nodeModel.blockId));
|
||||||
let viewName = util.useAtomValueSafe(viewModel?.viewName) ?? blockViewToName(blockData?.meta?.view);
|
let viewName = util.useAtomValueSafe(viewModel?.viewName) ?? blockViewToName(blockData?.meta?.view);
|
||||||
const showBlockIds = jotai.useAtomValue(useSettingsKeyAtom("blockheader:showblockids"));
|
const showBlockIds = jotai.useAtomValue(getSettingsKeyAtom("blockheader:showblockids"));
|
||||||
let viewIconUnion = util.useAtomValueSafe(viewModel?.viewIcon) ?? blockViewToIcon(blockData?.meta?.view);
|
let viewIconUnion = util.useAtomValueSafe(viewModel?.viewIcon) ?? blockViewToIcon(blockData?.meta?.view);
|
||||||
const preIconButton = util.useAtomValueSafe(viewModel?.preIconButton);
|
const preIconButton = util.useAtomValueSafe(viewModel?.preIconButton);
|
||||||
let headerTextUnion = util.useAtomValueSafe(viewModel?.viewText);
|
let headerTextUnion = util.useAtomValueSafe(viewModel?.viewText);
|
||||||
|
@ -191,7 +191,7 @@ const Markdown = ({
|
|||||||
scrollable = true,
|
scrollable = true,
|
||||||
onClickExecute,
|
onClickExecute,
|
||||||
}: MarkdownProps) => {
|
}: MarkdownProps) => {
|
||||||
const textAtomValue = useAtomValueSafe(textAtom);
|
const textAtomValue = useAtomValueSafe<string>(textAtom);
|
||||||
const tocRef = useRef<TocItem[]>([]);
|
const tocRef = useRef<TocItem[]>([]);
|
||||||
const showToc = useAtomValueSafe(showTocAtom) ?? false;
|
const showToc = useAtomValueSafe(showTocAtom) ?? false;
|
||||||
const contentsOsRef = useRef<OverlayScrollbarsComponentRef>(null);
|
const contentsOsRef = useRef<OverlayScrollbarsComponentRef>(null);
|
||||||
|
@ -230,7 +230,7 @@ function useBlockCache<T>(blockId: string, name: string, makeFn: () => T): T {
|
|||||||
|
|
||||||
const settingsAtomCache = new Map<string, Atom<any>>();
|
const settingsAtomCache = new Map<string, Atom<any>>();
|
||||||
|
|
||||||
function useSettingsKeyAtom<T extends keyof SettingsType>(key: T): Atom<SettingsType[T]> {
|
function getSettingsKeyAtom<T extends keyof SettingsType>(key: T): Atom<SettingsType[T]> {
|
||||||
let settingsKeyAtom = settingsAtomCache.get(key) as Atom<SettingsType[T]>;
|
let settingsKeyAtom = settingsAtomCache.get(key) as Atom<SettingsType[T]>;
|
||||||
if (settingsKeyAtom == null) {
|
if (settingsKeyAtom == null) {
|
||||||
settingsKeyAtom = atom((get) => {
|
settingsKeyAtom = atom((get) => {
|
||||||
@ -534,6 +534,7 @@ export {
|
|||||||
getConnStatusAtom,
|
getConnStatusAtom,
|
||||||
getHostName,
|
getHostName,
|
||||||
getObjectId,
|
getObjectId,
|
||||||
|
getSettingsKeyAtom,
|
||||||
getUserName,
|
getUserName,
|
||||||
globalStore,
|
globalStore,
|
||||||
initGlobal,
|
initGlobal,
|
||||||
@ -553,7 +554,6 @@ export {
|
|||||||
useBlockAtom,
|
useBlockAtom,
|
||||||
useBlockCache,
|
useBlockCache,
|
||||||
useBlockDataLoaded,
|
useBlockDataLoaded,
|
||||||
useSettingsKeyAtom,
|
|
||||||
useSettingsPrefixAtom,
|
useSettingsPrefixAtom,
|
||||||
WOS,
|
WOS,
|
||||||
};
|
};
|
||||||
|
@ -8,7 +8,7 @@ import { RpcApi } from "@/app/store/wshclientapi";
|
|||||||
import { WindowRpcClient } from "@/app/store/wshrpcutil";
|
import { WindowRpcClient } from "@/app/store/wshrpcutil";
|
||||||
import { Markdown } from "@/element/markdown";
|
import { Markdown } from "@/element/markdown";
|
||||||
import { NodeModel } from "@/layout/index";
|
import { NodeModel } from "@/layout/index";
|
||||||
import { atoms, createBlock, getConnStatusAtom, globalStore, refocusNode } from "@/store/global";
|
import { atoms, createBlock, getConnStatusAtom, getSettingsKeyAtom, globalStore, refocusNode } from "@/store/global";
|
||||||
import * as services from "@/store/services";
|
import * as services from "@/store/services";
|
||||||
import * as WOS from "@/store/wos";
|
import * as WOS from "@/store/wos";
|
||||||
import { getWebServerEndpoint } from "@/util/endpoints";
|
import { getWebServerEndpoint } from "@/util/endpoints";
|
||||||
@ -153,7 +153,8 @@ export class PreviewModel implements ViewModel {
|
|||||||
this.viewType = "preview";
|
this.viewType = "preview";
|
||||||
this.blockId = blockId;
|
this.blockId = blockId;
|
||||||
this.nodeModel = nodeModel;
|
this.nodeModel = nodeModel;
|
||||||
this.showHiddenFiles = jotai.atom(true);
|
let showHiddenFiles = globalStore.get(getSettingsKeyAtom("preview:showhiddenfiles")) ?? true;
|
||||||
|
this.showHiddenFiles = jotai.atom<boolean>(showHiddenFiles);
|
||||||
this.refreshVersion = jotai.atom(0);
|
this.refreshVersion = jotai.atom(0);
|
||||||
this.previewTextRef = createRef();
|
this.previewTextRef = createRef();
|
||||||
this.openFileModal = jotai.atom(false);
|
this.openFileModal = jotai.atom(false);
|
||||||
|
@ -6,7 +6,7 @@ import { waveEventSubscribe } from "@/app/store/wps";
|
|||||||
import { RpcApi } from "@/app/store/wshclientapi";
|
import { RpcApi } from "@/app/store/wshclientapi";
|
||||||
import { WindowRpcClient } from "@/app/store/wshrpcutil";
|
import { WindowRpcClient } from "@/app/store/wshrpcutil";
|
||||||
import { VDomView } from "@/app/view/term/vdom";
|
import { VDomView } from "@/app/view/term/vdom";
|
||||||
import { WOS, atoms, getConnStatusAtom, globalStore, useSettingsPrefixAtom } from "@/store/global";
|
import { WOS, atoms, getConnStatusAtom, getSettingsKeyAtom, globalStore, useSettingsPrefixAtom } from "@/store/global";
|
||||||
import * as services from "@/store/services";
|
import * as services from "@/store/services";
|
||||||
import * as keyutil from "@/util/keyutil";
|
import * as keyutil from "@/util/keyutil";
|
||||||
import * as util from "@/util/util";
|
import * as util from "@/util/util";
|
||||||
@ -134,7 +134,11 @@ class TermViewModel {
|
|||||||
this.blockBg = jotai.atom((get) => {
|
this.blockBg = jotai.atom((get) => {
|
||||||
const blockData = get(this.blockAtom);
|
const blockData = get(this.blockAtom);
|
||||||
const fullConfig = get(atoms.fullConfigAtom);
|
const fullConfig = get(atoms.fullConfigAtom);
|
||||||
const theme = computeTheme(fullConfig, blockData?.meta?.["term:theme"]);
|
let themeName: string = globalStore.get(getSettingsKeyAtom("term:theme"));
|
||||||
|
if (blockData?.meta?.["term:theme"]) {
|
||||||
|
themeName = blockData.meta["term:theme"];
|
||||||
|
}
|
||||||
|
const theme = computeTheme(fullConfig, themeName);
|
||||||
if (theme != null && theme.background != null) {
|
if (theme != null && theme.background != null) {
|
||||||
return { bg: theme.background };
|
return { bg: theme.background };
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright 2024, Command Line Inc.
|
// Copyright 2024, Command Line Inc.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import { getApi, openLink, useSettingsKeyAtom } from "@/app/store/global";
|
import { getApi, getSettingsKeyAtom, openLink } from "@/app/store/global";
|
||||||
import { getSimpleControlShiftAtom } from "@/app/store/keymodel";
|
import { getSimpleControlShiftAtom } from "@/app/store/keymodel";
|
||||||
import { RpcApi } from "@/app/store/wshclientapi";
|
import { RpcApi } from "@/app/store/wshclientapi";
|
||||||
import { WindowRpcClient } from "@/app/store/wshrpcutil";
|
import { WindowRpcClient } from "@/app/store/wshrpcutil";
|
||||||
@ -63,7 +63,7 @@ export class WebViewModel implements ViewModel {
|
|||||||
this.webviewRef = React.createRef<WebviewTag>();
|
this.webviewRef = React.createRef<WebviewTag>();
|
||||||
|
|
||||||
this.viewText = jotai.atom((get) => {
|
this.viewText = jotai.atom((get) => {
|
||||||
const defaultUrlAtom = useSettingsKeyAtom("web:defaulturl");
|
const defaultUrlAtom = getSettingsKeyAtom("web:defaulturl");
|
||||||
let url = get(this.blockAtom)?.meta?.url || get(defaultUrlAtom);
|
let url = get(this.blockAtom)?.meta?.url || get(defaultUrlAtom);
|
||||||
const currUrl = get(this.url);
|
const currUrl = get(this.url);
|
||||||
if (currUrl !== undefined) {
|
if (currUrl !== undefined) {
|
||||||
@ -270,7 +270,7 @@ export class WebViewModel implements ViewModel {
|
|||||||
* @param newUrl The new URL to load in the webview.
|
* @param newUrl The new URL to load in the webview.
|
||||||
*/
|
*/
|
||||||
loadUrl(newUrl: string, reason: string) {
|
loadUrl(newUrl: string, reason: string) {
|
||||||
const defaultSearchAtom = useSettingsKeyAtom("web:defaultsearch");
|
const defaultSearchAtom = getSettingsKeyAtom("web:defaultsearch");
|
||||||
const searchTemplate = globalStore.get(defaultSearchAtom);
|
const searchTemplate = globalStore.get(defaultSearchAtom);
|
||||||
const nextUrl = this.ensureUrlScheme(newUrl, searchTemplate);
|
const nextUrl = this.ensureUrlScheme(newUrl, searchTemplate);
|
||||||
console.log("webview loadUrl", reason, nextUrl, "cur=", this.webviewRef?.current.getURL());
|
console.log("webview loadUrl", reason, nextUrl, "cur=", this.webviewRef?.current.getURL());
|
||||||
@ -384,9 +384,9 @@ interface WebViewProps {
|
|||||||
|
|
||||||
const WebView = memo(({ model }: WebViewProps) => {
|
const WebView = memo(({ model }: WebViewProps) => {
|
||||||
const blockData = jotai.useAtomValue(model.blockAtom);
|
const blockData = jotai.useAtomValue(model.blockAtom);
|
||||||
const defaultUrlAtom = useSettingsKeyAtom("web:defaulturl");
|
const defaultUrlAtom = getSettingsKeyAtom("web:defaulturl");
|
||||||
const defaultUrl = jotai.useAtomValue(defaultUrlAtom);
|
const defaultUrl = jotai.useAtomValue(defaultUrlAtom);
|
||||||
const defaultSearchAtom = useSettingsKeyAtom("web:defaultsearch");
|
const defaultSearchAtom = getSettingsKeyAtom("web:defaultsearch");
|
||||||
const defaultSearch = jotai.useAtomValue(defaultSearchAtom);
|
const defaultSearch = jotai.useAtomValue(defaultSearchAtom);
|
||||||
let metaUrl = blockData?.meta?.url || defaultUrl;
|
let metaUrl = blockData?.meta?.url || defaultUrl;
|
||||||
metaUrl = model.ensureUrlScheme(metaUrl, defaultSearch);
|
metaUrl = model.ensureUrlScheme(metaUrl, defaultSearch);
|
||||||
|
2
frontend/types/gotypes.d.ts
vendored
2
frontend/types/gotypes.d.ts
vendored
@ -421,6 +421,7 @@ declare global {
|
|||||||
"term:*"?: boolean;
|
"term:*"?: boolean;
|
||||||
"term:fontsize"?: number;
|
"term:fontsize"?: number;
|
||||||
"term:fontfamily"?: string;
|
"term:fontfamily"?: string;
|
||||||
|
"term:theme"?: string;
|
||||||
"term:disablewebgl"?: boolean;
|
"term:disablewebgl"?: boolean;
|
||||||
"term:localshellpath"?: string;
|
"term:localshellpath"?: string;
|
||||||
"term:localshellopts"?: string[];
|
"term:localshellopts"?: string[];
|
||||||
@ -438,6 +439,7 @@ declare global {
|
|||||||
"autoupdate:intervalms"?: number;
|
"autoupdate:intervalms"?: number;
|
||||||
"autoupdate:installonquit"?: boolean;
|
"autoupdate:installonquit"?: boolean;
|
||||||
"autoupdate:channel"?: string;
|
"autoupdate:channel"?: string;
|
||||||
|
"preview:showhiddenfiles"?: boolean;
|
||||||
"widget:*"?: boolean;
|
"widget:*"?: boolean;
|
||||||
"widget:showhelp"?: boolean;
|
"widget:showhelp"?: boolean;
|
||||||
"window:*"?: boolean;
|
"window:*"?: boolean;
|
||||||
|
@ -17,6 +17,7 @@ const (
|
|||||||
ConfigKey_TermClear = "term:*"
|
ConfigKey_TermClear = "term:*"
|
||||||
ConfigKey_TermFontSize = "term:fontsize"
|
ConfigKey_TermFontSize = "term:fontsize"
|
||||||
ConfigKey_TermFontFamily = "term:fontfamily"
|
ConfigKey_TermFontFamily = "term:fontfamily"
|
||||||
|
ConfigKey_TermTheme = "term:theme"
|
||||||
ConfigKey_TermDisableWebGl = "term:disablewebgl"
|
ConfigKey_TermDisableWebGl = "term:disablewebgl"
|
||||||
ConfigKey_TermLocalShellPath = "term:localshellpath"
|
ConfigKey_TermLocalShellPath = "term:localshellpath"
|
||||||
ConfigKey_TermLocalShellOpts = "term:localshellopts"
|
ConfigKey_TermLocalShellOpts = "term:localshellopts"
|
||||||
@ -39,6 +40,8 @@ const (
|
|||||||
ConfigKey_AutoUpdateInstallOnQuit = "autoupdate:installonquit"
|
ConfigKey_AutoUpdateInstallOnQuit = "autoupdate:installonquit"
|
||||||
ConfigKey_AutoUpdateChannel = "autoupdate:channel"
|
ConfigKey_AutoUpdateChannel = "autoupdate:channel"
|
||||||
|
|
||||||
|
ConfigKey_PreviewShowHiddenFiles = "preview:showhiddenfiles"
|
||||||
|
|
||||||
ConfigKey_WidgetClear = "widget:*"
|
ConfigKey_WidgetClear = "widget:*"
|
||||||
ConfigKey_WidgetShowHelp = "widget:showhelp"
|
ConfigKey_WidgetShowHelp = "widget:showhelp"
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ type SettingsType struct {
|
|||||||
TermClear bool `json:"term:*,omitempty"`
|
TermClear bool `json:"term:*,omitempty"`
|
||||||
TermFontSize float64 `json:"term:fontsize,omitempty"`
|
TermFontSize float64 `json:"term:fontsize,omitempty"`
|
||||||
TermFontFamily string `json:"term:fontfamily,omitempty"`
|
TermFontFamily string `json:"term:fontfamily,omitempty"`
|
||||||
|
TermTheme string `json:"term:theme,omitempty"`
|
||||||
TermDisableWebGl bool `json:"term:disablewebgl,omitempty"`
|
TermDisableWebGl bool `json:"term:disablewebgl,omitempty"`
|
||||||
TermLocalShellPath string `json:"term:localshellpath,omitempty"`
|
TermLocalShellPath string `json:"term:localshellpath,omitempty"`
|
||||||
TermLocalShellOpts []string `json:"term:localshellopts,omitempty"`
|
TermLocalShellOpts []string `json:"term:localshellopts,omitempty"`
|
||||||
@ -73,6 +74,8 @@ type SettingsType struct {
|
|||||||
AutoUpdateInstallOnQuit bool `json:"autoupdate:installonquit,omitempty"`
|
AutoUpdateInstallOnQuit bool `json:"autoupdate:installonquit,omitempty"`
|
||||||
AutoUpdateChannel string `json:"autoupdate:channel,omitempty"`
|
AutoUpdateChannel string `json:"autoupdate:channel,omitempty"`
|
||||||
|
|
||||||
|
PreviewShowHiddenFiles *bool `json:"preview:showhiddenfiles,omitempty"`
|
||||||
|
|
||||||
WidgetClear bool `json:"widget:*,omitempty"`
|
WidgetClear bool `json:"widget:*,omitempty"`
|
||||||
WidgetShowHelp bool `json:"widget:showhelp,omitempty"`
|
WidgetShowHelp bool `json:"widget:showhelp,omitempty"`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user