mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-16 06:03:42 +08:00
add 'type' field for ChatModel, support Chat and Image model
This commit is contained in:
@@ -108,6 +108,14 @@ html, body {
|
||||
text-rendering: optimizeLegibility;
|
||||
|
||||
--primary-color: #21aa93
|
||||
|
||||
h1 { font-size: 2em; } /* 通常是 2em */
|
||||
h2 { font-size: 1.5em; } /* 通常是 1.5em */
|
||||
h3 { font-size: 1.17em; } /* 通常是 1.17em */
|
||||
h4 { font-size: 1em; } /* 通常是 1em */
|
||||
h5 { font-size: 0.83em; } /* 通常是 0.83em */
|
||||
h6 { font-size: 0.67em; } /* 通常是 0.67em */
|
||||
|
||||
}
|
||||
|
||||
.el-overlay-dialog {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
.chat-page {
|
||||
height: 100%;
|
||||
::v-deep (.el-message-box__message){
|
||||
:deep (.el-message-box__message){
|
||||
font-size: 18px !important
|
||||
}
|
||||
.newChat{
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
width: 306px;
|
||||
margin-right: 9px;
|
||||
}
|
||||
::v-deep(.el-tabs__item.is-active, .el-tabs__item:hover){
|
||||
:deep(.el-tabs__item.is-active, .el-tabs__item:hover){
|
||||
color: var(--common-text-color) !important;
|
||||
}
|
||||
.el-tabs__item{
|
||||
|
||||
@@ -4,8 +4,13 @@
|
||||
width 100%
|
||||
display flex
|
||||
flex-flow row
|
||||
|
||||
.image-slot {
|
||||
color var(--theme-text-color-primary)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.job-item {
|
||||
margin-right 10px
|
||||
width 200px
|
||||
@@ -31,7 +36,7 @@
|
||||
|
||||
span {
|
||||
font-size 20px
|
||||
color #ffffff
|
||||
color var(--theme-text-color-primary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
--border-active:rgba(255, 255, 255, 0.1);
|
||||
--card-bg:#252d58;
|
||||
--chat-bg:#1f243f
|
||||
--chat-wel-bg:#2d2f388a;
|
||||
--chat-wel-bg:#2d2f38;
|
||||
--card-bg-table: rgba(17, 28, 68, 1);
|
||||
--theme-bg:rgb(13, 20, 53);
|
||||
--theme-bg-color: rgb(13, 20, 53);
|
||||
@@ -76,4 +76,7 @@
|
||||
// 加载动画
|
||||
--el-mask-color: rgba(255, 255, 255, 0.5);
|
||||
--van-toast-background: rgba(255, 255, 255, 0.3);
|
||||
|
||||
--code-bg-color: #424242;
|
||||
--code-text-color: #fff;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
|
||||
// 加载动画
|
||||
--el-mask-color: rgba(100, 100, 100, 0.2);
|
||||
// code 标签背景
|
||||
--code-bg-color: #ececec;
|
||||
--code-text-color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import FooterBar from "@/components/FooterBar.vue";
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
z-index: 1;
|
||||
::v-deep(.foot-container){
|
||||
:deep(.foot-container){
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
width: 100%;
|
||||
|
||||
@@ -17,12 +17,7 @@
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="title">
|
||||
<el-link
|
||||
:href="file.url"
|
||||
target="_blank"
|
||||
style="--el-font-weight-primary: bold"
|
||||
>{{ file.name }}</el-link
|
||||
>
|
||||
<el-link :href="file.url" target="_blank" style="--el-font-weight-primary: bold">{{ file.name }}</el-link>
|
||||
</div>
|
||||
<div class="info">
|
||||
<span>{{ GetFileType(file.ext) }}</span>
|
||||
@@ -35,8 +30,7 @@
|
||||
<div class="content" v-html="content"></div>
|
||||
<div class="bar" v-if="data.created_at > 0">
|
||||
<span class="bar-item"
|
||||
><el-icon><Clock /></el-icon>
|
||||
{{ dateFormat(data.created_at) }}</span
|
||||
><el-icon><Clock /></el-icon> {{ dateFormat(data.created_at) }}</span
|
||||
>
|
||||
<span class="bar-item">tokens: {{ finalTokens }}</span>
|
||||
</div>
|
||||
@@ -62,12 +56,7 @@
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="title">
|
||||
<el-link
|
||||
:href="file.url"
|
||||
target="_blank"
|
||||
style="--el-font-weight-primary: bold"
|
||||
>{{ file.name }}</el-link
|
||||
>
|
||||
<el-link :href="file.url" target="_blank" style="--el-font-weight-primary: bold">{{ file.name }}</el-link>
|
||||
</div>
|
||||
<div class="info">
|
||||
<span>{{ GetFileType(file.ext) }}</span>
|
||||
@@ -82,8 +71,7 @@
|
||||
</div>
|
||||
<div class="bar" v-if="data.created_at > 0">
|
||||
<span class="bar-item"
|
||||
><el-icon><Clock /></el-icon>
|
||||
{{ dateFormat(data.created_at) }}</span
|
||||
><el-icon><Clock /></el-icon> {{ dateFormat(data.created_at) }}</span
|
||||
>
|
||||
<!-- <span class="bar-item">tokens: {{ finalTokens }}</span>-->
|
||||
</div>
|
||||
@@ -99,16 +87,17 @@ import { httpPost } from "@/utils/http";
|
||||
import hl from "highlight.js";
|
||||
import { dateFormat, isImage, processPrompt } from "@/utils/libs";
|
||||
import { FormatFileSize, GetFileIcon, GetFileType } from "@/store/system";
|
||||
import emoji from "markdown-it-emoji";
|
||||
import mathjaxPlugin from "markdown-it-mathjax3";
|
||||
import MarkdownIt from "markdown-it";
|
||||
|
||||
const mathjaxPlugin = require("markdown-it-mathjax3");
|
||||
const md = require("markdown-it")({
|
||||
const md = new MarkdownIt({
|
||||
breaks: true,
|
||||
html: true,
|
||||
linkify: true,
|
||||
typographer: true,
|
||||
highlight: function (str, lang) {
|
||||
const codeIndex =
|
||||
parseInt(Date.now()) + Math.floor(Math.random() * 10000000);
|
||||
const codeIndex = parseInt(Date.now()) + Math.floor(Math.random() * 10000000);
|
||||
// 显示复制代码按钮
|
||||
const copyBtn = `<span class="copy-code-btn" data-clipboard-action="copy" data-clipboard-target="#copy-target-${codeIndex}">复制</span>
|
||||
<textarea style="position: absolute;top: -9999px;left: -9999px;z-index: -9999;" id="copy-target-${codeIndex}">${str.replace(
|
||||
@@ -127,9 +116,10 @@ const md = require("markdown-it")({
|
||||
const preCode = md.utils.escapeHtml(str);
|
||||
// 将代码包裹在 pre 中
|
||||
return `<pre class="code-container"><code class="language-${lang} hljs">${preCode}</code>${copyBtn}</pre>`;
|
||||
}
|
||||
},
|
||||
});
|
||||
md.use(mathjaxPlugin);
|
||||
md.use(emoji);
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
@@ -138,13 +128,13 @@ const props = defineProps({
|
||||
created_at: "",
|
||||
tokens: 0,
|
||||
model: "",
|
||||
icon: ""
|
||||
}
|
||||
icon: "",
|
||||
},
|
||||
},
|
||||
listStyle: {
|
||||
type: String,
|
||||
default: "list"
|
||||
}
|
||||
default: "list",
|
||||
},
|
||||
});
|
||||
const finalTokens = ref(props.data.tokens);
|
||||
const content = ref(processPrompt(props.data.content));
|
||||
|
||||
@@ -6,23 +6,14 @@
|
||||
</div>
|
||||
|
||||
<div class="chat-item">
|
||||
<div
|
||||
class="content"
|
||||
v-html="md.render(processContent(data.content))"
|
||||
></div>
|
||||
<div class="content" v-html="md.render(processContent(data.content))"></div>
|
||||
<div class="bar" v-if="data.created_at">
|
||||
<span class="bar-item"
|
||||
><el-icon><Clock /></el-icon>
|
||||
{{ dateFormat(data.created_at) }}</span
|
||||
><el-icon><Clock /></el-icon> {{ dateFormat(data.created_at) }}</span
|
||||
>
|
||||
<span class="bar-item">tokens: {{ data.tokens }}</span>
|
||||
<span class="bar-item">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
content="复制回答"
|
||||
placement="bottom"
|
||||
>
|
||||
<el-tooltip class="box-item" effect="dark" content="复制回答" placement="bottom">
|
||||
<el-icon class="copy-reply" :data-clipboard-text="data.content">
|
||||
<DocumentCopy />
|
||||
</el-icon>
|
||||
@@ -30,23 +21,13 @@
|
||||
</span>
|
||||
<span v-if="!readOnly">
|
||||
<span class="bar-item" @click="reGenerate(data.prompt)">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
content="重新生成"
|
||||
placement="bottom"
|
||||
>
|
||||
<el-tooltip class="box-item" effect="dark" content="重新生成" placement="bottom">
|
||||
<el-icon><Refresh /></el-icon>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
|
||||
<span class="bar-item" @click="synthesis(data.content)">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
content="生成语音朗读"
|
||||
placement="bottom"
|
||||
>
|
||||
<el-tooltip class="box-item" effect="dark" content="生成语音朗读" placement="bottom">
|
||||
<i class="iconfont icon-speaker"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
@@ -75,24 +56,15 @@
|
||||
</div>
|
||||
<div class="chat-item">
|
||||
<div class="content-wrapper">
|
||||
<div
|
||||
class="content"
|
||||
v-html="md.render(processContent(data.content))"
|
||||
></div>
|
||||
<div class="content" v-html="md.render(processContent(data.content))"></div>
|
||||
</div>
|
||||
<div class="bar" v-if="data.created_at">
|
||||
<span class="bar-item"
|
||||
><el-icon><Clock /></el-icon>
|
||||
{{ dateFormat(data.created_at) }}</span
|
||||
><el-icon><Clock /></el-icon> {{ dateFormat(data.created_at) }}</span
|
||||
>
|
||||
<!-- <span class="bar-item">tokens: {{ data.tokens }}</span>-->
|
||||
<span class="bar-item bg">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
content="复制回答"
|
||||
placement="bottom"
|
||||
>
|
||||
<el-tooltip class="box-item" effect="dark" content="复制回答" placement="bottom">
|
||||
<el-icon class="copy-reply" :data-clipboard-text="data.content">
|
||||
<DocumentCopy />
|
||||
</el-icon>
|
||||
@@ -100,23 +72,13 @@
|
||||
</span>
|
||||
<span v-if="!readOnly">
|
||||
<span class="bar-item bg" @click="reGenerate(data.prompt)">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
content="重新生成"
|
||||
placement="bottom"
|
||||
>
|
||||
<el-tooltip class="box-item" effect="dark" content="重新生成" placement="bottom">
|
||||
<el-icon><Refresh /></el-icon>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
|
||||
<span class="bar-item bg" @click="synthesis(data.content)">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
content="生成语音朗读"
|
||||
placement="bottom"
|
||||
>
|
||||
<el-tooltip class="box-item" effect="dark" content="生成语音朗读" placement="bottom">
|
||||
<i class="iconfont icon-speaker"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
@@ -132,6 +94,10 @@ import { Clock, DocumentCopy, Refresh } from "@element-plus/icons-vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { dateFormat, processContent } from "@/utils/libs";
|
||||
import hl from "highlight.js";
|
||||
import emoji from "markdown-it-emoji";
|
||||
import mathjaxPlugin from "markdown-it-mathjax3";
|
||||
import MarkdownIt from "markdown-it";
|
||||
|
||||
// eslint-disable-next-line no-undef,no-unused-vars
|
||||
const props = defineProps({
|
||||
data: {
|
||||
@@ -140,28 +106,26 @@ const props = defineProps({
|
||||
icon: "",
|
||||
content: "",
|
||||
created_at: "",
|
||||
tokens: 0
|
||||
}
|
||||
tokens: 0,
|
||||
},
|
||||
},
|
||||
readOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
listStyle: {
|
||||
type: String,
|
||||
default: "list"
|
||||
}
|
||||
default: "list",
|
||||
},
|
||||
});
|
||||
|
||||
const mathjaxPlugin = require("markdown-it-mathjax3");
|
||||
const md = require("markdown-it")({
|
||||
const md = new MarkdownIt({
|
||||
breaks: true,
|
||||
html: true,
|
||||
linkify: true,
|
||||
typographer: true,
|
||||
highlight: function (str, lang) {
|
||||
const codeIndex =
|
||||
parseInt(Date.now()) + Math.floor(Math.random() * 10000000);
|
||||
const codeIndex = parseInt(Date.now()) + Math.floor(Math.random() * 10000000);
|
||||
// 显示复制代码按钮
|
||||
const copyBtn = `<span class="copy-code-btn" data-clipboard-action="copy" data-clipboard-target="#copy-target-${codeIndex}">复制</span>
|
||||
<textarea style="position: absolute;top: -9999px;left: -9999px;z-index: -9999;" id="copy-target-${codeIndex}">${str.replace(
|
||||
@@ -171,7 +135,7 @@ const md = require("markdown-it")({
|
||||
if (lang && hl.getLanguage(lang)) {
|
||||
const langHtml = `<span class="lang-name">${lang}</span>`;
|
||||
// 处理代码高亮
|
||||
const preCode = hl.highlight(lang, str, true).value;
|
||||
const preCode = hl.highlight(str, { language: lang }).value;
|
||||
// 将代码包裹在 pre 中
|
||||
return `<pre class="code-container"><code class="language-${lang} hljs">${preCode}</code>${copyBtn} ${langHtml}</pre>`;
|
||||
}
|
||||
@@ -180,10 +144,10 @@ const md = require("markdown-it")({
|
||||
const preCode = md.utils.escapeHtml(str);
|
||||
// 将代码包裹在 pre 中
|
||||
return `<pre class="code-container"><code class="language-${lang} hljs">${preCode}</code>${copyBtn}</pre>`;
|
||||
}
|
||||
},
|
||||
});
|
||||
md.use(mathjaxPlugin);
|
||||
|
||||
md.use(emoji);
|
||||
const emits = defineEmits(["regen"]);
|
||||
|
||||
if (!props.data.icon) {
|
||||
@@ -205,6 +169,9 @@ const reGenerate = (prompt) => {
|
||||
<style lang="stylus">
|
||||
@import '@/assets/css/markdown/vue.css';
|
||||
.chat-page,.chat-export {
|
||||
--font-family: Menlo,"微软雅黑","Roboto Mono","Courier New",Courier,monospace,"Inter",sans-serif;
|
||||
font-family: var(--font-family);
|
||||
|
||||
.chat-line-reply-list {
|
||||
justify-content: center;
|
||||
background-color: var(--chat-list-bg);
|
||||
@@ -255,12 +222,13 @@ const reGenerate = (prompt) => {
|
||||
line-height 1.5
|
||||
|
||||
code {
|
||||
// color:var(--theme-text-color-primary);
|
||||
color:#fff
|
||||
color:var(--theme-text-color-primary);
|
||||
font-weight 600
|
||||
// color:#fff
|
||||
// background-color var(--el-color-primary-light-3)
|
||||
background-color: var(--el-color-primary);
|
||||
padding 3px 5px;
|
||||
border-radius 5px;
|
||||
// background-color: var(--el-color-primary);
|
||||
// padding 3px 5px;
|
||||
// border-radius 5px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,12 +400,12 @@ const reGenerate = (prompt) => {
|
||||
line-height 1.5
|
||||
|
||||
code {
|
||||
color:#fff;
|
||||
background-color var( --el-color-primary)
|
||||
padding 0 3px;
|
||||
border-radius 5px;
|
||||
font-size: 16px;
|
||||
padding: 5px 7px;
|
||||
color:var(--code-text-color);
|
||||
font-weight bold
|
||||
font-family: var(--font-family);
|
||||
background-color: var(--code-bg-color);
|
||||
border-radius: 4px;
|
||||
padding: .2rem .4rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
<template>
|
||||
<div class="running-job-list">
|
||||
<div class="running-job-list pt-4 pb-4">
|
||||
<div class="running-job-box" v-if="list.length > 0">
|
||||
<div class="job-item" v-for="item in list" :key="item.id">
|
||||
<div v-if="item.progress > 0" class="job-item-inner">
|
||||
<div class="progress" v-if="item.progress > 0">
|
||||
<el-progress
|
||||
type="circle"
|
||||
:percentage="item.progress"
|
||||
:width="100"
|
||||
color="#47fff1"
|
||||
/>
|
||||
<el-progress type="circle" :percentage="item.progress" :width="100" color="#47fff1" />
|
||||
</div>
|
||||
</div>
|
||||
<el-image fit="cover" v-else>
|
||||
@@ -33,8 +28,8 @@ import nodata from "@/assets/img/no-data.png";
|
||||
const props = defineProps({
|
||||
list: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
default: [],
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,40 +1,36 @@
|
||||
<template>
|
||||
<div :class="'sidebar '+theme">
|
||||
<div :class="'sidebar ' + theme">
|
||||
<a class="logo w-full" href="/" target="_blank">
|
||||
<el-image :src="logo"/>
|
||||
<el-image :src="logo" />
|
||||
<span class="text" v-show="!sidebar.collapse">{{ title }}</span>
|
||||
</a>
|
||||
|
||||
<el-menu
|
||||
class="sidebar-el-menu"
|
||||
:default-active="onRoutes"
|
||||
:collapse="sidebar.collapse"
|
||||
background-color="#324157"
|
||||
text-color="#bfcbd9"
|
||||
active-text-color="#20a0ff"
|
||||
unique-opened
|
||||
router
|
||||
class="sidebar-el-menu"
|
||||
:default-active="onRoutes"
|
||||
:collapse="sidebar.collapse"
|
||||
background-color="#324157"
|
||||
text-color="#bfcbd9"
|
||||
active-text-color="#20a0ff"
|
||||
unique-opened
|
||||
router
|
||||
>
|
||||
<template v-for="item in items">
|
||||
<template v-if="item.subs">
|
||||
<el-sub-menu :index="item.index" :key="item.index">
|
||||
<template #title>
|
||||
<i :class="'iconfont icon-'+item.icon"></i>
|
||||
<i :class="'iconfont icon-' + item.icon"></i>
|
||||
<span>{{ item.title }}</span>
|
||||
</template>
|
||||
<template v-for="subItem in item.subs">
|
||||
<el-sub-menu
|
||||
v-if="subItem.subs"
|
||||
:index="subItem.index"
|
||||
:key="subItem.index"
|
||||
>
|
||||
<el-sub-menu v-if="subItem.subs" :index="subItem.index" :key="subItem.index">
|
||||
<template #title>{{ subItem.title }}</template>
|
||||
<el-menu-item v-for="(threeItem, i) in subItem.subs" :key="i" :index="threeItem.index">
|
||||
{{ threeItem.title }}
|
||||
</el-menu-item>
|
||||
</el-sub-menu>
|
||||
<el-menu-item v-else :index="subItem.index" :key="subItem.index">
|
||||
<i v-if="subItem.icon" :class="'iconfont icon-'+subItem.icon"></i>
|
||||
<i v-if="subItem.icon" :class="'iconfont icon-' + subItem.icon"></i>
|
||||
{{ subItem.title }}
|
||||
</el-menu-item>
|
||||
</template>
|
||||
@@ -42,7 +38,7 @@
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-menu-item :index="item.index" :key="item.index">
|
||||
<i :class="'iconfont icon-'+item.icon"></i>
|
||||
<i :class="'iconfont icon-' + item.icon"></i>
|
||||
<template #title>{{ item.title }}</template>
|
||||
</el-menu-item>
|
||||
</template>
|
||||
@@ -52,120 +48,125 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {computed, ref, watch} from 'vue';
|
||||
import {setMenuItems, useSidebarStore} from '@/store/sidebar';
|
||||
import {httpGet} from "@/utils/http";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {useRoute} from "vue-router";
|
||||
import {useSharedStore} from "@/store/sharedata";
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { setMenuItems, useSidebarStore } from "@/store/sidebar";
|
||||
import { httpGet } from "@/utils/http";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useRoute } from "vue-router";
|
||||
import { useSharedStore } from "@/store/sharedata";
|
||||
|
||||
const title = ref('')
|
||||
const logo = ref('')
|
||||
const title = ref("");
|
||||
const logo = ref("");
|
||||
|
||||
// 加载系统配置
|
||||
httpGet('/api/admin/config/get?key=system').then(res => {
|
||||
title.value = res.data.admin_title
|
||||
logo.value = res.data.logo
|
||||
}).catch(e => {
|
||||
ElMessage.error("加载系统配置失败: " + e.message)
|
||||
})
|
||||
const store = useSharedStore()
|
||||
const theme = ref(store.theme)
|
||||
watch(() => store.theme, (val) => {
|
||||
theme.value = val
|
||||
})
|
||||
httpGet("/api/admin/config/get?key=system")
|
||||
.then((res) => {
|
||||
title.value = res.data.admin_title;
|
||||
logo.value = res.data.logo;
|
||||
})
|
||||
.catch((e) => {
|
||||
ElMessage.error("加载系统配置失败: " + e.message);
|
||||
});
|
||||
const store = useSharedStore();
|
||||
const theme = ref(store.theme);
|
||||
watch(
|
||||
() => store.theme,
|
||||
(val) => {
|
||||
theme.value = val;
|
||||
}
|
||||
);
|
||||
const items = [
|
||||
{
|
||||
icon: 'home',
|
||||
index: '/admin/dashboard',
|
||||
title: '仪表盘',
|
||||
icon: "home",
|
||||
index: "/admin/dashboard",
|
||||
title: "仪表盘",
|
||||
},
|
||||
|
||||
{
|
||||
icon: 'user-fill',
|
||||
index: '/admin/user',
|
||||
title: '用户管理',
|
||||
icon: "user-fill",
|
||||
index: "/admin/user",
|
||||
title: "用户管理",
|
||||
},
|
||||
{
|
||||
icon: 'menu',
|
||||
index: '1',
|
||||
title: '应用管理',
|
||||
icon: "menu",
|
||||
index: "1",
|
||||
title: "应用管理",
|
||||
subs: [
|
||||
{
|
||||
index: '/admin/app',
|
||||
title: '应用列表',
|
||||
index: "/admin/app",
|
||||
title: "应用列表",
|
||||
},
|
||||
{
|
||||
index: '/admin/app/type',
|
||||
title: '应用分类',
|
||||
index: "/admin/app/type",
|
||||
title: "应用分类",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
icon: 'api-key',
|
||||
index: '/admin/apikey',
|
||||
title: 'API-KEY',
|
||||
icon: "api-key",
|
||||
index: "/admin/apikey",
|
||||
title: "API-KEY",
|
||||
},
|
||||
{
|
||||
icon: 'model',
|
||||
index: '/admin/chat/model',
|
||||
title: '语言模型',
|
||||
icon: "model",
|
||||
index: "/admin/chat/model",
|
||||
title: "模型管理",
|
||||
},
|
||||
{
|
||||
icon: 'recharge',
|
||||
index: '/admin/product',
|
||||
title: '充值产品',
|
||||
icon: "recharge",
|
||||
index: "/admin/product",
|
||||
title: "充值产品",
|
||||
},
|
||||
{
|
||||
icon: 'order',
|
||||
index: '/admin/order',
|
||||
title: '充值订单',
|
||||
icon: "order",
|
||||
index: "/admin/order",
|
||||
title: "充值订单",
|
||||
},
|
||||
{
|
||||
icon: 'reward',
|
||||
index: '/admin/redeem',
|
||||
title: '兑换码',
|
||||
icon: "reward",
|
||||
index: "/admin/redeem",
|
||||
title: "兑换码",
|
||||
},
|
||||
{
|
||||
icon: 'control',
|
||||
index: '/admin/functions',
|
||||
title: '函数管理',
|
||||
icon: "control",
|
||||
index: "/admin/functions",
|
||||
title: "函数管理",
|
||||
},
|
||||
{
|
||||
icon: 'prompt',
|
||||
index: '/admin/chats',
|
||||
title: '对话管理',
|
||||
icon: "prompt",
|
||||
index: "/admin/chats",
|
||||
title: "对话管理",
|
||||
},
|
||||
{
|
||||
icon: 'image',
|
||||
index: '/admin/images',
|
||||
title: '绘图管理',
|
||||
icon: "image",
|
||||
index: "/admin/images",
|
||||
title: "绘图管理",
|
||||
},
|
||||
{
|
||||
icon: 'mp3',
|
||||
index: '/admin/medias',
|
||||
title: '音视频管理',
|
||||
icon: "mp3",
|
||||
index: "/admin/medias",
|
||||
title: "音视频管理",
|
||||
},
|
||||
{
|
||||
icon: 'role',
|
||||
index: '/admin/manger',
|
||||
title: '管理员',
|
||||
icon: "role",
|
||||
index: "/admin/manger",
|
||||
title: "管理员",
|
||||
},
|
||||
{
|
||||
icon: 'config',
|
||||
index: '/admin/system',
|
||||
title: '系统设置',
|
||||
icon: "config",
|
||||
index: "/admin/system",
|
||||
title: "系统设置",
|
||||
},
|
||||
{
|
||||
icon: 'log',
|
||||
index: '/admin/powerLog',
|
||||
title: '用户算力日志',
|
||||
icon: "log",
|
||||
index: "/admin/powerLog",
|
||||
title: "用户算力日志",
|
||||
},
|
||||
{
|
||||
icon: 'log',
|
||||
index: '/admin/loginLog',
|
||||
title: '用户登录日志',
|
||||
icon: "log",
|
||||
index: "/admin/loginLog",
|
||||
title: "用户登录日志",
|
||||
},
|
||||
// {
|
||||
// icon: 'menu',
|
||||
@@ -198,7 +199,7 @@ const onRoutes = computed(() => {
|
||||
});
|
||||
|
||||
const sidebar = useSidebarStore();
|
||||
setMenuItems(items)
|
||||
setMenuItems(items);
|
||||
</script>
|
||||
|
||||
<style scoped lang="stylus">
|
||||
@@ -291,5 +292,4 @@ setMenuItems(items)
|
||||
border-color var(--el-border-color)
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -1,87 +1,90 @@
|
||||
<template>
|
||||
<div class="chat-export" v-loading="loading">
|
||||
<div class="chat-box" id="chat-box">
|
||||
<div class="title">
|
||||
<div class="title pt-4">
|
||||
<h2>{{ chatTitle }}</h2>
|
||||
</div>
|
||||
|
||||
<div v-for="item in chatData" :key="item.id">
|
||||
<chat-prompt v-if="item.type==='prompt'" :data="item" list-style="list"/>
|
||||
<chat-reply v-else-if="item.type==='reply'" :data="item" :read-only="true" list-style="list"/>
|
||||
<chat-prompt v-if="item.type === 'prompt'" :data="item" list-style="list" />
|
||||
<chat-reply v-else-if="item.type === 'reply'" :data="item" :read-only="true" list-style="list" />
|
||||
</div>
|
||||
</div><!-- end chat box -->
|
||||
</div>
|
||||
<!-- end chat box -->
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
|
||||
import ChatReply from "@/components/ChatReply.vue";
|
||||
import ChatPrompt from "@/components/ChatPrompt.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 { 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 { ElMessage } from "element-plus";
|
||||
import Clipboard from "clipboard";
|
||||
|
||||
const chatData = ref([])
|
||||
const router = useRouter()
|
||||
const chatId = router.currentRoute.value.query['chat_id']
|
||||
const loading = ref(true)
|
||||
const chatTitle = ref('')
|
||||
const chatData = ref([]);
|
||||
const router = useRouter();
|
||||
const chatId = router.currentRoute.value.query["chat_id"];
|
||||
const loading = ref(true);
|
||||
const chatTitle = ref("");
|
||||
|
||||
httpGet('/api/chat/history?chat_id=' + chatId).then(res => {
|
||||
const data = res.data
|
||||
if (!data) {
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
const md = require('markdown-it')({breaks: true});
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
if (data[i].type === "prompt") {
|
||||
chatData.value.push(data[i]);
|
||||
continue;
|
||||
} else if (data[i].type === "mj") {
|
||||
data[i].content = JSON.parse(data[i].content)
|
||||
data[i].content.content = md.render(data[i].content?.content)
|
||||
chatData.value.push(data[i]);
|
||||
continue;
|
||||
httpGet("/api/chat/history?chat_id=" + chatId)
|
||||
.then((res) => {
|
||||
const data = res.data;
|
||||
if (!data) {
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
data[i].orgContent = data[i].content;
|
||||
data[i].content = md.render(data[i].content);
|
||||
chatData.value.push(data[i]);
|
||||
}
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
if (data[i].type === "prompt") {
|
||||
chatData.value.push(data[i]);
|
||||
continue;
|
||||
} else if (data[i].type === "mj") {
|
||||
data[i].content = JSON.parse(data[i].content);
|
||||
data[i].content.content = data[i].content?.content;
|
||||
chatData.value.push(data[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
hl.configure({ignoreUnescapedHTML: true})
|
||||
const blocks = document.querySelector("#chat-box").querySelectorAll('pre code');
|
||||
blocks.forEach((block) => {
|
||||
hl.highlightElement(block)
|
||||
})
|
||||
data[i].orgContent = data[i].content;
|
||||
data[i].content = data[i].content;
|
||||
chatData.value.push(data[i]);
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
hl.configure({ ignoreUnescapedHTML: true });
|
||||
const blocks = document.querySelector("#chat-box").querySelectorAll("pre code");
|
||||
blocks.forEach((block) => {
|
||||
hl.highlightElement(block);
|
||||
});
|
||||
});
|
||||
loading.value = false;
|
||||
})
|
||||
loading.value = false
|
||||
}).catch(e => {
|
||||
ElMessage.error('加载聊天记录失败:' + e.message);
|
||||
})
|
||||
.catch((e) => {
|
||||
ElMessage.error("加载聊天记录失败:" + e.message);
|
||||
});
|
||||
|
||||
httpGet('/api/chat/detail?chat_id=' + chatId).then(res => {
|
||||
chatTitle.value = res.data.title
|
||||
}).catch(e => {
|
||||
ElMessage.error("加载会失败: " + e.message)
|
||||
})
|
||||
httpGet("/api/chat/detail?chat_id=" + chatId)
|
||||
.then((res) => {
|
||||
chatTitle.value = res.data.title;
|
||||
})
|
||||
.catch((e) => {
|
||||
ElMessage.error("加载会失败: " + e.message);
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
const clipboard = new Clipboard('.copy-reply');
|
||||
clipboard.on('success', () => {
|
||||
ElMessage.success('复制成功!');
|
||||
})
|
||||
const clipboard = new Clipboard(".copy-reply");
|
||||
clipboard.on("success", () => {
|
||||
ElMessage.success("复制成功!");
|
||||
});
|
||||
|
||||
clipboard.on('error', () => {
|
||||
ElMessage.error('复制失败!');
|
||||
})
|
||||
})
|
||||
clipboard.on("error", () => {
|
||||
ElMessage.error("复制失败!");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style lang="stylus">
|
||||
.chat-export {
|
||||
@@ -113,4 +116,4 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -224,7 +224,7 @@
|
||||
</el-container>
|
||||
|
||||
<el-dialog v-model="showNotice" :show-close="true" class="notice-dialog" title="网站公告">
|
||||
<div class="notice">
|
||||
<div class="notice p-4">
|
||||
<div v-html="notice"></div>
|
||||
</div>
|
||||
|
||||
@@ -262,24 +262,24 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import {nextTick, onMounted, onUnmounted, ref, watch} from "vue";
|
||||
import { nextTick, onMounted, onUnmounted, ref, watch } from "vue";
|
||||
import ChatPrompt from "@/components/ChatPrompt.vue";
|
||||
import ChatReply from "@/components/ChatReply.vue";
|
||||
import {Delete, Edit, InfoFilled, More, Plus, Promotion, Search, Share, VideoPause} from "@element-plus/icons-vue";
|
||||
import { Delete, Edit, InfoFilled, More, Plus, Promotion, Search, Share, VideoPause } from "@element-plus/icons-vue";
|
||||
import "highlight.js/styles/a11y-dark.css";
|
||||
import {isMobile, randString, removeArrayItem, UUID} from "@/utils/libs";
|
||||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
import {httpGet, httpPost} from "@/utils/http";
|
||||
import {useRouter} from "vue-router";
|
||||
import { isMobile, randString, removeArrayItem, UUID } from "@/utils/libs";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { httpGet, httpPost } from "@/utils/http";
|
||||
import { useRouter } from "vue-router";
|
||||
import Clipboard from "clipboard";
|
||||
import {checkSession, getClientId, getSystemInfo} from "@/store/cache";
|
||||
import { checkSession, getClientId, getSystemInfo } from "@/store/cache";
|
||||
import Welcome from "@/components/Welcome.vue";
|
||||
import {useSharedStore} from "@/store/sharedata";
|
||||
import { useSharedStore } from "@/store/sharedata";
|
||||
import FileSelect from "@/components/FileSelect.vue";
|
||||
import FileList from "@/components/FileList.vue";
|
||||
import ChatSetting from "@/components/ChatSetting.vue";
|
||||
import BackTop from "@/components/BackTop.vue";
|
||||
import {closeLoading, showLoading, showMessageError} from "@/utils/dialog";
|
||||
import { closeLoading, showLoading, showMessageError } from "@/utils/dialog";
|
||||
|
||||
const title = ref("GeekAI-智能助手");
|
||||
const models = ref([]);
|
||||
@@ -362,12 +362,15 @@ getSystemInfo()
|
||||
ElMessage.error("获取系统配置失败:" + e.message);
|
||||
});
|
||||
|
||||
const md = require("markdown-it")({
|
||||
import MarkdownIt from "markdown-it";
|
||||
import emoji from "markdown-it-emoji";
|
||||
|
||||
const md = new MarkdownIt({
|
||||
breaks: true,
|
||||
html: true,
|
||||
linkify: true,
|
||||
typographer: true,
|
||||
});
|
||||
}).use(emoji);
|
||||
// 获取系统公告
|
||||
httpGet("/api/config/get?key=notice")
|
||||
.then((res) => {
|
||||
|
||||
@@ -7,7 +7,19 @@
|
||||
|
||||
<div class="sd-params">
|
||||
<el-form :model="params" label-width="80px" label-position="left">
|
||||
<div class="param-line" style="padding-top: 10px">
|
||||
<div class="param-line pt-1">
|
||||
<el-form-item label="生图模型">
|
||||
<template #default>
|
||||
<div class="form-item-inner">
|
||||
<el-select v-model="selectedModel" style="width: 150px" placeholder="请选择模型" @change="changeModel">
|
||||
<el-option v-for="v in models" :label="v.name" :value="v" :key="v.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<div class="param-line">
|
||||
<el-form-item label="图片质量">
|
||||
<template #default>
|
||||
<div class="form-item-inner">
|
||||
@@ -222,7 +234,7 @@ import { checkSession, getClientId, getSystemInfo } from "@/store/cache";
|
||||
import { useSharedStore } from "@/store/sharedata";
|
||||
import TaskList from "@/components/TaskList.vue";
|
||||
import BackTop from "@/components/BackTop.vue";
|
||||
import { showMessageError } from "@/utils/dialog";
|
||||
import { showMessageError, showMessageOK } from "@/utils/dialog";
|
||||
|
||||
const listBoxHeight = ref(0);
|
||||
// const paramBoxHeight = ref(0)
|
||||
@@ -232,6 +244,7 @@ const colWidth = ref(220);
|
||||
const isOver = ref(false);
|
||||
const previewURL = ref("");
|
||||
const store = useSharedStore();
|
||||
const models = ref([]);
|
||||
|
||||
const resizeElement = function () {
|
||||
listBoxHeight.value = window.innerHeight - 58;
|
||||
@@ -245,7 +258,9 @@ const qualities = [
|
||||
{ name: "标准", value: "standard" },
|
||||
{ name: "高清", value: "hd" },
|
||||
];
|
||||
const sizes = ["1024x1024", "1792x1024", "1024x1792"];
|
||||
const dalleSizes = ["1024x1024", "1792x1024", "1024x1792"];
|
||||
const fluxSizes = ["1024x1024", "1024x768", "768x1024", "1280x960", "960x1280", "1366x768", "768x1366"];
|
||||
const sizes = ref(dalleSizes);
|
||||
const styles = [
|
||||
{ name: "生动", value: "vivid" },
|
||||
{ name: "自然", value: "natural" },
|
||||
@@ -264,15 +279,17 @@ const power = ref(0);
|
||||
const dallPower = ref(0); // 画一张 SD 图片消耗算力
|
||||
const clipboard = ref(null);
|
||||
const userId = ref(0);
|
||||
const selectedModel = ref(null);
|
||||
|
||||
onMounted(() => {
|
||||
initData();
|
||||
clipboard.value = new Clipboard(".copy-prompt");
|
||||
clipboard.value.on("success", () => {
|
||||
ElMessage.success("复制成功!");
|
||||
showMessageOK("复制成功!");
|
||||
});
|
||||
|
||||
clipboard.value.on("error", () => {
|
||||
ElMessage.error("复制失败!");
|
||||
showMessageError("复制失败!");
|
||||
});
|
||||
|
||||
getSystemInfo()
|
||||
@@ -280,7 +297,7 @@ onMounted(() => {
|
||||
dallPower.value = res.data["dall_power"];
|
||||
})
|
||||
.catch((e) => {
|
||||
ElMessage.error("获取系统配置失败:" + e.message);
|
||||
showMessageError("获取系统配置失败:" + e.message);
|
||||
});
|
||||
|
||||
store.addMessageHandler("dall", (data) => {
|
||||
@@ -296,6 +313,15 @@ onMounted(() => {
|
||||
}
|
||||
nextTick(() => fetchRunningJobs());
|
||||
});
|
||||
|
||||
// 获取模型列表
|
||||
httpGet("/api/dall/models")
|
||||
.then((res) => {
|
||||
models.value = res.data;
|
||||
})
|
||||
.catch((e) => {
|
||||
showMessageError("获取模型列表失败:" + e.message);
|
||||
});
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
@@ -367,6 +393,9 @@ const fetchFinishJobs = () => {
|
||||
// 创建绘图任务
|
||||
const promptRef = ref(null);
|
||||
const generate = () => {
|
||||
if (!params.value.model_id) {
|
||||
return ElMessage.error("请选择生图模型!");
|
||||
}
|
||||
if (params.value.prompt === "") {
|
||||
promptRef.value.focus();
|
||||
return ElMessage.error("请输入绘画提示词!");
|
||||
@@ -446,6 +475,15 @@ const generatePrompt = () => {
|
||||
isGenerating.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
const changeModel = (model) => {
|
||||
if (model.value.startsWith("dall")) {
|
||||
sizes.value = dalleSizes;
|
||||
} else {
|
||||
sizes.value = fluxSizes;
|
||||
}
|
||||
params.value.model_id = selectedModel.value.id;
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="stylus">
|
||||
|
||||
@@ -10,83 +10,36 @@
|
||||
<el-tab-pane label="手机注册" name="mobile" v-if="enableMobile">
|
||||
<el-form-item>
|
||||
<div class="form-title">手机号码</div>
|
||||
<el-input
|
||||
placeholder="请输入手机号码"
|
||||
size="large"
|
||||
v-model="data.mobile"
|
||||
maxlength="11"
|
||||
autocomplete="off"
|
||||
>
|
||||
</el-input>
|
||||
<el-input placeholder="请输入手机号码" size="large" v-model="data.mobile" maxlength="11" autocomplete="off"> </el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div class="form-title">验证码</div>
|
||||
<div class="flex w100">
|
||||
<el-input
|
||||
placeholder="请输入验证码"
|
||||
size="large"
|
||||
maxlength="30"
|
||||
class="code-input"
|
||||
v-model="data.code"
|
||||
autocomplete="off"
|
||||
>
|
||||
</el-input>
|
||||
<el-input placeholder="请输入验证码" size="large" maxlength="30" class="code-input" v-model="data.code" autocomplete="off"> </el-input>
|
||||
|
||||
<send-msg
|
||||
size="large"
|
||||
:receiver="data.mobile"
|
||||
type="mobile"
|
||||
/>
|
||||
<send-msg size="large" :receiver="data.mobile" type="mobile" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="邮箱注册" name="email" v-if="enableEmail">
|
||||
<el-form-item class="block">
|
||||
<div class="form-title">邮箱</div>
|
||||
<el-input
|
||||
placeholder="请输入邮箱地址"
|
||||
size="large"
|
||||
v-model="data.email"
|
||||
autocomplete="off"
|
||||
>
|
||||
</el-input>
|
||||
<el-input placeholder="请输入邮箱地址" size="large" v-model="data.email" autocomplete="off"> </el-input>
|
||||
</el-form-item>
|
||||
<el-form-item class="block">
|
||||
<div class="form-title">验证码</div>
|
||||
<div class="flex w100">
|
||||
<el-input
|
||||
placeholder="请输入验证码"
|
||||
size="large"
|
||||
maxlength="30"
|
||||
class="code-input"
|
||||
v-model="data.code"
|
||||
autocomplete="off"
|
||||
>
|
||||
</el-input>
|
||||
<el-input placeholder="请输入验证码" size="large" maxlength="30" class="code-input" v-model="data.code" autocomplete="off"> </el-input>
|
||||
|
||||
<send-msg
|
||||
size="large"
|
||||
:receiver="data.email"
|
||||
type="email"
|
||||
/>
|
||||
<send-msg size="large" :receiver="data.email" type="email" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane
|
||||
label="用户名注册"
|
||||
name="username"
|
||||
v-if="enableUser"
|
||||
>
|
||||
<el-tab-pane label="用户名注册" name="username" v-if="enableUser">
|
||||
<el-form-item class="block">
|
||||
<div class="form-title">用户名</div>
|
||||
|
||||
<el-input
|
||||
placeholder="请输入用户名"
|
||||
size="large"
|
||||
v-model="data.username"
|
||||
autocomplete="off"
|
||||
>
|
||||
</el-input>
|
||||
<el-input placeholder="请输入用户名" size="large" v-model="data.username" autocomplete="off"> </el-input>
|
||||
</el-form-item>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@@ -94,52 +47,24 @@
|
||||
<el-form-item class="block">
|
||||
<div class="form-title">密码</div>
|
||||
|
||||
<el-input
|
||||
placeholder="请输入密码(8-16位)"
|
||||
maxlength="16"
|
||||
size="large"
|
||||
v-model="data.password"
|
||||
show-password
|
||||
autocomplete="off"
|
||||
>
|
||||
</el-input>
|
||||
<el-input placeholder="请输入密码(8-16位)" maxlength="16" size="large" v-model="data.password" show-password autocomplete="off"> </el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item class="block">
|
||||
<div class="form-title">重复密码</div>
|
||||
|
||||
<el-input
|
||||
placeholder="请再次输入密码(8-16位)"
|
||||
size="large"
|
||||
maxlength="16"
|
||||
v-model="data.repass"
|
||||
show-password
|
||||
autocomplete="off"
|
||||
>
|
||||
</el-input>
|
||||
<el-input placeholder="请再次输入密码(8-16位)" size="large" maxlength="16" v-model="data.repass" show-password autocomplete="off"> </el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item class="block">
|
||||
<div class="form-title">邀请码</div>
|
||||
|
||||
<el-input
|
||||
placeholder="请输入邀请码(可选)"
|
||||
size="large"
|
||||
v-model="data.invite_code"
|
||||
autocomplete="off"
|
||||
>
|
||||
</el-input>
|
||||
<el-input placeholder="请输入邀请码(可选)" size="large" v-model="data.invite_code" autocomplete="off"> </el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-row class="btn-row" :gutter="20">
|
||||
<el-col :span="24">
|
||||
<el-button
|
||||
class="login-btn"
|
||||
type="primary"
|
||||
size="large"
|
||||
@click="submitRegister"
|
||||
>注册</el-button
|
||||
>
|
||||
<el-button class="login-btn" type="primary" size="large" @click="submitRegister">注册</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
@@ -156,11 +81,7 @@
|
||||
</template>
|
||||
</el-result>
|
||||
</div>
|
||||
<captcha
|
||||
v-if="enableVerify"
|
||||
@success="doSubmitRegister"
|
||||
ref="captchaRef"
|
||||
/>
|
||||
<captcha v-if="enableVerify" @success="doSubmitRegister" ref="captchaRef" />
|
||||
<account-bg />
|
||||
</div>
|
||||
</div>
|
||||
@@ -193,7 +114,7 @@ const data = ref({
|
||||
password: "",
|
||||
code: "",
|
||||
repass: "",
|
||||
invite_code: router.currentRoute.value.query["invite_code"]
|
||||
invite_code: router.currentRoute.value.query["invite_code"],
|
||||
});
|
||||
|
||||
const enableMobile = ref(false);
|
||||
@@ -272,10 +193,7 @@ const submitRegister = () => {
|
||||
return showMessageError("两次输入密码不一致");
|
||||
}
|
||||
|
||||
if (
|
||||
(activeName.value === "mobile" || activeName.value === "email") &&
|
||||
data.value.code === ""
|
||||
) {
|
||||
if ((activeName.value === "mobile" || activeName.value === "email") && data.value.code === "") {
|
||||
return showMessageError("请输入验证码");
|
||||
}
|
||||
|
||||
@@ -310,11 +228,11 @@ const doSubmitRegister = (verifyData) => {
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import "@/assets/css/login.styl"
|
||||
::v-deep(.back){
|
||||
:deep(.back){
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
::v-deep(.orline){
|
||||
:deep(.orline){
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.wechat-card {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<el-button :icon="Search" @click="fetchData">搜索</el-button>
|
||||
<el-button type="primary" :icon="Plus" @click="add">新增</el-button>
|
||||
<a href="https://api.chat-plus.net" target="_blank" style="margin-left: 10px">
|
||||
<a href="https://api.geekai.pro" target="_blank" style="margin-left: 10px">
|
||||
<el-button type="success" :icon="ShoppingCart" @click="add" plain>购买API-KEY</el-button>
|
||||
</a>
|
||||
</div>
|
||||
@@ -66,10 +66,21 @@
|
||||
<el-dialog v-model="showDialog" :close-on-click-modal="false" :title="title">
|
||||
<el-form :model="item" label-width="120px" ref="formRef" :rules="rules">
|
||||
<el-form-item label="名称:" prop="name">
|
||||
<el-input v-model="item.name" autocomplete="off" />
|
||||
<template #default>
|
||||
<el-row :gutter="10" class="w-full">
|
||||
<el-col :span="12">
|
||||
<el-input v-model="item.name" autocomplete="off" />
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-select v-model="preset" placeholder="请选择预设" @change="changePreset">
|
||||
<el-option v-for="item in presets" :value="item" :label="item.label" :key="item.value">{{ item.label }} </el-option>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型:" prop="type">
|
||||
<el-select v-model="item.type" placeholder="请选择类型" @change="changeType">
|
||||
<el-select v-model="item.type" placeholder="请选择类型">
|
||||
<el-option v-for="item in types" :value="item.value" :label="item.label" :key="item.value">{{ item.label }} </el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -111,10 +122,7 @@ import ClipboardJS from "clipboard";
|
||||
// 变量定义
|
||||
const items = ref([]);
|
||||
const query = ref({ type: "" });
|
||||
const item = ref({
|
||||
enabled: true,
|
||||
api_url: "",
|
||||
});
|
||||
const item = ref({});
|
||||
const showDialog = ref(false);
|
||||
const rules = reactive({
|
||||
name: [{ required: true, message: "请输入名称", trigger: "change" }],
|
||||
@@ -136,6 +144,14 @@ const types = ref([
|
||||
]);
|
||||
const isEdit = ref(false);
|
||||
const clipboard = ref(null);
|
||||
const presets = ref([
|
||||
{ label: "GiteeAI", value: "https://ai.gitee.com" },
|
||||
{ label: "中转01", value: "https://api.geekai.pro" },
|
||||
{ label: "中转03", value: "https://api.geekai.me" },
|
||||
{ label: "OpenAI", value: "https://api.openai.com" },
|
||||
]);
|
||||
const preset = ref(null);
|
||||
|
||||
onMounted(() => {
|
||||
clipboard.value = new ClipboardJS(".copy-key");
|
||||
clipboard.value.on("success", () => {
|
||||
@@ -153,18 +169,6 @@ onUnmounted(() => {
|
||||
clipboard.value.destroy();
|
||||
});
|
||||
|
||||
const changeType = (event) => {
|
||||
if (isEdit.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event === "realtime") {
|
||||
item.value.api_url = "wss://api.geekai.pro";
|
||||
} else {
|
||||
item.value.api_url = "https://api.geekai.pro";
|
||||
}
|
||||
};
|
||||
|
||||
const getTypeName = (type) => {
|
||||
for (let v of types.value) {
|
||||
if (v.value === type) {
|
||||
@@ -175,7 +179,6 @@ const getTypeName = (type) => {
|
||||
};
|
||||
|
||||
// 获取数据
|
||||
|
||||
const fetchData = () => {
|
||||
httpGet("/api/admin/apikey/list", query.value)
|
||||
.then((res) => {
|
||||
@@ -198,6 +201,10 @@ const add = function () {
|
||||
showDialog.value = true;
|
||||
title.value = "新增 API KEY";
|
||||
isEdit.value = false;
|
||||
item.value = {
|
||||
enabled: true,
|
||||
api_url: "",
|
||||
};
|
||||
};
|
||||
|
||||
const edit = function (row) {
|
||||
@@ -251,6 +258,13 @@ const set = (filed, row) => {
|
||||
ElMessage.error("操作失败:" + e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const changePreset = (row) => {
|
||||
item.value.api_url = row.value;
|
||||
if (!item.value.name) {
|
||||
item.value.name = row.label;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div class="container model-list" v-loading="loading">
|
||||
|
||||
<div class="handle-box">
|
||||
<el-input v-model="query.name" placeholder="模型名称" class="handle-input" />
|
||||
|
||||
@@ -9,7 +8,7 @@
|
||||
</div>
|
||||
|
||||
<el-row>
|
||||
<el-table :data="items" :row-key="row => row.id" table-layout="auto">
|
||||
<el-table :data="items" :row-key="(row) => row.id" table-layout="auto">
|
||||
<el-table-column type="selection" width="38"></el-table-column>
|
||||
<el-table-column prop="name" label="模型名称">
|
||||
<template #default="scope">
|
||||
@@ -19,30 +18,36 @@
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="type" label="模型类型">
|
||||
<template #default="scope">
|
||||
<el-tag type="primary" v-if="scope.row.type === 'img'">绘图</el-tag>
|
||||
<el-tag type="success" v-else>聊天</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="value" label="模型值">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.value }}</span>
|
||||
<el-icon class="copy-model" :data-clipboard-text="scope.row.value">
|
||||
<DocumentCopy/>
|
||||
<DocumentCopy />
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="power" label="费率"/>
|
||||
<el-table-column prop="max_tokens" label="最大响应长度"/>
|
||||
<el-table-column prop="max_context" label="最大上下文长度"/>
|
||||
<el-table-column prop="temperature" label="创意度"/>
|
||||
<el-table-column prop="power" label="费率" />
|
||||
<el-table-column prop="max_tokens" label="最大响应长度" />
|
||||
<el-table-column prop="max_context" label="最大上下文长度" />
|
||||
<el-table-column prop="temperature" label="创意度" />
|
||||
<el-table-column prop="enabled" label="启用状态">
|
||||
<template #default="scope">
|
||||
<el-switch v-model="scope.row['enabled']" @change="modelSet('enabled',scope.row)"/>
|
||||
<el-switch v-model="scope.row['enabled']" @change="modelSet('enabled', scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="enabled" label="开放状态">
|
||||
<template #default="scope">
|
||||
<el-switch v-model="scope.row['open']" @change="modelSet('open',scope.row)"/>
|
||||
<el-switch v-model="scope.row['open']" @change="modelSet('open', scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="key_name" label="绑定API-KEY"/>
|
||||
<el-table-column prop="key_name" label="绑定API-KEY" />
|
||||
<el-table-column label="操作" width="180">
|
||||
<template #default="scope">
|
||||
<el-button size="small" type="primary" @click="edit(scope.row)">编辑</el-button>
|
||||
@@ -56,81 +61,70 @@
|
||||
</el-table>
|
||||
</el-row>
|
||||
|
||||
<el-dialog
|
||||
v-model="showDialog"
|
||||
:title="title"
|
||||
:close-on-click-modal="false"
|
||||
style="width: 90%; max-width: 600px;"
|
||||
>
|
||||
<el-dialog v-model="showDialog" :title="title" :close-on-click-modal="false" style="width: 90%; max-width: 600px">
|
||||
<el-form :model="item" label-width="120px" ref="formRef" :rules="rules">
|
||||
<el-form-item label="模型类型:" prop="type">
|
||||
<el-select v-model="item.type" placeholder="请选择模型类型">
|
||||
<el-option v-for="v in type" :value="v.value" :label="v.label" :key="v.value">
|
||||
{{ v.label }}
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="模型名称:" prop="name">
|
||||
<el-input v-model="item.name" autocomplete="off"/>
|
||||
<el-input v-model="item.name" autocomplete="off" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="模型值:" prop="value">
|
||||
<el-input v-model="item.value" autocomplete="off"/>
|
||||
<el-input v-model="item.value" autocomplete="off" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="消耗算力:" prop="weight">
|
||||
<template #default>
|
||||
<div class="tip-input">
|
||||
<el-input-number :min="0" v-model="item.power" autocomplete="off"/>
|
||||
<div class="info">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
content="每次对话扣减多少单位算力"
|
||||
placement="right"
|
||||
>
|
||||
<el-form-item label="消耗算力:" prop="power">
|
||||
<template #label>
|
||||
<div class="flex items-center">
|
||||
<span class="mr-1">消耗算力</span>
|
||||
<el-tooltip effect="dark" content="每日签到赠送算力" raw-content placement="right">
|
||||
<el-icon>
|
||||
<InfoFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<el-input v-model.number="item.power" autocomplete="off" placeholder="消耗算力" />
|
||||
</el-form-item>
|
||||
|
||||
<div v-if="item.type === 'chat'">
|
||||
<el-form-item label="最长响应:" prop="max_tokens">
|
||||
<el-input v-model.number="item.max_tokens" autocomplete="off" placeholder="模型最大响应长度" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<div class="flex items-center">
|
||||
<span class="mr-1">最大上下文</span>
|
||||
<el-tooltip effect="dark" content="去各大模型的官方 API 文档查询模型支持的最大上下文长度" raw-content placement="right">
|
||||
<el-icon>
|
||||
<InfoFilled/>
|
||||
<InfoFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-input v-model.number="item.max_context" autocomplete="off" placeholder="模型最大上下文长度" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="最长响应:" prop="max_tokens">
|
||||
<el-input v-model.number="item.max_tokens" autocomplete="off" placeholder="模型最大响应长度"/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="最大上下文:" prop="max_context">
|
||||
<div class="tip-input">
|
||||
<el-input v-model.number="item.max_context" autocomplete="off" placeholder="模型最大上下文长度"/>
|
||||
<div class="info">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
raw-content
|
||||
content="去各大模型的官方 API 文档查询模型支持的最大上下文长度"
|
||||
placement="right"
|
||||
>
|
||||
<el-icon>
|
||||
<InfoFilled/>
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="创意度:" prop="temperature">
|
||||
<div class="tip-input">
|
||||
<el-input v-model="item.temperature" autocomplete="off" placeholder="模型创意度"/>
|
||||
<div class="info">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
content="OpenAI 0-2,其他模型 0-1"
|
||||
placement="right"
|
||||
>
|
||||
<el-icon>
|
||||
<InfoFilled/>
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="创意度:" prop="temperature">
|
||||
<template #label>
|
||||
<div class="flex items-center">
|
||||
<span class="mr-1">创意度</span>
|
||||
<el-tooltip effect="dark" content="OpenAI 0-2,其他模型 0-1" raw-content placement="right">
|
||||
<el-icon>
|
||||
<InfoFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<el-input v-model="item.temperature" autocomplete="off" placeholder="模型创意度" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<el-form-item label="绑定API-KEY:" prop="apikey">
|
||||
<el-select v-model="item.key_id" placeholder="请选择 API KEY" filterable clearable>
|
||||
@@ -142,181 +136,193 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="启用状态:" prop="enable">
|
||||
<el-switch v-model="item.enabled"/>
|
||||
<el-switch v-model="item.enabled" />
|
||||
</el-form-item>
|
||||
<el-form-item label="开放状态:" prop="open">
|
||||
<div class="tip-input">
|
||||
<el-switch v-model="item.open"/>
|
||||
<div class="info">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
raw-content
|
||||
content="开放后,该模型将对所有用户可见。<br/> 如果模型没有启用,则当前设置无效。"
|
||||
placement="right"
|
||||
>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<div class="flex items-center">
|
||||
<span class="mr-1">开放状态</span>
|
||||
<el-tooltip effect="dark" content="开放后,该模型将对所有用户可见。<br/> 如果模型没有启用,则当前设置无效。" raw-content placement="right">
|
||||
<el-icon>
|
||||
<InfoFilled/>
|
||||
<InfoFilled />
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<el-switch v-model="item.open" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="showDialog = false">取消</el-button>
|
||||
<el-button type="primary" @click="save">提交</el-button>
|
||||
</span>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="showDialog = false">取消</el-button>
|
||||
<el-button type="primary" @click="save">提交</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {onMounted, onUnmounted, reactive, ref} from "vue";
|
||||
import {httpGet, httpPost} from "@/utils/http";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {dateFormat, removeArrayItem, substr} from "@/utils/libs";
|
||||
import {DocumentCopy, InfoFilled, Plus,Search} from "@element-plus/icons-vue";
|
||||
import {Sortable} from "sortablejs";
|
||||
import { onMounted, onUnmounted, reactive, ref } from "vue";
|
||||
import { httpGet, httpPost } from "@/utils/http";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { dateFormat, removeArrayItem, substr } from "@/utils/libs";
|
||||
import { DocumentCopy, InfoFilled, Plus, Search } from "@element-plus/icons-vue";
|
||||
import { Sortable } from "sortablejs";
|
||||
import ClipboardJS from "clipboard";
|
||||
import Default from "md-editor-v3";
|
||||
|
||||
// 变量定义
|
||||
const items = ref([])
|
||||
const query = ref({name:''})
|
||||
const item = ref({})
|
||||
const showDialog = ref(false)
|
||||
const title = ref("")
|
||||
const items = ref([]);
|
||||
const query = ref({ name: "" });
|
||||
const item = ref({});
|
||||
const showDialog = ref(false);
|
||||
const title = ref("");
|
||||
const rules = reactive({
|
||||
name: [{required: true, message: '请输入模型名称', trigger: 'change',}],
|
||||
value: [{required: true, message: '请输入模型值', trigger: 'change',}]
|
||||
})
|
||||
const loading = ref(true)
|
||||
const formRef = ref(null)
|
||||
type: [{ required: true, message: "请选择模型类型", trigger: "change" }],
|
||||
name: [{ required: true, message: "请输入模型名称", trigger: "change" }],
|
||||
value: [{ required: true, message: "请输入模型值", trigger: "change" }],
|
||||
power: [{ required: true, message: "请输入消耗算力", trigger: "change" }],
|
||||
});
|
||||
const loading = ref(true);
|
||||
const formRef = ref(null);
|
||||
const type = ref([
|
||||
{ label: "聊天", value: "chat" },
|
||||
{ label: "绘图", value: "img" },
|
||||
]);
|
||||
|
||||
// 获取 API KEY
|
||||
const apiKeys = ref([])
|
||||
httpGet('/api/admin/apikey/list?type=chat').then(res => {
|
||||
apiKeys.value = res.data
|
||||
}).catch(e => {
|
||||
ElMessage.error("获取 API KEY 失败:" + e.message)
|
||||
})
|
||||
const apiKeys = ref([]);
|
||||
httpGet("/api/admin/apikey/list?type=chat")
|
||||
.then((res) => {
|
||||
apiKeys.value = res.data;
|
||||
})
|
||||
.catch((e) => {
|
||||
ElMessage.error("获取 API KEY 失败:" + e.message);
|
||||
});
|
||||
|
||||
// 获取数据
|
||||
const fetchData = () => {
|
||||
httpGet('/api/admin/model/list', query.value).then((res) => {
|
||||
if (res.data) {
|
||||
// 初始化数据
|
||||
const arr = res.data;
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
arr[i].last_used_at = dateFormat(arr[i].last_used_at)
|
||||
httpGet("/api/admin/model/list", query.value)
|
||||
.then((res) => {
|
||||
if (res.data) {
|
||||
// 初始化数据
|
||||
const arr = res.data;
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
arr[i].last_used_at = dateFormat(arr[i].last_used_at);
|
||||
}
|
||||
items.value = arr;
|
||||
}
|
||||
items.value = arr
|
||||
}
|
||||
loading.value = false
|
||||
}).catch(() => {
|
||||
ElMessage.error("获取数据失败");
|
||||
})
|
||||
}
|
||||
loading.value = false;
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error("获取数据失败");
|
||||
});
|
||||
};
|
||||
|
||||
const clipboard = ref(null)
|
||||
const clipboard = ref(null);
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
const drawBodyWrapper = document.querySelector('.el-table__body tbody')
|
||||
fetchData();
|
||||
const drawBodyWrapper = document.querySelector(".el-table__body tbody");
|
||||
|
||||
// 初始化拖动排序插件
|
||||
Sortable.create(drawBodyWrapper, {
|
||||
sort: true,
|
||||
animation: 500,
|
||||
onEnd({newIndex, oldIndex, from}) {
|
||||
onEnd({ newIndex, oldIndex, from }) {
|
||||
if (oldIndex === newIndex) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
const sortedData = Array.from(from.children).map(row => row.querySelector('.sort').getAttribute('data-id'));
|
||||
const ids = []
|
||||
const sorts = []
|
||||
const sortedData = Array.from(from.children).map((row) => row.querySelector(".sort").getAttribute("data-id"));
|
||||
const ids = [];
|
||||
const sorts = [];
|
||||
sortedData.forEach((id, index) => {
|
||||
ids.push(parseInt(id))
|
||||
sorts.push(index + 1)
|
||||
items.value[index].sort_num = index + 1
|
||||
})
|
||||
ids.push(parseInt(id));
|
||||
sorts.push(index + 1);
|
||||
items.value[index].sort_num = index + 1;
|
||||
});
|
||||
|
||||
httpPost("/api/admin/model/sort", {ids: ids, sorts: sorts}).then(() => {
|
||||
}).catch(e => {
|
||||
ElMessage.error("排序失败:" + e.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
httpPost("/api/admin/model/sort", { ids: ids, sorts: sorts })
|
||||
.then(() => {})
|
||||
.catch((e) => {
|
||||
ElMessage.error("排序失败:" + e.message);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
clipboard.value = new ClipboardJS('.copy-model');
|
||||
clipboard.value.on('success', () => {
|
||||
ElMessage.success('复制成功!');
|
||||
})
|
||||
clipboard.value = new ClipboardJS(".copy-model");
|
||||
clipboard.value.on("success", () => {
|
||||
ElMessage.success("复制成功!");
|
||||
});
|
||||
|
||||
clipboard.value.on('error', () => {
|
||||
ElMessage.error('复制失败!');
|
||||
})
|
||||
})
|
||||
clipboard.value.on("error", () => {
|
||||
ElMessage.error("复制失败!");
|
||||
});
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
clipboard.value.destroy()
|
||||
})
|
||||
clipboard.value.destroy();
|
||||
});
|
||||
|
||||
const add = function () {
|
||||
title.value = "新增模型"
|
||||
showDialog.value = true
|
||||
item.value = {enabled: true, power: 1, open: true,max_tokens: 1024,max_context: 8192, temperature: 0.9,}
|
||||
}
|
||||
title.value = "新增模型";
|
||||
showDialog.value = true;
|
||||
item.value = { enabled: true, power: 1, open: true, max_tokens: 1024, max_context: 8192, temperature: 0.9 };
|
||||
};
|
||||
|
||||
const edit = function (row) {
|
||||
title.value = "修改模型"
|
||||
showDialog.value = true
|
||||
item.value = row
|
||||
}
|
||||
title.value = "修改模型";
|
||||
showDialog.value = true;
|
||||
item.value = row;
|
||||
};
|
||||
|
||||
const save = function () {
|
||||
formRef.value.validate((valid) => {
|
||||
item.value.temperature = parseFloat(item.value.temperature)
|
||||
item.value.temperature = parseFloat(item.value.temperature);
|
||||
if (!item.value.sort_num) {
|
||||
item.value.sort_num = items.value.length
|
||||
item.value.sort_num = items.value.length;
|
||||
}
|
||||
if (valid) {
|
||||
showDialog.value = false
|
||||
item.value.key_id = parseInt(item.value.key_id)
|
||||
httpPost('/api/admin/model/save', item.value).then(() => {
|
||||
ElMessage.success('操作成功!')
|
||||
fetchData()
|
||||
}).catch((e) => {
|
||||
ElMessage.error('操作失败,' + e.message)
|
||||
})
|
||||
showDialog.value = false;
|
||||
item.value.key_id = parseInt(item.value.key_id);
|
||||
httpPost("/api/admin/model/save", item.value)
|
||||
.then(() => {
|
||||
ElMessage.success("操作成功!");
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
ElMessage.error("操作失败," + e.message);
|
||||
});
|
||||
} else {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const modelSet = (filed, row) => {
|
||||
httpPost('/api/admin/model/set', {id: row.id, filed: filed, value: row[filed]}).then(() => {
|
||||
ElMessage.success("操作成功!")
|
||||
}).catch(e => {
|
||||
ElMessage.error("操作失败:" + e.message)
|
||||
})
|
||||
}
|
||||
httpPost("/api/admin/model/set", { id: row.id, filed: filed, value: row[filed] })
|
||||
.then(() => {
|
||||
ElMessage.success("操作成功!");
|
||||
})
|
||||
.catch((e) => {
|
||||
ElMessage.error("操作失败:" + e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const remove = function (row) {
|
||||
httpGet('/api/admin/model/remove?id=' + row.id).then(() => {
|
||||
ElMessage.success("删除成功!")
|
||||
items.value = removeArrayItem(items.value, row, (v1, v2) => {
|
||||
return v1.id === v2.id
|
||||
httpGet("/api/admin/model/remove?id=" + row.id)
|
||||
.then(() => {
|
||||
ElMessage.success("删除成功!");
|
||||
items.value = removeArrayItem(items.value, row, (v1, v2) => {
|
||||
return v1.id === v2.id;
|
||||
});
|
||||
})
|
||||
}).catch((e) => {
|
||||
ElMessage.error("删除失败:" + e.message)
|
||||
})
|
||||
}
|
||||
.catch((e) => {
|
||||
ElMessage.error("删除失败:" + e.message);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@@ -357,4 +363,4 @@ const remove = function (row) {
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -203,12 +203,18 @@
|
||||
<el-form-item label="VIP每月赠送算力" prop="vip_month_power">
|
||||
<el-input v-model.number="system['vip_month_power']" placeholder="VIP用户每月赠送算力" />
|
||||
</el-form-item>
|
||||
<el-form-item label="每日赠送算力" prop="daily_power">
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<div class="label-title">
|
||||
签到赠送算力
|
||||
<el-tooltip effect="dark" content="每日签到赠送算力" raw-content placement="right">
|
||||
<el-icon>
|
||||
<InfoFilled/>
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<el-input v-model.number="system['daily_power']" placeholder="默认值0" />
|
||||
|
||||
<el-text type="info">
|
||||
如果设置0表示不赠送,用户享受完免费算力额度之后就不能再发起对话了。如果设置为N,则系统每天将算力值小于N的用户自动补充到N。注意,此功能要配合XXL-JOB启用。
|
||||
</el-text>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
@@ -240,6 +246,17 @@
|
||||
<el-input v-model.number="system['sd_power']" placeholder="使用Stable-Diffusion画一张图消耗算力" />
|
||||
</el-form-item>
|
||||
<el-form-item label="DALL-E-3算力" prop="dall_power">
|
||||
<template #label>
|
||||
<div class="label-title">
|
||||
MJ操作算力
|
||||
<el-tooltip effect="dark" content="主要用户函数调用 DALL-E-3 进行绘画" raw-content
|
||||
placement="right">
|
||||
<el-icon>
|
||||
<InfoFilled/>
|
||||
</el-icon>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<el-input v-model.number="system['dall_power']" placeholder="使用DALL-E-3画一张图消耗算力" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Suno 算力" prop="suno_power">
|
||||
@@ -379,17 +396,17 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { httpGet, httpPost } from "@/utils/http";
|
||||
import {onMounted, reactive, ref} from "vue";
|
||||
import {httpGet, httpPost} from "@/utils/http";
|
||||
import Compressor from "compressorjs";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { CloseBold, InfoFilled, Select, UploadFilled } from "@element-plus/icons-vue";
|
||||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
import {CloseBold, InfoFilled, Select, UploadFilled} from "@element-plus/icons-vue";
|
||||
import MdEditor from "md-editor-v3";
|
||||
import "md-editor-v3/lib/style.css";
|
||||
import Menu from "@/views/admin/Menu.vue";
|
||||
import { copyObj, dateFormat } from "@/utils/libs";
|
||||
import {copyObj, dateFormat} from "@/utils/libs";
|
||||
import ItemsInput from "@/components/ui/ItemsInput.vue";
|
||||
import { useSharedStore } from "@/store/sharedata";
|
||||
import {useSharedStore} from "@/store/sharedata";
|
||||
|
||||
const activeName = ref("basic");
|
||||
const system = ref({ models: [] });
|
||||
|
||||
Reference in New Issue
Block a user