diff --git a/public/i18n/en.yml b/public/i18n/en.yml index 14b4e1c..641ccc4 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -392,6 +392,7 @@ MANAGE_SETTING_CLEAR_CACHE_TIPS: After clearing, the file list will be reloaded MANAGE_SETTING_CLEAR_CACHE_PROMPT: Are you sure you want to clear the file list cache database? MANAGE_SETTING_CLEAR_CACHE_BUTTON: Clear MANAGE_SETTING_ISSHOWTHUMBNAIL_TITLE: Display the original image instead of format icon (requires public access permissions) +MANAGE_SETTING_ISUSEPRESIGNEDURL_TITLE: Use presigned URL for image display MANAGE_SETTING_ISSHOWLIST_TITLE: Default display mode for the file list MANAGE_SETTING_ISSHOWLIST_ON: List MANAGE_SETTING_ISSHOWLIST_OFF: Card diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index f6bf7f1..4703f7a 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -394,6 +394,7 @@ MANAGE_SETTING_CLEAR_CACHE_TIPS: 清空后下次进入新目录时将会重新 MANAGE_SETTING_CLEAR_CACHE_PROMPT: 确定要清空文件列表缓存数据库吗? MANAGE_SETTING_CLEAR_CACHE_BUTTON: 清空 MANAGE_SETTING_ISSHOWTHUMBNAIL_TITLE: 图片显示为原图而非默认文件格式图标(需要存储桶可公开访问) +MANAGE_SETTING_ISUSEPRESIGNEDURL_TITLE: 使用预签名URL预览图片 MANAGE_SETTING_ISSHOWLIST_TITLE: 文件列表默认显示方式 MANAGE_SETTING_ISSHOWLIST_ON: 列表 MANAGE_SETTING_ISSHOWLIST_OFF: 卡片 diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index fb8a72a..22efdab 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -392,6 +392,7 @@ MANAGE_SETTING_CLEAR_CACHE_TIPS: 清空後下次進入新目錄時將會重新 MANAGE_SETTING_CLEAR_CACHE_PROMPT: 確定要清空檔案列表快取資料庫嗎? MANAGE_SETTING_CLEAR_CACHE_BUTTON: 清空 MANAGE_SETTING_ISSHOWTHUMBNAIL_TITLE: 顯示圖片的原始圖像而非預設的檔案格式圖示(需要存儲桶公開訪問權限) +MANAGE_SETTING_ISUSEPRESIGNEDURL_TITLE: 使用預簽名URL预览圖片 MANAGE_SETTING_ISSHOWLIST_TITLE: 檔案列表預設顯示方式 MANAGE_SETTING_ISSHOWLIST_ON: 列表 MANAGE_SETTING_ISSHOWLIST_OFF: 卡片 diff --git a/src/renderer/components/ImagePreSign.vue b/src/renderer/components/ImagePreSign.vue new file mode 100644 index 0000000..a514e35 --- /dev/null +++ b/src/renderer/components/ImagePreSign.vue @@ -0,0 +1,51 @@ + + + diff --git a/src/renderer/components/ImagePreSignTsx.tsx b/src/renderer/components/ImagePreSignTsx.tsx new file mode 100644 index 0000000..de0a8b2 --- /dev/null +++ b/src/renderer/components/ImagePreSignTsx.tsx @@ -0,0 +1,65 @@ +import { ElImage, ElIcon } from 'element-plus' +import { defineComponent, ref, onMounted, watch, computed } from 'vue' +import { Loading } from '@element-plus/icons-vue' + +import { getFileIconPath } from '@/manage/utils/common' +import { IRPCActionType } from '#/types/enum' +import { triggerRPC } from '@/utils/common' + +export default defineComponent({ + props: { + isShowThumbnail: { + type: Boolean, + required: true + }, + item: { + type: Object, + required: true + }, + alias: { + type: String, + required: true + }, + url: { + type: String, + required: true + }, + config: { + type: Object, + required: true + } + }, + + setup(props) { + const preSignedUrl = ref('') + + const imageSource = computed(() => { + return props.isShowThumbnail && props.item.isImage + ? preSignedUrl.value + : require(`../manage/pages/assets/icons/${getFileIconPath(props.item.fileName ?? '')}`) + }) + const iconPath = computed(() => + require(`../manage/pages/assets/icons/${getFileIconPath(props.item.fileName ?? '')}`) + ) + + async function getUrl() { + preSignedUrl.value = await triggerRPC(IRPCActionType.MANAGE_GET_PRE_SIGNED_URL, props.alias, props.config) + } + + watch(() => [props.url, props.item], getUrl, { deep: true }) + onMounted(getUrl) + + return () => ( + + {{ + placeholder: () => ( + + + + ), + error: () => + }} + + ) + } +}) diff --git a/src/renderer/manage/components/DynamicSwitch.vue b/src/renderer/manage/components/DynamicSwitch.vue index 9ac22d5..3ef9a0e 100644 --- a/src/renderer/manage/components/DynamicSwitch.vue +++ b/src/renderer/manage/components/DynamicSwitch.vue @@ -5,7 +5,7 @@ {{ segment.text }} - + diff --git a/src/renderer/manage/pages/BucketPage.vue b/src/renderer/manage/pages/BucketPage.vue index bde0b40..8abdf1c 100644 --- a/src/renderer/manage/pages/BucketPage.vue +++ b/src/renderer/manage/pages/BucketPage.vue @@ -391,12 +391,7 @@ https://www.baidu.com/img/bd_logo1.png" shadow="hover" > + + + + + manageStore.config.settings.isShowThumbnail ?? false) +const isUsePreSignedUrl = computed(() => manageStore.config.settings.isUsePreSignedUrl ?? false) const isAutoRefresh = computed(() => manageStore.config.settings.isAutoRefresh ?? false) const isIgnoreCase = computed(() => manageStore.config.settings.isIgnoreCase ?? false) @@ -2901,6 +2932,18 @@ function singleRename() { }) } +function handleGetS3Config(item: any) { + return { + bucketName: configMap.bucketName, + region: configMap.bucketConfig.Location, + key: item.key, + customUrl: currentCustomDomain.value, + expires: manageStore.config.settings.PreSignedExpire, + githubPrivate: configMap.bucketConfig.private, + rawUrl: item.url + } +} + async function getPreSignedUrl(item: any) { const param = { // tcyun @@ -3180,32 +3223,42 @@ const columns: Column[] = [ reference: () => !item.isDir ? ( currentPicBedName.value !== 'webdavplist' ? ( - + ) : ( + - {{ - placeholder: () => ( - - - - ), - error: () => ( - - ) - }} - + } + fit='contain' + style={{ width: '20px', height: '20px' }} + > + {{ + placeholder: () => ( + + + + ), + error: () => ( + + ) + }} + + ) ) : item.isImage ? ( [] = [ config={handleGetWebdavConfig()} url={item.url} /> + ) : currentPicBedName.value === 's3plist' && item.isImage && isUsePreSignedUrl.value ? ( + ) : ( ({ isAutoRefresh: false, isShowThumbnail: false, isShowList: false, + isUsePreSignedUrl: false, isIgnoreCase: false, isForceCustomUrlHttps: false, isEncodeUrl: false, @@ -246,6 +247,7 @@ const switchFieldsList = [ 'isAutoRefresh', 'isShowThumbnail', 'isShowList', + 'isUsePreSignedUrl', 'isForceCustomUrlHttps', 'isEncodeUrl', 'isUploadKeepDirStructure', @@ -254,7 +256,7 @@ const switchFieldsList = [ 'randomStringRename', 'customRename' ] -const switchFieldsNoTipsList = ['isShowThumbnail', 'isShowList'] +const switchFieldsNoTipsList = ['isShowThumbnail', 'isShowList', 'isUsePreSignedUrl'] const switchFieldsHasActiveTextList = ['isShowList'] const switchFieldsConfigList = switchFieldsList.map(item => ({ diff --git a/src/universal/types/i18n.d.ts b/src/universal/types/i18n.d.ts index bc2b172..ea6c360 100644 --- a/src/universal/types/i18n.d.ts +++ b/src/universal/types/i18n.d.ts @@ -368,6 +368,7 @@ interface ILocales { MANAGE_SETTING_CLEAR_CACHE_PROMPT: string MANAGE_SETTING_CLEAR_CACHE_BUTTON: string MANAGE_SETTING_ISSHOWTHUMBNAIL_TITLE: string + MANAGE_SETTING_ISUSEPRESIGNEDURL_TITLE: string MANAGE_SETTING_ISSHOWLIST_TITLE: string MANAGE_SETTING_ISSHOWLIST_ON: string MANAGE_SETTING_ISSHOWLIST_OFF: string