Skip to content

Commit 337731d

Browse files
committed
extract strings and routes out of main.js
1 parent 44e646d commit 337731d

File tree

3 files changed

+183
-195
lines changed

3 files changed

+183
-195
lines changed

src/main.js

Lines changed: 2 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -17,168 +17,14 @@ import App from './app'
1717
import { EventBus } from './EventBus.js'
1818
import db from './db.js'
1919

20-
import YdDisplay from './pages/YdDisplay'
21-
import YdResource from './pages/YdResource'
22-
2320
import VueTouch from 'vue-touch'
2421
Vue.use(VueTouch, {name: 'v-touch'})
2522

2623
import VueI18n from 'vue-i18n'
2724
Vue.use(VueI18n)
2825

29-
const messages = {
30-
en: {
31-
message: {
32-
// Display
33-
done: 'Done',
34-
library: 'Library',
35-
new: 'New',
36-
settings: 'Settings',
37-
downloading: 'Uncompressing image resources, please wait',
38-
39-
// Dialogs
40-
edit_card: 'Edit Card',
41-
choose_animation: 'Choose animation',
42-
none: 'None',
43-
enlarge: 'Enlarge',
44-
swing: 'Swing',
45-
delete_card: 'Delete this card',
46-
mute: 'Mute',
47-
edit_category: 'Edit Category',
48-
delete_courseware: 'Delete this courseware',
49-
edit_courseware_title: 'Edit courseware',
50-
choose_layout: 'Choose layout',
51-
// Resource
52-
back: 'Back',
53-
new_card: 'New Card',
54-
new_category: 'New Category',
55-
camera: 'Camera',
56-
album: 'Album',
57-
record: 'Record',
58-
play: 'Play',
59-
delete: 'Delete',
60-
cancel: 'Cancel',
61-
confirm: 'Confirm',
62-
choose_cover: 'Choose cover',
63-
category_name: 'Category name',
64-
65-
// Alerts
66-
// Courseware settings
67-
cannot_delete_all: 'Cannot delete "All"',
68-
forbidden: 'Forbidden',
69-
are_you_sure: 'Are you sure?',
70-
delete_whole_category: 'Delete whole category',
71-
// Pick item
72-
cannot_navi_chosen_items: 'Please add chosen items before navigating to another folder',
73-
// Edit card
74-
missing_info_body: 'Please choose name, category and image before save',
75-
missing_info_title: 'Missing infomation',
76-
// Edit category
77-
require_category_title: 'Category title is required',
78-
cannot_edit_in_all: 'Cannot edit in "All" category',
79-
modify_card_in_library: 'Can be modified in Asset library',
80-
cannot_delete_in_all: 'Cannot delete items in "All" category',
81-
// New category
82-
must_choose_name: 'Please choose a name before save',
83-
alert_delete_card: 'Delete card',
84-
notice: 'Notice',
85-
press_again_to_exit: 'Press back button again to exit app',
86-
// Other category
87-
other: 'Other',
88-
// OK, Cancel
89-
ok: 'Ok',
90-
all: 'All',
91-
// Drawer back image
92-
drawer_back: 'drawer-back-en',
93-
// YdCard text class
94-
card_text_class: 'card-text-small',
95-
96-
// Startup checks
97-
download_confirm_title: 'Download content',
98-
download_confirm_body: 'Preload content not found, will start downloading. This will use about 30Mb data',
99-
download_fail_body: 'Failed to download from server. Please reopen app to try again',
100-
download_fail_title: 'Failded',
101-
102-
helper_message: 'Press and hold these 3 areas simultaneously to enter edit mode'
103-
}
104-
},
105-
zh: {
106-
message: {
107-
// Display
108-
done: '结束编辑',
109-
library: '素材库',
110-
new: '新建',
111-
settings: '设置',
112-
downloading: '正在解压小雨滴卡片资源,请稍候...',
113-
114-
// Dialogs
115-
edit_card: '编辑卡片',
116-
choose_animation: '选择动画',
117-
none: '无',
118-
enlarge: '放大',
119-
swing: '旋转',
120-
delete_card: '删除卡片',
121-
mute: '静音',
122-
edit_category: '编辑分类',
123-
delete_courseware: '删除课件',
124-
edit_courseware_title: '编辑课件',
125-
choose_layout: '选择布局',
126-
127-
// Resource
128-
back: '后退',
129-
new_card: '新卡片',
130-
new_category: '新分类',
131-
camera: '相机',
132-
album: '相册',
133-
record: '录音',
134-
play: '播放',
135-
delete: '删除',
136-
cancel: '取消',
137-
confirm: '确认',
138-
choose_cover: '选择封面',
139-
category_name: '分类名称',
140-
141-
// Alerts
142-
// Courseware settings
143-
cannot_delete_all: '不能删除“全部”课件',
144-
forbidden: '禁止',
145-
are_you_sure: '是否确定?',
146-
delete_whole_category: '删除整个课件',
147-
// Pick item
148-
cannot_navi_chosen_items: '已有选择的卡片,不能切换到其他分类,请先保存已选择的卡片',
149-
// Edit card
150-
missing_info_body: '请选择名称、分类和图片,然后保存',
151-
missing_info_title: '缺少信息',
152-
// Edit category
153-
require_category_title: '必须输入一个名称',
154-
cannot_edit_in_all: '不能在”全部“中编辑',
155-
modify_card_in_library: '可以在素材库中编辑',
156-
cannot_delete_in_all: '不能在”全部“中删除分类或课件',
157-
// New category
158-
must_choose_name: '请输入一个名称,然后保存',
159-
alert_delete_card: '删除卡片',
160-
notice: '提示',
161-
press_again_to_exit: '再按一次后退键退出应用',
162-
// Other category
163-
other: '其他',
164-
// OK, Cancel
165-
ok: '确认',
166-
all: '全部',
167-
// Drawer back image
168-
drawer_back: 'drawer-back',
169-
// YdCard text class
170-
card_text_class: 'card-text',
171-
172-
// Startup checks
173-
download_confirm_title: '下载',
174-
download_confirm_body: '没有找到内置卡片,需要下载,这将花费约30M流量',
175-
download_fail_body: '下载失败,请重新打开app下载',
176-
download_fail_title: '失败',
177-
178-
helper_message: '手指同时触摸这三个位置可以进入家长编辑模式'
179-
}
180-
}
181-
}
26+
import messages from './strings'
27+
import routes from './routes'
18228

