2023-06-27 15:53:29 +08:00
|
|
|
<script setup>
|
2023-07-02 03:25:57 +08:00
|
|
|
import ConnectionDialog from './components/dialogs/ConnectionDialog.vue'
|
2023-06-27 15:53:29 +08:00
|
|
|
import NewKeyDialog from './components/dialogs/NewKeyDialog.vue'
|
|
|
|
import PreferencesDialog from './components/dialogs/PreferencesDialog.vue'
|
|
|
|
import RenameKeyDialog from './components/dialogs/RenameKeyDialog.vue'
|
|
|
|
import SetTtlDialog from './components/dialogs/SetTtlDialog.vue'
|
|
|
|
import hljs from 'highlight.js/lib/core'
|
|
|
|
import json from 'highlight.js/lib/languages/json'
|
|
|
|
import plaintext from 'highlight.js/lib/languages/plaintext'
|
|
|
|
import AddFieldsDialog from './components/dialogs/AddFieldsDialog.vue'
|
2023-06-28 00:47:44 +08:00
|
|
|
import AppContent from './AppContent.vue'
|
2023-07-02 16:52:07 +08:00
|
|
|
import GroupDialog from './components/dialogs/GroupDialog.vue'
|
2023-07-06 01:22:14 +08:00
|
|
|
import DeleteKeyDialog from './components/dialogs/DeleteKeyDialog.vue'
|
2023-07-13 15:46:12 +08:00
|
|
|
import { computed, onBeforeMount, ref } from 'vue'
|
|
|
|
import { get } from 'lodash'
|
|
|
|
import usePreferencesStore from './stores/preferences.js'
|
|
|
|
import useConnectionStore from './stores/connections.js'
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
import { darkTheme, lightTheme, useOsTheme } from 'naive-ui'
|
2023-06-27 15:53:29 +08:00
|
|
|
|
|
|
|
hljs.registerLanguage('json', json)
|
|
|
|
hljs.registerLanguage('plaintext', plaintext)
|
|
|
|
|
2023-07-13 15:46:12 +08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @type import('naive-ui').GlobalThemeOverrides
|
|
|
|
*/
|
2023-06-27 15:53:29 +08:00
|
|
|
const themeOverrides = {
|
|
|
|
common: {
|
2023-07-13 15:46:12 +08:00
|
|
|
primaryColor: '#D33A31',
|
|
|
|
primaryColorHover: '#FF6B6B',
|
|
|
|
primaryColorPressed: '#D5271C',
|
|
|
|
primaryColorSuppl: '#FF6B6B',
|
2023-06-27 15:53:29 +08:00
|
|
|
borderRadius: '4px',
|
|
|
|
borderRadiusSmall: '3px',
|
|
|
|
lineHeight: 1.5,
|
2023-07-13 15:46:12 +08:00
|
|
|
scrollbarWidth: '8px',
|
2023-06-27 15:53:29 +08:00
|
|
|
},
|
|
|
|
Tag: {
|
|
|
|
// borderRadius: '3px'
|
|
|
|
},
|
2023-06-28 00:47:44 +08:00
|
|
|
Tabs: {
|
|
|
|
tabGapSmallCard: '1px',
|
|
|
|
tabGapMediumCard: '1px',
|
|
|
|
tabGapLargeCard: '1px',
|
|
|
|
},
|
2023-06-27 15:53:29 +08:00
|
|
|
}
|
2023-07-13 15:46:12 +08:00
|
|
|
|
|
|
|
const prefStore = usePreferencesStore()
|
|
|
|
const connectionStore = useConnectionStore()
|
|
|
|
const i18n = useI18n()
|
|
|
|
const initializing = ref(false)
|
|
|
|
onBeforeMount(async () => {
|
|
|
|
try {
|
|
|
|
initializing.value = true
|
|
|
|
await prefStore.loadPreferences()
|
|
|
|
i18n.locale.value = get(prefStore.general, 'language', 'en')
|
|
|
|
await prefStore.loadFontList()
|
|
|
|
await connectionStore.initConnections()
|
|
|
|
} finally {
|
|
|
|
initializing.value = false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const osTheme = useOsTheme()
|
|
|
|
const theme = computed(() => {
|
|
|
|
if (prefStore.general.theme === 'auto') {
|
|
|
|
if (osTheme.value === 'dark') {
|
|
|
|
return darkTheme
|
|
|
|
}
|
|
|
|
} else if (prefStore.general.theme === 'dark') {
|
|
|
|
return darkTheme
|
|
|
|
}
|
|
|
|
return lightTheme
|
|
|
|
})
|
2023-06-27 15:53:29 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-07-13 15:46:12 +08:00
|
|
|
<n-config-provider
|
|
|
|
:hljs="hljs"
|
|
|
|
:inline-theme-disabled="true"
|
|
|
|
:theme="theme"
|
|
|
|
:theme-overrides="themeOverrides"
|
|
|
|
class="fill-height"
|
|
|
|
>
|
|
|
|
<n-global-style />
|
2023-06-27 15:53:29 +08:00
|
|
|
<n-message-provider>
|
|
|
|
<n-dialog-provider>
|
2023-07-13 15:46:12 +08:00
|
|
|
<n-spin v-show="initializing" :theme-overrides="{ opacitySpinning: 0 }">
|
|
|
|
<div id="launch-container" />
|
|
|
|
</n-spin>
|
2023-07-15 01:54:40 +08:00
|
|
|
<app-content v-if="!initializing" class="flex-item-expand" />
|
2023-06-27 15:53:29 +08:00
|
|
|
|
|
|
|
<!-- top modal dialogs -->
|
2023-07-02 03:25:57 +08:00
|
|
|
<connection-dialog />
|
2023-07-02 16:52:07 +08:00
|
|
|
<group-dialog />
|
2023-06-27 15:53:29 +08:00
|
|
|
<new-key-dialog />
|
|
|
|
<add-fields-dialog />
|
|
|
|
<rename-key-dialog />
|
2023-07-06 01:22:14 +08:00
|
|
|
<delete-key-dialog />
|
2023-06-27 15:53:29 +08:00
|
|
|
<set-ttl-dialog />
|
|
|
|
<preferences-dialog />
|
|
|
|
</n-dialog-provider>
|
|
|
|
</n-message-provider>
|
|
|
|
</n-config-provider>
|
|
|
|
</template>
|
|
|
|
|
2023-07-13 15:46:12 +08:00
|
|
|
<style lang="scss">
|
|
|
|
#launch-container {
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
}
|
2023-07-15 01:54:40 +08:00
|
|
|
|
|
|
|
#app-title {
|
|
|
|
text-align: center;
|
|
|
|
width: 100vw;
|
|
|
|
height: 30px;
|
|
|
|
line-height: 30px;
|
|
|
|
}
|
2023-07-13 15:46:12 +08:00
|
|
|
</style>
|