Skip to content

Commit 7a633c3

Browse files
committed
使用 leptos 作为前端框架重构
1 parent 5e00f2f commit 7a633c3

File tree

1,663 files changed

+4022
-547981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,663 files changed

+4022
-547981
lines changed

Cargo.lock

Lines changed: 1566 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "leptos_open_wechat"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
console_error_panic_hook = "0.1.7"
8+
js-sys = "0.3.69"
9+
leptos = { version = "0.6.13", features = ["csr"] }
10+
serde = { version = "1.0.204", features = ["derive"] }
11+
serde-wasm-bindgen = "0.6.5"
12+
wasm-bindgen = "0.2.92"
13+
wasm-bindgen-futures = "0.4.42"

README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

dist/assets/index-BXm5H3BW.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/assets/index-i-AjiEcy.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

dist/index.html

Lines changed: 151 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,158 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33

44
<head>
5-
<meta charset="UTF-8" />
6-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<link data-trunk href="./output.css">
9-
<title>Tauri + Vue 3 App</title>
10-
<script type="module" crossorigin src="/assets/index-i-AjiEcy.js"></script>
11-
<link rel="stylesheet" crossorigin href="/assets/index-BXm5H3BW.css">
12-
</head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
<link rel="stylesheet" href="/output-7aacb22fb5660605.css" integrity="sha384&#x2D;tvVVnBSGm9pgWCtw17PS0iewjncuBBemAC0l4m91oY4k3fXCL3UPEHc5sUZtQ1ac"/>
9+
10+
<script type="module" nonce="iY+6eIyinEUvVyz43SYEdA==">
11+
import init, * as bindings from '/leptos_open_wechat-3bf700fbef5eaabc.js';
12+
const wasm = await init('/leptos_open_wechat-3bf700fbef5eaabc_bg.wasm');
13+
14+
15+
window.wasmBindings = bindings;
16+
17+
18+
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));
19+
20+
</script>
21+
22+
23+
<link rel="modulepreload" href="/leptos_open_wechat-3bf700fbef5eaabc.js" crossorigin=anonymous integrity="sha384-vSTa+MzyVe200xPcvdAs5edUq3Br420EzGp2v92kTqL/B1FOuLe/7MkC+/7S2dMb">
24+
<link rel="preload" href="/leptos_open_wechat-3bf700fbef5eaabc_bg.wasm" crossorigin=anonymous integrity="sha384-5rBHZkshRpFgmKLKLzBeGpths/nO0EYdxQHKmmBEi6IyORIIYeZt1gpXwstb43mf" as="fetch" type="application/wasm"></head>
1325

1426
<body>
15-
<div id="app"></div>
16-
</body>
27+
<script>"use strict";
28+
29+
(function () {
30+
31+
const address = '{{__TRUNK_ADDRESS__}}';
32+
const base = '{{__TRUNK_WS_BASE__}}';
33+
let protocol = '';
34+
protocol =
35+
protocol
36+
? protocol
37+
: window.location.protocol === 'https:'
38+
? 'wss'
39+
: 'ws';
40+
const url = protocol + '://' + address + base + '.well-known/trunk/ws';
41+
42+
class Overlay {
43+
constructor() {
44+
// create an overlay
45+
this._overlay = document.createElement("div");
46+
const style = this._overlay.style;
47+
style.height = "100vh";
48+
style.width = "100vw";
49+
style.position = "fixed";
50+
style.top = "0";
51+
style.left = "0";
52+
style.backgroundColor = "rgba(222, 222, 222, 0.5)";
53+
style.fontFamily = "sans-serif";
54+
// not sure that's the right approach
55+
style.zIndex = "1000000";
56+
style.backdropFilter = "blur(1rem)";
57+
58+
const container = document.createElement("div");
59+
// center it
60+
container.style.position = "absolute";
61+
container.style.top = "30%";
62+
container.style.left = "15%";
63+
container.style.maxWidth = "85%";
64+
65+
this._title = document.createElement("div");
66+
this._title.innerText = "Build failure";
67+
this._title.style.paddingBottom = "2rem";
68+
this._title.style.fontSize = "2.5rem";
69+
70+
this._message = document.createElement("div");
71+
this._message.style.whiteSpace = "pre-wrap";
72+
73+
const icon= document.createElement("div");
74+
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="#dc3545" viewBox="0 0 16 16"><path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/></svg>';
75+
this._title.prepend(icon);
76+
77+
container.append(this._title, this._message);
78+
this._overlay.append(container);
79+
80+
this._inject();
81+
window.setInterval(() => {
82+
this._inject();
83+
}, 250);
84+
}
85+
86+
set reason(reason) {
87+
this._message.textContent = reason;
88+
}
89+
90+
_inject() {
91+
if (!this._overlay.isConnected) {
92+
// prepend it
93+
document.body?.prepend(this._overlay);
94+
}
95+
}
96+
97+
}
98+
99+
class Client {
100+
constructor(url) {
101+
this.url = url;
102+
this.poll_interval = 5000;
103+
this._overlay = null;
104+
}
105+
106+
start() {
107+
const ws = new WebSocket(this.url);
108+
ws.onmessage = (ev) => {
109+
const msg = JSON.parse(ev.data);
110+
switch (msg.type) {
111+
case "reload":
112+
this.reload();
113+
break;
114+
case "buildFailure":
115+
this.buildFailure(msg.data)
116+
break;
117+
}
118+
};
119+
ws.onclose = this.onclose;
120+
}
121+
122+
onclose() {
123+
window.setTimeout(
124+
() => {
125+
// when we successfully reconnect, we'll force a
126+
// reload (since we presumably lost connection to
127+
// trunk due to it being killed, so it will have
128+
// rebuilt on restart)
129+
const ws = new WebSocket(this.url);
130+
ws.onopen = () => window.location.reload();
131+
ws.onclose = this.onclose;
132+
},
133+
this.poll_interval);
134+
}
135+
136+
reload() {
137+
window.location.reload();
138+
}
139+
140+
buildFailure({reason}) {
141+
// also log the console
142+
console.error("Build failed:", reason);
143+
144+
console.debug("Overlay", this._overlay);
145+
146+
if (!this._overlay) {
147+
this._overlay = new Overlay();
148+
}
149+
this._overlay.reason = reason;
150+
}
151+
}
152+
153+
new Client(url).start();
154+
155+
})()
156+
</script></body>
17157

18158
</html>

dist/tauri.svg

Lines changed: 0 additions & 6 deletions
This file was deleted.

dist/vite.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

index.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33

44
<head>
5-
<meta charset="UTF-8" />
6-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<link data-trunk href="./output.css">
9-
<title>Tauri + Vue 3 App</title>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
<link data-trunk rel="css" href="./output.css">
9+
<link data-trunk rel="rust" data-wasm-opt="z" />
10+
1011
</head>
1112

1213
<body>
13-
<div id="app"></div>
14-
<script type="module" src="/src/main.js"></script>
1514
</body>
1615

1716
</html>

index.css renamed to input.css

File renamed without changes.

node_modules/.bin/autoprefixer

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/browserslist

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/esbuild

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/parser

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/rollup

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/tauri

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/update-browserslist-db

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/.bin/vite

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)