Skip to content

Commit

Permalink
ui: collapsible side pannel
Browse files Browse the repository at this point in the history
  • Loading branch information
VisionView committed Aug 12, 2023
1 parent 149049f commit 261c8a6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"debug": "^4.3.4",
"electron-store": "^8.1.0",
"highlight.js": "^11.8.0",
"mitt": "^3.0.1",
"monaco-editor": "^0.41.0",
"pinia": "^2.1.6",
"vue": "^3.3.4",
Expand Down
18 changes: 12 additions & 6 deletions src/layout/components/the-aside.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,30 @@
<script setup lang="ts">
import { DataBase, Folders, LogoGithub, Settings, UserAvatar } from '@vicons/carbon';
import { useLang } from './../../lang';
import { useBus } from './../../utils';
import theAsideIcon from './the-aside-icon.vue';
const lang = useLang();
const router = useRouter();
const route = useRoute();
const mainNavList = ref([
{
id: 'connect',
path: '/',
path: '/connect',
name: lang.t('aside.connect'),
icon: markRaw(DataBase),
isLink: false,
},
{
id: 'file',
path: '/',
path: '/connect',
name: lang.t('aside.file'),
icon: markRaw(Folders),
isLink: false,
},
{
id: 'github',
path: '/',
path: '/connect',
name: lang.t('aside.github'),
icon: markRaw(LogoGithub),
isLink: true,
Expand Down Expand Up @@ -81,9 +83,13 @@ const navClick = (item: RouteItem) => {
if (item.isLink && item.id === 'github') {
window.electronAPI.openGitHub();
} else {
router.push({
path: item.path,
});
if (route.path === item.path) {
useBus.emit('pannel-change');
} else {
router.push({
path: item.path,
});
}
}
};
</script>
Expand Down
1 change: 0 additions & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ const router = createRouter({
},
],
});

export default router;
File renamed without changes.
3 changes: 2 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './debounce-throttle';
export * from './debounceThrottle';
export * from './mittBus';
2 changes: 2 additions & 0 deletions src/utils/mittBus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import mitt from 'mitt';
export const useBus = mitt();
18 changes: 12 additions & 6 deletions src/views/connect/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="connect-container">
<div class="connect-list" v-if="false">
<div class="connect-list" v-if="isPannelOpen">
<div class="add-connect" @click="addConnect">
<n-icon size="28">
<Add />
Expand All @@ -18,19 +18,25 @@

<script setup lang="ts">
import { Add } from '@vicons/carbon';
import ConnectModal from './components/connect-dialog.vue';
import connectList from './components/connect-list.vue';
import Editor from '../editor/index.vue';
const router = useRouter();
import { useBus } from './../../utils';
// DOM
const connectModalRef = ref();
const isPannelOpen = ref(true);
onMounted(() => {
})
useBus.on('pannel-change', pannelHandler);
});
onUnmounted(() => {
useBus.off('pannel-change');
});
const pannelHandler = () => {
isPannelOpen.value = !isPannelOpen.value;
};
const addConnect = () => connectModalRef.value.showMedal();
const editConnectHandler = (row: object) => {
Expand Down

0 comments on commit 261c8a6

Please sign in to comment.