feat: add ImageMj page view

This commit is contained in:
RockYang 2023-09-13 18:04:31 +08:00
parent 3daf2f7738
commit 382d7bfaa1
6 changed files with 144 additions and 42 deletions

View File

@ -110,8 +110,8 @@ func (s *MjService) Run() {
continue continue
} }
// 锁定任务执行通道,直到任务超时(10分钟) // 锁定任务执行通道,直到任务超时(5分钟)
s.redis.Set(ctx, MjRunningJobKey, utils.JsonEncode(task), time.Minute*10) s.redis.Set(ctx, MjRunningJobKey, utils.JsonEncode(task), time.Minute*5)
} }
} }

View File

@ -10,8 +10,9 @@
<div class="text" v-html="data.html"></div> <div class="text" v-html="data.html"></div>
<div class="images" v-if="data.image?.url !== ''"> <div class="images" v-if="data.image?.url !== ''">
<el-image :src="data.image?.url" <el-image :src="data.image?.url"
:zoom-rate="1.0" :zoom-rate="1.2"
:preview-src-list="[data.image?.url]" :preview-src-list="[data.image?.url]"
fit="cover"
:initial-index="0" loading="lazy"> :initial-index="0" loading="lazy">
<template #placeholder> <template #placeholder>
<div class="image-slot" <div class="image-slot"

View File

