import * as vscode from "vscode"; import { AnswersWebview } from "../view/AnswersWebview"; import { instance } from "../service"; import { login, checkIsLogin } from "./login"; import {getDayId} from '../utils/getDayID'; export async function openAnswer( document: vscode.TextDocument, context: vscode.ExtensionContext ): Promise { try { const {name} = await checkIsLogin(); const dayId = getDayId(document.fileName); // const { hasSelfAnswer }: { hasSelfAnswer: boolean } = await instance.get( // `/api/searchHasSelfAnswer`, // { params: { gitId, dayId } } // ); // if (!hasSelfAnswer) { // vscode.window.showWarningMessage("提交自己的回答后才可以查看题解", { // modal: true, // }); // return; // } const answersWebview: AnswersWebview = new AnswersWebview(dayId); await answersWebview.init(name); answersWebview.show(); return; } catch (error) { vscode.window .showWarningMessage("请先点击此处登录", "登录") .then((result) => { if (result === "登录") { login(context); } }); } }