auto-launch');
const nativeImg=electron.nativeImage;


let mainWindow = null;
let tray=null;
let webContents = null;

//let appAutoLauncher=new AutoLaunch({
//  name:'QMB'//this is the app name.
//  //,path:app.getAppPath()
//});
//appAutoLauncher.isEnabled((enabled)=>{
//  if(enabled){return;}
//appAutoLauncher.enable((err)=>{
//  if(err){
//  SystemLoger(err);
//  //throw(err);
//}
//});
//});

app.on('window-all-closed', function() {
  if (process.platform!= 'darwin') {
    app.quit();
  }
});
app.on('ready', function() {
  InitWin();
  initAppTray();
  ipc.on('win-show', function (ev,obj) {
    mainWindow.show();
    tray.setHighlightMode('selection')
  });
  ipc.on('win-exit', function () {
    app.exit(0);
  });
  ipc.on('win-min', function () {
    mainWindow.minimize();
  });
  ipc.on('win-max', function () {
    if (mainWindow.isMaximized()) {
      mainWindow.unmaximize();
    }else{
      mainWindow.maximize();
    }
  });
  ipc.on('app-logout',function(){
    mainWindow.loadURL('file://' + __dirname + '/Views/login.html');
  });
  ipc.on('tray-removed', function () {
    app.exit(0);
    tray.destroy();
  });
  ipc.on('im-msg',function(ev,obj){
    const iconPath=path.join(__dirname,'Images/lookme.jpg');//图标必须为本地资源
    var bloon={icon:obj.Img,title:obj.sender,content:obj.text};
    tray.displayBalloon(bloon);//冒泡提示
    //tray.getBounds();
  });

});
//实例化应用角标：
function initAppTray(){
  const iconPath=path.join(__dirname,'Images/Appx.png');
  tray=new Tray(iconPath);
  const contextMenu=Menu.buildFromTemplate([{
    label:'退出',
    click:function(){
      app.exit(0);
      tray.destroy();
    }
    },
      {label:'在线',type:'radio',checked:true},
      {label:'隐身',type:'radio'},
      {label:'离线',type:'radio'}
  ]);
  tray.setToolTip('我的圈圈');
  tray.setContextMenu(contextMenu);
  tray.on('click',()=>{
    mainWindow.isVisible()?mainWindow.hide():mainWindow.show();
  });
  tray.on('show',()=>{
    tray.setHighlightMode('always');
  });
  tray.on('hide',()=>{
    tray.setHighlightMode('never');
  });
  tray.on('balloon-click',function(obj){
    var bbool=obj.getBounds();
    mainWindow.webContents.send('balloon-clk',bbool);
  });

}
//单例模式：
function makeSingleInstance () {
  if (process.mas) return false
  return app.makeSingleInstance(function () {
    if (mainWindow) {
      if (mainWindow.isMinimized()) mainWindow.restore()
      mainWindow.focus()
    }
  })
}
//实例化窗体：
function InitWin(){
  try{
    makeSingleInstance();
    // Create the browser window.
    var windowOptions = {
      width:900,
      height:700,
      minWidth:900,
      minHeight:700,
      //icon:'Images/Appx.png',
      //title: app.getName(),
      //resizable:false,
      hasShadow:true,
      transparent:false,
      frame:false
      //webPreferences:{nodeIntegration:false}
    }

    mainWindow = new BrowserWindow(windowOptions);

    mainWindow.loadURL('file://' + __dirname + '/Views/login.html');
    webContents=mainWindow.webContents;

    webContents.openDevTools();//显示调试工具

    mainWindow.on('closed', function() {
      mainWindow = null;
    });
    //By:joney.
    mainWindow.on('resize', function() {
      var winSize = mainWindow.getSize();
      webContents.send('resetIMFrame', winSize + '');
    })
    //By:joney.
    webContents.on('did-finish-load', function() {
      var winSize = mainWindow.getSize();
      webContents.send('resetIMFrame', winSize + '');
    });
    webContents.on('did-finish-load',function(){
      webContents.send('ping', '欢迎使用我的圈圈办公助手');
    });
  }catch(ex){
    SystemLoger(ex);
  }
}

//系统日志：BY Joney.
function SystemLoger(msgInfo){
  try{
    var filePath=path.join(__dirname,'/log/runninglog.log');
    fs.exists(filePath,(exists)=>{
      if(!exists){
      fs.mkdir(path.join(__dirname,'/log'),(err)=>{});
    }
  });
  if(true){
    var logInfo='\r\n'+new Date().toString()+'\r\n----------'+msgInfo;
    fs.appendFile(filePath,logInfo,'utf8',function(err){
      //if(err){throw err;}
    });
  }else{
    fs.readFileSync(path.join(__dirname,'runninglog'),'utf8',function(err,data){
      //if(err){throw err;}
    });
  }
}catch(ex){
  throw ex;
}
}


Shirts were terrible thin quality. Did not last. Prints were still sticky even after repeated washes. Sticky enough to stick to itself and pull bits of the print off the shirt. Customer service was terrible and liars. Were not willing to refund me if I returned the shirts, only offered to send me double the shirts. Said they'd do that for free and I figured fine, I guess that's better than nothing. But then they charged me for them. Plus shipping and duty. When you add that to how little they charge their artists? Absolutely not worth it; they should be ashamed!
Ordered the CSGO medal, firstly the delivery address they messed up because it was completely different to my order address as they forgot the postcode and only used the road address. Delivered to somewhere completely different. Fair enough they admitted to it and sent a replacement, which again they sent to the wrong address due to forgetting the first part of my postcode so this one actually got lost. Then finally got this one after the Post Office tracked me down only to slap a £10 payment on top because of all the mess up and also because they didn't put that this is a gift....
Ordered a few products to Spain and had to pay basically 50% in fees!!! What the $#*!ing heck!
I've never paid any kind of fees when ordering stuff from abroad in all of my life. Never buying from them again.
Ordered a jacket in medium size, and in the descriptions and reviews of said jacket, everyone said that the sizes ran large. When the jacket came, it was too small. Had emailed support to see if I could do an exchange for another size up and then I was informed that "due to recent changes to the website, exchanges are not being done at this time". I must return the jacket, pay the $12.50 in shipping cost again, wait for the money to be refunded to my bank account, and then have to do the ENTIRE PROCESS all over again. Unfortunately this is terribly inconvenient as I have to have the new jacket in my posession by October 31st.
Tried to order CS:GO Pins from their website but I couldn't due to high traffic. A friend had notified me the website was working again so I wanted to order but I noticed they had doubled the price from $10.00 to $20.00. No one should trust this company.
I ordered three shirts from them. There was nothing in the sizing to explain that they