Explorar o código

feat: search kbd shortcut + fix logo upload

NGPixel %!s(int64=2) %!d(string=hai) anos
pai
achega
b8a44d99ae
Modificáronse 2 ficheiros con 40 adicións e 17 borrados
  1. 4 6
      server/graph/resolvers/site.mjs
  2. 36 11
      ux/src/components/HeaderNav.vue

+ 4 - 6
server/graph/resolvers/site.mjs

@@ -184,8 +184,7 @@ export default {
         const imgBuffer = await fs.readFile(destPath)
         await WIKI.db.knex('assets').insert({
           id: site.config.assets.logo,
-          filename: `_logo.${destFormat}`,
-          hash: '_logo',
+          fileName: `_logo.${destFormat}`,
           fileExt: `.${destFormat}`,
           isSystem: true,
           kind: 'image',
@@ -245,12 +244,11 @@ export default {
         const imgBuffer = await fs.readFile(destPath)
         await WIKI.db.knex('assets').insert({
           id: site.config.assets.favicon,
-          filename: `_favicon.${destFormat}`,
-          hash: '_favicon',
-          ext: `.${destFormat}`,
+          fileName: `_favicon.${destFormat}`,
+          fileExt: `.${destFormat}`,
           isSystem: true,
           kind: 'image',
-          mime: (destFormat === 'svg') ? 'image/svg' : 'image/png',
+          mimeType: (destFormat === 'svg') ? 'image/svg' : 'image/png',
           fileSize: Math.ceil(imgBuffer.byteLength / 1024),
           data: imgBuffer,
           authorId: context.req.user.id,

+ 36 - 11
ux/src/components/HeaderNav.vue

@@ -49,18 +49,19 @@ q-header.bg-header.text-white.site-header(
             :color='$q.dark.isActive ? `blue` : `grey-4`'
             )
           q-badge.q-ml-sm(
-            label='v3 Preview'
-            color='pink'
+            label='Ctrl+K'
+            color='grey-7'
             outline
+            @click='searchField.focus()'
             )
-      q-btn.q-ml-md(
-        flat
-        round
-        dense
-        icon='las la-tags'
-        color='grey'
-        to='/_tags'
-        )
+      //- q-btn.q-ml-md(
+      //-   flat
+      //-   round
+      //-   dense
+      //-   icon='las la-tags'
+      //-   color='grey'
+      //-   to='/_tags'
+      //-   )
     q-toolbar(
       style='height: 64px;'
       dark
@@ -128,7 +129,7 @@ import NewMenu from './PageNewMenu.vue'
 
 import { useI18n } from 'vue-i18n'
 import { useQuasar } from 'quasar'
-import { reactive } from 'vue'
+import { onBeforeUnmount, onMounted, reactive, ref } from 'vue'
 
 import { useCommonStore } from 'src/stores/common'
 import { useSiteStore } from 'src/stores/site'
@@ -154,11 +155,35 @@ const state = reactive({
   search: ''
 })
 
+const searchField = ref(null)
+
 // METHODS
 
 function openFileManager () {
   siteStore.openFileManager()
 }
+
+function handleKeyPress (ev) {
+  if (siteStore.features.search) {
+    if (ev.ctrlKey && ev.key === 'k') {
+      ev.preventDefault()
+      searchField.value.focus()
+    }
+  }
+}
+
+// MOUNTED
+
+onMounted(() => {
+  if (process.env.CLIENT) {
+    window.addEventListener('keydown', handleKeyPress)
+  }
+})
+onBeforeUnmount(() => {
+  if (process.env.CLIENT) {
+    window.removeEventListener('keydown', handleKeyPress)
+  }
+})
 </script>
 
 <style lang="scss">