Skip to content

Commit 4a829c7

Browse files
YunaiVgitee-org
authored andcommitted
!486 AI 大模型的草稿提交(code review 代码)
Merge pull request !486 from 芋道源码/dev
2 parents 21c7c17 + 4d3c5b7 commit 4a829c7

File tree

24 files changed

+671
-436
lines changed

24 files changed

+671
-436
lines changed

src/api/ai/image/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const ImageApi = {
5757
return await request.get({ url: `/ai/image/my-page`, params })
5858
},
5959
// 获取公开的绘图记录
60-
getImagePagePublic: async (params: PageParam) => {
60+
getImagePagePublic: async (params) => {
6161
return await request.get({ url: `/ai/image/public-page`, params })
6262
},
6363
// 获取【我的】绘图记录

src/api/mall/product/history.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import request from '@/config/axios'
2+
3+
/**
4+
* 获得商品浏览记录分页
5+
*
6+
* @param params 请求参数
7+
*/
8+
export const getBrowseHistoryPage = (params: any) => {
9+
return request.get({ url: '/product/browse-history/page', params })
10+
}

src/assets/audio/response.mp3

1.66 MB
Binary file not shown.

src/views/ai/image/square/index.vue

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,85 @@
11
<template>
2-
<div class="card-list">
3-
<div v-for="item in publicList" :key="item.id" class="card">
4-
<img :src="item.picUrl" class="img" />
2+
<div class="square-container">
3+
<el-input
4+
v-model="searchText"
5+
style="width: 100%; margin-bottom: 20px"
6+
size="large"
7+
placeholder="请输入要搜索的内容"
8+
:suffix-icon="Search"
9+
@keyup.enter="handleSearch"
10+
/>
11+
<div class="gallery">
12+
<div v-for="item in publicList" :key="item.id" class="gallery-item">
13+
<img :src="item.picUrl" class="img" />
14+
</div>
515
</div>
616
</div>
717
</template>
818
<script setup lang="ts">
919
import { ImageApi, ImageVO } from '@/api/ai/image'
20+
import { Search } from '@element-plus/icons-vue'
1021
1122
/** 属性 */
1223
// TODO @fan:queryParams 里面搞分页哈。
1324
const pageNo = ref<number>(1)
1425
const pageSize = ref<number>(20)
1526
const publicList = ref<ImageVO[]>([])
27+
const searchText = ref<string>('')
1628
1729
/** 获取数据 */
1830
const getListData = async () => {
19-
const res = await ImageApi.getImagePagePublic({ pageNo: pageNo.value, pageSize: pageSize.value })
31+
const res = await ImageApi.getImagePagePublic({
32+
pageNo: pageNo.value,
33+
pageSize: pageSize.value,
34+
prompt: searchText.value
35+
})
2036
publicList.value = res.list as ImageVO[]
21-
console.log('publicList.value', publicList.value)
37+
}
38+
39+
/** 搜索 */
40+
const handleSearch = async () => {
41+
await getListData()
2242
}
2343
2444
onMounted(async () => {
2545
await getListData()
2646
})
2747
</script>
2848
<style scoped lang="scss">
29-
.card-list {
30-
//display: flex;
31-
//flex-direction: column;
32-
column-count: 4;
33-
column-gap: 3px;
34-
}
49+
.square-container {
50+
background-color: #fff;
51+
padding: 20px;
52+
53+
.gallery {
54+
display: grid;
55+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
56+
gap: 10px;
57+
//max-width: 1000px;
58+
background-color: #fff;
59+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
60+
}
61+
62+
.gallery-item {
63+
position: relative;
64+
overflow: hidden;
65+
background: #f0f0f0;
66+
cursor: pointer;
67+
transition: transform 0.3s;
68+
}
69+
70+
.gallery-item img {
71+
width: 100%;
72+
height: auto;
73+
display: block;
74+
transition: transform 0.3s;
75+
}
76+
77+
.gallery-item:hover img {
78+
transform: scale(1.1);
79+
}
3580
36-
.card {
37-
.img {
38-
width: 50%;
81+
.gallery-item:hover {
82+
transform: scale(1.05);
3983
}
4084
}
4185
</style>

src/views/ai/music/components/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="flex ">
2+
<div class="flex h-full items-stretch">
33
<!-- 模式 -->
44
<Mode class="flex-none" @generate-music="generateMusic"/>
55
<!-- 音频列表 -->
@@ -15,6 +15,11 @@ defineOptions({ name: 'Index' })
1515
1616
const listRef = ref<Nullable<{generateMusic: (...args) => void}>>(null)
1717
18+
/*
19+
*@Description: 拿到左侧配置信息调用右侧音乐生成的方法
20+
*@MethodAuthor: xiaohong
21+
*@Date: 2024-07-19 11:13:38
22+
*/
1823
function generateMusic (args: {formData: Recordable}) {
1924
unref(listRef)?.generateMusic(args.formData)
2025
}

src/views/ai/music/components/list/audioBar/index.vue

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<div class="flex gap-[10px]">
55
<el-image src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" class="w-[45px]"/>
66
<div>
7-
<div>我很好</div>
8-
<div class="text-[12px] text-gray-400">刘大壮</div>
7+
<div>{{currentSong.name}}</div>
8+
<div class="text-[12px] text-gray-400">{{currentSong.singer}}</div>
99
</div>
1010
</div>
1111

@@ -21,7 +21,7 @@
2121
</div>
2222
<!-- 音频 -->
2323
<audio v-bind="audioProps" ref="audioRef" controls v-show="!audioProps" @timeupdate="audioTimeUpdate">
24-
<source :src="response"/>
24+
<source :src="audioUrl"/>
2525
</audio>
2626
</div>
2727

@@ -35,34 +35,36 @@
3535

3636
<script lang="ts" setup>
3737
import { formatPast } from '@/utils/formatTime'
38-
import response from '@/assets/audio/response.mp3'
38+
import audioUrl from '@/assets/audio/response.mp3'
3939
4040
defineOptions({ name: 'Index' })
4141
42-
const audioRef = ref<Nullable<HTMLElement>>(null)
43-
// 音频相关属性https://www.runoob.com/tags/ref-av-dom.html
44-
const audioProps = reactive({
45-
autoplay: true,
46-
paused: false,
47-
currentTime: '00:00',
48-
duration: '00:00',
49-
muted: false,
50-
volume: 50,
51-
})
42+
const currentSong = inject('currentSong', {})
5243
53-
function toggleStatus (type: string) {
54-
audioProps[type] = !audioProps[type]
55-
if (type === 'paused' && audioRef.value) {
56-
if (audioProps[type]) {
57-
audioRef.value.pause()
58-
} else {
59-
audioRef.value.play()
60-
}
44+
const audioRef = ref<Nullable<HTMLElement>>(null)
45+
// 音频相关属性https://www.runoob.com/tags/ref-av-dom.html
46+
const audioProps = reactive({
47+
autoplay: true,
48+
paused: false,
49+
currentTime: '00:00',
50+
duration: '00:00',
51+
muted: false,
52+
volume: 50,
53+
})
54+
55+
function toggleStatus (type: string) {
56+
audioProps[type] = !audioProps[type]
57+
if (type === 'paused' && audioRef.value) {
58+
if (audioProps[type]) {
59+
audioRef.value.pause()
60+
} else {
61+
audioRef.value.play()
6162
}
6263
}
64+
}
6365
64-
// 更新播放位置
65-
function audioTimeUpdate (args) {
66-
audioProps.currentTime = formatPast(new Date(args.timeStamp), 'mm:ss')
67-
}
66+
// 更新播放位置
67+
function audioTimeUpdate (args) {
68+
audioProps.currentTime = formatPast(new Date(args.timeStamp), 'mm:ss')
69+
}
6870
</script>

src/views/ai/music/components/list/index.vue

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
<template>
2-
<div class="flex flex-col h-[600px]">
2+
<div class="flex flex-col">
33
<div class="flex-auto flex overflow-hidden">
44
<el-tabs v-model="currentType" class="flex-auto px-[var(--app-content-padding)]">
55
<!-- 我的创作 -->
6-
<el-tab-pane label="我的创作" v-loading="loading" name="mine">
6+
<el-tab-pane v-loading="loading" label="我的创作" name="mine">
77
<el-row v-if="mySongList.length" :gutter="12">
88
<el-col v-for="song in mySongList" :key="song.id" :span="24">
9-
<songCard v-bind="song"/>
9+
<songCard :songInfo="song" @play="setCurrentSong(song)"/>
1010
</el-col>
1111
</el-row>
1212
<el-empty v-else description="暂无音乐"/>
1313
</el-tab-pane>
1414

1515
<!-- 试听广场 -->
16-
<el-tab-pane label="试听广场" v-loading="loading" name="square">
16+
<el-tab-pane v-loading="loading" label="试听广场" name="square">
1717
<el-row v-if="squareSongList.length" v-loading="loading" :gutter="12">
1818
<el-col v-for="song in squareSongList" :key="song.id" :span="24">
19-
<songCard v-bind="song"/>
19+
<songCard :songInfo="song" @play="setCurrentSong(song)"/>
2020
</el-col>
2121
</el-row>
2222
<el-empty v-else description="暂无音乐"/>
2323
</el-tab-pane>
2424
</el-tabs>
2525
<!-- songInfo -->
26-
<songInfo v-bind="squareSongList[0]" class="flex-none"/>
26+
<songInfo class="flex-none"/>
2727
</div>
2828
<audioBar class="flex-none"/>
2929
</div>
@@ -36,13 +36,18 @@ import audioBar from './audioBar/index.vue'
3636
3737
defineOptions({ name: 'Index' })
3838
39+
3940
const currentType = ref('mine')
4041
// loading 状态
4142
const loading = ref(false)
43+
// 当前音乐
44+
const currentSong = ref({})
4245
4346
const mySongList = ref<Recordable[]>([])
4447
const squareSongList = ref<Recordable[]>([])
4548
49+
provide('currentSong', currentSong)
50+
4651
/*
4752
*@Description: 调接口生成音乐列表
4853
*@MethodAuthor: xiaohong
@@ -57,7 +62,7 @@ function generateMusic (formData: Recordable) {
5762
id: index,
5863
audioUrl: '',
5964
videoUrl: '',
60-
title: '我走后',
65+
title: '我走后' + index,
6166
imageUrl: 'https://www.carsmp3.com/data/attachment/forum/201909/19/091020q5kgre20fidreqyt.jpg',
6267
desc: 'Metal, symphony, film soundtrack, grand, majesticMetal, dtrack, grand, majestic',
6368
date: '2024年04月30日 14:02:57',
@@ -76,6 +81,15 @@ function generateMusic (formData: Recordable) {
7681
}, 3000)
7782
}
7883
84+
/*
85+
*@Description: 设置当前播放的音乐
86+
*@MethodAuthor: xiaohong
87+
*@Date: 2024-07-19 11:22:33
88+
*/
89+
function setCurrentSong (music: Recordable) {
90+
currentSong.value = music
91+
}
92+
7993
defineExpose({
8094
generateMusic
8195
})
@@ -86,9 +100,9 @@ defineExpose({
86100
:deep(.el-tabs) {
87101
display: flex;
88102
flex-direction: column;
89-
.el-tabs__content{
90-
padding: 0 7px;
91-
overflow: auto;
92-
}
103+
.el-tabs__content {
104+
padding: 0 7px;
105+
overflow: auto;
106+
}
93107
}
94108
</style>
Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<template>
22
<div class="flex bg-[var(--el-bg-color-overlay)] p-12px mb-12px rounded-1">
3-
<el-image :src="imageUrl" class="flex-none w-80px"/>
3+
<div class="relative" @click="playSong">
4+
<el-image :src="songInfo.imageUrl" class="flex-none w-80px"/>
5+
<div class="bg-black bg-op-40 absolute top-0 left-0 w-full h-full flex items-center justify-center cursor-pointer">
6+
<Icon :icon="currentSong.id === songInfo.id ? 'solar:pause-circle-bold':'mdi:arrow-right-drop-circle'" :size="30" />
7+
</div>
8+
</div>
49
<div class="ml-8px">
5-
<div>{{ title }}</div>
10+
<div>{{ songInfo.title }}</div>
611
<div class="mt-8px text-12px text-[var(--el-text-color-secondary)] line-clamp-2">
7-
{{ desc }}
12+
{{ songInfo.desc }}
813
</div>
914
</div>
1015
</div>
@@ -15,15 +20,17 @@
1520
defineOptions({ name: 'Index' })
1621
1722
defineProps({
18-
imageUrl: {
19-
type: String
20-
},
21-
title: {
22-
type: String
23-
},
24-
desc: {
25-
type: String
23+
songInfo: {
24+
type: Object,
25+
default: () => ({})
2626
}
2727
})
2828
29+
const emits = defineEmits(['play'])
30+
31+
const currentSong = inject('currentSong', {})
32+
33+
function playSong () {
34+
emits('play')
35+
}
2936
</script>

0 commit comments

Comments
 (0)