V 2.2.11 优化MJ代理模式
This commit is contained in:
@@ -48,7 +48,6 @@ export default defineComponent({
|
||||
if (software.data == null) {
|
||||
throw new Error('初始化信息错误: 未获取到数据')
|
||||
}
|
||||
debugger
|
||||
if (software.data.length == 0) {
|
||||
throw new Error('初始化信息错误: 未获取到数据')
|
||||
}
|
||||
|
||||
@@ -316,21 +316,21 @@ export default defineComponent({
|
||||
}
|
||||
]
|
||||
},
|
||||
// {
|
||||
// label: () =>
|
||||
// h(
|
||||
// RouterLink,
|
||||
// {
|
||||
// to: {
|
||||
// name: 'reverse_management'
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// default: () => '一键反推'
|
||||
// }
|
||||
// ),
|
||||
// key: 'reverse_management'
|
||||
// },
|
||||
{
|
||||
label: () =>
|
||||
h(
|
||||
RouterLink,
|
||||
{
|
||||
to: {
|
||||
name: 'reverse_management'
|
||||
}
|
||||
},
|
||||
{
|
||||
default: () => '一键反推'
|
||||
}
|
||||
),
|
||||
key: 'reverse_management'
|
||||
},
|
||||
// {
|
||||
// label: "剪辑",
|
||||
// key: "clip_options",
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
<template>
|
||||
<div id="AddMultiRemoteMj" style="overflow-y: auto">
|
||||
<div style="margin-bottom: 5px">
|
||||
<n-button type="info" @click="ManageAccount(null)">新增账号</n-button>
|
||||
</div>
|
||||
<n-data-table :data="remoteMjSetting" :columns="columns" :max-height="maxHeight">
|
||||
</n-data-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted, defineComponent, onUnmounted, toRaw, watch, h } from 'vue'
|
||||
import {
|
||||
useMessage,
|
||||
NDataTable,
|
||||
NButton,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NForm,
|
||||
NFormItem,
|
||||
useDialog,
|
||||
NTag
|
||||
} from 'naive-ui'
|
||||
import { useSettingStore } from '../../../../../stores/setting'
|
||||
import ManageRemoteMjAccount from './ManageRemoteMjAccount.vue'
|
||||
import { isEmpty } from 'lodash'
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
NDataTable,
|
||||
NButton,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NForm,
|
||||
NFormItem,
|
||||
NTag
|
||||
},
|
||||
props: ['height'],
|
||||
setup(props) {
|
||||
let message = useMessage()
|
||||
let dialog = useDialog()
|
||||
let maxHeight = ref(props.height - 150)
|
||||
let remoteMjSetting = ref([])
|
||||
let settingStore = useSettingStore()
|
||||
|
||||
onMounted(async () => {
|
||||
document.getElementById('AddMultiRemoteMj').style.height = props.height - 60 + 'px'
|
||||
debugger
|
||||
let remoteMjSettingRes = await window.setting.GetRemoteMJSettings()
|
||||
if (remoteMjSettingRes.code == 0) {
|
||||
message.error('获取代理MJ配置失败')
|
||||
} else {
|
||||
remoteMjSetting.value = remoteMjSettingRes.data
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 添加和编辑账号
|
||||
*/
|
||||
async function ManageAccount(remote = null) {
|
||||
debugger
|
||||
if (remote == null) {
|
||||
settingStore.ResetActionRemoteMJ()
|
||||
} else {
|
||||
// 有数据的话
|
||||
settingStore.actionRemoteMJ = remote
|
||||
}
|
||||
|
||||
// 弹窗,管理不想要的值
|
||||
let dW = 800
|
||||
let dH = 600
|
||||
dialog.create({
|
||||
showIcon: false,
|
||||
title: '添加MJ账号',
|
||||
content: () => h(ManageRemoteMjAccount, {}),
|
||||
style: `min-width : 600px; width : ${dW}px; height : ${dH}px; padding-right : 5px;`,
|
||||
maskClosable: false,
|
||||
onClose: async () => {
|
||||
// 关闭的时候,刷新数据
|
||||
let remoteMjSettingRes = await window.setting.GetRemoteMJSettings()
|
||||
if (remoteMjSettingRes.code == 0) {
|
||||
message.error('获取代理MJ配置失败')
|
||||
} else {
|
||||
remoteMjSetting.value = remoteMjSettingRes.data
|
||||
}
|
||||
settingStore.ResetActionRemoteMJ()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定的账号
|
||||
* @param row 数据
|
||||
*/
|
||||
async function DeleteAccount(row) {
|
||||
dialog.warning({
|
||||
title: '删除账号',
|
||||
content: '确定删除该账号吗?',
|
||||
positiveText: '确认',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
if (isEmpty(row.accountId)) {
|
||||
message.error('删除账号失败,错误消息如下:' + '账号ID为空')
|
||||
return
|
||||
}
|
||||
let deleteRes = await window.setting.DeleteRemoteMJSetting(row.id)
|
||||
if (deleteRes.code == 0) {
|
||||
message.error('删除账号失败,错误消息如下:' + deleteRes.message)
|
||||
return
|
||||
}
|
||||
message.success('删除账号成功')
|
||||
// 这边刷新一下数据
|
||||
let remoteMjSettingRes = await window.setting.GetRemoteMJSettings()
|
||||
if (remoteMjSettingRes.code == 0) {
|
||||
message.error('获取代理MJ配置失败')
|
||||
} else {
|
||||
remoteMjSetting.value = remoteMjSettingRes.data
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
remoteMjSetting,
|
||||
maxHeight,
|
||||
ManageAccount,
|
||||
settingStore,
|
||||
columns: [
|
||||
{
|
||||
title: '服务器ID',
|
||||
key: 'guildId'
|
||||
},
|
||||
{
|
||||
title: '频道ID',
|
||||
key: 'channelId'
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
key: 'enable',
|
||||
render(row) {
|
||||
return h(
|
||||
NTag,
|
||||
{
|
||||
style: {
|
||||
marginRight: '6px'
|
||||
},
|
||||
type: (() => (row.enable ? 'success' : 'error'))(),
|
||||
bordered: false
|
||||
},
|
||||
{
|
||||
default: () => (row.enable ? '启用' : '禁用')
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'MJ私信ID',
|
||||
key: 'mjBotChannelId'
|
||||
},
|
||||
{
|
||||
title: 'NIJI私信ID',
|
||||
key: 'nijiBotChannelId'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
render(row) {
|
||||
return h('div', {}, [
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
size: 'small',
|
||||
type: 'info',
|
||||
style: 'margin-left: 5px',
|
||||
onClick: () => ManageAccount(row)
|
||||
},
|
||||
{ default: () => '编辑并同步' }
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
size: 'small',
|
||||
type: 'error',
|
||||
style: 'margin-left: 5px',
|
||||
onClick: () => DeleteAccount(row)
|
||||
},
|
||||
{ default: () => '删除账号' }
|
||||
)
|
||||
])
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,175 @@
|
||||
<template>
|
||||
<div style="margin-top: 20px; margin-left: 20px">
|
||||
<n-form ref="addRef" :model="settingStore.actionRemoteMJ" :rules="rules">
|
||||
<div style="display: flex">
|
||||
<div style="margin-top: 10px; flex: 1">
|
||||
<n-form-item label="服务器ID" style="width: 200px; margin-left: 5px" path="guildId">
|
||||
<n-input
|
||||
v-model:value="settingStore.actionRemoteMJ.guildId"
|
||||
placeholder="请填写服务器ID"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="频道ID" style="width: 200px; margin-left: 10px" path="channelId">
|
||||
<n-input
|
||||
v-model:value="settingStore.actionRemoteMJ.channelId"
|
||||
placeholder="请填写频道ID"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="MJ私信ID"
|
||||
style="width: 200px; margin-left: 10px"
|
||||
path="mjBotChannelId"
|
||||
>
|
||||
<n-input
|
||||
v-model:value="settingStore.actionRemoteMJ.mjBotChannelId"
|
||||
placeholder="请填写MJ私信ID"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="Niji私信ID"
|
||||
style="width: 200px; margin-left: 10px"
|
||||
path="nijiBotChannelId"
|
||||
>
|
||||
<n-input
|
||||
v-model:value="settingStore.actionRemoteMJ.nijiBotChannelId"
|
||||
placeholder="请填写NIJI私信ID"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="用户token" style="width: 240px; margin-left: 10px" path="userToken">
|
||||
<n-input
|
||||
v-model:value="settingStore.actionRemoteMJ.userToken"
|
||||
placeholder="请填写MJtoken"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="用户Agent" style="width: 250px; margin-left: 10px" path="userAgent">
|
||||
<n-input
|
||||
v-model:value="settingStore.actionRemoteMJ.userAgent"
|
||||
placeholder="请填写用户Agent"
|
||||
/>
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div style="margin-top: 10px; flex: 1">
|
||||
<n-form-item label="账号并发数" style="width: 100px; margin-left: 10px" path="coreSize">
|
||||
<n-input-number
|
||||
v-model:value="settingStore.actionRemoteMJ.coreSize"
|
||||
:show-button="false"
|
||||
placeholder="请填写账号并发数"
|
||||
:min="1"
|
||||
:max="20"
|
||||
></n-input-number>
|
||||
</n-form-item>
|
||||
<n-form-item label="等待队列" style="width: 100px; margin-left: 10px" path="queueSize">
|
||||
<n-input-number
|
||||
v-model:value="settingStore.actionRemoteMJ.queueSize"
|
||||
:show-button="false"
|
||||
placeholder="请填写等待队列数量"
|
||||
:min="1"
|
||||
:max="20"
|
||||
></n-input-number>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="任务超时时间"
|
||||
style="width: 100px; margin-left: 10px"
|
||||
path="timeoutMinutes"
|
||||
>
|
||||
<n-input-number
|
||||
v-model:value="settingStore.actionRemoteMJ.timeoutMinutes"
|
||||
:show-button="false"
|
||||
placeholder="请填写任务超时时间"
|
||||
:min="1"
|
||||
:max="20"
|
||||
></n-input-number>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
v-if="settingStore.actionRemoteMJ.accountId != null"
|
||||
label="账号状态"
|
||||
style="width: 100px; margin-left: 10px"
|
||||
path="enable"
|
||||
>
|
||||
<n-switch v-model:value="settingStore.actionRemoteMJ.enable">
|
||||
<template #checked> 启用 </template>
|
||||
<template #unchecked> 禁用 </template>
|
||||
</n-switch>
|
||||
</n-form-item>
|
||||
<n-form-item style="margin-left: 10px">
|
||||
<n-button type="info" @click="CreateAccount" :loading="loading">{{
|
||||
settingStore.actionRemoteMJ.accountId ? '修改并重连' : '创建账号'
|
||||
}}</n-button>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</n-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted, defineComponent, onUnmounted, toRaw, watch } from 'vue'
|
||||
import { useMessage, NForm, NFormItem, NInput, NInputNumber, NButton, NSwitch } from 'naive-ui'
|
||||
import { useSettingStore } from '../../../../../stores/setting'
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
NForm,
|
||||
NFormItem,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NButton,
|
||||
NSwitch
|
||||
},
|
||||
setup() {
|
||||
let message = useMessage()
|
||||
debugger
|
||||
let settingStore = useSettingStore()
|
||||
let addRef = ref(null)
|
||||
let loading = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
debugger
|
||||
console.log(settingStore)
|
||||
})
|
||||
let rules = {
|
||||
guildId: [{ required: true, message: '请输入服务器ID', trigger: 'blur' }],
|
||||
channelId: [{ required: true, message: '请输入频道ID', trigger: 'blur' }],
|
||||
userToken: [{ required: true, message: '请输入用户token', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建账号
|
||||
*/
|
||||
async function CreateAccount(e) {
|
||||
debugger
|
||||
e.preventDefault()
|
||||
addRef.value?.validate(async (errors) => {
|
||||
if (errors) {
|
||||
message.error('请检查必填字段')
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
|
||||
// 判断当前是不是有数据
|
||||
if (settingStore.actionRemoteMJ.accountId) {
|
||||
// 同步并重连
|
||||
let res = await window.setting.UpdateRemoteMJSetting(toRaw(settingStore.actionRemoteMJ))
|
||||
loading.value = false
|
||||
if (res.code == 0) {
|
||||
message.error('更新账号失败,错误消息如下:' + res.message)
|
||||
return
|
||||
}
|
||||
message.success('更新账号成功')
|
||||
} else {
|
||||
// 新建,开始保存
|
||||
let res = await window.setting.AddRemoteMJSetting(toRaw(settingStore.actionRemoteMJ))
|
||||
loading.value = false
|
||||
if (res.code == 0) {
|
||||
message.error('创建账号失败,错误消息如下:' + res.message)
|
||||
return
|
||||
}
|
||||
message.success('创建账号成功')
|
||||
settingStore.ResetActionRemoteMJ()
|
||||
}
|
||||
})
|
||||
}
|
||||
return { settingStore, rules, CreateAccount, addRef, loading }
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -1,263 +1,156 @@
|
||||
<template>
|
||||
<n-spin :show="show" size="large">
|
||||
<div style="overflow: auto; height: 100%">
|
||||
<n-card title="基础设置" size="medium" hoverable style="min-width: 850px">
|
||||
<n-form :model="mjSetting" ref="sampleRef" :rules="sampleRules">
|
||||
<div style="display: flex; align-items: center">
|
||||
<n-form-item label="出图模式" style="width: 150px" path="requestModel">
|
||||
<n-select
|
||||
:options="request_model_options"
|
||||
v-model:value="mjSetting.requestModel"
|
||||
placeholder="请选择出图模式"
|
||||
></n-select>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="选择生图机器人"
|
||||
path="selectRobot"
|
||||
style="width: 120px; margin-left: 10px"
|
||||
>
|
||||
<n-select
|
||||
:options="select_robot_options"
|
||||
v-model:value="mjSetting.selectRobot"
|
||||
@update:value="UpdateSelectRobot"
|
||||
></n-select>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="机器人模型"
|
||||
style="width: 120px; margin-left: 10px"
|
||||
path="imageModel"
|
||||
>
|
||||
<n-select
|
||||
placeholder="请选择机器人模型"
|
||||
:options="image_model_options"
|
||||
v-model:value="mjSetting.imageModel"
|
||||
></n-select>
|
||||
</n-form-item>
|
||||
<n-form-item label="生图尺寸" style="width: 120px; margin-left: 10px" path="imageScale">
|
||||
<n-select
|
||||
placeholder="请选择生图尺寸"
|
||||
:options="image_scale_options"
|
||||
v-model:value="mjSetting.imageScale"
|
||||
></n-select>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="命令后缀"
|
||||
style="width: 160px; margin-left: 10px"
|
||||
path="image_suffix"
|
||||
>
|
||||
<n-input v-model:value="image_suffix" placeholder="请输入后缀命令"></n-input>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="生图任务量"
|
||||
style="width: 100px; margin-left: 10px"
|
||||
path="taskCount"
|
||||
>
|
||||
<n-input-number
|
||||
v-model:value="mjSetting.taskCount"
|
||||
:show-button="false"
|
||||
placeholder="MJ并发出图数量"
|
||||
:min="1"
|
||||
:max="20"
|
||||
></n-input-number>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="间隔时间(s)"
|
||||
style="width: 100px; margin-left: 10px"
|
||||
path="spaceTime"
|
||||
>
|
||||
<n-input-number
|
||||
v-model:value="mjSetting.spaceTime"
|
||||
:show-button="false"
|
||||
placeholder="请输入间隔时间(s)"
|
||||
:min="1"
|
||||
:max="30"
|
||||
></n-input-number>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</n-form>
|
||||
</n-card>
|
||||
<n-card
|
||||
title="API模式设置"
|
||||
hoverable
|
||||
style="margin-top: 10px; min-width: 850px"
|
||||
size="medium"
|
||||
>
|
||||
<n-form :model="mjSetting.apiSetting">
|
||||
<div style="display: flex">
|
||||
<n-form-item
|
||||
label="选择出图的API"
|
||||
style="width: 160px; margin-left: 10px"
|
||||
path="mjApiUrl"
|
||||
>
|
||||
<n-select
|
||||
:options="mj_api_options"
|
||||
v-model:value="mjSetting.apiSetting.mjApiUrl"
|
||||
placeholder="选择出图的中转API"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item style="margin-left: 10px" path="mj_api_url">
|
||||
<n-button type="success" @click="openGptBuyUrl">购买</n-button>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="选择出图速度模式"
|
||||
style="width: 160px; margin-left: 10px"
|
||||
path="mjSpeed"
|
||||
>
|
||||
<n-select
|
||||
:options="mj_speed_options"
|
||||
v-model:value="mjSetting.apiSetting.mjSpeed"
|
||||
placeholder="选择出图速度模式"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="输入API密钥" style="width: 160px; margin-left: 10px" path="apiKey">
|
||||
<n-input
|
||||
type="password"
|
||||
placeholder="请输入密钥"
|
||||
v-model:value="mjSetting.apiSetting.apiKey"
|
||||
></n-input>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</n-form>
|
||||
</n-card>
|
||||
|
||||
<n-card title="代理模式设置" hoverable style="margin-top: 10px; min-width: 850px">
|
||||
<n-form :model="mjSetting.remoteSetting">
|
||||
<div style="display: flex; margin-top: 10px">
|
||||
<n-form-item label="服务器ID" style="width: 200px; margin-left: 5px" path="guildId">
|
||||
<n-input
|
||||
v-model:value="mjSetting.remoteSetting.guildId"
|
||||
placeholder="请填写服务器ID"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="频道ID" style="width: 200px; margin-left: 10px" path="channelId">
|
||||
<n-input
|
||||
v-model:value="mjSetting.remoteSetting.channelId"
|
||||
placeholder="请填写频道ID"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="MJ私信ID"
|
||||
style="width: 200px; margin-left: 10px"
|
||||
path="mjBotChannelId"
|
||||
>
|
||||
<n-input
|
||||
v-model:value="mjSetting.remoteSetting.mjBotChannelId"
|
||||
placeholder="请填写MJ私信ID"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="Niji私信ID"
|
||||
style="width: 200px; margin-left: 10px"
|
||||
path="nijiBotChannelId"
|
||||
>
|
||||
<n-input
|
||||
v-model:value="mjSetting.remoteSetting.nijiBotChannelId"
|
||||
placeholder="请填写NIJI私信ID"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item style="width: 200px; margin-left: 10px">
|
||||
<n-button type="info" @click="AccountSync">账号同步</n-button>
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div style="display: flex; margin-top: 10px">
|
||||
<n-form-item label="用户token" style="width: 240px" path="token">
|
||||
<n-input
|
||||
v-model:value="mjSetting.remoteSetting.userToken"
|
||||
placeholder="请填写MJtoken"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="用户Agent" style="width: 250px; margin-left: 10px" path="userAgent">
|
||||
<n-input
|
||||
v-model:value="mjSetting.remoteSetting.userAgent"
|
||||
placeholder="请填写用户Agent"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="账号并发数" style="width: 100px; margin-left: 10px" path="coreSize">
|
||||
<n-input-number
|
||||
v-model:value="mjSetting.remoteSetting.coreSize"
|
||||
:show-button="false"
|
||||
placeholder="请填写账号并发数"
|
||||
:min="1"
|
||||
:max="20"
|
||||
></n-input-number>
|
||||
</n-form-item>
|
||||
<n-form-item label="等待队列" style="width: 100px; margin-left: 10px" path="queueSize">
|
||||
<n-input-number
|
||||
v-model:value="mjSetting.remoteSetting.queueSize"
|
||||
:show-button="false"
|
||||
placeholder="请填写等待队列数量"
|
||||
:min="1"
|
||||
:max="20"
|
||||
></n-input-number>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="任务超时时间"
|
||||
style="width: 100px; margin-left: 10px"
|
||||
path="timeoutMinutes"
|
||||
>
|
||||
<n-input-number
|
||||
v-model:value="mjSetting.remoteSetting.timeoutMinutes"
|
||||
:show-button="false"
|
||||
placeholder="请填写任务超时时间"
|
||||
:min="1"
|
||||
:max="20"
|
||||
></n-input-number>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</n-form>
|
||||
</n-card>
|
||||
|
||||
<n-card title="浏览器模式设置" hoverable style="margin-top: 10px; min-width: 850px">
|
||||
<n-form :model="mjSetting.browserSetting">
|
||||
<div style="display: flex; margin-top: 10px">
|
||||
<n-form-item>
|
||||
<n-button type="info" @click="OpenDiscordWindow">打开登录MJ</n-button>
|
||||
</n-form-item>
|
||||
<n-form-item label="服务器ID" style="width: 200px; margin-left: 5px" path="serviceId">
|
||||
<n-input
|
||||
v-model:value="mjSetting.browserSetting.serviceId"
|
||||
placeholder="登录MJ后切换服务器自动获取"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="频道ID" style="width: 200px; margin-left: 10px" path="channelId">
|
||||
<n-input
|
||||
v-model:value="mjSetting.browserSetting.channelId"
|
||||
placeholder="登录MJ后切换频道自动获取"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="用户token" style="width: 300px; margin-left: 10px" path="token">
|
||||
<n-input
|
||||
v-model:value="mjSetting.browserSetting.token"
|
||||
placeholder="登录MJ后切换服务器自动获取"
|
||||
/>
|
||||
</n-form-item>
|
||||
</div>
|
||||
<n-form-item label="用户Agent" style="width: 810px" path="userAgent">
|
||||
<n-input
|
||||
v-model:value="mjSetting.browserSetting.userAgent"
|
||||
placeholder="登录MJ后切换服务器自动获取(可自定义)"
|
||||
style="margin-right: 10px"
|
||||
/>
|
||||
<n-tooltip trigger="hover" style="background-color: aliceblue; color: black">
|
||||
<template #trigger>
|
||||
<n-checkbox
|
||||
v-model:checked="mjSetting.browserSetting.userAgentCustom"
|
||||
style="width: 100px"
|
||||
>
|
||||
自定义
|
||||
</n-checkbox>
|
||||
</template>
|
||||
开启自定义需要手动填写userAgent。可以填入浏览器的userAgent
|
||||
</n-tooltip>
|
||||
<div style="overflow: auto; height: 100%">
|
||||
<n-card title="基础设置" size="medium" hoverable style="min-width: 850px">
|
||||
<n-form :model="mjSetting" ref="sampleRef" :rules="sampleRules">
|
||||
<div style="display: flex; align-items: center">
|
||||
<n-form-item label="出图模式" style="width: 150px" path="requestModel">
|
||||
<n-select
|
||||
:options="request_model_options"
|
||||
v-model:value="mjSetting.requestModel"
|
||||
placeholder="请选择出图模式"
|
||||
></n-select>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-card>
|
||||
<n-button type="info" round @click="SaveMjSetting" style="margin-top: 10px"
|
||||
>保存MJ配置</n-button
|
||||
>
|
||||
</div>
|
||||
<template #description> 正在添加或同步MJ账号信息 </template>
|
||||
</n-spin>
|
||||
<n-form-item
|
||||
label="选择生图机器人"
|
||||
path="selectRobot"
|
||||
style="width: 120px; margin-left: 10px"
|
||||
>
|
||||
<n-select
|
||||
:options="select_robot_options"
|
||||
v-model:value="mjSetting.selectRobot"
|
||||
@update:value="UpdateSelectRobot"
|
||||
></n-select>
|
||||
</n-form-item>
|
||||
<n-form-item label="机器人模型" style="width: 120px; margin-left: 10px" path="imageModel">
|
||||
<n-select
|
||||
placeholder="请选择机器人模型"
|
||||
:options="image_model_options"
|
||||
v-model:value="mjSetting.imageModel"
|
||||
></n-select>
|
||||
</n-form-item>
|
||||
<n-form-item label="生图尺寸" style="width: 120px; margin-left: 10px" path="imageScale">
|
||||
<n-select
|
||||
placeholder="请选择生图尺寸"
|
||||
:options="image_scale_options"
|
||||
v-model:value="mjSetting.imageScale"
|
||||
></n-select>
|
||||
</n-form-item>
|
||||
<n-form-item label="命令后缀" style="width: 160px; margin-left: 10px" path="image_suffix">
|
||||
<n-input v-model:value="image_suffix" placeholder="请输入后缀命令"></n-input>
|
||||
</n-form-item>
|
||||
<n-form-item label="生图任务量" style="width: 100px; margin-left: 10px" path="taskCount">
|
||||
<n-input-number
|
||||
v-model:value="mjSetting.taskCount"
|
||||
:show-button="false"
|
||||
placeholder="MJ并发出图数量"
|
||||
:min="1"
|
||||
:max="20"
|
||||
></n-input-number>
|
||||
</n-form-item>
|
||||
<n-form-item label="间隔时间(s)" style="width: 100px; margin-left: 10px" path="spaceTime">
|
||||
<n-input-number
|
||||
v-model:value="mjSetting.spaceTime"
|
||||
:show-button="false"
|
||||
placeholder="请输入间隔时间(s)"
|
||||
:min="1"
|
||||
:max="30"
|
||||
></n-input-number>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</n-form>
|
||||
</n-card>
|
||||
<n-card title="API模式设置" hoverable style="margin-top: 10px; min-width: 850px" size="medium">
|
||||
<n-form :model="mjSetting.apiSetting">
|
||||
<div style="display: flex">
|
||||
<n-form-item
|
||||
label="选择出图的API"
|
||||
style="width: 160px; margin-left: 10px"
|
||||
path="mjApiUrl"
|
||||
>
|
||||
<n-select
|
||||
:options="mj_api_options"
|
||||
v-model:value="mjSetting.apiSetting.mjApiUrl"
|
||||
placeholder="选择出图的中转API"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item style="margin-left: 10px" path="mj_api_url">
|
||||
<n-button type="success" @click="openGptBuyUrl">购买</n-button>
|
||||
</n-form-item>
|
||||
<n-form-item
|
||||
label="选择出图速度模式"
|
||||
style="width: 160px; margin-left: 10px"
|
||||
path="mjSpeed"
|
||||
>
|
||||
<n-select
|
||||
:options="mj_speed_options"
|
||||
v-model:value="mjSetting.apiSetting.mjSpeed"
|
||||
placeholder="选择出图速度模式"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="输入API密钥" style="width: 160px; margin-left: 10px" path="apiKey">
|
||||
<n-input
|
||||
type="password"
|
||||
placeholder="请输入密钥"
|
||||
v-model:value="mjSetting.apiSetting.apiKey"
|
||||
></n-input>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</n-form>
|
||||
</n-card>
|
||||
|
||||
<n-card title="代理模式设置" hoverable style="margin-top: 10px; min-width: 850px">
|
||||
<n-button type="info" @click="AddMultiMjAccount">账号管理</n-button>
|
||||
</n-card>
|
||||
|
||||
<n-card title="浏览器模式设置" hoverable style="margin-top: 10px; min-width: 850px">
|
||||
<n-form :model="mjSetting.browserSetting">
|
||||
<div style="display: flex; margin-top: 10px">
|
||||
<n-form-item>
|
||||
<n-button type="info" @click="OpenDiscordWindow">打开登录MJ</n-button>
|
||||
</n-form-item>
|
||||
<n-form-item label="服务器ID" style="width: 200px; margin-left: 5px" path="serviceId">
|
||||
<n-input
|
||||
v-model:value="mjSetting.browserSetting.serviceId"
|
||||
placeholder="登录MJ后切换服务器自动获取"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="频道ID" style="width: 200px; margin-left: 10px" path="channelId">
|
||||
<n-input
|
||||
v-model:value="mjSetting.browserSetting.channelId"
|
||||
placeholder="登录MJ后切换频道自动获取"
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="用户token" style="width: 300px; margin-left: 10px" path="token">
|
||||
<n-input
|
||||
v-model:value="mjSetting.browserSetting.token"
|
||||
placeholder="登录MJ后切换服务器自动获取"
|
||||
/>
|
||||
</n-form-item>
|
||||
</div>
|
||||
<n-form-item label="用户Agent" style="width: 810px" path="userAgent">
|
||||
<n-input
|
||||
v-model:value="mjSetting.browserSetting.userAgent"
|
||||
placeholder="登录MJ后切换服务器自动获取(可自定义)"
|
||||
style="margin-right: 10px"
|
||||
/>
|
||||
<n-tooltip trigger="hover" style="background-color: aliceblue; color: black">
|
||||
<template #trigger>
|
||||
<n-checkbox
|
||||
v-model:checked="mjSetting.browserSetting.userAgentCustom"
|
||||
style="width: 100px"
|
||||
>
|
||||
自定义
|
||||
</n-checkbox>
|
||||
</template>
|
||||
开启自定义需要手动填写userAgent。可以填入浏览器的userAgent
|
||||
</n-tooltip>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-card>
|
||||
<n-button type="info" round @click="SaveMjSetting" style="margin-top: 10px"
|
||||
>保存MJ配置</n-button
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -283,6 +176,7 @@ import { DEFINE_STRING } from '../../../../define/define_string'
|
||||
import { Reload } from '@vicons/ionicons5'
|
||||
import { isEmpty, max, min } from 'lodash'
|
||||
import { MJImageType } from '../../../../define/enum/mjEnum'
|
||||
import AddMultiRemoteMj from './Components/AddMultiRemoteMj.vue'
|
||||
export default defineComponent({
|
||||
components: {
|
||||
NButton,
|
||||
@@ -304,7 +198,6 @@ export default defineComponent({
|
||||
let message = useMessage()
|
||||
let dialog = useDialog()
|
||||
let sampleRef = ref(null)
|
||||
let show = ref(false)
|
||||
let select_robot_options = ref([
|
||||
{
|
||||
label: 'MJ',
|
||||
@@ -543,25 +436,15 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
if (request_model == MJImageType.REMOTE_MJ) {
|
||||
if (mjSetting.value.remoteSetting == null) {
|
||||
message.error('请先添加代理模式的配置')
|
||||
// 检查是不是有代理账号
|
||||
let remoteMjRes = await window.setting.GetRemoteMJSettings()
|
||||
if (remoteMjRes.code == 0) {
|
||||
message.error('获取代理MJ配置失败')
|
||||
return
|
||||
}
|
||||
|
||||
// if (mjSetting.value.remoteSetting.accountId == null) {
|
||||
// message.error('请先同步账号')
|
||||
// return
|
||||
// }
|
||||
|
||||
// 代理模式,检查必填数据
|
||||
if (
|
||||
mjSetting.value.remoteSetting == null ||
|
||||
mjSetting.value.remoteSetting.guildId == null ||
|
||||
mjSetting.value.remoteSetting.channelId == null ||
|
||||
mjSetting.value.remoteSetting.userToken == null ||
|
||||
mjSetting.value.remoteSetting.userAgent == null
|
||||
) {
|
||||
message.error('请检查代理模式设置的必填字段')
|
||||
if (remoteMjRes.data.length <= 0) {
|
||||
message.error('请先添加代理模式的配置')
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -590,8 +473,7 @@ export default defineComponent({
|
||||
if (mjSetting.value.requestModel == MJImageType.REMOTE_MJ) {
|
||||
window.api.showGlobalMessageDialog({
|
||||
code: 1,
|
||||
message: `数据保存成功,
|
||||
当前生图模式为代理模式,若有修改配置请手动同步账号数据,但是不要频繁同步,有封号风险 `
|
||||
message: `数据保存成功,当前模式为代理模式`
|
||||
})
|
||||
} else {
|
||||
window.api.showGlobalMessageDialog({ code: 1, message: '添加成功' })
|
||||
@@ -639,49 +521,18 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
/**
|
||||
* 账号同步
|
||||
* 添加多个账号,这样可以同时跑多个账号
|
||||
*/
|
||||
async function AccountSync() {
|
||||
dialog.warning({
|
||||
title: '警告',
|
||||
content: () =>
|
||||
h('div', {}, [
|
||||
h(
|
||||
'span',
|
||||
{},
|
||||
{
|
||||
default: () => '同步数据的信息是保存后的数据'
|
||||
}
|
||||
),
|
||||
h('br'),
|
||||
h(
|
||||
'span',
|
||||
{ style: 'color : red;font-size : 18px' },
|
||||
{
|
||||
default: () => '修改数据后请先保存,请先保存再执行同步操作'
|
||||
}
|
||||
),
|
||||
h('br'),
|
||||
h(
|
||||
'span',
|
||||
{},
|
||||
{
|
||||
default: () => '同步操作不要频繁,有封号风险'
|
||||
}
|
||||
)
|
||||
]),
|
||||
positiveText: '确定',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
show.value = true
|
||||
let res = await window.setting.MjRemoteAccountSync()
|
||||
show.value = false
|
||||
if (res.code == 0) {
|
||||
message.error(res.message)
|
||||
return
|
||||
}
|
||||
message.success('MJ账号同步成功,可以开始使用')
|
||||
}
|
||||
async function AddMultiMjAccount() {
|
||||
// 弹窗,管理不想要的值
|
||||
let dW = window.innerWidth * 0.9
|
||||
let dH = window.innerHeight * 0.9
|
||||
dialog.create({
|
||||
showIcon: false,
|
||||
title: '管理代理模式MJ账号',
|
||||
content: () => h(AddMultiRemoteMj, { height: dH }),
|
||||
style: `min-width : 600px; width : ${dW}px; height : ${dH}px; padding-right : 5px;`,
|
||||
maskClosable: false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -700,8 +551,7 @@ export default defineComponent({
|
||||
mj_speed_options,
|
||||
openGptBuyUrl,
|
||||
sampleRules,
|
||||
AccountSync,
|
||||
show
|
||||
AddMultiMjAccount
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user