修改 about 页面
This commit is contained in:
parent
859d506ea9
commit
3b1afa70bd
@ -6,5 +6,6 @@ mkdir -p ./resources
|
|||||||
|
|
||||||
(cd ./renderer && npm run build && mv ./dist ../resources/renderer) &
|
(cd ./renderer && npm run build && mv ./dist ../resources/renderer) &
|
||||||
(cd ./service && npm run build && mv ./dist ../resources/service) &
|
(cd ./service && npm run build && mv ./dist ../resources/service) &
|
||||||
|
|
||||||
wait
|
wait
|
||||||
echo "finish building services in ./resources"
|
echo "finish building services in ./resources"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
cd renderer && npm i && cd ..
|
cd renderer && npm i && cd ..
|
||||||
cd service && npm i && node patch-mcp-sdk.js && cd ..
|
cd service && npm i && node patch-mcp-sdk.js && cd ..
|
||||||
|
cd servers && uv sync
|
||||||
npm i
|
npm i
|
@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="about-container">
|
<div class="about-container">
|
||||||
|
|
||||||
<span class="openmcp-logo" style="height: 230px; width: 230px;">
|
<span class="about-icon-container">
|
||||||
|
<span class="iconfont icon-openmcp"></span>
|
||||||
|
<span>openmcp</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -19,6 +21,8 @@
|
|||||||
<p>
|
<p>
|
||||||
如果感兴趣,欢迎加入我们的QQ群和我们讨论
|
如果感兴趣,欢迎加入我们的QQ群和我们讨论
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<div style="display: inline-flex;">
|
||||||
<el-button
|
<el-button
|
||||||
class="join-qq"
|
class="join-qq"
|
||||||
type="primary"
|
type="primary"
|
||||||
@ -27,6 +31,15 @@
|
|||||||
<span class="iconfont icon-QQ"></span>
|
<span class="iconfont icon-QQ"></span>
|
||||||
加入 OpenMCP 技术群
|
加入 OpenMCP 技术群
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button type="primary"
|
||||||
|
class="join-qq"
|
||||||
|
@click="gotoWebsite('https://zhuanlan.zhihu.com/p/1894785817186121106')"
|
||||||
|
>
|
||||||
|
<span class="iconfont icon-send"></span>
|
||||||
|
OpenMCP 发布页
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -39,6 +52,10 @@ function joinQQGroup(url: string) {
|
|||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gotoWebsite(url: string) {
|
||||||
|
window.open(url, '_blank');
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -51,6 +68,23 @@ function joinQQGroup(url: string) {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.about-icon-container {
|
||||||
|
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.3);
|
||||||
|
border-radius: .8em;
|
||||||
|
padding: 20px 50px;
|
||||||
|
color: var(--main-color);
|
||||||
|
background-color: var(--background);
|
||||||
|
display: flex;
|
||||||
|
font-size: 30px;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.about-icon-container .iconfont {
|
||||||
|
font-size: 180px;
|
||||||
|
}
|
||||||
|
|
||||||
.about-container > span > img {
|
.about-container > span > img {
|
||||||
height: 150px;
|
height: 150px;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
|
@ -3,26 +3,8 @@ import * as fs from 'fs';
|
|||||||
import * as fspath from 'path';
|
import * as fspath from 'path';
|
||||||
|
|
||||||
import * as OpenMCPService from '../resources/service';
|
import * as OpenMCPService from '../resources/service';
|
||||||
|
import { getLaunchCWD, getWebviewContent } from './webview';
|
||||||
function getWebviewContent(context: vscode.ExtensionContext, panel: vscode.WebviewPanel): string | undefined {
|
import { panels } from './global';
|
||||||
const viewRoot = fspath.join(context.extensionPath, 'resources', 'renderer');
|
|
||||||
const htmlIndexPath = fspath.join(viewRoot, 'index.html');
|
|
||||||
const html = fs.readFileSync(htmlIndexPath, { encoding: 'utf-8' })?.replace(/(<link.+?href="|<script.+?src="|<img.+?src=")(.+?)"/g, (m, $1, $2) => {
|
|
||||||
const absLocalPath = fspath.resolve(viewRoot, $2);
|
|
||||||
const webviewUri = panel.webview.asWebviewUri(vscode.Uri.file(absLocalPath));
|
|
||||||
|
|
||||||
const replaceHref = $1 + webviewUri?.toString() + '"';
|
|
||||||
return replaceHref;
|
|
||||||
});
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLaunchCWD(context: vscode.ExtensionContext, uri: vscode.Uri) {
|
|
||||||
// TODO: 启动上下文?
|
|
||||||
// 获取当前打开的项目的路径
|
|
||||||
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
|
|
||||||
return workspaceFolder?.uri.fsPath || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
console.log('activate openmcp');
|
console.log('activate openmcp');
|
||||||
@ -37,6 +19,12 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
context.subscriptions.push(
|
context.subscriptions.push(
|
||||||
vscode.commands.registerCommand('openmcp.showOpenMCP', async (uri: vscode.Uri) => {
|
vscode.commands.registerCommand('openmcp.showOpenMCP', async (uri: vscode.Uri) => {
|
||||||
|
|
||||||
|
if (panels.has(uri.fsPath)) {
|
||||||
|
const panel = panels.get(uri.fsPath);
|
||||||
|
panel?.reveal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const panel = vscode.window.createWebviewPanel(
|
const panel = vscode.window.createWebviewPanel(
|
||||||
'OpenMCP',
|
'OpenMCP',
|
||||||
'OpenMCP',
|
'OpenMCP',
|
||||||
@ -48,6 +36,8 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
panels.set(uri.fsPath, panel);
|
||||||
|
|
||||||
const cwd = getLaunchCWD(context, uri);
|
const cwd = getLaunchCWD(context, uri);
|
||||||
// 获取 uri 相对于 cwd 的路径
|
// 获取 uri 相对于 cwd 的路径
|
||||||
const relativePath = fspath.relative(cwd, uri.fsPath);
|
const relativePath = fspath.relative(cwd, uri.fsPath);
|
||||||
@ -93,7 +83,11 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
panel.onDidDispose(() => {
|
panel.onDidDispose(async () => {
|
||||||
|
// 删除
|
||||||
|
panels.delete(uri.fsPath);
|
||||||
|
|
||||||
|
// 退出
|
||||||
panel.dispose();
|
panel.dispose();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
4
src/global.ts
Normal file
4
src/global.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
export type FsPath = string;
|
||||||
|
export const panels = new Map<FsPath, vscode.WebviewPanel>();
|
23
src/webview.ts
Normal file
23
src/webview.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as fspath from 'path';
|
||||||
|
|
||||||
|
export function getWebviewContent(context: vscode.ExtensionContext, panel: vscode.WebviewPanel): string | undefined {
|
||||||
|
const viewRoot = fspath.join(context.extensionPath, 'resources', 'renderer');
|
||||||
|
const htmlIndexPath = fspath.join(viewRoot, 'index.html');
|
||||||
|
const html = fs.readFileSync(htmlIndexPath, { encoding: 'utf-8' })?.replace(/(<link.+?href="|<script.+?src="|<img.+?src=")(.+?)"/g, (m, $1, $2) => {
|
||||||
|
const absLocalPath = fspath.resolve(viewRoot, $2);
|
||||||
|
const webviewUri = panel.webview.asWebviewUri(vscode.Uri.file(absLocalPath));
|
||||||
|
|
||||||
|
const replaceHref = $1 + webviewUri?.toString() + '"';
|
||||||
|
return replaceHref;
|
||||||
|
});
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLaunchCWD(context: vscode.ExtensionContext, uri: vscode.Uri) {
|
||||||
|
// TODO: 启动上下文?
|
||||||
|
// 获取当前打开的项目的路径
|
||||||
|
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
|
||||||
|
return workspaceFolder?.uri.fsPath || '';
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user