mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
Use GitHub native PJAX
This commit is contained in:
parent
69efa5bcdc
commit
8a3135a312
2 changed files with 19 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { BranchName, Breadcrumb, Flex, Text } from '@primer/components'
|
||||
import { GitBranchIcon } from '@primer/octicons-react'
|
||||
import { platform } from 'platforms'
|
||||
import { platform, platformName } from 'platforms'
|
||||
import * as React from 'react'
|
||||
import { isOpenInNewWindowClick } from 'utils/general'
|
||||
import { loadWithPJAX } from 'utils/hooks/usePJAX'
|
||||
|
|
@ -28,12 +28,16 @@ export function MetaBar({ metaData }: Props) {
|
|||
href={branchUrl}
|
||||
as="a"
|
||||
className={'branch-name'}
|
||||
onClick={e => {
|
||||
if (isOpenInNewWindowClick(e)) return
|
||||
{...(platformName === 'GitHub'
|
||||
? { 'data-pjax': '#repo-content-pjax-container' }
|
||||
: {
|
||||
onClick: e => {
|
||||
if (isOpenInNewWindowClick(e)) return
|
||||
|
||||
e.preventDefault()
|
||||
loadWithPJAX(branchUrl)
|
||||
}}
|
||||
e.preventDefault()
|
||||
loadWithPJAX(branchUrl)
|
||||
},
|
||||
})}
|
||||
>
|
||||
{branchName || '...'}
|
||||
</BranchName>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { useConfigs } from 'containers/ConfigsContext'
|
||||
import { platformName } from 'platforms'
|
||||
import * as React from 'react'
|
||||
import { cx } from 'utils/cx'
|
||||
import { isOpenInNewWindowClick } from 'utils/general'
|
||||
|
|
@ -42,11 +43,15 @@ export function Node({
|
|||
return (
|
||||
<a
|
||||
href={node.url}
|
||||
onClick={event => {
|
||||
if (isOpenInNewWindowClick(event)) return
|
||||
{...(platformName === 'GitHub' && node.type === 'blob'
|
||||
? { 'data-pjax': '#repo-content-pjax-container' }
|
||||
: {
|
||||
onClick: event => {
|
||||
if (isOpenInNewWindowClick(event)) return
|
||||
|
||||
onClick(event, node)
|
||||
}}
|
||||
onClick(event, node)
|
||||
},
|
||||
})}
|
||||
className={cx(`node-item`, { focused, disabled: node.accessDenied, expanded, compact })}
|
||||
style={{ ...style, paddingLeft: `${10 + (compact ? 10 : 20) * depth}px` }}
|
||||
title={node.path}
|
||||
|
|
|
|||
Loading…
Reference in a new issue