Skip to content

Commit

Permalink
fix 安卓手机app 打开不同审批单的同名附件时, 显示的不是最新的
Browse files Browse the repository at this point in the history
  • Loading branch information
baozhoutao committed Jan 11, 2025
1 parent 1a73722 commit f764d17
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions creator/packages/steedos-base/client/helpers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,25 @@ TemplateHelpers =
url = url + '?token=' + token
return url

generateShortStringFromUrl = (url, length = 6) ->
# 简单哈希函数
hash = 0
for i in [0...url.length]
char = url.charCodeAt(i)
hash = (hash << 5) - hash + char
hash |= 0 # 转换为32位整数

# 基于哈希生成的随机字符串
characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
shortString = ''

# 生成指定长度的短字符串
for i in [0...length]
shortString += characters[Math.abs(hash) % characters.length]
hash = Math.floor(hash / characters.length)

shortString

cordovaDownload: (url, filename, rev, length) ->
url = Steedos.addTokenTodownloadUrl(url)

Expand Down Expand Up @@ -853,6 +872,10 @@ TemplateHelpers =
directory = ""
if Steedos.isAndroidApp()
directory = cordova.file.externalCacheDirectory
try
fileName = Steedos.generateShortStringFromUrl(url) + '-' + filename
catch e
console.log(e)
else
directory = cordova.file.cacheDirectory

Expand Down

0 comments on commit f764d17

Please sign in to comment.