Skip to content

Commit

Permalink
support share file
Browse files Browse the repository at this point in the history
  • Loading branch information
lixinyang123 committed Jul 4, 2024
1 parent c1bad73 commit fef5525
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async function init() {

//初始化导航
window.onpopstate = (e) => {
navigate(e.state.page, true);
navigate(e.target.location.hash.substring(1), true);
}

//获取当前用户
Expand Down
34 changes: 24 additions & 10 deletions js/toss.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const api = 'https://oss.conchbrain.club'
var api = 'https://oss.conchbrain.club'
var prefix = 'oss_key'

let files = []
let totalSize = 0
let uploadedSize = 0;
let fileHandlers = []
var files = []
var totalSize = 0
var uploadedSize = 0;
var fileHandlers = []

function keyBase() {
let key = 'oss_key'
let base = localStorage.getItem(key)
let base = localStorage.getItem(prefix)
if (!base) {
base = guid()
localStorage.setItem(key, base)
localStorage.setItem(prefix, base)
}
return base
}
Expand Down Expand Up @@ -215,5 +215,19 @@ async function showUploaded() {
render(handlers, '#uploaded')
}

render(fileHandlers)
showUploaded()
function init() {
let regex = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/
let href = location.href.substring(location.href.indexOf("#") + 1)
let id = href.split('/').at(1)

if (!id || !regex.test(id)) {
navigate(`toss/${keyBase()}`)
return
}

localStorage.setItem(prefix, id)
render(fileHandlers)
showUploaded()
}

init()

0 comments on commit fef5525

Please sign in to comment.