From 42aa7671a39be3cab33ea0483f449e9cece9aa49 Mon Sep 17 00:00:00 2001 From: hanyuxia Date: Fri, 2 Feb 2024 18:16:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20CN-1558=20=E5=BC=80=E5=8F=91license?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=EF=BC=8C=E6=94=AF=E6=8C=81license=E6=8B=A6?= =?UTF-8?q?=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 06a8bd9626a6d54bb97ad40d155466012c98eaac) --- src/Login.vue | 160 +++++++++++++++++++++++++-- src/assets/css/font/iconfont.js | 2 +- src/utils/api.js | 3 +- src/views/administration/License.vue | 42 ++++--- 4 files changed, 179 insertions(+), 28 deletions(-) diff --git a/src/Login.vue b/src/Login.vue index a89429be..2396f0c7 100644 --- a/src/Login.vue +++ b/src/Login.vue @@ -22,16 +22,40 @@ > - + +
{{licenseStatusErrMsg}}
+
+ + + + +
+
@@ -46,6 +70,7 @@ import { api } from '@/utils/api' import dayjs from 'dayjs' import _ from 'lodash' import utc from 'dayjs/plugin/utc' +import { ref } from 'vue' dayjs.extend(utc) export default { @@ -55,7 +80,11 @@ export default { loading: false, username: '', pin: '', - language: '' + language: '', + licenseStatus: 1, + licenseStatusErrMsg: '', + downloadC2vUrl: api.downloadLicenseC2v, + supportID: '' } }, methods: { @@ -103,6 +132,70 @@ export default { } }) }, + downloadFile () { + axios.get(this.downloadC2vUrl, { responseType: 'blob' }).then(res => { + const fileName = 'CN-' + this.supportID + '-license-apply.xml' + if (window.navigator.msSaveOrOpenBlob) { + // 兼容ie11 + const blobObject = new Blob([res.data]) + window.navigator.msSaveOrOpenBlob(blobObject, fileName) + } else { + const url = URL.createObjectURL(new Blob([res.data])) + const a = document.createElement('a') + document.body.appendChild(a) // 此处增加了将创建的添加到body当中 + a.href = url + a.download = fileName + a.target = '_blank' + a.click() + a.remove() // 将a标签移除 + } + }, error => { + const $self = this + const reader = new FileReader() + reader.onload = function (event) { + const responseText = reader.result + const exception = JSON.parse(responseText) + if (exception.message) { + $self.$message.error(exception.message) + } else { + console.error(error) + } + } + reader.readAsText(error.response.data) + }) + }, + fileChange (file, fileList) { + if (file.status !== 'ready') return + if (!_.endsWith(file.name, '.xml')) { + this.fileList = [] + this.$message.error('Only support '+ this.fileTypeLimit + ' files') + } else { + this.fileList = fileList.slice(-1) + this.$refs.licenseUpload.submit() + } + }, + uploadSuccess (response) { + this.$message.success('Success') + this.licenseStatus = 1 + }, + uploadError (error) { + let errorMsg + if (error.message) { + errorMsg = JSON.parse(error.message).message + } else { + errorMsg = 'error' + } + this.$message.error('Upload failed: ' + errorMsg) + }, + checkLicenseStatus () { + axios.get(api.licenseStatus).then(res => { + if (res.status === 200) { + this.licenseStatus = res.data.status + } + }).catch(e => { + this.licenseStatusErrMsg = this.errorMsgHandler(e) + }) + }, queryAppearance () { axios.get(api.appearance).then(res => { if (res.status === 200) { @@ -128,13 +221,24 @@ export default { localStorage.setItem(storageKey.sysLogo, data.system_logo) } }, - mounted () { + async mounted () { this.queryAppearance() + this.checkLicenseStatus() + await axios.get(api.license).then(res => { + if (res.status === 200) { + this.supportID = res.data.data.license.supportID + } + }).catch(e => { + console.log(e) + }) }, setup (props) { const { currentRoute } = useRouter() return { - loginSuccessPath: currentRoute.value.query.redirect + loginSuccessPath: currentRoute.value.query.redirect, + baseUrl: BASE_CONFIG.baseUrl, + fileTypeLimit: '.xml', + fileList: ref([]) } } } @@ -181,7 +285,7 @@ export default { } .inside { width: 414px; - height: 524px; + height: fit-content;/*524*/ background: #0B325C; border: 1px solid rgba(103,179,245,0.65); box-shadow: 0 2px 4px 0 rgba(0,0,0,0.38); @@ -198,6 +302,7 @@ export default { .title { margin-top: 65px; + margin-bottom: 44px; text-align: center; } .title > img { @@ -208,6 +313,39 @@ export default { justify-content: center; flex-direction: column; align-items: center; + .is-disabled { + background: #21B4ED; + color: #FFFFFF; + opacity: 0.6; + } + .license-error-msg { + color:#c73249; + display: flex; + align-items: flex-start; + justify-content: center; + height:40px; + } + .license-file { + display: flex; + flex-direction: row; + height: 100%; + align-items: center; + justify-content: space-between; + .license__btn { + height: 40px; + padding-left:10px; + padding-right:10px; + min-width: 74px; + color: white; + background-color: #21B4ED; + border: none; + border-radius: 4px; + outline: none; + font-size: 14px; + cursor: pointer; + transition: background-color linear .2s, color linear .1s; + } + } } :deep .el-form-item { width: 334px; @@ -220,9 +358,8 @@ export default { width: 17px; font-size: 17px; } -.login__box .el-form-item:nth-of-type(3) { - margin-top: 25px; - margin-bottom: 65px; +.login__box .el-form-item:nth-child(3){ + margin-bottom: 0px; } .login--button { background: #21B4ED; @@ -234,5 +371,12 @@ export default { line-height: 22px; width: 334px; height: 52px; + margin-top: 25px; + margin-bottom:65px; +} +.login-btn__license-error { + margin-top: 25px; + margin-bottom: 10px; + height:40px; } diff --git a/src/assets/css/font/iconfont.js b/src/assets/css/font/iconfont.js index 168a3b5d..b22c49e2 100644 --- a/src/assets/css/font/iconfont.js +++ b/src/assets/css/font/iconfont.js @@ -1 +1 @@ -window._iconfont_svg_string_2614877='',function(l){var a=(a=document.getElementsByTagName("script"))[a.length-1],c=a.getAttribute("data-injectcss"),a=a.getAttribute("data-disable-injectsvg");if(!a){var h,o,i,m,v,z=function(a,c){c.parentNode.insertBefore(a,c)};if(c&&!l.__iconfont__svg__cssinject__){l.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}h=function(){var a,c=document.createElement("div");c.innerHTML=l._iconfont_svg_string_2614877,(c=c.getElementsByTagName("svg")[0])&&(c.setAttribute("aria-hidden","true"),c.style.position="absolute",c.style.width=0,c.style.height=0,c.style.overflow="hidden",c=c,(a=document.body).firstChild?z(c,a.firstChild):a.appendChild(c))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(h,0):(o=function(){document.removeEventListener("DOMContentLoaded",o,!1),h()},document.addEventListener("DOMContentLoaded",o,!1)):document.attachEvent&&(i=h,m=l.document,v=!1,s(),m.onreadystatechange=function(){"complete"==m.readyState&&(m.onreadystatechange=null,t())})}function t(){v||(v=!0,i())}function s(){try{m.documentElement.doScroll("left")}catch(a){return void setTimeout(s,50)}t()}}(window); \ No newline at end of file +window._iconfont_svg_string_2614877 = '', (function (l) { var a = (a = document.getElementsByTagName('script'))[a.length - 1]; const c = a.getAttribute('data-injectcss'); var a = a.getAttribute('data-disable-injectsvg'); if (!a) { let h; let o; var i; var m; var v; const z = function (a, c) { c.parentNode.insertBefore(a, c) }; if (c && !l.__iconfont__svg__cssinject__) { l.__iconfont__svg__cssinject__ = !0; try { document.write('') } catch (a) { console && console.log(a) } }h = function () { let a; let c = document.createElement('div'); c.innerHTML = l._iconfont_svg_string_2614877, (c = c.getElementsByTagName('svg')[0]) && (c.setAttribute('aria-hidden', 'true'), c.style.position = 'absolute', c.style.width = 0, c.style.height = 0, c.style.overflow = 'hidden', c = c, (a = document.body).firstChild ? z(c, a.firstChild) : a.appendChild(c)) }, document.addEventListener ? ~['complete', 'loaded', 'interactive'].indexOf(document.readyState) ? setTimeout(h, 0) : (o = function () { document.removeEventListener('DOMContentLoaded', o, !1), h() }, document.addEventListener('DOMContentLoaded', o, !1)) : document.attachEvent && (i = h, m = l.document, v = !1, s(), m.onreadystatechange = function () { m.readyState == 'complete' && (m.onreadystatechange = null, t()) }) } function t () { v || (v = !0, i()) } function s () { try { m.documentElement.doScroll('left') } catch (a) { return void setTimeout(s, 50) }t() } }(window)) diff --git a/src/utils/api.js b/src/utils/api.js index d54c5b82..450285d7 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -15,7 +15,8 @@ export const api = { logout: '/logout', pin: 'sys/user/pin', appearance: '/sys/appearance', - license: '/sys/license', + license: '/sys/license/detail', + licenseStatus: '/sys/license/status', downloadLicenseC2v: '/sys/license/download', permissions: '/sys/user/permissions', operationLog: '/sys/log', diff --git a/src/views/administration/License.vue b/src/views/administration/License.vue index 5f3f421e..acc81c1f 100644 --- a/src/views/administration/License.vue +++ b/src/views/administration/License.vue @@ -8,8 +8,8 @@
{{licenseObject.organization}}
- -
{{licenseObject.supportId}}
+ +
{{licenseObject.supportID}}
{{licenseObject.dateIssued}}
@@ -17,12 +17,12 @@
{{licenseObject.dateExpires}}
- +
-