mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-05 18:20:39 -08:00
parent
95bc83022f
commit
15daa6cb51
4 changed files with 25 additions and 8 deletions
|
|
@ -107,6 +107,8 @@ TBD
|
|||
|
||||
### `Uncaught ReferenceError: require is not defined`
|
||||
|
||||
Or `Uncaught TypeError: Cannot read properties of undefined (reading 'call') at __webpack_require__ (index.js:4317:33)`
|
||||
|
||||
`pnpm run clean:cache` can fix this.
|
||||
|
||||
### Electron download slow
|
||||
|
|
|
|||
|
|
@ -18,18 +18,23 @@ export class DeepLinkService implements IDeepLinkService {
|
|||
*/
|
||||
private readonly deepLinkHandler: (requestUrl: string) => Promise<void> = async (requestUrl) => {
|
||||
logger.info(`Receiving deep link`, { requestUrl, function: 'deepLinkHandler' });
|
||||
const url = new URL(requestUrl);
|
||||
const workspaceId = url.hostname;
|
||||
const workspace = await this.workspaceService.get(workspaceId);
|
||||
// hostname is workspace id or name
|
||||
const { hostname, hash } = new URL(requestUrl);
|
||||
let workspace = await this.workspaceService.get(hostname);
|
||||
if (workspace === undefined) {
|
||||
logger.error(`Workspace not found`, { workspaceId, function: 'deepLinkHandler' });
|
||||
return;
|
||||
logger.error(`Workspace not found, try get by name`, { hostname, function: 'deepLinkHandler' });
|
||||
workspace = await this.workspaceService.getByWikiName(hostname);
|
||||
if (workspace === undefined) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let tiddlerName = url.hash.substring(1); // remove '#:'
|
||||
let tiddlerName = hash.substring(1); // remove '#:'
|
||||
if (tiddlerName.includes(':')) {
|
||||
tiddlerName = tiddlerName.split(':')[1];
|
||||
}
|
||||
logger.info(`Open deep link`, { workspaceId, tiddlerName, function: 'deepLinkHandler' });
|
||||
// Support CJK
|
||||
tiddlerName = decodeURIComponent(tiddlerName);
|
||||
logger.info(`Open deep link`, { workspaceId: workspace.id, tiddlerName, function: 'deepLinkHandler' });
|
||||
await this.workspaceService.openWorkspaceTiddler(workspace, tiddlerName);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -289,6 +289,12 @@ export class Workspace implements IWorkspaceService {
|
|||
return (await this.getWorkspacesAsList()).find((workspace) => workspace.wikiFolderLocation === wikiFolderLocation);
|
||||
}
|
||||
|
||||
public async getByWikiName(wikiName: string): Promise<IWorkspace | undefined> {
|
||||
return (await this.getWorkspacesAsList())
|
||||
.sort((a, b) => a.order - b.order)
|
||||
.find((workspace) => workspace.name === wikiName);
|
||||
}
|
||||
|
||||
public getPreviousWorkspace = async (id: string): Promise<IWorkspace | undefined> => {
|
||||
const workspaceList = await this.getWorkspacesAsList();
|
||||
let currentWorkspaceIndex = 0;
|
||||
|
|
|
|||
|
|
@ -186,6 +186,10 @@ export interface IWorkspaceService {
|
|||
getActiveWorkspaceSync: () => IWorkspace | undefined;
|
||||
getAllMetaData: () => Promise<Record<string, Partial<IWorkspaceMetaData>>>;
|
||||
getByWikiFolderLocation(wikiFolderLocation: string): Promise<IWorkspace | undefined>;
|
||||
/**
|
||||
* Get workspace by human readable wiki name, if no workspace found, return undefined. If multiple workspace with same name, return the first one order by sidebar.
|
||||
*/
|
||||
getByWikiName(wikiName: string): Promise<IWorkspace | undefined>;
|
||||
getFirstWorkspace: () => Promise<IWorkspace | undefined>;
|
||||
/**
|
||||
* Get parent workspace of a subWorkspace, if the workspace you provided is a main workspace, return undefined.
|
||||
|
|
@ -236,7 +240,7 @@ export const WorkspaceServiceIPCDescriptor = {
|
|||
get$: ProxyPropertyType.Function$,
|
||||
getActiveWorkspace: ProxyPropertyType.Function,
|
||||
getAllMetaData: ProxyPropertyType.Function,
|
||||
getByName: ProxyPropertyType.Function,
|
||||
getByWikiName: ProxyPropertyType.Function,
|
||||
getFirstWorkspace: ProxyPropertyType.Function,
|
||||
getMainWorkspace: ProxyPropertyType.Function,
|
||||
getMetaData: ProxyPropertyType.Function,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue