feat:获取会员信息 并且展示title

This commit is contained in:
Roe-xin
2026-01-09 16:24:27 +08:00
parent 940584e1ea
commit c58e3603de
9 changed files with 205 additions and 4 deletions

View File

@ -20,6 +20,37 @@ import { ChatHistoryManager } from "../utils/chatHistoryManager";
import { MessageType } from "../types/chatHistory";
import { getCachedUserInfo } from "../services/userService";
/**
* 获取会员等级图标 URI
*/
function getTierIconUri(
webview: vscode.Webview,
context: vscode.ExtensionContext,
tierCode?: string
): string | undefined {
if (!tierCode) {
return undefined;
}
const tierIconMap: Record<string, string> = {
'BASIC': 'free.png',
'TRIAL': 'PRO-Try.png',
'ADVANCED': 'PRO.png',
'PROFESSIONAL': 'PRO+.png'
};
const iconFile = tierIconMap[tierCode];
if (!iconFile) {
return undefined;
}
const iconUri = webview.asWebviewUri(
vscode.Uri.joinPath(context.extensionUri, 'src', 'assets', 'titleIcon', iconFile)
);
return iconUri.toString();
}
/**
* 创建并显示 IC 助手面板
*/
@ -117,13 +148,15 @@ export async function showICHelperPanel(
if (userInfo) {
// 使用缓存的用户信息
console.log('[ICHelperPanel] 使用缓存的用户信息:', userInfo);
const tierIconUrl = getTierIconUri(panel.webview, context, userInfo.membership?.tierCode);
panel.webview.postMessage({
command: 'updateUserInfo',
userInfo: {
userId: userInfo.userId,
nickname: userInfo.nickname,
username: userInfo.username
}
},
tierIconUrl: tierIconUrl
});
} else {
// 如果没有缓存,从 session 中获取