@fivetu53/soul-chat 1.0.3 → 1.0.6
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 +6 -14
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import readline from 'readline';
|
|
4
4
|
import { execSync } from 'child_process';
|
|
5
5
|
import fs from 'fs';
|
|
6
|
+
import os from 'os';
|
|
6
7
|
import { Marked } from 'marked';
|
|
7
8
|
import { markedTerminal } from 'marked-terminal';
|
|
8
9
|
import { loadConfig, saveConfig, getConfigPath } from './config.js';
|
|
@@ -98,7 +99,6 @@ const showCursor = () => process.stdout.write('\x1b[?25h');
|
|
|
98
99
|
|
|
99
100
|
// 获取剪贴板图片 (跨平台)
|
|
100
101
|
function getClipboardImage() {
|
|
101
|
-
const os = require('os');
|
|
102
102
|
const tmpDir = os.tmpdir();
|
|
103
103
|
const tmpFile = process.platform === 'win32'
|
|
104
104
|
? `${tmpDir}\\soul_clipboard.png`
|
|
@@ -121,17 +121,9 @@ end try`;
|
|
|
121
121
|
if (result !== 'ok') return null;
|
|
122
122
|
} else if (process.platform === 'win32') {
|
|
123
123
|
// Windows: 用 PowerShell 导出剪贴板图片
|
|
124
|
-
|
|
125
|
-
const psScript = `
|
|
126
|
-
|
|
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();
|
|
124
|
+
const savePath = tmpFile.replace(/\\/g, '/');
|
|
125
|
+
const psScript = `Add-Type -AssemblyName System.Windows.Forms; $img = [System.Windows.Forms.Clipboard]::GetImage(); if ($img) { $img.Save('${savePath}', [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'no' }`;
|
|
126
|
+
const result = execSync(`powershell -NoProfile -ExecutionPolicy Bypass -Command "${psScript}"`, { encoding: 'utf8', windowsHide: true }).trim();
|
|
135
127
|
if (result !== 'ok') return null;
|
|
136
128
|
} else {
|
|
137
129
|
return null;
|
|
@@ -1044,7 +1036,7 @@ async function main() {
|
|
|
1044
1036
|
console.log(' 检查更新中...\n');
|
|
1045
1037
|
|
|
1046
1038
|
try {
|
|
1047
|
-
const latestVersion = execSync('npm view @fivetu53/soul-chat version --registry https://registry.
|
|
1039
|
+
const latestVersion = execSync('npm view @fivetu53/soul-chat version --registry https://registry.npmmirror.com', { encoding: 'utf8' }).trim();
|
|
1048
1040
|
|
|
1049
1041
|
if (latestVersion === currentVersion) {
|
|
1050
1042
|
console.log(' ✓ 已是最新版本\n');
|
|
@@ -1053,7 +1045,7 @@ async function main() {
|
|
|
1053
1045
|
|
|
1054
1046
|
console.log(` 发现新版本: v${latestVersion}`);
|
|
1055
1047
|
console.log(' 正在更新...\n');
|
|
1056
|
-
execSync('npm update -g @fivetu53/soul-chat --registry https://registry.
|
|
1048
|
+
execSync('npm update -g @fivetu53/soul-chat --registry https://registry.npmmirror.com', { stdio: 'inherit' });
|
|
1057
1049
|
console.log('\n ✓ 更新完成!\n');
|
|
1058
1050
|
} catch (err) {
|
|
1059
1051
|
console.log(' 更新失败,请手动运行: npm update -g @fivetu53/soul-chat\n');
|