Skip to content

Commit 5f2ba0a

Browse files
committed
refactor: dashboard view select
1 parent dea866c commit 5f2ba0a

File tree

4 files changed

+270
-13
lines changed

4 files changed

+270
-13
lines changed

frontend/src/views/dashboard/components/sq-text/index.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,12 @@ const props = defineProps({
5050
type: Boolean,
5151
default: false,
5252
},
53-
showPosition: {
54-
type: String,
55-
required: false,
56-
default: 'preview',
57-
},
5853
})
5954
60-
const { configItem, showPosition } = toRefs(props)
61-
const tinymceId = 'tinymce-view-' + configItem.value.id + '-' + showPosition.value
55+
const { configItem } = toRefs(props)
56+
const tinymceId = 'vue-tinymce-' + +new Date() + ((Math.random() * 1000).toFixed(0) + '')
6257
const init = reactive({
6358
selector: tinymceId,
64-
toolbar_items_size: 'small',
6559
language_url: '/tinymce-sqlbot-private/langs/zh_CN.js',
6660
language: 'zh_CN',
6761
skin_url: '/tinymce-sqlbot-private/skins/ui/oxide',
@@ -92,6 +86,12 @@ const isDisabled = computed(() => props.disabled || !configItem.value.editing)
9286
9387
const setEdit = () => {
9488
configItem.value.editing = true
89+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
90+
const ed = tinymce.editors[tinymceId]
91+
ed.setContent(configItem.value.propValue)
92+
nextTick(() => {
93+
editCursor()
94+
})
9595
}
9696
9797
const editCursor = () => {
Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
1-
<script setup lang="ts"></script>
1+
<script setup lang="ts">
2+
import ChartComponent from '@/views/chat/component/ChartComponent.vue'
3+
import { reactive } from 'vue'
4+
import type { ChartAxis, ChartData } from '@/views/chat/component/BaseChart.ts'
5+
6+
const state = reactive({
7+
chartInfo: {
8+
id: null as string | null,
9+
type: '' as string,
10+
columns: [] as ChartAxis[],
11+
xAxis: [] as ChartAxis[],
12+
yAxis: [] as ChartAxis[],
13+
series: [] as ChartAxis[],
14+
data: [] as ChartData[],
15+
},
16+
})
17+
</script>
218

319
<template>
4-
<div></div>
20+
<div class="chart-base-container">
21+
<div>
22+
<ChartComponent
23+
v-if="state.chartInfo.id"
24+
:id="state.chartInfo.id"
25+
ref="chartRef"
26+
:type="state.chartInfo.type"
27+
:columns="state.chartInfo.columns"
28+
:x="state.chartInfo.xAxis"
29+
:y="state.chartInfo.yAxis"
30+
:series="state.chartInfo.series"
31+
:data="state.chartInfo.data"
32+
/>
33+
</div>
34+
</div>
535
</template>
636

7-
<style scoped lang="less"></style>
37+
<style scoped lang="less">
38+
.chart-base-container {
39+
padding: 20px;
40+
background: rgba(224, 224, 226, 0.29);
41+
}
42+
</style>

frontend/src/views/dashboard/editor/ChatChartSelection.vue

Lines changed: 129 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,25 @@
88
modal-class="custom-drawer"
99
@closed="handleClose()"
1010
>
11-
<div>Preview</div>
11+
<el-container class="chat-container">
12+
<el-aside class="chat-container-left">
13+
<el-container class="chat-container-right-container">
14+
<el-main class="chat-list">
15+
<DashboardChatList
16+
v-model:loading="loading"
17+
:current-chat-id="currentChatId"
18+
:chat-list="chatList"
19+
@chat-selected="onClickHistory"
20+
/>
21+
</el-main>
22+
</el-container>
23+
</el-aside>
24+
<el-container :loading="loading">
25+
<el-main class="chat-record-list">
26+
<el-scrollbar ref="chatListRef"> </el-scrollbar>
27+
</el-main>
28+
</el-container>
29+
</el-container>
1230

1331
<template #footer>
1432
<el-row class="multiplexing-footer">
@@ -31,14 +49,58 @@
3149
</template>
3250

3351
<script setup lang="ts">
34-
import { computed, reactive, ref } from 'vue'
52+
import { computed, onMounted, reactive, ref } from 'vue'
3553
import { useI18n } from 'vue-i18n'
54+
import { Chat, chatApi, ChatInfo } from '@/api/chat.ts'
55+
import DashboardChatList from '@/views/dashboard/editor/DashboardChatList.vue'
3656
const dialogShow = ref(false)
3757
const { t } = useI18n()
3858
const selectComponentCount = computed(() => Object.keys(state.curMultiplexingComponents).length)
3959
const state = reactive({
4060
curMultiplexingComponents: {},
4161
})
62+
63+
const loading = ref<boolean>(false)
64+
const chatList = ref<Array<ChatInfo>>([])
65+
66+
const currentChatId = ref<number | undefined>()
67+
const currentChat = ref<ChatInfo>(new ChatInfo())
68+
69+
onMounted(() => {
70+
getChatList()
71+
})
72+
73+
function onClickHistory(chat: Chat) {
74+
currentChat.value = new ChatInfo(chat)
75+
if (chat !== undefined && chat.id !== undefined && !loading.value) {
76+
currentChatId.value = chat.id
77+
loading.value = true
78+
chatApi
79+
.get(chat.id)
80+
.then((res) => {
81+
const info = chatApi.toChatInfo(res)
82+
if (info) {
83+
currentChat.value = info
84+
}
85+
})
86+
.finally(() => {
87+
loading.value = false
88+
})
89+
}
90+
}
91+
92+
function getChatList() {
93+
loading.value = true
94+
chatApi
95+
.list()
96+
.then((res) => {
97+
chatList.value = chatApi.toChatInfoList(res)
98+
})
99+
.finally(() => {
100+
loading.value = false
101+
})
102+
}
103+
42104
const dialogInit = () => {
43105
dialogShow.value = true
44106
state.curMultiplexingComponents = {}
@@ -107,4 +169,69 @@ defineExpose({
107169
padding: 0 0 64px 0 !important;
108170
}
109171
}
172+
173+
.chat-container {
174+
height: 100%;
175+
176+
.chat-container-left {
177+
padding-top: 20px;
178+
--ed-aside-width: 260px;
179+
180+
box-shadow: 0 0 3px #d7d7d7;
181+
z-index: 1;
182+
183+
background: var(--ed-fill-color-blank);
184+
185+
.chat-container-right-container {
186+
height: 100%;
187+
188+
.chat-list-header {
189+
display: flex;
190+
align-items: center;
191+
justify-content: center;
192+
}
193+
194+
.chat-list {
195+
padding: 0 0 20px 0;
196+
}
197+
}
198+
}
199+
200+
.chat-record-list {
201+
padding: 0 0 20px 0;
202+
}
203+
204+
.chat-footer {
205+
--ed-footer-height: 120px;
206+
207+
display: flex;
208+
flex-direction: column;
209+
210+
.input-wrapper {
211+
flex: 1;
212+
213+
position: relative;
214+
215+
.input-area {
216+
height: 100%;
217+
padding-bottom: 8px;
218+
219+
:deep(.ed-textarea__inner) {
220+
height: 100% !important;
221+
}
222+
}
223+
224+
.input-icon {
225+
min-width: unset;
226+
position: absolute;
227+
bottom: 14px;
228+
right: 8px;
229+
}
230+
}
231+
}
232+
233+
.send-btn {
234+
min-width: 0;
235+
}
236+
}
110237
</style>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<script setup lang="ts">
2+
import { type Chat } from '@/api/chat.ts'
3+
4+
withDefaults(
5+
defineProps<{
6+
currentChatId?: number
7+
chatList: Array<Chat>
8+
}>(),
9+
{
10+
currentChatId: undefined,
11+
chatList: () => [],
12+
}
13+
)
14+
15+
const emits = defineEmits(['chatSelected'])
16+
17+
function onClickHistory(chat: Chat) {
18+
emits('chatSelected', chat)
19+
}
20+
</script>
21+
22+
<template>
23+
<el-scrollbar ref="chatListRef">
24+
<div class="chat-list-inner">
25+
<template v-for="chat in chatList" :key="chat.id">
26+
<div
27+
class="chat-list-item"
28+
:class="{ active: currentChatId === chat.id }"
29+
@click="onClickHistory(chat)"
30+
>
31+
<span class="title">{{ chat.brief ?? 'Untitled' }}</span>
32+
</div>
33+
</template>
34+
</div>
35+
</el-scrollbar>
36+
</template>
37+
38+
<style scoped lang="less">
39+
.chat-list-inner {
40+
--hover-color: var(--ed-color-primary-light-9);
41+
--active-color: var(--hover-color);
42+
43+
padding-left: 14px;
44+
padding-right: 14px;
45+
width: 100%;
46+
47+
display: flex;
48+
flex-direction: column;
49+
50+
gap: 8px;
51+
52+
.chat-list-item {
53+
width: 100%;
54+
height: 42px;
55+
cursor: pointer;
56+
border-radius: 6px;
57+
line-height: 1em;
58+
59+
display: flex;
60+
align-items: center;
61+
padding: 8px;
62+
63+
overflow: hidden;
64+
text-overflow: ellipsis;
65+
white-space: nowrap;
66+
67+
.title {
68+
flex: 1;
69+
width: 0;
70+
overflow: hidden;
71+
text-overflow: ellipsis;
72+
white-space: nowrap;
73+
}
74+
75+
.icon-more {
76+
margin-left: auto;
77+
display: none;
78+
79+
min-width: unset;
80+
}
81+
82+
&:hover {
83+
background-color: var(--hover-color);
84+
85+
.icon-more {
86+
display: inline-flex;
87+
}
88+
}
89+
90+
&.active {
91+
background-color: var(--active-color);
92+
}
93+
}
94+
}
95+
</style>

0 commit comments

Comments
 (0)