index.vue
1.89 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
<template>
<n-space>
<n-icon size="20" :depth="3">
<fish-icon></fish-icon>
</n-icon>
<!-- THINGS_KIT -->
<n-text @click="handleFocus">
工作空间 -
<n-button secondary round size="tiny">
<span class="title">
{{ comTitle }}
</span>
</n-button>
</n-text>
<!-- <n-input
v-show="focus"
ref="inputInstRef"
size="small"
type="text"
maxlength="16"
show-count
round
placeholder="请输入项目名称"
v-model:value.trim="title"
@keyup.enter="handleBlur"
@blur="handleBlur"
></n-input> -->
</n-space>
</template>
<script setup lang="ts">
import { ref, nextTick, computed,watchEffect } from 'vue'
import { fetchRouteParamsLocation, setTitle } from '@/utils'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { icon } from '@/plugins'
const { FishIcon } = icon.ionicons5
const chartEditStore = useChartEditStore()
const focus = ref<boolean>(false)
const inputInstRef = ref(null)
// THINGS_KIT
const title = ref<string>(fetchRouteParamsLocation())
watchEffect(() => {
title.value = chartEditStore.getProjectInfo.projectName || ''
})
const comTitle = computed(() => {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
title.value = title.value.replace(/\s/g, '')
const newTitle = title.value.length ? title.value : '新项目'
setTitle(`工作空间-${newTitle}`)
chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.PROJECT_NAME, newTitle)
return newTitle
})
const handleFocus = () => {
focus.value = true
nextTick(() => {
inputInstRef.value && (inputInstRef.value as any).focus()
})
}
const handleBlur = () => {
focus.value = false
}
</script>
<style lang="scss" scoped>
.title {
font-size: 15px;
}
</style>