import { createApp } from 'vue';
import App from './App.vue';
import store from './store';
import router from './router';
import permission from './utils/permission';
import DictData from '@/components/DictData/index.vue';
import i18n from './i18n';
import installer from './as-needed';
import { iconsInstaller } from '@/components/IconSelect/util';
import { WsConfig, WsPlugin } from '@/plugins/websocket';
import '@/plugins/notification';
import '@/plugins/service-worker';
import 'element-plus/theme-chalk/display.css';
import 'ele-admin-plus/es/style/nprogress.scss';
import './styles/themes/rounded.scss';
import './styles/themes/dark.scss';
import './styles/themes/transparent.scss';
import './styles/index.scss';
import { WS_BASE_URL } from '@/config/setting';

const app = createApp(App);

// WebSocket配置
const websocketConfig: Partial<WsConfig> = {
  url: WS_BASE_URL, // 你的WebSocket服务器地址
  reconnectAttempts: 10,
  reconnectDelay: 5000,
  autoConnect: true // 应用启动时自动连接
};
// 安装WebSocket插件
app.use(WsPlugin, {
  globalConfig: websocketConfig
});

app.use(store);
app.use(router);
app.use(permission);
app.use(i18n);
app.use(installer);
app.use(iconsInstaller);
app.component('DictData', DictData);

app.mount('#app');