18329
// Create VueI18n instance with options
18430
const i18n = new VueI18n({
@@ -193,33 +39,6 @@ window.oncontextmenu = function(event) {
19339
return false
19440
}
19541

196-
var routes = [
197-
{ path: '/display',
198-
name: 'YdDisplay',
199-
component: (resolve) => {
200-
EventBus.$on('RESOURCE_LOADED', function() {
201-
resolve(YdDisplay)
202-
})
203-
}
204-
},
205-
{
206-
path: '/resource',
207-
name: 'YdResource',
208-
component: YdResource,
209-
props: { mode: 'show' }
210-
},
211-
{
212-
path: '/resource/pick',
213-
name: 'YdResource',
214-
component: YdResource,
215-
props: { mode: 'pick' }
216-
},
217-
{
218-
path: '/',
219-
redirect: '/display'
220-
}
221-
]
222-
22342
var router = new Router({ routes })
22443

22544
var initApp = function() {

src/routes.js

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1+
import YdDisplay from './pages/YdDisplay'
2+
import YdResource from './pages/YdResource'
3+
import { EventBus } from './EventBus.js'
4+
15
export default [
2-
// {
3-
// path: '/about/',
4-
// component: require('./pages/about.vue')
5-
// },
6-
// {
7-
// path: '/form/',
8-
// component: require('./pages/about.vue')
9-
// },
10-
// {
11-
// path: '/dynamic-route/blog/:blogId/post/:postId/',
12-
// component: require('./pages/dynamic-route.vue')
13-
// }
6+
{ path: '/display',
7+
name: 'YdDisplay',
8+
component: (resolve) => {
9+
EventBus.$on('RESOURCE_LOADED', function() {
10+
resolve(YdDisplay)
11+
})
12+
}
13+
},
14+
{
15+
path: '/resource',
16+
name: 'YdResource',
17+
component: YdResource,
18+
props: { mode: 'show' }
19+
},
20+
{
21+
path: '/resource/pick',
22+
name: 'YdResource',
23+
component: YdResource,
24+
props: { mode: 'pick' }
25+
},
26+
{
27+
path: '/',
28+
redirect: '/display'
29+
}
1430
]

0 commit comments

Comments
 (0)