Compare commits
15 Commits
v0.6.7
...
bc8168e724
| Author | SHA1 | Date | |
|---|---|---|---|
|
bc8168e724
|
|||
|
dcde3b0799
|
|||
|
60fc774586
|
|||
|
d65c0d0357
|
|||
|
02736ecc70
|
|||
|
7b1d19ca7a
|
|||
|
4846d0e61c
|
|||
|
3155e12b84
|
|||
|
b8bbe84aa9
|
|||
|
74984caf9e
|
|||
|
c8b799b078
|
|||
|
f3a4c1af05
|
|||
|
616f615d7c
|
|||
|
4d572b55ca
|
|||
|
9822cab93e
|
20
README.md
20
README.md
@@ -20,6 +20,26 @@ Monitor and capture your clipboard history in real-time.
|
|||||||
- Clears history on demand.
|
- Clears history on demand.
|
||||||
- Privacy-focused: Data is processed locally and never sent to any server.
|
- Privacy-focused: Data is processed locally and never sent to any server.
|
||||||
|
|
||||||
|
### 🔗 URL Cleaner
|
||||||
|
Clean tracking parameters and clutter from URLs.
|
||||||
|
- **Privacy:** Removes known tracking parameters (UTM, fbclid, gclid, etc.).
|
||||||
|
- **Bulk Processing:** Clean list of URLs at once.
|
||||||
|
- **Customizable:** Manage exceptions to keep specific parameters.
|
||||||
|
- **Smart:** "Direct Clean" mode for quick single-URL cleaning.
|
||||||
|
|
||||||
|
### ⬛ QR Generator
|
||||||
|
Create custom QR codes instantly.
|
||||||
|
- **Customizable:** Adjustable error correction level and size.
|
||||||
|
- **Download:** Save as PNG (raster) or SVG (vector) for high-quality printing.
|
||||||
|
- **Persistent Settings:** Remembers your preferences.
|
||||||
|
|
||||||
|
### 📷 QR Scanner
|
||||||
|
Scan QR codes directly from your camera or device.
|
||||||
|
- **Privacy First:** Works entirely in the browser using local `BarcodeDetector` API. No images are sent to any server.
|
||||||
|
- **Multi-Camera:** Support for front and back cameras with easy switching.
|
||||||
|
- **History:** Keeps a log of scanned codes with options to copy or download as JSON.
|
||||||
|
- **Responsive:** Fullscreen mode for immersive scanning experience.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Chrome Extension 🧩
|
## Chrome Extension 🧩
|
||||||
|
|||||||
17
package-lock.json
generated
17
package-lock.json
generated
@@ -1,16 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "tools-app",
|
"name": "tools-app",
|
||||||
"version": "0.6.7",
|
"version": "0.6.14",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "tools-app",
|
"name": "tools-app",
|
||||||
"version": "0.6.7",
|
"version": "0.6.14",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"barcode-detector": "^3.1.0",
|
"barcode-detector": "^3.1.0",
|
||||||
"lucide-vue-next": "^0.575.0",
|
"lucide-vue-next": "^0.575.0",
|
||||||
|
"marked": "^17.0.3",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"vue": "^3.5.25",
|
"vue": "^3.5.25",
|
||||||
"vue-router": "^5.0.3"
|
"vue-router": "^5.0.3"
|
||||||
@@ -4750,6 +4751,18 @@
|
|||||||
"url": "https://github.com/sponsors/sxzz"
|
"url": "https://github.com/sponsors/sxzz"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/marked": {
|
||||||
|
"version": "17.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/marked/-/marked-17.0.3.tgz",
|
||||||
|
"integrity": "sha512-jt1v2ObpyOKR8p4XaUJVk3YWRJ5n+i4+rjQopxvV32rSndTJXvIzuUdWWIy/1pFQMkQmvTXawzDNqOH/CUmx6A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"marked": "bin/marked.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 20"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/math-intrinsics": {
|
"node_modules/math-intrinsics": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "tools-app",
|
"name": "tools-app",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.6.7",
|
"version": "0.6.14",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"barcode-detector": "^3.1.0",
|
"barcode-detector": "^3.1.0",
|
||||||
"lucide-vue-next": "^0.575.0",
|
"lucide-vue-next": "^0.575.0",
|
||||||
|
"marked": "^17.0.3",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"vue": "^3.5.25",
|
"vue": "^3.5.25",
|
||||||
"vue-router": "^5.0.3"
|
"vue-router": "^5.0.3"
|
||||||
|
|||||||
@@ -51,12 +51,20 @@ const dismissPrompt = () => {
|
|||||||
deferredPrompt = null
|
deferredPrompt = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleKeydown = (e) => {
|
||||||
|
if (e.key === 'Escape' && showInstallPrompt.value) {
|
||||||
|
dismissPrompt()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
window.addEventListener('beforeinstallprompt', handleBeforeInstallPrompt)
|
window.addEventListener('beforeinstallprompt', handleBeforeInstallPrompt)
|
||||||
|
window.addEventListener('keydown', handleKeydown)
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
window.removeEventListener('beforeinstallprompt', handleBeforeInstallPrompt)
|
window.removeEventListener('beforeinstallprompt', handleBeforeInstallPrompt)
|
||||||
|
window.removeEventListener('keydown', handleKeydown)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,99 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { marked } from 'marked'
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import readmeContent from '../../README.md?raw'
|
||||||
|
|
||||||
|
const htmlContent = computed(() => {
|
||||||
|
return marked(readmeContent)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
main
|
<div class="readme-container glass-panel">
|
||||||
|
<div class="markdown-body" v-html="htmlContent"></div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.readme-container {
|
||||||
|
padding: 2rem;
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(h1) {
|
||||||
|
font-size: 2rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
color: var(--primary-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(h2) {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-top: 2rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
border-bottom: 1px solid var(--glass-border);
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
color: var(--text-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(h3) {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
color: var(--text-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(p) {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(ul) {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
padding-left: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(li) {
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(a) {
|
||||||
|
color: var(--primary-accent);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(a:hover) {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(code) {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
padding: 0.2em 0.4em;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(pre) {
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow-x: auto;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
border: 1px solid var(--glass-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(pre code) {
|
||||||
|
background: none;
|
||||||
|
padding: 0;
|
||||||
|
color: #e6e6e6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body :deep(hr) {
|
||||||
|
border: none;
|
||||||
|
border-top: 1px solid var(--glass-border);
|
||||||
|
margin: 2rem 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const scannedCodes = ref([])
|
|||||||
const hasMultipleCameras = ref(false)
|
const hasMultipleCameras = ref(false)
|
||||||
const isFullscreen = ref(false)
|
const isFullscreen = ref(false)
|
||||||
const videoAspect = ref(1)
|
const videoAspect = ref(1)
|
||||||
const isFront = computed(() => facingMode.value === 'user')
|
const isMirrored = ref(false)
|
||||||
const wrapperRef = ref(null)
|
const wrapperRef = ref(null)
|
||||||
const bgCanvas = ref(null)
|
const bgCanvas = ref(null)
|
||||||
let bgRafId = null
|
let bgRafId = null
|
||||||
@@ -19,6 +19,95 @@ let stream = null
|
|||||||
let scanRafId = null
|
let scanRafId = null
|
||||||
let barcodeDetector = null
|
let barcodeDetector = null
|
||||||
|
|
||||||
|
const overlayCanvas = ref(null)
|
||||||
|
|
||||||
|
const paintDetections = (codes) => {
|
||||||
|
const canvas = overlayCanvas.value
|
||||||
|
const video = videoRef.value
|
||||||
|
|
||||||
|
if (!canvas || !video) return
|
||||||
|
|
||||||
|
const ctx = canvas.getContext('2d')
|
||||||
|
const { width, height } = canvas.getBoundingClientRect()
|
||||||
|
|
||||||
|
// Update canvas size if needed (to match CSS size)
|
||||||
|
if (canvas.width !== width || canvas.height !== height) {
|
||||||
|
canvas.width = width
|
||||||
|
canvas.height = height
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.clearRect(0, 0, width, height)
|
||||||
|
|
||||||
|
if (!codes || codes.length === 0) return
|
||||||
|
|
||||||
|
const vw = video.videoWidth
|
||||||
|
const vh = video.videoHeight
|
||||||
|
if (!vw || !vh) return
|
||||||
|
|
||||||
|
// Calculate object-fit: cover scaling
|
||||||
|
const videoRatio = vw / vh
|
||||||
|
const canvasRatio = width / height
|
||||||
|
|
||||||
|
let drawWidth, drawHeight, startX, startY
|
||||||
|
|
||||||
|
if (canvasRatio > videoRatio) {
|
||||||
|
// Canvas is wider than video (video cropped top/bottom)
|
||||||
|
drawWidth = width
|
||||||
|
drawHeight = width / videoRatio
|
||||||
|
startX = 0
|
||||||
|
startY = (height - drawHeight) / 2
|
||||||
|
} else {
|
||||||
|
// Canvas is taller than video (video cropped left/right)
|
||||||
|
drawHeight = height
|
||||||
|
drawWidth = height * videoRatio
|
||||||
|
startY = 0
|
||||||
|
startX = (width - drawWidth) / 2
|
||||||
|
}
|
||||||
|
|
||||||
|
const scale = drawWidth / vw
|
||||||
|
// Canvas is mirrored via CSS if isMirrored is true, so no manual coordinate mirroring needed
|
||||||
|
|
||||||
|
// Styles
|
||||||
|
const styles = getComputedStyle(document.documentElement)
|
||||||
|
const accent = styles.getPropertyValue('--primary-accent').trim() || '#00f2fe'
|
||||||
|
|
||||||
|
ctx.lineWidth = 4
|
||||||
|
ctx.strokeStyle = accent
|
||||||
|
ctx.fillStyle = accent
|
||||||
|
|
||||||
|
codes.forEach(code => {
|
||||||
|
const points = code.cornerPoints
|
||||||
|
if (!points || points.length < 4) return
|
||||||
|
|
||||||
|
ctx.beginPath()
|
||||||
|
|
||||||
|
const transform = (p) => {
|
||||||
|
let x = p.x * scale + startX
|
||||||
|
let y = p.y * scale + startY
|
||||||
|
return { x, y }
|
||||||
|
}
|
||||||
|
|
||||||
|
const p0 = transform(points[0])
|
||||||
|
ctx.moveTo(p0.x, p0.y)
|
||||||
|
|
||||||
|
for (let i = 1; i < points.length; i++) {
|
||||||
|
const p = transform(points[i])
|
||||||
|
ctx.lineTo(p.x, p.y)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.closePath()
|
||||||
|
ctx.stroke()
|
||||||
|
|
||||||
|
// Draw corners
|
||||||
|
points.forEach(p => {
|
||||||
|
const tp = transform(p)
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.arc(tp.x, tp.y, 4, 0, Math.PI * 2)
|
||||||
|
ctx.fill()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const updateVideoAspect = () => {
|
const updateVideoAspect = () => {
|
||||||
if (videoRef.value && videoRef.value.videoWidth && videoRef.value.videoHeight) {
|
if (videoRef.value && videoRef.value.videoWidth && videoRef.value.videoHeight) {
|
||||||
videoAspect.value = videoRef.value.videoWidth / videoRef.value.videoHeight
|
videoAspect.value = videoRef.value.videoWidth / videoRef.value.videoHeight
|
||||||
@@ -110,6 +199,23 @@ const startScan = async () => {
|
|||||||
|
|
||||||
stream = await navigator.mediaDevices.getUserMedia(constraints)
|
stream = await navigator.mediaDevices.getUserMedia(constraints)
|
||||||
|
|
||||||
|
// Detect actual facing mode to mirror front camera correctly
|
||||||
|
const videoTrack = stream.getVideoTracks()[0]
|
||||||
|
if (videoTrack) {
|
||||||
|
const settings = videoTrack.getSettings()
|
||||||
|
if (settings.facingMode) {
|
||||||
|
isMirrored.value = settings.facingMode === 'user'
|
||||||
|
} else {
|
||||||
|
// Fallback: check label for desktop cameras or assume requested mode
|
||||||
|
const label = videoTrack.label ? videoTrack.label.toLowerCase() : ''
|
||||||
|
if (label.includes('front') || label.includes('facetime') || label.includes('macbook')) {
|
||||||
|
isMirrored.value = true
|
||||||
|
} else {
|
||||||
|
isMirrored.value = facingMode.value === 'user'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (videoRef.value) {
|
if (videoRef.value) {
|
||||||
videoRef.value.srcObject = stream
|
videoRef.value.srcObject = stream
|
||||||
// Wait for metadata to play
|
// Wait for metadata to play
|
||||||
@@ -142,6 +248,7 @@ const detectLoop = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const codes = await barcodeDetector.detect(videoRef.value)
|
const codes = await barcodeDetector.detect(videoRef.value)
|
||||||
|
paintDetections(codes)
|
||||||
if (codes.length > 0) {
|
if (codes.length > 0) {
|
||||||
onDetect(codes)
|
onDetect(codes)
|
||||||
}
|
}
|
||||||
@@ -270,11 +377,18 @@ watch(scannedCodes, (newVal) => {
|
|||||||
localStorage.setItem('qr-history', JSON.stringify(newVal))
|
localStorage.setItem('qr-history', JSON.stringify(newVal))
|
||||||
}, { deep: true })
|
}, { deep: true })
|
||||||
|
|
||||||
|
const handleKeydown = (e) => {
|
||||||
|
if (e.key === 'Escape' && isFullscreen.value) {
|
||||||
|
toggleFullscreen()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
checkCameras()
|
checkCameras()
|
||||||
loadHistory()
|
loadHistory()
|
||||||
window.addEventListener('resize', updateVideoAspect)
|
window.addEventListener('resize', updateVideoAspect)
|
||||||
window.addEventListener('resize', startBackgroundLoop)
|
window.addEventListener('resize', startBackgroundLoop)
|
||||||
|
window.addEventListener('keydown', handleKeydown)
|
||||||
watch(isFullscreen, (fs) => {
|
watch(isFullscreen, (fs) => {
|
||||||
if (fs) {
|
if (fs) {
|
||||||
startBackgroundLoop()
|
startBackgroundLoop()
|
||||||
@@ -282,13 +396,14 @@ onMounted(() => {
|
|||||||
stopBackgroundLoop()
|
stopBackgroundLoop()
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
startScan()
|
startScan()
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('resize', updateVideoAspect)
|
window.removeEventListener('resize', updateVideoAspect)
|
||||||
window.removeEventListener('resize', startBackgroundLoop)
|
window.removeEventListener('resize', startBackgroundLoop)
|
||||||
|
window.removeEventListener('keydown', handleKeydown)
|
||||||
stopScan()
|
stopScan()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -363,6 +478,7 @@ const isUrl = (string) => {
|
|||||||
v-if="isFullscreen"
|
v-if="isFullscreen"
|
||||||
ref="bgCanvas"
|
ref="bgCanvas"
|
||||||
class="camera-bg"
|
class="camera-bg"
|
||||||
|
:class="{ 'is-mirrored': isMirrored }"
|
||||||
></canvas>
|
></canvas>
|
||||||
<button v-if="isFullscreen" class="close-fullscreen-btn" @click="toggleFullscreen">
|
<button v-if="isFullscreen" class="close-fullscreen-btn" @click="toggleFullscreen">
|
||||||
<X size="24" />
|
<X size="24" />
|
||||||
@@ -370,7 +486,7 @@ const isUrl = (string) => {
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
class="camera-wrapper"
|
class="camera-wrapper"
|
||||||
:class="{ 'clickable': !isFullscreen, 'is-front': isFront }"
|
:class="{ 'clickable': !isFullscreen, 'is-mirrored': isMirrored }"
|
||||||
:style="desktopFullscreenStyle"
|
:style="desktopFullscreenStyle"
|
||||||
ref="wrapperRef"
|
ref="wrapperRef"
|
||||||
@click="!isFullscreen && toggleFullscreen()"
|
@click="!isFullscreen && toggleFullscreen()"
|
||||||
@@ -378,12 +494,14 @@ const isUrl = (string) => {
|
|||||||
<video
|
<video
|
||||||
ref="videoRef"
|
ref="videoRef"
|
||||||
class="camera-feed"
|
class="camera-feed"
|
||||||
:class="{ 'is-front': isFront }"
|
:class="{ 'is-mirrored': isMirrored }"
|
||||||
autoplay
|
autoplay
|
||||||
playsinline
|
playsinline
|
||||||
muted
|
muted
|
||||||
></video>
|
></video>
|
||||||
|
|
||||||
|
<canvas ref="overlayCanvas" class="scan-overlay-canvas" :class="{ 'is-mirrored': isMirrored }"></canvas>
|
||||||
|
|
||||||
<div v-if="error" class="error-overlay">
|
<div v-if="error" class="error-overlay">
|
||||||
<p>{{ error }}</p>
|
<p>{{ error }}</p>
|
||||||
<button @click="startScan" class="retry-btn">Retry</button>
|
<button @click="startScan" class="retry-btn">Retry</button>
|
||||||
@@ -529,6 +647,10 @@ const isUrl = (string) => {
|
|||||||
z-index: 0;
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.camera-bg.is-mirrored {
|
||||||
|
transform: scaleX(-1);
|
||||||
|
}
|
||||||
|
|
||||||
.camera-feed {
|
.camera-feed {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -536,7 +658,21 @@ const isUrl = (string) => {
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.camera-feed.is-front {
|
.camera-feed.is-mirrored {
|
||||||
|
transform: scaleX(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.scan-overlay-canvas {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scan-overlay-canvas.is-mirrored {
|
||||||
transform: scaleX(-1);
|
transform: scaleX(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed, watch, onUnmounted } from 'vue'
|
||||||
import { X, Plus, Trash2, RotateCcw } from 'lucide-vue-next'
|
import { X, Plus, Trash2, RotateCcw } from 'lucide-vue-next'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -10,6 +10,24 @@ const props = defineProps({
|
|||||||
|
|
||||||
const emit = defineEmits(['close', 'update:exceptions'])
|
const emit = defineEmits(['close', 'update:exceptions'])
|
||||||
|
|
||||||
|
const handleKeydown = (e) => {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => props.isOpen, (isOpen) => {
|
||||||
|
if (isOpen) {
|
||||||
|
window.addEventListener('keydown', handleKeydown)
|
||||||
|
} else {
|
||||||
|
window.removeEventListener('keydown', handleKeydown)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener('keydown', handleKeydown)
|
||||||
|
})
|
||||||
|
|
||||||
const newRule = ref({
|
const newRule = ref({
|
||||||
domainPattern: '',
|
domainPattern: '',
|
||||||
keepParams: '',
|
keepParams: '',
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref, watch, onUnmounted } from 'vue'
|
||||||
import { Plug, Plus, X } from 'lucide-vue-next'
|
import { Plug, Plus, X } from 'lucide-vue-next'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -13,6 +13,24 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const showModal = ref(false)
|
const showModal = ref(false)
|
||||||
|
|
||||||
|
const handleKeydown = (e) => {
|
||||||
|
if (e.key === 'Escape' && showModal.value) {
|
||||||
|
showModal.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(showModal, (isOpen) => {
|
||||||
|
if (isOpen) {
|
||||||
|
window.addEventListener('keydown', handleKeydown)
|
||||||
|
} else {
|
||||||
|
window.removeEventListener('keydown', handleKeydown)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
window.removeEventListener('keydown', handleKeydown)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
Reference in New Issue
Block a user