Skip to content

Commit

Permalink
Update plugin-share-profile-to-phone
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayideyia committed Oct 15, 2024
1 parent 4fc434e commit 3ab8ce1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions plugins/GFS/plugin-share-profile-to-phone.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,18 @@ function getQRCode(rawUrl, rawStr) {
}

async function getIPAddress() {
const isWindows = Plugins.useEnvStore().env.os === 'windows'
const cmd = isWindows ? 'ipconfig' : 'ip'
const arg = isWindows ? [] : ['a']
const text = await Plugins.Exec(cmd, arg, { convert: isWindows })
const os = Plugins.useEnvStore().env.os
const cmd = {
windows: 'ipconfig',
linux: 'ip',
darwin: 'ifconfig'
}[os]
const arg = {
windows: [],
linux: ['a'],
darwin: []
}[os]
const text = await Plugins.Exec(cmd, arg, { convert: os === 'windows' })
const ipv4Pattern = /\b(?:\d{1,3}\.){3}\d{1,3}\b/g
let ips = text.match(ipv4Pattern) || []
ips.unshift('127.0.0.1')
Expand Down

0 comments on commit 3ab8ce1

Please sign in to comment.