diff --git a/electron/dbHandler.js b/electron/dbHandler.js index 37f70a3..dde4d96 100644 --- a/electron/dbHandler.js +++ b/electron/dbHandler.js @@ -100,11 +100,10 @@ function getAllSystemMessages() { console.error("数据库连接错误:", err.message); return reject(err); } - console.log("成功连接到数据库"); }); // 执行查询 - const sql = "SELECT message FROM system_message"; + const sql = "SELECT * FROM message"; db.all(sql, [], (err, rows) => { // 关闭数据库连接 db.close(closeErr => { @@ -118,10 +117,54 @@ function getAllSystemMessages() { console.error("查询错误:", err.message); return reject(err); } + resolve(rows); + }); + }); +} +function updateMessageById(id, data) { + return new Promise((resolve, reject) => { + const db = new sqlite3.Database(getDatabasePath(), err => { + if (err) { + return reject(err); + } + }); + debugger; + // 解构data中的所有字段(根据实际表结构调整字段名) + const { message, status } = data; + + // 构建更新字段字符串(排除ID,避免更新主键) + const fields = []; + const params = []; + + // 动态处理所有字段(确保与表结构一致) + if (message !== undefined) { + fields.push("message = ?"); + params.push(message); + } + if (status !== undefined) { + fields.push("status = ?"); + params.push(status); + } + // 构建SQL语句(UPDATE message SET 字段1=?, 字段2=? WHERE id=?) + const sql = `UPDATE message SET ${fields.join(", ")} WHERE id = ?`; + params.push(id); // 最后添加WHERE条件的ID参数 - // 提取所有message字段 - const messages = rows.map(row => row.message); - resolve(messages); + // 执行更新 + db.run(sql, params, function (err) { + if (err) { + console.error("更新message表失败:", err.message); + reject({ code: 1, msg: `更新失败:${err.message}` }); + } else { + if (this.changes > 0) { + resolve({ + code: 0, + msg: `成功更新ID为${id}的记录`, + affectedRows: this.changes + }); + } else { + resolve({ code: 2, msg: `未找到ID为${id}的记录`, affectedRows: 0 }); + } + } }); }); } @@ -325,6 +368,23 @@ async function stopAllProcesses() { console.error(err); } } +async function stopChatProcesses() { + try { + delete processes["chatProcess"]; + const projectRoot = process.cwd(); + const parentDir = path.dirname(projectRoot); + const exPath = path.join(parentDir, "kill-chat.bat"); + const child = spawn("cmd.exe", ["/c", "start", '""', `"${exPath}"`], { + cwd: parentDir, + windowsVerbatimArguments: true, + windowsHide: false, + detached: true + }); + child.unref(); + } catch (err) { + console.error(err); + } +} module.exports = { updateConfig, getConfigValue, @@ -332,5 +392,7 @@ module.exports = { clearSystemMessages, startProcess, stopAllProcesses, - getAllSystemMessages + stopChatProcesses, + getAllSystemMessages, + updateMessageById }; diff --git a/electron/main.js b/electron/main.js index dccf920..8a7fe0d 100644 --- a/electron/main.js +++ b/electron/main.js @@ -1,5 +1,6 @@ const { app, BrowserWindow } = require("electron"); const { ipcMain } = require("electron"); +// const { initSplashScreen } = require("electron-splashscreen"); const path = require("path"); const { updateConfig, @@ -8,8 +9,10 @@ const { stopProcess, startProcess, stopAllProcesses, + stopChatProcesses, getAllSystemMessages, - clearSystemMessages + clearSystemMessages, + updateMessageById } = require("./dbHandler"); // 注册IPC通信处理 @@ -73,6 +76,15 @@ function registerIpcHandlers() { throw error; } }); + ipcMain.handle("stop-chat-process", async () => { + try { + return await stopChatProcesses(); + } catch (error) { + console.error("停止失败:", error); + throw error; + } + }); + ipcMain.handle("get-all-system-messages", async () => { try { return await getAllSystemMessages(); @@ -81,6 +93,14 @@ function registerIpcHandlers() { throw error; } }); + ipcMain.handle("update-message", async (event, id, data) => { + try { + return await updateMessageById(id, data); + } catch (error) { + console.error("更新失败:", error); + throw error; + } + }); } function createWindow() { const win = new BrowserWindow({ @@ -92,7 +112,6 @@ function createWindow() { contextIsolation: true } }); - // 捕获 preload 加载错误 win.webContents.on("did-fail-load", (event, errorCode, errorDescription) => { console.error("Preload 加载失败:", errorDescription); @@ -105,7 +124,7 @@ function createWindow() { win.loadURL("http://localhost:8848/#/login"); win.webContents.openDevTools(); } else { - win.webContents.openDevTools(); + // win.webContents.openDevTools(); win.loadFile("dist/index.html"); } } diff --git a/electron/preload.js b/electron/preload.js index f9bbef1..ce5592d 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -17,6 +17,10 @@ contextBridge.exposeInMainWorld("electronAPI", { stopProcess: (fileName, exeName) => ipcRenderer.invoke("stop-process", fileName, exeName), stopAllProcesses: () => ipcRenderer.invoke("stop-all-process"), + stopChatProcesses: () => ipcRenderer.invoke("stop-chat-process"), clearSystemMessages: () => ipcRenderer.invoke("clear-system-messages"), - getAllSystemMessages: () => ipcRenderer.invoke("get-all-system-messages") + getAllSystemMessages: () => ipcRenderer.invoke("get-all-system-messages"), + updateMessageById: async (id, data) => { + return await ipcRenderer.invoke("update-message", id, data); + } }); diff --git a/package.json b/package.json index 9ee5583..9246eab 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ }, "build": { "appId": "com.example.myapp", - "productName": "My Electron App", + "artifactName": "${productName}.exe", + "productName": "直播数字人", "directories": { "output": "dist-electron" }, diff --git a/src/App.vue b/src/App.vue index 05aeb5a..cd24de7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -47,7 +47,11 @@ export default defineComponent({ .page-main { width: 100%; height: 100%; - overflow: hidden; + overflow-x: auto; + overflow-y: hidden; + // overflow: auto; + min-width: 1200px; + min-height: 800px; display: flex; flex-direction: column; .main-content { diff --git a/src/api/chat.ts b/src/api/chat.ts index 9921c5e..26aac0a 100644 --- a/src/api/chat.ts +++ b/src/api/chat.ts @@ -7,3 +7,8 @@ export const getSalespitch = (data?: object) => { { data } ); }; +export const interruptTalk = (data?: object) => { + return http.request("post", `${config.services.interruptTalk}`, { + data + }); +}; diff --git a/src/api/user.ts b/src/api/user.ts index d13976e..a7d85e3 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -34,6 +34,16 @@ export const getLogin = (data?: object) => { ); }; +/** 获取当前用户信息 */ +export const getUserInfo = (data?: object) => { + return http.request( + "get", + `${config.services.liveDigital}/auth/me`, + { + params: data + } + ); +}; /** 刷新token */ export const refreshTokenApi = (data?: object) => { return http.request("post", "/refreshToken", { data }); diff --git a/src/assets/live/goods_empty.png b/src/assets/live/goods_empty.png new file mode 100644 index 0000000..e6e44bc Binary files /dev/null and b/src/assets/live/goods_empty.png differ diff --git a/src/assets/live/talk_loading.gif b/src/assets/live/talk_loading.gif new file mode 100644 index 0000000..497a9b1 Binary files /dev/null and b/src/assets/live/talk_loading.gif differ diff --git a/src/assets/login/main_bg.png b/src/assets/login/main_bg.png new file mode 100644 index 0000000..8b1b920 Binary files /dev/null and b/src/assets/login/main_bg.png differ diff --git a/src/assets/svg/live/disable_play.svg b/src/assets/svg/live/disable_play.svg new file mode 100644 index 0000000..373f209 --- /dev/null +++ b/src/assets/svg/live/disable_play.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/assets/svg/live/edit.svg b/src/assets/svg/live/edit.svg new file mode 100644 index 0000000..6ac000a --- /dev/null +++ b/src/assets/svg/live/edit.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/assets/svg/live/play.svg b/src/assets/svg/live/play.svg new file mode 100644 index 0000000..e71e807 --- /dev/null +++ b/src/assets/svg/live/play.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/assets/svg/live/random.svg b/src/assets/svg/live/random.svg new file mode 100644 index 0000000..f0e08e2 --- /dev/null +++ b/src/assets/svg/live/random.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/assets/svg/live/stop_play.svg b/src/assets/svg/live/stop_play.svg new file mode 100644 index 0000000..4e1c676 --- /dev/null +++ b/src/assets/svg/live/stop_play.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/components/NavBar/index.vue b/src/components/NavBar/index.vue index aec6330..8e7694e 100644 --- a/src/components/NavBar/index.vue +++ b/src/components/NavBar/index.vue @@ -8,9 +8,12 @@ import router from "@/router"; const { logout, userAvatar, avatarsStyle } = useNav(); import { useRoute } from "vue-router"; const route = useRoute(); -const userName = ref("admin"); +const userName = ref("admin"); -onMounted(() => {}); +onMounted(async () => { + const res: any = await window.electronAPI.getConfig("config", "userName"); + userName.value = res || "admin"; +}); diff --git a/src/views/Live/index1.vue b/src/views/Live/index1.vue new file mode 100644 index 0000000..5f93003 --- /dev/null +++ b/src/views/Live/index1.vue @@ -0,0 +1,514 @@ + + + + diff --git a/src/views/Setting/index.vue b/src/views/Setting/index.vue index 881df75..d97bfde 100644 --- a/src/views/Setting/index.vue +++ b/src/views/Setting/index.vue @@ -1,12 +1,12 @@