-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.vue
More file actions
73 lines (66 loc) · 1.87 KB
/
shell.vue
File metadata and controls
73 lines (66 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<template>
<div class="shell">
<div class="shell-nav">
<button v-for="(app, idx) in data.shell.apps" @click="newTab(idx)">{{app.name}}</button>
<br/>
<button v-for="(instance, idx) in data.shell.tabs" @click="data.shell.visibleTabIndex = idx">
<b v-if="data.shell.visibleTabIndex === idx">{{instance.app.name}} {{idx}}</b>
<span v-else>{{instance.app.name}} {{idx}}</span>
</button>
</div>
<div class="shell-content" v-if="data.shell.visibleTabIndex !== null">
<keep-alive>
<component v-bind:is="data.shell.tabs[data.shell.visibleTabIndex].instance"></component>
</keep-alive>
</div>
</div>
</template>
<script setup>
import {inject, reactive, ref} from 'vue'
const config = inject('config')
config.shell = {
navHeight: '40pt'
}
const data = inject('data')
data.shell = {
tabs: [],
visibleTabIndex: null,
apps: [{
name: "Image Editor",
src: "./image-editor.app.vue",
}, {
name: "Settings",
src: "./settings.app.vue",
isSingleton: true,
}],
}
function newTab(appIdx) {
let app = data.shell.apps[appIdx]
if (app?.isSingleton === true) {
for (let idx = 0; idx < data.shell.tabs.length; idx++) {
let e = data.shell.tabs[idx]
if (e.app.src === app.src) {
data.shell.visibleTabIndex = idx
return
}
}
}
let instance = getComponentDefinition(app.src)
data.shell.tabs.push({app: app, instance: instance})
data.shell.visibleTabIndex = data.shell.tabs.length - 1
}
</script>
<style scoped>
.shell {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
}
.shell-nav {
flex: 0 0 v-bind('config.shell.navHeight');
}
.shell-content {
flex: 1;
}
</style>