Skip to content

Commit

Permalink
Update plugin-metacubexd-dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayideyia committed Oct 23, 2024
1 parent 5b9f511 commit 5b7fc79
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 62 deletions.
112 changes: 56 additions & 56 deletions plugins/Generic/plugin-metacubexd-dashboard.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
const openClashDashboard = async () => {
let url

let dashboardUrl = 'https://metacubexd.pages.dev'
if (Plugin.xd_url){
dashboardUrl = Plugin.xd_url
}
if (Plugins.APP_TITLE.includes('SingBox')) {
const configpath = './data/sing-box/config.json'

// 读取 JSON 文件
const jsonContent = await Plugins.Readfile(configpath)

// 解析 JSON 内容
const jsonData = JSON.parse(jsonContent)

// 将 JSON 中的值赋给不同的变量
const localAddress = jsonData['experimental']['clash_api']['external_controller']
const secret = jsonData['experimental']['clash_api']['secret']

// 解构localAddress获取主机和端口
const [host, port] = localAddress.split(':')

// 构建URL
url = `${dashboardUrl}/?hostname=${host}&port=${port}&secret=${secret}&http=1`
} else if (Plugins.APP_TITLE.includes('Clash')) {
const configpath = './data/mihomo/config.yaml'

// 读取 YAML 文件
const yamlContent = await Plugins.Readfile(configpath)

// 解析 YAML 内容
const yamlData = Plugins.YAML.parse(yamlContent)

// 将 YAML 中的值赋给不同的变量
const localAddress = yamlData['external-controller']
const secret = yamlData['secret']

// 解构localAddress获取主机和端口
const [host, port] = localAddress.split(':')

// 构建URL
url = `${dashboardUrl}/#?hostname=${host}&port=${port}&secret=${secret}&http=1`
}

window.open(url)
let url

let dashboardUrl = 'https://metacubexd.pages.dev'
if (Plugin.xd_url) {
dashboardUrl = Plugin.xd_url
}

const onRun = async () => {
await openClashDashboard()
if (Plugins.APP_TITLE.includes('SingBox')) {
const configpath = './data/sing-box/config.json'

// 读取 JSON 文件
const jsonContent = await Plugins.Readfile(configpath)

// 解析 JSON 内容
const jsonData = JSON.parse(jsonContent)

// 将 JSON 中的值赋给不同的变量
const localAddress = jsonData['experimental']['clash_api']['external_controller']
const secret = jsonData['experimental']['clash_api']['secret']

// 解构localAddress获取主机和端口
const [, port] = localAddress.split(':')

// 构建URL
url = `${dashboardUrl}/?hostname=127.0.0.1&port=${port}&secret=${secret}&http=1`
} else if (Plugins.APP_TITLE.includes('Clash')) {
const configpath = './data/mihomo/config.yaml'

// 读取 YAML 文件
const yamlContent = await Plugins.Readfile(configpath)

// 解析 YAML 内容
const yamlData = Plugins.YAML.parse(yamlContent)

// 将 YAML 中的值赋给不同的变量
const localAddress = yamlData['external-controller']
const secret = yamlData['secret']

// 解构localAddress获取主机和端口
const [, port] = localAddress.split(':')

// 构建URL
url = `${dashboardUrl}/?hostname=127.0.0.1&port=${port}&secret=${secret}&http=1`
}

const onShutdown = async () => {
await openClashDashboard()

window.open(url)
}

const onRun = async () => {
await openClashDashboard()
}

const onShutdown = async () => {
await openClashDashboard()
}
const onReady = async () => {
if (Plugin.start_onboot) {
return await onRun()
}
const onReady = async () => {
if (Plugin.start_onboot) {
return await onRun()
}
}
}
9 changes: 3 additions & 6 deletions plugins/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -1478,15 +1478,12 @@
{
"id": "plugin-metacubexd-dashboard",
"name": "metacubexd 仪表板",
"description": "一个更好看的Mihomo仪表板",
"description": "一个更好看的Mihomo仪表板。Supported by: ColinZeb",
"type": "Http",
"url": "https://github.com/MetaCubeX/metacubexd",
"url": "https://raw.githubusercontent.com/GUI-for-Cores/Plugin-Hub/refs/heads/main/plugins/Generic/plugin-metacubexd-dashboard.js",
"status": 0,
"path": "data/plugins/plugin-metacubexd-dashboard.js",
"triggers": [
"on::manual",
"on::ready"
],
"triggers": ["on::manual", "on::ready"],
"menus": {
"XD Dashboard": "OnRun"
},
Expand Down

0 comments on commit 5b7fc79

Please sign in to comment.