@fivetu53/soul-chat 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +28 -6
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -121,8 +121,17 @@ end try`;
|
|
|
121
121
|
if (result !== 'ok') return null;
|
|
122
122
|
} else if (process.platform === 'win32') {
|
|
123
123
|
// Windows: 用 PowerShell 导出剪贴板图片
|
|
124
|
-
|
|
125
|
-
const
|
|
124
|
+
// 使用单引号包裹路径,避免转义问题
|
|
125
|
+
const psScript = `
|
|
126
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
127
|
+
$img = [System.Windows.Forms.Clipboard]::GetImage()
|
|
128
|
+
if ($img) {
|
|
129
|
+
$img.Save('${tmpFile.replace(/\\/g, '/')}', [System.Drawing.Imaging.ImageFormat]::Png)
|
|
130
|
+
Write-Output 'ok'
|
|
131
|
+
} else {
|
|
132
|
+
Write-Output 'no'
|
|
133
|
+
}`;
|
|
134
|
+
const result = execSync(`powershell -NoProfile -ExecutionPolicy Bypass -Command "${psScript.replace(/"/g, '\\"').replace(/\n/g, ' ')}"`, { encoding: 'utf8', windowsHide: true }).trim();
|
|
126
135
|
if (result !== 'ok') return null;
|
|
127
136
|
} else {
|
|
128
137
|
return null;
|
|
@@ -1029,12 +1038,25 @@ async function main() {
|
|
|
1029
1038
|
// 处理命令行参数
|
|
1030
1039
|
const args = process.argv.slice(2);
|
|
1031
1040
|
if (args[0] === 'update') {
|
|
1032
|
-
|
|
1041
|
+
const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
1042
|
+
const currentVersion = pkg.version;
|
|
1043
|
+
console.log(`\n 当前版本: v${currentVersion}`);
|
|
1044
|
+
console.log(' 检查更新中...\n');
|
|
1045
|
+
|
|
1033
1046
|
try {
|
|
1034
|
-
execSync('npm
|
|
1035
|
-
|
|
1047
|
+
const latestVersion = execSync('npm view @fivetu53/soul-chat version --registry https://registry.npmjs.org', { encoding: 'utf8' }).trim();
|
|
1048
|
+
|
|
1049
|
+
if (latestVersion === currentVersion) {
|
|
1050
|
+
console.log(' ✓ 已是最新版本\n');
|
|
1051
|
+
process.exit(0);
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
console.log(` 发现新版本: v${latestVersion}`);
|
|
1055
|
+
console.log(' 正在更新...\n');
|
|
1056
|
+
execSync('npm update -g @fivetu53/soul-chat --registry https://registry.npmjs.org', { stdio: 'inherit' });
|
|
1057
|
+
console.log('\n ✓ 更新完成!\n');
|
|
1036
1058
|
} catch (err) {
|
|
1037
|
-
console.log('
|
|
1059
|
+
console.log(' 更新失败,请手动运行: npm update -g @fivetu53/soul-chat\n');
|
|
1038
1060
|
}
|
|
1039
1061
|
process.exit(0);
|
|
1040
1062
|
}
|