|
@@ -23,7 +23,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="query">
|
|
|
- <Input :placeholder="'请输入搜索关键词'" v-model:value="queryData.name">
|
|
|
+ <Input :placeholder="'请输入搜索关键词'" v-model:value="queryData.name" @enter="handleQuery">
|
|
|
<template #prefix>
|
|
|
<img class="img" src="./imgs/query.png" alt="" />
|
|
|
</template>
|
|
@@ -34,7 +34,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="musicListCon">
|
|
|
- <div class="queryFrom">
|
|
|
+ <div class="queryFrom" :class="{ isExpandAct: !isExpand }">
|
|
|
<div v-show="queryData.sourceType === 2" class="queryFromList">
|
|
|
<div class="tit">教程:</div>
|
|
|
<div class="queryFromCon">
|
|
@@ -97,6 +97,10 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div v-show="queryData.sourceType === 2" @click="isExpand = !isExpand" class="isExpand" :class="{ active: isExpand }">
|
|
|
+ <div>{{ isExpand ? "收起" : "展开" }}</div>
|
|
|
+ <img src="./imgs/jiao.png" alt="" />
|
|
|
+ </div>
|
|
|
<div class="musicListConBox" v-loading="loading">
|
|
|
<div class="musicList" :class="{ empty: !musicList.length && !loading }">
|
|
|
<div class="musicListBox" v-if="musicList.length && !loading">
|
|
@@ -122,8 +126,14 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="musicRight">
|
|
|
- <img class="sc" @click="handleFavorite(item)" :src="item.favoriteFlag ? scActImg : scImg" alt="" />
|
|
|
- <div class="addBtn" @click="handleAddMusic(item.id)">添加</div>
|
|
|
+ <img
|
|
|
+ v-if="queryParams.fromType !== 'PLATFORM'"
|
|
|
+ class="sc"
|
|
|
+ @click="handleFavorite(item)"
|
|
|
+ :src="item.favoriteFlag ? scActImg : scImg"
|
|
|
+ alt=""
|
|
|
+ />
|
|
|
+ <div class="addBtn" @click="handleAddMusic(item.id, item.name)">添加</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -151,35 +161,44 @@ import { httpAjax } from "@/plugins/httpAjax"
|
|
|
import queryParams from "@/queryParams"
|
|
|
import scActImg from "./imgs/scAct.png"
|
|
|
import scImg from "./imgs/sc.png"
|
|
|
+import { CODE_ERR_CANCELED } from "@/libs/auth"
|
|
|
|
|
|
const emits = defineEmits<{
|
|
|
- (event: "update", id: string): void
|
|
|
+ (event: "update", id: string, name: string): void
|
|
|
(event: "close"): void
|
|
|
}>()
|
|
|
|
|
|
-function handleAddMusic(id: string) {
|
|
|
- emits("update", id)
|
|
|
+function handleAddMusic(id: string, name: string) {
|
|
|
+ emits("update", id, name)
|
|
|
emits("close")
|
|
|
}
|
|
|
|
|
|
-const tabData = [
|
|
|
- {
|
|
|
- label: "相关资源",
|
|
|
- value: 5
|
|
|
- },
|
|
|
- {
|
|
|
- label: "共享资源",
|
|
|
- value: 2
|
|
|
- },
|
|
|
- {
|
|
|
- label: "我的资源",
|
|
|
- value: 3
|
|
|
- },
|
|
|
- {
|
|
|
- label: "我的收藏",
|
|
|
- value: 4
|
|
|
- }
|
|
|
-]
|
|
|
+const tabData =
|
|
|
+ queryParams.fromType === "PLATFORM"
|
|
|
+ ? [
|
|
|
+ {
|
|
|
+ label: "共享资源",
|
|
|
+ value: 2
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ : [
|
|
|
+ {
|
|
|
+ label: "相关资源",
|
|
|
+ value: 5
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "共享资源",
|
|
|
+ value: 2
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "我的资源",
|
|
|
+ value: 3
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "我的收藏",
|
|
|
+ value: 4
|
|
|
+ }
|
|
|
+ ]
|
|
|
// 场景
|
|
|
const audioPlayTypesOption = [
|
|
|
{ text: "全部", value: "" },
|
|
@@ -196,7 +215,7 @@ const queryData = reactive({
|
|
|
page: 1,
|
|
|
rows: 21,
|
|
|
total: 0,
|
|
|
- sourceType: 5,
|
|
|
+ sourceType: tabData[0].value,
|
|
|
name: "",
|
|
|
bookVersionId: "",
|
|
|
audioPlayTypes: "",
|
|
@@ -209,6 +228,7 @@ const queryData = reactive({
|
|
|
const musicList = ref<any[]>([])
|
|
|
const loading = ref(true)
|
|
|
const vLoading = ElLoading.directive
|
|
|
+const isExpand = ref(true)
|
|
|
|
|
|
getQueryList()
|
|
|
function getQueryList() {
|
|
@@ -270,6 +290,7 @@ function clearQueryData() {
|
|
|
}
|
|
|
function handleTabChange(sourceType: number) {
|
|
|
clearQueryData()
|
|
|
+ isExpand.value = true
|
|
|
queryData.sourceType = sourceType
|
|
|
handleQuery()
|
|
|
}
|
|
@@ -301,6 +322,8 @@ function handleQuery() {
|
|
|
queryData.rows = 21
|
|
|
handleGetQuery()
|
|
|
}
|
|
|
+
|
|
|
+let controller: AbortController
|
|
|
function handleGetQuery() {
|
|
|
loading.value = true
|
|
|
let { sourceType, subject, audioPlayTypes, name, page, rows, bookVersionId } = queryData
|
|
@@ -367,7 +390,15 @@ function handleGetQuery() {
|
|
|
audioPlayTypes: audioPlayTypesParams
|
|
|
}
|
|
|
}
|
|
|
- httpAjax(getMaterialQueryPage, params).then(res => {
|
|
|
+ if (controller) {
|
|
|
+ controller.abort()
|
|
|
+ }
|
|
|
+ controller = new AbortController()
|
|
|
+ httpAjax(getMaterialQueryPage, params, controller).then(res => {
|
|
|
+ // 自己关闭的时候不取消加载
|
|
|
+ if (res.code === CODE_ERR_CANCELED) {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (res.code === 200) {
|
|
|
musicList.value = res.data.rows.map((item: any) => {
|
|
|
item.name = highlightedText(item.name, queryData.name)
|
|
@@ -537,6 +568,11 @@ const highlightedText = (text: string, query: string) => {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
.queryFrom {
|
|
|
+ &.isExpandAct {
|
|
|
+ height: 42px;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+ flex-shrink: 0;
|
|
|
padding: 0 30px;
|
|
|
.queryFromList {
|
|
|
display: flex;
|
|
@@ -585,6 +621,30 @@ const highlightedText = (text: string, query: string) => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ .isExpand {
|
|
|
+ flex-shrink: 0;
|
|
|
+ margin-bottom: 12px;
|
|
|
+ cursor: pointer;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ font-weight: 400;
|
|
|
+ font-size: 14px;
|
|
|
+ color: #198cfe;
|
|
|
+ line-height: 20px;
|
|
|
+ align-items: center;
|
|
|
+ &:hover {
|
|
|
+ opacity: 0.8;
|
|
|
+ }
|
|
|
+ &.active > img {
|
|
|
+ transform: rotate(0deg);
|
|
|
+ }
|
|
|
+ & > img {
|
|
|
+ transform: rotate(180deg);
|
|
|
+ margin-left: 4px;
|
|
|
+ width: 10px;
|
|
|
+ height: 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
.musicListConBox {
|
|
|
flex-grow: 1;
|
|
|
overflow: hidden;
|
|
@@ -613,6 +673,7 @@ const highlightedText = (text: string, query: string) => {
|
|
|
display: flex;
|
|
|
justify-content: space-between;
|
|
|
align-items: center;
|
|
|
+ height: 102px;
|
|
|
&:nth-last-child(-n + 3) {
|
|
|
margin-bottom: 0;
|
|
|
}
|