Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:文件类型变量上传的文件支持版本管理 #11467 #11482

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

useryuyu
Copy link
Collaborator

extractRandomString (path) {
const RANDOM_STRING_REGEX = /\/([A-Za-z0-9]{8})\//
const match = path.match(RANDOM_STRING_REGEX)
return match ? match[1] : null
Copy link
Collaborator

Choose a reason for hiding this comment

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

你这里通过正则去拿,有可能会不准,比如这样
image

}
this.updatePath()
},
generateUniqueRandomString (existingStrings, length = 8) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

有randomString这个方法,在utils里面不用自己写


if (this.enableVersionControl) {
const uniqueStrings = new Set()
this.fileDefaultVal.randomFilePath = this.generateUniqueRandomString(uniqueStrings)
Copy link
Collaborator

Choose a reason for hiding this comment

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

你这里判断每次都给个新的Set, 意义是什么?

@tencentblueking-adm
Copy link

tencentblueking-adm commented Mar 14, 2025

CLA assistant check
All committers have signed the CLA.

handler () {
this.splitFilePath()
},
handler: 'splitFilePath',
Copy link
Collaborator

Choose a reason for hiding this comment

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

handler: funciton (newValue) {
                this.enableVersionControl = this.versionControl
                const lastSlashIndex = newValue.lastIndexOf('/')
                this.fileDefaultVal.fileName = newValue.slice(lastSlashIndex + 1)
                
                const randomFile = this.extractRandomString(newValue)
                if (this.enableVersionControl && randomFile) {
                    const lastIndex = newValue.lastIndexOf('/', lastSlashIndex - 1)
                    this.fileDefaultVal.randomFilePath = randomFile
                    this.fileDefaultVal.directory = newValue.slice(0, lastIndex)
                } else {
                    this.fileDefaultVal.directory = newValue.slice(0, lastSlashIndex)
                }
            },

uploadFileName: ''
directory: '',
fileName: '',
randomFilePath: that.randomSubPath
Copy link
Collaborator

Choose a reason for hiding this comment

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

不需要再去维护一份randomFilePath数据了, 还有,that没意义,直接用this一样的

handler () {
this.splitFilePath()
handler: function (newValue) {
const currentValue = newValue.directory ?? newValue
Copy link
Collaborator

Choose a reason for hiding this comment

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

外层已经有处理数据了这里的value就不会是object了

this.fileName = currentValue.slice(lastSlashIndex + 1)

if (this.enableVersionControl && this.randomFilePath) {
this.randomFilePath = this.randomSubPath
Copy link
Collaborator

Choose a reason for hiding this comment

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

这一行可以不要,不需要再在里面维护一个randomFilePath

this.randomFilePath = ''
}
this.handleChange('enableVersionControl', value)
this.updatePath('enableVersionControl', value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里不需要再这么写呀,直接把外层的randomSubPath更新一下就可以

handleEnableVersionControl (value) {
if (!this.flex && !value) {
this.handleChange('randomStringInPath', '')
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

统一在updatePath里面做这个就行了,不需要再在这里多弄一个


const path = [
this.directory,
...(randomFilePath ? [randomFilePath] : []),
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里应该是以this.enableVersionControl为判断条件的

let randomFilePath = this.randomSubPath
if (newFile && this.enableVersionControl) {
randomFilePath = randomString(8)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this[name] = value
let randomFilePath = this.enableVersionControl ? this.randomSubPath : ''

@bkci-bot bkci-bot added the for test Test environment in tencent has been deploy label Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for test Test environment in tencent has been deploy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants