Skip to content

Commit

Permalink
add QR code on demo page
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Nov 11, 2024
1 parent 8588d13 commit 74a2968
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
"eslint-plugin-format": "^0.1.2",
"eslint-plugin-svelte": "^2.43.0",
"openai": "^4.56.0",
"paneforge": "^0.0.5",
"pyodide": "0.26.3",
"qrious": "^4.0.2",
"rehype-stringify": "^10.0.0",
"remark-gfm": "^4.0.0",
"remark-parse": "^11.0.0",
Expand Down
39 changes: 39 additions & 0 deletions src/routes/demo/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script lang="ts">
import Qr from "./QR.svelte";
import { Pane, PaneGroup, PaneResizer } from "paneforge";
</script>

<div class="h-screen w-screen">
<PaneGroup direction="horizontal">
<Pane minSize={10} defaultSize={20}>
<div class="h-full w-full flex flex-col select-none gap-5 ws-nowrap p-5">
<div class="flex flex-col items-center gap-2 rounded-md bg-white/4 p-3 not-hover:op-80">
<Qr url="/" scale={2} />
<h3>扫码体验 Python Agent 🤖</h3>
</div>
<div class="flex flex-col items-center gap-2 rounded-md bg-white/4 p-3 not-hover:op-80">
<Qr url="https://github.com/promplate/reasonify" scale={2} />
<h3>GitHub 仓库求 ⭐</h3>
</div>
<div class="flex flex-row gap-2">
<div class="flex flex-col items-center gap-2 rounded-md bg-white/4 p-3 not-hover:op-80">
<Qr url="https://promplate.dev/" />
<h3>体验提示工程框架</h3>
</div>
<div class="flex flex-col items-center gap-2 rounded-md bg-white/4 p-3 not-hover:op-80">
<Qr url="https://docs.py.promplate.dev/" />
<h3>提示工程框架文档</h3>
</div>
</div>
</div>
</Pane>
<PaneResizer class="group">
<div
class="mx-1 h-full w-0.11em bg-white/10 transition group-active:bg-current group-hover:bg-white/30"
/>
</PaneResizer>
<Pane minSize={20}>
<iframe class="h-full w-full" title="demo" src="/" frameborder="0" />
</Pane>
</PaneGroup>
</div>
22 changes: 22 additions & 0 deletions src/routes/demo/QR.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script lang="ts">
// @ts-ignore
import QRious from "qrious";
import { onMount } from "svelte";
export let url: string;
export let scale = 1;
let qr: QRious;
onMount(() => {
qr = new QRious({
value: new URL(url, location.href).href,
background: "#00000000",
foreground: "#ffffff",
size: 345 * scale,
level: ["L", "M", "Q", "H"][scale],
});
});
</script>

<img src={qr?.toDataURL("image/svg")} alt="qr code" />

0 comments on commit 74a2968

Please sign in to comment.