feat(interconnect): display active node name in travel mode & update changelog
- Persist active interconnect node name in localStorage via api - Pass node name on MasterList and NodeSwitcher when traveling - Display current node name on the 'Return to Master' floating button in App.vue - Update CHANGELOG.md, README.md and docs with v1.1.17 release notes highlighting interconnect features
This commit is contained in:
+2
-2
@@ -3,7 +3,7 @@ import { onMounted } from 'vue'
|
||||
import { RouterView } from 'vue-router'
|
||||
import { Toaster } from '@/components/ui/sonner'
|
||||
import { LogOut } from 'lucide-vue-next'
|
||||
import { activeInterconnectNodeId, setActiveInterconnectNodeId } from '@/api'
|
||||
import { activeInterconnectNodeId, activeInterconnectNodeName, setActiveInterconnectNodeId } from '@/api'
|
||||
|
||||
function exitTravel() {
|
||||
setActiveInterconnectNodeId('')
|
||||
@@ -37,7 +37,7 @@ onMounted(() => {
|
||||
hover:scale-105 active:scale-95 cursor-pointer"
|
||||
>
|
||||
<LogOut class="h-3 w-3 transition-transform group-hover:-translate-x-0.5" />
|
||||
<span>返回主节点</span>
|
||||
<span>返回主节点 <template v-if="activeInterconnectNodeName">当前:({{ activeInterconnectNodeName }})</template></span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -66,15 +66,22 @@ export interface MonitorStats {
|
||||
}
|
||||
}
|
||||
export let activeInterconnectNodeId = localStorage.getItem('activeInterconnectNodeId') || ''
|
||||
export let activeInterconnectNodeName = localStorage.getItem('activeInterconnectNodeName') || ''
|
||||
|
||||
export function setActiveInterconnectNodeId(id: string) {
|
||||
export function setActiveInterconnectNodeId(id: string, name?: string) {
|
||||
activeInterconnectNodeId = id
|
||||
if (name !== undefined) {
|
||||
activeInterconnectNodeName = name
|
||||
}
|
||||
localStorage.removeItem('site_settings_cache')
|
||||
if (id) {
|
||||
localStorage.setItem('activeInterconnectNodeId', id)
|
||||
if (name) localStorage.setItem('activeInterconnectNodeName', name)
|
||||
document.cookie = `active_interconnect_node_id=${id}; path=/; max-age=${7 * 24 * 3600}`
|
||||
} else {
|
||||
localStorage.removeItem('activeInterconnectNodeId')
|
||||
localStorage.removeItem('activeInterconnectNodeName')
|
||||
activeInterconnectNodeName = ''
|
||||
document.cookie = `active_interconnect_node_id=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ function handleNodeChange(val: any) {
|
||||
if (strVal === 'local') {
|
||||
setActiveInterconnectNodeId('')
|
||||
} else {
|
||||
setActiveInterconnectNodeId(strVal)
|
||||
const nodeName = nodes.value.find(n => n.id === strVal)?.name || ''
|
||||
setActiveInterconnectNodeId(strVal, nodeName)
|
||||
}
|
||||
// Refresh the current page to reload data from the new node
|
||||
window.location.reload()
|
||||
|
||||
@@ -143,8 +143,8 @@ async function showDetail(node: interconnectApi.InterconnectNode) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleTravel(nodeId: string) {
|
||||
setActiveInterconnectNodeId(nodeId)
|
||||
function handleTravel(node: interconnectApi.InterconnectNode) {
|
||||
setActiveInterconnectNodeId(node.id, node.name)
|
||||
window.location.href = '/'
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ defineExpose({
|
||||
<Button variant="ghost" size="icon" class="h-7 w-7" @click="showDetail(node)" title="查看详情">
|
||||
<Eye class="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" class="h-7 w-7" @click="handleTravel(node.id)" title="穿越到此子节点">
|
||||
<Button variant="ghost" size="icon" class="h-7 w-7" @click="handleTravel(node)" title="穿越到此子节点">
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" class="h-7 w-7" @click="openEditDialog(node)" title="编辑">
|
||||
@@ -329,7 +329,7 @@ defineExpose({
|
||||
</div>
|
||||
<div class="w-36 shrink-0 flex justify-center gap-0.5">
|
||||
<Button variant="ghost" size="icon" class="h-7 w-7" @click="showDetail(node)" title="查看详情"><Eye class="h-3.5 w-3.5" /></Button>
|
||||
<Button variant="ghost" size="icon" class="h-7 w-7" @click="handleTravel(node.id)" title="穿越到此子节点"><ExternalLink class="h-3.5 w-3.5" /></Button>
|
||||
<Button variant="ghost" size="icon" class="h-7 w-7" @click="handleTravel(node)" title="穿越到此子节点"><ExternalLink class="h-3.5 w-3.5" /></Button>
|
||||
<Button variant="ghost" size="icon" class="h-7 w-7" @click="openEditDialog(node)" title="编辑"><Edit2 class="h-3.5 w-3.5" /></Button>
|
||||
<Button variant="ghost" size="icon" class="h-7 w-7" @click="confirmDelete(node.id)" title="删除"><Trash2 class="h-3.5 w-3.5" /></Button>
|
||||
</div>
|
||||
@@ -386,7 +386,7 @@ defineExpose({
|
||||
<Button variant="ghost" class="h-9 px-0 text-xs gap-1 hover:bg-primary/5 rounded-none" @click="showDetail(node)">
|
||||
<Eye class="h-3.5 w-3.5" />详情
|
||||
</Button>
|
||||
<Button variant="ghost" class="h-9 px-0 text-xs gap-1 hover:bg-primary/5 rounded-none border-l border-border/10" @click="handleTravel(node.id)">
|
||||
<Button variant="ghost" class="h-9 px-0 text-xs gap-1 hover:bg-primary/5 rounded-none border-l border-border/10" @click="handleTravel(node)">
|
||||
<ExternalLink class="h-3.5 w-3.5" />穿越
|
||||
</Button>
|
||||
<Button variant="ghost" class="h-9 px-0 text-xs gap-1 hover:bg-primary/5 rounded-none border-l border-border/10" @click="openEditDialog(node)">
|
||||
|
||||
Reference in New Issue
Block a user