Merge pull request #4874 from h3poteto/feat/invoke-web
Separate invoke method for browser
This commit is contained in:
commit
446005dafe
|
@ -22,3 +22,6 @@ jobs:
|
||||||
- name: typecheck
|
- name: typecheck
|
||||||
run: |
|
run: |
|
||||||
yarn run typecheck
|
yarn run typecheck
|
||||||
|
- name: Build web
|
||||||
|
run: |
|
||||||
|
yarn run build:web
|
||||||
|
|
|
@ -7,16 +7,16 @@
|
||||||
"main": "app/background.js",
|
"main": "app/background.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nextron",
|
"dev": "nextron",
|
||||||
"dev:web": "next dev renderer",
|
|
||||||
"build": "nextron build",
|
"build": "nextron build",
|
||||||
"build:web": "cd renderer && next build",
|
|
||||||
"build:mas": "nextron build --config ./electron-builder.mas.yml",
|
"build:mas": "nextron build --config ./electron-builder.mas.yml",
|
||||||
"build:appx2": "nextron build --win --x64 && electron-windows-store --assets ./resources/icons --input-directory ./dist/win-unpacked --output-directory ./dist/appx --package-name Whalebird --package-display-name Whalebird --package-version 6.0.3.0 --publisher-display-name h3poteto --identity-name 45610h3poteto.Whalebird",
|
"build:appx2": "nextron build --win --x64 && electron-windows-store --assets ./resources/icons --input-directory ./dist/win-unpacked --output-directory ./dist/appx --package-name Whalebird --package-display-name Whalebird --package-version 6.0.3.0 --publisher-display-name h3poteto --identity-name 45610h3poteto.Whalebird",
|
||||||
"postinstall": "electron-builder install-app-deps",
|
"postinstall": "electron-builder install-app-deps",
|
||||||
"typecheck": "tsc -p renderer --noEmit && tsc -p main --noEmit",
|
"typecheck": "tsc -p renderer --noEmit && tsc -p main --noEmit",
|
||||||
"lint": "eslint renderer --ext ts,tsx",
|
"lint": "eslint renderer --ext ts,tsx",
|
||||||
"thirdparty": "license-checker --production --json > renderer/thirdparty.json",
|
"thirdparty": "license-checker --production --json > renderer/thirdparty.json",
|
||||||
"start:web": "cd renderer && next start"
|
"dev:web": "NEXT_PUBLIC_CLIENT_ENV=browser next dev renderer",
|
||||||
|
"build:web": "NEXT_PUBLIC_CLIENT_ENV=browser next build renderer",
|
||||||
|
"start:web": "cd renderer && NEXT_PUBLIC_CLIENT_ENV=browser next start"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emoji-mart/react": "^1.1.1",
|
"@emoji-mart/react": "^1.1.1",
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { db } from '@/db'
|
import { db } from '@/db'
|
||||||
import { FormattedMessage, useIntl } from 'react-intl'
|
import { FormattedMessage, useIntl } from 'react-intl'
|
||||||
import { Alert, Button, Dialog, DialogBody, DialogHeader, Input, Spinner, Typography } from '@material-tailwind/react'
|
import { Alert, Button, Dialog, DialogBody, DialogHeader, Input, Spinner, Typography } from '@material-tailwind/react'
|
||||||
|
import { invoke } from '@/utils/invoke'
|
||||||
|
|
||||||
type NewProps = {
|
type NewProps = {
|
||||||
opened: boolean
|
opened: boolean
|
||||||
|
@ -57,7 +58,7 @@ export default function New(props: NewProps) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setAppData(appData)
|
setAppData(appData)
|
||||||
global.ipc.invoke('open-browser', appData.url)
|
invoke('open-browser', appData.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDomainSubmit = useCallback(
|
const handleDomainSubmit = useCallback(
|
||||||
|
|
|
@ -24,6 +24,7 @@ import {
|
||||||
TabsHeader
|
TabsHeader
|
||||||
} from '@material-tailwind/react'
|
} from '@material-tailwind/react'
|
||||||
import { domainFromAcct } from '@/utils/domain'
|
import { domainFromAcct } from '@/utils/domain'
|
||||||
|
import { invoke } from '@/utils/invoke'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
client: MegalodonInterface
|
client: MegalodonInterface
|
||||||
|
@ -67,7 +68,7 @@ export default function Profile(props: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const openOriginal = async (url: string) => {
|
const openOriginal = async (url: string) => {
|
||||||
global.ipc.invoke('open-browser', url)
|
invoke('open-browser', url)
|
||||||
}
|
}
|
||||||
|
|
||||||
const block = async () => {
|
const block = async () => {
|
||||||
|
@ -115,7 +116,7 @@ export default function Profile(props: Props) {
|
||||||
const profileClicked: MouseEventHandler<HTMLDivElement> = async e => {
|
const profileClicked: MouseEventHandler<HTMLDivElement> = async e => {
|
||||||
const url = findLink(e.target as HTMLElement, 'profile')
|
const url = findLink(e.target as HTMLElement, 'profile')
|
||||||
if (url) {
|
if (url) {
|
||||||
global.ipc.invoke('open-browser', url)
|
invoke('open-browser', url)
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { Account } from '@/db'
|
||||||
import { FormattedMessage, useIntl } from 'react-intl'
|
import { FormattedMessage, useIntl } from 'react-intl'
|
||||||
import { IconButton, List, ListItem, Popover, PopoverContent, PopoverHandler } from '@material-tailwind/react'
|
import { IconButton, List, ListItem, Popover, PopoverContent, PopoverHandler } from '@material-tailwind/react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
import { invoke } from '@/utils/invoke'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
status: Entity.Status
|
status: Entity.Status
|
||||||
|
@ -60,7 +61,7 @@ export default function Actions(props: Props) {
|
||||||
|
|
||||||
const original = () => {
|
const original = () => {
|
||||||
setPopoverDetail(false)
|
setPopoverDetail(false)
|
||||||
global.ipc.invoke('open-browser', props.status.url)
|
invoke('open-browser', props.status.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
const report = () => {
|
const report = () => {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { invoke } from '@/utils/invoke'
|
||||||
import { Entity } from 'megalodon'
|
import { Entity } from 'megalodon'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -6,7 +7,7 @@ type Props = {
|
||||||
|
|
||||||
export default function Card(props: Props) {
|
export default function Card(props: Props) {
|
||||||
const openCard = () => {
|
const openCard = () => {
|
||||||
global.ipc.invoke('open-browser', props.card.url)
|
invoke('open-browser', props.card.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { MouseEventHandler, useState } from 'react'
|
||||||
import { findAccount, findLink, ParsedAccount, accountMatch, findTag } from '@/utils/statusParser'
|
import { findAccount, findLink, ParsedAccount, accountMatch, findTag } from '@/utils/statusParser'
|
||||||
import { Account } from '@/db'
|
import { Account } from '@/db'
|
||||||
import { Avatar } from '@material-tailwind/react'
|
import { Avatar } from '@material-tailwind/react'
|
||||||
|
import { invoke } from '@/utils/invoke'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
status: Entity.Status
|
status: Entity.Status
|
||||||
|
@ -67,7 +68,7 @@ export default function Status(props: Props) {
|
||||||
|
|
||||||
const url = findLink(e.target as HTMLElement, 'status-body')
|
const url = findLink(e.target as HTMLElement, 'status-body')
|
||||||
if (url) {
|
if (url) {
|
||||||
global.ipc.invoke('open-browser', url)
|
invoke('open-browser', url)
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
export function invoke(event: string, data: any) {
|
||||||
|
if (process.env.NEXT_PUBLIC_CLIENT_ENV !== 'browser') {
|
||||||
|
global.ipc.invoke(event, data)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch (event) {
|
||||||
|
case 'open-browser':
|
||||||
|
window.open(data, '_blank').focus()
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
console.error(`Unknown event: ${event}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue