| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- 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){
- return GET('/api/ai_image/camera_machine/get_all_user_configs',data)
- }
- //更新配置
- export async function setAllUserConfigs(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;
- }
- //获取左右脚配置
- export async function getTopTabs(data){
- return GET('/api/ai_image/camera_machine/get_top_tabs',data)
- }
- //获取配置下的动作列表
- export async function getDeviceConfigs(data){
- return GET('/api/ai_image/camera_machine/get_device_configs',data)
- }
- //点击切换执行配置
- export async function setLeftRightConfig(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){
- 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){
- 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){
- 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;
- }
- //获取设备配置详情
- export async function getDeviceConfigDetail(data){
- return GET('/api/ai_image/camera_machine/device_config_detail',data)
- }
- //根据条件查询可执行程序-单条
- export async function getDeviceConfigDetailQuery(data){
- return GET('/api/ai_image/camera_machine/device_config_detail_query',data)
- }
- //创建或者保存动作
- export async function saveDeviceConfig(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);
- // 同步失败不影响登录流程
- }
- }
|