|
@@ -12,10 +12,13 @@ export default defineComponent({
|
|
|
setup() {
|
|
|
const catchStore = useCatchStore();
|
|
|
const router = useRouter();
|
|
|
+
|
|
|
+ const xiaokuAiSearch = localStorage.getItem('xiaoku-ai-search');
|
|
|
+ const xiaokuAi = xiaokuAiSearch ? JSON.parse(xiaokuAiSearch) : {};
|
|
|
const forms = reactive({
|
|
|
- musicTagIds: [] as any[],
|
|
|
+ musicTagIds: xiaokuAi.musicTagIds ? xiaokuAi.musicTagIds : ([] as any[]),
|
|
|
enable: true,
|
|
|
- subjectId: null,
|
|
|
+ subjectId: xiaokuAi.subjectId || null,
|
|
|
keyword: '',
|
|
|
page: 1,
|
|
|
rows: 9999
|
|
@@ -23,7 +26,7 @@ export default defineComponent({
|
|
|
const data = reactive({
|
|
|
tags: [] as any[],
|
|
|
tagChildren: [] as any[],
|
|
|
- tagActiveId: '',
|
|
|
+ tagActiveId: xiaokuAi.tagActiveId || '',
|
|
|
tagActive: {} as any,
|
|
|
list: [] as any,
|
|
|
loading: false
|
|
@@ -31,11 +34,21 @@ export default defineComponent({
|
|
|
const getTags = async () => {
|
|
|
const res = await api_musicTagTree();
|
|
|
if (Array.isArray(res?.data) && res.data.length) {
|
|
|
- data.tags = res.data;
|
|
|
- data.tagActiveId = res.data[0].id;
|
|
|
- const list: any[] = [];
|
|
|
- renderTag(res.data[0].children, list);
|
|
|
- data.tagChildren = list;
|
|
|
+ data.tags = res.data || [];
|
|
|
+ const index = data.tags.findIndex(
|
|
|
+ (item: any) => item.id == data.tagActiveId
|
|
|
+ );
|
|
|
+ if (index > -1) {
|
|
|
+ data.tagActiveId = res.data[index].id;
|
|
|
+ const list: any[] = [];
|
|
|
+ renderTag(res.data[index].children, list);
|
|
|
+ data.tagChildren = list;
|
|
|
+ } else {
|
|
|
+ data.tagActiveId = res.data[0].id;
|
|
|
+ const list: any[] = [];
|
|
|
+ renderTag(res.data[0].children, list);
|
|
|
+ data.tagChildren = list;
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -85,6 +98,15 @@ export default defineComponent({
|
|
|
await getList();
|
|
|
// 获取教材分类列表
|
|
|
await catchStore.getSubjects();
|
|
|
+
|
|
|
+ localStorage.setItem(
|
|
|
+ 'xiaoku-ai-search',
|
|
|
+ JSON.stringify({
|
|
|
+ tagActiveId: data.tagActiveId,
|
|
|
+ subjectId: forms.subjectId,
|
|
|
+ musicTagIds: forms.musicTagIds
|
|
|
+ })
|
|
|
+ );
|
|
|
} catch {
|
|
|
//
|
|
|
}
|
|
@@ -95,6 +117,16 @@ export default defineComponent({
|
|
|
const changeTag = (item: any, index: number) => {
|
|
|
data.tagActiveId = item.id;
|
|
|
forms.musicTagIds = [];
|
|
|
+
|
|
|
+ localStorage.setItem(
|
|
|
+ 'xiaoku-ai-search',
|
|
|
+ JSON.stringify({
|
|
|
+ tagActiveId: item.id,
|
|
|
+ subjectId: forms.subjectId,
|
|
|
+ musicTagIds: forms.musicTagIds
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
const list: any[] = [];
|
|
|
renderTag(data.tags[index].children, list);
|
|
|
data.tagChildren = list;
|
|
@@ -122,6 +154,15 @@ export default defineComponent({
|
|
|
forms.musicTagIds.push(activeItem.id);
|
|
|
data.tagChildren[columnIndex].activeIndex = index;
|
|
|
}
|
|
|
+
|
|
|
+ localStorage.setItem(
|
|
|
+ 'xiaoku-ai-search',
|
|
|
+ JSON.stringify({
|
|
|
+ tagActiveId: data.tagActiveId,
|
|
|
+ subjectId: forms.subjectId,
|
|
|
+ musicTagIds: forms.musicTagIds
|
|
|
+ })
|
|
|
+ );
|
|
|
getList();
|
|
|
};
|
|
|
return () => (
|
|
@@ -196,6 +237,15 @@ export default defineComponent({
|
|
|
}
|
|
|
onClick={() => {
|
|
|
forms.subjectId = item.id;
|
|
|
+
|
|
|
+ localStorage.setItem(
|
|
|
+ 'xiaoku-ai-search',
|
|
|
+ JSON.stringify({
|
|
|
+ tagActiveId: data.tagActiveId,
|
|
|
+ subjectId: item.id,
|
|
|
+ musicTagIds: forms.musicTagIds
|
|
|
+ })
|
|
|
+ );
|
|
|
getList();
|
|
|
}}>
|
|
|
{item.name}
|