Skip to content

Commit

Permalink
feat: qrcode
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Feb 25, 2024
1 parent e89992a commit f7c7221
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@types/file-saver": "^2.0.7",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.11.19",
"@types/qrcode": "^1.5.5",
"@vitejs/plugin-legacy": "^5.3.0",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
Expand Down Expand Up @@ -56,6 +57,7 @@
"p-limit": "^5.0.0",
"pinia": "^2.1.7",
"prettier": "^3.2.5",
"qrcode": "^1.5.3",
"sass": "^1.71.0",
"simple-git": "^3.22.0",
"simple-git-hooks": "^2.9.0",
Expand Down
166 changes: 166 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions src/components/BuildShareDlg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import JSON5 from 'json5';
import { NButton, NInput, NModal } from 'naive-ui';
import { shallowRef, watchEffect } from 'vue';
import { useRouter } from 'vue-router';
import QRCode from 'qrcode';
const router = useRouter();
Expand All @@ -33,6 +34,16 @@ watchEffect(() => {
const linkDlgShow = shallowRef(false);
const shareLink = shallowRef('');
const shareLinkQr = shallowRef('');
watchEffect(() => {
if (shareLink.value) {
QRCode.toDataURL(shareLink.value, { width: 256, margin: 2 }).then((url) => {
shareLinkQr.value = url;
});
} else {
shareLinkQr.value = '';
}
});
const copyLink = () => {
copy(shareLink.value);
linkDlgShow.value = false;
Expand Down Expand Up @@ -95,8 +106,11 @@ const buildShare = useTask(async () => {
"
@afterLeave="shareLink = ''"
>
<NButton text tag="a" :href="shareLink" target="_blank" type="primary">
{{ shareLink }}
</NButton>
<div>
<NButton text tag="a" :href="shareLink" target="_blank" type="primary">
{{ shareLink }}
</NButton>
<img v-if="shareLinkQr" :src="shareLinkQr" size-200px block />
</div>
</NModal>
</template>

0 comments on commit f7c7221

Please sign in to comment.