fixed conflicts

This commit is contained in:
RockYang
2024-06-30 06:09:12 +08:00
59 changed files with 2535 additions and 1293 deletions

View File

@@ -1,19 +1,22 @@
<template>
<div>
<div class="page-apps custom-scroll">
<div class="title">
AI 助手应用中心
</div>
<div class="inner" :style="{height: listBoxHeight + 'px'}">
<ItemList :items="list" v-if="list.length > 0" :gap="20" :width="250">
<ItemList :items="list" v-if="list.length > 0" :gap="15" :width="300">
<template #default="scope">
<div class="app-item" :style="{width: scope.width+'px'}">
<el-image :src="scope.item.icon" fit="cover" :style="{height: scope.width+'px'}"/>
<div class="title">
<span class="name">{{ scope.item.name }}</span>
<div class="opt">
<div class="item">
<div class="image">
<el-image :src="scope.item.icon" fit="cover"/>
</div>
<div class="inner">
<div class="info">
<div class="info-title">{{ scope.item.name }}</div>
<div class="info-text">{{ scope.item.hello_msg }}</div>
</div>
<div class="btn">
<div v-if="hasRole(scope.item.key)">
<el-button size="small" type="success" @click="useRole(scope.item)">使用</el-button>
<el-button size="small" color="#21aa93" @click="useRole(scope.item)">使用</el-button>
<el-button size="small" type="danger" @click="updateRole(scope.item,'remove')">移除</el-button>
</div>
<el-button v-else size="small"
@@ -26,15 +29,34 @@
</el-button>
</div>
</div>
<div class="hello-msg" ref="elements">{{ scope.item.intro }}</div>
</div>
<!-- <div class="app-item">-->
<!-- <el-image :src="scope.item.icon" fit="cover"/>-->
<!-- <div class="title">-->
<!-- <span class="name">{{ scope.item.name }}</span>-->
<!-- <div class="opt">-->
<!-- <div v-if="hasRole(scope.item.key)">-->
<!-- <el-button size="small" type="success" @click="useRole(scope.item)">使用</el-button>-->
<!-- <el-button size="small" type="danger" @click="updateRole(scope.item,'remove')">移除</el-button>-->
<!-- </div>-->
<!-- <el-button v-else size="small"-->
<!-- style="&#45;&#45;el-color-primary:#009999"-->
<!-- @click="updateRole(scope.item, 'add')">-->
<!-- <el-icon>-->
<!-- <Plus/>-->
<!-- </el-icon>-->
<!-- <span>添加应用</span>-->
<!-- </el-button>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="hello-msg" ref="elements">{{ scope.item.intro }}</div>-->
<!-- </div>-->
</template>
</ItemList>
</div>
</div>
<login-dialog :show="showLoginDialog" @hide="getRoles" @success=""/>
</div>
</template>
@@ -42,18 +64,18 @@
import {onMounted, ref} from "vue"
import {ElMessage} from "element-plus";
import {httpGet, httpPost} from "@/utils/http";
import ItemList from "@/components/ItemList.vue";
import {Plus} from "@element-plus/icons-vue";
import LoginDialog from "@/components/LoginDialog.vue";
import {checkSession} from "@/action/session";
import {arrayContains, removeArrayItem, substr} from "@/utils/libs";
import {useRouter} from "vue-router";
import {useSharedStore} from "@/store/sharedata";
import ItemList from "@/components/ItemList.vue";
import {Plus} from "@element-plus/icons-vue";
const listBoxHeight = window.innerHeight - 97
const listBoxHeight = window.innerHeight - 87
const list = ref([])
const showLoginDialog = ref(false)
const roles = ref([])
const elements = ref(null)
const store = useSharedStore();
onMounted(() => {
httpGet("/api/role/list?all=true").then((res) => {
const items = res.data
@@ -70,7 +92,6 @@ onMounted(() => {
})
const getRoles = () => {
showLoginDialog.value = false
checkSession().then(user => {
roles.value = user.chat_roles
}).catch(() => {
@@ -101,7 +122,7 @@ const updateRole = (row, opt) => {
ElMessage.error(title.value + "失败:" + e.message)
})
}).catch(() => {
showLoginDialog.value = true
store.setShowLoginDialog(true)
})
}

View File

@@ -3,9 +3,6 @@
<div class="chat-box" id="chat-box">
<div class="title">
<h2>{{ chatTitle }}</h2>
<el-button type="success" @click="exportChat" :icon="Promotion">
导出 PDF 文档
</el-button>
</div>
<div v-for="item in chatData" :key="item.id">
@@ -14,17 +11,10 @@
:icon="item.icon"
:created-at="dateFormat(item['created_at'])"
:tokens="item['tokens']"
:model="item['model']"
:content="item.content"/>
<chat-reply v-else-if="item.type==='reply'"
:icon="item.icon"
:org-content="item.orgContent"
:created-at="dateFormat(item['created_at'])"
:tokens="item['tokens']"
:content="item.content"/>
<chat-mid-journey v-else-if="item.type==='mj'"
:content="item.content"
:icon="item.icon"
:created-at="dateFormat(item['created_at'])"/>
:data="item" :read-only="true"/>
</div>
</div><!-- end chat box -->
</div>
@@ -34,14 +24,13 @@
import {dateFormat} from "@/utils/libs";
import ChatReply from "@/components/ChatReply.vue";
import ChatPrompt from "@/components/ChatPrompt.vue";
import {nextTick, ref} from "vue";
import {nextTick, onMounted, ref} from "vue";
import {useRouter} from "vue-router";
import {httpGet} from "@/utils/http";
import 'highlight.js/styles/a11y-dark.css'
import hl from "highlight.js";
import {ElMessage} from "element-plus";
import {Promotion} from "@element-plus/icons-vue";
import ChatMidJourney from "@/components/ChatMidJourney.vue";
import Clipboard from "clipboard";
const chatData = ref([])
const router = useRouter()
@@ -91,9 +80,16 @@ httpGet('/api/chat/detail?chat_id=' + chatId).then(res => {
ElMessage.error("加载会失败: " + e.message)
})
const exportChat = () => {
window.print()
}
onMounted(() => {
const clipboard = new Clipboard('.copy-reply');
clipboard.on('success', () => {
ElMessage.success('复制成功!');
})
clipboard.on('error', () => {
ElMessage.error('复制失败!');
})
})
</script>
<style lang="stylus">
.chat-export {
@@ -115,12 +111,15 @@ const exportChat = () => {
}
.chat-line {
.chat-line-prompt {
font-size: 14px;
display: flex;
align-items: flex-start;
.chat-line-inner {
.chat-icon {
margin-right: 0
}
.content {
padding-top: 0
font-size 16px;
@@ -138,10 +137,6 @@ const exportChat = () => {
.chat-line-inner {
display flex
.copy-reply {
display none
}
.bar-item {
background-color: #f7f7f8;
color: #888;

View File

@@ -1,13 +1,18 @@
<template>
<div class="common-layout theme-white">
<div class="common-layout">
<el-container>
<el-aside>
<div class="title-box">
<span>{{ title }}</span>
</div>
<div class="chat-list">
<el-button @click="newChat" color="#21aa93">
<el-icon style="margin-right: 5px">
<Plus/>
</el-icon>
新建对话
</el-button>
<div class="search-box">
<el-input v-model="chatName" class="w-50 m-2" size="small" placeholder="搜索会话" @keyup="searchChat">
<el-input v-model="chatName" placeholder="搜索会话" @keyup="searchChat($event)" style=""
class="search-input">
<template #prefix>
<el-icon class="el-input__icon">
<Search/>
@@ -22,111 +27,45 @@
@click="changeChat(chat)">
<el-image :src="chat.icon" class="avatar"/>
<span class="chat-title-input" v-if="chat.edit">
<el-input v-model="tmpChatTitle" size="small" @keydown="titleKeydown($event, chat)"
placeholder="请输入会话标题"/>
</span>
<el-input v-model="tmpChatTitle" size="small" @keydown="titleKeydown($event, chat)"
:id="'chat-'+chat.chat_id"
@blur="editConfirm(chat)"
@click="stopPropagation($event)"
placeholder="请输入标题"/>
</span>
<span v-else class="chat-title">{{ chat.title }}</span>
<span class="btn btn-check" v-if="chat.edit || chat.removing">
<el-icon @click="confirm($event, chat)"><Check/></el-icon>
<el-icon @click="cancel($event, chat)"><Close/></el-icon>
</span>
<span class="btn" v-else>
<el-icon title="编辑" @click="editChatTitle($event, chat)"><Edit/></el-icon>
<el-icon title="删除会话" @click="removeChat($event, chat)"><Delete/></el-icon>
</span>
<span class="chat-opt">
<el-dropdown trigger="click">
<span class="el-dropdown-link" @click="stopPropagation($event)">
<el-icon><More/></el-icon>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item :icon="Edit" @click="editChatTitle(chat)">重命名</el-dropdown-item>
<el-dropdown-item :icon="Delete"
style="--el-text-color-regular: var(--el-color-danger);
--el-dropdown-menuItem-hover-fill:#F8E1DE;
--el-dropdown-menuItem-hover-color: var(--el-color-danger)"
@click="removeChat(chat)">删除</el-dropdown-item>
<el-dropdown-item :icon="Share" @click="shareChat(chat)">分享</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</span>
</div>
</el-row>
</div>
</div>
<div class="tool-box">
<el-dropdown :hide-on-click="true" class="user-info" trigger="click" v-if="isLogin">
<span class="el-dropdown-link">
<el-image :src="loginUser.avatar"/>
<span class="username">{{ loginUser.nickname }}</span>
<el-icon><ArrowDown/></el-icon>
</span>
<template #dropdown>
<el-dropdown-menu style="width: 296px;">
<el-dropdown-item @click="showConfig">
<el-icon>
<Tools/>
</el-icon>
<span>账户信息</span>
</el-dropdown-item>
<el-dropdown-item @click="clearAllChats">
<el-icon>
<Delete/>
</el-icon>
<span>清除所有会话</span>
</el-dropdown-item>
<el-dropdown-item @click="logout">
<i class="iconfont icon-logout"></i>
<span>注销</span>
</el-dropdown-item>
<el-dropdown-item>
<i class="iconfont icon-github"></i>
<span>
powered by
<el-link type="primary" href="https://github.com/yangjian102621/chatgpt-plus" target="_blank">chatgpt-plus-v3</el-link>
</span>
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-button type="danger" size="small" @click="clearAllChats">
<i class="iconfont icon-clear"></i> 清空聊天记录
</el-button>
</div>
</el-aside>
<el-main v-loading="loading" element-loading-background="rgba(122, 122, 122, 0.3)">
<div class="chat-head">
<div class="chat-config">
<el-select v-model="roleId" filterable placeholder="角色" class="role-select" @change="_newChat"
style="width:150px">
<el-option
v-for="item in roles"
:key="item.id"
:label="item.name"
:value="item.id"
>
<div class="role-option">
<el-image :src="item.icon"></el-image>
<span>{{ item.name }}</span>
</div>
</el-option>
</el-select>
<el-select v-model="modelID" placeholder="模型" @change="_newChat" :disabled="disableModel"
style="width:150px">
<el-option
v-for="item in models"
:key="item.id"
:label="item.name"
:value="item.id"
>
<span>{{ item.name }}</span>
<el-tag style="margin-left: 5px; position: relative; top:-2px" type="info" size="small">{{
item.power
}}算力
</el-tag>
</el-option>
</el-select>
<el-button type="primary" @click="newChat">
<el-icon>
<Plus/>
</el-icon>
新建对话
</el-button>
<el-button type="success" @click="exportChat" plain>
<i class="iconfont icon-export"></i>
<span>导出会话</span>
</el-button>
</div>
</div>
<div class="right-box" :style="{height: mainWinHeight+'px'}">
<div class="chat-box" :style="{height: mainWinHeight+'px'}">
<div>
<div id="container">
<div class="chat-box" id="chat-box" :style="{height: chatBoxHeight+'px'}">
@@ -141,63 +80,103 @@
:tokens="item['tokens']"
:model="getModelValue(modelID)"
:content="item.content"/>
<chat-reply v-else-if="item.type==='reply'"
:icon="item.icon"
:org-content="item.orgContent"
:created-at="dateFormat(item['created_at'])"
:tokens="item['tokens']"
:content="item.content"/>
<chat-mid-journey v-else-if="item.type==='mj'"
:content="item.content"
:role-id="item.role_id"
:chat-id="item.chat_id"
:icon="item.icon"
@disable-input="disableInput(true)"
@enable-input="enableInput"
:created-at="dateFormat(item['created_at'])"/>
<chat-reply v-else-if="item.type==='reply'" :data="item" @regen="reGenerate" :read-only="false"/>
</div>
</div><!-- end chat box -->
<div class="re-generate">
<div class="btn-box">
<el-button type="info" v-if="showStopGenerate" @click="stopGenerate" plain>
<el-icon>
<VideoPause/>
</el-icon>
停止生成
</el-button>
<el-affix position="bottom" :offset="0">
<div class="input-box">
<span class="tool-item">
<el-popover
:width="300"
trigger="click"
placement="top-start"
>
<template #reference>
<div>
<el-tooltip effect="dark" content="模型选择">
<i class="iconfont icon-model"></i>
</el-tooltip>
</div>
</template>
<el-button type="primary" v-if="showReGenerate" @click="reGenerate" plain>
<el-icon>
<RefreshRight/>
</el-icon>
重新生成
</el-button>
</div>
</div>
<template #default>
<div class="chat-config">
<el-select v-model="roleId" filterable placeholder="角色" @change="_newChat"
class="role-select"
style="width:150px">
<el-option
v-for="item in roles"
:key="item.id"
:label="item.name"
:value="item.id"
>
<div class="role-option">
<el-image :src="item.icon"></el-image>
<span>{{ item.name }}</span>
</div>
</el-option>
</el-select>
<div class="input-box">
<div class="input-container">
<el-input
ref="textInput"
v-model="prompt"
v-on:keydown="inputKeyDown"
autofocus
type="textarea"
:rows="2"
placeholder="按 Enter 键发送消息,使用 Ctrl + Enter 换行"
/>
<span class="select-file">
<file-select v-if="isLogin" :user-id="loginUser.id" @selected="insertURL"/>
<el-select v-model="modelID" filterable placeholder="模型" @change="_newChat"
:disabled="disableModel"
style="width:150px">
<el-option
v-for="item in models"
:key="item.id"
:label="item.name"
:value="item.id"
>
<span>{{ item.name }}</span>
<el-tag style="margin-left: 5px; position: relative; top:-2px" type="info" size="small">{{
item.power
}}算力
</el-tag>
</el-option>
</el-select>
</div>
</template>
</el-popover>
</span>
<span class="send-btn">
<el-button @click="sendMessage">
<span class="tool-item" @click="ElMessage.info('暂时不支持语音输入')">
<el-tooltip class="box-item" effect="dark" content="语音输入">
<i class="iconfont icon-mic-bold"></i>
</el-tooltip>
</span>
<span class="tool-item" v-if="isLogin">
<el-tooltip class="box-item" effect="dark" content="上传附件">
<file-select v-if="isLogin" :user-id="loginUser.id" @selected="insertURL"/>
</el-tooltip>
</span>
<div class="input-container">
<el-input
ref="textInput"
v-model="prompt"
v-on:keydown="inputKeyDown"
autofocus
type="textarea"
:rows="2"
style="--el-input-focus-border-color:#21AA93;
border: 1px solid #21AA93;--el-input-border-color:#21AA93;
border-radius: 5px; --el-input-hover-border-color:#21AA93;"
placeholder="按 Enter 键发送消息,使用 Ctrl + Enter 换行"
/>
<span class="send-btn">
<el-button type="info" v-if="showStopGenerate" @click="stopGenerate" plain>
<el-icon>
<VideoPause/>
</el-icon>
</el-button>
<el-button @click="sendMessage" color="#19c37d" style="color:#ffffff" v-else>
<el-icon><Promotion/></el-icon>
</el-button>
</span>
</div>
</div><!-- end input box -->
</div>
</div><!-- end input box -->
</el-affix>
</div><!-- end container -->
</div><!-- end loading -->
</div>
@@ -207,23 +186,17 @@
<el-dialog
v-model="showNotice"
:show-close="true"
custom-class="notice-dialog"
class="notice-dialog"
title="网站公告"
>
<div class="notice">
<el-text type="primary">
<div v-html="notice"></div>
</el-text>
<div v-html="notice"></div>
<p style="text-align: right">
<el-button @click="notShow" type="success" plain>我知道了不再显示</el-button>
</p>
</div>
</el-dialog>
<config-dialog v-if="isLogin" :show="showConfigDialog" :models="models" @hide="showConfigDialog = false"/>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="initData"/>
</div>
@@ -232,19 +205,7 @@
import {nextTick, onMounted, onUnmounted, ref} from 'vue'
import ChatPrompt from "@/components/ChatPrompt.vue";
import ChatReply from "@/components/ChatReply.vue";
import {
ArrowDown,
Check,
Close,
Delete,
Edit,
Plus,
Promotion,
RefreshRight,
Search,
Tools,
VideoPause
} from '@element-plus/icons-vue'
import {Delete, Edit, More, Plus, Promotion, Search, Share, VideoPause} from '@element-plus/icons-vue'
import 'highlight.js/styles/a11y-dark.css'
import {dateFormat, escapeHTML, isMobile, processContent, randString, removeArrayItem, UUID} from "@/utils/libs";
import {ElMessage, ElMessageBox} from "element-plus";
@@ -253,12 +214,10 @@ import {getSessionId, getUserToken, removeUserToken} from "@/store/session";
import {httpGet, httpPost} from "@/utils/http";
import {useRouter} from "vue-router";
import Clipboard from "clipboard";
import ConfigDialog from "@/components/ConfigDialog.vue";
import {checkSession} from "@/action/session";
import Welcome from "@/components/Welcome.vue";
import ChatMidJourney from "@/components/ChatMidJourney.vue";
import {useSharedStore} from "@/store/sharedata";
import FileSelect from "@/components/FileSelect.vue";
import LoginDialog from "@/components/LoginDialog.vue";
const title = ref('ChatGPT-智能助手');
const models = ref([])
@@ -276,14 +235,13 @@ const roles = ref([]);
const router = useRouter();
const roleId = ref(0)
const newChatItem = ref(null);
const showConfigDialog = ref(false);
const showLoginDialog = ref(false)
const isLogin = ref(false)
const showHello = ref(true)
const textInput = ref(null)
const showNotice = ref(false)
const notice = ref("")
const noticeKey = ref("SYSTEM_NOTICE")
const store = useSharedStore();
if (isMobile()) {
router.replace("/mobile/chat")
@@ -414,9 +372,9 @@ const getRoleById = function (rid) {
}
const resizeElement = function () {
chatBoxHeight.value = window.innerHeight - 51 - 82 - 38;
mainWinHeight.value = window.innerHeight - 51;
leftBoxHeight.value = window.innerHeight - 43 - 47 - 45;
chatBoxHeight.value = window.innerHeight - 50 - 82 - 38;
mainWinHeight.value = window.innerHeight - 50;
leftBoxHeight.value = window.innerHeight - 90 - 45 - 82;
};
const _newChat = () => {
@@ -424,17 +382,17 @@ const _newChat = () => {
newChat()
}
}
const disableModel = ref(false)
// 新建会话
const newChat = () => {
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return;
}
const role = getRoleById(roleId.value)
showHello.value = role.key === 'gpt';
// if the role bind a model, disable model change
disableModel.value = false
if (role.model_id > 0) {
modelID.value = role.model_id
disableModel.value = true
@@ -462,7 +420,6 @@ const newChat = () => {
};
activeChat.value = {} //取消激活的会话高亮
showStopGenerate.value = false;
showReGenerate.value = false;
connect(null, roleId.value)
}
@@ -474,7 +431,7 @@ const changeChat = (chat) => {
const loadChat = function (chat) {
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return;
}
@@ -487,69 +444,77 @@ const loadChat = function (chat) {
roleId.value = chat.role_id;
modelID.value = chat.model_id;
showStopGenerate.value = false;
showReGenerate.value = false;
connect(chat.chat_id, chat.role_id)
}
// 编辑会话标题
const curOpt = ref('')
const tmpChatTitle = ref('');
const editChatTitle = function (event, chat) {
event.stopPropagation();
const editChatTitle = (chat) => {
chat.edit = true;
curOpt.value = 'edit';
tmpChatTitle.value = chat.title;
console.log(chat.chat_id)
nextTick(() => {
document.getElementById('chat-' + chat.chat_id).focus()
})
};
const titleKeydown = (e, chat) => {
if (e.keyCode === 13) {
e.stopPropagation();
confirm(e, chat)
editConfirm(chat)
}
}
const stopPropagation = (e) => {
e.stopPropagation();
}
// 确认修改
const confirm = function (event, chat) {
event.stopPropagation();
if (curOpt.value === 'edit') {
if (tmpChatTitle.value === '') {
return ElMessage.error("请输入会话标题!");
}
if (!chat.chat_id) {
return ElMessage.error("对话 ID 为空,请刷新页面再试!");
}
httpPost('/api/chat/update', {chat_id: chat.chat_id, title: tmpChatTitle.value}).then(() => {
chat.title = tmpChatTitle.value;
chat.edit = false;
}).catch(e => {
ElMessage.error("操作失败:" + e.message);
})
} else if (curOpt.value === 'remove') {
httpGet('/api/chat/remove?chat_id=' + chat.chat_id).then(() => {
chatList.value = removeArrayItem(chatList.value, chat, function (e1, e2) {
return e1.id === e2.id
})
// 重置会话
newChat();
}).catch(e => {
ElMessage.error("操作失败:" + e.message);
})
const editConfirm = function (chat) {
if (tmpChatTitle.value === '') {
return ElMessage.error("请输入会话标题!");
}
if (!chat.chat_id) {
return ElMessage.error("对话 ID 为空,请刷新页面再试!");
}
if (tmpChatTitle.value === chat.title) {
chat.edit = false;
return
}
}
// 取消修改
const cancel = function (event, chat) {
event.stopPropagation();
chat.edit = false;
chat.removing = false;
}
httpPost('/api/chat/update', {chat_id: chat.chat_id, title: tmpChatTitle.value}).then(() => {
chat.title = tmpChatTitle.value;
chat.edit = false;
}).catch(e => {
ElMessage.error("操作失败:" + e.message);
})
}
// 删除会话
const removeChat = function (event, chat) {
event.stopPropagation();
chat.removing = true;
curOpt.value = 'remove';
const removeChat = function (chat) {
ElMessageBox.confirm(
`该操作会删除"${chat.title}"`,
'删除聊天',
{
confirmButtonText: '删除',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
httpGet('/api/chat/remove?chat_id=' + chat.chat_id).then(() => {
chatList.value = removeArrayItem(chatList.value, chat, function (e1, e2) {
return e1.id === e2.id
})
// 重置会话
newChat();
}).catch(e => {
ElMessage.error("操作失败:" + e.message);
})
})
.catch(() => {
})
}
const latexPlugin = require('markdown-it-latex2img')
@@ -584,8 +549,6 @@ md.use(mathjaxPlugin)
// 创建 socket 连接
const prompt = ref('');
const showStopGenerate = ref(false); // 停止生成
const showReGenerate = ref(false); // 重新生成
const previousText = ref(''); // 上一次提问
const lineBuffer = ref(''); // 输出缓冲行
const socket = ref(null);
const activelyClose = ref(false); // 主动关闭
@@ -630,7 +593,6 @@ const connect = function (chat_id, role_id) {
const _socket = new WebSocket(host + `/api/chat/new?session_id=${_sessionId}&role_id=${role_id}&chat_id=${chat_id}&model_id=${modelID.value}&token=${getUserToken()}`);
_socket.addEventListener('open', () => {
chatData.value = []; // 初始化聊天数据
previousText.value = '';
enableInput()
activelyClose.value = false;
@@ -670,7 +632,7 @@ const connect = function (chat_id, role_id) {
} else if (data.type === 'end') { // 消息接收完毕
// 追加当前会话到会话列表
if (isNewChat && newChatItem.value !== null) {
newChatItem.value['title'] = previousText.value;
newChatItem.value['title'] = tmpChatTitle.value;
newChatItem.value['chat_id'] = chat_id;
chatList.value.unshift(newChatItem.value);
activeChat.value = newChatItem.value;
@@ -735,13 +697,11 @@ const connect = function (chat_id, role_id) {
const disableInput = (force) => {
canSend.value = false;
showReGenerate.value = false;
showStopGenerate.value = !force;
}
const enableInput = () => {
canSend.value = true;
showReGenerate.value = previousText.value !== "";
showStopGenerate.value = false;
}
@@ -766,7 +726,7 @@ const autofillPrompt = (text) => {
// 发送消息
const sendMessage = function () {
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return;
}
@@ -784,7 +744,7 @@ const sendMessage = function () {
id: randString(32),
icon: loginUser.value.avatar,
content: md.render(escapeHTML(processContent(prompt.value))),
created_at: new Date().getTime(),
created_at: new Date().getTime() / 1000,
});
nextTick(() => {
@@ -794,15 +754,11 @@ const sendMessage = function () {
showHello.value = false
disableInput(false)
socket.value.send(JSON.stringify({type: "chat", content: prompt.value}));
previousText.value = prompt.value;
tmpChatTitle.value = prompt.value
prompt.value = '';
return true;
}
const showConfig = function () {
showConfigDialog.value = true;
}
const clearAllChats = function () {
ElMessageBox.confirm(
'确认要清空所有的会话历史记录吗?<br/>此操作不可以撤销!',
@@ -850,6 +806,9 @@ const loadChatHistory = function (chatId) {
for (let i = 0; i < data.length; i++) {
data[i].orgContent = data[i].content;
data[i].content = md.render(processContent(data[i].content))
if (i > 0 && data[i].type === 'reply') {
data[i].prompt = data[i - 1].orgContent
}
chatData.value.push(data[i]);
}
@@ -871,9 +830,9 @@ const stopGenerate = function () {
}
// 重新生成
const reGenerate = function () {
const reGenerate = function (prompt) {
disableInput(false)
const text = '重新生成上述问题的答案:' + previousText.value;
const text = '重新生成下面问题的答案:' + prompt;
// 追加消息
chatData.value.push({
type: "prompt",
@@ -881,32 +840,34 @@ const reGenerate = function () {
icon: loginUser.value.avatar,
content: md.render(text)
});
socket.value.send(JSON.stringify({type: "chat", content: previousText.value}));
socket.value.send(JSON.stringify({type: "chat", content: prompt}));
}
const chatName = ref('')
// 搜索会话
const searchChat = function () {
const searchChat = function (e) {
if (chatName.value === '') {
chatList.value = allChats.value
return
}
const items = [];
for (let i = 0; i < allChats.value.length; i++) {
if (allChats.value[i].title.toLowerCase().indexOf(chatName.value.toLowerCase()) !== -1) {
items.push(allChats.value[i]);
if (e.keyCode === 13) {
const items = [];
for (let i = 0; i < allChats.value.length; i++) {
if (allChats.value[i].title.toLowerCase().indexOf(chatName.value.toLowerCase()) !== -1) {
items.push(allChats.value[i]);
}
}
chatList.value = items;
}
chatList.value = items;
}
// 导出会话
const exportChat = () => {
if (!activeChat.value['chat_id']) {
const shareChat = (chat) => {
if (!chat.chat_id) {
return ElMessage.error("请先选中一个会话")
}
const url = location.protocol + '//' + location.host + '/chat/export?chat_id=' + activeChat.value['chat_id']
const url = location.protocol + '//' + location.host + '/chat/export?chat_id=' + chat.chat_id
// console.log(url)
window.open(url, '_blank');
}
@@ -939,8 +900,58 @@ const insertURL = (url) => {
<style lang="stylus">
.notice-dialog {
.el-dialog__header {
padding-bottom 0
}
.el-dialog__body {
padding 0 20px
ol, ul {
padding-left 10px
}
ol {
list-style decimal-leading-zero
padding-left 20px
}
ul {
list-style disc
}
}
}
.input-container {
.el-textarea {
.el-textarea__inner {
padding-right 40px
}
}
}
.chat-config {
display flex
flex-direction row
padding-top 10px;
.role-select-label {
color #ffffff
}
.el-select {
max-width 150px;
margin-right 10px;
}
.role-select {
max-width 130px;
}
.el-button {
.el-icon {
margin-right 5px;
}
}
}
</style>

View File

@@ -5,7 +5,7 @@
<div class="sd-box">
<h2>DALL-E 创作中心</h2>
<div class="sd-params" :style="{ height: paramBoxHeight + 'px' }">
<div class="sd-params">
<el-form :model="params" label-width="80px" label-position="left">
<div class="param-line" style="padding-top: 10px">
<el-form-item label="图片质量">
@@ -88,7 +88,7 @@
<h2>任务列表</h2>
<div class="running-job-list">
<div class="running-job-box" v-if="runningJobs.length > 0">
<div class="job-item" v-for="item in runningJobs">
<div class="job-item" v-for="item in runningJobs" :key="item.id">
<div v-if="item.progress > 0" class="job-item-inner">
<el-image :src="item['img_url']" fit="cover" loading="lazy">
<template #placeholder>
@@ -221,32 +221,35 @@
</div>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="initData"/>
<el-image-viewer @close="() => { previewURL = '' }" v-if="previewURL !== ''" :url-list="[previewURL]"/>
</div>
</template>
<script setup>
import {onMounted, onUnmounted, ref} from "vue"
import {Delete, InfoFilled} from "@element-plus/icons-vue";
import {Delete, InfoFilled, Picture} from "@element-plus/icons-vue";
import {httpGet, httpPost} from "@/utils/http";
import {ElMessage, ElMessageBox, ElNotification} from "element-plus";
import Clipboard from "clipboard";
import {checkSession} from "@/action/session";
import LoginDialog from "@/components/LoginDialog.vue";
import {useSharedStore} from "@/store/sharedata";
const listBoxHeight = ref(window.innerHeight - 40)
const paramBoxHeight = ref(window.innerHeight - 150)
const showLoginDialog = ref(false)
const listBoxHeight = ref(0)
// const paramBoxHeight = ref(0)
const isLogin = ref(false)
const loading = ref(true)
const colWidth = ref(240)
const colWidth = ref(220)
const isOver = ref(false)
const previewURL = ref("")
const store = useSharedStore();
const resizeElement = function () {
listBoxHeight.value = window.innerHeight - 90
// paramBoxHeight.value = window.innerHeight - 110
};
resizeElement()
window.onresize = () => {
listBoxHeight.value = window.innerHeight - 40
paramBoxHeight.value = window.innerHeight - 150
resizeElement()
}
const qualities = [
{name: "标准", value: "standard"},
@@ -351,8 +354,8 @@ const connect = () => {
const message = String(reader.result)
if (message === "FINISH") {
page.value = 0
fetchFinishJobs(page.value)
isOver.value = false
fetchFinishJobs(page.value)
}
fetchRunningJobs()
}
@@ -434,7 +437,7 @@ const generate = () => {
}
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return
}
httpPost("/api/dall/image", params.value).then(() => {
@@ -458,7 +461,9 @@ const removeImage = (event, item) => {
).then(() => {
httpPost("/api/dall/remove", {id: item.id, img_url: item.img_url, user_id: userId.value}).then(() => {
ElMessage.success("任务删除成功")
fetchFinishJobs(1)
page.value = 0
isOver.value = false
fetchFinishJobs()
}).catch(e => {
ElMessage.error("任务删除失败:" + e.message)
})
@@ -480,6 +485,9 @@ const publishImage = (event, item, action) => {
httpPost("/api/dall/publish", {id: item.id, action: action}).then(() => {
ElMessage.success(text + "成功")
item.publish = action
page.value = 0
isOver.value = false
fetchFinishJobs()
}).catch(e => {
ElMessage.error(text + "失败:" + e.message)
})

View File

@@ -0,0 +1,38 @@
<template>
<div class="page-iframe" v-loading="loading"
style="--el-color-primary:#47fff1"
element-loading-text="页面正在加载中..."
element-loading-background="rgba(122, 122, 122, 0.8)">
<iframe :src="externalUrl" class="iframe" @load="onIframeLoad"></iframe>
</div>
</template>
<script setup>
import {useRouter} from "vue-router";
import {computed, ref} from "vue";
const loading = ref(true)
const router = useRouter()
const externalUrl = computed(() => {
loading.value = true
return router.currentRoute.value.query.url || 'about:blank'
})
const onIframeLoad = () => {
loading.value = false
}
</script>
<style scoped lang="stylus">
.page-iframe {
width 100%
height 100%
overflow hidden
.iframe {
width 100%
height 100%
border none
}
}
</style>

View File

@@ -1,200 +1,225 @@
<template>
<div class="home">
<div class="navigator">
<div class="logo">
<el-image :src="logo" @click="router.push('/')"/>
<div class="divider"></div>
<div class="header">
<div class="banner">
<div class="logo">
<el-image :src="logo" @click="router.push('/')"/>
</div>
<div class="title">
<span>{{ title }}</span>
</div>
</div>
<ul class="nav-items">
<li v-for="item in mainNavs" :key="item.url">
<a @click="changeNav(item)" :class="item.url === curPath ? 'active' : ''">
<el-image :src="item.icon" style="width: 30px;height: 30px"/>
</a>
<div :class="item.url === curPath ? 'title active' : 'title'">{{ item.name }}</div>
</li>
<el-popover
v-if="moreNavs.length > 0"
placement="right-end"
trigger="hover"
>
<template #reference>
<li>
<a class="active">
<el-image src="/images/menu/more.png" style="width: 30px;height: 30px"/>
</a>
</li>
<div class="navbar">
<el-tooltip
class="box-item"
effect="light"
content="部署文档"
placement="bottom">
<a href="https://ai.r9it.com/docs/install/" class="link-button" target="_blank">
<i class="iconfont icon-book"></i>
</a>
</el-tooltip>
<el-tooltip
class="box-item"
effect="light"
content="项目源码"
placement="bottom">
<a href="https://github.com/yangjian102621/chatgpt-plus" class="link-button" target="_blank">
<i class="iconfont icon-github"></i>
</a>
</el-tooltip>
<el-dropdown :hide-on-click="true" class="user-info" trigger="click" v-if="loginUser.id">
<span class="el-dropdown-link">
<el-image :src="loginUser.avatar"/>
</span>
<template #dropdown>
<el-dropdown-menu class="user-info-menu">
<el-dropdown-item @click="showConfigDialog = true">
<el-icon>
<UserFilled/>
</el-icon>
<span class="username">{{ loginUser.nickname }}</span>
</el-dropdown-item>
<el-dropdown-item>
<i class="iconfont icon-book"></i>
<a href="https://github.com/yangjian102621/chatgpt-plus" target="_blank">
用户手册
</a>
</el-dropdown-item>
<el-dropdown-item>
<i class="iconfont icon-github"></i>
<a href="https://ai.r9it.com/docs/" target="_blank">
Geek-AI {{ version }}
</a>
</el-dropdown-item>
<el-divider style="margin: 2px 0"/>
<el-dropdown-item @click="logout">
<i class="iconfont icon-logout"></i>
<span>退出登录</span>
</el-dropdown-item>
</el-dropdown-menu>
</template>
<template #default>
<ul class="more-menus">
<li v-for="item in moreNavs" :key="item.url" :class="item.url === curPath ? 'active' : ''">
<a @click="changeNav(item)">
<el-image :src="item.icon" style="width: 20px;height: 20px"/>
<span :class="item.url === curPath ? 'title active' : 'title'">{{ item.name }}</span>
</el-dropdown>
<div v-else>
<el-button size="small" color="#21aa93" @click="store.setShowLoginDialog(true)" round>登录</el-button>
<el-button size="small" @click="router.push('/register')" round>注册</el-button>
</div>
</div>
</div>
<div class="main">
<div class="navigator">
<ul class="nav-items">
<li v-for="item in mainNavs" :key="item.url">
<el-tooltip
effect="light"
:content="item.name"
placement="right">
<a @click="changeNav(item)" :class="item.url === curPath ? 'active' : ''">
<el-image :src="item.icon" style="width: 30px;height: 30px"/>
</a>
</el-tooltip>
</li>
<el-popover
v-if="moreNavs.length > 0"
placement="right-end"
trigger="hover"
>
<template #reference>
<li>
<a class="active">
<el-image src="/images/menu/more.png" style="width: 30px;height: 30px"/>
</a>
</li>
</ul>
</template>
</el-popover>
</ul>
</div>
<div class="content">
<router-view v-slot="{ Component }">
<transition name="move" mode="out-in">
<component :is="Component"></component>
</transition>
</router-view>
</template>
<template #default>
<ul class="more-menus">
<li v-for="item in moreNavs" :key="item.url" :class="item.url === curPath ? 'active' : ''">
<a @click="changeNav(item)">
<el-image :src="item.icon" style="width: 20px;height: 20px"/>
<span :class="item.url === curPath ? 'title active' : 'title'">{{ item.name }}</span>
</a>
</li>
</ul>
</template>
</el-popover>
</ul>
</div>
<div class="content custom-scroll" :style="{height: mainWinHeight+'px'}">
<router-view :key="routerViewKey" v-slot="{ Component }">
<transition name="move" mode="out-in">
<component :is="Component"></component>
</transition>
</router-view>
</div>
</div>
<login-dialog :show="show" @hide="store.setShowLoginDialog(false)" @success="loginCallback"/>
<config-dialog v-if="loginUser.id" :show="showConfigDialog" @hide="showConfigDialog = false"/>
</div>
</template>
<script setup>
import {useRouter} from "vue-router";
import {onMounted, ref} from "vue";
import {onMounted, ref, watch} from "vue";
import {httpGet} from "@/utils/http";
import {ElMessage} from "element-plus";
import {UserFilled} from "@element-plus/icons-vue";
import {checkSession} from "@/action/session";
import {removeUserToken} from "@/store/session";
import LoginDialog from "@/components/LoginDialog.vue";
import {useSharedStore} from "@/store/sharedata";
import ConfigDialog from "@/components/ConfigDialog.vue";
const router = useRouter();
const logo = ref('/images/logo.png');
const mainNavs = ref([])
const moreNavs = ref([])
const curPath = ref(router.currentRoute.value.path)
const title = ref("")
const mainWinHeight = window.innerHeight - 50
const loginUser = ref({})
const version = ref(process.env.VUE_APP_VERSION)
const routerViewKey = ref(0)
const showConfigDialog = ref(false)
const store = useSharedStore();
const show = ref(false)
watch(() => store.showLoginDialog, (newValue) => {
show.value = newValue
});
if (curPath.value === "/external") {
curPath.value = router.currentRoute.value.query.url
}
const changeNav = (item) => {
curPath.value = item.url
router.push(item.url)
if (item.url.indexOf("http") !== -1) { // 外部链接
router.push({name: 'ExternalLink', query: {url: item.url}})
} else {
router.push(item.url)
}
}
onMounted(() => {
httpGet("/api/config/get?key=system").then(res => {
logo.value = res.data['logo']
logo.value = res.data.logo
title.value = res.data.title
}).catch(e => {
ElMessage.error("获取系统配置失败:" + e.message)
})
// 获取菜单
httpGet("/api/menu/list").then(res => {
mainNavs.value = res.data
if (res.data.length > 7) {
mainNavs.value = res.data.slice(0, 7)
moreNavs.value = res.data.slice(7)
// 根据窗口的高度计算应该显示多少菜单
const rows = Math.floor((window.innerHeight - 90) / 60)
if (res.data.length > rows) {
mainNavs.value = res.data.slice(0, rows)
moreNavs.value = res.data.slice(rows)
}
}).catch(e => {
ElMessage.error("获取系统菜单失败:" + e.message)
})
init()
})
const init = () => {
checkSession().then(user => {
loginUser.value = user
}).catch(() => {
})
}
const logout = function () {
httpGet('/api/user/logout').then(() => {
removeUserToken()
store.setShowLoginDialog(true)
loginUser.value = {}
// 刷新组件
routerViewKey.value += 1
}).catch(() => {
ElMessage.error('注销失败!');
})
}
const loginCallback = () => {
init()
// 刷新组件
routerViewKey.value += 1
}
</script>
<style lang="stylus" scoped>
@import '@/assets/iconfont/iconfont.css';
.home {
display: flex;
height 100vh
width 100%
.navigator {
display flex
flex-flow column
width 60px
padding 10px 6px
border-right: 1px solid #3c3c3c
background-color: #25272D
.logo {
display flex
flex-flow column
align-items center
cursor pointer
.el-image {
width 50px
height 50px
}
.divider {
border-bottom 1px solid #4A4A4A
width 80%
height 10px
}
}
.nav-items {
margin-top: 10px;
padding 0 5px
li {
margin-bottom 15px
a {
color #DADBDC
border-radius 10px
width 48px
height 48px
display flex
justify-content center
align-items center
cursor pointer
.el-image {
border-radius 10px
}
.iconfont {
font-size 20px
}
}
a:hover, a.active {
color #47fff1
background-color #0F7A71
}
.title {
font-size: 12px
padding-top: 5px
color: #e5e7eb;
text-align: center;
}
.active {
color #47fff1
}
}
}
}
.content {
width: 100%
height: 100vh
box-sizing: border-box
background-color #282c34
}
}
.el-popper {
.more-menus {
li {
padding 10px 15px
cursor pointer
border-radius 5px
margin 5px 0
.el-image {
position: relative
top 5px
right 5px
}
&:hover {
background-color #f1f1f1
}
}
li.active {
background-color #f1f1f1
}
}
}
@import "@/assets/css/custom-scroll.styl"
@import "@/assets/css/home.styl"
</style>

View File

@@ -600,8 +600,6 @@
</div>
<el-image-viewer @close="() => { previewURL = '' }" v-if="previewURL !== ''" :url-list="[previewURL]"/>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="initData"/>
</div>
</template>
@@ -616,19 +614,24 @@ import {checkSession} from "@/action/session";
import {useRouter} from "vue-router";
import {getSessionId} from "@/store/session";
import {copyObj, removeArrayItem} from "@/utils/libs";
import LoginDialog from "@/components/LoginDialog.vue";
import {useSharedStore} from "@/store/sharedata";
const listBoxHeight = ref(window.innerHeight - 40)
const paramBoxHeight = ref(window.innerHeight - 150)
const showLoginDialog = ref(false)
const listBoxHeight = ref(0)
const paramBoxHeight = ref(0)
const loading = ref(true)
const colWidth = ref(240)
const colWidth = ref(220)
const previewURL = ref("")
const store = useSharedStore();
const resizeElement = function () {
listBoxHeight.value = window.innerHeight - 80
paramBoxHeight.value = window.innerHeight - 160
};
resizeElement()
window.onresize = () => {
listBoxHeight.value = window.innerHeight - 40
paramBoxHeight.value = window.innerHeight - 150
resizeElement()
}
const rates = [
{css: "square", value: "1:1", text: "1:1", img: "/images/mj/rate_1_1.png"},
{css: "size1-2", value: "1:2", text: "1:2", img: "/images/mj/rate_1_2.png"},
@@ -746,8 +749,8 @@ const connect = () => {
const message = String(reader.result)
if (message === "FINISH") {
page.value = 0
fetchFinishJobs(page.value)
isOver.value = false
fetchFinishJobs(page.value)
}
fetchRunningJobs()
}
@@ -898,7 +901,7 @@ const beforeUpload = (key) => {
// 图片上传
const uploadImg = (file) => {
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return
}
@@ -931,7 +934,7 @@ const uploadImg = (file) => {
const promptRef = ref(null)
const generate = () => {
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return
}
@@ -993,6 +996,9 @@ const removeImage = (item) => {
).then(() => {
httpPost("/api/mj/remove", {id: item.id, img_url: item.img_url, user_id: userId.value}).then(() => {
ElMessage.success("任务删除成功")
page.value = 0
isOver.value = false
fetchFinishJobs()
}).catch(e => {
ElMessage.error("任务删除失败:" + e.message)
})
@@ -1009,6 +1015,9 @@ const publishImage = (item, action) => {
httpPost("/api/mj/publish", {id: item.id, action: action}).then(() => {
ElMessage.success(text + "成功")
item.publish = action
page.value = 0
isOver.value = false
fetchFinishJobs()
}).catch(e => {
ElMessage.error(text + "失败:" + e.message)
})

View File

@@ -5,7 +5,7 @@
<div class="sd-box">
<h2>Stable Diffusion 创作中心</h2>
<div class="sd-params" :style="{ height: paramBoxHeight + 'px' }">
<div class="sd-params">
<el-form :model="params" label-width="80px" label-position="left">
<div class="param-line" style="padding-top: 10px">
<el-form-item label="采样方法">
@@ -497,8 +497,6 @@
</el-dialog>
</div>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="initData"/>
</div>
</template>
@@ -511,21 +509,25 @@ import Clipboard from "clipboard";
import {checkSession} from "@/action/session";
import {useRouter} from "vue-router";
import {getSessionId} from "@/store/session";
import LoginDialog from "@/components/LoginDialog.vue";
import {useSharedStore} from "@/store/sharedata";
const listBoxHeight = ref(window.innerHeight - 40)
const paramBoxHeight = ref(window.innerHeight - 150)
const listBoxHeight = ref(0)
// const paramBoxHeight = ref(0)
const fullImgHeight = ref(window.innerHeight - 60)
const showTaskDialog = ref(false)
const item = ref({})
const showLoginDialog = ref(false)
const isLogin = ref(false)
const loading = ref(true)
const colWidth = ref(240)
const colWidth = ref(220)
const store = useSharedStore();
const resizeElement = function () {
listBoxHeight.value = window.innerHeight - 80
// paramBoxHeight.value = window.innerHeight - 200
};
resizeElement()
window.onresize = () => {
listBoxHeight.value = window.innerHeight - 40
paramBoxHeight.value = window.innerHeight - 150
resizeElement()
}
const samplers = ["Euler a", "DPM++ 2S a", "DPM++ 2M", "DPM++ SDE", "DPM++ 2M SDE", "UniPC", "Restart"]
const schedulers = ["Automatic", "Karras", "Exponential", "Uniform"]
@@ -600,8 +602,8 @@ const connect = () => {
const message = String(reader.result)
if (message === "FINISH") {
page.value = 0
fetchFinishJobs()
isOver.value = false
fetchFinishJobs()
}
fetchRunningJobs()
}
@@ -726,7 +728,7 @@ const generate = () => {
}
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return
}
@@ -765,6 +767,9 @@ const removeImage = (event, item) => {
).then(() => {
httpPost("/api/sd/remove", {id: item.id, img_url: item.img_url, user_id: userId.value}).then(() => {
ElMessage.success("任务删除成功")
page.value = 0
isOver.value = false
fetchFinishJobs()
}).catch(e => {
ElMessage.error("任务删除失败:" + e.message)
})
@@ -782,6 +787,9 @@ const publishImage = (event, item, action) => {
httpPost("/api/sd/publish", {id: item.id, action: action}).then(() => {
ElMessage.success(text + "成功")
item.publish = action
page.value = 0
isOver.value = false
fetchFinishJobs()
}).catch(e => {
ElMessage.error(text + "失败:" + e.message)
})

View File

@@ -310,8 +310,8 @@ const data = ref({
const loading = ref(true)
const isOver = ref(false)
const imgType = ref("mj") // 图片类别
const listBoxHeight = window.innerHeight - 74
const colWidth = ref(240)
const listBoxHeight = window.innerHeight - 124
const colWidth = ref(220)
const fullImgHeight = ref(window.innerHeight - 60)
const showTaskDialog = ref(false)
const item = ref({})
@@ -395,6 +395,7 @@ onUnmounted(() => {
})
const changeImgType = () => {
console.log(imgType.value)
document.getElementById('waterfall-box').scrollTo(0, 0)
page.value = 0
data.value = {

View File

@@ -84,8 +84,6 @@
</div>
</div>
</div>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="initData"/>
</div>
</template>
@@ -97,17 +95,17 @@ import {ElMessage} from "element-plus";
import Clipboard from "clipboard";
import InviteList from "@/components/InviteList.vue";
import {checkSession} from "@/action/session";
import LoginDialog from "@/components/LoginDialog.vue";
import {useSharedStore} from "@/store/sharedata";
const inviteURL = ref("")
const qrImg = ref("")
const qrImg = ref("/images/wx.png")
const inviteChatCalls = ref(0)
const inviteImgCalls = ref(0)
const hits = ref(0)
const regNum = ref(0)
const rate = ref(0)
const isLogin = ref(false)
const showLoginDialog = ref(false)
const store = useSharedStore()
onMounted(() => {
initData()
@@ -152,7 +150,7 @@ const initData = () => {
ElMessage.error("获取系统配置失败:" + e.message)
})
}).catch(() => {
showLoginDialog.value = true
store.setShowLoginDialog(true)
});
}
</script>
@@ -163,7 +161,7 @@ const initData = () => {
display: flex;
justify-content: center;
background-color: #282c34;
height 100vh
height 100%
overflow-x hidden
overflow-y visible
@@ -176,6 +174,7 @@ const initData = () => {
h2 {
color #ffffff;
text-align center
}
.share-box {

View File

@@ -36,8 +36,12 @@
<el-row class="opt" :gutter="20">
<el-col :span="8"><el-link type="primary" @click="router.push('/register')">注册</el-link></el-col>
<el-col :span="8"><el-link @click="showResetPass = true">重置密码</el-link></el-col>
<el-col :span="8"><el-link @click="router.push('/')">首页</el-link></el-col>
<el-col :span="8">
<el-link type="info" @click="showResetPass = true">重置密码</el-link>
</el-col>
<el-col :span="8">
<el-link type="info" @click="router.push('/')">首页</el-link>
</el-col>
</el-row>
</div>
</div>

View File

@@ -2,10 +2,10 @@
<div>
<div class="page-mark-map">
<div class="inner custom-scroll">
<div class="mark-map-box">
<div class="mark-map-box" :style="{ height: leftBoxHeight + 'px' }">
<h2>思维导图创作中心</h2>
<div class="mark-map-params" :style="{ height: leftBoxHeight + 'px' }">
<div class="mark-map-params">
<el-form label-width="80px" label-position="left">
<div class="param-line">
你的需求
@@ -69,9 +69,8 @@
</div>
</div>
<div class="right-box">
<div class="chat-box">
<div class="top-bar">
<h2>思维导图</h2>
<el-button @click="downloadImage" type="primary">
<el-icon>
<Download/>
@@ -91,13 +90,10 @@
</div>
</div>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="initData"/>
</div>
</template>
<script setup>
import LoginDialog from "@/components/LoginDialog.vue";
import {nextTick, onMounted, onUnmounted, ref} from 'vue';
import {Markmap} from 'markmap-view';
import {Transformer} from 'markmap-lib';
@@ -106,9 +102,10 @@ import {httpGet} from "@/utils/http";
import {ElMessage} from "element-plus";
import {Download} from "@element-plus/icons-vue";
import {Toolbar} from 'markmap-toolbar';
import {useSharedStore} from "@/store/sharedata";
const leftBoxHeight = ref(window.innerHeight - 105)
const rightBoxHeight = ref(window.innerHeight - 85)
const rightBoxHeight = ref(window.innerHeight - 115)
const prompt = ref("")
const text = ref(`# Geek-AI 助手
@@ -126,10 +123,10 @@ const md = require('markdown-it')({breaks: true});
const content = ref(text.value)
const html = ref("")
const showLoginDialog = ref(false)
const isLogin = ref(false)
const loginUser = ref({power: 0})
const transformer = new Transformer();
const store = useSharedStore();
const svgRef = ref(null)
@@ -151,21 +148,21 @@ onMounted(() => {
});
const initData = () => {
httpGet("/api/model/list").then(res => {
for (let v of res.data) {
if (v.platform === "OpenAI" && v.value.indexOf("gpt-4-gizmo") === -1) {
models.value.push(v)
}
}
modelID.value = models.value[0].id
}).catch(e => {
ElMessage.error("获取模型失败:" + e.message)
})
checkSession().then(user => {
loginUser.value = user
isLogin.value = true
httpGet("/api/model/list").then(res => {
for (let v of res.data) {
if (v.platform === "OpenAI" && v.value.indexOf("gpt-4-gizmo") === -1) {
models.value.push(v)
}
}
modelID.value = models.value[0].id
connect(user.id)
}).catch(e => {
ElMessage.error("获取模型失败:" + e.message)
})
connect(user.id)
}).catch(() => {
});
}
@@ -206,7 +203,7 @@ window.onresize = () => {
}
const socket = ref(null)
const heartbeatHandle = ref(null)
const heartbeatHandle = ref(0)
const connect = (userId) => {
if (socket.value !== null) {
socket.value.close()
@@ -293,7 +290,7 @@ const generateAI = () => {
return ElMessage.error("请输入你的需求")
}
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return
}
loading.value = true

View File

@@ -1,102 +1,93 @@
<template>
<div>
<div class="member custom-scroll">
<div class="title">
会员充值中心
</div>
<div class="inner" :style="{height: listBoxHeight + 'px'}">
<el-row :gutter="20">
<el-col :span="7">
<div class="user-profile">
<user-profile/>
<div class="inner">
<div class="user-profile">
<user-profile/>
<el-row class="user-opt" :gutter="20">
<el-col :span="12">
<el-button type="primary" @click="showPasswordDialog = true">修改密码</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" @click="showBindMobileDialog = true">更改账号</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" v-if="enableReward" @click="showRewardDialog = true">加入众筹</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" v-if="enableReward" @click="showRewardVerifyDialog = true">众筹核销
</el-button>
</el-col>
<el-row class="user-opt" :gutter="20">
<el-col :span="12">
<el-button type="primary" @click="showPasswordDialog = true">修改密码</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" @click="showBindMobileDialog = true">更改账号</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" v-if="enableReward" @click="showRewardDialog = true">加入众筹</el-button>
</el-col>
<el-col :span="12">
<el-button type="primary" v-if="enableReward" @click="showRewardVerifyDialog = true">众筹核销
</el-button>
</el-col>
<el-col :span="24" style="padding-top: 30px" v-if="isLogin">
<el-button type="danger" round @click="logout">退出登录</el-button>
</el-col>
</el-row>
</div>
</el-col>
<el-col :span="24" style="padding-top: 30px" v-if="isLogin">
<el-button type="danger" round @click="logout">退出登录</el-button>
</el-col>
</el-row>
</div>
<el-col :span="17">
<div class="product-box">
<div class="info" v-if="orderPayInfoText !== ''">
<el-alert type="success" show-icon :closable="false" effect="dark">
<strong>说明:</strong> {{ vipInfoText }}
</el-alert>
</div>
<div class="product-box">
<div class="info" v-if="orderPayInfoText !== ''">
<el-alert type="success" show-icon :closable="false" effect="dark">
<strong>说明:</strong> {{ vipInfoText }}
</el-alert>
</div>
<ItemList :items="list" v-if="list.length > 0" :gap="30" :width="240">
<template #default="scope">
<div class="product-item" :style="{width: scope.width+'px'}">
<div class="image-container">
<el-image :src="vipImg" fit="cover"/>
</div>
<div class="product-title">
<span class="name">{{ scope.item.name }}</span>
</div>
<div class="product-info">
<div class="info-line">
<span class="label">商品原价</span>
<span class="price">{{ scope.item.price }}</span>
</div>
<div class="info-line">
<span class="label">促销立减</span>
<span class="price">{{ scope.item.discount }}</span>
</div>
<div class="info-line">
<span class="label">有效期</span>
<span class="expire" v-if="scope.item.days > 0">{{ scope.item.days }}</span>
<span class="expire" v-else>长期有效</span>
</div>
<div class="info-line">
<span class="label">算力值</span>
<span class="power" v-if="scope.item.power > 0">{{ scope.item.power }}</span>
<span class="power" v-else>{{ vipMonthPower }}</span>
</div>
<div class="pay-way">
<el-button type="primary" @click="alipay(scope.item)" size="small" v-if="payWays['alipay']">
<i class="iconfont icon-alipay"></i> 支付宝
</el-button>
<el-button type="success" @click="huPiPay(scope.item)" size="small" v-if="payWays['hupi']">
<span v-if="payWays['hupi']['name'] === 'wechat'"><i class="iconfont icon-wechat-pay"></i> 微信</span>
<span v-else><i class="iconfont icon-alipay"></i> 支付宝</span>
</el-button>
<el-button type="success" @click="PayJs(scope.item)" size="small" v-if="payWays['payjs']">
<span><i class="iconfont icon-wechat-pay"></i> 微信</span>
</el-button>
</div>
</div>
<ItemList :items="list" v-if="list.length > 0" :gap="15" :width="240">
<template #default="scope">
<div class="product-item">
<div class="image-container">
<el-image :src="vipImg" fit="cover"/>
</div>
<div class="product-title">
<span class="name">{{ scope.item.name }}</span>
</div>
<div class="product-info">
<div class="info-line">
<span class="label">商品原价</span>
<span class="price">{{ scope.item.price }}</span>
</div>
<div class="info-line">
<span class="label">促销立减</span>
<span class="price">{{ scope.item.discount }}</span>
</div>
<div class="info-line">
<span class="label">有效期</span>
<span class="expire" v-if="scope.item.days > 0">{{ scope.item.days }}</span>
<span class="expire" v-else>长期有效</span>
</div>
</template>
</ItemList>
<h2 class="headline">消费账单</h2>
<div class="info-line">
<span class="label">算力值</span>
<span class="power" v-if="scope.item.power > 0">{{ scope.item.power }}</span>
<span class="power" v-else>{{ vipMonthPower }}</span>
</div>
<div class="user-order">
<user-order v-if="isLogin"/>
<div class="pay-way">
<el-button type="primary" @click="alipay(scope.item)" size="small" v-if="payWays['alipay']">
<i class="iconfont icon-alipay"></i> 支付宝
</el-button>
<el-button type="success" @click="huPiPay(scope.item)" size="small" v-if="payWays['hupi']">
<span v-if="payWays['hupi']['name'] === 'wechat'"><i
class="iconfont icon-wechat-pay"></i> 微信</span>
<span v-else><i class="iconfont icon-alipay"></i> 支付宝</span>
</el-button>
<el-button type="success" @click="PayJs(scope.item)" size="small" v-if="payWays['payjs']">
<span><i class="iconfont icon-wechat-pay"></i> 微信</span>
</el-button>
</div>
</div>
</div>
</div>
</el-col>
</el-row>
</template>
</ItemList>
<h2 class="headline">消费账单</h2>
<div class="user-order">
<user-order v-if="isLogin"/>
</div>
</div>
</div>
<password-dialog v-if="isLogin" :show="showPasswordDialog" @hide="showPasswordDialog = false"
@@ -157,7 +148,6 @@
</el-dialog>
</div>
<login-dialog :show="showLoginDialog" @hide="showLoginDialog = false" @success="loginSuccess"/>
</div>
</template>
@@ -167,7 +157,6 @@ import {ElMessage} from "element-plus";
import {httpGet, httpPost} from "@/utils/http";
import ItemList from "@/components/ItemList.vue";
import {InfoFilled, SuccessFilled} from "@element-plus/icons-vue";
import LoginDialog from "@/components/LoginDialog.vue";
import {checkSession} from "@/action/session";
import UserProfile from "@/components/UserProfile.vue";
import PasswordDialog from "@/components/PasswordDialog.vue";
@@ -177,10 +166,9 @@ import {useRouter} from "vue-router";
import {removeUserToken} from "@/store/session";
import UserOrder from "@/components/UserOrder.vue";
import CountDown from "@/components/CountDown.vue";
import {useSharedStore} from "@/store/sharedata";
const listBoxHeight = window.innerHeight - 97
const list = ref([])
const showLoginDialog = ref(false)
const showPayDialog = ref(false)
const vipImg = ref("/images/vip.png")
const enableReward = ref(false) // 是否启用众筹功能
@@ -208,6 +196,7 @@ const amount = ref(0)
const payName = ref("支付宝")
const curPay = ref("alipay") // 当前支付方式
const vipInfoText = ref("")
const store = useSharedStore()
onMounted(() => {
@@ -215,7 +204,7 @@ onMounted(() => {
user.value = _user
isLogin.value = true
}).catch(() => {
showLoginDialog.value = true
store.setShowLoginDialog(true)
})
httpGet("/api/product/list").then((res) => {
@@ -281,7 +270,7 @@ const alipay = (row) => {
curPay.value = "alipay"
amount.value = (row.price - row.discount).toFixed(2)
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return
}
@@ -297,7 +286,7 @@ const huPiPay = (row) => {
curPay.value = "hupi"
amount.value = (row.price - row.discount).toFixed(2)
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return
}
@@ -313,7 +302,7 @@ const PayJs = (row) => {
curPay.value = "payjs"
amount.value = (row.price - row.discount).toFixed(2)
if (!isLogin.value) {
showLoginDialog.value = true
store.setShowLoginDialog(true)
return
}

View File

@@ -1,9 +1,7 @@
<template>
<div class="power-log" v-loading="loading">
<div class="inner">
<h2>消费日志</h2>
<div class="list-box" :style="{height: listBoxHeight + 'px'}">
<div class="power-log custom-scroll" v-loading="loading">
<div class="inner" :style="{height: listBoxHeight + 'px'}">
<div class="list-box">
<div class="handle-box">
<el-input v-model="query.model" placeholder="模型" class="handle-input mr10" clearable></el-input>
<el-date-picker
@@ -13,9 +11,9 @@
end-placeholder="结束日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
style="margin: 0 10px;width: 200px; position: relative;top:3px;"
style="margin: 0 10px;width: 200px;"
/>
<el-button type="primary" :icon="Search" @click="fetchData">搜索</el-button>
<el-button color="#21aa93" :icon="Search" @click="fetchData">搜索</el-button>
</div>
<el-row v-if="items.length > 0">
@@ -73,21 +71,25 @@ import {Search} from "@element-plus/icons-vue";
import Clipboard from "clipboard";
import {ElMessage} from "element-plus";
import {httpPost} from "@/utils/http";
import {checkSession} from "@/action/session";
const items = ref([])
const total = ref(0)
const page = ref(1)
const pageSize = ref(20)
const loading = ref(false)
const listBoxHeight = window.innerHeight - 117
const listBoxHeight = window.innerHeight - 87
const query = ref({
model: "",
date: []
})
const tagColors = ref(["", "success", "", "danger", "info", "warning"])
const tagColors = ref(["primary", "success", "primary", "danger", "info", "warning"])
onMounted(() => {
fetchData()
checkSession().then(() => {
fetchData()
}).catch(() => {
})
const clipboard = new Clipboard('.copy-order-no');
clipboard.on('success', () => {
ElMessage.success("复制成功");
@@ -123,33 +125,12 @@ const fetchData = () => {
</script>
<style lang="stylus" scoped>
@import "@/assets/css/custom-scroll.styl"
.power-log {
color #ffffff
.inner {
padding 0 20px 20px 20px
::-webkit-scrollbar {
width: 8px; /* 滚动条宽度 */
}
/* 修改滚动条轨道的背景颜色 */
::-webkit-scrollbar-track {
background-color: #ffffff;
}
/* 修改滚动条的滑块颜色 */
::-webkit-scrollbar-thumb {
background-color: #cccccc;
border-radius 8px
}
/* 修改滚动条的滑块的悬停颜色 */
::-webkit-scrollbar-thumb:hover {
background-color: #999999;
}
overflow auto
.list-box {
overflow-x hidden

View File

@@ -528,6 +528,10 @@ const onUploadImg = (files, callback) => {
}
}
}
.el-input {
width 100%
}
}
.el-descriptions {