-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
73 lines (64 loc) · 1.95 KB
/
index.js
File metadata and controls
73 lines (64 loc) · 1.95 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
import _ from 'lodash';
import axios from 'axios';
import moment from "moment/moment";
import ClickOutside from "vue-click-outside";
import VueI18n from 'vue-i18n';
import PageTitle from './components/PageTitle';
import ApiTable from './components/ApiTable';
import ApiPagedTable from "./components/ApiPagedTable";
import ModelForm from './components/ModelForm';
import ModelView from './components/ModelView';
const ElementAdminComponents = {
install: (Vue, userOptions = {}) => {
const options = _.merge({
apiBase: '/api/admin',
apiUpload: '/api/upload',
appTitleKey: 'Admin',
urlBase: '',
messages: {},
}, userOptions);
const ctx = _.omit(options, ['messages']);
Vue.directive('click-outside', ClickOutside);
Vue.component('page-title', PageTitle);
Vue.component('api-table', ApiTable);
Vue.component('api-paged-table', ApiPagedTable);
Vue.component('model-form', ModelForm);
Vue.component('model-view', ModelView);
Vue.mixin({
methods: {
objGet: _.get,
formatDate(dateInput, format = 'YYYY-MM-DD HH:mm:ss') {
if (!dateInput) {
return '-';
}
return moment(dateInput).format(format);
},
},
});
Vue.use(VueI18n);
Vue.prototype.$ctx = {
...ctx
};
Vue._ = _;
Vue.prototype.$lodash = _;
Vue.axios = axios;
Vue.moment = moment;
Vue.prototype.$axios = axios;
Vue.prototype.$moment = moment;
},
i18n: (userOptions = {}) => {
const options = _.merge({
locale: 'zh-CN',
}, userOptions);
const i18n = new VueI18n({
locale: options.locale || 'zh-CN',
fallbackLocale: 'en',
messages: {
'zh-CN': _.merge(require('./langs/zh-CN.json'), _.get(options, ['messages', ['zh-CN']])),
'en-US': _.merge(require('./langs/en-US.json'), _.get(options, ['messages', ['en-US']])),
},
});
return i18n;
},
};
export default ElementAdminComponents;