feat: 从JWT解析userId并添加资源点余额提醒

- 新增 jwtUtils.ts 解析JWT token获取user_id
- dialogService 从登录session获取真实userId
- 添加 credit_update 事件处理
- 余额低于5点时弹窗提醒用户充值
- settings.ts 登录URL改为可配置
This commit is contained in:
XiaoFeng
2026-01-09 15:53:54 +08:00
parent 4037e9e2d7
commit 178f3a7498
6 changed files with 136 additions and 7 deletions

View File

@ -2,6 +2,7 @@ import * as vscode from "vscode";
import * as http from "http";
import * as path from "path";
import * as fs from "fs";
import { getConfig } from "../config/settings";
/**
* IC Coder Authentication Provider
@ -12,7 +13,6 @@ export class ICCoderAuthenticationProvider
{
private static readonly AUTH_TYPE = "iccoder";
private static readonly AUTH_NAME = "IC Coder";
private static readonly LOGIN_URL = "http://192.168.1.108:2005/login";
private static loginServer: http.Server | null = null;
private static currentPort: number | null = null;
@ -149,9 +149,8 @@ export class ICCoderAuthenticationProvider
// 构建登录 URL
const callbackUrl = `http://localhost:${port}/callback`;
const loginUrl = `${
ICCoderAuthenticationProvider.LOGIN_URL
}?redirect_uri=${encodeURIComponent(callbackUrl)}`;
const config = getConfig();
const loginUrl = `${config.loginUrl}?redirect_uri=${encodeURIComponent(callbackUrl)}`;
console.log("🔐 登录服务器已启动,监听端口:", port);
console.log("🌐 登录 URL:", loginUrl);