Skip to content

Commit a566042

Browse files
committed
feat: add v86 emulator integration, have fun!
1 parent bf730d0 commit a566042

File tree

7 files changed

+770
-2
lines changed

7 files changed

+770
-2
lines changed

docs/index.md

+71-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,73 @@
11
# Welcome!
22

3-
123123123
3+
???+ success "🎉 恭喜! 现在你是一位 Linux 用户了!"
4+
<!-- A minimal structure for the ScreenAdapter defined in browser/screen.js -->
5+
<div id="screen_container" style="display: flex;">
6+
<div style="white-space: pre; font: 14px monospace; line-height: 14px; margin: auto;"></div>
7+
<canvas style="display: none"></canvas>
8+
</div>
9+
10+
这是使用 [copy/v86](https://github.com/copy/v86) 项目运行的 [Linux](https://en.wikipedia.org/wiki/Linux) 6.8.12 内核, 使用 [Web Assembly](https://webassembly.org/) 技术在你的浏览器上运行了一个虚拟机, 并启动了极简的 [Buildroot](https://buildroot.org/) 环境.
11+
12+
你可以在这里尝试 Linux 常用的命令, 例如 `ls`, `cd`, `cat`, `echo`, `pwd`, `uname`, `date`, `top`, `ps`, `clear`, `exit`.
13+
14+
<script src="/notes/javascripts/v86/libv86.js"></script>
15+
<script>
16+
"use strict";
17+
18+
// Save references to the original event handler methods
19+
const originalAddEventListener = window.addEventListener;
20+
const originalRemoveEventListener = window.removeEventListener;
21+
22+
// Array to store keydown listeners
23+
const keydownListeners = [];
24+
25+
// Override addEventListener to track keydown listeners
26+
window.addEventListener = function(type, listener, options) {
27+
originalAddEventListener.call(window, type, listener, options);
28+
if (type === 'keydown') {
29+
keydownListeners.push({ listener, options });
30+
}
31+
};
32+
33+
// Override removeEventListener to update the keydown listeners list
34+
window.removeEventListener = function(type, listener, options) {
35+
originalRemoveEventListener.call(window, type, listener, options);
36+
if (type === 'keydown') {
37+
const index = keydownListeners.findIndex(entry =>
38+
entry.listener === listener &&
39+
(entry.options === options ||
40+
(typeof entry.options === 'object' && typeof options === 'object' &&
41+
JSON.stringify(entry.options) === JSON.stringify(options))));
42+
if (index !== -1) {
43+
keydownListeners.splice(index, 1);
44+
}
45+
}
46+
};
47+
48+
window.onload = function()
49+
{
50+
// Remove key listener from material mkdocs
51+
if (keydownListeners.length > 0) {
52+
const firstListener = keydownListeners.shift();
53+
window.removeEventListener('keydown', firstListener.listener, firstListener.options);
54+
}
55+
56+
var emulator = new V86({
57+
wasm_path: "/notes/javascripts/v86/v86.wasm",
58+
memory_size: 512 * 1024 * 1024,
59+
vga_memory_size: 8 * 1024 * 1024,
60+
screen_container: document.getElementById("screen_container"),
61+
bios: {
62+
url: "/notes/javascripts/v86/seabios.bin",
63+
},
64+
vga_bios: {
65+
url: "/notes/javascripts/v86/vgabios.bin",
66+
},
67+
bzimage: {
68+
url: "/notes/javascripts/v86/buildroot-bzimage68.bin",
69+
},
70+
autostart: true,
71+
});
72+
};
73+
</script>
9.6 MB
Binary file not shown.

docs/javascripts/v86/libv86.js

+698
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/javascripts/v86/seabios.bin

128 KB
Binary file not shown.

docs/javascripts/v86/v86.wasm

1.89 MB
Binary file not shown.

docs/javascripts/v86/vgabios.bin

35.5 KB
Binary file not shown.

overrides/partials/copyright.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</div>
99
{% endif %}
1010
{% if not config.extra.generator == false %}
11-
使用
11+
基于
1212
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
1313
Material for MkDocs
1414
</a>

0 commit comments

Comments
 (0)