mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 15:10:03 +00:00
20 lines
423 B
JavaScript
20 lines
423 B
JavaScript
|
import { toRef, isClient } from '@vueuse/shared';
|
||
|
import { ref, watch } from 'vue-demi';
|
||
|
import QRCode from 'qrcode';
|
||
|
|
||
|
function useQRCode(text, options) {
|
||
|
const src = toRef(text);
|
||
|
const result = ref("");
|
||
|
watch(
|
||
|
src,
|
||
|
async (value) => {
|
||
|
if (src.value && isClient)
|
||
|
result.value = await QRCode.toDataURL(value, options);
|
||
|
},
|
||
|
{ immediate: true }
|
||
|
);
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
export { useQRCode };
|