|
|
@@ -1,4 +1,7 @@
|
|
|
import { GET,POST } from "@/utils/http";
|
|
|
+import client from "@/stores/modules/client";
|
|
|
+import icpList from '@/utils/ipc'
|
|
|
+import tokenInfo from '@/stores/modules/token';
|
|
|
|
|
|
//获取配置
|
|
|
export async function getAllUserConfigs(data){
|
|
|
@@ -9,8 +12,22 @@ export async function getAllUserConfigs(data){
|
|
|
|
|
|
//更新配置
|
|
|
export async function setAllUserConfigs(data){
|
|
|
- return POST('/api/ai_image/camera_machine/update_all_user_configs',data)
|
|
|
-
|
|
|
+ const result = await POST('/api/ai_image/camera_machine/update_all_user_configs',data);
|
|
|
+
|
|
|
+ // 同步到Python
|
|
|
+ try {
|
|
|
+ const clientStore = client();
|
|
|
+ const tokenInfoStore = tokenInfo();
|
|
|
+ const token = tokenInfoStore.getToken;
|
|
|
+ await clientStore.ipc.invoke(icpList.setting.syncSysConfigs, {
|
|
|
+ token: token || ''
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.error('同步系统配置到Python失败:', error);
|
|
|
+ // 同步失败不影响主流程
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -31,28 +48,93 @@ export async function getDeviceConfigs(data){
|
|
|
|
|
|
//点击切换执行配置
|
|
|
export async function setLeftRightConfig(data){
|
|
|
- return POST('/api/ai_image/camera_machine/update_left_right_config',data)
|
|
|
-
|
|
|
+ const result = await POST('/api/ai_image/camera_machine/update_left_right_config',data);
|
|
|
+
|
|
|
+ // 同步到Python
|
|
|
+ try {
|
|
|
+ const clientStore = client();
|
|
|
+ const tokenInfoStore = tokenInfo();
|
|
|
+ const token = tokenInfoStore.getToken;
|
|
|
+ await clientStore.ipc.invoke(icpList.setting.syncActions, {
|
|
|
+ token: token || '',
|
|
|
+ action: 'update',
|
|
|
+ data: data
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.error('同步左右脚配置到Python失败:', error);
|
|
|
+ // 同步失败不影响主流程
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
//重置配置
|
|
|
export async function restConfig(data){
|
|
|
- return POST('/api/ai_image/camera_machine/reset_config',data)
|
|
|
-
|
|
|
+ const result = await POST('/api/ai_image/camera_machine/reset_config',data);
|
|
|
+
|
|
|
+ // 同步到Python
|
|
|
+ try {
|
|
|
+ const clientStore = client();
|
|
|
+ const tokenInfoStore = tokenInfo();
|
|
|
+ const token = tokenInfoStore.getToken;
|
|
|
+ await clientStore.ipc.invoke(icpList.setting.syncActions, {
|
|
|
+ token: token || '',
|
|
|
+ action: 'reset',
|
|
|
+ tab_id: data.tab_id
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.error('同步重置配置到Python失败:', error);
|
|
|
+ // 同步失败不影响主流程
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
//更新顶部TOP
|
|
|
export async function setTabName(data){
|
|
|
- return POST('/api/ai_image/camera_machine/update_tab_name',data)
|
|
|
-
|
|
|
+ const result = await POST('/api/ai_image/camera_machine/update_tab_name',data);
|
|
|
+
|
|
|
+ // 同步到Python
|
|
|
+ try {
|
|
|
+ const clientStore = client();
|
|
|
+ const tokenInfoStore = tokenInfo();
|
|
|
+ const token = tokenInfoStore.getToken;
|
|
|
+ await clientStore.ipc.invoke(icpList.setting.syncActions, {
|
|
|
+ token: token || '',
|
|
|
+ action: 'rename',
|
|
|
+ id: data.id,
|
|
|
+ mode_name: data.mode_name
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.error('同步重命名配置到Python失败:', error);
|
|
|
+ // 同步失败不影响主流程
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
//删除可执行命令
|
|
|
export async function delDviceConfig(data){
|
|
|
- return POST('/api/ai_image/camera_machine/remove_device_config',data)
|
|
|
-
|
|
|
+ const result = await POST('/api/ai_image/camera_machine/remove_device_config',data);
|
|
|
+
|
|
|
+ // 同步到Python
|
|
|
+ try {
|
|
|
+ const clientStore = client();
|
|
|
+ const tokenInfoStore = tokenInfo();
|
|
|
+ const token = tokenInfoStore.getToken;
|
|
|
+ await clientStore.ipc.invoke(icpList.setting.syncActions, {
|
|
|
+ token: token || '',
|
|
|
+ action: 'delete',
|
|
|
+ id: data.id
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.error('同步删除配置到Python失败:', error);
|
|
|
+ // 同步失败不影响主流程
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -74,7 +156,46 @@ export async function getDeviceConfigDetailQuery(data){
|
|
|
|
|
|
//创建或者保存动作
|
|
|
export async function saveDeviceConfig(data){
|
|
|
- return POST('/api/ai_image/camera_machine/save_device_config',data)
|
|
|
+ const result = await POST('/api/ai_image/camera_machine/save_device_config',data);
|
|
|
+
|
|
|
+ // 同步到Python
|
|
|
+ try {
|
|
|
+ const clientStore = client();
|
|
|
+ const tokenInfoStore = tokenInfo();
|
|
|
+ const token = tokenInfoStore.getToken;
|
|
|
+ await clientStore.ipc.invoke(icpList.setting.syncActions, {
|
|
|
+ token: token || '',
|
|
|
+ action: 'save',
|
|
|
+ data: data
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.error('同步保存配置到Python失败:', error);
|
|
|
+ // 同步失败不影响主流程
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+}
|
|
|
|
|
|
+// 登录后同步数据
|
|
|
+export async function syncAfterLogin(token: string) {
|
|
|
+ try {
|
|
|
+ const clientStore = client();
|
|
|
+ // 同步系统配置
|
|
|
+ await clientStore.ipc.invoke(icpList.setting.syncSysConfigs, {
|
|
|
+ token: token
|
|
|
+ });
|
|
|
+
|
|
|
+ // 同步动作配置
|
|
|
+ await clientStore.ipc.invoke(icpList.setting.syncActions, {
|
|
|
+ token: token,
|
|
|
+ action: 'sync_all'
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log('登录后数据同步成功');
|
|
|
+ } catch (error) {
|
|
|
+ console.error('登录后数据同步失败:', error);
|
|
|
+ // 同步失败不影响登录流程
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|