From 80d44dfc1aba72bdf14cfa6f64bb690b01d638b6 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Wed, 15 Feb 2023 16:43:13 +0800 Subject: [PATCH 01/12] =?UTF-8?q?fix(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=87=E6=8D=A2=E4=B8=BB=E9=A2=98=E8=89=B2?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E7=BB=84=E4=BB=B6=E8=A1=A8=E5=A4=B4=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E4=B9=9F=E5=8F=98=E5=8C=96=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/canvas/utils/style.js | 5 ++++- .../components/widget/deWidget/TitlePosition.vue | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/canvas/utils/style.js b/frontend/src/components/canvas/utils/style.js index d6e254e97a..448ac7e418 100644 --- a/frontend/src/components/canvas/utils/style.js +++ b/frontend/src/components/canvas/utils/style.js @@ -381,7 +381,10 @@ export function adaptCurThemeCommonStyle(component) { if (isFilterComponent(component.component)) { const filterStyle = store.state.canvasStyleData.chartInfo.filterStyle for (const styleKey in filterStyle) { - Vue.set(component.style, styleKey, filterStyle[styleKey]) + // 位置属性不修改 + if (styleKey !== 'horizontal' && styleKey !== 'vertical') { + Vue.set(component.style, styleKey, filterStyle[styleKey]) + } } } else if (isTabComponent(component.component)) { const tabStyle = store.state.canvasStyleData.chartInfo.tabStyle diff --git a/frontend/src/components/widget/deWidget/TitlePosition.vue b/frontend/src/components/widget/deWidget/TitlePosition.vue index 1af68342f3..fb9b0e2645 100644 --- a/frontend/src/components/widget/deWidget/TitlePosition.vue +++ b/frontend/src/components/widget/deWidget/TitlePosition.vue @@ -19,12 +19,14 @@ {{ $t('chart.text_pos_left') }} {{ $t('chart.text_pos_center') }} + >{{ $t('chart.text_pos_center') }} + {{ $t('chart.text_pos_right') }} @@ -36,12 +38,14 @@ {{ $t('chart.text_pos_top') }} {{ $t('chart.text_pos_center') }} + >{{ $t('chart.text_pos_center') }} + @@ -73,6 +77,12 @@ export default { type: String, default: '' } + }, + + methods: { + styleChange() { + this.$store.commit('canvasChange') + } } } From c37f86f7423daf5a36abe741aa5b5989d8049109 Mon Sep 17 00:00:00 2001 From: dataeaseShu <106045316+dataeaseShu@users.noreply.github.com> Date: Wed, 15 Feb 2023 17:08:45 +0800 Subject: [PATCH 02/12] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E5=89=8D=E7=AB=AF=E6=8C=81=E4=B9=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.vue | 7 +++++++ frontend/src/store/modules/user.js | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 2dc1dd4a5f..1ec6edbbca 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -7,6 +7,7 @@ component-name="ThemeSetting" /> { reject(error) From 1d3e48d3c5e89a7e7fb4a90d55cf1f6911a74adc Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Wed, 15 Feb 2023 17:36:06 +0800 Subject: [PATCH 03/12] =?UTF-8?q?refactor(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=96=87=E6=9C=AC=E7=BB=84=E4=BB=B6=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E5=A4=A7=E5=B0=8F=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/canvas/components/TextAttr.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/canvas/components/TextAttr.vue b/frontend/src/components/canvas/components/TextAttr.vue index 59a66cf145..d0fca3718b 100644 --- a/frontend/src/components/canvas/components/TextAttr.vue +++ b/frontend/src/components/canvas/components/TextAttr.vue @@ -466,7 +466,7 @@ export default { initFontSize: 12, initActiveFontSize: 18, miniFontSize: 12, - maxFontSize: 128, + maxFontSize: 256, textAlignOptions: [ { icon: 'iconfont icon-juzuo', From 02371b44416ab107cc6947fef221ff5469877466 Mon Sep 17 00:00:00 2001 From: dataeaseShu <106045316+dataeaseShu@users.noreply.github.com> Date: Thu, 16 Feb 2023 10:09:18 +0800 Subject: [PATCH 04/12] =?UTF-8?q?fix:=20=E4=B8=8B=E6=8B=89=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=8D=95=E9=80=89=E6=A0=B7=E5=BC=8F=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/styles/index.scss | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/src/styles/index.scss b/frontend/src/styles/index.scss index e07bc87886..c76b43b777 100644 --- a/frontend/src/styles/index.scss +++ b/frontend/src/styles/index.scss @@ -828,8 +828,12 @@ div:focus { color: #1F2329 !important; } -.de-select-grid-class { - .el-checkbox__input.is-checked:not(.is-disabled)+.el-checkbox__label { +.el-radio__input.is-checked:not(.is-disabled)+.el-radio__label { + color: var(--deTextPrimary, #1F2329) !important; +} + +.de-select-grid-class{ + .el-checkbox__input.is-checked:not(.is-disabled)+.el-checkbox__label, .el-radio__input.is-checked:not(.is-disabled)+.el-radio__label { color: #3370ff !important; } } @@ -1176,9 +1180,6 @@ div:focus { color: var(--deTextPrimary, #1F2329) !important; } -.el-radio__input.is-checked:not(.is-disabled)+.el-radio__label { - color: var(--deTextPrimary, #1F2329) !important; -} .date-filter-poper>.el-scrollbar>.el-select-dropdown__wrap { max-height: 230px !important; From 9f6e66ad821bff63e99d793852e82d2fd33358f5 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Thu, 16 Feb 2023 18:30:24 +0800 Subject: [PATCH 05/12] fix(i18n): i18n --- .../panel/PanelPdfTemplateController.java | 2 ++ .../resources/db/migration/V50__1.18.3.sql | 2 ++ .../resources/i18n/messages_en_US.properties | 20 +++++++++++++++---- .../resources/i18n/messages_zh_CN.properties | 2 ++ .../resources/i18n/messages_zh_TW.properties | 14 ++++++++++++- frontend/src/lang/en.js | 8 +++++++- frontend/src/lang/tw.js | 8 +++++++- frontend/src/lang/zh.js | 8 +++++++- frontend/src/utils/StringUtils.js | 19 ++++++++++++++++++ frontend/src/views/background/index.vue | 8 ++++---- .../src/views/panel/export/PDFPreExport.vue | 3 ++- 11 files changed, 81 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/io/dataease/controller/panel/PanelPdfTemplateController.java b/backend/src/main/java/io/dataease/controller/panel/PanelPdfTemplateController.java index c499a468c5..01297b83e6 100644 --- a/backend/src/main/java/io/dataease/controller/panel/PanelPdfTemplateController.java +++ b/backend/src/main/java/io/dataease/controller/panel/PanelPdfTemplateController.java @@ -1,6 +1,7 @@ package io.dataease.controller.panel; import com.github.xiaoymin.knife4j.annotations.ApiSupport; +import io.dataease.controller.handler.annotation.I18n; import io.dataease.plugins.common.base.domain.PanelPdfTemplate; import io.dataease.service.panel.PanelPdfTemplateService; import io.swagger.annotations.Api; @@ -26,6 +27,7 @@ public class PanelPdfTemplateController { private PanelPdfTemplateService panelPdfTemplateService; @GetMapping("queryAll") + @I18n @ApiOperation("查询所有仪表板模板") public List queryAll() { return panelPdfTemplateService.queryAll(); diff --git a/backend/src/main/resources/db/migration/V50__1.18.3.sql b/backend/src/main/resources/db/migration/V50__1.18.3.sql index f9f320fd3f..4974cb230d 100644 --- a/backend/src/main/resources/db/migration/V50__1.18.3.sql +++ b/backend/src/main/resources/db/migration/V50__1.18.3.sql @@ -2,3 +2,5 @@ UPDATE `my_plugin` SET `version` = '1.18.3' where `plugin_id` > 0 and `version` = '1.18.2'; +UPDATE `panel_pdf_template` SET `name` = 'I18N_PANEL_PDF_TEMPLATE_WITH_PARAMS',`template_content` = '
\n
\n $t(''panel.panel_name''):$panelName$
\n $t(''panel.export_time''):$yyyy-MM-dd hh:mm:ss$
\n $t(''panel.export_user''):$nickName$
\n $t(''panel.you_can_type_here'')\n
\n
\n \n
\n
' WHERE id='1'; +UPDATE `panel_pdf_template` SET `name` = 'I18N_PANEL_PDF_TEMPLATE_ONLY_PIC' WHERE id='2'; diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 63c80bb089..3e28818c0a 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -62,7 +62,7 @@ i18n_panel_list=Dashboard i18n_processing_data=Processing data now, Refresh later i18n_union_already_exists=Union relation already exists i18n_union_field_exists=The same field can't in two dataset -i18n_cron_time_error=Start time can't greater then end time +i18n_cron_time_error=Start time can't greater than end time i18n_auth_source_be_canceled=This Auth Resource Already Be Canceled,Please Connect Admin i18n_username_exists=ID is already exists i18n_nickname_exists=NickName is already exists @@ -134,7 +134,7 @@ theme_name_empty=name can not be empty i18n_public_chart=\u3010Public Chart\u3011 i18n_class_blue=Blue Tone \u63D2\u4EF6\u7BA1\u7406=Plugins -i18n_plugin_not_allow_delete=The plugin in in use cannot be deleted +i18n_plugin_not_allow_delete=The plugin in use cannot be deleted i18n_wrong_content=Wrong content i18n_wrong_tel=Wrong tel format i18n_wrong_email=Wrong email format @@ -146,7 +146,7 @@ OPERATE_TYPE_DELETE=Delete OPERATE_TYPE_SHARE=Share OPERATE_TYPE_UNSHARE=Unshare OPERATE_TYPE_AUTHORIZE=Authorize -OPERATE_TYPE_UNAUTHORIZE=Unauthorize +OPERATE_TYPE_UNAUTHORIZE=Unauthorized OPERATE_TYPE_CREATELINK=Create Link OPERATE_TYPE_DELETELINK=Delete Link OPERATE_TYPE_MODIFYLINK=Modify Link @@ -261,4 +261,16 @@ I18N_LOG_FORMAT_PREFIX=With authority of %s\u3010%s\u3011 \u6C34\u5370\u7BA1\u7406=Watermark \u8840\u7F18\u5173\u7CFB=Relationship -I18N_CRON_ERROR=Cron expression error \ No newline at end of file +I18N_CRON_ERROR=Cron expression error +I18N_PANEL_PDF_TEMPLATE_WITH_PARAMS=Default template with params +I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=Default template only screenshot +\u8FB9\u68461=Border 1 +\u8FB9\u68462=Border 2 +\u8FB9\u68463=Border 3 +\u8FB9\u68464=Border 4 +\u8FB9\u68465=Border 5 +\u8FB9\u68466=Border 6 +\u8FB9\u68467=Border 7 +\u8FB9\u68468=Border 8 +\u8FB9\u68469=Border 9 +\u8FB9\u684610=Border 10 diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index a0a278575f..c1afe1cd28 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -262,4 +262,6 @@ I18N_LOG_FORMAT_PREFIX=\u4EE5%s\u3010%s\u3011\u6743\u9650 \u8840\u7F18\u5173\u7CFB=\u8840\u7F18\u5173\u7CFB I18N_CRON_ERROR=cron\u8868\u8FBE\u5F0F\u9519\u8BEF +I18N_PANEL_PDF_TEMPLATE_WITH_PARAMS=\u9ED8\u8BA4\u6A21\u677F(\u52A0\u53C2\u6570\u6837\u5F0F) +I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=\u9ED8\u8BA4\u6A21\u677F(\u53EA\u622A\u56FE) diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index fe253c3b6f..b5b4f68656 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -257,4 +257,16 @@ I18N_LOG_FORMAT_PREFIX=\u4EE5%s\u3010%s\u3011\u6B0A\u9650 \u6C34\u5370\u7BA1\u7406=\u6C34\u5370\u7BA1\u7406 \u8840\u7F18\u5173\u7CFB=\u8840\u7DE3\u95DC\u7CFB -I18N_CRON_ERROR=cron\u8868\u9054\u5F0F\u932F\u8AA4 \ No newline at end of file +I18N_CRON_ERROR=cron\u8868\u9054\u5F0F\u932F\u8AA4 +I18N_PANEL_PDF_TEMPLATE_WITH_PARAMS=\u9ED8\u8A8D\u6A21\u677F(\u52A0\u53C3\u6578\u6A23\u5F0F) +I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=\u9ED8\u8A8D\u6A21\u677F(\u53EA\u622A\u5716) +\u8FB9\u68461=\u908A\u6846 1 +\u8FB9\u68462=\u908A\u6846 2 +\u8FB9\u68463=\u908A\u6846 3 +\u8FB9\u68464=\u908A\u6846 4 +\u8FB9\u68465=\u908A\u6846 5 +\u8FB9\u68466=\u908A\u6846 6 +\u8FB9\u68467=\u908A\u6846 7 +\u8FB9\u68468=\u908A\u6846 8 +\u8FB9\u68469=\u908A\u6846 9 +\u8FB9\u684610=\u908A\u6846 10 diff --git a/frontend/src/lang/en.js b/frontend/src/lang/en.js index f97d2eb399..765cc7595a 100644 --- a/frontend/src/lang/en.js +++ b/frontend/src/lang/en.js @@ -2316,7 +2316,13 @@ export default { fold: 'Fold', expand: 'Expand', pdf_export: 'PDF Export', - switch_pdf_template: 'Switch PDF Template' + switch_pdf_template: 'Switch PDF Template', + pdf_template_with_params: 'Default template(with params)', + pdf_template_only_pic: 'Default template(only screenshot)', + panel_name: 'Panel name', + export_user: 'Export User', + export_time: 'Export Time', + you_can_type_here: 'You can type here' }, plugin: { local_install: 'Local installation', diff --git a/frontend/src/lang/tw.js b/frontend/src/lang/tw.js index ee62fb3c3d..8c23dfbe84 100644 --- a/frontend/src/lang/tw.js +++ b/frontend/src/lang/tw.js @@ -2310,7 +2310,13 @@ export default { fold: '收起', expand: '展開', pdf_export: 'PDF 導出', - switch_pdf_template: '切換 PDF 模板' + switch_pdf_template: '切換 PDF 模板', + pdf_template_with_params: '默認模板(加參數樣式)', + pdf_template_only_pic: '默認模板(只截圖)', + panel_name: '儀錶板名稱', + export_user: '導出用戶', + export_time: '導出時間', + you_can_type_here: '可以在這裡輸入其他內容' }, plugin: { local_install: '本地安裝', diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 1fb1fe5f52..767c2d7f44 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -2310,7 +2310,13 @@ export default { fold: '收起', expand: '展开', pdf_export: 'PDF 导出', - switch_pdf_template: '切换 PDF 模板' + switch_pdf_template: '切换 PDF 模板', + pdf_template_with_params: '默认模板(加参数样式)', + pdf_template_only_pic: '默认模板(只截图)', + panel_name: '仪表板名称', + export_user: '导出用户', + export_time: '导出时间', + you_can_type_here: '可以在这里输入其他内容' }, plugin: { local_install: '本地安装', diff --git a/frontend/src/utils/StringUtils.js b/frontend/src/utils/StringUtils.js index 0707dc2bd4..8fb157234e 100644 --- a/frontend/src/utils/StringUtils.js +++ b/frontend/src/utils/StringUtils.js @@ -1,3 +1,5 @@ +import i18n from '@/lang' + // 替换所有 标准模板格式 为 $panelName$ export function pdfTemplateReplaceAll(content, source, target) { const pattern = '\\$' + source + '\\$' @@ -37,3 +39,20 @@ export function includesAny(target, ...sources) { } return false } + +// 替换字符串中的国际化内容, 格式为$t('xxx') +export function replaceInlineI18n(rawString) { + const res = [] + const reg = /\$t\('([\w.]+)'\)/gm + let tmp + if (!rawString) { + return res + } + while ((tmp = reg.exec(rawString)) !== null) { + res.push(tmp) + } + res.forEach((tmp) => { + rawString = rawString.replaceAll(tmp[0], i18n.t(tmp[1])) + }) + return rawString +} diff --git a/frontend/src/views/background/index.vue b/frontend/src/views/background/index.vue index bcb72f375f..58cd92aa7b 100644 --- a/frontend/src/views/background/index.vue +++ b/frontend/src/views/background/index.vue @@ -179,13 +179,13 @@ :span="5" style="padding-left: 10px;padding-top: 8px" > - 输入框样式(颜色): + {{ $t('panel.input_style') }}: - 边框 + {{ $t('panel.board') }} - 文字 + {{ $t('panel.text') }} - 背景 + {{ $t('panel.background') }} Date: Fri, 17 Feb 2023 18:37:19 +0800 Subject: [PATCH 06/12] =?UTF-8?q?feat(=E7=99=BB=E5=BD=95):=20=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E9=92=89=E9=92=89=E5=B7=A5=E4=BD=9C=E5=8F=B0?= =?UTF-8?q?=E5=85=8D=E7=99=BB=E8=BF=9B=E5=85=A5DE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/auth/util/JWTUtils.java | 3 +- frontend/src/permission.js | 21 +- mobile/src/common/utils.js | 15 +- mobile/src/pages.json | 370 ++++----- mobile/src/pages/login/index.vue | 713 +++++++++--------- 5 files changed, 582 insertions(+), 540 deletions(-) diff --git a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java index 6d0aaef239..cebe34c5f5 100644 --- a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java +++ b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java @@ -68,7 +68,8 @@ public class JWTUtils { public static boolean needRefresh(String token) { Date exp = JWTUtils.getExp(token); - return new Date().getTime() >= exp.getTime(); + Long advanceTime = 5000L; + return (new Date().getTime() + advanceTime) >= exp.getTime(); } /** diff --git a/frontend/src/permission.js b/frontend/src/permission.js index c5961184b6..c612f949c9 100644 --- a/frontend/src/permission.js +++ b/frontend/src/permission.js @@ -18,9 +18,13 @@ import { changeFavicon } from '@/utils/index' import Layout from '@/layout/index' -import { getSysUI } from '@/utils/auth' +import { + getSysUI +} from '@/utils/auth' -import { getSocket } from '@/websocket' +import { + getSocket +} from '@/websocket' NProgress.configure({ showSpinner: false @@ -53,14 +57,19 @@ const routeBefore = (callBack) => { callBack() } } -router.beforeEach(async (to, from, next) => routeBefore(() => { +router.beforeEach(async(to, from, next) => routeBefore(() => { // start progress bar NProgress.start() - const mobileIgnores = ['/delink'] + const mobileIgnores = ['/delink', '/de-auto-login'] const mobilePreview = '/preview/' + const hasToken = getToken() if (isMobile() && !to.path.includes(mobilePreview) && mobileIgnores.indexOf(to.path) === -1) { - window.location.href = window.origin + '/app.html' + let urlSuffix = '/app.html' + if (hasToken) { + urlSuffix += ('?detoken=' + hasToken) + } + window.location.href = window.origin + urlSuffix NProgress.done() } @@ -68,7 +77,7 @@ router.beforeEach(async (to, from, next) => routeBefore(() => { document.title = getPageTitle(to.meta.title) // determine whether the user has logged in - const hasToken = getToken() + if (hasToken) { if (to.path === '/login') { // if is logged in, redirect to the home page diff --git a/mobile/src/common/utils.js b/mobile/src/common/utils.js index f4c10d9700..2e6fa8b2f7 100644 --- a/mobile/src/common/utils.js +++ b/mobile/src/common/utils.js @@ -142,4 +142,17 @@ export function parseLanguage() { const language = getLanguage() if(language === 'sys') return uni.getLocale() return language -} \ No newline at end of file +} + +export function getUrlParams(url){ + const Params = {} + if(url.indexOf('?')>0){//判断是否有qurey + let parmas = url.slice(url.indexOf('?')+1)//截取出query + const paramlists = parmas.split('&')//分割键值对 + for (const param of paramlists) { + let a = param.split('=') + Object.assign(Params,{[a[0]]:a[1]})//将键值对封装成对象 + } + } + return Params +} diff --git a/mobile/src/pages.json b/mobile/src/pages.json index 1e6be356ac..1fcfb0dc34 100644 --- a/mobile/src/pages.json +++ b/mobile/src/pages.json @@ -1,192 +1,192 @@ { - "pages": [ + "pages": [ + + { + "path": "pages/login/index", + "style": { + "navigationBarTitleText": "%navigate.login%", + "app-plus": { + "titleNView": false + } + } + }, + { + "path": "pages/tabBar/home/index", + "style": { + "navigationBarTitleText": "%navigate.menuHome%", + "app-plus": { + "titleNView": false - { - "path": "pages/login/index", - "style": { - "navigationBarTitleText": "%navigate.login%", - "app-plus": { - "titleNView": false - } - } - }, - { - "path": "pages/tabBar/home/index", - "style": { - "navigationBarTitleText": "%navigate.menuHome%", - "app-plus": { - "titleNView": false - - }, - "enablePullDownRefresh": true - } - }, - - { - "path": "pages/tabBar/home/detail", - "style": { - "navigationBarTitleText": "", - "app-plus": { - "titleNView": false, - "bounce": "none" - } - } }, - { - "path": "pages/tabBar/dir/index", - "style": { - "navigationBarTitleText": "%navigate.menuDir%", - "app-plus": { - "titleNView": { - "type": "transparent", - "titleColor": "#fff", - "backgroundColor": "#0faeff", - "buttons": [], - "searchInput": { - "backgroundColor": "#fff", - "borderRadius": "6px", - "placeholder": "%searchPlaceholder%", - "disabled": true - } - } - }, - "enablePullDownRefresh": true - } - }, - { - "path": "pages/tabBar/dir/search", - "style": { - "navigationBarTitleText": "%navigate.search%", - "app-plus": { - "titleNView": { - "titleColor": "#fff", - "backgroundColor": "#0faeff", - - "searchInput": { - "backgroundColor": "#fff", - "borderRadius": "6px", - "placeholder": "%searchPlaceholder%", - "autoFocus": true - } - } - } + "enablePullDownRefresh": true + } + }, + + { + "path": "pages/tabBar/home/detail", + "style": { + "navigationBarTitleText": "", + "app-plus": { + "titleNView": false, + "bounce": "none" + } + } + }, + { + "path": "pages/tabBar/dir/index", + "style": { + "navigationBarTitleText": "%navigate.menuDir%", + "app-plus": { + "titleNView": { + "type": "transparent", + "titleColor": "#fff", + "backgroundColor": "#0faeff", + "buttons": [], + "searchInput": { + "backgroundColor": "#fff", + "borderRadius": "6px", + "placeholder": "%searchPlaceholder%", + "disabled": true } + } }, - { - "path": "pages/tabBar/dir/folder", - "style": { - "navigationBarTitleText": "", - "app-plus": { - "titleNView": { - "type": "transparent" - } - }, - "h5": { - "titleNView": { - "type": "transparent", - "buttons": [] - } - } + "enablePullDownRefresh": true + } + }, + { + "path": "pages/tabBar/dir/search", + "style": { + "navigationBarTitleText": "%navigate.search%", + "app-plus": { + "titleNView": { + "titleColor": "#fff", + "backgroundColor": "#0faeff", + + "searchInput": { + "backgroundColor": "#fff", + "borderRadius": "6px", + "placeholder": "%searchPlaceholder%", + "autoFocus": true } + } + } + } + }, + { + "path": "pages/tabBar/dir/folder", + "style": { + "navigationBarTitleText": "", + "app-plus": { + "titleNView": { + "type": "transparent" + } }, - { - "path": "pages/tabBar/me/index", - "style": { - "navigationBarTitleText": "%navigate.menuMe%", - "app-plus": { - "titleNView": false - } - } - }, - { - "path": "pages/tabBar/me/person", - "style": { - "navigationBarTitleText": "%navigate.personInfo%", - - "app-plus": { - "titleNView": { - "type": "transparent" - } - } - } - }, - { - "path": "pages/tabBar/me/language", - "style": { - "navigationBarTitleText": "%navigate.language%", - - "app-plus": { - "titleNView": { - "type": "transparent" - } - } - } - }, - { - "path": "pages/tabBar/me/about", - "style": { - "navigationBarTitleText": "%navigate.about%", - - "app-plus": { - "titleNView": { - "type": "transparent" - } - } - } - }, - { - "path": "pages/tabBar/me/outlink", - "style": { - "navigationBarTitleText": "", - - "app-plus": { - "titleNView": { - "type": "transparent" - } - } - } - }, - { - "path": "pages/index/index", - "style": { - "navigationBarTitleText": "%app.name%", - "h5": { - "maxWidth": 1190, - "navigationBarTextStyle": "black", - "navigationBarBackgroundColor": "#F1F1F1" - } - } - } - ], - "globalStyle": { - "navigationBarTextStyle": "black", - "navigationBarTitleText": "%app.name%", - "navigationBarBackgroundColor": "#ffffff", - "backgroundColor": "#ffffff" - }, - "tabBar": { - "color": "#7A7E83", - "selectedColor": "#007AFF", - "borderStyle": "black", - "backgroundColor": "#ffffff", - - "list": [{ - "pagePath": "pages/tabBar/home/index", - "iconPath": "static/home.png", - "selectedIconPath": "static/home_select.png", - "text": "%navigate.menuHome%" - }, - { - "pagePath": "pages/tabBar/dir/index", - "iconPath": "static/dir.png", - "selectedIconPath": "static/dir_select.png", - "text": "%navigate.menuDir%" - }, { - "pagePath": "pages/tabBar/me/index", - "iconPath": "static/me.png", - "selectedIconPath": "static/me_select.png", - "text": "%navigate.menuMe%" - } - ] - } -} + "h5": { + "titleNView": { + "type": "transparent", + "buttons": [] + } + } + } + }, + { + "path": "pages/tabBar/me/index", + "style": { + "navigationBarTitleText": "%navigate.menuMe%", + "app-plus": { + "titleNView": false + } + } + }, + { + "path": "pages/tabBar/me/person", + "style": { + "navigationBarTitleText": "%navigate.personInfo%", + + "app-plus": { + "titleNView": { + "type": "transparent" + } + } + } + }, + { + "path": "pages/tabBar/me/language", + "style": { + "navigationBarTitleText": "%navigate.language%", + + "app-plus": { + "titleNView": { + "type": "transparent" + } + } + } + }, + { + "path": "pages/tabBar/me/about", + "style": { + "navigationBarTitleText": "%navigate.about%", + + "app-plus": { + "titleNView": { + "type": "transparent" + } + } + } + }, + { + "path": "pages/tabBar/me/outlink", + "style": { + "navigationBarTitleText": "", + + "app-plus": { + "titleNView": { + "type": "transparent" + } + } + } + }, + { + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "%app.name%", + "h5": { + "maxWidth": 1190, + "navigationBarTextStyle": "black", + "navigationBarBackgroundColor": "#F1F1F1" + } + } + } + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "%app.name%", + "navigationBarBackgroundColor": "#ffffff", + "backgroundColor": "#ffffff" + }, + "tabBar": { + "color": "#7A7E83", + "selectedColor": "#007AFF", + "borderStyle": "black", + "backgroundColor": "#ffffff", + + "list": [{ + "pagePath": "pages/tabBar/home/index", + "iconPath": "static/home.png", + "selectedIconPath": "static/home_select.png", + "text": "%navigate.menuHome%" + }, + { + "pagePath": "pages/tabBar/dir/index", + "iconPath": "static/dir.png", + "selectedIconPath": "static/dir_select.png", + "text": "%navigate.menuDir%" + }, { + "pagePath": "pages/tabBar/me/index", + "iconPath": "static/me.png", + "selectedIconPath": "static/me_select.png", + "text": "%navigate.menuMe%" + } + ] + } +} \ No newline at end of file diff --git a/mobile/src/pages/login/index.vue b/mobile/src/pages/login/index.vue index 5b10f91ac3..12b9d94dee 100644 --- a/mobile/src/pages/login/index.vue +++ b/mobile/src/pages/login/index.vue @@ -1,385 +1,404 @@ + .oauth-image image { + width: 30px; + height: 30px; + margin: 10px; + } + + .oauth-image button { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + opacity: 0; + } + + .captcha-view { + line-height: 0; + justify-content: center; + align-items: center; + display: flex; + position: relative; + background-color: #f3f3f3; + } + + .welcome { + padding-left: 15px; + font-size: x-large; + font-weight: 500; + letter-spacing: 2px; + } + \ No newline at end of file From 0e6cb26ba9c9a3aa6647108f95f214da8503ec0b Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 17 Feb 2023 21:53:57 +0800 Subject: [PATCH 07/12] =?UTF-8?q?perf(token):=20=E7=A6=81=E7=94=A8token?= =?UTF-8?q?=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/auth/filter/JWTFilter.java | 4 +--- .../java/io/dataease/auth/util/JWTUtils.java | 21 +++---------------- .../commons/utils/TokenCacheUtils.java | 9 -------- .../src/main/resources/ehcache/ehcache.xml | 12 +---------- 4 files changed, 5 insertions(+), 41 deletions(-) diff --git a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java index e5bd636789..db9be9a709 100644 --- a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java +++ b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java @@ -66,7 +66,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { if (StringUtils.startsWith(authorization, "Basic")) { return false; } - if (!TokenCacheUtils.validate(authorization) && !TokenCacheUtils.validateDelay(authorization)) { + if (!TokenCacheUtils.validate(authorization)) { throw new AuthenticationException(expireMessage); } // 当没有出现登录超时 且需要刷新token 则执行刷新token @@ -75,8 +75,6 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { throw new AuthenticationException(expireMessage); } if (JWTUtils.needRefresh(authorization)) { - TokenCacheUtils.addWithTtl(authorization, 1L); - TokenCacheUtils.remove(authorization); authorization = refreshToken(request, response); } JWTToken token = new JWTToken(authorization); diff --git a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java index cebe34c5f5..2c671abda9 100644 --- a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java +++ b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java @@ -20,9 +20,6 @@ import java.util.Date; public class JWTUtils { - // token过期时间1min (过期会自动刷新续命 目的是避免一直都是同一个token ) - private static final long EXPIRE_TIME = 1 * 60 * 1000; - // 登录间隔时间10min 超过这个时间强制重新登录 private static long Login_Interval; /** @@ -67,9 +64,7 @@ public class JWTUtils { } public static boolean needRefresh(String token) { - Date exp = JWTUtils.getExp(token); - Long advanceTime = 5000L; - return (new Date().getTime() + advanceTime) >= exp.getTime(); + return false; } /** @@ -95,18 +90,9 @@ public class JWTUtils { return isExpire; } - public static Date getExp(String token) { - try { - DecodedJWT jwt = JWT.decode(token); - return jwt.getClaim("exp").asDate(); - } catch (JWTDecodeException e) { - e.printStackTrace(); - return null; - } - } + /** - * 生成签名,5min后过期 * * @param tokenInfo 用户信息 * @param secret 用户的密码 @@ -114,12 +100,11 @@ public class JWTUtils { */ public static String sign(TokenInfo tokenInfo, String secret) { try { - Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME); Algorithm algorithm = Algorithm.HMAC256(secret); Builder builder = JWT.create() .withClaim("username", tokenInfo.getUsername()) .withClaim("userId", tokenInfo.getUserId()); - String sign = builder.withExpiresAt(date).sign(algorithm); + String sign = builder.sign(algorithm); TokenCacheUtils.add(sign, tokenInfo.getUserId()); return sign; diff --git a/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java b/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java index 338adbf2da..bc936c3be5 100644 --- a/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java +++ b/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java @@ -7,7 +7,6 @@ import org.apache.commons.lang3.StringUtils; public class TokenCacheUtils { private static final String KEY = "sys_token_store"; - private static final String DELAY_KEY = "sys_token_store_delay"; public static void add(String token, Long userId) { CacheUtils.put(KEY, token, userId, null, null); @@ -27,12 +26,4 @@ public class TokenCacheUtils { return ObjectUtils.isNotEmpty(sys_token_store) && StringUtils.isNotBlank(sys_token_store.toString()) && userId == Long.parseLong(sys_token_store.toString()); } - public static void addWithTtl(String token, Long userId) { - CacheUtils.put(DELAY_KEY, token, userId, 3, 5); - } - - public static boolean validateDelay(String token) { - Object tokenObj = CacheUtils.get(DELAY_KEY, token); - return ObjectUtils.isNotEmpty(tokenObj) && StringUtils.isNotBlank(tokenObj.toString()); - } } diff --git a/backend/src/main/resources/ehcache/ehcache.xml b/backend/src/main/resources/ehcache/ehcache.xml index f8d8591b20..eccd3b1661 100644 --- a/backend/src/main/resources/ehcache/ehcache.xml +++ b/backend/src/main/resources/ehcache/ehcache.xml @@ -277,19 +277,9 @@ maxElementsOnDisk="3000" overflowToDisk="true" diskPersistent="false" - /> - - + \ No newline at end of file From a34e99d7c1bab3a1555c67e7ed81eae0d571f466 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 17 Feb 2023 22:05:00 +0800 Subject: [PATCH 08/12] =?UTF-8?q?Revert=20"perf(token):=20=E7=A6=81?= =?UTF-8?q?=E7=94=A8token=E5=88=B7=E6=96=B0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0e6cb26ba9c9a3aa6647108f95f214da8503ec0b. --- .../io/dataease/auth/filter/JWTFilter.java | 4 +++- .../java/io/dataease/auth/util/JWTUtils.java | 21 ++++++++++++++++--- .../commons/utils/TokenCacheUtils.java | 9 ++++++++ .../src/main/resources/ehcache/ehcache.xml | 12 ++++++++++- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java index db9be9a709..e5bd636789 100644 --- a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java +++ b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java @@ -66,7 +66,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { if (StringUtils.startsWith(authorization, "Basic")) { return false; } - if (!TokenCacheUtils.validate(authorization)) { + if (!TokenCacheUtils.validate(authorization) && !TokenCacheUtils.validateDelay(authorization)) { throw new AuthenticationException(expireMessage); } // 当没有出现登录超时 且需要刷新token 则执行刷新token @@ -75,6 +75,8 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { throw new AuthenticationException(expireMessage); } if (JWTUtils.needRefresh(authorization)) { + TokenCacheUtils.addWithTtl(authorization, 1L); + TokenCacheUtils.remove(authorization); authorization = refreshToken(request, response); } JWTToken token = new JWTToken(authorization); diff --git a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java index 2c671abda9..cebe34c5f5 100644 --- a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java +++ b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java @@ -20,6 +20,9 @@ import java.util.Date; public class JWTUtils { + // token过期时间1min (过期会自动刷新续命 目的是避免一直都是同一个token ) + private static final long EXPIRE_TIME = 1 * 60 * 1000; + // 登录间隔时间10min 超过这个时间强制重新登录 private static long Login_Interval; /** @@ -64,7 +67,9 @@ public class JWTUtils { } public static boolean needRefresh(String token) { - return false; + Date exp = JWTUtils.getExp(token); + Long advanceTime = 5000L; + return (new Date().getTime() + advanceTime) >= exp.getTime(); } /** @@ -90,9 +95,18 @@ public class JWTUtils { return isExpire; } - + public static Date getExp(String token) { + try { + DecodedJWT jwt = JWT.decode(token); + return jwt.getClaim("exp").asDate(); + } catch (JWTDecodeException e) { + e.printStackTrace(); + return null; + } + } /** + * 生成签名,5min后过期 * * @param tokenInfo 用户信息 * @param secret 用户的密码 @@ -100,11 +114,12 @@ public class JWTUtils { */ public static String sign(TokenInfo tokenInfo, String secret) { try { + Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME); Algorithm algorithm = Algorithm.HMAC256(secret); Builder builder = JWT.create() .withClaim("username", tokenInfo.getUsername()) .withClaim("userId", tokenInfo.getUserId()); - String sign = builder.sign(algorithm); + String sign = builder.withExpiresAt(date).sign(algorithm); TokenCacheUtils.add(sign, tokenInfo.getUserId()); return sign; diff --git a/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java b/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java index bc936c3be5..338adbf2da 100644 --- a/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java +++ b/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils; public class TokenCacheUtils { private static final String KEY = "sys_token_store"; + private static final String DELAY_KEY = "sys_token_store_delay"; public static void add(String token, Long userId) { CacheUtils.put(KEY, token, userId, null, null); @@ -26,4 +27,12 @@ public class TokenCacheUtils { return ObjectUtils.isNotEmpty(sys_token_store) && StringUtils.isNotBlank(sys_token_store.toString()) && userId == Long.parseLong(sys_token_store.toString()); } + public static void addWithTtl(String token, Long userId) { + CacheUtils.put(DELAY_KEY, token, userId, 3, 5); + } + + public static boolean validateDelay(String token) { + Object tokenObj = CacheUtils.get(DELAY_KEY, token); + return ObjectUtils.isNotEmpty(tokenObj) && StringUtils.isNotBlank(tokenObj.toString()); + } } diff --git a/backend/src/main/resources/ehcache/ehcache.xml b/backend/src/main/resources/ehcache/ehcache.xml index eccd3b1661..f8d8591b20 100644 --- a/backend/src/main/resources/ehcache/ehcache.xml +++ b/backend/src/main/resources/ehcache/ehcache.xml @@ -277,9 +277,19 @@ maxElementsOnDisk="3000" overflowToDisk="true" diskPersistent="false" + /> + + - \ No newline at end of file From 13adc3de0bac706b84940699d649169004e1e372 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 20 Feb 2023 09:15:14 +0800 Subject: [PATCH 09/12] =?UTF-8?q?perf(token):=20token=E9=80=80=E5=87=BA?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E9=87=87=E7=94=A8token=E9=BB=91=E5=90=8D?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/auth/config/F2CRealm.java | 2 +- .../io/dataease/auth/filter/JWTFilter.java | 4 +- .../io/dataease/auth/server/AuthServer.java | 6 +- .../java/io/dataease/auth/util/JWTUtils.java | 2 - .../commons/utils/TokenCacheUtils.java | 72 ++++++++++++++----- 5 files changed, 61 insertions(+), 25 deletions(-) diff --git a/backend/src/main/java/io/dataease/auth/config/F2CRealm.java b/backend/src/main/java/io/dataease/auth/config/F2CRealm.java index 2084145759..504d8cfb6f 100644 --- a/backend/src/main/java/io/dataease/auth/config/F2CRealm.java +++ b/backend/src/main/java/io/dataease/auth/config/F2CRealm.java @@ -84,7 +84,7 @@ public class F2CRealm extends AuthorizingRealm { token = (String) auth.getCredentials(); // 解密获得username,用于和数据库进行对比 tokenInfo = JWTUtils.tokenInfoByToken(token); - if (!TokenCacheUtils.validate(token)) { + if (TokenCacheUtils.invalid(token)) { throw new AuthenticationException("token invalid"); } } catch (Exception e) { diff --git a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java index e5bd636789..0d70181289 100644 --- a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java +++ b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java @@ -66,7 +66,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { if (StringUtils.startsWith(authorization, "Basic")) { return false; } - if (!TokenCacheUtils.validate(authorization) && !TokenCacheUtils.validateDelay(authorization)) { + if (TokenCacheUtils.invalid(authorization)) { throw new AuthenticationException(expireMessage); } // 当没有出现登录超时 且需要刷新token 则执行刷新token @@ -75,8 +75,6 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { throw new AuthenticationException(expireMessage); } if (JWTUtils.needRefresh(authorization)) { - TokenCacheUtils.addWithTtl(authorization, 1L); - TokenCacheUtils.remove(authorization); authorization = refreshToken(request, response); } JWTToken token = new JWTToken(authorization); diff --git a/backend/src/main/java/io/dataease/auth/server/AuthServer.java b/backend/src/main/java/io/dataease/auth/server/AuthServer.java index 6e1fdafd57..ed7cdb0328 100644 --- a/backend/src/main/java/io/dataease/auth/server/AuthServer.java +++ b/backend/src/main/java/io/dataease/auth/server/AuthServer.java @@ -148,7 +148,7 @@ public class AuthServer implements AuthApi { AccountLockStatus lockStatus = authUserService.recordLoginFail(username, 0); DataEaseException.throwException(appendLoginErrorMsg(Translator.get("i18n_id_or_pwd_error"), lockStatus)); } - if(user.getIsAdmin() && user.getPassword().equals("40b8893ea9ebc2d631c4bb42bb1e8996")){ + if (user.getIsAdmin() && user.getPassword().equals("40b8893ea9ebc2d631c4bb42bb1e8996")) { result.put("passwordModified", false); } } @@ -237,7 +237,7 @@ public class AuthServer implements AuthApi { if (StringUtils.isBlank(result)) { result = "success"; } - TokenCacheUtils.remove(token); + TokenCacheUtils.add(token, userId); } catch (Exception e) { LogUtil.error(e); if (StringUtils.isBlank(result)) { @@ -291,7 +291,7 @@ public class AuthServer implements AuthApi { if (StringUtils.isBlank(result)) { result = "success"; } - TokenCacheUtils.remove(token); + TokenCacheUtils.add(token, userId); } catch (Exception e) { LogUtil.error(e); if (StringUtils.isBlank(result)) { diff --git a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java index cebe34c5f5..fc297d1e17 100644 --- a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java +++ b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java @@ -10,7 +10,6 @@ import com.auth0.jwt.interfaces.Verification; import io.dataease.auth.entity.TokenInfo; import io.dataease.auth.entity.TokenInfo.TokenInfoBuilder; import io.dataease.commons.utils.CommonBeanFactory; -import io.dataease.commons.utils.TokenCacheUtils; import io.dataease.exception.DataEaseException; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -120,7 +119,6 @@ public class JWTUtils { .withClaim("username", tokenInfo.getUsername()) .withClaim("userId", tokenInfo.getUserId()); String sign = builder.withExpiresAt(date).sign(algorithm); - TokenCacheUtils.add(sign, tokenInfo.getUserId()); return sign; } catch (Exception e) { diff --git a/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java b/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java index 338adbf2da..0bcec3b8c8 100644 --- a/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java +++ b/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java @@ -3,36 +3,76 @@ package io.dataease.commons.utils; import io.dataease.listener.util.CacheUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.stereotype.Component; +import java.util.concurrent.TimeUnit; + + +@Component public class TokenCacheUtils { + private static final String KEY = "sys_token_store"; - private static final String DELAY_KEY = "sys_token_store_delay"; + + private static String cacheType; + + private static Long expTime; + + @Value("${spring.cache.type:ehcache}") + public void setCacheType(String cacheType) { + TokenCacheUtils.cacheType = cacheType; + } + + @Value("${dataease.login_timeout:480}") + public void setExpTime(Long expTime) { + TokenCacheUtils.expTime = expTime; + } + + private static boolean useRedis() { + return StringUtils.equals(cacheType, "redis"); + } + + + private static ValueOperations cacheHandler() { + RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate"); + ValueOperations valueOperations = redisTemplate.opsForValue(); + return valueOperations; + } public static void add(String token, Long userId) { - CacheUtils.put(KEY, token, userId, null, null); + if (useRedis()) { + ValueOperations valueOperations = cacheHandler(); + valueOperations.set(KEY + token, userId, expTime, TimeUnit.MINUTES); + return; + } + + Long time = expTime * 60; + CacheUtils.put(KEY, token, userId, time.intValue(), null); + } public static void remove(String token) { + if (useRedis()) { + RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate"); + String key = KEY + token; + if (redisTemplate.hasKey(key)) { + redisTemplate.delete(key); + } + return; + } CacheUtils.remove(KEY, token); } - public static boolean validate(String token) { + public static boolean invalid(String token) { + if (useRedis()) { + RedisTemplate redisTemplate = (RedisTemplate) CommonBeanFactory.getBean("redisTemplate"); + return redisTemplate.hasKey(KEY + token); + } Object sys_token_store = CacheUtils.get(KEY, token); return ObjectUtils.isNotEmpty(sys_token_store) && StringUtils.isNotBlank(sys_token_store.toString()); } - public static boolean validate(String token, Long userId) { - Object sys_token_store = CacheUtils.get(KEY, token); - return ObjectUtils.isNotEmpty(sys_token_store) && StringUtils.isNotBlank(sys_token_store.toString()) && userId == Long.parseLong(sys_token_store.toString()); - } - - public static void addWithTtl(String token, Long userId) { - CacheUtils.put(DELAY_KEY, token, userId, 3, 5); - } - - public static boolean validateDelay(String token) { - Object tokenObj = CacheUtils.get(DELAY_KEY, token); - return ObjectUtils.isNotEmpty(tokenObj) && StringUtils.isNotBlank(tokenObj.toString()); - } } From 67672fbc94e0cca4e2f78214f19f744f016b4c90 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 20 Feb 2023 13:49:59 +0800 Subject: [PATCH 10/12] =?UTF-8?q?perf(=E7=99=BB=E5=BD=95):=20=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E9=92=89=E9=92=89=E5=B7=A5=E4=BD=9C=E5=8F=B0?= =?UTF-8?q?=E5=85=8D=E7=99=BB=E4=BD=BF=E7=94=A8DE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/ehcache/ehcache.xml | 18 ++++-------------- mobile/src/locale/zh-Hans.json | 2 +- mobile/src/locale/zh-Hant.json | 2 +- mobile/src/pages.json | 2 +- mobile/src/pages/login/index.vue | 11 +++++++++-- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/backend/src/main/resources/ehcache/ehcache.xml b/backend/src/main/resources/ehcache/ehcache.xml index f8d8591b20..5976911a62 100644 --- a/backend/src/main/resources/ehcache/ehcache.xml +++ b/backend/src/main/resources/ehcache/ehcache.xml @@ -273,23 +273,13 @@ - + \ No newline at end of file diff --git a/mobile/src/locale/zh-Hans.json b/mobile/src/locale/zh-Hans.json index afaed12e0f..3da2e19ea1 100644 --- a/mobile/src/locale/zh-Hans.json +++ b/mobile/src/locale/zh-Hans.json @@ -1,5 +1,5 @@ { - "app.name": "Hello uni-app", + "app.name": "DataEase", "navigate.menuHome": "首页", "navigate.menuDir": "目录", diff --git a/mobile/src/locale/zh-Hant.json b/mobile/src/locale/zh-Hant.json index a3b8f5f97c..ff6fb1f846 100644 --- a/mobile/src/locale/zh-Hant.json +++ b/mobile/src/locale/zh-Hant.json @@ -1,5 +1,5 @@ { - "app.name": "Hello uni-app", + "app.name": "DataEase", "navigate.menuHome": "首頁", "navigate.menuDir": "目錄", "navigate.menuMe": "我的", diff --git a/mobile/src/pages.json b/mobile/src/pages.json index 1fcfb0dc34..11a720f61d 100644 --- a/mobile/src/pages.json +++ b/mobile/src/pages.json @@ -4,7 +4,7 @@ { "path": "pages/login/index", "style": { - "navigationBarTitleText": "%navigate.login%", + "navigationBarTitleText": "%app.name%", "app-plus": { "titleNView": false } diff --git a/mobile/src/pages/login/index.vue b/mobile/src/pages/login/index.vue index 12b9d94dee..5c68fc6808 100644 --- a/mobile/src/pages/login/index.vue +++ b/mobile/src/pages/login/index.vue @@ -69,7 +69,7 @@ title: this.$t('commons.loading') }); this.loadUiInfo() - this.loadPublicKey() + this.loadPublicKey() if (!this.autoLogin() && getToken() && getUserInfo()) { this.toMain() } @@ -154,8 +154,15 @@ const url = window.location.href const param = getUrlParams(url) if (param?.detoken) { + if(param.detoken.endsWith('#/')) + param.detoken = param.detoken.substr(0, param.detoken.length - 2) setToken(param.detoken) - this.toMain() + getInfo().then(res => { + setUserInfo(res.data) + const redirect = window.location.href.split('?')[0] + + window.location.href = redirect + }) return true } return false From d9b664f86db371b19bd1a3142eb17809e44d4880 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 20 Feb 2023 15:01:22 +0800 Subject: [PATCH 11/12] =?UTF-8?q?perf(=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?):=20=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=97=B6=E5=A2=9E=E5=8A=A0=E9=A1=B5=E9=9D=A2=E9=81=AE=E7=BD=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/system/user.js | 1 + frontend/src/views/system/user/UserEditer.vue | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/api/system/user.js b/frontend/src/api/system/user.js index cdfc543a6d..6b366912e4 100644 --- a/frontend/src/api/system/user.js +++ b/frontend/src/api/system/user.js @@ -35,6 +35,7 @@ export const addUser = (data) => { return request({ url: pathMap.createPath, method: 'post', + loading: true, data }) } diff --git a/frontend/src/views/system/user/UserEditer.vue b/frontend/src/views/system/user/UserEditer.vue index 5635d732a8..5e58d7b4c8 100644 --- a/frontend/src/views/system/user/UserEditer.vue +++ b/frontend/src/views/system/user/UserEditer.vue @@ -1,5 +1,6 @@