feat: qr codes for note sharing

This commit is contained in:
老周部落 2024-05-29 22:24:48 +08:00
parent 111284b93e
commit 78a18e9000
No known key found for this signature in database
GPG key ID: C72181CD85C6B738
3 changed files with 31 additions and 5 deletions

View file

@ -546,7 +546,7 @@ router.get("/notes/:note", async (ctx, next) => {
ctx.set("Cache-Control", "public, max-age=15"); ctx.set("Cache-Control", "public, max-age=15");
ctx.set( ctx.set(
"Content-Security-Policy", "Content-Security-Policy",
"default-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src *; font-src 'self' data:; img-src *; media-src *; worker-src 'self'; frame-ancestors *", "default-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src *; font-src 'self' data:; img-src * data:; media-src *; worker-src 'self'; frame-ancestors *",
); );
return; return;

View file

@ -6,9 +6,14 @@
:value="qrCode" :value="qrCode"
/> />
</div> </div>
<MkButton :class="$style.gotIt" primary full @click="gotIt()">{{ <div class="_flexList" style="gap: 0.6rem">
i18n.ts.gotIt <MkButton :class="$style.gotIt" primary full @click="gotIt()">{{
}}</MkButton> i18n.ts.gotIt
}}</MkButton>
<MkButton :class="$style.copyLink" full @click="copyLink()">{{
i18n.ts.copyLink
}}</MkButton>
</div>
</div> </div>
</MkModal> </MkModal>
</template> </template>
@ -19,8 +24,10 @@ import QRCodeVue3 from "qrcode-vue3";
import MkModal from "@/components/MkModal.vue"; import MkModal from "@/components/MkModal.vue";
import MkButton from "@/components/MkButton.vue"; import MkButton from "@/components/MkButton.vue";
import { i18n } from "@/i18n"; import { i18n } from "@/i18n";
import * as os from "@/os";
import copyToClipboard from "@/scripts/copy-to-clipboard";
defineProps<{ const props = defineProps<{
qrCode: string; qrCode: string;
}>(); }>();
@ -29,6 +36,11 @@ const modal = shallowRef<InstanceType<typeof MkModal>>();
const gotIt = () => { const gotIt = () => {
modal.value.close(); modal.value.close();
}; };
const copyLink = () => {
copyToClipboard(props.qrCode);
os.success();
};
</script> </script>
<style lang="scss" module> <style lang="scss" module>

View file

@ -399,6 +399,13 @@ export function getNoteMenu(props: {
action: copyOriginal, action: copyOriginal,
} }
: undefined, : undefined,
{
icon: `${icon("ph-qr-code")}`,
text: i18n.ts.getQrCode,
action: () => {
os.displayQrCode(`${url}/notes/${appearNote.id}`);
},
},
shareAvailable() shareAvailable()
? { ? {
icon: `${icon("ph-share-network")}`, icon: `${icon("ph-share-network")}`,
@ -516,6 +523,13 @@ export function getNoteMenu(props: {
action: copyOriginal, action: copyOriginal,
} }
: undefined, : undefined,
{
icon: `${icon("ph-qr-code")}`,
text: i18n.ts.getQrCode,
action: () => {
os.displayQrCode(`${url}/notes/${appearNote.id}`);
},
},
shareAvailable() shareAvailable()
? { ? {
icon: `${icon("ph-share-network")}`, icon: `${icon("ph-share-network")}`,