mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-24 22:09:08 +08:00
feat(core): open app in electron app entry (#8637)
fix PD-208 fix PD-210 fix PD-209 fix AF-1495
This commit is contained in:
@@ -273,15 +273,3 @@ export async function openUrlInHiddenWindow(urlObj: URL) {
|
||||
});
|
||||
return win;
|
||||
}
|
||||
|
||||
// TODO(@pengx17): somehow the page won't load the url passed, help needed
|
||||
export async function openUrlInMainWindow(urlObj: URL) {
|
||||
const url = transformToAppUrl(urlObj);
|
||||
logger.info('loading page at', url);
|
||||
const mainWindow = await getMainWindow();
|
||||
if (mainWindow) {
|
||||
await mainWindow.loadURL(url);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -932,7 +932,35 @@ export const isActiveTab = (wc: WebContents) => {
|
||||
WebContentViewsManager.instance.activeWorkbenchView?.webContents.id
|
||||
);
|
||||
};
|
||||
|
||||
// parse the full pathname to basename and pathname
|
||||
// eg: /workspace/xxx/yyy => { basename: '/workspace/xxx', pathname: '/yyy' }
|
||||
export const parseFullPathname = (url: string) => {
|
||||
const urlObj = new URL(url);
|
||||
const basename = urlObj.pathname.match(/\/workspace\/[^/]+/g)?.[0] ?? '/';
|
||||
return {
|
||||
basename,
|
||||
pathname: urlObj.pathname.slice(basename.length),
|
||||
search: urlObj.search,
|
||||
hash: urlObj.hash,
|
||||
};
|
||||
};
|
||||
|
||||
export const addTab = WebContentViewsManager.instance.addTab;
|
||||
export const addTabWithUrl = (url: string) => {
|
||||
const { basename, pathname, search, hash } = parseFullPathname(url);
|
||||
return addTab({
|
||||
basename,
|
||||
view: {
|
||||
path: { pathname, search, hash },
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const loadUrlInActiveTab = async (_url: string) => {
|
||||
// todo: implement
|
||||
throw new Error('loadUrlInActiveTab not implemented');
|
||||
};
|
||||
export const showTab = WebContentViewsManager.instance.showTab;
|
||||
export const closeTab = WebContentViewsManager.instance.closeTab;
|
||||
export const undoCloseTab = WebContentViewsManager.instance.undoCloseTab;
|
||||
|
||||
Reference in New Issue
Block a user