forked from opentiny/tiny-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.vue
More file actions
185 lines (169 loc) · 4.42 KB
/
Copy pathMain.vue
File metadata and controls
185 lines (169 loc) · 4.42 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<template>
<plugin-panel title="TinyEngine 教程">
<template #header>
<svg-button
class="item icon-sidebar"
name="fixed"
:class="[fixedPanels?.includes(PLUGIN_NAME.Tutorial) && 'active']"
:tips="!fixedPanels?.includes(PLUGIN_NAME.Tutorial) ? '固定面板' : '解除固定面板'"
@click="$emit('fixPanel', PLUGIN_NAME.Tutorial)"
></svg-button>
</template>
<template #content>
<div class="video-container">
<tiny-collapse v-model="state.expandingNames">
<tiny-collapse-item
v-for="item in state.list"
:key="item.id"
class="video-item"
:name="item.id"
:title="item.name"
>
<div class="video-item-content">
<div
v-for="tutorial in item.videos"
:key="tutorial"
:class="['video-item-content-tutorial', state.active === tutorial.id ? 'active' : '']"
@mousedown.stop="playVideo(tutorial)"
>
<svg-icon name="video"></svg-icon>
<span class="tutorial-name">{{ tutorial.title }}</span>
<IconChevronRight v-if="state.active === tutorial.id" class="icon-chevron"></IconChevronRight>
</div>
</div>
</tiny-collapse-item>
</tiny-collapse>
</div>
</template>
</plugin-panel>
<tutorial-video-panel v-model="state.video"></tutorial-video-panel>
</template>
<script>
import { onMounted, reactive, ref } from 'vue'
import { PluginPanel, SvgButton } from '@opentiny/tiny-engine-common'
import { IconChevronRight } from '@opentiny/vue-icon'
import { useLayout } from '@opentiny/tiny-engine-controller'
import { Collapse, CollapseItem } from '@opentiny/vue'
import TutorialVideoPanel, { open as openPanel } from './TutorialVideoPanel.vue'
import { fetchTutorialList } from './js/http'
const boxVisibility = ref(false)
const videoData = ref(null)
const open = (data) => {
videoData.value = data
boxVisibility.value = true
}
export const api = { open }
export default {
props: {
shortcut: [Boolean, String],
fixedPanels: {
type: Array
}
},
components: {
PluginPanel,
SvgButton,
TutorialVideoPanel,
TinyCollapse: Collapse,
TinyCollapseItem: CollapseItem,
IconChevronRight: IconChevronRight()
},
setup() {
const state = reactive({
active: '',
expandingNames: [],
show: false,
video: {},
list: []
})
const playVideo = (data) => {
state.video = data
state.active = data.id
openPanel()
}
onMounted(() => {
fetchTutorialList({ category: 'appDev' })
.then((data) => {
if (data) {
state.list = data
state.expandingNames = state.list.map(({ id }) => id) // 默认扩展所有
}
})
.catch(() => {})
})
const close = () => {
boxVisibility.value = false
}
const openVideoPanel = () => {
const { getPluginApi } = useLayout()
const { open } = getPluginApi('Tutorial')
open()
}
const { PLUGIN_NAME } = useLayout()
return {
state,
PLUGIN_NAME,
playVideo,
boxVisibility,
close,
videoData,
openVideoPanel
}
}
}
</script>
<style lang="less" scoped>
.video-container {
height: calc(100% - 76px);
overflow-y: scroll;
}
.video-item {
.video-item-content {
color: var(--ti-lowcode-tutorial-primary-text-color);
.video-item-content-tutorial {
padding: 0 8px;
display: grid;
grid-template-columns: 20px 1fr 20px;
column-gap: 4px;
background: var(--ti-lowcode-tutorial-primary-bg-color);
height: 32px;
line-height: 32px;
align-items: center;
svg {
font-size: 16px;
}
&.active,
&:hover {
background: var(--ti-lowcode-tutorial-hover-bg-color);
cursor: pointer;
svg.icon-chevron {
font-size: 16px;
}
}
}
}
.tutorial-name {
font-size: 12px;
display: inline-block;
width: 108%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
</style>
<style lang="less">
.tiny-dialog-box__wrapper.tutorial-box {
.tiny-dialog-box__header {
padding: 20px;
}
.tiny-dialog-box__body {
padding: 0 20px;
max-height: unset;
height: calc(100vh - 54px);
}
video {
width: 100%;
}
}
</style>