mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
use location.hash
instead search
This commit is contained in:
parent
f6fe72842d
commit
8a0093aa30
@ -48,7 +48,7 @@ export const Panel = (props) => {
|
||||
|
||||
export class PagePanelWithNavMenu extends React.Component {
|
||||
state = {
|
||||
activeTab: new URLSearchParams(window.location.search).get("type") ?? this.props.defaultTab ?? this.props.tabs[0].key,
|
||||
activeTab: new URLSearchParams(window.location.hash.replace("#", "?")).get("type") ?? this.props.defaultTab ?? this.props.tabs[0].key,
|
||||
renders: [],
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ export class PagePanelWithNavMenu extends React.Component {
|
||||
}
|
||||
|
||||
replaceQueryTypeToCurrentTab = (key) => {
|
||||
app.history.replace(`${window.location.pathname}?type=${key ?? this.state.activeTab}`)
|
||||
document.location.hash = `type=${key ?? this.state.activeTab}`
|
||||
}
|
||||
|
||||
tabChange = async (key) => {
|
||||
|
@ -4,15 +4,15 @@ export default ({
|
||||
defaultKey = "0",
|
||||
queryKey = "key",
|
||||
}) => {
|
||||
const [activeKey, setActiveKey] = React.useState(new URLSearchParams(window.location.search).get(queryKey) ?? defaultKey)
|
||||
const [activeKey, setActiveKey] = React.useState(new URLSearchParams(window.location.hash.replace("#", "?")).get(queryKey) ?? defaultKey)
|
||||
|
||||
const replaceQueryTypeToCurrentTab = (key) => {
|
||||
if (!key) {
|
||||
// delete query
|
||||
return app.history.replace(window.location.pathname)
|
||||
return document.location.hash = null
|
||||
}
|
||||
|
||||
return app.history.replace(`${window.location.pathname}?${queryKey}=${key}`)
|
||||
return document.location.hash = `${queryKey}=${key}`
|
||||
}
|
||||
|
||||
const changeActiveKey = (key) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user