You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
chore: move files to frontend
This commit is contained in:
16
frontend/src/api/commands.js
Normal file
16
frontend/src/api/commands.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { removePrefix } from './utils'
|
||||
import { baseURL } from '@/utils/constants'
|
||||
import store from '@/store'
|
||||
|
||||
const ssl = (window.location.protocol === 'https:')
|
||||
const protocol = (ssl ? 'wss:' : 'ws:')
|
||||
|
||||
export default function command(url, command, onmessage, onclose) {
|
||||
url = removePrefix(url)
|
||||
url = `${protocol}//${window.location.host}${baseURL}/api/command${url}?auth=${store.state.jwt}`
|
||||
|
||||
let conn = new window.WebSocket(url)
|
||||
conn.onopen = () => conn.send(command)
|
||||
conn.onmessage = onmessage
|
||||
conn.onclose = onclose
|
||||
}
|
||||
Reference in New Issue
Block a user