mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-20 17:03:42 +00:00
layout sharing via url
[deploy]
This commit is contained in:
@@ -1,7 +1,35 @@
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import LayoutCC1 from "$lib/components/LayoutCC1.svelte"
|
||||
import {share} from "$lib/share"
|
||||
import {getSharableUrl, parseSharableUrl} from "$lib/serial/serialization"
|
||||
import {layout} from "$lib/serial/connection"
|
||||
import type {CharaLayout} from "$lib/serial/connection"
|
||||
import tippy from "tippy.js"
|
||||
import {onMount} from "svelte"
|
||||
|
||||
onMount(async () => {
|
||||
const sharedLayout = await parseSharableUrl<CharaLayout>("layout")
|
||||
if (sharedLayout) {
|
||||
$layout = sharedLayout
|
||||
}
|
||||
})
|
||||
|
||||
async function shareLayout(event) {
|
||||
const data = await getSharableUrl("layout", $layout)
|
||||
await navigator.clipboard.writeText(data.toString())
|
||||
tippy(event.target, {
|
||||
content: "Share url copied!",
|
||||
hideOnClick: true,
|
||||
duration: 4000,
|
||||
onHidden(instance) {
|
||||
instance.destroy()
|
||||
},
|
||||
}).show()
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window use:share={shareLayout} />
|
||||
|
||||
<section>
|
||||
<LayoutCC1 />
|
||||
</section>
|
||||
|
||||
0
src/routes/stats/+page.svelte
Normal file
0
src/routes/stats/+page.svelte
Normal file
Reference in New Issue
Block a user