mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-09-26 08:00:55 +00:00
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
import { listNodeOptions } from '@/api/modules/setting';
|
|
import { GlobalStore } from '@/store';
|
|
|
|
const globalStore = GlobalStore();
|
|
|
|
export const changeToLocal = async () => {
|
|
if (!globalStore.isMasterPro) {
|
|
setDefaultNodeInfo();
|
|
return;
|
|
}
|
|
await listNodeOptions('all')
|
|
.then((res) => {
|
|
if (!res) {
|
|
setDefaultNodeInfo();
|
|
return;
|
|
}
|
|
let nodes = res.data || [];
|
|
if (nodes.length === 0) {
|
|
setDefaultNodeInfo();
|
|
return;
|
|
}
|
|
for (const item of nodes) {
|
|
if (item.name === 'local') {
|
|
globalStore.currentNode = 'local';
|
|
globalStore.currentNodeAddr = item.addr;
|
|
return;
|
|
}
|
|
}
|
|
})
|
|
.catch(() => {
|
|
setDefaultNodeInfo();
|
|
});
|
|
};
|
|
|
|
export const setDefaultNodeInfo = () => {
|
|
globalStore.currentNode = 'local';
|
|
globalStore.currentNodeAddr = '';
|
|
};
|