mirror of
https://github.com/imezx/Warp.git
synced 2025-04-25 07:30:02 +00:00
19 lines
423 B
JavaScript
19 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 };
|