import { createApp } from 'vue'
import {
  ActionBar, ActionBarIcon, ActionBarButton, Divider, Popup, Overlay, Loading, Dialog, ContactCard, Form, AddressEdit,
  AddressList, Field, CellGroup, Cell, SwipeCell, Icon, Stepper, Card, Checkbox, CheckboxGroup, Button, Swipe, SwipeItem,
  PullRefresh, List, Tab, Tabs, SubmitBar, Toast, Skeleton, RadioGroup, Radio, NoticeBar, ActionSheet, Cascader, Col, Row,
  Slider, DatetimePicker, Switch, Calendar, Picker, Uploader } from 'vant';
import { Image as VanImage } from 'vant';
import App from './App.vue'
import store from './store'
import router from './router'
import 'lib-flexible/flexible'
import 'vant/lib/index.css'; // 全局引入样式
// import VueI18n from 'vue-i18n'
import { createI18n } from 'vue-i18n';
import { navigatorLanguage } from './common/js/utils';
import '@vant/touch-emulator';

const app = createApp(App) // 创建实例

//多语言实例
const i18n = createI18n({
  // 默认语言
  locale: navigatorLanguage(),
  // 关闭控制台警告
  silentFallbackWarn: true,
  messages:{
    'en':require('./assets/language/en.json'), //英文包
    'zh':require('./assets/language/zh.json'), //中文包
  }
});

// 全局过滤器
app.config.globalProperties.$filters = {
  prefix(url) {
    if (url && url.startsWith('http')) {
      return url
    } else {
      url = `http://backend-api-01.newbee.ltd${url}`
      return url
    }
  }
}
// Vant组件注册
app.use(ActionBarButton)
  .use(ActionBarIcon)
  .use(ActionBar)
  .use(Divider)
  .use(Popup)
  .use(Overlay)
  .use(Loading)
  .use(Dialog)
  .use(Toast)
  .use(ContactCard)
  .use(Form)
  .use(AddressEdit)
  .use(AddressList)
  .use(Field)
  .use(CellGroup)
  .use(Cell)
  .use(SwipeCell)
  .use(Icon)
  .use(Stepper)
  .use(Card)
  .use(Button)
  .use(Swipe)
  .use(SwipeItem)
  .use(PullRefresh)
  .use(List)
  .use(Tab)
  .use(Tabs)
  .use(SubmitBar)
  .use(Checkbox)
  .use(CheckboxGroup)
  .use(Skeleton)
  .use(VanImage)
  .use(RadioGroup)
  .use(Radio)
  .use(NoticeBar)
  .use(ActionSheet)
  .use(Cascader)
  .use(Col)
  .use(Row)
  .use(Slider)
  .use(DatetimePicker)
  .use(Switch)
  .use(Calendar)
  .use(Picker)
  .use(Uploader)

app.use(router)
app.use(store)

app.use(i18n)

app.mount('#app')