blivechat/frontend/src/main.js

107 lines
2.5 KiB
JavaScript
Raw Normal View History

2019-05-21 19:15:12 +08:00
import Vue from 'vue'
import VueRouter from 'vue-router'
2020-02-22 17:21:47 +08:00
import {
2022-02-27 14:45:19 +08:00
Aside, Autocomplete, Badge, Button, ButtonGroup, Card, Col, ColorPicker, Container, Divider, Form, FormItem, Image,
2021-03-07 14:40:58 +08:00
Input, Main, Menu, MenuItem, Message, Option, OptionGroup, Radio, RadioGroup, Row, Select, Scrollbar,
2022-02-27 14:45:19 +08:00
Slider, Submenu, Switch, Table, TableColumn, TabPane, Tabs, Tooltip
2020-02-22 17:21:47 +08:00
} from 'element-ui'
2019-06-12 13:55:49 +08:00
import axios from 'axios'
2019-05-21 19:15:12 +08:00
2022-02-26 14:53:22 +08:00
import * as i18n from './i18n'
2022-02-25 22:42:50 +08:00
import App from './App'
2019-06-11 12:51:25 +08:00
import Layout from './layout'
2022-02-25 22:42:50 +08:00
import Home from './views/Home'
2019-06-16 23:04:30 +08:00
import StyleGenerator from './views/StyleGenerator'
2019-12-16 23:40:01 +08:00
import Help from './views/Help'
2022-02-25 22:42:50 +08:00
import Room from './views/Room'
import NotFound from './views/NotFound'
2019-07-08 11:42:35 +08:00
2021-03-28 18:30:31 +08:00
axios.defaults.timeout = 10 * 1000
2019-06-12 13:55:49 +08:00
2019-05-21 19:15:12 +08:00
Vue.use(VueRouter)
2020-02-22 17:21:47 +08:00
// 初始化element
Vue.use(Aside)
Vue.use(Autocomplete)
Vue.use(Badge)
Vue.use(Button)
2022-02-27 14:45:19 +08:00
Vue.use(ButtonGroup)
2021-03-07 14:40:58 +08:00
Vue.use(Card)
2020-02-22 17:21:47 +08:00
Vue.use(Col)
Vue.use(ColorPicker)
Vue.use(Container)
Vue.use(Divider)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Image)
Vue.use(Input)
Vue.use(Main)
Vue.use(Menu)
Vue.use(MenuItem)
2021-03-07 14:40:58 +08:00
Vue.use(Option)
Vue.use(OptionGroup)
2020-11-28 21:53:49 +08:00
Vue.use(Radio)
Vue.use(RadioGroup)
2020-02-22 17:21:47 +08:00
Vue.use(Row)
2021-03-07 14:40:58 +08:00
Vue.use(Select)
2020-02-22 17:21:47 +08:00
Vue.use(Scrollbar)
Vue.use(Slider)
Vue.use(Submenu)
Vue.use(Switch)
2022-02-27 14:45:19 +08:00
Vue.use(Table)
Vue.use(TableColumn)
2020-02-22 17:21:47 +08:00
Vue.use(TabPane)
Vue.use(Tabs)
Vue.use(Tooltip)
Vue.prototype.$message = Message
2019-05-21 19:15:12 +08:00
2019-06-09 12:37:59 +08:00
Vue.config.ignoredElements = [
/^yt-/
]
2019-05-21 19:15:12 +08:00
const router = new VueRouter({
mode: 'history',
routes: [
2019-06-11 12:51:25 +08:00
{
path: '/',
component: Layout,
children: [
2023-09-10 10:39:02 +08:00
{ path: '', name: 'home', component: Home },
2022-01-04 21:41:12 +08:00
{ path: 'stylegen', name: 'stylegen', component: StyleGenerator },
{ path: 'help', name: 'help', component: Help }
2019-06-11 12:51:25 +08:00
]
},
2022-02-26 14:53:22 +08:00
{
path: '/room/test',
name: 'test_room',
component: Room,
props: route => ({ strConfig: route.query })
},
2021-04-05 18:48:49 +08:00
{
2023-09-09 17:13:53 +08:00
path: '/room/:roomKeyValue',
2021-04-05 18:48:49 +08:00
name: 'room',
component: Room,
props(route) {
2023-09-09 17:13:53 +08:00
let roomKeyType = parseInt(route.query.roomKeyType) || 1
if (roomKeyType < 1 || roomKeyType > 2) {
roomKeyType = 1
2021-04-05 18:48:49 +08:00
}
2023-09-09 17:13:53 +08:00
let roomKeyValue = route.params.roomKeyValue
if (roomKeyType === 1) {
roomKeyValue = parseInt(roomKeyValue) || null
} else {
roomKeyValue = roomKeyValue || null
}
return { roomKeyType, roomKeyValue, strConfig: route.query }
2021-04-05 18:48:49 +08:00
}
},
2022-01-04 21:41:12 +08:00
{ path: '*', component: NotFound }
2019-05-21 19:15:12 +08:00
]
})
new Vue({
render: h => h(App),
2019-07-08 11:42:35 +08:00
router,
2022-02-26 14:53:22 +08:00
i18n: i18n.i18n
2019-05-21 19:15:12 +08:00
}).$mount('#app')