mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-25 01:58:39 +02:00
Add ref=<app_id> to external links pointing to yaak.app
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
"*"
|
"*"
|
||||||
],
|
],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
"core:app:allow-identifier",
|
||||||
"core:event:allow-emit",
|
"core:event:allow-emit",
|
||||||
"core:event:allow-listen",
|
"core:event:allow-listen",
|
||||||
"core:event:allow-unlisten",
|
"core:event:allow-unlisten",
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { useAppInfo } from '../hooks/useAppInfo';
|
import { appInfo } from '../lib/appInfo';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function IsDev({ children }: Props) {
|
export function IsDev({ children }: Props) {
|
||||||
const appInfo = useAppInfo();
|
|
||||||
if (!appInfo.isDev) {
|
if (!appInfo.isDev) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { LicenseCheckStatus } from '@yaakapp-internal/license';
|
|||||||
import { useLicense } from '@yaakapp-internal/license';
|
import { useLicense } from '@yaakapp-internal/license';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { openSettings } from '../commands/openSettings';
|
import { openSettings } from '../commands/openSettings';
|
||||||
import { appInfo } from '../hooks/useAppInfo';
|
import { appInfo } from '../lib/appInfo';
|
||||||
import { useLicenseConfirmation } from '../hooks/useLicenseConfirmation';
|
import { useLicenseConfirmation } from '../hooks/useLicenseConfirmation';
|
||||||
import { BadgeButton } from './core/BadgeButton';
|
import { BadgeButton } from './core/BadgeButton';
|
||||||
import type { ButtonProps } from './core/Button';
|
import type { ButtonProps } from './core/Button';
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { patchModel, settingsAtom } from '@yaakapp-internal/models';
|
|||||||
import { useAtomValue } from 'jotai';
|
import { useAtomValue } from 'jotai';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { activeWorkspaceAtom } from '../../hooks/useActiveWorkspace';
|
import { activeWorkspaceAtom } from '../../hooks/useActiveWorkspace';
|
||||||
import { useAppInfo } from '../../hooks/useAppInfo';
|
import { appInfo } from '../../lib/appInfo';
|
||||||
import { useCheckForUpdates } from '../../hooks/useCheckForUpdates';
|
import { useCheckForUpdates } from '../../hooks/useCheckForUpdates';
|
||||||
import { revealInFinderText } from '../../lib/reveal';
|
import { revealInFinderText } from '../../lib/reveal';
|
||||||
import { Checkbox } from '../core/Checkbox';
|
import { Checkbox } from '../core/Checkbox';
|
||||||
@@ -18,7 +18,6 @@ import { VStack } from '../core/Stacks';
|
|||||||
export function SettingsGeneral() {
|
export function SettingsGeneral() {
|
||||||
const workspace = useAtomValue(activeWorkspaceAtom);
|
const workspace = useAtomValue(activeWorkspaceAtom);
|
||||||
const settings = useAtomValue(settingsAtom);
|
const settings = useAtomValue(settingsAtom);
|
||||||
const appInfo = useAppInfo();
|
|
||||||
const checkForUpdates = useCheckForUpdates();
|
const checkForUpdates = useCheckForUpdates();
|
||||||
|
|
||||||
if (settings == null || workspace == null) {
|
if (settings == null || workspace == null) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { openUrl } from '@tauri-apps/plugin-opener';
|
|||||||
import { useLicense } from '@yaakapp-internal/license';
|
import { useLicense } from '@yaakapp-internal/license';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import { openSettings } from '../commands/openSettings';
|
import { openSettings } from '../commands/openSettings';
|
||||||
import { useAppInfo } from '../hooks/useAppInfo';
|
import { appInfo } from '../lib/appInfo';
|
||||||
import { useCheckForUpdates } from '../hooks/useCheckForUpdates';
|
import { useCheckForUpdates } from '../hooks/useCheckForUpdates';
|
||||||
import { useExportData } from '../hooks/useExportData';
|
import { useExportData } from '../hooks/useExportData';
|
||||||
import { useImportData } from '../hooks/useImportData';
|
import { useImportData } from '../hooks/useImportData';
|
||||||
@@ -17,7 +17,6 @@ import { KeyboardShortcutsDialog } from './KeyboardShortcutsDialog';
|
|||||||
export function SettingsDropdown() {
|
export function SettingsDropdown() {
|
||||||
const importData = useImportData();
|
const importData = useImportData();
|
||||||
const exportData = useExportData();
|
const exportData = useExportData();
|
||||||
const appInfo = useAppInfo();
|
|
||||||
const dropdownRef = useRef<DropdownRef>(null);
|
const dropdownRef = useRef<DropdownRef>(null);
|
||||||
const checkForUpdates = useCheckForUpdates();
|
const checkForUpdates = useCheckForUpdates();
|
||||||
const { check } = useLicense();
|
const { check } = useLicense();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Link as RouterLink } from '@tanstack/react-router';
|
import { Link as RouterLink } from '@tanstack/react-router';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import type { HTMLAttributes } from 'react';
|
import type { HTMLAttributes } from 'react';
|
||||||
|
import { appInfo } from '../../lib/appInfo';
|
||||||
import { Icon } from './Icon';
|
import { Icon } from './Icon';
|
||||||
|
|
||||||
interface Props extends HTMLAttributes<HTMLAnchorElement> {
|
interface Props extends HTMLAttributes<HTMLAnchorElement> {
|
||||||
@@ -13,9 +14,15 @@ export function Link({ href, children, className, ...other }: Props) {
|
|||||||
className = classNames(className, 'relative underline hover:text-violet-600');
|
className = classNames(className, 'relative underline hover:text-violet-600');
|
||||||
|
|
||||||
if (isExternal) {
|
if (isExternal) {
|
||||||
|
let finalHref = href;
|
||||||
|
if (href.startsWith('https://yaak.app')) {
|
||||||
|
const url = new URL(href);
|
||||||
|
url.searchParams.set('ref', appInfo.identifier);
|
||||||
|
finalHref = url.toString();
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
href={href}
|
href={finalHref}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className={classNames(className, 'pr-4 inline-flex items-center')}
|
className={classNames(className, 'pr-4 inline-flex items-center')}
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
import { invokeCmd } from '../lib/tauri';
|
|
||||||
|
|
||||||
export interface AppInfo {
|
|
||||||
isDev: boolean;
|
|
||||||
version: string;
|
|
||||||
name: string;
|
|
||||||
appDataDir: string;
|
|
||||||
appLogDir: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const appInfo = (await invokeCmd('cmd_metadata')) as AppInfo;
|
|
||||||
|
|
||||||
export function useAppInfo() {
|
|
||||||
return appInfo;
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation } from '@tanstack/react-query';
|
||||||
import { InlineCode } from '../components/core/InlineCode';
|
import { InlineCode } from '../components/core/InlineCode';
|
||||||
import { showAlert } from '../lib/alert';
|
import { showAlert } from '../lib/alert';
|
||||||
|
import { appInfo } from '../lib/appInfo';
|
||||||
import { minPromiseMillis } from '../lib/minPromiseMillis';
|
import { minPromiseMillis } from '../lib/minPromiseMillis';
|
||||||
import { invokeCmd } from '../lib/tauri';
|
import { invokeCmd } from '../lib/tauri';
|
||||||
import { useAppInfo } from './useAppInfo';
|
|
||||||
|
|
||||||
export function useCheckForUpdates() {
|
export function useCheckForUpdates() {
|
||||||
const appInfo = useAppInfo();
|
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationKey: ['check_for_updates'],
|
mutationKey: ['check_for_updates'],
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { setWindowTitle } from '@yaakapp-internal/mac-window';
|
import { setWindowTitle } from '@yaakapp-internal/mac-window';
|
||||||
import { useAtomValue } from 'jotai';
|
import { useAtomValue } from 'jotai';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import { appInfo } from '../lib/appInfo';
|
||||||
import { resolvedModelName } from '../lib/resolvedModelName';
|
import { resolvedModelName } from '../lib/resolvedModelName';
|
||||||
import { useActiveEnvironment } from './useActiveEnvironment';
|
import { useActiveEnvironment } from './useActiveEnvironment';
|
||||||
import { activeRequestAtom } from './useActiveRequest';
|
import { activeRequestAtom } from './useActiveRequest';
|
||||||
import { activeWorkspaceAtom } from './useActiveWorkspace';
|
import { activeWorkspaceAtom } from './useActiveWorkspace';
|
||||||
import { appInfo } from './useAppInfo';
|
|
||||||
|
|
||||||
export function useSyncWorkspaceRequestTitle() {
|
export function useSyncWorkspaceRequestTitle() {
|
||||||
const activeWorkspace = useAtomValue(activeWorkspaceAtom);
|
const activeWorkspace = useAtomValue(activeWorkspaceAtom);
|
||||||
|
|||||||
16
src-web/lib/appInfo.ts
Normal file
16
src-web/lib/appInfo.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { getIdentifier } from '@tauri-apps/api/app';
|
||||||
|
import { invokeCmd } from './tauri';
|
||||||
|
|
||||||
|
export interface AppInfo {
|
||||||
|
isDev: boolean;
|
||||||
|
version: string;
|
||||||
|
name: string;
|
||||||
|
appDataDir: string;
|
||||||
|
appLogDir: string;
|
||||||
|
identifier: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const appInfo = {
|
||||||
|
...(await invokeCmd('cmd_metadata')),
|
||||||
|
identifier: await getIdentifier(),
|
||||||
|
} as AppInfo;
|
||||||
Reference in New Issue
Block a user