Skip to content

Commit a19beb1

Browse files
add QR code on demo page
1 parent 519494f commit a19beb1

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

Diff for: package.json

+2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"eslint-plugin-format": "^1.0.1",
2828
"eslint-plugin-svelte": "^3.0.1",
2929
"openai": "^4.56.0",
30+
"paneforge": "^0.0.5",
3031
"pyodide": "0.27.4",
32+
"qrious": "^4.0.2",
3133
"rehype-stringify": "^10.0.0",
3234
"remark-gfm": "^4.0.0",
3335
"remark-parse": "^11.0.0",

Diff for: src/routes/demo/+page.svelte

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<script lang="ts">
2+
import Qr from "./QR.svelte";
3+
import { Pane, PaneGroup, PaneResizer } from "paneforge";
4+
</script>
5+
6+
<div class="h-screen w-screen">
7+
<PaneGroup direction="horizontal">
8+
<Pane minSize={10} defaultSize={20}>
9+
<div class="h-full w-full flex flex-col select-none gap-5 ws-nowrap p-5">
10+
<div class="flex flex-col items-center gap-2 rounded-md bg-white/4 p-3 not-hover:op-80">
11+
<Qr url="/" scale={2} />
12+
<h3>扫码体验 Python Agent 🤖</h3>
13+
</div>
14+
<div class="flex flex-col items-center gap-2 rounded-md bg-white/4 p-3 not-hover:op-80">
15+
<Qr url="https://github.com/promplate/reasonify" scale={2} />
16+
<h3>GitHub 仓库求 ⭐</h3>
17+
</div>
18+
<div class="flex flex-row gap-2">
19+
<div class="flex flex-col items-center gap-2 rounded-md bg-white/4 p-3 not-hover:op-80">
20+
<Qr url="https://promplate.dev/" />
21+
<h3>体验提示工程框架</h3>
22+
</div>
23+
<div class="flex flex-col items-center gap-2 rounded-md bg-white/4 p-3 not-hover:op-80">
24+
<Qr url="https://docs.py.promplate.dev/" />
25+
<h3>提示工程框架文档</h3>
26+
</div>
27+
</div>
28+
</div>
29+
</Pane>
30+
<PaneResizer class="group">
31+
<div
32+
class="mx-1 h-full w-0.11em bg-white/10 transition group-active:bg-current group-hover:bg-white/30"
33+
/>
34+
</PaneResizer>
35+
<Pane minSize={20}>
36+
<iframe class="h-full w-full" title="demo" src="/" frameborder="0" />
37+
</Pane>
38+
</PaneGroup>
39+
</div>

Diff for: src/routes/demo/QR.svelte

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script lang="ts">
2+
// @ts-ignore
3+
import QRious from "qrious";
4+
import { onMount } from "svelte";
5+
6+
export let url: string;
7+
export let scale = 1;
8+
9+
let qr: QRious;
10+
11+
onMount(() => {
12+
qr = new QRious({
13+
value: new URL(url, location.href).href,
14+
background: "#00000000",
15+
foreground: "#ffffff",
16+
size: 345 * scale,
17+
level: ["L", "M", "Q", "H"][scale],
18+
});
19+
});
20+
</script>
21+
22+
<img src={qr?.toDataURL("image/svg")} alt="qr code" />

0 commit comments

Comments
 (0)