import VueI18n from 'vue-i18n' import 'normalize.css/normalize.css' import MakingForm from './components/Container.vue' import GenerateForm from './components/GenerateForm.vue' import GenerateAntdForm from './components/AntdvGenerator/GenerateForm.vue' import enUS from './lang/en-US' import zhCN from './lang/zh-CN' import './iconfont/iconfont.css' import './styles/cover.scss' import './styles/index.scss' import './styles/editor.scss' import './styles/scrollbar.scss' const loadLang = function (Vue, lang, locale, i18n) { if (locale) { locale('en-US', {...locale('en-US'), ...enUS}) locale('zh-CN', {...locale('zh-CN'), ...zhCN}) Vue.config.lang = lang } else if (i18n){ i18n.setLocaleMessage('en-US', {...i18n.messages['en-US'], ...enUS}) i18n.setLocaleMessage('zh-CN', {...i18n.messages['zh-CN'], ...zhCN}) i18n.locale = lang } else { if (!Vue.prototype.$t) { Vue.use(VueI18n) const localI18n = new VueI18n({ locale: lang, messages: { 'en-US': {...enUS}, 'zh-CN': {...zhCN} } }) const init = Vue.prototype._init Vue.prototype._init = function (options) { init.call(this, { i18n: localI18n, ...options }) } } } } const expire = 253402271999000 const version = '1.6.15' const displayVersion = () => { Function(` window.console && console.log('%cFormMaking %cV${version} https://form.making.link', 'color: #1890ff;font-weight: 500;font-size: 20px;font-family: Source Sans Pro,Helvetica Neue,Arial,sans-serif;', 'color: #ccc;'); `)() } const loadOptions = (opts) => { window.FormMaking_OPTIONS = { ...opts, aceurl: opts.aceurl || 'https://form.making.link/public/lib/ace', key: '03202501060166M', version } } MakingForm.install = function (Vue, opts = { lang: 'zh-CN', locale: null, i18n: null }) { opts = { key: '03202501060166M', lang: 'zh-CN', locale: null, i18n: null, ...opts } loadLang(Vue, opts.lang, opts.locale, opts.i18n) if (expire >= new Date().getTime()) { Vue.component(MakingForm.name, MakingForm) } displayVersion() loadOptions(opts) } GenerateForm.install = function (Vue, opts = { lang: 'zh-CN', locale: null, i18n: null }) { opts = { key: '03202501060166M', lang: 'zh-CN', locale: null, i18n: null, ...opts } loadLang(Vue, opts.lang, opts.locale, opts.i18n) if (expire >= new Date().getTime()) { Vue.component(GenerateForm.name, GenerateForm) } displayVersion() loadOptions(opts) } GenerateAntdForm.install = function (Vue, opts = { lang: 'zh-CN', locale: null, i18n: null }) { opts = { key: '03202501060166M', lang: 'zh-CN', locale: null, i18n: null, ...opts } loadLang(Vue, opts.lang, opts.locale, opts.i18n) if (expire >= new Date().getTime()) { Vue.component(GenerateAntdForm.name, GenerateAntdForm) } displayVersion() loadOptions(opts) } const components = [ MakingForm, GenerateForm, GenerateAntdForm ] const install = function (Vue, opts = { lang: 'zh-CN', locale: null, i18n: null, components: [] }) { opts = { key: '03202501060166M', lang: 'zh-CN', locale: null, i18n: null, components: [], ...opts } loadLang(Vue, opts.lang, opts.locale, opts.i18n) if (expire >= new Date().getTime()) { components.forEach(component => { Vue.component(component.name, component) }) opts.components && opts.components.forEach(item => { Vue.component(item.name, item.component) }) } displayVersion() loadOptions(opts) } if (typeof window !== 'undefined' && window.Vue) { install(window.Vue); } export { install, MakingForm, GenerateForm, GenerateAntdForm } export default { install, MakingForm, GenerateForm, GenerateAntdForm }