Skip to content

Commit 0a48b52

Browse files
committed
Merge remote-tracking branch 'yudao-ui-admin-vue3/dev' into dev
# Conflicts: # src/api/ai/writer/index.ts
2 parents 1f22e0b + 69940e2 commit 0a48b52

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+515
-324
lines changed

src/api/ai/writer/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export interface WriteVO {
1313
format: number // 格式
1414
tone: number // 语气
1515
language: number // 语言
16+
userId?: number // 用户编号
17+
platform?: string // 平台
18+
model?: string // 模型
19+
generatedContent?: string // 生成的内容
20+
errorMessage: string // 错误信息
21+
createTime?: Date // 创建时间
1622
}
1723

1824
export interface AiWritePageReqVO extends PageParam {

src/components/MarkdownView/index.vue

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
1-
21
<template>
32
<div ref="contentRef" class="markdown-view" v-html="contentHtml"></div>
43
</template>
54

65
<script setup lang="ts">
7-
import {useClipboard} from "@vueuse/core";
8-
9-
import {marked} from 'marked'
6+
import { useClipboard } from '@vueuse/core'
7+
import { marked } from 'marked'
108
import 'highlight.js/styles/vs2015.min.css'
119
import hljs from 'highlight.js'
12-
import {ref} from "vue";
1310
14-
const {copy} = useClipboard() // 初始化 copy 到粘贴板
11+
// 定义组件属性
12+
const props = defineProps({
13+
content: {
14+
type: String,
15+
required: true
16+
}
17+
})
18+
19+
const message = useMessage() // 消息弹窗
20+
const { copy } = useClipboard() // 初始化 copy 到粘贴板
1521
const contentRef = ref()
22+
const contentHtml = ref<any>() // 渲染的html内容
23+
const { content } = toRefs(props) // 将 props 变为引用类型
1624
1725
// 代码高亮:https://highlightjs.org/
1826
// 转换 markdown:marked
1927
20-
// marked 渲染器
28+
/** marked 渲染器 */
2129
const renderer = {
2230
code(code, language, c) {
2331
let highlightHtml
2432
try {
25-
highlightHtml = hljs.highlight(code, {language: language, ignoreIllegals: true}).value
33+
highlightHtml = hljs.highlight(code, { language: language, ignoreIllegals: true }).value
2634
} catch (e) {
2735
// skip
2836
}
@@ -36,50 +44,30 @@ marked.use({
3644
renderer: renderer
3745
})
3846
39-
// 渲染的html内容
40-
const contentHtml = ref<any>()
41-
42-
// 定义组件属性
43-
const props = defineProps({
44-
content: {
45-
type: String,
46-
required: true
47-
}
48-
})
49-
50-
// 将 props 变为引用类型
51-
const { content } = toRefs(props)
52-
53-
// 监听 content 变化
47+
/** 监听 content 变化 */
5448
watch(content, async (newValue, oldValue) => {
55-
await renderMarkdown(newValue);
49+
await renderMarkdown(newValue)
5650
})
5751
58-
// 渲染 markdown
52+
/** 渲染 markdown */
5953
const renderMarkdown = async (content: string) => {
6054
contentHtml.value = await marked(content)
6155
}
6256
63-
// 组件挂在时
64-
onMounted(async () => {
57+
/** 初始化 **/
58+
onMounted(async () => {
6559
// 解析转换 markdown
66-
await renderMarkdown(props.content as string);
67-
//
60+
await renderMarkdown(props.content as string)
6861
// 添加 copy 监听
6962
contentRef.value.addEventListener('click', (e: any) => {
70-
console.log(e)
7163
if (e.target.id === 'copy') {
7264
copy(e.target?.dataset?.copy)
73-
ElMessage({
74-
message: '复制成功!',
75-
type: 'success'
76-
})
65+
message.success('复制成功!')
7766
}
7867
})
7968
})
8069
</script>
8170

82-
8371
<style lang="scss">
8472
.markdown-view {
8573
font-family: PingFang SC;

src/layout/components/AppView.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ provide('reload', reload)
3838
:class="[
3939
'p-[var(--app-content-padding)] w-[calc(100%-var(--app-content-padding)-var(--app-content-padding))] bg-[var(--app-content-bg-color)] dark:bg-[var(--el-bg-color)]',
4040
{
41-
'!h-[calc(100%-var(--app-content-padding)-var(--app-content-padding)-var(--app-footer-height))]':
41+
'!min-h-[calc(100%-var(--app-content-padding)-var(--app-content-padding)-var(--app-footer-height))]':
4242
(fixedHeader &&
4343
(layout === 'classic' || layout === 'topLeft' || layout === 'top') &&
4444
footer) ||
4545
(!tagsView && layout === 'top' && footer),
46-
'!h-[calc(100%-var(--app-content-padding)-var(--app-content-padding)-var(--app-footer-height)-var(--tags-view-height))]':
46+
'!min-h-[calc(100%-var(--app-content-padding)-var(--app-content-padding)-var(--app-footer-height)-var(--tags-view-height))]':
4747
tagsView && layout === 'top' && footer,
4848
49-
'!h-[calc(100%-var(--tags-view-height)-var(--app-content-padding)-var(--app-content-padding)-var(--top-tool-height)-var(--app-footer-height))]':
49+
'!min-h-[calc(100%-var(--tags-view-height)-var(--app-content-padding)-var(--app-content-padding)-var(--top-tool-height)-var(--app-footer-height))]':
5050
!fixedHeader && layout === 'classic' && footer,
5151
52-
'!h-[calc(100%-var(--tags-view-height)-var(--app-content-padding)-var(--app-content-padding)-var(--app-footer-height))]':
52+
'!min-h-[calc(100%-var(--tags-view-height)-var(--app-content-padding)-var(--app-content-padding)-var(--app-footer-height))]':
5353
!fixedHeader && layout === 'topLeft' && footer,
5454
55-
'!h-[calc(100%-var(--top-tool-height)-var(--app-content-padding)-var(--app-content-padding))]':
55+
'!min-h-[calc(100%-var(--top-tool-height)-var(--app-content-padding)-var(--app-content-padding))]':
5656
fixedHeader && layout === 'cutMenu' && footer,
5757
58-
'!h-[calc(100%-var(--top-tool-height)-var(--app-content-padding)-var(--app-content-padding)-var(--tags-view-height))]':
58+
'!min-h-[calc(100%-var(--top-tool-height)-var(--app-content-padding)-var(--app-content-padding)-var(--tags-view-height))]':
5959
!fixedHeader && layout === 'cutMenu' && footer
6060
}
6161
]"

src/router/modules/remaining.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,26 @@ const remainingRouter: AppRouteRecordRaw[] = [
7070
}
7171
]
7272
},
73-
{
74-
path: '/ai/music',
75-
component: Layout,
76-
redirect: '/index',
77-
name: 'AIMusic',
78-
meta: {},
79-
children: [
80-
{
81-
path: 'index',
82-
component: () => import('@/views/ai/music/components/index.vue'),
83-
name: 'AIMusicIndex',
84-
meta: {
85-
title: 'AI 音乐',
86-
icon: 'ep:home-filled',
87-
noCache: false,
88-
affix: true
89-
}
90-
}
91-
]
92-
},
73+
// {
74+
// path: '/ai/music',
75+
// component: Layout,
76+
// redirect: '/index',
77+
// name: 'AIMusic',
78+
// meta: {},
79+
// children: [
80+
// {
81+
// path: 'index',
82+
// component: () => import('@/views/ai/music/components/index.vue'),
83+
// name: 'AIMusicIndex',
84+
// meta: {
85+
// title: 'AI 音乐',
86+
// icon: 'ep:home-filled',
87+
// noCache: false,
88+
// affix: true
89+
// }
90+
// }
91+
// ]
92+
// },
9393
{
9494
path: '/user',
9595
component: Layout,

src/utils/dict.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,5 +222,10 @@ export enum DICT_TYPE {
222222
AI_PLATFORM = 'ai_platform', // AI 平台
223223
AI_IMAGE_STATUS = 'ai_image_status', // AI 图片状态
224224
AI_MUSIC_STATUS = 'ai_music_status', // AI 音乐状态
225-
AI_GENERATE_MODE = 'ai_generate_mode' // AI 生成模式
225+
AI_GENERATE_MODE = 'ai_generate_mode', // AI 生成模式
226+
AI_WRITE_TYPE = 'ai_write_type', // AI 写作类型
227+
AI_WRITE_LENGTH = 'ai_write_length', // AI 写作长度
228+
AI_WRITE_FORMAT = 'ai_write_format', // AI 写作格式
229+
AI_WRITE_TONE = 'ai_write_tone', // AI 写作语气
230+
AI_WRITE_LANGUAGE = 'ai_write_language' // AI 写作语言
226231
}

src/views/ai/image/index/components/other/index.vue

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@
3636
<el-text tag="b">平台</el-text>
3737
</div>
3838
<el-space wrap class="group-item-body">
39-
<el-select v-model="otherPlatform" placeholder="Select" size="large" class="!w-350px" @change="handlerPlatformChange">
39+
<el-select
40+
v-model="otherPlatform"
41+
placeholder="Select"
42+
size="large"
43+
class="!w-350px"
44+
@change="handlerPlatformChange"
45+
>
4046
<el-option
4147
v-for="item in OtherPlatformEnum"
4248
:key="item.key"
@@ -52,12 +58,7 @@
5258
</div>
5359
<el-space wrap class="group-item-body">
5460
<el-select v-model="model" placeholder="Select" size="large" class="!w-350px">
55-
<el-option
56-
v-for="item in models"
57-
:key="item.key"
58-
:label="item.name"
59-
:value="item.key"
60-
/>
61+
<el-option v-for="item in models" :key="item.key" :label="item.name" :value="item.key" />
6162
</el-select>
6263
</el-space>
6364
</div>
@@ -77,12 +78,14 @@
7778
</div>
7879
</template>
7980
<script setup lang="ts">
80-
import {ImageApi, ImageDrawReqVO, ImageVO} from '@/api/ai/image'
81+
import { ImageApi, ImageDrawReqVO, ImageVO } from '@/api/ai/image'
8182
import {
8283
AiPlatformEnum,
84+
ChatGlmModels,
8385
ImageHotWords,
8486
ImageModelVO,
8587
OtherPlatformEnum,
88+
QianFanModels,
8689
TongYiWanXiangModels
8790
} from '@/views/ai/utils/constants'
8891
@@ -96,10 +99,9 @@ const prompt = ref<string>('') // 提示词
9699
const width = ref<number>(512) // 图片宽度
97100
const height = ref<number>(512) // 图片高度
98101
const otherPlatform = ref<string>(AiPlatformEnum.TONG_YI) // 平台
99-
const models = ref<ImageModelVO[]>(TongYiWanXiangModels) // 模型
102+
const models = ref<ImageModelVO[]>(TongYiWanXiangModels) // 模型 TongYiWanXiangModels、QianFanModels
100103
const model = ref<string>(models.value[0].key) // 模型
101104
102-
103105
const emits = defineEmits(['onDrawStart', 'onDrawComplete']) // 定义 emits
104106
105107
/** 选择热词 */
@@ -131,9 +133,8 @@ const handleGenerateImage = async () => {
131133
prompt: prompt.value, // 提示词
132134
width: width.value, // 图片宽度
133135
height: height.value, // 图片高度
134-
options: {
135-
}
136-
} as ImageDrawReqVO
136+
options: {}
137+
} as unknown as ImageDrawReqVO
137138
await ImageApi.drawImage(form)
138139
} finally {
139140
// 回调
@@ -148,21 +149,24 @@ const settingValues = async (detail: ImageVO) => {
148149
prompt.value = detail.prompt
149150
width.value = detail.width
150151
height.value = detail.height
151-
152152
}
153153
154154
/** 平台切换 */
155-
const handlerPlatformChange = async (platform) => {
155+
const handlerPlatformChange = async (platform: string) => {
156156
// 切换平台,切换模型、风格
157-
if (AiPlatformEnum.YI_YAN === platform) {
157+
if (AiPlatformEnum.TONG_YI === platform) {
158158
models.value = TongYiWanXiangModels
159+
} else if (AiPlatformEnum.YI_YAN === platform) {
160+
models.value = QianFanModels
161+
} else if (AiPlatformEnum.ZHI_PU === platform) {
162+
models.value = ChatGlmModels
159163
} else {
160164
models.value = []
161165
}
162166
// 切换平台,默认选择一个风格
163167
if (models.value.length > 0) {
164168
model.value = models.value[0].key
165-
} else {
169+
} else {
166170
model.value = ''
167171
}
168172
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
ref="otherRef"
2424
@on-draw-complete="handleDrawComplete"
2525
/>
26-
2726
</div>
2827
</div>
2928
<div class="main">
@@ -63,7 +62,7 @@ const platformOptions = [
6362
value: AiPlatformEnum.STABLE_DIFFUSION
6463
},
6564
{
66-
label: '其他',
65+
label: '其它',
6766
value: 'other'
6867
}
6968
]
@@ -89,6 +88,7 @@ const handleRegeneration = async (image: ImageVO) => {
8988
} else if (image.platform === AiPlatformEnum.STABLE_DIFFUSION) {
9089
stableDiffusionRef.value.settingValues(image)
9190
}
91+
// TODO @fan:貌似 other 重新设置不行?
9292
}
9393
</script>
9494

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@
99
label-width="68px"
1010
>
1111
<el-form-item label="用户编号" prop="userId">
12-
<el-input
12+
<el-select
1313
v-model="queryParams.userId"
14-
placeholder="请输入用户编号"
1514
clearable
16-
@keyup.enter="handleQuery"
15+
placeholder="请输入用户编号"
1716
class="!w-240px"
18-
/>
17+
>
18+
<el-option
19+
v-for="item in userList"
20+
:key="item.id"
21+
:label="item.nickname"
22+
:value="item.id"
23+
/>
24+
</el-select>
1925
</el-form-item>
2026
<el-form-item label="音乐名称" prop="title">
2127
<el-input

0 commit comments

Comments
 (0)