feat:实现了点击头像和用户名进行跳转到首页

这里还需要完善的地方:
- 跳转到Web端还需要进行登录,如果要自动登录
- 需要后端给个临时的授权码
- 这样就不用前端传递token然后自动登录了
- 避免了token暴露的风险
This commit is contained in:
Roe-xin
2026-01-17 10:48:05 +08:00
parent 5347425327
commit d90cca7cef
2 changed files with 50 additions and 2 deletions

View File

@ -350,6 +350,10 @@ export async function showICHelperPanel(
// 退出登录 // 退出登录
vscode.commands.executeCommand("ic-coder.logout"); vscode.commands.executeCommand("ic-coder.logout");
break; break;
case "openICCoder":
// 跳转到 IC Coder 官网
vscode.env.openExternal(vscode.Uri.parse("https://www.iccoder.com"));
break;
case "openUserManual": case "openUserManual":
// 打开用户手册 // 打开用户手册
vscode.env.openExternal(vscode.Uri.parse("https://www.iccoder.com")); vscode.env.openExternal(vscode.Uri.parse("https://www.iccoder.com"));

View File

@ -14,13 +14,13 @@ export function getUserInfoComponentContent(): string {
<div class="user-detail-dropdown" id="userDetailDropdown"> <div class="user-detail-dropdown" id="userDetailDropdown">
<div class="user-detail-content"> <div class="user-detail-content">
<div class="user-detail-header"> <div class="user-detail-header">
<div class="user-avatar-small"> <div class="user-avatar-small clickable" id="userAvatarClickable">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" fill="currentColor"/> <path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" fill="currentColor"/>
</svg> </svg>
</div> </div>
<div class="user-name-tier"> <div class="user-name-tier">
<div class="user-detail-name" id="userDetailName">加载中...</div> <div class="user-detail-name clickable" id="userDetailName">加载中...</div>
<img class="tier-icon-inline" id="tierIconInline" style="display: none;" /> <img class="tier-icon-inline" id="tierIconInline" style="display: none;" />
</div> </div>
</div> </div>
@ -103,6 +103,16 @@ export function getUserInfoComponentStyles(): string {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
box-shadow: 0 2px 8px rgba(0, 122, 204, 0.3); box-shadow: 0 2px 8px rgba(0, 122, 204, 0.3);
transition: all 0.2s ease;
}
.user-avatar-small.clickable {
cursor: pointer;
}
.user-avatar-small.clickable:hover {
transform: scale(1.1);
box-shadow: 0 4px 12px rgba(0, 122, 204, 0.5);
} }
.user-avatar-small svg { .user-avatar-small svg {
@ -122,6 +132,16 @@ export function getUserInfoComponentStyles(): string {
font-size: 14px; font-size: 14px;
font-weight: 600; font-weight: 600;
color: var(--vscode-foreground); color: var(--vscode-foreground);
transition: all 0.2s ease;
}
.user-detail-name.clickable {
cursor: pointer;
}
.user-detail-name.clickable:hover {
color: #007acc;
text-decoration: underline;
} }
.tier-icon-inline { .tier-icon-inline {
@ -248,6 +268,12 @@ export function getUserInfoComponentScript(): string {
vscode.postMessage({ command: 'logout' }); vscode.postMessage({ command: 'logout' });
} }
// 跳转到 IC Coder 官网
function openICCoder() {
console.log("跳转到 IC Coder 官网");
vscode.postMessage({ command: 'openICCoder' });
}
// 关闭用户详情下拉面板 // 关闭用户详情下拉面板
function closeUserDetailModal() { function closeUserDetailModal() {
const dropdown = document.getElementById('userDetailDropdown'); const dropdown = document.getElementById('userDetailDropdown');
@ -317,6 +343,24 @@ export function getUserInfoComponentScript(): string {
}); });
} }
// 绑定头像点击事件
const userAvatar = document.getElementById('userAvatarClickable');
if (userAvatar) {
userAvatar.addEventListener('click', (e) => {
e.stopPropagation();
openICCoder();
});
}
// 绑定用户名点击事件
const userName = document.getElementById('userDetailName');
if (userName) {
userName.addEventListener('click', (e) => {
e.stopPropagation();
openICCoder();
});
}
// 点击页面其他地方关闭下拉面板 // 点击页面其他地方关闭下拉面板
document.addEventListener('click', (e) => { document.addEventListener('click', (e) => {
const dropdown = document.getElementById('userDetailDropdown'); const dropdown = document.getElementById('userDetailDropdown');