feat: add launching screen to indicate launching status
feat: store custom aside width to preferences
This commit is contained in:
parent
49435848ee
commit
73f637a9f8
|
@ -1,19 +1,21 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import ContentPane from './components/content/ContentPane.vue'
|
import ContentPane from './components/content/ContentPane.vue'
|
||||||
import BrowserPane from './components/sidebar/BrowserPane.vue'
|
import BrowserPane from './components/sidebar/BrowserPane.vue'
|
||||||
import { computed, nextTick, onMounted, reactive } from 'vue'
|
import { computed, nextTick, onBeforeMount, onMounted, reactive, watch } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { get } from 'lodash'
|
import { debounce, get } from 'lodash'
|
||||||
import { useThemeVars } from 'naive-ui'
|
import { useThemeVars } from 'naive-ui'
|
||||||
import NavMenu from './components/sidebar/NavMenu.vue'
|
import NavMenu from './components/sidebar/NavMenu.vue'
|
||||||
import ConnectionPane from './components/sidebar/ConnectionPane.vue'
|
import ConnectionPane from './components/sidebar/ConnectionPane.vue'
|
||||||
import ContentServerPane from './components/content/ContentServerPane.vue'
|
import ContentServerPane from './components/content/ContentServerPane.vue'
|
||||||
import useTabStore from './stores/tab.js'
|
import useTabStore from './stores/tab.js'
|
||||||
import usePreferencesStore from './stores/preferences.js'
|
import usePreferencesStore from './stores/preferences.js'
|
||||||
|
import useConnectionStore from './stores/connections.js'
|
||||||
|
|
||||||
const themeVars = useThemeVars()
|
const themeVars = useThemeVars()
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
|
initializing: false,
|
||||||
navMenuWidth: 60,
|
navMenuWidth: 60,
|
||||||
hoverResize: false,
|
hoverResize: false,
|
||||||
resizing: false,
|
resizing: false,
|
||||||
|
@ -21,26 +23,28 @@ const data = reactive({
|
||||||
|
|
||||||
const tabStore = useTabStore()
|
const tabStore = useTabStore()
|
||||||
const prefStore = usePreferencesStore()
|
const prefStore = usePreferencesStore()
|
||||||
|
const connectionStore = useConnectionStore()
|
||||||
// const preferences = ref({})
|
// const preferences = ref({})
|
||||||
// provide('preferences', preferences)
|
// provide('preferences', preferences)
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
|
|
||||||
onMounted(async () => {
|
onBeforeMount(async () => {
|
||||||
await prefStore.loadFontList()
|
try {
|
||||||
await prefStore.loadPreferences()
|
data.initializing = true
|
||||||
await nextTick(() => {
|
await prefStore.loadPreferences()
|
||||||
i18n.locale.value = get(prefStore.general, 'language', 'en')
|
i18n.locale.value = get(prefStore.general, 'language', 'en')
|
||||||
})
|
await prefStore.loadFontList()
|
||||||
|
await connectionStore.initConnections()
|
||||||
|
} finally {
|
||||||
|
data.initializing = false
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: apply font size to all elements
|
const saveWidth = debounce(prefStore.savePreferences, 1000, { trailing: true })
|
||||||
// const getFontSize = computed(() => {
|
|
||||||
// return get(prefStore.general, 'fontSize', 'en')
|
|
||||||
// })
|
|
||||||
|
|
||||||
const handleResize = (evt) => {
|
const handleResize = (evt) => {
|
||||||
if (data.resizing) {
|
if (data.resizing) {
|
||||||
tabStore.asideWidth = Math.max(evt.clientX - data.navMenuWidth, 300)
|
prefStore.setNavWidth(Math.max(evt.clientX - data.navMenuWidth, 300))
|
||||||
|
saveWidth()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +62,7 @@ const startResize = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const asideWidthVal = computed(() => {
|
const asideWidthVal = computed(() => {
|
||||||
return tabStore.asideWidth + 'px'
|
return prefStore.general.navMenuWidth + 'px'
|
||||||
})
|
})
|
||||||
|
|
||||||
const dragging = computed(() => {
|
const dragging = computed(() => {
|
||||||
|
@ -68,52 +72,56 @@ const dragging = computed(() => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<!-- app content-->
|
<!-- app content-->
|
||||||
<div id="app-container" :class="{ dragging }" class="flex-box-h" :style="prefStore.generalFont">
|
<!-- <div id="app-container"></div>-->
|
||||||
<nav-menu v-model:value="tabStore.nav" :width="data.navMenuWidth" />
|
<n-spin :show="data.initializing" :theme-overrides="{ opacitySpinning: 0 }">
|
||||||
<!-- structure page-->
|
<template #description> {{ $t('launching') }} </template>
|
||||||
<div v-show="tabStore.nav === 'structure'" class="flex-box-h flex-item-expand">
|
<div id="app-container" :class="{ dragging }" class="flex-box-h" :style="prefStore.generalFont">
|
||||||
<div id="app-side" :style="{ width: asideWidthVal }" class="flex-box-h flex-item">
|
<nav-menu v-model:value="tabStore.nav" :width="data.navMenuWidth" />
|
||||||
<browser-pane
|
<!-- structure page-->
|
||||||
v-for="t in tabStore.tabs"
|
<div v-show="tabStore.nav === 'structure'" class="flex-box-h flex-item-expand">
|
||||||
v-show="get(tabStore.currentTab, 'name') === t.name"
|
<div id="app-side" :style="{ width: asideWidthVal }" class="flex-box-h flex-item">
|
||||||
:key="t.name"
|
<browser-pane
|
||||||
class="flex-item-expand"
|
v-for="t in tabStore.tabs"
|
||||||
/>
|
v-show="get(tabStore.currentTab, 'name') === t.name"
|
||||||
<div
|
:key="t.name"
|
||||||
:class="{
|
class="flex-item-expand"
|
||||||
'resize-divider-hover': data.hoverResize,
|
/>
|
||||||
'resize-divider-drag': data.resizing,
|
<div
|
||||||
}"
|
:class="{
|
||||||
class="resize-divider"
|
'resize-divider-hover': data.hoverResize,
|
||||||
@mousedown="startResize"
|
'resize-divider-drag': data.resizing,
|
||||||
@mouseout="data.hoverResize = false"
|
}"
|
||||||
@mouseover="data.hoverResize = true"
|
class="resize-divider"
|
||||||
/>
|
@mousedown="startResize"
|
||||||
|
@mouseout="data.hoverResize = false"
|
||||||
|
@mouseover="data.hoverResize = true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<content-pane class="flex-item-expand" />
|
||||||
</div>
|
</div>
|
||||||
<content-pane class="flex-item-expand" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- server list page -->
|
<!-- server list page -->
|
||||||
<div v-show="tabStore.nav === 'server'" class="flex-box-h flex-item-expand">
|
<div v-show="tabStore.nav === 'server'" class="flex-box-h flex-item-expand">
|
||||||
<div id="app-side" :style="{ width: asideWidthVal }" class="flex-box-h flex-item">
|
<div id="app-side" :style="{ width: asideWidthVal }" class="flex-box-h flex-item">
|
||||||
<connection-pane class="flex-item-expand" />
|
<connection-pane class="flex-item-expand" />
|
||||||
<div
|
<div
|
||||||
:class="{
|
:class="{
|
||||||
'resize-divider-hover': data.hoverResize,
|
'resize-divider-hover': data.hoverResize,
|
||||||
'resize-divider-drag': data.resizing,
|
'resize-divider-drag': data.resizing,
|
||||||
}"
|
}"
|
||||||
class="resize-divider"
|
class="resize-divider"
|
||||||
@mousedown="startResize"
|
@mousedown="startResize"
|
||||||
@mouseout="data.hoverResize = false"
|
@mouseout="data.hoverResize = false"
|
||||||
@mouseover="data.hoverResize = true"
|
@mouseover="data.hoverResize = true"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
<content-server-pane class="flex-item-expand" />
|
||||||
</div>
|
</div>
|
||||||
<content-server-pane class="flex-item-expand" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- log page -->
|
<!-- log page -->
|
||||||
<div v-show="tabStore.nav === 'log'">display log</div>
|
<div v-show="tabStore.nav === 'log'">display log</div>
|
||||||
</div>
|
</div>
|
||||||
|
</n-spin>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
@ -18,7 +18,6 @@ import Edit from '../icons/Edit.vue'
|
||||||
import { useConfirmDialog } from '../../utils/confirm_dialog.js'
|
import { useConfirmDialog } from '../../utils/confirm_dialog.js'
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const loadingConnection = ref(false)
|
|
||||||
const openingConnection = ref(false)
|
const openingConnection = ref(false)
|
||||||
const connectionStore = useConnectionStore()
|
const connectionStore = useConnectionStore()
|
||||||
const tabStore = useTabStore()
|
const tabStore = useTabStore()
|
||||||
|
@ -34,16 +33,6 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
try {
|
|
||||||
loadingConnection.value = true
|
|
||||||
await nextTick()
|
|
||||||
await connectionStore.initConnections()
|
|
||||||
} finally {
|
|
||||||
loadingConnection.value = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const contextMenuParam = reactive({
|
const contextMenuParam = reactive({
|
||||||
show: false,
|
show: false,
|
||||||
x: 0,
|
x: 0,
|
||||||
|
@ -337,7 +326,7 @@ const handleDrop = ({ node, dragNode, dropPosition }) => {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- status display modal -->
|
<!-- status display modal -->
|
||||||
<n-modal :show="loadingConnection || openingConnection" transform-origin="center">
|
<n-modal :show="openingConnection" transform-origin="center">
|
||||||
<n-card
|
<n-card
|
||||||
:bordered="false"
|
:bordered="false"
|
||||||
:content-style="{ textAlign: 'center' }"
|
:content-style="{ textAlign: 'center' }"
|
||||||
|
@ -347,7 +336,7 @@ const handleDrop = ({ node, dragNode, dropPosition }) => {
|
||||||
>
|
>
|
||||||
<n-spin>
|
<n-spin>
|
||||||
<template #description>
|
<template #description>
|
||||||
{{ openingConnection ? $t('opening_connection') : '' }}
|
{{ $t('opening_connection') }}
|
||||||
</template>
|
</template>
|
||||||
</n-spin>
|
</n-spin>
|
||||||
</n-card>
|
</n-card>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"lang_name": "English",
|
"lang_name": "English",
|
||||||
|
"launching": "Launching...",
|
||||||
"confirm": "Confirm",
|
"confirm": "Confirm",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"success": "Success",
|
"success": "Success",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"lang_name": "简体中文",
|
"lang_name": "简体中文",
|
||||||
|
"launching": "启动中...",
|
||||||
"confirm": "确认",
|
"confirm": "确认",
|
||||||
"cancel": "取消",
|
"cancel": "取消",
|
||||||
"success": "成功",
|
"success": "成功",
|
||||||
|
|
|
@ -33,6 +33,7 @@ const usePreferencesStore = defineStore('preferences', {
|
||||||
useSysProxy: false,
|
useSysProxy: false,
|
||||||
useSysProxyHttp: false,
|
useSysProxyHttp: false,
|
||||||
checkUpdate: false,
|
checkUpdate: false,
|
||||||
|
navMenuWidth: 300,
|
||||||
},
|
},
|
||||||
editor: {
|
editor: {
|
||||||
font: '',
|
font: '',
|
||||||
|
@ -165,6 +166,10 @@ const usePreferencesStore = defineStore('preferences', {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setNavWidth(width) {
|
||||||
|
this.general.navMenuWidth = width
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue