Skip to content

Commit

Permalink
perf: ⚡️ 压缩给文件名添加时间戳, 方式粘贴的截图重名导致重复命名覆盖文件
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaochao.yang committed Oct 25, 2022
1 parent c6e8fdc commit 420fdb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CHANGELOG

## v2.0.1
- perf: 压缩给文件名添加时间戳, 方式粘贴的截图重名导致重复命名覆盖文件
## v2.0.0
- docs: 文档更新, 正式发布

Expand Down
8 changes: 5 additions & 3 deletions src/plugins/Tiny.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import tiny from '@mxsir/image-tiny';
import { TINY_SUPPORTE } from './config';
import { Fs } from '@/utils/fs';
import { Plugin } from './Plugin';
import dayjs from 'dayjs';

export interface TinyConfig {
quality: number;
Expand Down Expand Up @@ -30,15 +31,16 @@ export class TinyPlugin extends Plugin {

async upload(file: File, alias: string): Promise<StoreItem> {
const buffer = await file.arrayBuffer();
const url = await Fs.wirte(file.name, buffer);
const fileName = `${+dayjs()}_${file.name}`;
const url = await Fs.wirte(fileName, buffer);

const ret: StoreItem = {
size: file.size,
alias,
scope: this.name,
hash: file.name,
hash: fileName,
dir: '',
name: file.name,
name: fileName,
url: `file://${url}`,
create_time: +new Date(),
extra: '',
Expand Down

1 comment on commit 420fdb2

@vercel
Copy link

@vercel vercel bot commented on 420fdb2 Oct 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

rush – ./

rush-git-master-charlzyx.vercel.app
rush-charlzyx.vercel.app
rushapp.vercel.app

Please sign in to comment.