制作桌面端软件
This commit is contained in:
parent
1c696fa585
commit
9ca03ef0fe
13
electron/.gitignore
vendored
Normal file
13
electron/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
out
|
||||
dist
|
||||
node_modules
|
||||
.vscode-test/
|
||||
*.vsix
|
||||
.env
|
||||
resources
|
||||
.DS_Store
|
||||
.exe
|
||||
|
||||
.idea
|
||||
resources
|
||||
setting.json
|
7859
electron/package-lock.json
generated
Normal file
7859
electron/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
60
electron/package.json
Normal file
60
electron/package.json
Normal file
@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "openmcp-electron",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"build": "webpack --config webpack.config.js",
|
||||
"watch": "webpack --watch --config webpack.config.js",
|
||||
"dist": "electron-builder"
|
||||
},
|
||||
"author": {
|
||||
"name": "LSTM-Kirigaya",
|
||||
"email": "1193466151@qq.com"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.10.2",
|
||||
"axios": "^1.7.7",
|
||||
"bson": "^6.8.0",
|
||||
"openai": "^4.93.0",
|
||||
"pako": "^2.1.0",
|
||||
"sqlite": "^5.1.1",
|
||||
"sqlite3": "^5.1.7",
|
||||
"tesseract.js": "^6.0.1",
|
||||
"uuid": "^11.1.0",
|
||||
"ws": "^8.18.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ws": "^8.18.1",
|
||||
"electron": "^28.1.0",
|
||||
"electron-builder": "^26.0.12",
|
||||
"ts-loader": "^9.5.1",
|
||||
"typescript": "^5.6.3",
|
||||
"webpack": "^5.99.5",
|
||||
"webpack-cli": "^5.1.4"
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.example.openmcp",
|
||||
"productName": "OpenMCP",
|
||||
"directories": {
|
||||
"output": "dist"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"resources/**/*"
|
||||
],
|
||||
"mac": {
|
||||
"target": "dmg",
|
||||
"icon": "resources/icons/icon.icns"
|
||||
},
|
||||
"win": {
|
||||
"target": "nsis",
|
||||
"icon": "resources/icons/icon.ico"
|
||||
},
|
||||
"linux": {
|
||||
"target": "AppImage",
|
||||
"icon": "resources/icons/icon.png"
|
||||
}
|
||||
}
|
||||
}
|
56
electron/src/main.ts
Normal file
56
electron/src/main.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import { app, BrowserWindow } from 'electron';
|
||||
import WebSocket from 'ws';
|
||||
import * as OpenMCPService from '../resources/service';
|
||||
|
||||
let mainWindow: BrowserWindow
|
||||
|
||||
function createWindow(): void {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
})
|
||||
|
||||
mainWindow.loadFile('resources/renderer/index.html')
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
|
||||
const wss = new (WebSocket as any).Server({ port: 8080 });
|
||||
|
||||
wss.on('connection', (ws: any) => {
|
||||
|
||||
// 仿造 webview 进行统一接口访问
|
||||
const webview = new OpenMCPService.VSCodeWebViewLike(ws);
|
||||
|
||||
// 先发送成功建立的消息
|
||||
webview.postMessage({
|
||||
command: 'hello',
|
||||
data: {
|
||||
version: '0.0.1',
|
||||
name: '消息桥连接完成'
|
||||
}
|
||||
});
|
||||
|
||||
// 注册消息接受的管线
|
||||
webview.onDidReceiveMessage(message => {
|
||||
console.info(`command: [${message.command || 'No Command'}]`);
|
||||
|
||||
const { command, data } = message;
|
||||
OpenMCPService.routeMessage(command, data, webview);
|
||||
});
|
||||
});
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
|
||||
app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
15
electron/tsconfig.json
Normal file
15
electron/tsconfig.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES6",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"outDir": "./dist",
|
||||
"declaration": true,
|
||||
"declarationMap": true
|
||||
},
|
||||
"include": ["src/**/*.ts"], // 确保包含所有 .ts 文件
|
||||
"exclude": ["node_modules"]
|
||||
}
|
23
electron/webpack.config.js
Normal file
23
electron/webpack.config.js
Normal file
@ -0,0 +1,23 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
entry: './src/main.ts',
|
||||
output: {
|
||||
filename: 'main.js',
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js'],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts$/,
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
],
|
||||
},
|
||||
mode: 'production',
|
||||
target: 'electron-main',
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user