@fivetu53/soul-chat 1.0.0 → 1.0.1
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 +7 -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;
|