-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from LucienShui/dev
png compressed, i18n lazy loaded, add api.js, update README.md
- Loading branch information
Showing
34 changed files
with
127 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ module.exports = { | |
parserOptions: { | ||
parser: 'babel-eslint' | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ module.exports = { | |
presets: [ | ||
'@vue/app' | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ module.exports = { | |
plugins: { | ||
autoprefixer: {} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import axios from 'axios' | ||
import qs from 'qs' | ||
|
||
export default { | ||
get: function(url, params = {}) { | ||
return new Promise((resolve, reject) => { | ||
axios.get(url, { | ||
params: params | ||
}).then(response => { | ||
resolve(response.data); | ||
}).catch(error => { | ||
alert(url + '\n' + JSON.stringify(error)); | ||
reject(error); | ||
}); | ||
}); | ||
}, | ||
post: function(url, params = {}) { | ||
return new Promise((resolve, reject) => { | ||
axios.post(url, qs.stringify(params)).then(response => { | ||
resolve(response.data); | ||
}).catch(error => { | ||
alert(url + '\n' + JSON.stringify(error)); | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,38 @@ | ||
/* | ||
@File : i18n.js | ||
@Contact : [email protected] | ||
@License : (C)Copyright 2019, Lucien Shui | ||
@Modify Time @Author @Version @Desciption | ||
------------ ------- -------- ----------- | ||
2019-05-31 23:48 Lucien 1.0 None | ||
*/ | ||
import Vue from 'vue' | ||
import VueI18n from 'vue-i18n' | ||
|
||
Vue.use(VueI18n); | ||
|
||
export default new VueI18n({ | ||
const i18n = new VueI18n({ | ||
locale: 'zh-CN', | ||
fallbackLocale: 'zh-CN', | ||
messages: { | ||
'zh-CN': require('./assets/lang/zh-CN'), | ||
'en': require('./assets/lang/en'), | ||
'zh-CN': require('./assets/lang/zh-CN') | ||
} | ||
}); | ||
|
||
const loadedLanguages = ['zh-CN']; | ||
const supportedLanguage = ['zh-CN', 'en']; | ||
|
||
function setI18nLanguage(lang) { | ||
i18n.locale = lang; | ||
document.querySelector('html').setAttribute('lang', lang); | ||
} | ||
|
||
Vue.prototype.setI18n = function (lang) { | ||
if (i18n.locale !== lang) { | ||
if (supportedLanguage.includes(lang)) { | ||
if (!loadedLanguages.includes(lang)) { | ||
import(/* webpackChunkName: "lang-[request]" */ `./assets/lang/${lang}`).then(messages => { | ||
i18n.setLocaleMessage(lang, messages); | ||
loadedLanguages.push(lang); | ||
setI18nLanguage(lang); | ||
}).catch(error => { | ||
alert(JSON.stringify(error)); | ||
}); | ||
} else setI18nLanguage(lang); | ||
} else setI18nLanguage(supportedLanguage[0]); | ||
} | ||
}; | ||
|
||
export default i18n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.