-
Notifications
You must be signed in to change notification settings - Fork 553
Expand file tree
/
Copy pathmain.js
More file actions
133 lines (124 loc) · 5.81 KB
/
main.js
File metadata and controls
133 lines (124 loc) · 5.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import Vue from 'vue';
import VueRouter from 'vue-router';
import Resource from 'vue-resource';
import YDUI from '../src/ydui.js';
import Index from './routers/index.vue';
import Button from './routers/button.vue';
import Dialog from './routers/dialog.vue';
import Cell from './routers/cell.vue';
import Grids from './routers/grids.vue';
import Icons from './routers/icons.vue';
import List from './routers/list.vue';
import ListTheme from './routers/list.theme.vue';
import ListInfinitescroll from './routers/list.infinitescroll.vue';
import ListPullRefresh from './routers/list.pullrefresh.vue';
import listCombination from './routers/list.combination.vue';
import Badge from './routers/badge.vue';
import AsideBar from './routers/asidebar.vue';
import TabBar from './routers/tabbar.vue';
import NavBar from './routers/navbar.vue';
import Tab from './routers/tab.vue';
import ScrollTab from './routers/scrolltab.vue';
import ActionSheet from './routers/actionsheet.vue';
import SendCode from './routers/sendcode.vue';
import ProgressBar from './routers/progressbar.vue';
import KeyBoard from './routers/keyboard.vue';
import Slider from './routers/slider.vue';
import Spinner from './routers/spinner.vue';
import CitySelect from './routers/cityselect.vue';
import CountDown from './routers/countdown.vue';
import Rate from './routers/rate.vue';
import Popup from './routers/popup.vue';
import CountUp from './routers/countup.vue';
import RollNotice from './routers/rollnotice.vue';
import Input from './routers/input.vue';
import FlexBox from './routers/flexbox.vue';
import CR from './routers/cr.vue';
import Switch from './routers/switch.vue';
import Radio from './routers/radio.vue';
import CheckBox from './routers/checkbox.vue';
import BackTop from './routers/backtop.vue';
import Accordion from './routers/accordion.vue';
import DateTime from './routers/datetime.vue';
import LightBox from './routers/lightbox.vue';
import TimeLine from './routers/timeline.vue';
import Step from './routers/step.vue';
import CheckList from './routers/checklist.vue';
import Search from './routers/search.vue';
import ScrollNav from './routers/scrollnav.vue';
import Preview from './routers/preview.vue';
import App from './app.vue';
Vue.use(VueRouter);
Vue.use(Resource);
Vue.use(YDUI);
const router = new VueRouter({
routes: [
{path: "*", redirect: "/"},
{path: '/', name: 'index', component: Index},
{path: '/button', name: 'button', component: Button},
{path: '/dialog', name: 'dialog', component: Dialog},
{path: '/cell', name: 'cell', component: Cell},
{path: '/grids', name: 'grids', component: Grids},
{path: '/icons', name: 'icons', component: Icons},
{path: '/list', name: 'list', component: List},
{path: '/list.theme/:id', name: 'list.theme/:id', component: ListTheme},
{path: '/list.infinitescroll', name: 'list.infinitescroll', component: ListInfinitescroll},
{path: '/list.pullrefresh', name: 'list.pullrefresh', component: ListPullRefresh},
{path: '/list.combination', name: 'list.combination', component: listCombination},
{path: '/badge', name: 'badge', component: Badge},
{path: '/asidebar', name: 'asidebar', component: AsideBar},
{path: '/tabbar', name: 'tabbar', component: TabBar},
{path: '/navbar', name: 'navbar', component: NavBar},
{path: '/tab', name: 'tab', component: Tab},
{path: '/scrolltab', name: 'scrolltab', component: ScrollTab},
{path: '/actionsheet', name: 'actionsheet', component: ActionSheet},
{path: '/sendcode', name: 'sendcode', component: SendCode},
{path: '/progressbar', name: 'progressbar', component: ProgressBar},
{path: '/keyboard', name: 'keyboard', component: KeyBoard},
{path: '/slider', name: 'slider', component: Slider},
{path: '/spinner', name: 'spinner', component: Spinner},
{path: '/cityselect', name: 'cityselect', component: CitySelect},
{path: '/countdown', name: 'countdown', component: CountDown},
{path: '/rate', name: 'rate', component: Rate},
{path: '/popup', name: 'popup', component: Popup},
{path: '/countup', name: 'countup', component: CountUp},
{path: '/rollnotice', name: 'rollnotice', component: RollNotice},
{path: '/input', name: 'input', component: Input},
{path: '/flexbox', name: 'flexbox', component: FlexBox},
{path: '/cr', name: 'C&R', component: CR},
{path: '/switch', name: 'switch', component: Switch},
{path: '/radio', name: 'radio', component: Radio},
{path: '/checkbox', name: 'checkbox', component: CheckBox},
{path: '/backtop', name: 'backtop', component: BackTop},
{path: '/accordion', name: 'accordion', component: Accordion},
{path: '/datetime', name: 'datetime', component: DateTime},
{path: '/lightbox', name: 'lightbox', component: LightBox},
{path: '/timeline', name: 'timeline', component: TimeLine},
{path: '/step', name: 'step', component: Step},
{path: '/checklist', name: 'checklist', component: CheckList},
{path: '/search', name: 'search', component: Search},
{path: '/scrollnav', name: 'scrollnav', component: ScrollNav},
{path: '/preview', name: 'preview', component: Preview},
]
});
const app = new Vue({
router: router,
render: v => v(App)
}).$mount('#app');
let scrollTop = 0;
router.beforeEach((route, redirect, next) => {
if (redirect.path === '/') {
scrollTop = document.getElementById('scrollView').scrollTop;
}
document.title = 'YDUI Touch - ' + route.name;
next();
});
router.afterEach(route => {
if (route.path === '/') {
Vue.nextTick(() => {
document.getElementById('scrollView').scrollTop = scrollTop;
});
} else {
document.getElementById('scrollView').scrollTop = 0;
}
});