// var root = "http:/.hieap.cn"

//var root = "http://192.168.4.106:7778";
var root = "http://192.168.4.105:7777";
//var root = "http://e51.hieap.cn"
var server = "";
var oauth = "";
 var projectName = "eap5csxm/admin"
//var projectName = "erp/0000212"
//var projectName = "hscm/0000212"
// var projectName = "eapdev/0000221"
// var projectName = "yypt/0000221"
var pName = projectName.split("/")[0];
var user = projectName.split("/")[1];
var deployRoot="/render"
var deployDir = deployRoot+"/"+user;
//登录页url
var loginUrl = root + server + "/index.html?pn=" + pName + "/" + user;
//首页url
var mainPageUrl = root + server + "/main.html?pn=" + pName + "/" + user;
deployDir = "/render";
serverName = server;
if (window._global && window._global.env == 'dev') {
    deployDir = ""
    serverName = ""
    //登录页url
    var loginUrl = location.origin + deployDir + "/project" + "/hivuiLogin/index.html#/";
    //首页url
    var mainPageUrl = location.origin + deployDir + "/project" + "/hivuiMain/index.html#/";
}

var _formatLang = function(str){
    return Vue.prototype.$t(str)
}
var HIVUI_SETTING = {
    //项目名
    projectName: projectName,
    //接口返回消息弹窗模式，默认为消息提示（自动消失），msgBox为消息弹窗（需手动确定关闭）
    //messageType:"msgBox",
    //请求对象
    request: eap.request,
    deployDir: deployDir,
    //服务器域名
    url: root,
    //编辑器脚本路径
    editorResDir: deployDir,
    serverName: serverName,
    //默认服务url
    serverUrl: root + server,
    //授权服务url
    oauth: root + oauth,
    //用户信息
    userInfo: root + server + "/sys/user/detail",
    //自定义登录页url
    //customLoginUrl:"https://www.baidu.com",
    //登录页url
    loginUrl: loginUrl,
    //首页url
    mainPageUrl: mainPageUrl,
    //系统管理url
    sysManageUrl: "http://192.168.4.193:5188",
    //数据保存url
    saveUrl: root + server + "/data/save", //'/data/save',
    //数据查询url
    queryUrl: root + server + "/data/query", //'/data/query',
    //excel导出心跳
    exportExcelHeartbeatUrl:root + server + "/export/dataexcel/status",
    //导入URL
    excelImportUrl: root + server + "/import/exceldata",
    //导出URL
    exportUrl: root + server + "/export/dataexcel",
    exportPathUrl:root + server + "/export/dataexcel/path",
    exportNewUrl:root + server + "/export/dataexcelnew",
    //页面初始化接口
    pageInitUrl: root + server + "/data/page/permit",
    //数据策略url
    policyUrl: root + server + "/data/policy",
    //附件上传url
    upload: root + server + "/file/upload",
    //附件下载url
    download: root + server + "/file/download",
    //附件查看url
    review: root + server + "/file/static/preview",
    //附件上传url
    publicupload: root + server +"/file/public/upload",
    //附件下载url
    publicdownload: root + server +"/file/public/download",
    //附件查看url
    publicreview: root + server +"/file/public/preview",
    //流程信息url
    getFlowInfo: root + server + "/flow/open",
    getApprovalInfo: root + server + "/flow/getApprovalInfo",
    processFlow: root + server + "/flow/processFlow",
    umpireOrder: root + server + "/flow/umpireOrder",
    queryTask: root + server + "/flow/queryTask",
    withdrawtask: root + server + "/flow/withdrawtask",
    taskDiagram: root + server + "/flow/taskDiagram",
    openOrdernumber: root + server + "/flow/openOrdernumber",
    //接口返回消息弹窗模式，默认为消息提示（自动消失），msgBox为消息弹窗（需手动确定关闭）
    messageType:"msgBox",
    //默认查询操作符
    queryOperate: 'like',
    //默认组件配置
    defaultCmp: {
        "DtTable": {
            "allColSort": true,
            "colWidthCount": false
        },
        "DtPushData": {
            //自动暂存
            // "wakeupTempData": true
        },
        "DtDataSet": {
            "autoTrim": true,
            //自动暂存
            // "autoTemporary": true,
            // "saveNewTemporary": false,
            // "temporaryTime": 10000

        },
        "DtToolbar": {
            "buttons": [
                {
                    "kind": "add",
                    // "text": "添加"
                },
                {
                    "kind": "del",
                    // "text": "删除"
                },
                {
                    "kind": "reset",
                    // "text": "取消"
                },
                {
                    "kind": "save",
                    // "text": "保存"
                }
            ]
        }
    },
    //数据返回超时时间
    requestTimeout: 140 * 1000,

    //是否单点登录
    isSingleLogin: false,
    //单点登录页
    singleLoginUrl: "http://192.168.10.241:31020/authcenter/login?service=",
    //单点登出页
    singleLogoutUrl: "http://192.168.10.241:31020/authcenter/logout?service=http://192.168.10.241:31020/authcenter/login?service=" + mainPageUrl,
    // 网格自定义高亮行背景色
    // curRowBg: '#2bdbe2',
}
window.__guid = new Date().valueOf();
//切换布局
function changeLayout(name) {
    window.localStorage.setItem('layout', name);
    window.location.reload();
}
//模板自定义配置
window.customSysCofig = {
    // 邮箱配置
    emailConfig:{
        url:'http://fdmail.fdauto.com:8003/webmail/index.do?osName=windows',
        // iconClass:'icon-mail',
    },
    //默认门户   对应自定义门户功能
    sysSetTabs: [
        {
            title: _formatLang("customSysCfg_taskcenter"),
            id: __guid++,
            close: false,
            url: '#taskCenter',
        },
        {
            title: _formatLang("customSysCfg_mainpage"),
            id: __guid++,
            close: false,
            url:"/eapdev/home/index/func/index.func",
            //type: 'home',
            //actived: true //默认选中
        },
        /*{
            title: "测试哈哈哈",
            id: __guid++,
            url:"http://127.0.0.1:5501/page/index.html",
        }*/
        // ,{
        //     title:'工作台',
        //     id: __guid++,
        //     close:false,
        //     type:'work'
        // }
    ],
    //默认 打开功能
    sysDefTabs: [
        /*{
            id: __guid++,
            title: "主页",
            url: '/eapdev/home/index/func/index.func',
            close: true,
            actived: true,
        },*/
        // {
        //   id: __guid++,
        //   title:"设计",
        //   url:'http://192.168.7.109:9090/#/design',
        //   close:true,
        // },
    ],
    //头部菜单
    sysFuncMenus: {
        /*
        {
            id: __guid++,
            name: '系统管理',
            url: window.HIVUI_SETTING.sysManageUrl + "/?pn=" + window.HIVUI_SETTING.projectName,
            iconClass: 'icon-set-fill',
            target: '_blank',
            type: 'widthToken',
        },
        {
            id: __guid++,
            name: '<font color=red>邮件系统</font>',
            url: 'http://hcmail.histron.cn:8001/webmail/index.do?osName=windows',
            iconClass: 'icon-mail',
            target: '_blank',
        },*/
        // { type: 'split' },
        // {
        //     id: __guid++,
        //     name: _formatLang("customSysCfg_layout"),
        //     type: 'layout',
        //     iconClass: 'icon-user',
        //     children: [
        //         {
        //             id: 'vertical',
        //             name: _formatLang("customSysCfg_updownlayout"),
        //             handler: function () {
        //                 changeLayout(this.id)
        //             }
        //         },
        //         {
        //             id: 'level',
        //             name: _formatLang("customSysCfg_leftrightlayout"),
        //             handler: function () {
        //                 changeLayout(this.id)
        //             }
        //         }
        //     ]
        // },
        // { type: 'split' },
        // {
        //     id: __guid++,
        //     name:  _formatLang("customSysCfg_messagecenter"),
        //     type: 'withNumTips',
        //     iconClass: 'icon-bell',
        //     target: 'tab',
        //     url: '/platf/msg/func/query.func',//消息中心地址
        //     hideNotific:true,//隐藏底部消息通知
        //     numIntervalTime: 1000 * 30,//循环时间，默认30秒
        //     //消息提示文字
        //     messageText: function (res) {
        //         return  _formatLang("customSysCfg_unreadmessage").replace("{}",res.num);
        //     },
        //     //获取未读消息数量
        //     numFunc: function () {
        //         return new Promise((resolve, reject) => {
        //             let param = new eap.dataHelper.Param();
        //             let where = new eap.dataHelper.Where();
        //             let orders = new eap.dataHelper.Orders();
        //             if (window.Scp.User.fuserid) {
        //                 where.eq("freceiver", window.Scp.User.fuserid);
        //             }
        //             where.setPage(1, -1);
        //             param.where = where;
        //             eap.dataHelper.query(
        //                 param,
        //                 "/platf/msg/entity/MsgUnReadBizEntity.xml",
        //             ).then(res => {
        //                 let __data = res.dataPack.rows;
        //                 resolve({
        //                     num: (__data && __data.length > 0) ? __data.length : 0
        //                 });
        //             }).catch(err => {
        //                 reject(err);
        //             });
        //         });
        //     },
        // },
        // { type: 'split' },
        layout:{
            id: __guid++,
            name: eap.lang.get('customSysCfg_layout'),
            type: 'layout',
            iconClass: 'icon-layout',
            children: [
                {
                    id: 'vertical',
                    name: eap.lang.get('customSysCfg_updownlayout'),
                    handler: function () {
                        changeLayout(this.id);
                    }
                },
                {
                    id: 'level',
                    name: eap.lang.get('customSysCfg_leftrightlayout'),
                    handler: function () {
                        changeLayout(this.id);
                    }
                },
                {
                    id: 'concise',
                    name: eap.lang.get('customSysCfg_conciselayout'),
                    handler: function () {
                        changeLayout(this.id);
                    }
                }
            ]
        },
        messagecenter:{
            id: __guid++,
            name: eap.lang.get('customSysCfg_messagecenter'),
            type: 'withNumTips',
            iconClass: 'icon-bell',
            target:'tab',
            url:'/platf/msg/func/query.func',//消息中心地址
            numIntervalTime:1000*30,//循环时间，默认30秒
            //hideNotific:true,//隐藏底部消息通知
            //消息提示文字
            messageText:function(res){
                return  eap.lang.get("customSysCfg_unreadmessage").replace("{0}",res.num);
            },
            //获取未读消息数量
            numFunc:function(){
                return new Promise((resolve, reject) => {
                    let param = new eap.dataHelper.Param();
                    let where = new eap.dataHelper.Where();
                    let orders = new eap.dataHelper.Orders();
                    if (window.Scp.User.fuserid) {
                        where.eq("freceiver", window.Scp.User.fuserid);
                    }
                    where.setPage(1, -1);
                    param.where = where;
                    eap.dataHelper.query(
                        param,
                        "/platf/msg/entity/MsgUnReadBizEntity.xml",
                    ).then(res=>{
                        let __data=res.dataPack.rows;
                        resolve({
                            num: (__data && __data.length > 0) ? __data.length : 0
                        });
                    }).catch(err=>{
                        reject(err);
                    });
                });                 
            },
        },
        itemSort:["|","layout","|","messagecenter","|"],
    },

    //浏览器标签logo
    //favicon: '/' + pName + "/setting/desktop/sysAssets/login_logo/png/1.0.0/login_logo.png",
    //首页加载logo
    sysLoadLogo: {
        src: '/project/setting/desktop/sysAssets/sy_loading/png/1.0.0/sy_loading.png',
        title:  _formatLang("customSysCfg_companyname"),
        hide:true,
    },
    //首页头部logo
    sysLogo: {
        src: '/project/setting/desktop/sysAssets/sy_logo/png/1.0.0/sy_logo.png',
        title: _formatLang("customSysCfg_companyname"),
        // clickHandler:()=>{
        //     alert(123456);
        // }
    },
    //首页左右结构头部logo
    sysLogoHorizon: {
        src: '/project/setting/desktop/sysAssets/sys_logo_horizon/png/1.0.0/sys_logo_horizon.png',
        // title: '闽纺联盟',
        // width:null,
        // height:null,
    },
    //首页mini图标
    MsysLogo: {
        src: '/project/setting/desktop/sysAssets/sy_minLogo/png/1.0.0/sy_minLogo.png',
        title: _formatLang("customSysCfg_companyname")
    },
    //左右布局菜单项文字是否单行显示
    isMenuWordwrap: false,
    hideSettingBtn:false,
    //hideHistoryFuncList:true,
    //是否显示全部功能按钮
    isShowAllFunc:true,
    //登录页配置
    //登录页logo
    loginLogo: "/project/setting/desktop/sysAssets/login_logo/png/1.0.0/login_logo.png",
    //logo高
    loginLogo_h: null,
    //logo宽
    loginLogo_w: null,
    //登录页背景
    loginBgImg: "/project/setting/desktop/sysAssets/login_bg/png/1.0.0/login_bg.png",
    //标题
    //loginTitle:"",
    //版权
    copyright: _formatLang("customSysCfg_copyright")+"<a href='https://beian.miit.gov.cn/'>闽ICP备2021011270号-1</a>",
    leftMenuWidth:200,
    hideRegister:true,
    isPwdLogin:true,
    //是否开启扫码登录
    isScan:true,
    appName:"APP_NAME",
    //默认布局（左右:left、上下:top）
    //layout:"top",
    //app二维码
    // 鼠标移入任意一级菜单项时，该菜单项对应的全部二级子菜单，以下拉形式完整展开；
    useKyMenuStyle:false,
    // 案例
    loginView:{
        scanInit(loginUtil){
            console.log("loginUtil",loginUtil);
            // setScanQrCode(url,param)
            // setToken(token)
            // setScanState({type:0|1,msg:"正在扫码中"})
            // createScanSocket(url,callback)
            const uuid = "549100b0-9c30-42a0-9e06-dbc16ffbc217"
            loginUtil.setScanQrCode("https://e52.hieap.cn/qr/sso-qr?pn=fdszh/0000221",
            {
                "type":"qrLogin",
                "uuid": uuid
            }).then(res=>{
                loginUtil.createScanSocket("wss://e52.hieap.cn/ws/qr/login/pc/fdszh/0000221/"+uuid,()=>{
                   
                })
            })
        },
        async loginClick(loginUtil) {
            // getLoginData({type:"md5"})
            // setToken(token)
            this.loginLoading = true;
            const data = loginUtil.getLoginData(); 
            let username = data.username;
            let password = data.password;
            if(username=='admin'){
                this.defaultLogin(); 
                this.loginLoading =false;
                return;
            }
            if (!window.electron && !isPwdLogin) { 
                this.message.error("只允许在福事通浏览器中登录");
                return;
            }
            let result = await electron.login(username, password)
            if (!result.success) {
                //注册
                if (result.regUrl) {
                    electron.createWindow({
                        windowName: 'window-web',
                        windowTitle: 'fdapply',
                        contentUrl: result.regUrl,
                    })
                } else { 
                    this.message.error(result.message);
                }

            } else {
                let main = await electron.openMain();
                if (main.success) { 
                    console.log(main.url)
                    // window.location = main.url;
                    //return;
                }
            }
            this.loginLoading = false;
        }

    },
    appQRcodeConfig:{
        title:"APP下载",
        QRcode_img:"/project/setting/desktop/sysAssets/login_logo/png/1.0.0/login_logo.png",
        icon:"https://www.baidu.com/favicon.ico",
        icon_width:18
    },
    // appQRcode:"/project/setting/desktop/sysAssets/login_logo/png/1.0.0/login_logo.png",
    // isSinglePage:true,
    //isPageCache:true,
    //layout:"left",

    // 登录状态实时监听ws配置
    loginStatusMonitorWs:{
        enable:true,
        message:"已在其他地方登录，请重新登录！"
    },
    orgBzTpl:"${fbzname}/${fbzid}",
    showChangeLangBtn:false,
    showMiniLogin:false,
    /*thirdParty:[//第三方资源
        {
            type:"js",
            link:"https://vis.hieap.cn/serviceChat.js?operator=admin&groupGuid=FZ-230804-0015",
            callback:()=>{
                alert(123456);
            }
        }
    ],*/
    //leftMenuWidth:300,
    isSelectUserBz:false,
    addLangList:[
        {
            id: __guid++,
            name:"aaaa",
            key:"aaaaa"
        },
    ]
};