mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-30 04:11:33 -08:00
feat: some url related
This commit is contained in:
parent
f7877b46dc
commit
600501edd9
8 changed files with 39 additions and 7 deletions
|
|
@ -51,10 +51,7 @@ module.exports = {
|
|||
'@typescript-eslint/no-misused-promises': [
|
||||
'error',
|
||||
{
|
||||
checksVoidReturn: {
|
||||
arguments: false,
|
||||
attributes: false,
|
||||
},
|
||||
checksVoidReturn: false,
|
||||
},
|
||||
],
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
|
|
|
|||
|
|
@ -4,3 +4,7 @@
|
|||
export const defaultServerIP = '0.0.0.0';
|
||||
export const latestStableUpdateUrl = 'https://github.com/tiddly-gittly/TidGi-Desktop/releases/latest';
|
||||
export const githubDesktopUrl = 'https://desktop.github.com/';
|
||||
/** https://tiddlywiki.com/#SafeMode
|
||||
* This is currently unused, because it always entering /#safe:safe , very annoying. And even entered, the url can still not containing this. So I decided not support enter/quit safe mode now.
|
||||
*/
|
||||
export const safeModeHash = '#:safe';
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import { IZxFileInput } from '@services/wiki/wikiWorker';
|
|||
import { ZxNotInitializedError } from './error';
|
||||
import { lazyInject } from '@services/container';
|
||||
import i18next from 'i18next';
|
||||
import { getLocalHostUrlWithActualIP } from '@services/libs/url';
|
||||
|
||||
@injectable()
|
||||
export class NativeService implements INativeService {
|
||||
|
|
@ -154,4 +155,8 @@ ${message.message}
|
|||
public async openNewGitHubIssue(error: Error): Promise<void> {
|
||||
reportErrorToGithubWithTemplates(error);
|
||||
}
|
||||
|
||||
public async getLocalHostUrlWithActualIP(url: string): Promise<string> {
|
||||
return await getLocalHostUrlWithActualIP(url);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export interface INativeService {
|
|||
* @param wikiFolderLocation Each wiki has its own worker, we use wiki's folder path to determine which worker to use. If not provided, will use current active workspace's wiki's path
|
||||
*/
|
||||
executeZxScript$(zxWorkerArguments: IZxFileInput, wikiFolderLocation?: string): Observable<string>;
|
||||
getLocalHostUrlWithActualIP(url: string): Promise<string>;
|
||||
log(level: string, message: string, meta?: Record<string, unknown>): Promise<void>;
|
||||
open(uri: string, isDirectory?: boolean): Promise<void>;
|
||||
openInEditor(filePath: string, editorName?: string | undefined): Promise<boolean>;
|
||||
|
|
@ -30,6 +31,7 @@ export const NativeServiceIPCDescriptor = {
|
|||
channel: NativeChannel.name,
|
||||
properties: {
|
||||
executeZxScript$: ProxyPropertyType.Function$,
|
||||
getLocalHostUrlWithActualIP: ProxyPropertyType.Function,
|
||||
log: ProxyPropertyType.Function,
|
||||
open: ProxyPropertyType.Function,
|
||||
openInEditor: ProxyPropertyType.Function,
|
||||
|
|
|
|||
|
|
@ -472,6 +472,18 @@ export class View implements IViewService {
|
|||
});
|
||||
}
|
||||
|
||||
public async getViewCurrentUrl(workspaceID?: string): Promise<string | undefined> {
|
||||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
||||
if (!workspaceID) {
|
||||
return;
|
||||
}
|
||||
const view = this.getView(workspaceID, WindowNames.main);
|
||||
if (view === undefined) {
|
||||
return;
|
||||
}
|
||||
return view.webContents.getURL();
|
||||
}
|
||||
|
||||
public async getActiveBrowserView(): Promise<BrowserView | undefined> {
|
||||
const workspace = await this.workspaceService.getActiveWorkspace();
|
||||
const isMenubarOpen = await this.windowService.isMenubarOpen();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export interface IViewService {
|
|||
getAllViewOfWorkspace: (workspaceID: string) => BrowserView[];
|
||||
getView: (workspaceID: string, windowName: WindowNames) => BrowserView | undefined;
|
||||
getViewCount(): Promise<number>;
|
||||
getViewCurrentUrl(workspaceID?: string): Promise<string | undefined>;
|
||||
realignActiveView: (browserWindow: BrowserWindow, activeId: string) => Promise<void>;
|
||||
reloadActiveBrowserView: () => Promise<void>;
|
||||
reloadViewsWebContents(workspaceID?: string | undefined): Promise<void>;
|
||||
|
|
@ -49,6 +50,7 @@ export const ViewServiceIPCDescriptor = {
|
|||
getAllViewOfWorkspace: ProxyPropertyType.Function,
|
||||
getView: ProxyPropertyType.Function,
|
||||
getViewCount: ProxyPropertyType.Function,
|
||||
getViewCurrentUrl: ProxyPropertyType.Function,
|
||||
realignActiveView: ProxyPropertyType.Function,
|
||||
reloadActiveBrowserView: ProxyPropertyType.Function,
|
||||
reloadViewsWebContents: ProxyPropertyType.Function,
|
||||
|
|
|
|||
|
|
@ -17,15 +17,20 @@ interface IWorkspaceMenuRequiredServices {
|
|||
auth: Pick<IAuthenticationService, 'getStorageServiceUserInfo'>;
|
||||
context: Pick<IContextService, 'isOnline'>;
|
||||
git: Pick<IGitService, 'commitAndSync'>;
|
||||
native: Pick<INativeService, 'open' | 'openInEditor' | 'openInGitGuiApp'>;
|
||||
view: Pick<IViewService, 'reloadViewsWebContents' | 'enterSafeModeForViewsWebContents'>;
|
||||
native: Pick<INativeService, 'open' | 'openInEditor' | 'openInGitGuiApp' | 'getLocalHostUrlWithActualIP'>;
|
||||
view: Pick<IViewService, 'reloadViewsWebContents' | 'getViewCurrentUrl'>;
|
||||
wiki: Pick<IWikiService, 'requestOpenTiddlerInWiki' | 'requestWikiSendActionMessage'>;
|
||||
wikiGitWorkspace: Pick<IWikiGitWorkspaceService, 'removeWorkspace'>;
|
||||
window: Pick<IWindowService, 'open'>;
|
||||
workspace: Pick<IWorkspaceService, 'getActiveWorkspace'>;
|
||||
workspaceView: Pick<
|
||||
IWorkspaceViewService,
|
||||
'wakeUpWorkspaceView' | 'hibernateWorkspaceView' | 'setActiveWorkspaceView' | 'restartWorkspaceViewService' | 'realignActiveWorkspace'
|
||||
| 'wakeUpWorkspaceView'
|
||||
| 'hibernateWorkspaceView'
|
||||
| 'setActiveWorkspaceView'
|
||||
| 'restartWorkspaceViewService'
|
||||
| 'realignActiveWorkspace'
|
||||
| 'openUrlInWorkspace'
|
||||
>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ export interface IWorkspaceViewService {
|
|||
* @param id workspace id, if omit, will load url in active workspace if existed
|
||||
*/
|
||||
loadURL(url: string, workspaceID?: string): Promise<void>;
|
||||
/**
|
||||
* Open url, and if id is valid, we will switch to that workspace first
|
||||
* @param url
|
||||
* @param workspaceID
|
||||
*/
|
||||
openUrlInWorkspace(url: string, workspaceID: string): Promise<void>;
|
||||
printTiddler(tiddlerName?: string | undefined): Promise<void>;
|
||||
realignActiveWorkspace(id?: string): Promise<void>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue