Unverified Commit b8a44d99 authored by NGPixel's avatar NGPixel

feat: search kbd shortcut + fix logo upload

parent bb4a1e6b
...@@ -184,8 +184,7 @@ export default { ...@@ -184,8 +184,7 @@ export default {
const imgBuffer = await fs.readFile(destPath) const imgBuffer = await fs.readFile(destPath)
await WIKI.db.knex('assets').insert({ await WIKI.db.knex('assets').insert({
id: site.config.assets.logo, id: site.config.assets.logo,
filename: `_logo.${destFormat}`, fileName: `_logo.${destFormat}`,
hash: '_logo',
fileExt: `.${destFormat}`, fileExt: `.${destFormat}`,
isSystem: true, isSystem: true,
kind: 'image', kind: 'image',
...@@ -245,12 +244,11 @@ export default { ...@@ -245,12 +244,11 @@ export default {
const imgBuffer = await fs.readFile(destPath) const imgBuffer = await fs.readFile(destPath)
await WIKI.db.knex('assets').insert({ await WIKI.db.knex('assets').insert({
id: site.config.assets.favicon, id: site.config.assets.favicon,
filename: `_favicon.${destFormat}`, fileName: `_favicon.${destFormat}`,
hash: '_favicon', fileExt: `.${destFormat}`,
ext: `.${destFormat}`,
isSystem: true, isSystem: true,
kind: 'image', kind: 'image',
mime: (destFormat === 'svg') ? 'image/svg' : 'image/png', mimeType: (destFormat === 'svg') ? 'image/svg' : 'image/png',
fileSize: Math.ceil(imgBuffer.byteLength / 1024), fileSize: Math.ceil(imgBuffer.byteLength / 1024),
data: imgBuffer, data: imgBuffer,
authorId: context.req.user.id, authorId: context.req.user.id,
......
...@@ -49,18 +49,19 @@ q-header.bg-header.text-white.site-header( ...@@ -49,18 +49,19 @@ q-header.bg-header.text-white.site-header(
:color='$q.dark.isActive ? `blue` : `grey-4`' :color='$q.dark.isActive ? `blue` : `grey-4`'
) )
q-badge.q-ml-sm( q-badge.q-ml-sm(
label='v3 Preview' label='Ctrl+K'
color='pink' color='grey-7'
outline outline
@click='searchField.focus()'
) )
q-btn.q-ml-md( //- q-btn.q-ml-md(
flat //- flat
round //- round
dense //- dense
icon='las la-tags' //- icon='las la-tags'
color='grey' //- color='grey'
to='/_tags' //- to='/_tags'
) //- )
q-toolbar( q-toolbar(
style='height: 64px;' style='height: 64px;'
dark dark
...@@ -128,7 +129,7 @@ import NewMenu from './PageNewMenu.vue' ...@@ -128,7 +129,7 @@ import NewMenu from './PageNewMenu.vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useQuasar } from 'quasar' import { useQuasar } from 'quasar'
import { reactive } from 'vue' import { onBeforeUnmount, onMounted, reactive, ref } from 'vue'
import { useCommonStore } from 'src/stores/common' import { useCommonStore } from 'src/stores/common'
import { useSiteStore } from 'src/stores/site' import { useSiteStore } from 'src/stores/site'
...@@ -154,11 +155,35 @@ const state = reactive({ ...@@ -154,11 +155,35 @@ const state = reactive({
search: '' search: ''
}) })
const searchField = ref(null)
// METHODS // METHODS
function openFileManager () { function openFileManager () {
siteStore.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> </script>
<style lang="scss"> <style lang="scss">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment