@fivetu53/soul-chat 1.0.0 → 1.0.2
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 +26 -3
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -98,7 +98,11 @@ const showCursor = () => process.stdout.write('\x1b[?25h');
|
|
|
98
98
|
|
|
99
99
|
// 获取剪贴板图片 (跨平台)
|
|
100
100
|
function getClipboardImage() {
|
|
101
|
-
const
|
|
101
|
+
const os = require('os');
|
|
102
|
+
const tmpDir = os.tmpdir();
|
|
103
|
+
const tmpFile = process.platform === 'win32'
|
|
104
|
+
? `${tmpDir}\\soul_clipboard.png`
|
|
105
|
+
: `${tmpDir}/soul_clipboard.png`;
|
|
102
106
|
|
|
103
107
|
try {
|
|
104
108
|
if (process.platform === 'darwin') {
|
|
@@ -117,8 +121,8 @@ end try`;
|
|
|
117
121
|
if (result !== 'ok') return null;
|
|
118
122
|
} else if (process.platform === 'win32') {
|
|
119
123
|
// Windows: 用 PowerShell 导出剪贴板图片
|
|
120
|
-
const ps =
|
|
121
|
-
const result = execSync(`powershell -Command "${ps}"`, { encoding: 'utf8' }).trim();
|
|
124
|
+
const ps = `Add-Type -AssemblyName System.Windows.Forms; $img = [System.Windows.Forms.Clipboard]::GetImage(); if ($img) { $img.Save('${tmpFile.replace(/\\/g, '\\\\')}'); 'ok' } else { 'no' }`;
|
|
125
|
+
const result = execSync(`powershell -Command "${ps}"`, { encoding: 'utf8', windowsHide: true }).trim();
|
|
122
126
|
if (result !== 'ok') return null;
|
|
123
127
|
} else {
|
|
124
128
|
return null;
|
|
@@ -1022,6 +1026,25 @@ async function showMemories() {
|
|
|
1022
1026
|
|
|
1023
1027
|
// 主程序
|
|
1024
1028
|
async function main() {
|
|
1029
|
+
// 处理命令行参数
|
|
1030
|
+
const args = process.argv.slice(2);
|
|
1031
|
+
if (args[0] === 'update') {
|
|
1032
|
+
console.log('\n 正在更新 Soul Chat...\n');
|
|
1033
|
+
try {
|
|
1034
|
+
execSync('npm update -g @fivetu53/soul-chat', { stdio: 'inherit' });
|
|
1035
|
+
console.log('\n 更新完成!\n');
|
|
1036
|
+
} catch (err) {
|
|
1037
|
+
console.log('\n 更新失败,请手动运行: npm update -g @fivetu53/soul-chat\n');
|
|
1038
|
+
}
|
|
1039
|
+
process.exit(0);
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
if (args[0] === 'version' || args[0] === '-v' || args[0] === '--version') {
|
|
1043
|
+
const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
1044
|
+
console.log(`Soul Chat v${pkg.version}`);
|
|
1045
|
+
process.exit(0);
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1025
1048
|
process.on('SIGINT', () => {
|
|
1026
1049
|
cleanup();
|
|
1027
1050
|
process.exit();
|