diff --git a/CHANGELOG.md b/CHANGELOG.md
index c032a59..7e93ad7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,11 +2,8 @@
All notable changes to the "cyezoi" extension will be documented in this file.
-## v0.0.17
+## v0.0.18
-- **Add keybindings to submit and open problem**
-- **Add refresh button to webview**
-- Fix the issue of displaying the relative time
-- Enhance login experience
+- Emergency fix for webview
Want to see the previous log? [Click here](https://github.com/CYEZOI/cyezoi-helper/commits/main/CHANGELOG.md)
diff --git a/package.json b/package.json
index 118d69c..83b6de5 100644
--- a/package.json
+++ b/package.json
@@ -181,8 +181,12 @@
}
},
{
- "command": "attendC",
- "title": "CYEZOI: Attend Contest"
+ "command": "cyezoi.attendC",
+ "title": "CYEZOI: Attend Contest",
+ "icon": {
+ "light": "res/icons/plus-light.svg",
+ "dark": "res/icons/plus-dark.svg"
+ }
},
{
"command": "cyezoi.refreshRTree",
@@ -223,6 +227,11 @@
"command": "cyezoi.submitProblem",
"when": "viewItem == problem",
"group": "inline"
+ },
+ {
+ "command": "cyezoi.attendC",
+ "when": "viewItem == contest",
+ "group": "inline"
}
],
"view/title": [
diff --git a/res/icons/plus-dark.svg b/res/icons/plus-dark.svg
new file mode 100644
index 0000000..6850114
--- /dev/null
+++ b/res/icons/plus-dark.svg
@@ -0,0 +1,3 @@
+
diff --git a/res/icons/plus-light.svg b/res/icons/plus-light.svg
new file mode 100644
index 0000000..25404dc
--- /dev/null
+++ b/res/icons/plus-light.svg
@@ -0,0 +1,3 @@
+
diff --git a/src/cTree.ts b/src/cTree.ts
index 262ae5d..da4f895 100644
--- a/src/cTree.ts
+++ b/src/cTree.ts
@@ -76,8 +76,8 @@ export default class implements vscode.TreeDataProvider {
}
export class Contest extends vscode.TreeItem {
- constructor(tdoc: utils.ContestDoc, showProblem: boolean) {
- super(tdoc.title, showProblem ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None);
+ constructor(tdoc: utils.ContestDoc, attended: boolean) {
+ super(tdoc.title, vscode.TreeItemCollapsibleState.Collapsed);
this.id = tdoc._id;
this.contextValue = 'contest';
this.description = utils.toTime(new Date(tdoc.endAt).getTime() - new Date(tdoc.beginAt).getTime());
@@ -89,13 +89,12 @@ export class Contest extends vscode.TreeItem {
tooltipDoc.appendMarkdown(`- **Rated**: ${tdoc.rated ? 'Yes' : 'No'}\n`);
tooltipDoc.appendMarkdown(`- **Allow View Code**: ${tdoc.allowViewCode ? 'Yes' : 'No'}\n`);
this.tooltip = tooltipDoc;
- if (showProblem) {
- this.command = {
- command: 'cyezoi.openC',
- title: 'Open Contest',
- arguments: [tdoc._id],
- };
- } else {
+ this.command = {
+ command: 'cyezoi.openC',
+ title: 'Open Contest',
+ arguments: [tdoc._id],
+ };
+ if (attended) {
this.command = {
command: 'cyezoi.attendC',
title: 'Attend Contest',
diff --git a/src/cWeb.ts b/src/cWeb.ts
index 4760829..63f4a55 100644
--- a/src/cWeb.ts
+++ b/src/cWeb.ts
@@ -51,7 +51,7 @@ export default class {
const staticFiles = [
{ 'path': ['res', 'libs', 'vscode-elements', 'bundled.js'], attributes: { 'type': 'module' } },
{ 'path': ['res', 'libs', 'codicon', 'codicon.css'], attributes: { 'id': 'vscode-codicon-stylesheet' } },
- { 'path': ['src', 'utils.js'] },
+ { 'path': ['res', 'html', 'static.js'] },
{ 'path': ['res', 'html', 'contest.js'] },
];
let recordHtml = path.join(this._extensionPath, 'res', 'html', 'contest.html');
diff --git a/src/extension.ts b/src/extension.ts
index 19bb5e2..ea5ff08 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -176,19 +176,30 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.commands.executeCommand('cyezoi.openT', rid);
}
}));
- disposables.push(vscode.commands.registerCommand('cyezoi.attendC', async (tid: string | undefined) => {
+ disposables.push(vscode.commands.registerCommand('cyezoi.attendC', async (tid: vscode.TreeItem | string | undefined) => {
+ if (tid instanceof vscode.TreeItem) {
+ const args = tid.command?.arguments;
+ if (args && args[Symbol.iterator]) {
+ [tid] = args;
+ }
+ }
if (tid === undefined) {
tid = await io.input('Please input the contest ID');
if (tid === undefined) {
return;
}
};
- await new fetch({
- path: `/d/${settings.domain}/contest/${tid}`, addCookie: true,
- body: {
- "operation": "attend",
- },
- }).start();
+ try {
+ await new fetch({
+ path: `/d/${settings.domain}/contest/${tid}`, addCookie: true,
+ body: {
+ "operation": "attend",
+ },
+ }).start();
+ } catch (e) {
+ io.error((e as Error).message);
+ return;
+ }
io.info('Contest attended');
vscode.commands.executeCommand('cyezoi.refreshCTree');
}));
diff --git a/src/pWeb.ts b/src/pWeb.ts
index b02ad7d..045a619 100644
--- a/src/pWeb.ts
+++ b/src/pWeb.ts
@@ -61,7 +61,7 @@ export default class {
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'fold', 'indent-fold.min.js'] },
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'section', 'active-line.min.js'] },
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'display', 'autorefresh.min.js'] },
- { 'path': ['src', 'utils.js'] },
+ { 'path': ['res', 'html', 'static.js'] },
{ 'path': ['res', 'html', 'problem.css'] },
{ 'path': ['res', 'html', 'problem.js'] },
];
diff --git a/src/rWeb.ts b/src/rWeb.ts
index 8cbf2f3..9ab096d 100644
--- a/src/rWeb.ts
+++ b/src/rWeb.ts
@@ -59,7 +59,7 @@ export default class {
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'fold', 'indent-fold.min.js'] },
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'section', 'active-line.min.js'] },
{ 'path': ['res', 'libs', 'codemirror', 'addon', 'display', 'autorefresh.min.js'] },
- { 'path': ['src', 'utils.js'] },
+ { 'path': ['res', 'html', 'static.js'] },
{ 'path': ['res', 'html', 'record.css'] },
{ 'path': ['res', 'html', 'record.js'] },
];