load license content from LICENSE file when build app

This commit is contained in:
MaysWind
2021-04-05 18:26:18 +08:00
parent a570a51bdf
commit d8b6091dcc
4 changed files with 29 additions and 30 deletions
+5 -2
View File
@@ -1,5 +1,8 @@
export default {
getLicenses: () => {
return process.env.LICENSES || [];
getLicense: () => {
return process.env.LICENSE;
},
getThirdPartyLicenses: () => {
return process.env.THIRD_PARTY_LICENSES || [];
}
};
+5 -1
View File
@@ -172,7 +172,11 @@ const i18n = new VueI18n(getI18nOptions());
Vue.prototype.$version = version.getVersion();
Vue.prototype.$buildTime = version.getBuildTime();
Vue.prototype.$licenses = licenses.getLicenses();
Vue.prototype.$licenses = {
license: licenses.getLicense(),
thirdPartyLicenses: licenses.getThirdPartyLicenses()
};
Vue.prototype.$constants = {
api: api,
+12 -25
View File
@@ -23,35 +23,19 @@
<f7-nav-title :title="$t('License')"></f7-nav-title>
</f7-navbar>
<f7-block>
<p><p>MIT License</p>
<p></p>
<p>Copyright (c) 2020 MaysWind (i@mayswind.net)</p>
<p></p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:</p>
<p></p>
<p>The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.</p>
<p></p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.</p>
<p></p>
<p>
<span v-for="(line, num) in licenseLines" :key="num"
:style="{ 'display': line ? 'initial' : 'block', 'padding' : line ? '0' : '0 0 1em 0' }">
{{ line }}
</span>
</p>
<hr/>
<p>
<span>lab also contains additional third party software.</span><br/>
<span>All the third party software included or linked is redistributed under the terms and conditions of their original licenses.</span>
</p>
<p></p>
<p v-for="license in licenses" :key="license.name">
<p v-for="license in thirdPartyLicenses" :key="license.name">
<strong>{{ license.name }}</strong>
<br v-if="license.copyright"/><span v-if="license.copyright">{{ license.copyright }}</span>
<br v-if="license.url"/><span class="work-break-all" v-if="license.url">{{ license.url }}</span>
@@ -72,8 +56,11 @@ export default {
buildTime() {
return this.$buildTime;
},
licenses() {
return this.$licenses;
licenseLines() {
return this.$licenses.license.replaceAll(/\r/g, '').split('\n');
},
thirdPartyLicenses() {
return this.$licenses.thirdPartyLicenses;
}
}
}
+7 -2
View File
@@ -1,8 +1,12 @@
const fs = require('fs');
const GitRevisionPlugin = require('git-revision-webpack-plugin');
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
const pkgFile = require('./package.json');
const licenseFile = require('./third-patry-licenses.json');
const thirdPartyLicenseFile = require('./third-patry-licenses.json');
const licenseFile = fs.readFileSync('./LICENSE', 'UTF-8');
module.exports = {
pages: {
@@ -60,7 +64,8 @@ module.exports = {
definitions[0]['process.env']['VERSION'] = JSON.stringify(pkgFile.version);
definitions[0]['process.env']['COMMIT_HASH'] = JSON.stringify(gitRevisionPlugin.commithash());
definitions[0]['process.env']['BUILD_UNIXTIME'] = JSON.stringify(parseInt((new Date().getTime() / 1000).toString()));
definitions[0]['process.env']['LICENSES'] = JSON.stringify(licenseFile);
definitions[0]['process.env']['LICENSE'] = JSON.stringify(licenseFile.trim());
definitions[0]['process.env']['THIRD_PARTY_LICENSES'] = JSON.stringify(thirdPartyLicenseFile);
return definitions;
});