mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-02-25 17:41:01 -08:00
refactor: rename nativeService.open -> openURI
This commit is contained in:
parent
cbfc068ff4
commit
5446c0f305
16 changed files with 38 additions and 38 deletions
|
|
@ -134,7 +134,7 @@ export function SideBar(): JSX.Element {
|
|||
id='update-available'
|
||||
aria-label={t('SideBar.UpdateAvailable')}
|
||||
onClick={async () => {
|
||||
await window.service.native.open(updaterMetaData.info?.latestReleasePageUrl ?? latestStableUpdateUrl);
|
||||
await window.service.native.openURI(updaterMetaData.info?.latestReleasePageUrl ?? latestStableUpdateUrl);
|
||||
}}
|
||||
>
|
||||
<Tooltip title={<span>{t('SideBar.UpdateAvailable')}</span>} placement='top'>
|
||||
|
|
|
|||
|
|
@ -99,14 +99,14 @@ export default function About(): JSX.Element {
|
|||
<ButtonContainer>
|
||||
<GoToTheWebsiteButton
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://github.com/tiddly-gittly/TidGi-Desktop');
|
||||
await window.service.native.openURI('https://github.com/tiddly-gittly/TidGi-Desktop');
|
||||
}}
|
||||
>
|
||||
Website
|
||||
</GoToTheWebsiteButton>
|
||||
<GoToTheWebsiteButton
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://github.com/tiddly-gittly/TidGi-Desktop/issues/new/choose');
|
||||
await window.service.native.openURI('https://github.com/tiddly-gittly/TidGi-Desktop/issues/new/choose');
|
||||
}}
|
||||
>
|
||||
Support
|
||||
|
|
@ -123,13 +123,13 @@ export default function About(): JSX.Element {
|
|||
</Trans>
|
||||
<Link
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://onetwo.ren/wiki/');
|
||||
await window.service.native.openURI('https://onetwo.ren/wiki/');
|
||||
}}
|
||||
onKeyDown={async (event: React.KeyboardEvent<HTMLSpanElement>) => {
|
||||
if (event.key !== 'Enter') {
|
||||
return;
|
||||
}
|
||||
await window.service.native.open('https://onetwo.ren/wiki/');
|
||||
await window.service.native.openURI('https://onetwo.ren/wiki/');
|
||||
}}
|
||||
role='link'
|
||||
tabIndex={0}
|
||||
|
|
@ -139,13 +139,13 @@ export default function About(): JSX.Element {
|
|||
<span>&&</span>
|
||||
<Link
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://webcatalog.app/?utm_source=tidgi_app');
|
||||
await window.service.native.openURI('https://webcatalog.app/?utm_source=tidgi_app');
|
||||
}}
|
||||
onKeyDown={async (event: React.KeyboardEvent<HTMLSpanElement>) => {
|
||||
if (event.key !== 'Enter') {
|
||||
return;
|
||||
}
|
||||
await window.service.native.open('https://webcatalog.app/?utm_source=tidgi_app');
|
||||
await window.service.native.openURI('https://webcatalog.app/?utm_source=tidgi_app');
|
||||
}}
|
||||
role='link'
|
||||
tabIndex={0}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ export function ServerOptions(props: IServerOptionsProps) {
|
|||
{t('EditWorkspace.URL')}{' '}
|
||||
<Link
|
||||
onClick={async () => {
|
||||
actualIP && (await window.service.native.open(actualIP));
|
||||
actualIP && (await window.service.native.openURI(actualIP));
|
||||
}}
|
||||
style={{ cursor: 'pointer' }}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ export const HelpWebsiteItem: React.FC<HelpWebsiteItemProps> = ({ item }) => {
|
|||
void window.service.window.open(WindowNames.any, { uri }, { multiple: true });
|
||||
};
|
||||
const openExternalLinkInBrowser = (uri: string) => {
|
||||
void window.service.native.open(uri);
|
||||
void window.service.native.openURI(uri);
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export function DeveloperTools(props: ISectionProps): JSX.Element {
|
|||
button
|
||||
onClick={() => {
|
||||
if (LOG_FOLDER !== undefined) {
|
||||
void window.service.native.open(LOG_FOLDER, true);
|
||||
void window.service.native.openPath(LOG_FOLDER, true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
|
@ -38,7 +38,7 @@ export function DeveloperTools(props: ISectionProps): JSX.Element {
|
|||
button
|
||||
onClick={() => {
|
||||
if (SETTINGS_FOLDER !== undefined) {
|
||||
void window.service.native.open(SETTINGS_FOLDER, true);
|
||||
void window.service.native.openPath(SETTINGS_FOLDER, true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
|
@ -50,7 +50,7 @@ export function DeveloperTools(props: ISectionProps): JSX.Element {
|
|||
onClick={async () => {
|
||||
if (V8_CACHE_FOLDER !== undefined) {
|
||||
try {
|
||||
await window.service.native.open(V8_CACHE_FOLDER, true);
|
||||
await window.service.native.openPath(V8_CACHE_FOLDER, true);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export function FriendLinks(props: ISectionProps): JSX.Element {
|
|||
<ListItem
|
||||
button
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://github.com/webcatalog/webcatalog-engine');
|
||||
await window.service.native.openURI('https://github.com/webcatalog/webcatalog-engine');
|
||||
}}
|
||||
>
|
||||
<ListItemText secondary={t('Preference.WebCatalogEngineIntro')} />
|
||||
|
|
@ -36,7 +36,7 @@ export function FriendLinks(props: ISectionProps): JSX.Element {
|
|||
<ListItem
|
||||
button
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://webcatalogapp.com?utm_source=tidgi_app');
|
||||
await window.service.native.openURI('https://webcatalogapp.com?utm_source=tidgi_app');
|
||||
}}
|
||||
>
|
||||
<ListItemText primary={<Logo src={webcatalogLogo} alt={t('Preference.WebCatalog')} />} secondary={t('Preference.WebCatalogIntro')} />
|
||||
|
|
@ -46,7 +46,7 @@ export function FriendLinks(props: ISectionProps): JSX.Element {
|
|||
<ListItem
|
||||
button
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://translatiumapp.com?utm_source=tidgi_app');
|
||||
await window.service.native.openURI('https://translatiumapp.com?utm_source=tidgi_app');
|
||||
}}
|
||||
>
|
||||
<ListItemText primary={<Logo src={translatiumLogo} alt={t('Preference.Translatium')} />} secondary={t('Preference.TranslatiumIntro')} />
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export function LanguageModel(props: Partial<ISectionProps>): JSX.Element {
|
|||
onClick={async () => {
|
||||
if (LANGUAGE_MODEL_FOLDER !== undefined) {
|
||||
await window.service.native.mkdir(LANGUAGE_MODEL_FOLDER);
|
||||
await window.service.native.open(LANGUAGE_MODEL_FOLDER, true);
|
||||
await window.service.native.openPath(LANGUAGE_MODEL_FOLDER, true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export function Miscellaneous(props: ISectionProps): JSX.Element {
|
|||
<ListItem
|
||||
button
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://github.com/tiddly-gittly/TidGi-desktop/');
|
||||
await window.service.native.openURI('https://github.com/tiddly-gittly/TidGi-desktop/');
|
||||
}}
|
||||
>
|
||||
<ListItemText primary={t('Preference.WebSite')} />
|
||||
|
|
@ -40,7 +40,7 @@ export function Miscellaneous(props: ISectionProps): JSX.Element {
|
|||
<ListItem
|
||||
button
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://github.com/tiddly-gittly/TidGi-desktop/issues');
|
||||
await window.service.native.openURI('https://github.com/tiddly-gittly/TidGi-desktop/issues');
|
||||
}}
|
||||
>
|
||||
<ListItemText primary={t('Preference.Support')} />
|
||||
|
|
|
|||
|
|
@ -153,11 +153,11 @@ export function Notifications(props: Required<ISectionProps>): JSX.Element {
|
|||
</span>
|
||||
<Link
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://github.com/atomery/webcatalog/wiki/How-to-Enable-Notifications-in-Web-Apps');
|
||||
await window.service.native.openURI('https://github.com/atomery/webcatalog/wiki/How-to-Enable-Notifications-in-Web-Apps');
|
||||
}}
|
||||
onKeyDown={(event: React.KeyboardEvent<HTMLSpanElement>) => {
|
||||
if (event.key !== 'Enter') return;
|
||||
void window.service.native.open('https://github.com/atomery/webcatalog/wiki/How-to-Enable-Notifications-in-Web-Apps');
|
||||
void window.service.native.openURI('https://github.com/atomery/webcatalog/wiki/How-to-Enable-Notifications-in-Web-Apps');
|
||||
}}
|
||||
>
|
||||
Learn more
|
||||
|
|
|
|||
|
|
@ -43,11 +43,11 @@ export function PrivacyAndSecurity(props: Required<ISectionProps>): JSX.Element
|
|||
<span>Not recommended.</span>
|
||||
<Link
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://groups.google.com/a/chromium.org/d/msg/security-dev/mB2KJv_mMzM/ddMteO9RjXEJ');
|
||||
await window.service.native.openURI('https://groups.google.com/a/chromium.org/d/msg/security-dev/mB2KJv_mMzM/ddMteO9RjXEJ');
|
||||
}}
|
||||
onKeyDown={(event: React.KeyboardEvent<HTMLSpanElement>) => {
|
||||
if (event.key !== 'Enter') return;
|
||||
void window.service.native.open('https://groups.google.com/a/chromium.org/d/msg/security-dev/mB2KJv_mMzM/ddMteO9RjXEJ');
|
||||
void window.service.native.openURI('https://groups.google.com/a/chromium.org/d/msg/security-dev/mB2KJv_mMzM/ddMteO9RjXEJ');
|
||||
}}
|
||||
>
|
||||
Learn more
|
||||
|
|
@ -82,7 +82,7 @@ export function PrivacyAndSecurity(props: Required<ISectionProps>): JSX.Element
|
|||
<ListItem
|
||||
button
|
||||
onClick={async () => {
|
||||
await window.service.native.open('https://github.com/tiddly-gittly/TidGi-Desktop/blob/master/PrivacyPolicy.md');
|
||||
await window.service.native.openURI('https://github.com/tiddly-gittly/TidGi-Desktop/blob/master/PrivacyPolicy.md');
|
||||
}}
|
||||
>
|
||||
<ListItemText primary='Privacy Policy' />
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export function Updates(props: Required<ISectionProps>): JSX.Element {
|
|||
button
|
||||
onClick={updaterMetaData.status === IUpdaterStatus.updateAvailable
|
||||
? async () => {
|
||||
await window.service.native.open(updaterMetaData.info?.latestReleasePageUrl ?? latestStableUpdateUrl);
|
||||
await window.service.native.openURI(updaterMetaData.info?.latestReleasePageUrl ?? latestStableUpdateUrl);
|
||||
}
|
||||
: async () => {
|
||||
await window.service.updater.checkForUpdates();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export function WikiErrorMessages(props: IWikiErrorMessagesProps): JSX.Element {
|
|||
<Button
|
||||
variant='outlined'
|
||||
onClick={async () => {
|
||||
await window.service.native.open(wikiLogs.filePath, true);
|
||||
await window.service.native.openPath(wikiLogs.filePath, true);
|
||||
}}
|
||||
>
|
||||
{t('Preference.OpenLogFolder')}
|
||||
|
|
@ -118,10 +118,10 @@ export function ViewLoadErrorMessages(props: IViewLoadErrorMessagesProps): JSX.E
|
|||
Check the{' '}
|
||||
<b
|
||||
onClick={async () => {
|
||||
await window.service.native.open(await window.service.context.get('LOG_FOLDER'), true);
|
||||
await window.service.native.openPath(await window.service.context.get('LOG_FOLDER'), true);
|
||||
}}
|
||||
onKeyPress={async () => {
|
||||
await window.service.native.open(await window.service.context.get('LOG_FOLDER'), true);
|
||||
await window.service.native.openPath(await window.service.context.get('LOG_FOLDER'), true);
|
||||
}}
|
||||
role='button'
|
||||
tabIndex={0}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ export class NativeService implements INativeService {
|
|||
return false;
|
||||
}
|
||||
|
||||
public async open(uri: string, showItemInFolder = false): Promise<void> {
|
||||
public async openURI(uri: string, showItemInFolder = false): Promise<void> {
|
||||
logger.debug(`NativeService.open() Opening ${uri}`, { showItemInFolder });
|
||||
showItemInFolder ? shell.showItemInFolder(uri) : await shell.openExternal(uri);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,12 +44,6 @@ export interface INativeService {
|
|||
getLocalHostUrlWithActualInfo(urlToReplace: string, workspaceID: string): Promise<string>;
|
||||
log(level: string, message: string, meta?: Record<string, unknown>): Promise<void>;
|
||||
mkdir(absoulutePath: string): Promise<void>;
|
||||
/**
|
||||
* Open a file or URI in the desktop's default manner, or show in file manager.
|
||||
* @param uri File path or URI starts with any scheme.
|
||||
* @param showItemInFolder Show the given file in a file manager. If possible, select the file.
|
||||
*/
|
||||
open(uri: string, showItemInFolder?: boolean): Promise<void>;
|
||||
openInEditor(filePath: string, editorName?: string | undefined): Promise<boolean>;
|
||||
openInGitGuiApp(filePath: string, editorName?: string | undefined): Promise<boolean>;
|
||||
openNewGitHubIssue(error: Error): Promise<void>;
|
||||
|
|
@ -59,6 +53,12 @@ export interface INativeService {
|
|||
* @param showItemInFolder Show the given file in a file manager. If possible, select the file.
|
||||
*/
|
||||
openPath(filePath: string, showItemInFolder?: boolean): Promise<void>;
|
||||
/**
|
||||
* Open a file or URI in the desktop's default manner, or show in file manager.
|
||||
* @param uri File path or URI starts with any scheme.
|
||||
* @param showItemInFolder Show the given file in a file manager. If possible, select the file.
|
||||
*/
|
||||
openURI(uri: string, showItemInFolder?: boolean): Promise<void>;
|
||||
path(method: 'basename' | 'dirname' | 'join', pathString: string | undefined, ...paths: string[]): Promise<string | undefined>;
|
||||
pickDirectory(defaultPath?: string, options?: IPickDirectoryOptions): Promise<string[]>;
|
||||
pickFile(filters?: Electron.OpenDialogOptions['filters']): Promise<string[]>;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ export function reportErrorToGithubWithTemplates(error: Error): void {
|
|||
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
||||
.then(({ container }) => {
|
||||
const nativeService = container.get<INativeService>(serviceIdentifier.NativeService);
|
||||
return nativeService.open(LOG_FOLDER, true);
|
||||
return nativeService.openPath(LOG_FOLDER, true);
|
||||
})
|
||||
.catch(async (error) => {
|
||||
await import('@services/libs/log').then(({ logger }) => {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ interface IWorkspaceMenuRequiredServices {
|
|||
auth: Pick<IAuthenticationService, 'getStorageServiceUserInfo'>;
|
||||
context: Pick<IContextService, 'isOnline'>;
|
||||
git: Pick<IGitService, 'commitAndSync'>;
|
||||
native: Pick<INativeService, 'open' | 'openInEditor' | 'openInGitGuiApp' | 'getLocalHostUrlWithActualInfo'>;
|
||||
native: Pick<INativeService, 'openURI' | 'openPath' | 'openInEditor' | 'openInGitGuiApp' | 'getLocalHostUrlWithActualInfo'>;
|
||||
pages: Pick<IPagesService, 'setActivePage' | 'getActivePage'>;
|
||||
view: Pick<IViewService, 'reloadViewsWebContents' | 'getViewCurrentUrl'>;
|
||||
wiki: Pick<IWikiService, 'wikiOperationInBrowser' | 'wikiOperationInServer' | 'requestWikiSendActionMessage'>;
|
||||
|
|
@ -101,7 +101,7 @@ export async function getWorkspaceMenuTemplate(
|
|||
{
|
||||
label: t('WorkspaceSelector.OpenWorkspaceFolder'),
|
||||
click: async () => {
|
||||
await service.native.open(wikiFolderLocation, true);
|
||||
await service.native.openPath(wikiFolderLocation);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -117,7 +117,7 @@ export async function getWorkspaceMenuTemplate(
|
|||
enabled: enableHTTPAPI,
|
||||
click: async () => {
|
||||
const actualIP = await service.native.getLocalHostUrlWithActualInfo(getDefaultHTTPServerIP(port), id);
|
||||
await service.native.open(actualIP);
|
||||
await service.native.openURI(actualIP);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue