2023-06-28 00:47:44 +08:00
|
|
|
<script setup>
|
2023-07-01 02:05:30 +08:00
|
|
|
import ContentPane from './components/content/ContentPane.vue'
|
2023-07-03 23:48:41 +08:00
|
|
|
import BrowserPane from './components/sidebar/BrowserPane.vue'
|
2023-10-15 04:02:09 +08:00
|
|
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
2023-07-12 15:48:49 +08:00
|
|
|
import { debounce, get } from 'lodash'
|
2023-06-28 00:47:44 +08:00
|
|
|
import { useThemeVars } from 'naive-ui'
|
2023-07-03 23:48:41 +08:00
|
|
|
import NavMenu from './components/sidebar/NavMenu.vue'
|
2023-07-01 02:05:30 +08:00
|
|
|
import ConnectionPane from './components/sidebar/ConnectionPane.vue'
|
|
|
|
import ContentServerPane from './components/content/ContentServerPane.vue'
|
|
|
|
import useTabStore from './stores/tab.js'
|
2023-07-11 18:06:44 +08:00
|
|
|
import usePreferencesStore from './stores/preferences.js'
|
2023-07-12 15:48:49 +08:00
|
|
|
import useConnectionStore from './stores/connections.js'
|
2023-07-16 01:50:01 +08:00
|
|
|
import ContentLogPane from './components/content/ContentLogPane.vue'
|
2023-09-02 18:23:40 +08:00
|
|
|
import ContentValueTab from '@/components/content/ContentValueTab.vue'
|
|
|
|
import ToolbarControlWidget from '@/components/common/ToolbarControlWidget.vue'
|
2023-10-15 04:02:09 +08:00
|
|
|
import { EventsOn, WindowIsFullscreen, WindowIsMaximised, WindowToggleMaximise } from 'wailsjs/runtime/runtime.js'
|
2023-09-02 18:23:40 +08:00
|
|
|
import { isMacOS } from '@/utils/platform.js'
|
|
|
|
import iconUrl from '@/assets/images/icon.png'
|
2023-10-27 18:26:35 +08:00
|
|
|
import ResizeableWrapper from '@/components/common/ResizeableWrapper.vue'
|
2023-10-28 22:22:48 +08:00
|
|
|
import { extraTheme } from '@/utils/extra_theme.js'
|
2023-06-28 00:47:44 +08:00
|
|
|
|
|
|
|
const themeVars = useThemeVars()
|
|
|
|
|
2023-09-05 14:43:43 +08:00
|
|
|
const props = defineProps({
|
|
|
|
loading: Boolean,
|
|
|
|
})
|
|
|
|
|
2023-06-28 00:47:44 +08:00
|
|
|
const data = reactive({
|
2023-07-01 02:05:30 +08:00
|
|
|
navMenuWidth: 60,
|
2023-09-02 18:23:40 +08:00
|
|
|
toolbarHeight: 45,
|
2023-06-28 00:47:44 +08:00
|
|
|
})
|
|
|
|
|
2023-07-01 02:05:30 +08:00
|
|
|
const tabStore = useTabStore()
|
2023-07-12 11:48:08 +08:00
|
|
|
const prefStore = usePreferencesStore()
|
2023-07-12 15:48:49 +08:00
|
|
|
const connectionStore = useConnectionStore()
|
2023-08-02 19:42:05 +08:00
|
|
|
const logPaneRef = ref(null)
|
2023-10-28 22:22:48 +08:00
|
|
|
const exThemeVars = computed(() => {
|
|
|
|
return extraTheme(prefStore.isDark)
|
|
|
|
})
|
2023-07-11 18:06:44 +08:00
|
|
|
// const preferences = ref({})
|
|
|
|
// provide('preferences', preferences)
|
2023-06-28 00:47:44 +08:00
|
|
|
|
2023-10-15 04:02:09 +08:00
|
|
|
const saveSidebarWidth = debounce(prefStore.savePreferences, 1000, { trailing: true })
|
2023-10-27 18:26:35 +08:00
|
|
|
const handleResize = () => {
|
|
|
|
saveSidebarWidth()
|
2023-06-28 00:47:44 +08:00
|
|
|
}
|
|
|
|
|
2023-08-02 19:42:05 +08:00
|
|
|
watch(
|
|
|
|
() => tabStore.nav,
|
|
|
|
(nav) => {
|
|
|
|
if (nav === 'log') {
|
|
|
|
logPaneRef.value?.refresh()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
2023-09-24 22:48:41 +08:00
|
|
|
|
2023-10-27 16:41:27 +08:00
|
|
|
const logoWrapperWidth = computed(() => {
|
|
|
|
return `${data.navMenuWidth + prefStore.behavior.asideWidth - 4}px`
|
|
|
|
})
|
|
|
|
|
2023-10-15 04:02:09 +08:00
|
|
|
const logoPaddingLeft = ref(10)
|
|
|
|
const maximised = ref(false)
|
2023-10-28 22:59:47 +08:00
|
|
|
const hideRadius = ref(false)
|
|
|
|
const wrapperStyle = computed(() => {
|
|
|
|
return hideRadius.value
|
|
|
|
? {}
|
|
|
|
: {
|
|
|
|
border: `1px solid ${themeVars.value.borderColor}`,
|
|
|
|
borderRadius: '10px',
|
|
|
|
}
|
|
|
|
})
|
2023-10-30 21:54:20 +08:00
|
|
|
const spinStyle = computed(() => {
|
|
|
|
return hideRadius.value
|
|
|
|
? {
|
|
|
|
backgroundColor: themeVars.value.bodyColor,
|
|
|
|
}
|
|
|
|
: {
|
|
|
|
backgroundColor: themeVars.value.bodyColor,
|
|
|
|
borderRadius: '10px',
|
|
|
|
}
|
|
|
|
})
|
2023-10-15 04:02:09 +08:00
|
|
|
|
|
|
|
const onToggleFullscreen = (fullscreen) => {
|
2023-10-28 22:59:47 +08:00
|
|
|
hideRadius.value = fullscreen
|
2023-10-15 04:02:09 +08:00
|
|
|
if (fullscreen) {
|
|
|
|
logoPaddingLeft.value = 10
|
|
|
|
} else {
|
|
|
|
logoPaddingLeft.value = isMacOS() ? 70 : 10
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const onToggleMaximize = (isMaximised) => {
|
|
|
|
if (isMaximised) {
|
|
|
|
maximised.value = true
|
2023-10-30 21:54:20 +08:00
|
|
|
if (!isMacOS()) {
|
|
|
|
hideRadius.value = true
|
|
|
|
}
|
2023-10-15 04:02:09 +08:00
|
|
|
} else {
|
|
|
|
maximised.value = false
|
2023-10-30 21:54:20 +08:00
|
|
|
if (!isMacOS()) {
|
|
|
|
hideRadius.value = false
|
|
|
|
}
|
2023-10-15 04:02:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EventsOn('window_changed', (info) => {
|
|
|
|
const { fullscreen, maximised } = info
|
|
|
|
onToggleFullscreen(fullscreen === true)
|
|
|
|
onToggleMaximize(maximised)
|
|
|
|
})
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
const fullscreen = await WindowIsFullscreen()
|
|
|
|
onToggleFullscreen(fullscreen === true)
|
|
|
|
const maximised = await WindowIsMaximised()
|
|
|
|
onToggleMaximize(maximised)
|
|
|
|
})
|
2023-06-28 00:47:44 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<!-- app content-->
|
2023-10-30 21:54:20 +08:00
|
|
|
<n-spin :show="props.loading" :style="spinStyle" :theme-overrides="{ opacitySpinning: 0 }">
|
2023-10-28 22:59:47 +08:00
|
|
|
<div id="app-content-wrapper" :style="wrapperStyle" class="flex-box-v">
|
2023-09-05 14:43:43 +08:00
|
|
|
<!-- title bar -->
|
2023-09-02 18:23:40 +08:00
|
|
|
<div
|
2023-09-05 14:43:43 +08:00
|
|
|
id="app-toolbar"
|
2023-10-20 18:34:19 +08:00
|
|
|
:style="{ height: data.toolbarHeight + 'px' }"
|
2023-09-05 14:43:43 +08:00
|
|
|
class="flex-box-h"
|
|
|
|
style="--wails-draggable: drag"
|
|
|
|
@dblclick="WindowToggleMaximise">
|
|
|
|
<!-- title -->
|
|
|
|
<div
|
|
|
|
id="app-toolbar-title"
|
|
|
|
:style="{
|
2023-10-27 16:41:27 +08:00
|
|
|
width: logoWrapperWidth,
|
|
|
|
minWidth: logoWrapperWidth,
|
2023-10-15 04:02:09 +08:00
|
|
|
paddingLeft: `${logoPaddingLeft}px`,
|
2023-09-05 14:43:43 +08:00
|
|
|
}">
|
2023-10-20 18:34:19 +08:00
|
|
|
<n-space :size="3" :wrap="false" :wrap-item="false" align="center">
|
|
|
|
<n-avatar :size="35" :src="iconUrl" color="#0000" style="min-width: 35px" />
|
2023-09-05 14:43:43 +08:00
|
|
|
<div style="min-width: 68px; font-weight: 800">Tiny RDM</div>
|
|
|
|
<transition name="fade">
|
2023-10-20 18:34:19 +08:00
|
|
|
<n-text v-if="tabStore.nav === 'browser'" class="ellipsis" strong style="font-size: 13px">
|
2023-09-05 14:43:43 +08:00
|
|
|
- {{ get(tabStore.currentTab, 'name') }}
|
|
|
|
</n-text>
|
|
|
|
</transition>
|
|
|
|
</n-space>
|
|
|
|
</div>
|
|
|
|
<!-- browser tabs -->
|
|
|
|
<div v-show="tabStore.nav === 'browser'" class="app-toolbar-tab flex-item-expand">
|
|
|
|
<content-value-tab />
|
|
|
|
</div>
|
|
|
|
<div class="flex-item-expand"></div>
|
|
|
|
<!-- simulate window control buttons -->
|
2023-10-15 04:02:09 +08:00
|
|
|
<toolbar-control-widget
|
|
|
|
v-if="!isMacOS()"
|
|
|
|
:maximised="maximised"
|
2023-10-20 18:34:19 +08:00
|
|
|
:size="data.toolbarHeight"
|
2023-10-15 04:02:09 +08:00
|
|
|
style="align-self: flex-start" />
|
2023-09-02 18:23:40 +08:00
|
|
|
</div>
|
2023-07-01 02:05:30 +08:00
|
|
|
|
2023-09-05 14:43:43 +08:00
|
|
|
<!-- content -->
|
2023-09-06 16:07:20 +08:00
|
|
|
<div
|
|
|
|
id="app-content"
|
|
|
|
:style="prefStore.generalFont"
|
2023-10-20 18:34:19 +08:00
|
|
|
class="flex-box-h flex-item-expand"
|
|
|
|
style="--wails-draggable: none">
|
2023-09-05 14:43:43 +08:00
|
|
|
<nav-menu v-model:value="tabStore.nav" :width="data.navMenuWidth" />
|
2023-09-22 18:31:50 +08:00
|
|
|
<!-- browser page -->
|
2023-10-30 21:54:20 +08:00
|
|
|
<div v-show="tabStore.nav === 'browser'" class="content-area flex-box-h flex-item-expand">
|
2023-10-27 18:26:35 +08:00
|
|
|
<resizeable-wrapper
|
|
|
|
v-model:size="prefStore.behavior.asideWidth"
|
|
|
|
:min-size="300"
|
|
|
|
:offset="data.navMenuWidth"
|
|
|
|
class="flex-item"
|
|
|
|
@update:size="handleResize">
|
2023-09-05 14:43:43 +08:00
|
|
|
<browser-pane
|
|
|
|
v-for="t in tabStore.tabs"
|
|
|
|
v-show="get(tabStore.currentTab, 'name') === t.name"
|
|
|
|
:key="t.name"
|
2023-10-27 18:26:35 +08:00
|
|
|
class="app-side flex-item-expand" />
|
|
|
|
</resizeable-wrapper>
|
2023-10-27 10:50:22 +08:00
|
|
|
<content-pane
|
|
|
|
v-for="t in tabStore.tabs"
|
|
|
|
v-show="get(tabStore.currentTab, 'name') === t.name"
|
|
|
|
:key="t.name"
|
|
|
|
:server="t.name"
|
|
|
|
class="flex-item-expand" />
|
2023-09-02 18:23:40 +08:00
|
|
|
</div>
|
|
|
|
|
2023-09-05 14:43:43 +08:00
|
|
|
<!-- server list page -->
|
2023-10-30 21:54:20 +08:00
|
|
|
<div v-show="tabStore.nav === 'server'" class="content-area flex-box-h flex-item-expand">
|
2023-10-27 18:26:35 +08:00
|
|
|
<resizeable-wrapper
|
|
|
|
v-model:size="prefStore.behavior.asideWidth"
|
|
|
|
:min-size="300"
|
|
|
|
:offset="data.navMenuWidth"
|
|
|
|
class="flex-item"
|
|
|
|
@update:size="handleResize">
|
|
|
|
<connection-pane class="app-side flex-item-expand" />
|
|
|
|
</resizeable-wrapper>
|
2023-09-05 14:43:43 +08:00
|
|
|
<content-server-pane class="flex-item-expand" />
|
2023-09-02 18:23:40 +08:00
|
|
|
</div>
|
2023-07-13 15:46:12 +08:00
|
|
|
|
2023-09-05 14:43:43 +08:00
|
|
|
<!-- log page -->
|
2023-10-30 21:54:20 +08:00
|
|
|
<div v-show="tabStore.nav === 'log'" class="content-area flex-box-h flex-item-expand">
|
2023-09-05 14:43:43 +08:00
|
|
|
<content-log-pane ref="logPaneRef" class="flex-item-expand" />
|
|
|
|
</div>
|
2023-09-02 18:23:40 +08:00
|
|
|
</div>
|
2023-07-16 01:50:01 +08:00
|
|
|
</div>
|
2023-09-05 14:43:43 +08:00
|
|
|
</n-spin>
|
2023-06-28 00:47:44 +08:00
|
|
|
</template>
|
|
|
|
|
2023-08-02 19:42:05 +08:00
|
|
|
<style lang="scss" scoped>
|
2023-07-15 01:54:40 +08:00
|
|
|
#app-content-wrapper {
|
2023-10-28 22:22:48 +08:00
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
2023-06-28 00:47:44 +08:00
|
|
|
overflow: hidden;
|
|
|
|
box-sizing: border-box;
|
2023-10-28 22:22:48 +08:00
|
|
|
background-color: v-bind('themeVars.bodyColor');
|
2023-10-28 22:59:47 +08:00
|
|
|
color: v-bind('themeVars.textColorBase');
|
2023-06-28 00:47:44 +08:00
|
|
|
|
|
|
|
#app-toolbar {
|
2023-10-28 22:22:48 +08:00
|
|
|
background-color: v-bind('exThemeVars.titleColor');
|
|
|
|
border-bottom: 1px solid v-bind('exThemeVars.splitColor');
|
2023-09-02 18:23:40 +08:00
|
|
|
|
|
|
|
&-title {
|
|
|
|
padding-left: 10px;
|
|
|
|
padding-right: 10px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
align-self: center;
|
|
|
|
align-items: baseline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.app-toolbar-tab {
|
|
|
|
align-self: flex-end;
|
|
|
|
margin-bottom: -1px;
|
2023-09-03 00:15:31 +08:00
|
|
|
margin-left: 3px;
|
2023-09-02 18:23:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#app-content {
|
|
|
|
height: calc(100% - 60px);
|
2023-10-30 21:54:20 +08:00
|
|
|
|
|
|
|
.content-area {
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
2023-06-28 00:47:44 +08:00
|
|
|
}
|
|
|
|
|
2023-10-27 16:41:27 +08:00
|
|
|
.app-side {
|
2023-06-28 00:47:44 +08:00
|
|
|
//overflow: hidden;
|
|
|
|
height: 100%;
|
2023-10-28 22:22:48 +08:00
|
|
|
background-color: v-bind('exThemeVars.sidebarColor');
|
|
|
|
border-right: 1px solid v-bind('exThemeVars.splitColor');
|
2023-09-03 00:15:31 +08:00
|
|
|
}
|
|
|
|
}
|
2023-06-28 00:47:44 +08:00
|
|
|
|
2023-09-02 18:23:40 +08:00
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.3s ease;
|
|
|
|
}
|
2023-06-28 00:47:44 +08:00
|
|
|
</style>
|