From 1809bc4e09f686356fdc90c4122f0456abaa9a6e Mon Sep 17 00:00:00 2001 From: seaheart Date: Thu, 9 Nov 2023 23:40:44 +0800 Subject: [PATCH] fix some safety problem and add copy share feature --- craco.config.js | 13 +++++++------ src/pages/share/Detail.tsx | 6 +++++- src/pages/share/List.tsx | 2 ++ src/pages/share/widget/ShareDialogModal.tsx | 6 ++---- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/craco.config.js b/craco.config.js index cd61907..20e2ceb 100644 --- a/craco.config.js +++ b/craco.config.js @@ -9,25 +9,26 @@ module.exports = { target: 'http://localhost:6010', changeOrigin: true, pathRewrite: { - '^/api': '/api' - } - } + '^/api': '/api', + }, + }, }, }, plugins: [ { - // less loader. plugin: CracoLessPlugin, options: { // resolve-url-loader只对sass生效,craco-less默认使用sass配置,所以这里手动过滤掉resolve-url-loader modifyLessRule: (lessRule) => { - lessRule.use = lessRule.use.filter(i => !i.loader.includes('resolve-url-loader')); + lessRule.use = lessRule.use.filter( + (i) => !i.loader.includes('resolve-url-loader') + ); return lessRule; }, lessLoaderOptions: { lessOptions: { - modifyVars: {'@primary-color': '#215891'}, + modifyVars: { '@primary-color': '#215891' }, javascriptEnabled: true, }, }, diff --git a/src/pages/share/Detail.tsx b/src/pages/share/Detail.tsx index b388b14..e47d0c3 100644 --- a/src/pages/share/Detail.tsx +++ b/src/pages/share/Detail.tsx @@ -59,7 +59,11 @@ export default class Detail extends TankComponent { this.share.uuid = this.props.match.params.uuid; this.pager.urlPage = Share.URL_MATTER_PAGE; - if (this.user.hasLogin()) { + if (!!BrowserUtil.getQueryByName('code')) { + this.getFiles(BrowserUtil.getQueryByName('code')!); + // 去除url中的code query + window.history.replaceState({}, '', window.location.pathname); + } else if (this.user.hasLogin()) { this.pager.enableHistory(); this.refresh(); } diff --git a/src/pages/share/List.tsx b/src/pages/share/List.tsx index 1e72c9e..643fe3a 100644 --- a/src/pages/share/List.tsx +++ b/src/pages/share/List.tsx @@ -9,6 +9,7 @@ import ShareBar from './widget/ShareBar'; import './List.less'; import Lang from '../../common/model/global/Lang'; +import SortDirection from '../../common/model/base/SortDirection'; interface IProps extends RouteComponentProps {} @@ -23,6 +24,7 @@ export default class List extends TankComponent { componentDidMount() { this.pager.enableHistory(); + this.pager.setFilterValue('orderCreateTime', SortDirection.DESC); this.refresh(); } diff --git a/src/pages/share/widget/ShareDialogModal.tsx b/src/pages/share/widget/ShareDialogModal.tsx index 535f34a..e9b4914 100644 --- a/src/pages/share/widget/ShareDialogModal.tsx +++ b/src/pages/share/widget/ShareDialogModal.tsx @@ -30,10 +30,8 @@ export default class ShareDialogModal extends TankComponent { copyAll() { const { share } = this.props; - const text = `${Lang.t('share.link')}:${share.getLink()} ${Lang.t( - 'share.code' - )}:${share.code}`; - this.clipboard(text); + const url = `${share.getLink()}?code=${share.code}`; + this.clipboard(url); } static open = (share: Share) => {