/* * cfg.ts * Copyright (C) 2024 veypi * 2024-07-03 18:22 * Distributed under terms of the MIT license. */ import proxy from './components/proxy' let cfg = proxy.Watch({ uuid: '', refresh: '', token: '', app_data: {}, user: { username: 'asd', nickname: '', email: '', phone: '', id: 1, icon: 'https://public.veypi.com/img/avatar/0001.jpg' }, myapps: [ { name: 'a' }, { name: 'b' }, ], 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}/` }, }) export default cfg