import cloudbase from '@cloudbase/js-sdk';

const apps = cloudbase.init({
  // env: 'cloud1-6g98iw7i28b01747',
  env: 'honghgaier-5guiffgcf17a2eea',
  traceUser: true
});

const auth = apps.auth({ persistence: 'local' });
let models;
let _;
// 匿名登录
// if (!auth.hasLoginState()) {
//   auth.signInAnonymously().catch(console.error);
// }

if (!auth.hasLoginState()) {
  auth.signIn({
    username: 'admin',
    password: 'Admin1234_'
  }).then(res => {
    console.log('登录 =>', res);
  })
}

  models = apps.models;
  _ = apps.database().command;

export { apps, models, _ };
