@fivetu53/soul-chat 1.0.1 → 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 +43 -2
- 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;
|
|
@@ -1026,6 +1035,38 @@ async function showMemories() {
|
|
|
1026
1035
|
|
|
1027
1036
|
// 主程序
|
|
1028
1037
|
async function main() {
|
|
1038
|
+
// 处理命令行参数
|
|
1039
|
+
const args = process.argv.slice(2);
|
|
1040
|
+
if (args[0] === 'update') {
|
|
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
|
+
|
|
1046
|
+
try {
|
|
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');
|
|
1058
|
+
} catch (err) {
|
|
1059
|
+
console.log(' 更新失败,请手动运行: npm update -g @fivetu53/soul-chat\n');
|
|
1060
|
+
}
|
|
1061
|
+
process.exit(0);
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
if (args[0] === 'version' || args[0] === '-v' || args[0] === '--version') {
|
|
1065
|
+
const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
1066
|
+
console.log(`Soul Chat v${pkg.version}`);
|
|
1067
|
+
process.exit(0);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1029
1070
|
process.on('SIGINT', () => {
|
|
1030
1071
|
cleanup();
|
|
1031
1072
|
process.exit();
|