/** @format */

import { http } from '/nerv-lib/saas';
import { ref } from 'vue';

const value = ref('1');
const transform = (data, map) => {
  return Object.keys(map).reduce((pre, cur) => {
    pre[cur] = data[map[cur]];
    return pre;
  }, {});
};
export const appConfig = {
  projectType: 'web',
  projectName: '济阳站_AI智能BAS系统',
  baseApi: '/api',
  enablePermissions: false,
  // themeColor: '#eee',
  siderPosition: 'left',
  baseHeader: '/parkingManage',
  baseRouter: '/parkingManage/parkingLotManage',
  themeConfig: {
    logoLessUrl: `${import.meta.env.VITE_PUBLIC_PATH}/asset/image/headerIcon.png`,
    bgImageUrl: `${import.meta.env.VITE_PUBLIC_PATH}/asset/image/login/background.png`,
  },
  // userCustomRouterGuard: (to, from, next, whiteNameList, authorizationStore, appConfig) => {
  //   console.log({ to, from, next, whiteNameList, authorizationStore, appConfig }, 'routeConfig');
  //   next();
  // },

  // customUpdatePwd: () => import('/@/view/updatePassword/updatePassword.vue'),

  // userInfoApi: () => {
  //   return {
  //     code: 200,
  //     success: true,
  //     data: {
  //       accountCode: '1305107806187376793',
  //       accountName: 'adm*n',
  //       accountType: 'admin',
  //       accountStatus: 1,
  //       accountRealName: 'admin',
  //       organizationCode: 'dingcloud',
  //       authConfigList: [],
  //       organizeResCode: [],
  //       leadDepartmentUuidList: [],
  //     },
  //   };
  // },

  // headerSlotConfig: {
  //   component: 'NsSelect',
  //   componentProps: {
  //     style: { width: '200px' },
  //     placeholder: '请选择',
  //     value,
  //     onChange: (cur) => {
  //       value.value = cur;
  //     },
  //     options: [
  //       { label: '济阳', value: '1' },
  //       { label: '临沂', value: '2' },
  //     ],
  //   },
  // },
  timeout: 60 * 1000,
  userLoginApi: (params) => {
    return http.post('/carbon-smart/user/login', { ...params, operation: true });
  },
  userResourceApi: () => {
    return { data: [] };
  },
  userInfoApi: () => {
    return http.post('/carbon-smart/user/login/logInInfo').then((res) => {
      const info = res.data;
      const trD = transform(info, {
        accountCode: 'userId',
        accountName: 'accountNo',
        accountRealName: 'accountNo',
        orgId: 'orgId',
        orgName: 'orgName',
        projectId: 'projectId',
      });
      return { data: { ...trD } };
    });
  },

  useHistoryTag: false,
  // 修改密码配置
  updatePassWordInfo: {
    title: '修改密码',
    subtitle: 'huaxing管理平台',
    api: '/carbon-smart/api/user/update/password',
  },
  // headerBellInfo: {
  //   isShow: true,
  //   api: '/api/web/objs/bulletin/readCount',
  //   toRouterName: 'NoticeManageIndex',
  // },
  resourceInfo: {
    // application: {
    //   version: '1.1.74',
    //   label: '停车业务平台',
    //   dataScope: {
    //     scopeMode: 0,
    //     scopeType: '',
    //     dataTips: '',
    //   },
    // },
    // api: permission.add,
  },
};
