mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-03-03 12:31:04 -08:00
feat: add show/hide sidebar to context menu
This commit is contained in:
parent
ccc5f6021f
commit
5a2a0f1069
6 changed files with 18 additions and 5 deletions
|
|
@ -285,6 +285,7 @@
|
|||
"History": "History",
|
||||
"Language": "Language",
|
||||
"Window": "Window",
|
||||
"Workspaces": "Workspaces"
|
||||
"Workspaces": "Workspaces",
|
||||
"Back": "Back"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@
|
|||
"DarkTheme": "黑暗主题",
|
||||
"LightTheme": "亮色主题",
|
||||
"ShowSideBar": "显示侧边栏",
|
||||
"HideSideBar": "隐藏侧边栏",
|
||||
"SystemDefalutTheme": "系统默认主题色",
|
||||
"Theme": "主题色",
|
||||
"Reset": "你确定吗?所有首选项都将恢复为其原始默认值。浏览数据不会受到影响。此操作无法撤消。",
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export function SortableWorkspaceSelector({ index, workspace, showSidebarShortcu
|
|||
});
|
||||
}
|
||||
|
||||
void window.remote.popContextMenu(template, { x: event.clientX, y: event.clientY, editFlags: { canCopy: false } });
|
||||
void window.remote.buildContextMenuAndPopup(template, { x: event.clientX, y: event.clientY, editFlags: { canCopy: false } });
|
||||
}}>
|
||||
<WorkspaceSelector
|
||||
active={active}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import * as service from './services';
|
|||
import { windowName } from './browserViewMetaData';
|
||||
|
||||
export const remoteMethods = {
|
||||
popContextMenu: async (menus: MenuItemConstructorOptions[], parameters: IOnContextMenuInfo): Promise<() => void> => {
|
||||
buildContextMenuAndPopup: async (menus: MenuItemConstructorOptions[], parameters: IOnContextMenuInfo): Promise<() => void> => {
|
||||
const [ipcSafeMenus, unregister] = rendererMenuItemProxy(menus);
|
||||
await service.menu.buildContextMenuAndPopup(ipcSafeMenus, parameters, windowName);
|
||||
return unregister;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { lazyInject } from '@services/container';
|
|||
import serviceIdentifier from '@services/serviceIdentifier';
|
||||
import { IWindowService } from '@services/windows/interface';
|
||||
import { IViewService } from '@services/view/interface';
|
||||
import { IPreferenceService } from '@services/preferences/interface';
|
||||
import i18next from '@services/libs/i18n';
|
||||
import ContextMenuBuilder from './contextMenuBuilder';
|
||||
import { IpcSafeMenuItem, mainMenuItemProxy } from './rendererMenuItemProxy';
|
||||
|
|
@ -18,6 +19,7 @@ import { InsertMenuAfterSubMenuIndexError } from './error';
|
|||
export class MenuService implements IMenuService {
|
||||
@lazyInject(serviceIdentifier.Window) private readonly windowService!: IWindowService;
|
||||
@lazyInject(serviceIdentifier.View) private readonly viewService!: IViewService;
|
||||
@lazyInject(serviceIdentifier.Preference) private readonly preferenceService!: IPreferenceService;
|
||||
|
||||
private _menuTemplate?: DeferredMenuItemConstructorOptions[];
|
||||
private get menuTemplate(): DeferredMenuItemConstructorOptions[] {
|
||||
|
|
@ -303,6 +305,14 @@ export class MenuService implements IMenuService {
|
|||
},
|
||||
}),
|
||||
);
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: (await this.preferenceService.get('sidebar')) ? i18next.t('Preference.HideSideBar') : i18next.t('Preference.ShowSideBar'),
|
||||
click: async () => {
|
||||
await this.preferenceService.set('sidebar', !(await this.preferenceService.get('sidebar')));
|
||||
},
|
||||
}),
|
||||
);
|
||||
menu.append(new MenuItem({ type: 'separator' }));
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ import type { IWindowService } from '@services/windows/interface';
|
|||
import type { IMenuService } from '@services/menu/interface';
|
||||
import { WindowNames } from '@services/windows/WindowProperties';
|
||||
import { IAuthenticationService } from '@services/auth/interface';
|
||||
import { IWikiGitWorkspaceService } from '@services/wikiGitWorkspace/interface';
|
||||
import { SupportedStorageServices } from '@services/types';
|
||||
import { lazyInject } from '@services/container';
|
||||
import { IWorkspaceService, IWorkspace, IWorkspaceMetaData, INewWorkspaceConfig } from './interface';
|
||||
import i18n from '@services/libs/i18n';
|
||||
import { workspace } from '@/preload/common/services';
|
||||
|
||||
@injectable()
|
||||
export class Workspace implements IWorkspaceService {
|
||||
|
|
@ -37,6 +37,7 @@ export class Workspace implements IWorkspaceService {
|
|||
@lazyInject(serviceIdentifier.Window) private readonly windowService!: IWindowService;
|
||||
@lazyInject(serviceIdentifier.View) private readonly viewService!: IViewService;
|
||||
@lazyInject(serviceIdentifier.WorkspaceView) private readonly workspaceViewService!: IWorkspaceViewService;
|
||||
@lazyInject(serviceIdentifier.WikiGitWorkspace) private readonly wikiGitWorkspaceService!: IWikiGitWorkspaceService;
|
||||
@lazyInject(serviceIdentifier.MenuService) private readonly menuService!: IMenuService;
|
||||
@lazyInject(serviceIdentifier.Authentication) private readonly authenticationService!: IAuthenticationService;
|
||||
|
||||
|
|
@ -91,7 +92,7 @@ export class Workspace implements IWorkspaceService {
|
|||
click: async () => {
|
||||
const currentActiveWorkspace = await this.getActiveWorkspace();
|
||||
if (currentActiveWorkspace === undefined) return;
|
||||
await this.workspaceViewService.removeWorkspaceView(currentActiveWorkspace.id);
|
||||
await this.wikiGitWorkspaceService.removeWorkspace(currentActiveWorkspace.id);
|
||||
},
|
||||
enabled: async () => (await this.countWorkspaces()) > 0,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue