Преглед на файлове

chore(entry) move <a> handling code from q-app (#21)

Lucas Fernandes Nogueira преди 6 години
родител
ревизия
88f01efbe5
променени са 1 файла, в които са добавени 12 реда и са изтрити 0 реда
  1. 12 0
      lib/tauri.js

+ 12 - 0
lib/tauri.js

@@ -11,6 +11,18 @@
  *
  **/
 
+// open <a href="..."> links with the Tauri API
+document.querySelector('body').addEventListener('click', e => {
+  let target = e.target
+  while (target != null) {
+    if (target.matches ? target.matches('a') : target.msMatchesSelector('a')) {
+      tauri.open(target.href)
+      break
+    }
+    target = target.parentElement
+  }
+}, true)
+
 /**
  * @module tauri
  * @description This API interface makes powerful interactions available