@ -4,7 +4,7 @@ const routes = [
{ {
name: 'home', name: 'home',
path: '/', path: '/',
redirect: '/chat', redirect: '/mj',
meta: {title: '首页'}, meta: {title: '首页'},
component: () => import('@/views/Home.vue'), component: () => import('@/views/Home.vue'),
children: [ children: [
@ -14,13 +14,6 @@ const routes = [
meta: {title: '创作中心'}, meta: {title: '创作中心'},
component: () => import('@/views/ChatPlus.vue'), component: () => import('@/views/ChatPlus.vue'),
}, },
{
name: 'chat-id',
path: '/chat/:id',
meta: {title: '创作中心'},
component: () => import('@/views/ChatPlus.vue'),
props: true // 将路由参数传递给组件的 props
},
{ {
name: 'image-mj', name: 'image-mj',
path: '/mj', path: '/mj',

View File

@ -342,7 +342,7 @@ onMounted(() => {
newChat(); newChat();
} else { } else {
// //
changeChat(chat) loadChat(chat)
} }
}).catch((e) => { }).catch((e) => {
ElMessage.error('获取聊天角色失败: ' + e.messages) ElMessage.error('获取聊天角色失败: ' + e.messages)
@ -423,7 +423,6 @@ const newChat = function () {
// //
const changeChat = (chat) => { const changeChat = (chat) => {
router.push("/chat/" + chat.chat_id)
localStorage.setItem("chat_id", chat.chat_id) localStorage.setItem("chat_id", chat.chat_id)
loadChat(chat) loadChat(chat)
} }
@ -880,6 +879,5 @@ const getModelValue = (model_id) => {
</script> </script>
<style scoped lang="stylus"> <style scoped lang="stylus">
@import '@/assets/iconfont/iconfont.css';
@import "@/assets/css/chat-plus.styl" @import "@/assets/css/chat-plus.styl"
</style> </style>

View File

@ -39,16 +39,6 @@ import {isMobile} from "@/utils/libs";
import {ref} from "vue"; import {ref} from "vue";
const router = useRouter(); const router = useRouter();
checkSession().then(() => {
if (isMobile()) {
router.push("/mobile")
} else {
router.push("/chat")
}
}).catch(() => {
router.push("/login")
})
const logo = '/images/logo.png'; const logo = '/images/logo.png';
const navs = ref([ const navs = ref([
{path: "/chat", icon: "wechat", title: "对话聊天"}, {path: "/chat", icon: "wechat", title: "对话聊天"},
@ -60,7 +50,7 @@ const navs = ref([
{path: "/member", icon: "vip-user", title: "会员计划"}, {path: "/member", icon: "vip-user", title: "会员计划"},
{path: "/invite", icon: "share", title: "推广计划"}, {path: "/invite", icon: "share", title: "推广计划"},
]) ])
const curPath = ref(navs.value[0].path) const curPath = ref(router.currentRoute.value.path)
const changeNav = (item) => { const changeNav = (item) => {
curPath.value = item.path curPath.value = item.path
@ -69,6 +59,7 @@ const changeNav = (item) => {
</script> </script>
<style lang="stylus" scoped> <style lang="stylus" scoped>
@import '@/assets/iconfont/iconfont.css';
.home { .home {
display: flex; display: flex;
background-color: #25272D; background-color: #25272D;

View File

@ -1,39 +1,158 @@
<template> <template>
<div class="page-mj" :style="{ height: winHeight + 'px' }"> <div class="page-mj">
<div class="inner"> <div class="inner">
<h1>MidJourney 绘画中心</h1> <div class="mj-box">
<h2>页面正在紧锣密鼓开发中敬请期待</h2> <h2>MidJourney 创作中心</h2>
<div class="mj-params">
<div class="param-line">
<span>图片比例</span>
<el-tooltip
effect="light"
content="生成图片的尺寸比例"
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
<div class="param-line">
<el-row :gutter="10">
<el-col :span="8">
<div class="grid-content">
<div class="shape vertical"></div>
<div class="text">竖图</div>
</div>
</el-col>
<el-col :span="8">
<div class="grid-content">
<div class="shape square"></div>
<div class="text">方图</div>
</div>
</el-col>
<el-col :span="8">
<div class="grid-content">
<div class="shape horizontal"></div>
<div class="text">横图</div>
</div>
</el-col>
</el-row>
</div>
<div class="param-line">
<span>模型选择</span>
<el-tooltip
effect="light"
content="MJ: 偏真实通用模型 <br/>NIJI: 偏动漫风格、适用于二次元模型"
raw-content
placement="right"
>
<el-icon>
<InfoFilled/>
</el-icon>
</el-tooltip>
</div>
</div>
</div>
<div class="task-list-box" :style="{ height: listBoxHeight + 'px' }">
<h2>任务列表</h2>
<h2>创作记录</h2>
</div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import {ref} from "vue" import {ref} from "vue"
import {InfoFilled} from "@element-plus/icons-vue";
const winHeight = ref(window.innerHeight) const listBoxHeight = window.innerHeight - 20
const params = ref({
rate: '16:9'
})
</script> </script>
<style lang="stylus" scoped> <style lang="stylus" scoped>
.page-mj { .page-mj {
display: flex;
justify-content: center;
align-items center
background-color: #282c34; background-color: #282c34;
.inner { .inner {
text-align center display: flex;
h1 { .mj-box {
color: #202020; margin 10px
font-size: 80px; background-color #262626
font-weight: bold; border 1px solid #454545
letter-spacing: 0.1em; min-width 300px
text-shadow: -1px -1px 1px #111111, 2px 2px 1px #363636; padding 10px
border-radius 10px
color #ffffff;
font-size 14px
h2 {
font-weight: bold;
font-size 20px
text-align center
color #47fff1
}
.mj-params {
margin-top 10px
.param-line {
padding 6px 10px 6px 10px
.el-icon {
position relative
top 3px
}
.grid-content {
background-color #383838
border-radius 5px
padding 5px 6px
display flex
cursor pointer
.shape {
width 16px
height 16px
margin-right 5px
border 1px solid #C4C4C4
border-radius 3px
}
.shape.vertical {
width 12px
height 20px
}
.shape.horizontal {
height 12px
width 20px
position relative
top 3px
}
}
}
}
} }
h2 {
color #ffffff; .task-list-box {
font-weight: bold; width 100%
padding 10px
color #ffffff
overflow-x hidden
overflow-y auto
h2 {
font-size 20px
}
} }
} }