-
Notifications
You must be signed in to change notification settings - Fork 505
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
base: master
Are you sure you want to change the base?
Conversation
# Reviewed, transaction id: 30681
…o issue_11467 # Reviewed, transaction id: 31521
# Reviewed, transaction id: 31544
# Reviewed, transaction id: 31625
extractRandomString (path) { | ||
const RANDOM_STRING_REGEX = /\/([A-Za-z0-9]{8})\// | ||
const match = path.match(RANDOM_STRING_REGEX) | ||
return match ? match[1] : null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
this.updatePath() | ||
}, | ||
generateUniqueRandomString (existingStrings, length = 8) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你这里判断每次都给个新的Set, 意义是什么?
# Reviewed, transaction id: 33316
# Reviewed, transaction id: 33320
# Reviewed, transaction id: 33891
# Reviewed, transaction id: 34104
# Reviewed, transaction id: 34142
# Reviewed, transaction id: 34448
# Reviewed, transaction id: 34504
handler () { | ||
this.splitFilePath() | ||
}, | ||
handler: 'splitFilePath', |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不需要再这么写呀,直接把外层的randomSubPath更新一下就可以
# Reviewed, transaction id: 34634
handleEnableVersionControl (value) { | ||
if (!this.flex && !value) { | ||
this.handleChange('randomStringInPath', '') | ||
} |
There was a problem hiding this comment.
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] : []), |
There was a problem hiding this comment.
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) | ||
} |
There was a problem hiding this comment.
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 : ''
# Reviewed, transaction id: 34660
#11467