提交 3c3fa0c5 编写于 作者: View Design's avatar View Design

收藏夹放到菠萝

上级 bfdab39c
<template> <template>
<UModal v-model="isOpenCreate" :ui="{ width: 'w-96 sm:max-w-screen-md' }"> <UModal v-model="$isLibraryCreateOpen" :ui="{ width: 'w-96 sm:max-w-screen-md' }">
<UCard :ui="{ ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }"> <UCard :ui="{ ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }">
<template #header> <template #header>
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
...@@ -49,14 +49,14 @@ ...@@ -49,14 +49,14 @@
</UModal> </UModal>
</template> </template>
<script setup> <script setup>
const isOpenCreate = ref(false) const { $isLibraryCreateOpen } = storeToRefs(useLibraryStore())
const { $openLibraryCreate, $closeLibraryCreate } = useLibraryStore()
const title = ref('') const title = ref('')
const description = ref('') const description = ref('')
function handleClose () { function handleClose () {
isOpenCreate.value = false $closeLibraryCreate()
} }
function handleOpen () { function handleOpen () {
isOpenCreate.value = true $openLibraryCreate
} }
defineExpose({ handleOpen })
</script> </script>
<template> <template>
<UModal v-model="isOpenSelect" :ui="{ width: 'w-96 sm:max-w-screen-md' }"> <UModal v-model="$isLibrarySelectOpen" :ui="{ width: 'w-96 sm:max-w-screen-md' }">
<UCard :ui="{ ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }"> <UCard :ui="{ ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }">
<template #header> <template #header>
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
...@@ -37,17 +37,16 @@ ...@@ -37,17 +37,16 @@
</UModal> </UModal>
</template> </template>
<script setup> <script setup>
const Library = inject('Library') const { $isLibrarySelectOpen } = storeToRefs(useLibraryStore())
const isOpenSelect = ref(false) const { $openLibrarySelect, $closeLibrarySelect, $openLibraryCreate } = useLibraryStore()
function handleClose () { function handleClose () {
isOpenSelect.value = false $closeLibrarySelect()
} }
function handleOpen (id) { function handleOpen (id) {
isOpenSelect.value = true $openLibrarySelect()
} }
defineExpose({ handleOpen })
function handleOpenCreate () { function handleOpenCreate () {
handleClose() handleClose()
Library.handleOpenCreateLibrary() $openLibraryCreate()
} }
</script> </script>
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<UDivider /> <UDivider />
</template> </template>
<script setup> <script setup>
const Library = inject('Library') const { $openLibrarySelect } = useLibraryStore()
const textColor = 'text-gray-500 dark:text-gray-400' const textColor = 'text-gray-500 dark:text-gray-400'
const actionItems = [ const actionItems = [
[ [
...@@ -85,6 +85,6 @@ const actionItems = [ ...@@ -85,6 +85,6 @@ const actionItems = [
] ]
] ]
function handleOpenSelect (id) { function handleOpenSelect (id) {
Library.handleOpenSelect(id) $openLibrarySelect(id)
} }
</script> </script>
\ No newline at end of file
...@@ -13,7 +13,13 @@ ...@@ -13,7 +13,13 @@
@blur="handleBlurTitle" @blur="handleBlurTitle"
/> />
<span>/</span> <span>/</span>
<UButton color="gray" variant="ghost" leading-icon="i-heroicons-plus-20-solid">收藏</UButton> <UButton
color="gray"
variant="ghost"
leading-icon="i-heroicons-plus-20-solid"
label="收藏"
@click="handleOpenSelect"
/>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<ClientOnly> <ClientOnly>
...@@ -68,6 +74,7 @@ ...@@ -68,6 +74,7 @@
</div> </div>
<UDivider /> <UDivider />
</header> </header>
</template> </template>
<script setup> <script setup>
const toast = useToast() const toast = useToast()
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
<IAside /> <IAside />
</USlideover> </USlideover>
</div> </div>
<ILibraryCreate />
<ILibrarySelect />
</template> </template>
<script setup> <script setup>
const isOpenAside = ref(false) const isOpenAside = ref(false)
......
...@@ -52,21 +52,12 @@ ...@@ -52,21 +52,12 @@
</div> </div>
</div> </div>
</div> </div>
<ILibraryCreate ref="refCreate" />
<ILibrarySelect ref="refSelect" />
</template> </template>
<script setup> <script setup>
const { $openLibraryCreate } = useLibraryStore()
const searchQuery = ref('') const searchQuery = ref('')
const refCreate = ref(null)
function handleOpenCreateLibrary () { function handleOpenCreateLibrary () {
refCreate.value.handleOpen() $openLibraryCreate()
} }
const refSelect = ref(null)
function handleOpenSelect (id) {
refSelect.value.handleOpen(id)
}
provide('Library', {
handleOpenSelect,
handleOpenCreateLibrary
})
</script> </script>
import { defineStore } from 'pinia'
export const useLibraryStore = defineStore('library', () => {
const $isLibraryCreateOpen = ref(false)
const $isLibrarySelectOpen = ref(false)
const $selectThreadId = ref('')
function $openLibraryCreate () {
$isLibraryCreateOpen.value = true
}
function $closeLibraryCreate () {
$isLibraryCreateOpen.value = false
}
function $openLibrarySelect (id) {
$isLibrarySelectOpen.value = true
if (id) $selectThreadId.value = id
}
function $closeLibrarySelect () {
$isLibrarySelectOpen.value = false
}
return {
$isLibraryCreateOpen,
$isLibrarySelectOpen,
$openLibraryCreate,
$closeLibraryCreate,
$openLibrarySelect,
$closeLibrarySelect
}
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册