Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
inscode
NodeJS_639770
提交
8458b434
N
NodeJS_639770
项目概览
inscode
/
NodeJS_639770
与 Fork 源项目一致
Fork自
inscode / NodeJS
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NodeJS_639770
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8458b434
编写于
5月 30, 2024
作者:
D
DebugIsFalse
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 收藏问题
上级
e3812b86
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
23 deletion
+57
-23
components/i/library/select.vue
components/i/library/select.vue
+29
-17
components/i/search/Header.vue
components/i/search/Header.vue
+17
-2
composables/useCollectionRequest.js
composables/useCollectionRequest.js
+1
-1
stores/library.js
stores/library.js
+10
-3
未找到文件。
components/i/library/select.vue
浏览文件 @
8458b434
...
...
@@ -13,7 +13,6 @@
</div>
</
template
>
<div
class=
"flex flex-col gap-4"
>
{{ collection }}
<UButton
leading-icon=
"i-heroicons-plus-20-solid"
label=
"创建新集合"
...
...
@@ -21,36 +20,39 @@
@
click=
"handleOpenCreate"
/>
<div
class=
"flex flex-col gap-2"
>
<UButton
color=
"white"
size=
"md"
class=
"flex"
>
<UButton
v-for=
"item in collection"
color=
"white"
size=
"md"
class=
"flex"
:key=
"item.id"
@
click=
"handleSelected(item.id)"
>
<div
class=
"flex flex-grow justify-between items-center"
>
<div>
前端开发
</div>
<UIcon
name=
"i-heroicons-check-circle-20-solid"
class=
"text-primary text-lg"
/>
</div>
</UButton>
<UButton
color=
"white"
size=
"md"
class=
"flex"
>
<div
class=
"flex flex-grow justify-between items-center"
>
<div>
后端开发
</div>
<div>
{{item.name}}
</div>
<UIcon
v-if=
"selectedCollection.includes(item.id)"
name=
"i-heroicons-check-circle-20-solid"
class=
"text-primary text-lg"
/>
</div>
</UButton>
</div>
</div>
<
template
#footer
>
<
!-- <
template #footer>
<div class="flex justify-end">
<UButton
size="md"
label="保存"
/>
</div>
</
template
>
</template>
-->
</UCard>
</UModal>
</template>
<
script
setup
>
const
{
$isLibrarySelectOpen
}
=
storeToRefs
(
useLibraryStore
())
const
{
$openLibrarySelect
,
$closeLibrarySelect
,
$openLibraryCreate
}
=
useLibraryStore
()
const
{
getCollection
}
=
useCollectionRequest
()
//
收藏夹数据
const
{
$isLibrarySelectOpen
,
$selectCollectionId
,
$selectThreadId
}
=
storeToRefs
(
useLibraryStore
())
const
{
$openLibrarySelect
,
$closeLibrarySelect
,
$openLibraryCreate
,
$setSelectCollectionId
}
=
useLibraryStore
()
const
{
getCollection
,
saveCollection
}
=
useCollectionRequest
()
//
合集列表
const
collection
=
ref
([])
const
selectedCollection
=
ref
([])
function
handleClose
()
{
$closeLibrarySelect
()
}
...
...
@@ -62,10 +64,20 @@ function handleOpenCreate () {
$openLibraryCreate
()
}
async
function
getCollectionData
()
{
collection
.
value
=
await
getCollection
()
collection
.
value
=
await
getCollection
()
}
async
function
handleSelected
(
id
)
{
selectedCollection
.
value
=
[
id
]
$setSelectCollectionId
(
selectedCollection
.
value
)
const
{
error
}
=
await
saveCollection
({
collection_id
:
id
,
c_id
:
$selectThreadId
.
value
})
if
(
error
.
value
)
{
selectedCollection
.
value
=
[]
return
}
handleClose
()
}
watch
(()
=>
$isLibrarySelectOpen
.
value
,
()
=>
{
selectedCollection
.
value
=
$selectCollectionId
.
value
getCollectionData
()
})
</
script
>
components/i/search/Header.vue
浏览文件 @
8458b434
...
...
@@ -17,7 +17,7 @@
color=
"gray"
variant=
"ghost"
leading-icon=
"i-heroicons-plus-20-solid"
label=
"收藏
"
:label=
"$selectCollectionId.length > 0 ? '已收藏' : '收藏'
"
@
click=
"handleOpenSelect"
/>
</div>
...
...
@@ -79,7 +79,10 @@
<
script
setup
>
const
toast
=
useToast
()
const
route
=
useRoute
()
const
{
$openLibraryCreate
,
$openLibrarySelect
}
=
useLibraryStore
()
const
{
$isSignIn
}
=
storeToRefs
(
useUserStore
())
const
{
$selectCollectionId
}
=
storeToRefs
(
useLibraryStore
())
const
{
$openLibraryCreate
,
$openLibrarySelect
,
$setSelectCollectionId
}
=
useLibraryStore
()
const
{
findRecordCollection
}
=
useCollectionRequest
()
const
props
=
defineProps
({
query
:
String
,
isPublic
:
{
...
...
@@ -134,6 +137,18 @@ async function handleSetOpenState() {
function
handleOpenSelect
()
{
$openLibrarySelect
(
route
.
params
.
id
)
}
async
function
initData
()
{
const
{
data
,
error
}
=
await
findRecordCollection
(
route
.
params
.
id
)
if
(
!
error
.
value
)
{
const
ids
=
data
.
value
.
data
.
map
(
item
=>
item
.
collection_id
)
console
.
log
(
`ids:`
,
ids
)
$setSelectCollectionId
(
ids
)
}
}
// 初始化登录的时候判断是否已收藏
if
(
$isSignIn
.
value
)
{
await
initData
()
}
defineExpose
({
isOpen
,
handleUpdateOpenState
,
...
...
composables/useCollectionRequest.js
浏览文件 @
8458b434
...
...
@@ -19,7 +19,7 @@ export default () => {
const
{
data
,
error
}
=
await
useRequest
(
'
/v1/collection/list
'
,
{
method
:
'
get
'
})
if
(
!
error
.
value
)
{
if
(
error
.
value
)
{
return
[]
}
return
data
.
value
.
data
||
[]
...
...
stores/library.js
浏览文件 @
8458b434
...
...
@@ -4,6 +4,7 @@ export const useLibraryStore = defineStore('library', () => {
const
$isLibraryCreateOpen
=
ref
(
false
)
const
$isLibrarySelectOpen
=
ref
(
false
)
const
$selectThreadId
=
ref
(
''
)
const
$selectCollectionId
=
ref
([])
function
$openLibraryCreate
()
{
$isLibraryCreateOpen
.
value
=
true
...
...
@@ -11,20 +12,26 @@ export const useLibraryStore = defineStore('library', () => {
function
$closeLibraryCreate
()
{
$isLibraryCreateOpen
.
value
=
false
}
function
$openLibrarySelect
(
id
)
{
function
$openLibrarySelect
(
id
,
collectionId
)
{
$isLibrarySelectOpen
.
value
=
true
if
(
id
)
$selectThreadId
.
value
=
id
if
(
collectionId
)
$selectCollectionId
.
value
=
collectionId
}
function
$closeLibrarySelect
()
{
$isLibrarySelectOpen
.
value
=
false
}
function
$setSelectCollectionId
(
ids
)
{
$selectCollectionId
.
value
=
ids
}
return
{
$selectThreadId
,
$isLibraryCreateOpen
,
$isLibrarySelectOpen
,
$openLibraryCreate
,
$closeLibraryCreate
,
$openLibrarySelect
,
$closeLibrarySelect
$closeLibrarySelect
,
$selectCollectionId
,
$setSelectCollectionId
}
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录