You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/oaer/lib/cfg.ts

65 lines
1.1 KiB
TypeScript

/*
* cfg.ts
* Copyright (C) 2024 veypi <i@veypi.com>
* 2024-07-03 18:22
* Distributed under terms of the MIT license.
*/
1 month ago
import proxy from './components/proxy'
let cfg = proxy.Watch({
uuid: '',
refresh: '',
token: '',
app_data: {},
user: {
username: 'asd',
nickname: '',
email: '',
phone: '',
icon: 'https://public.veypi.com/img/avatar/0001.jpg'
},
ready: false,
local_user: {},
host: '',
_host_nats: '',
nats_pub_key: '',
prefix: '/api',
BaseUrl() {
return this.host + this.prefix
},
NatsHost() {
if (this._host_nats.startsWith('ws')) {
return this._host_nats
}
return 'ws://' + this._host_nats
},
media(u: string) {
return this.host + u
},
goto(url: string) {
if (url.startsWith('http')) {
window.location.href = url
return
}
if (!url.startsWith('/')) {
url = '/' + url
}
window.location.href = this.host + url
},
Host() {
return this.host || window.location.host
},
userFileUrl() {
return '/fs/u/'
},
appFileUrl() {
return `/fs/a/${this.uuid}/`
},
1 month ago
})
export default cfg