将logo替换成devstar的logo
This commit is contained in:
24
src/home.ts
24
src/home.ts
@@ -1,5 +1,6 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import RemoteContainer from './remote-container';
|
||||
import User from './user';
|
||||
import * as utils from './utils'
|
||||
@@ -66,10 +67,13 @@ export default class DSHome {
|
||||
{
|
||||
enableScripts: true,
|
||||
retainContextWhenHidden: true,
|
||||
localResourceRoots: [
|
||||
vscode.Uri.file(path.join(this.context.extensionPath, 'assets'))
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
panel.webview.html = await this.getWebviewContent();
|
||||
panel.webview.html = await this.getWebviewContent(panel);
|
||||
|
||||
panel.webview.onDidReceiveMessage(
|
||||
async (message) => {
|
||||
@@ -188,7 +192,16 @@ export default class DSHome {
|
||||
this.context.subscriptions.push(panel);
|
||||
}
|
||||
|
||||
async getWebviewContent(): Promise<string> {
|
||||
async getWebviewContent(panel?: vscode.WebviewPanel): Promise<string> {
|
||||
// 获取图片的 Webview URI
|
||||
let logoUri = '';
|
||||
if (panel) {
|
||||
const logoPath = vscode.Uri.file(
|
||||
path.join(this.context.extensionPath, 'assets', 'images', 'logo.png')
|
||||
);
|
||||
logoUri = panel.webview.asWebviewUri(logoPath).toString();
|
||||
}
|
||||
|
||||
return `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@@ -208,6 +221,11 @@ export default class DSHome {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.logo {
|
||||
width: auto;
|
||||
height: 30px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.feature-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
@@ -244,7 +262,7 @@ export default class DSHome {
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>🚀 DevStar Home</h1>
|
||||
${logoUri ? `<img src="${logoUri}" alt="DevStar Logo" class="logo">` : '🚀'}
|
||||
<p>欢迎使用 DevStar 扩展</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -146,7 +146,9 @@ export class DevStarExtension {
|
||||
this.dsHome.setDevstarDomainAndHomePageURL(devstarDomain)
|
||||
this.dsHome.setUser(this.user)
|
||||
this.dsHome.setRemoteContainer(this.remoteContainer)
|
||||
vscode.commands.executeCommand('devstar.showHome');
|
||||
|
||||
//防止进入HOME页面
|
||||
// vscode.commands.executeCommand('devstar.showHome');
|
||||
|
||||
// 将devstar domain存在global state中
|
||||
context.globalState.update('devstarDomain', devstarDomain)
|
||||
|
||||
Reference in New Issue
Block a user