编辑ai人设,新消息提醒

This commit is contained in:
2025-09-11 16:46:12 +08:00
parent b2bccb622a
commit 515cbab7c3
9 changed files with 504 additions and 35 deletions

View File

@@ -1,6 +1,10 @@
<template>
<div class="main">
<el-scrollbar class="left"> <!-- 左边栏 -->
<div style="position: absolute;left: 20px; top: 20px;">
<el-button style="background: linear-gradient(90deg, #60a5fa, #34d399); color: azure;"
@click="showMyInfo = true">人设编辑</el-button>
</div>
<div class="center-line"> <!-- 左边栏按钮 -->
<div v-for="(btn, index) in buttons" :key="index" style="width: 100%;">
<div v-if="btn.show?.()" class="left-button" :style="btn.style ? btn.style() : {}" @click="btn.onClick"
@@ -29,6 +33,8 @@
<div class="input-info" v-show="selectedDevice == index">
<div class="app-button" @click="getMesList(device.deviceId)">获取当前聊天记录</div>
<div class="app-button" @click="stopScript({ udid: device.deviceId })">停止任务</div>
<div class="app-button" @click="runTask(runType, device.deviceId)">开启</div>
<!-- <div class="app-button" @click="mqSend()">mq</div> -->
<!-- <div class="app-button"
@click="wsActions.clickCopyList(device.deviceId, index); openShowChat = true; istranslate = true">
@@ -52,15 +58,23 @@
</div>
</div>
</div>
<div class="right center-justify" @click.self="selectedDevice = 999">
<div class="right center-line" @click.self="selectedDevice = 999">
<!-- <div style="margin: 30px;"></div> -->
<ChatDialog :visible="openShowChat" :messages="chatList" />
<MessageDialogd :visible="openShowChat" :messages="MesNewList" />
</div>
<MultiLineInputDialog v-model:visible="showDialog" :initialText='""' :title="dialogTitle" :index="selectedDevice"
@confirm="onDialogConfirm" @cancel="stopAll" />
<HostListManagerDialog v-model:visible="showHostDlg" @save="onHostSaved" />
</div>
</div>
<!-- <AgentGuildDialog v-model="showMyInfo" :model="formInit" @save="handleSave" /> -->
<AgentGuildDialog v-model="showMyInfo" :model="{
agentName: borkerConfig.agentName,
guildName: borkerConfig.guildName,
contactTool: borkerConfig.contactTool,
contact: borkerConfig.contact
}" @save="onSave" />
<!-- 定时调度配置弹窗 -->
<el-dialog v-model="showScheduleDlg" title="定时调度(每小时)" width="420px">
<div style="display:grid;grid-template-columns: 100px 1fr; gap:12px; align-items:center;">
@@ -106,7 +120,7 @@
</template>
<script setup>
import { ref, onMounted, onUnmounted, onBeforeUnmount, watch, inject, computed } from "vue";
import { ref, reactive, onMounted, onUnmounted, onBeforeUnmount, watch, inject, computed } from "vue";
import { useRouter } from 'vue-router';
import {
setphoneXYinfo, getphoneXYinfo, getUser,
@@ -118,8 +132,11 @@ import { connectSSE } from '@/utils/sseUtils'
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus'
import { chat, translationToChinese, translation } from "@/api/chat";
import HostListManagerDialog from '@/components/HostListManagerDialog.vue'
import AgentGuildDialog from '@/components/AgentGuildDialog.vue'
import MultiLineInputDialog from '@/components/MultiLineInputDialog.vue'; // 根据实际路径修改
import ChatDialog from '@/components/ChatDialog.vue'
import MessageDialogd from '@/components/MessageDialogd.vue'
import { pickTikTokBundleId } from '@/utils/arrUtils'
import { logout } from '@/api/account';
import {
@@ -137,19 +154,76 @@ import {
launchApp,
getChatTextInfo,
setLoginInfo,
aiConfig,
} from '@/api/ios';
import { set } from "lodash";
const router = useRouter();
const openShowChat = ref([true])
//主播库
const showHostDlg = ref(false)
//ai人设
const showMyInfo = ref(false)
// 假设这是你已有的数据
const borkerConfig = reactive({
agentName: '',
guildName: '',
contactTool: '',
contact: ''
})
let hostList = []
//查询列表轮询
let getListtimer = null;
let userdata = getUser();
let chatList = ref([])
let MesNewList = ref([{
sender: 'Alice', // 或 name/user/from
device: 'iPhone 14 Pro', // 或 deviceName/udid
text: '你好呀~', // 或 content
type: 'msg' // 可选;有些是 'time' 会被过滤
}, {
sender: 'Alice', // 或 name/user/from
device: 'iPhone 14 Pro', // 或 deviceName/udid
text: '你好呀~', // 或 content
type: 'msg' // 可选;有些是 'time' 会被过滤
}, {
sender: 'Alice', // 或 name/user/from
device: 'iPhone 14 Pro', // 或 deviceName/udid
text: '你好呀~', // 或 content
type: 'msg' // 可选;有些是 'time' 会被过滤
}, {
sender: 'Alice', // 或 name/user/from
device: 'iPhone 14 Pro', // 或 deviceName/udid
text: '你好呀~', // 或 content
type: 'msg' // 可选;有些是 'time' 会被过滤
}, {
sender: 'Alice', // 或 name/user/from
device: 'iPhone 14 Pro', // 或 deviceName/udid
text: '你好呀~', // 或 content
type: 'msg' // 可选;有些是 'time' 会被过滤
}, {
sender: 'Alice', // 或 name/user/from
device: 'iPhone 14 Pro', // 或 deviceName/udid
text: '你好呀~', // 或 content
type: 'msg' // 可选;有些是 'time' 会被过滤
}, {
sender: 'Alice', // 或 name/user/from
device: 'iPhone 14 Pro', // 或 deviceName/udid
text: '你好呀~', // 或 content
type: 'msg' // 可选;有些是 'time' 会被过滤
}, {
sender: 'Alice', // 或 name/user/from
device: 'iPhone 14 Pro', // 或 deviceName/udid
text: '你好呀~', // 或 content
type: 'msg' // 可选;有些是 'time' 会被过滤
}, {
sender: 'Alice', // 或 name/user/from
device: 'iPhone 14 Pro', // 或 deviceName/udid
text: '你好呀~', // 或 content
type: 'msg' // 可选;有些是 'time' 会被过滤
},])
let isImg = ref(true)
// 引入刷新方法
const reload = inject("reload")
@@ -172,6 +246,8 @@ let deviceInformation = ref([])
// 你可以用这种方式声明按钮们
//联动用作标记
let batchMode = ref('init'); // 'init' | 'follow'(仅作标记)
//停止中
let stopLoading = null
// 当前是否被其它模式占用(四个互斥按钮专用)
const isLocked = (type) => !!runType.value && runType.value !== type
@@ -642,20 +718,36 @@ function getMesList(deviceId) {
})
}
function stopAll() {
async function stopAll() {
stopLoading = ElLoading.service({
lock: true,
text: '停止中',
background: 'rgba(0, 0, 0, 0.7)',
});
// if (!runType.value) return
deviceInformation.value.forEach((item) => {
stopScript({ udid: item.deviceId }).then((res) => {
console.log(`停止成功:${item.deviceId}`, res, printCurrentTime())
ElMessage.success(`停止成功:${item.deviceId}`)
}).catch((res) => {
console.log(`停止失败`, printCurrentTime())
ElMessage.error(`脚本已停止`)
})
})
scheduleEnabled.value = false
runType.value = ''
batchMode.value = 'init';
try {
// 使用 Promise.all 并行处理所有设备的停止操作
await Promise.all(deviceInformation.value.map(async (item) => {
try {
const res = await stopScript({ udid: item.deviceId })
console.log(`停止成功:${item.deviceId}`, res, printCurrentTime())
ElMessage.success(`停止成功:${item.deviceId}`)
stopLoading.close()
} catch (error) {
console.log(`停止失败`, printCurrentTime())
ElMessage.error(`脚本已停止`)
stopLoading.close()
}
}))
// 所有操作完成后执行以下代码
scheduleEnabled.value = false
runType.value = ''
batchMode.value = 'init'
} catch (error) {
console.error('批量停止过程中发生错误:', error)
}
}
//确认多行文本框内容
@@ -682,6 +774,8 @@ function onDialogConfirm(result, type, index, isMon) {
needReply: isMon
}
).then((res) => {
ElMessage({ type: 'success', message: '任务开启成功' });
hostList = []
})
}
@@ -741,7 +835,6 @@ onMounted(() => {
{ confirmButtonText: '开始', cancelButtonText: '取消', type: 'success' }
)
.then(() => {
ElMessage({ type: 'success', message: '任务开启成功' });
// runType.value = 'follow';
batchMode.value = 'follow';
@@ -749,8 +842,12 @@ onMounted(() => {
// 不直接发;把这“一波”的主播先塞进 hostList然后弹出“私信”输入框
scheduleFlush((items) => {
hostList = (items || []).map(h => ({ id: h.text, country: h.country || '' }))
showScheduleDlg.value = true
})
setTimeout(() => {
showScheduleDlg.value = true
}, 600)
})
.catch(() => {
// 取消:清理状态,丢弃批次
@@ -808,6 +905,8 @@ onUnmounted(() => {
clearInterval(getListtimer)
getListtimer = null
})
let isStartLac = false
const getDeviceListFun = () => {
getDeviceList().then((res) => {
console.log('返回', res.length)
@@ -823,7 +922,12 @@ const getDeviceListFun = () => {
}
// deviceInformation.value = ['', '', '', '', '', '',]
}).catch((err) => {
ElMessage.error(`IOSAI服务错误`)
if (isStartLac) {
ElMessage.error(`IOSAI服务错误`)
isStartLac = true
} else {
}
})
}
@@ -875,15 +979,30 @@ async function uploadLogFile() {
}
}
function runTask(key) {
function runTask(key, deviceId) {
console.log('[schedule] 切换到任务:', key, printCurrentTime())
forceActivate(key, () => {
forceActivate(key, async () => {
if (key === 'follow') {
if (scheduleEnabled.value) {
stopAll()
if (!deviceId) {
await stopAll()
} else {
passAnchorData(
{
deviceList: [deviceId],
anchorList: [],
prologueList: getContentpriList(),
needReply: false
}
).then((res) => {
hostList = []
})
return
}
setTimeout(() => {
runType.value = 'follow'
@@ -903,7 +1022,7 @@ function runTask(key) {
}
scheduleEnabled.value = true
if (hostList.length <= 0) {
if (batchMode.value == 'init') {
dialogTitle.value = '主播ID';
} else {
dialogTitle.value = '私信';
@@ -912,7 +1031,12 @@ function runTask(key) {
} else if (key === 'like') {
stopAll()
if (!deviceId) {
await stopAll()
} else {
growAccount({ udid: deviceId })
return
}
setTimeout(() => {
scheduleEnabled.value = true
@@ -921,7 +1045,12 @@ function runTask(key) {
}, 1000)
} else if (key === 'brushLive') {
stopAll()
if (!deviceId) {
await stopAll()
} else {
watchLiveForGrowth({ udid: deviceId })
return
}
setTimeout(() => {
scheduleEnabled.value = true
@@ -930,7 +1059,12 @@ function runTask(key) {
}, 1000)
runType.value = 'brushLive'
} else if (key === 'listen') {
stopAll()
if (!deviceId) {
await stopAll()
} else {
monitorMessages({ udid: deviceId })
return
}
setTimeout(() => {
runType.value = 'listen'
@@ -1014,6 +1148,14 @@ function printCurrentTime() {
return now.toLocaleString()
}
function onSave(payload) {
console.log(payload)
aiConfig(payload).then((res) => {
})
}
</script>
<style scoped lang="less">