Skip to content

Commit 69a0ddc

Browse files
committed
ui: add builtin quick commands
1 parent b2e3ca4 commit 69a0ddc

14 files changed

Lines changed: 127 additions & 78 deletions

File tree

build.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ const nopMap = '//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIj
3838
plugins: [{
3939
name: 'base16384',
4040
setup(b) {
41-
b.onLoad({ filter: /\.(frontend|ttf|wasm)$/, namespace: 'file' }, (t) => {
42-
const file = fs.readFileSync(path.join(t.path));
43-
const contents = `module.exports = "${process.argv.includes('--no-binary') ? '' : encodeBinary(file)}";\n${nopMap}`;
41+
b.onLoad({ filter: /\.(frontend|ttf|wasm|sh)$/, namespace: 'file' }, (t) => {
42+
const contents = `module.exports = ${process.argv.includes('--use-readfile')
43+
? `require('fs').readFileSync('${t.path}')`
44+
: `"${encodeBinary(fs.readFileSync(t.path))}"`};\n${nopMap}`;
4445
console.log(t.path, size(contents));
4546
return {
4647
contents,

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
"@hydrooj/utils": "^1.4.37",
2222
"@neutralinojs/neu": "^11.6.0",
2323
"@types/lodash": "^4.17.20",
24-
"@types/node": "^20.19.23",
25-
"@yao-pkg/pkg": "^6.9.0",
26-
"chardet": "^2.1.0",
24+
"@types/node": "^20.19.24",
25+
"@yao-pkg/pkg": "^6.10.1",
26+
"chardet": "^2.1.1",
2727
"dejavu-fonts-ttf": "^2.37.3",
28-
"eslint": "^9.38.0",
28+
"eslint": "^9.39.1",
2929
"eslint-import-resolver-typescript": "^4.4.4",
3030
"iconv-lite": "^0.6.3",
3131
"lodash": "^4.17.21",

packages/machine-setup/frontend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
},
1111
"dependencies": {
1212
"@neutralinojs/lib": "^6.3.0",
13-
"vue": "^3.5.22"
13+
"vue": "^3.5.24"
1414
},
1515
"devDependencies": {
1616
"@vitejs/plugin-vue": "^6.0.1",
1717
"naive-ui": "^2.43.1",
1818
"typescript": "5.8.3",
19-
"vite": "^7.1.12",
19+
"vite": "^7.2.2",
2020
"vue-tsc": "^2.2.12"
2121
}
2222
}

packages/server/handler/commands.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,6 @@ class CommandsHandler extends AuthHandler {
6060
result: result.map((i) => (i.status === 'fulfilled' ? i.value : i.reason)),
6161
};
6262
}
63-
64-
async postShowIds() {
65-
this.response.body = await this.executeForAll(`
66-
export ISAUTOLOGIN=$(cat /etc/gdm3/custom.conf | grep AutomaticLoginEnable | grep true)
67-
if [ -z "$ISAUTOLOGIN" ]; then
68-
export DISPLAY=:1
69-
else
70-
export DISPLAY=:0
71-
fi
72-
export XAUTHORITY=/run/user/1000/gdm/Xauthority
73-
zenity --info --text "<span font='256'>$(cat /etc/hostname)</span>"`);
74-
}
75-
76-
async postAutologin({ }, autologin = false) {
77-
this.response.body = await this.executeForAll(`
78-
cp /etc/gdm3/custom-${autologin ? 'autologin' : 'nologin'}.conf /etc/gdm3/custom.conf
79-
systemctl restart gdm`);
80-
}
81-
82-
async postReboot() {
83-
this.response.body = await this.executeForAll('reboot');
84-
}
8563
}
8664

8765
export async function apply(ctx: Context) {

packages/server/utils/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export function StaticHTML(context, randomHash) {
2222
return `<html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>@Hydro/XCPC-TOOLS</title></head><body><div id="root"></div><script>window.Context=JSON.parse('${JSON.stringify(context).replace(/\\/g, '\\\\').replace(/'/g, '\\\'')}')</script><script src="/main.js?${randomHash}"></script></body></html>`;
2323
}
2424

25-
export function decodeBinary(file: string, name: string) {
26-
if (process.env.NODE_ENV === 'development') return Buffer.from(file, 'base64');
25+
export function decodeBinary(file: string | Buffer, name: string) {
26+
if (process.env.NODE_ENV === 'development') return Buffer.from(file as string, 'base64');
2727
if ('Deno' in globalThis) return globalThis.Deno.readFileSync(name);
28-
const buf = decode(file);
29-
return gunzipSync(buf);
28+
if (typeof file === 'string') return gunzipSync(decode(file));
29+
return file;
3030
}
3131

3232
export * from './commandRunner';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 自动登录到桌面,并设置桌面背景为纯色
2+
3+
cat >/etc/gdm3/custom.conf << EOF123
4+
[daemon]
5+
AutomaticLoginEnable=true
6+
AutomaticLogin=icpc
7+
8+
[security]
9+
10+
[xdmcp]
11+
12+
[chooser]
13+
14+
[debug]
15+
16+
EOF123
17+
18+
convert -size 1920x1080 xc:white /var/lib/icpc/desktop-background.png
19+
systemctl restart gdm3
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 启动 firefox
2+
3+
cat >/etc/default/domjudge-firefox << EOF123
4+
DISPLAY=:0
5+
EOF123
6+
7+
cat >/usr/lib/systemd/system/domjudge-firefox.service << EOF123
8+
[Unit]
9+
Description=DOMJUDGE FIREFOX
10+
11+
[Service]
12+
Type=simple
13+
EnvironmentFile=-/etc/default/domjudge-firefox
14+
ExecStart=/usr/bin/firefox-esr
15+
16+
EOF123
17+
18+
systemctl daemon-reload
19+
systemctl restart domjudge-firefox

packages/ui/app/commands/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import desktopBackground from './desktop-background.sh?raw';
2+
import domjudgeFirefox from './domjudge-firefox.sh?raw';
3+
4+
export { desktopBackground, domjudgeFirefox };

packages/ui/app/components/ArenaView.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ import {
1818
Tooltip,
1919
useMantineTheme,
2020
} from '@mantine/core';
21+
import { notifications } from '@mantine/notifications';
2122
import {
2223
IconAlertTriangle,
23-
IconRouter,
2424
IconInfoCircle,
25+
IconRouter,
2526
IconTrash,
2627
IconUpload,
2728
IconWifi,
@@ -30,7 +31,6 @@ import {
3031
IconZoomReset,
3132
} from '@tabler/icons-react';
3233
import React from 'react';
33-
import { notifications } from '@mantine/notifications';
3434
import type { ArenaLayoutDocument, ArenaLayoutSectionDocument } from '../arena/types';
3535

3636
interface MonitorRecord {
@@ -549,15 +549,21 @@ export function ArenaView({ monitors, isLoading, openMonitorInfo }: ArenaViewPro
549549
return (
550550
<Group gap="sm">
551551
<Group gap={6}>
552-
<Box style={{ width: 16, height: 16, backgroundColor: theme.colors.green[6], borderRadius: 3 }} />
552+
<Box style={{
553+
width: 16, height: 16, backgroundColor: theme.colors.green[6], borderRadius: 3,
554+
}} />
553555
<Text size="sm">Online</Text>
554556
</Group>
555557
<Group gap={6}>
556-
<Box style={{ width: 16, height: 16, backgroundColor: theme.colors.gray[5], borderRadius: 3 }} />
558+
<Box style={{
559+
width: 16, height: 16, backgroundColor: theme.colors.gray[5], borderRadius: 3,
560+
}} />
557561
<Text size="sm">Offline</Text>
558562
</Group>
559563
<Group gap={6}>
560-
<Box style={{ width: 16, height: 16, backgroundColor: theme.colors.gray[3], borderRadius: 3 }} />
564+
<Box style={{
565+
width: 16, height: 16, backgroundColor: theme.colors.gray[3], borderRadius: 3,
566+
}} />
561567
<Text size="sm">Unmatched</Text>
562568
</Group>
563569
</Group>

packages/ui/app/components/MonitorDisplay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
import { IconCheck, IconX } from '@tabler/icons-react';
66
import { DataTable } from 'mantine-datatable';
77
import React from 'react';
8-
import { MonitorInfoButton } from './MonitorInfo';
98
import { formatWifiSignal } from '../utils';
9+
import { MonitorInfoButton } from './MonitorInfo';
1010

1111
function getLastOnlineTime(updateAt: number | undefined): string {
1212
if (!updateAt) return '未知';

0 commit comments

Comments
 (0)