From cf71dbcb8ec6b878586418c13e94ef5bedb4bfb1 Mon Sep 17 00:00:00 2001 From: Yunlong <384345134@qq.com> Date: Sat, 29 Mar 2025 03:57:18 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20setting=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/dao/setting.js | 51 ++++++ src/main/db/sql.js | 16 ++ src/main/service/index.js | 2 + src/main/service/setting.js | 102 ++++++++++++ src/renderer/src/api/index.js | 25 +++ src/renderer/src/components/menuLIst.vue | 8 + src/renderer/src/i18n/components/common.js | 6 +- src/renderer/src/router/index.js | 6 + src/renderer/src/views/setting/index.vue | 180 +++++++++++++++++++++ 9 files changed, 394 insertions(+), 2 deletions(-) create mode 100644 src/main/dao/setting.js create mode 100644 src/main/service/setting.js create mode 100644 src/renderer/src/views/setting/index.vue diff --git a/src/main/dao/setting.js b/src/main/dao/setting.js new file mode 100644 index 0000000..0c4be0f --- /dev/null +++ b/src/main/dao/setting.js @@ -0,0 +1,51 @@ +import { connect } from '../db/index.js' + +export function insert({ group_name, key, value, label }) { + const db = connect() + const stmt = db.prepare( + 'INSERT INTO setting (group_name, key, value, label, created_at) VALUES (?, ?, ?, ?, ?)' + ) + const info = stmt.run(group_name, key, value, label, Date.now()) + return info.lastInsertRowid +} + +export function update({ group_name, key, value, label }) { + const db = connect() + const info = db.prepare( + 'UPDATE setting SET value = ?, label = ? WHERE group_name = ? AND key = ?' + ).run(value, label, group_name, key) + return info +} + +export function remove(group_name, key) { + const db = connect() + return db.prepare('DELETE FROM setting WHERE group_name = ? AND key = ?').run(group_name, key) +} + +export function findByGroupAndKey(group_name, key) { + const db = connect() + return db.prepare('SELECT * FROM setting WHERE group_name = ? AND key = ?').get(group_name, key) +} + +export function findByGroup(group_name) { + const db = connect() + return db.prepare('SELECT * FROM setting WHERE group_name = ?').all(group_name) +} + +export function selectAll() { + const db = connect() + return db.prepare('SELECT * FROM setting').all() +} + +export function updateById({ id, value, label }) { + const db = connect() + const info = db.prepare( + 'UPDATE setting SET value = ?, label = ? WHERE id = ?' + ).run(value, label, id) + return info +} + +export function findById(id) { + const db = connect() + return db.prepare('SELECT * FROM setting WHERE id = ?').get(id) +} \ No newline at end of file diff --git a/src/main/db/sql.js b/src/main/db/sql.js index e1edfdd..5f2d907 100644 --- a/src/main/db/sql.js +++ b/src/main/db/sql.js @@ -65,5 +65,21 @@ export default [ script: `alter table video add voice_id integer; ` + }, + { + version: 4, + script: `create table setting + ( + id INTEGER + primary key autoincrement, + group_name TEXT, + key TEXT, + value TEXT, + label TEXT, + created_at INTEGER not null default (strftime('%s', 'now')), + constraint setting_unique unique (group_name, key) + ); + create index idx_setting_group_key on setting(group_name, key); + ` } ] diff --git a/src/main/service/index.js b/src/main/service/index.js index 83133bb..0d58d5a 100644 --- a/src/main/service/index.js +++ b/src/main/service/index.js @@ -2,9 +2,11 @@ import { init as videoResult } from './video.js' import { init as model } from './model.js' import { init as context } from './context.js' import { init as voice } from './voice.js' +import { init as setting } from './setting.js' export function registerHandler() { videoResult() model() context() voice() + setting() } diff --git a/src/main/service/setting.js b/src/main/service/setting.js new file mode 100644 index 0000000..774f0c2 --- /dev/null +++ b/src/main/service/setting.js @@ -0,0 +1,102 @@ +import { ipcMain } from 'electron' +import { insert, update, findByGroup, findByGroupAndKey, selectAll, updateById, findById } from '../dao/setting.js' + +const MODEL_NAME = 'setting' + +// 设置组常量 +export const SETTING_GROUPS = { + SYSTEM: 'system', // 系统设置 + STORAGE: 'storage', // 存储设置 + MINION: 'minio', // MINION 存储设置 + API: 'api', // API设置 + MODEL: 'model' // 模型设置 +} + +// 设置组显示名称映射 +export const GROUP_LABELS = { + [SETTING_GROUPS.SYSTEM]: '系统设置', + [SETTING_GROUPS.STORAGE]: '存储设置', + [SETTING_GROUPS.API]: 'API设置', + [SETTING_GROUPS.MODEL]: '模型设置', + [SETTING_GROUPS.MINION]: 'MINION存储设置' +} + +export function saveSetting({ group_name, key, value, label }) { + const setting = findByGroupAndKey(group_name, key) + if (setting) { + return update({ group_name, key, value, label }) + } + return insert({ group_name, key, value, label }) +} + +export function getSettingByGroup(group_name) { + return findByGroup(group_name) +} + +export function getSetting(group_name, key) { + return findByGroupAndKey(group_name, key) +} + +export function getAllSettings() { + return selectAll() +} + +// 默认设置数据 +const DEFAULT_SETTINGS = [ + { + group_name: SETTING_GROUPS.MINION, + key: 'enabled', + value: 'false', + label: '是否启用' + }, + { + group_name: SETTING_GROUPS.MINION, + key: 'endpoint', + value: '127.0.0.1:9000', + label: 'MinIO服务器地址' + }, + { + group_name: SETTING_GROUPS.MINION, + key: 'useSSL', + value: 'true', + label: '是否使用SSL' + }, + { + group_name: SETTING_GROUPS.MINION, + key: 'accessKey', + value: '', + label: '访问密钥' + }, + { + group_name: SETTING_GROUPS.MINION, + key: 'secretKey', + value: '', + label: '秘密密钥' + } +] + +export function init() { + // 初始化数据 + const settings = getAllSettings() + if (!settings || settings.length === 0) { + DEFAULT_SETTINGS.forEach(setting => { + saveSetting(setting) + }) + } + + ipcMain.handle(MODEL_NAME + '/save', (event, ...args) => { + return saveSetting(...args) + }) + ipcMain.handle(MODEL_NAME + '/getByGroup', (event, ...args) => { + return getSettingByGroup(...args) + }) + ipcMain.handle(MODEL_NAME + '/get', (event, ...args) => { + return getSetting(...args) + }) + ipcMain.handle(MODEL_NAME + '/getAll', (event, ...args) => { + return getAllSettings(...args) + }) + ipcMain.handle(MODEL_NAME + '/getAllGroupLables', (event, ...args) => { + return GROUP_LABELS + }) +} \ No newline at end of file diff --git a/src/renderer/src/api/index.js b/src/renderer/src/api/index.js index a492688..42e6ab4 100644 --- a/src/renderer/src/api/index.js +++ b/src/renderer/src/api/index.js @@ -64,3 +64,28 @@ export function saveContext(key, val) { export function audition(voiceId, text) { return window.electron.ipcRenderer.invoke('voice/audition', voiceId, text) } + +// 保存配置 +export function saveSetting(setting) { + return window.electron.ipcRenderer.invoke('setting/save', setting) +} + +// 获取某个组的所有配置 +export function getSettingByGroup(groupName) { + return window.electron.ipcRenderer.invoke('setting/getByGroup', groupName) +} + +// 获取特定配置项 +export function getSetting(groupName, key) { + return window.electron.ipcRenderer.invoke('setting/get', groupName, key) +} + +// 获取所有配置 +export function getAllSetting() { + return window.electron.ipcRenderer.invoke('setting/getAll') +} + +// 获取所有配置 +export function getAllSettingGroupLables() { + return window.electron.ipcRenderer.invoke('setting/getAllGroupLables') +} \ No newline at end of file diff --git a/src/renderer/src/components/menuLIst.vue b/src/renderer/src/components/menuLIst.vue index a87314a..31e323e 100644 --- a/src/renderer/src/components/menuLIst.vue +++ b/src/renderer/src/components/menuLIst.vue @@ -29,6 +29,14 @@ const obj = [ offIcon, active: true, path: '/home' + }, + { + key: 'common.menu.setting', + name: t('common.menu.setting'), + onIcon, + offIcon, + active: true, + path: '/setting' } /* { name: "账号", diff --git a/src/renderer/src/i18n/components/common.js b/src/renderer/src/i18n/components/common.js index e5e3ac4..6af183f 100644 --- a/src/renderer/src/i18n/components/common.js +++ b/src/renderer/src/i18n/components/common.js @@ -7,7 +7,8 @@ import { Button } from 'tdesign-vue-next' // 中文翻译 export const commonZh = { menu: { - text: '首页' + text: '首页', + setting: '配置' }, header: { minimizeText: '最小化', @@ -147,7 +148,8 @@ export const commonZh = { // 英文翻译 export const commonEn = { menu: { - text: 'Home' + text: 'Home', + setting: 'Setting' }, header: { minimizeText: 'Minimize', diff --git a/src/renderer/src/router/index.js b/src/renderer/src/router/index.js index 295177c..09218a5 100644 --- a/src/renderer/src/router/index.js +++ b/src/renderer/src/router/index.js @@ -1,6 +1,7 @@ import { createRouter, createWebHashHistory } from 'vue-router' import home from '@renderer/views/home/index.vue' import account from '@renderer/views/account/index.vue' +import setting from '@renderer/views/setting/index.vue' import VideoEditView from '@renderer/views/video-edit/VideoEditView.vue' const router = createRouter({ @@ -26,6 +27,11 @@ const router = createRouter({ name: 'account', component: account }, + { + path: '/setting', + name: 'setting', + component: setting + }, ] }) diff --git a/src/renderer/src/views/setting/index.vue b/src/renderer/src/views/setting/index.vue new file mode 100644 index 0000000..7583e04 --- /dev/null +++ b/src/renderer/src/views/setting/index.vue @@ -0,0 +1,180 @@ + + + + + \ No newline at end of file From f1691fa00afbf7b70bd9797aec89478fd0f1b386 Mon Sep 17 00:00:00 2001 From: Yunlong <384345134@qq.com> Date: Sat, 29 Mar 2025 12:29:40 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20setting=20?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E6=89=8B=E5=8A=A8=E9=85=8D=E7=BD=AE=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E8=B7=AF=E5=BE=84=EF=BC=8C=E9=9C=80=E8=A6=81=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E4=B8=8E=E5=AE=B9=E5=99=A8=E6=8C=82=E8=BD=BD=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 438 ++++++++++++++++++++++- package.json | 1 + src/main/api/f2f.js | 4 +- src/main/api/tts.js | 4 +- src/main/config/config.js | 39 +- src/main/handlers/file.js | 33 +- src/main/service/model.js | 32 +- src/main/service/setting.js | 44 +++ src/main/service/video.js | 12 +- src/renderer/src/views/setting/index.vue | 5 +- 10 files changed, 578 insertions(+), 34 deletions(-) diff --git a/package-lock.json b/package-lock.json index 098bdc1..5bc64aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "electron-updater": "^6.1.7", "fluent-ffmpeg": "^2.1.3", "lodash-es": "^4.17.21", + "minio": "^8.0.5", "pinia": "^2.2.6", "tdesign-icons-vue-next": "^0.3.3", "tdesign-vue-next": "^1.10.3", @@ -2391,6 +2392,13 @@ "license": "Apache-2.0", "peer": true }, + "node_modules/@zxing/text-encoding": { + "version": "0.9.0", + "resolved": "https://registry.npmmirror.com/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", + "integrity": "sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==", + "license": "(Unlicense OR Apache-2.0)", + "optional": true + }, "node_modules/7zip-bin": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-5.2.0.tgz", @@ -2744,7 +2752,6 @@ "version": "3.2.6", "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", - "dev": true, "license": "MIT" }, "node_modules/async-exit-hook": { @@ -2773,6 +2780,21 @@ "node": ">= 4.0.0" } }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmmirror.com/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "license": "MIT", + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/axios": { "version": "1.8.4", "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.4.tgz", @@ -2852,6 +2874,15 @@ "readable-stream": "^3.4.0" } }, + "node_modules/block-stream2": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/block-stream2/-/block-stream2-2.1.0.tgz", + "integrity": "sha512-suhjmLI57Ewpmq00qaygS8UgEq2ly2PCItenIyhMqVjo4t4pGzqMvfgJuX8iWTeSDdfSSqS6j38fL4ToNL7Pfg==", + "license": "MIT", + "dependencies": { + "readable-stream": "^3.4.0" + } + }, "node_modules/bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -2894,6 +2925,12 @@ "balanced-match": "^1.0.0" } }, + "node_modules/browser-or-node": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/browser-or-node/-/browser-or-node-2.1.1.tgz", + "integrity": "sha512-8CVjaLJGuSKMVTxJ2DpBl5XnlNDiT4cQFeuCJJrvJmts9YrTZDizTX7PjC2s6W4x+MBGZeEY6dGMrF04/6Hgqg==", + "license": "MIT" + }, "node_modules/browserslist": { "version": "4.24.4", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.4.tgz", @@ -3094,6 +3131,24 @@ "node": ">=8" } }, + "node_modules/call-bind": { + "version": "1.0.8", + "resolved": "https://registry.npmmirror.com/call-bind/-/call-bind-1.0.8.tgz", + "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.0", + "es-define-property": "^1.0.0", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/call-bind-apply-helpers": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", @@ -3107,6 +3162,22 @@ "node": ">= 0.4" } }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -3502,6 +3573,15 @@ } } }, + "node_modules/decode-uri-component": { + "version": "0.2.2", + "resolved": "https://registry.npmmirror.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", + "license": "MIT", + "engines": { + "node": ">=0.10" + } + }, "node_modules/decompress-response": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", @@ -3559,7 +3639,6 @@ "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "license": "MIT", - "optional": true, "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", @@ -4638,6 +4717,12 @@ "node": ">=0.10.0" } }, + "node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "license": "MIT" + }, "node_modules/events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", @@ -4735,6 +4820,24 @@ "license": "BSD-3-Clause", "peer": true }, + "node_modules/fast-xml-parser": { + "version": "4.5.3", + "resolved": "https://registry.npmmirror.com/fast-xml-parser/-/fast-xml-parser-4.5.3.tgz", + "integrity": "sha512-RKihhV+SHsIUGXObeVy9AXiBbFwkVk7Syp8XgwN5U3JV416+Gwp/GO9i0JYKmikykgz/UHRrrV4ROuZEo/T0ig==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT", + "dependencies": { + "strnum": "^1.1.1" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, "node_modules/fastq": { "version": "1.19.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", @@ -4783,6 +4886,15 @@ "minimatch": "^5.0.1" } }, + "node_modules/filter-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/filter-obj/-/filter-obj-1.1.0.tgz", + "integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -4872,6 +4984,21 @@ } } }, + "node_modules/for-each": { + "version": "0.3.5", + "resolved": "https://registry.npmmirror.com/for-each/-/for-each-0.3.5.tgz", + "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/foreground-child": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", @@ -5256,7 +5383,6 @@ "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "license": "MIT", - "optional": true, "dependencies": { "es-define-property": "^1.0.0" }, @@ -5510,6 +5636,43 @@ "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "license": "ISC" }, + "node_modules/ipaddr.js": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/ipaddr.js/-/ipaddr.js-2.2.0.tgz", + "integrity": "sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA==", + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/is-arguments": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/is-arguments/-/is-arguments-1.2.0.tgz", + "integrity": "sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmmirror.com/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-ci": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz", @@ -5543,6 +5706,24 @@ "node": ">=8" } }, + "node_modules/is-generator-function": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/is-generator-function/-/is-generator-function-1.1.0.tgz", + "integrity": "sha512-nPUB5km40q9e8UfN/Zc24eLlzdSf9OfKByBw9CIdw4H1giPMeA0OIJvbchsCu4npfI2QcMVBsGEBHKZ7wLTWmQ==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "get-proto": "^1.0.0", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -5566,6 +5747,39 @@ "node": ">=8" } }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.15", + "resolved": "https://registry.npmmirror.com/is-typed-array/-/is-typed-array-1.1.15.tgz", + "integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==", + "license": "MIT", + "dependencies": { + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-what": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/is-what/-/is-what-3.14.1.tgz", @@ -5947,7 +6161,6 @@ "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true, "license": "MIT" }, "node_modules/lodash-es": { @@ -6165,6 +6378,40 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/minio": { + "version": "8.0.5", + "resolved": "https://registry.npmmirror.com/minio/-/minio-8.0.5.tgz", + "integrity": "sha512-/vAze1uyrK2R/DSkVutE4cjVoAowvIQ18RAwn7HrqnLecLlMazFnY0oNBqfuoAWvu7mZIGX75AzpuV05TJeoHg==", + "license": "Apache-2.0", + "dependencies": { + "async": "^3.2.4", + "block-stream2": "^2.1.0", + "browser-or-node": "^2.1.1", + "buffer-crc32": "^1.0.0", + "eventemitter3": "^5.0.1", + "fast-xml-parser": "^4.4.1", + "ipaddr.js": "^2.0.1", + "lodash": "^4.17.21", + "mime-types": "^2.1.35", + "query-string": "^7.1.3", + "stream-json": "^1.8.0", + "through2": "^4.0.2", + "web-encoding": "^1.1.5", + "xml2js": "^0.5.0 || ^0.6.2" + }, + "engines": { + "node": "^16 || ^18 || >=20" + } + }, + "node_modules/minio/node_modules/buffer-crc32": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/buffer-crc32/-/buffer-crc32-1.0.0.tgz", + "integrity": "sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w==", + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/minipass": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", @@ -6594,6 +6841,15 @@ "node": ">=10.4.0" } }, + "node_modules/possible-typed-array-names": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", + "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/postcss": { "version": "8.5.3", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz", @@ -6766,6 +7022,24 @@ "node": ">=6" } }, + "node_modules/query-string": { + "version": "7.1.3", + "resolved": "https://registry.npmmirror.com/query-string/-/query-string-7.1.3.tgz", + "integrity": "sha512-hh2WYhq4fi8+b+/2Kg9CEge4fDPvHS534aOOvOZeQ3+Vf2mCFsaFBYj0i+iXcAq6I9Vzp5fjMFBlONvayDC1qg==", + "license": "MIT", + "dependencies": { + "decode-uri-component": "^0.2.2", + "filter-obj": "^1.1.0", + "split-on-first": "^1.0.0", + "strict-uri-encode": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -7092,6 +7366,23 @@ ], "license": "MIT" }, + "node_modules/safe-regex-test": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/safe-regex-test/-/safe-regex-test-1.1.0.tgz", + "integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-regex": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -7177,6 +7468,23 @@ "randombytes": "^2.1.0" } }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmmirror.com/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -7348,6 +7656,15 @@ "source-map": "^0.6.0" } }, + "node_modules/split-on-first": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/split-on-first/-/split-on-first-1.1.0.tgz", + "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/sprintf-js": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", @@ -7365,6 +7682,30 @@ "node": ">= 6" } }, + "node_modules/stream-chain": { + "version": "2.2.5", + "resolved": "https://registry.npmmirror.com/stream-chain/-/stream-chain-2.2.5.tgz", + "integrity": "sha512-1TJmBx6aSWqZ4tx7aTpBDXK0/e2hhcNSTV8+CbFJtDjbb+I1mZ8lHit0Grw9GRT+6JbIrrDd8esncgBi8aBXGA==", + "license": "BSD-3-Clause" + }, + "node_modules/stream-json": { + "version": "1.9.1", + "resolved": "https://registry.npmmirror.com/stream-json/-/stream-json-1.9.1.tgz", + "integrity": "sha512-uWkjJ+2Nt/LO9Z/JyKZbMusL8Dkh97uUBTv3AJQ74y07lVahLY4eEFsPsE97pxYBwr8nnjMAIch5eqI0gPShyw==", + "license": "BSD-3-Clause", + "dependencies": { + "stream-chain": "^2.2.5" + } + }, + "node_modules/strict-uri-encode": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", + "integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -7445,6 +7786,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT" + }, "node_modules/sumchecker": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", @@ -7782,6 +8135,15 @@ "dev": true, "license": "MIT" }, + "node_modules/through2": { + "version": "4.0.2", + "resolved": "https://registry.npmmirror.com/through2/-/through2-4.0.2.tgz", + "integrity": "sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==", + "license": "MIT", + "dependencies": { + "readable-stream": "3" + } + }, "node_modules/tiny-typed-emitter": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz", @@ -7946,6 +8308,19 @@ "dev": true, "license": "(WTFPL OR MIT)" }, + "node_modules/util": { + "version": "0.12.5", + "resolved": "https://registry.npmmirror.com/util/-/util-0.12.5.tgz", + "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "is-arguments": "^1.0.4", + "is-generator-function": "^1.0.7", + "is-typed-array": "^1.1.3", + "which-typed-array": "^1.1.2" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -8172,6 +8547,18 @@ "node": ">=10.13.0" } }, + "node_modules/web-encoding": { + "version": "1.1.5", + "resolved": "https://registry.npmmirror.com/web-encoding/-/web-encoding-1.1.5.tgz", + "integrity": "sha512-HYLeVCdJ0+lBYV2FvNZmv3HJ2Nt0QYXqZojk3d9FJOLkwnuhzM9tmamh8d7HPM8QqjKH8DeHkFTx+CFlWpZZDA==", + "license": "MIT", + "dependencies": { + "util": "^0.12.3" + }, + "optionalDependencies": { + "@zxing/text-encoding": "0.9.0" + } + }, "node_modules/webpack": { "version": "5.98.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.98.0.tgz", @@ -8334,6 +8721,27 @@ "node": ">= 8" } }, + "node_modules/which-typed-array": { + "version": "1.1.19", + "resolved": "https://registry.npmmirror.com/which-typed-array/-/which-typed-array-1.1.19.tgz", + "integrity": "sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==", + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "for-each": "^0.3.5", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", @@ -8397,6 +8805,28 @@ "node": ">=12" } }, + "node_modules/xml2js": { + "version": "0.6.2", + "resolved": "https://registry.npmmirror.com/xml2js/-/xml2js-0.6.2.tgz", + "integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==", + "license": "MIT", + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/xml2js/node_modules/xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmmirror.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "license": "MIT", + "engines": { + "node": ">=4.0" + } + }, "node_modules/xmlbuilder": { "version": "15.1.1", "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz", diff --git a/package.json b/package.json index ac5d790..5b68c6a 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "electron-updater": "^6.1.7", "fluent-ffmpeg": "^2.1.3", "lodash-es": "^4.17.21", + "minio": "^8.0.5", "pinia": "^2.2.6", "tdesign-icons-vue-next": "^0.3.3", "tdesign-vue-next": "^1.10.3", diff --git a/src/main/api/f2f.js b/src/main/api/f2f.js index 30cfe33..1720ead 100644 --- a/src/main/api/f2f.js +++ b/src/main/api/f2f.js @@ -4,11 +4,11 @@ import log from '../logger.js' export function makeVideo(param) { log.debug('~ makeVideo ~ param:', JSON.stringify(param)) - return request.post(`${serviceUrl.face2face}/submit`, param) + return request.post(`${serviceUrl().face2face}/submit`, param) } export function getVideoStatus(taskCode) { - return request.get(`${serviceUrl.face2face}/query?code=${taskCode}`).then((res) => { + return request.get(`${serviceUrl().face2face}/query?code=${taskCode}`).then((res) => { log.debug('~ getVideoStatus ~ res:', JSON.stringify(res)) return res }) diff --git a/src/main/api/tts.js b/src/main/api/tts.js index 45013f8..0bdf489 100644 --- a/src/main/api/tts.js +++ b/src/main/api/tts.js @@ -4,12 +4,12 @@ import log from '../logger.js' export function makeAudio(param) { log.debug('~ makeAudio ~ param:', JSON.stringify(param)) - return request.post(`${serviceUrl.tts}/v1/invoke`, param, { + return request.post(`${serviceUrl().tts}/v1/invoke`, param, { responseType: 'arraybuffer' }) } export function preprocessAndTran(param) { log.debug('~ preprocessAndTran ~ param:', JSON.stringify(param)) - return request.post(`${serviceUrl.tts}/v1/preprocess_and_tran`, param) + return request.post(`${serviceUrl().tts}/v1/preprocess_and_tran`, param) } diff --git a/src/main/config/config.js b/src/main/config/config.js index 8037bfb..1f3526e 100644 --- a/src/main/config/config.js +++ b/src/main/config/config.js @@ -1,15 +1,17 @@ import path from 'path' import os from 'os' +import { getSettingByGroup } from '../service/setting' +// import { set } from 'lodash-es' const isDev = process.env.NODE_ENV === 'development' const isWin = process.platform === 'win32' -export const serviceUrl = { +const defaultServiceUrl = { face2face: isDev ? 'http://192.168.4.204:8383/easy' : 'http://127.0.0.1:8383/easy', tts: isDev ? 'http://192.168.4.204:18180' : 'http://127.0.0.1:18180' } -export const assetPath = { +const defaultAssetPath = { model: isWin ? path.join('D:', 'heygem_data', 'face2face', 'temp') : path.join(os.homedir(), 'heygem_data', 'face2face', 'temp'), // 模特视频 @@ -23,3 +25,36 @@ export const assetPath = { ? path.join('D:', 'heygem_data', 'voice', 'data', 'origin_audio') : path.join(os.homedir(), 'heygem_data', 'voice', 'data', 'origin_audio') // TTS 训练产物 } + + + +function loadConfig() { + let _serviceUrl = { ...defaultServiceUrl } + let _assetPath = { ...defaultAssetPath } + const systemSetting = getSettingByGroup('system') + if (systemSetting) { + systemSetting.forEach((item) => { + console.log('item.value', item.value, item.key, _serviceUrl.hasOwnProperty(item.key)) + const k = item.key.replace('Url', '').replace('Path', '') + if(_serviceUrl.hasOwnProperty(k) && item.value) { + _serviceUrl[k] = item.value + } + if(_assetPath.hasOwnProperty(k) && item.value) { + _assetPath[k] = item.value + } + }) + } + + return { + _serviceUrl, + _assetPath + } +} + +export function serviceUrl() { + return loadConfig()._serviceUrl +} + +export function assetPath() { + return loadConfig()._assetPath +} \ No newline at end of file diff --git a/src/main/handlers/file.js b/src/main/handlers/file.js index 277d074..4065828 100644 --- a/src/main/handlers/file.js +++ b/src/main/handlers/file.js @@ -1,6 +1,7 @@ -import { dialog } from "electron" +import { dialog, ipcRenderer } from "electron" import ffmpeg from 'fluent-ffmpeg' import path from 'path' +import { Minio } from 'minio' export default { name: 'file', @@ -24,6 +25,36 @@ export default { defaultPath }) if (!result.canceled) { + + const minioConfig = await ipcRenderer.invoke('setting/getByGroup', 'minio') + console.log('minioConfig', minioConfig) + + if (minioConfig.enabled == 'true') { + // 创建 MinIO 客户端 + const minioClient = new Minio.Client(minioConfig) + + try { + // 生成唯一的文件名 + const fileName = path.basename(result.filePath) + const objectName = `${Date.now()}-${fileName}` + + // 上传文件到 MinIO + await minioClient.fPutObject( + minioConfig.bucket, + objectName, + result.filePath, + { 'Content-Type': 'application/octet-stream' } + ) + + // 返回 MinIO 中的文件路径 + return `minio://${minioConfig.bucket}/${objectName}` + } catch (err) { + console.error('Error uploading to MinIO:', err) + throw err + } + } + + return result.filePath } }, diff --git a/src/main/service/model.js b/src/main/service/model.js index 3129d35..f48bf75 100644 --- a/src/main/service/model.js +++ b/src/main/service/model.js @@ -17,28 +17,29 @@ const MODEL_NAME = 'model' * @returns */ function addModel(modelName, videoPath) { - if (!fs.existsSync(assetPath.model)) { - fs.mkdirSync(assetPath.model, { + if (!fs.existsSync(assetPath().model)) { + fs.mkdirSync(assetPath().model, { recursive: true }) } + console.log('modelPath', assetPath.model) // copy video to model video path const extname = path.extname(videoPath) const modelFileName = dayjs().format('YYYYMMDDHHmmssSSS') + extname - const modelPath = path.join(assetPath.model, modelFileName) + const modelPath = path.join(assetPath().model, modelFileName) fs.copyFileSync(videoPath, modelPath) // 用ffmpeg分离音频 - if (!fs.existsSync(assetPath.ttsTrain)) { - fs.mkdirSync(assetPath.ttsTrain, { + if (!fs.existsSync(assetPath().ttsTrain)) { + fs.mkdirSync(assetPath().ttsTrain, { recursive: true }) } - const audioPath = path.join(assetPath.ttsTrain, modelFileName.replace(extname, '.wav')) + const audioPath = path.join(assetPath().ttsTrain, modelFileName.replace(extname, '.wav')) return extractAudio(modelPath, audioPath).then(() => { // 训练语音模型 - const relativeAudioPath = path.relative(assetPath.ttsRoot, audioPath) + const relativeAudioPath = path.relative(assetPath().ttsRoot, audioPath) if (process.env.NODE_ENV === 'development') { // TODO 写死调试 return trainVoice('origin_audio/test.wav', 'zh') @@ -47,8 +48,8 @@ function addModel(modelName, videoPath) { } }).then((voiceId)=>{ // 插入模特信息 - const relativeModelPath = path.relative(assetPath.model, modelPath) - const relativeAudioPath = path.relative(assetPath.ttsRoot, audioPath) + const relativeModelPath = path.relative(assetPath().model, modelPath) + const relativeAudioPath = path.relative(assetPath().ttsRoot, audioPath) // insert model info to db const id = insert({ modelName, videoPath: relativeModelPath, audioPath: relativeAudioPath, voiceId }) @@ -57,13 +58,14 @@ function addModel(modelName, videoPath) { } function page({ page, pageSize, name = '' }) { + console.log('~ page ~:', assetPath()) const total = count(name) return { total, list: selectPage({ page, pageSize, name }).map((model) => ({ ...model, - video_path: path.join(assetPath.model, model.video_path), - audio_path: path.join(assetPath.ttsRoot, model.audio_path) + video_path: path.join(assetPath().model, model.video_path), + audio_path: path.join(assetPath().ttsRoot, model.audio_path) })) } } @@ -72,8 +74,8 @@ function findModel(modelId) { const model = selectByID(modelId) return { ...model, - video_path: path.join(assetPath.model, model.video_path), - audio_path: path.join(assetPath.ttsRoot, model.audio_path) + video_path: path.join(assetPath().model, model.video_path), + audio_path: path.join(assetPath().ttsRoot, model.audio_path) } } @@ -82,13 +84,13 @@ function removeModel(modelId) { log.debug('~ removeModel ~ modelId:', modelId) // 删除视频 - const videoPath = path.join(assetPath.model, model.video_path ||'') + const videoPath = path.join(assetPath().model, model.video_path ||'') if (!isEmpty(model.video_path) && fs.existsSync(videoPath)) { fs.unlinkSync(videoPath) } // 删除音频 - const audioPath = path.join(assetPath.ttsRoot, model.audio_path ||'') + const audioPath = path.join(assetPath().ttsRoot, model.audio_path ||'') if (!isEmpty(model.audio_path) && fs.existsSync(audioPath)) { fs.unlinkSync(audioPath) } diff --git a/src/main/service/setting.js b/src/main/service/setting.js index 774f0c2..36fa330 100644 --- a/src/main/service/setting.js +++ b/src/main/service/setting.js @@ -43,6 +43,42 @@ export function getAllSettings() { // 默认设置数据 const DEFAULT_SETTINGS = [ + { + group_name: SETTING_GROUPS.SYSTEM, + key: 'face2faceUrl', + value: 'http://127.0.0.1:8383/easy', + label: 'Face2Face 服务地址' + }, + { + group_name: SETTING_GROUPS.SYSTEM, + key: 'ttsUrl', + value: 'http://127.0.0.1:18180', + label: 'TTS 服务地址' + }, + { + group_name: SETTING_GROUPS.SYSTEM, + key: 'modelPath', + value: '', + label: '模型路径' + }, + { + group_name: SETTING_GROUPS.SYSTEM, + key: 'ttsProductPath', + value: '', + label: 'TTS 产物路径' + }, + { + group_name: SETTING_GROUPS.SYSTEM, + key: 'ttsRootPath', + value: '', + label: 'TTS 根路径' + }, + { + group_name: SETTING_GROUPS.SYSTEM, + key: 'ttsTrainPath', + value: '', + label: 'TTS 训练路径' + }, { group_name: SETTING_GROUPS.MINION, key: 'enabled', @@ -72,6 +108,12 @@ const DEFAULT_SETTINGS = [ key: 'secretKey', value: '', label: '秘密密钥' + }, + { + group_name: SETTING_GROUPS.MINION, + key: 'bucket', + value: '', + label: '存储桶' } ] @@ -85,6 +127,8 @@ export function init() { } ipcMain.handle(MODEL_NAME + '/save', (event, ...args) => { + + console.log('saveSetting args', ...args) return saveSetting(...args) }) ipcMain.handle(MODEL_NAME + '/getByGroup', (event, ...args) => { diff --git a/src/main/service/video.js b/src/main/service/video.js index 19bc2c9..b0c3c88 100644 --- a/src/main/service/video.js +++ b/src/main/service/video.js @@ -33,7 +33,7 @@ function page({ page, pageSize, name = '' }) { const list = selectPage({ page, pageSize, name }).map((video) => { video = { ...video, - file_path: video.file_path ? path.join(assetPath.model, video.file_path) : video.file_path + file_path: video.file_path ? path.join(assetPath().model, video.file_path) : video.file_path } if(video.status === 'waiting'){ @@ -52,7 +52,7 @@ function findVideo(videoId) { const video = selectVideoByID(videoId) return { ...video, - file_path: video.file_path ? path.join(assetPath.model, video.file_path) : video.file_path + file_path: video.file_path ? path.join(assetPath().model, video.file_path) : video.file_path } } @@ -188,7 +188,7 @@ export async function loopPending() { if(process.env.NODE_ENV === 'development'){ duration = 88 }else{ - const resultPath = path.join(assetPath.model, statusRes.data.result) + const resultPath = path.join(assetPath().model, statusRes.data.result) duration = await getVideoDuration(resultPath) } @@ -229,13 +229,13 @@ function removeVideo(videoId) { log.debug('~ removeVideo ~ videoId:', videoId) // 删除视频 - const videoPath = path.join(assetPath.model, video.file_path ||'') + const videoPath = path.join(assetPath().model, video.file_path ||'') if (!isEmpty(video.file_path) && fs.existsSync(videoPath)) { fs.unlinkSync(videoPath) } // 删除音频 - const audioPath = path.join(assetPath.model, video.audio_path ||'') + const audioPath = path.join(assetPath().model, video.audio_path ||'') if (!isEmpty(video.audio_path) && fs.existsSync(audioPath)) { fs.unlinkSync(audioPath) } @@ -246,7 +246,7 @@ function removeVideo(videoId) { function exportVideo(videoId, outputPath) { const video = selectVideoByID(videoId) - const filePath = path.join(assetPath.model, video.file_path) + const filePath = path.join(assetPath().model, video.file_path) fs.copyFileSync(filePath, outputPath) } diff --git a/src/renderer/src/views/setting/index.vue b/src/renderer/src/views/setting/index.vue index 7583e04..a3daadd 100644 --- a/src/renderer/src/views/setting/index.vue +++ b/src/renderer/src/views/setting/index.vue @@ -22,7 +22,7 @@ 新增配置 - +