Skip to content

Commit ea20d1f

Browse files
fix: windows
1 parent b774fe5 commit ea20d1f

5 files changed

Lines changed: 126 additions & 6 deletions

File tree

resources/dist.rc

1.8 KB
Binary file not shown.

src/celemod-ui/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { join } = require("path");
33
const { fileURLToPath } = require("url");
44

55
let bundler = new Parcel({
6-
entries: "./src/index.html",
6+
entries: ["./src/index.html", "./src/index_windows.html"],
77
defaultConfig: "@parcel/config-default",
88
serveOptions: {
99
port: 1234,
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<!DOCTYPE html>
2+
<html
3+
lang="en"
4+
window-alignment="5"
5+
window-corners="round"
6+
window-maximizable="true"
7+
window-min-width="800px"
8+
window-min-height="600px"
9+
window-icon="./Celemod.b5f3f7f9.png"
10+
window-frame="solid"
11+
>
12+
<head>
13+
<meta charset="utf-8" />
14+
<meta
15+
name="viewport"
16+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
17+
/>
18+
<title>CeleMod</title>
19+
</head>
20+
21+
<script>
22+
padding("padding for sciter-specific.js");
23+
</script>
24+
25+
<body>
26+
<div class="dummy"></div>
27+
<span class="celemod-version" title="点击检查更新 / Check Update">
28+
<div class="caption-hash"></div>
29+
<div class="caption-version"></div>
30+
</span>
31+
<div role="window-caption">
32+
CeleMod
33+
34+
<script>
35+
document.querySelector(".celemod-version").onclick = () => {
36+
if (!document.querySelector(".popup-container")) _checkUpdate();
37+
};
38+
document
39+
.querySelector(".celemod-version")
40+
.on("contextmenu", () => Window.this.xcall("show_log_window"));
41+
42+
document.querySelector(".caption-version").innerText =
43+
Window.this.xcall("celemod_version");
44+
document.querySelector(".caption-hash").innerText = Window.this
45+
.xcall("celemod_hash")
46+
.substr(0, 6);
47+
48+
const [x, y, w, h] = Window.this.box("xywh", "border", "desktop");
49+
if (w < 800 || h < 600)
50+
Window.this.move(x, y, 800 * (800 / w), 600 * (600 / h));
51+
</script>
52+
</div>
53+
<span class="win-ctrl">
54+
<button role="window-minimize">
55+
<icon|minus />
56+
</button>
57+
<button role="window-maximize">
58+
<icon|landscape />
59+
</button>
60+
<button class="close" role="window-close">
61+
<icon|cancel />
62+
</button>
63+
</span>
64+
65+
<div id="root"></div>
66+
<link rel="stylesheet" href="./index.scss" />
67+
<link rel="stylesheet" href="i2.css" />
68+
<script>
69+
if (env.PLATFORM !== "Windows") {
70+
document.querySelector(".win-ctrl").style.display = "none";
71+
} else {
72+
document.body.parentElement.setAttribute('window-frame', 'solid');
73+
}
74+
document.body.parentElement.setAttribute('platform', env.PLATFORM);
75+
76+
Window.this.isResizable = true;
77+
window.isMaximizable = true;
78+
79+
async function updateStyles() {
80+
for (const style of document.querySelectorAll("style")) {
81+
const url = style.getAttribute("src");
82+
const response = await fetch(url);
83+
const text = await response.text();
84+
if (text === style.textContent) continue;
85+
style.state.disabled = true;
86+
style.textContent = text;
87+
style.state.disabled = false;
88+
}
89+
}
90+
91+
console.clear = () => {
92+
console.log("------- Cleared --------");
93+
updateStyles();
94+
// location.reload();
95+
};
96+
97+
location.reload = function () {
98+
setTimeout(() => {
99+
console.log("location.reload1");
100+
Window.this.load(location.href);
101+
});
102+
};
103+
104+
document.on("keyup", function (evt) {
105+
if (evt.code == "F5") {
106+
location.reload();
107+
}
108+
});
109+
</script>
110+
<script src="./index.tsx" type="module"></script>
111+
</body>
112+
</html>

src/main.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,19 +1254,27 @@ fn main() {
12541254

12551255
frame.event_handler(Handler);
12561256

1257+
#[cfg(target_os = "windows")]
1258+
const INDEX_HTML: &str = "index_windows.html";
1259+
1260+
#[cfg(not(target_os = "windows"))]
1261+
const INDEX_HTML: &str = "index.html";
1262+
1263+
12571264
#[cfg(debug_assertions)]
12581265
frame.load_html(
12591266
read_to_string_bom(Path::new("../../src/celemod-ui/debug_index.html"))
12601267
.unwrap()
1261-
.as_bytes(),
1262-
Some("app://index.html"),
1263-
);
1268+
.as_bytes(), Some(
1269+
&format!("app://{}", INDEX_HTML)
1270+
));
12641271
#[cfg(not(debug_assertions))]
12651272
{
12661273
frame
12671274
.archive_handler(include_bytes!("../resources/dist.rc"))
12681275
.unwrap();
1269-
frame.load_file("this://app/index.html");
1276+
1277+
frame.load_file(&format!("this://app/{}", INDEX_HTML)).unwrap();
12701278
}
12711279

12721280
frame.run_app();

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.9
1+
0.1.10

0 commit comments

Comments
 (0)