parent
4c96f7ed21
commit
cc1eef5dff
@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Cat Coding</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script src="$ROOT/settings.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
const body = document.body;
|
||||||
|
body.append('ABC');
|
||||||
|
console.log('ok');
|
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as vscode from 'vscode';
|
||||||
|
import { loadConfigs } from './config';
|
||||||
|
|
||||||
|
let webviewPanel: vscode.WebviewPanel | undefined;
|
||||||
|
|
||||||
|
export function open(extensionPath: string) {
|
||||||
|
if (!webviewPanel) {
|
||||||
|
webviewPanel = vscode.window.createWebviewPanel('sshfs-settings', 'SSH-FS Settings', vscode.ViewColumn.One, { enableScripts: true });
|
||||||
|
webviewPanel.onDidDispose(() => webviewPanel = undefined);
|
||||||
|
webviewPanel.webview.onDidReceiveMessage(handleMessage);
|
||||||
|
const content = fs.readFileSync(path.resolve(extensionPath, 'resources/settings.html')).toString();
|
||||||
|
webviewPanel.webview.html = content.replace(/\$ROOT/g, vscode.Uri.file(path.join(extensionPath, 'resources')).with({ scheme: 'vscode-resource' }).toString());
|
||||||
|
}
|
||||||
|
webviewPanel.reveal();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RequestDataMessage {
|
||||||
|
type: 'requestData';
|
||||||
|
}
|
||||||
|
type Message = { type: 'requestData' } | RequestDataMessage;
|
||||||
|
|
||||||
|
async function handleMessage(message: Message): Promise<any> {
|
||||||
|
switch (message.type) {
|
||||||
|
case 'requestData': {
|
||||||
|
return webviewPanel!.webview.postMessage(await loadConfigs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue