()
| 3 | import { GlobalStore } from '@/store'; |
| 4 | |
| 5 | export const changeToLocal = async () => { |
| 6 | const globalStore = GlobalStore(); |
| 7 | let nodes = await listNodes('all'); |
| 8 | if (nodes.length === 0) { |
| 9 | setDefaultNodeInfo(); |
| 10 | return; |
| 11 | } |
| 12 | if (globalStore.isAdmin) { |
| 13 | for (const item of nodes) { |
| 14 | if (item.name === 'local') { |
| 15 | globalStore.currentNode = 'local'; |
| 16 | globalStore.currentNodeAddr = item.addr; |
| 17 | return; |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | globalStore.currentNode = nodes[0].name; |
| 22 | globalStore.currentNodeAddr = nodes[0].addr; |
| 23 | }; |
| 24 | |
| 25 | export async function listNodes(type: string): Promise<Array<Setting.NodeItem>> { |
| 26 | try { |
no test coverage detected