修复激活时 sudo 无法从 stdin 获取密码的问题,改为管道传密并后台拉起注册工具。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -75,18 +75,31 @@ export function stopService(vm) {
|
||||
}
|
||||
|
||||
export function handleActive(vm) {
|
||||
const platform = vm.$platform || require('@/platform').default
|
||||
const activePath = getActivePath(platform)
|
||||
console.log('[激活] 点击前往激活, activePath=', activePath, 'appRoot=', platform.getAppRoot && platform.getAppRoot())
|
||||
vm.$prompt('请输入管理员密码并点击确定以前往激活设备', '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
inputType: 'password'
|
||||
})
|
||||
.then(({ value }) => {
|
||||
const activePath = getActivePath(vm.$platform || require('@/platform').default)
|
||||
vm.$runCmd(`bash "${activePath}" '${String(value).replace(/'/g, `'\\''`)}'`).catch((err) => {
|
||||
vm.$message({ message: err, type: 'error' })
|
||||
})
|
||||
// regist.sh 内 sudo -S 从 stdin 读密码;后台 & 会导致 stdin 为空(sudo: no password was provided)
|
||||
const pass = String(value).replace(/'/g, `'\\''`)
|
||||
const cmd = `( echo '${pass}' | bash ${activePath} '${pass}' ) &`
|
||||
console.log('[激活] 确认密码, len=', (value || '').length, 'cmd=', cmd)
|
||||
vm.$runCmd(cmd)
|
||||
.then((res) => {
|
||||
console.log('[激活] runCmd 成功', res)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('[激活] runCmd 失败', err)
|
||||
vm.$message({ message: err, type: 'error' })
|
||||
})
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log('[激活] 取消或关闭弹窗', e)
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
export function openWork(vm, platform) {
|
||||
|
||||
Reference in New Issue
Block a user