add base url
This commit is contained in:
@@ -184,7 +184,7 @@ const reloadItems = computed({
|
||||
|
||||
const reloadData = async () => {
|
||||
const request = [...new Set(reloadItems.value.map(r => r.split('-')[1]))]
|
||||
const data = await HttpUtils.get('/api/status',{ r: request.join(',')})
|
||||
const data = await HttpUtils.get('api/status',{ r: request.join(',')})
|
||||
if (data.success) {
|
||||
tilesData.value = data.obj
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ const menu = [
|
||||
]
|
||||
|
||||
const logout = async () => {
|
||||
const response = await HttpUtil.get('/api/logout')
|
||||
const response = await HttpUtil.get('api/logout')
|
||||
if(response.success){
|
||||
router.push('/login')
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ export default {
|
||||
methods: {
|
||||
async loadData(limit: number) {
|
||||
this.loading = true
|
||||
const data = await HttpUtils.get('/api/stats', { resource: this.resource, tag: this.tag, limit: limit })
|
||||
const data = await HttpUtils.get('api/stats', { resource: this.resource, tag: this.tag, limit: limit })
|
||||
if (data.success && data.obj) {
|
||||
const obj = <any[]>data.obj
|
||||
const l = String(i18n.global.locale) == 'fa' ? "fa-IR" : "en-US"
|
||||
|
||||
@@ -86,6 +86,7 @@ export default {
|
||||
sub: "Subscription",
|
||||
addr: "Address",
|
||||
port: "Port",
|
||||
webPath: "Base URI",
|
||||
domain: "Domain",
|
||||
sslKey: "SSL Key Path",
|
||||
sslCert: "SSL Certificate Path",
|
||||
|
||||
@@ -86,6 +86,7 @@ export default {
|
||||
sub: "سابسکریپشن",
|
||||
addr: "آدرس",
|
||||
port: "پورت",
|
||||
webPath: "مسیر پایه",
|
||||
domain: "دامنه",
|
||||
sslKey: "مسیر فایل کلید",
|
||||
sslCert: "مسیر فایل گواهی",
|
||||
|
||||
@@ -3,6 +3,8 @@ import axios from 'axios'
|
||||
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
|
||||
|
||||
axios.defaults.baseURL = "./"
|
||||
|
||||
axios.interceptors.request.use(
|
||||
(config) => {
|
||||
if (config.data instanceof FormData) {
|
||||
|
||||
@@ -54,7 +54,7 @@ const routes = [
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(process.env.BASE_URL),
|
||||
history: createWebHistory((window as any).BASE_URL),
|
||||
routes,
|
||||
})
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ const Data = defineStore('Data', {
|
||||
}),
|
||||
actions: {
|
||||
async loadData() {
|
||||
const msg = await HttpUtils.get('/api/load', this.lastLoad >0 ? {lu: this.lastLoad} : {} )
|
||||
const msg = await HttpUtils.get('api/load', this.lastLoad >0 ? {lu: this.lastLoad} : {} )
|
||||
if(msg.success) {
|
||||
this.lastLoad = Math.floor((new Date()).getTime()/1000)
|
||||
|
||||
@@ -36,7 +36,7 @@ const Data = defineStore('Data', {
|
||||
config: JSON.stringify(FindDiff.Config(this.config,this.oldData.config)),
|
||||
clients: JSON.stringify(FindDiff.Clients(this.clients,this.oldData.clients)),
|
||||
}
|
||||
const msg = await HttpUtils.post('/api/save',diff)
|
||||
const msg = await HttpUtils.post('api/save',diff)
|
||||
if(msg.success) {
|
||||
this.loadData()
|
||||
}
|
||||
@@ -46,7 +46,7 @@ const Data = defineStore('Data', {
|
||||
config: JSON.stringify([{key: "inbounds", action: "del", index: index, obj: null}]),
|
||||
clients: JSON.stringify(FindDiff.Clients(this.clients,this.oldData.clients)),
|
||||
}
|
||||
const msg = await HttpUtils.post('/api/save',diff)
|
||||
const msg = await HttpUtils.post('api/save',diff)
|
||||
if(msg.success) {
|
||||
this.loadData()
|
||||
}
|
||||
@@ -56,7 +56,7 @@ const Data = defineStore('Data', {
|
||||
config: JSON.stringify(FindDiff.Config(this.config,this.oldData.config)),
|
||||
clients:JSON.stringify([{key: "clients", action: "del", index: id, obj: null}]),
|
||||
}
|
||||
const msg = await HttpUtils.post('/api/save',diff)
|
||||
const msg = await HttpUtils.post('api/save',diff)
|
||||
if(msg.success) {
|
||||
this.loadData()
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<v-tooltip activator="parent" dir="ltr" location="bottom" v-if="Object.hasOwn(item,'users')">
|
||||
<span v-for="u in findInbounsUsers(item)">{{ u }}<br /></span>
|
||||
</v-tooltip>
|
||||
{{ Object.hasOwn(item,'users') ? item.users.length : '-' }}
|
||||
{{ Array.isArray(item.users) ? item.users.length : '-' }}
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
|
||||
@@ -63,7 +63,7 @@ const router = useRouter()
|
||||
const login = async () => {
|
||||
if (username.value == '' || password.value == '') return
|
||||
loading.value=true
|
||||
const response = await HttpUtil.post('/api/login',{user: username.value, pass: password.value})
|
||||
const response = await HttpUtil.post('api/login',{user: username.value, pass: password.value})
|
||||
if(response.success){
|
||||
setTimeout(() => {
|
||||
loading.value=false
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
<v-col cols="12" sm="6" md="4">
|
||||
<v-text-field v-model="webPort" :label="$t('setting.port')" hide-details></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" md="4">
|
||||
<v-text-field v-model="settings.webPath" :label="$t('setting.webPath')" hide-details></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" md="4">
|
||||
<v-text-field v-model="settings.webDomain" :label="$t('setting.domain')" hide-details></v-text-field>
|
||||
</v-col>
|
||||
@@ -143,6 +146,7 @@ const settings = ref({
|
||||
webPort: "2095",
|
||||
webCertFile: "",
|
||||
webKeyFile: "",
|
||||
webPath: "/app/",
|
||||
sessionMaxAge: "0",
|
||||
timeLocation: "Asia/Tehran",
|
||||
subListen: "",
|
||||
@@ -166,7 +170,7 @@ const changeLocale = (l: any) => {
|
||||
|
||||
const loadData = async () => {
|
||||
loading.value = true
|
||||
const msg = await HttpUtils.get('/api/setting')
|
||||
const msg = await HttpUtils.get('api/setting')
|
||||
loading.value = false
|
||||
if (msg.success) {
|
||||
settings.value = msg.obj
|
||||
@@ -179,7 +183,7 @@ const saveChanges = async () => {
|
||||
const diff = {
|
||||
settings: JSON.stringify(FindDiff.Settings(settings.value,oldSettings.value)),
|
||||
}
|
||||
const msg = await HttpUtils.post('/api/save', diff)
|
||||
const msg = await HttpUtils.post('api/save', diff)
|
||||
if (msg.success) {
|
||||
loadData()
|
||||
}
|
||||
@@ -190,17 +194,17 @@ const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
|
||||
|
||||
const restartApp = async () => {
|
||||
loading.value = true
|
||||
const msg = await HttpUtils.post('/api/restartApp',{})
|
||||
const msg = await HttpUtils.post('api/restartApp',{})
|
||||
if (msg.success) {
|
||||
const isTLS = settings.value.webCertFile !== "" || settings.value.webKeyFile !== ""
|
||||
const url = buildURL(settings.value.webDomain,settings.value.webPort.toString(),isTLS)
|
||||
const url = buildURL(settings.value.webDomain,settings.value.webPort.toString(),isTLS, settings.value.webPath)
|
||||
await sleep(3000)
|
||||
window.location.replace(url)
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const buildURL = (host: string, port: string, isTLS: boolean ) => {
|
||||
const buildURL = (host: string, port: string, isTLS: boolean, path: string) => {
|
||||
if (!host || host.length == 0) host = window.location.hostname
|
||||
if (!port || port.length == 0) port = window.location.port
|
||||
|
||||
@@ -212,7 +216,7 @@ const buildURL = (host: string, port: string, isTLS: boolean ) => {
|
||||
port = `:${port}`
|
||||
}
|
||||
|
||||
return `${protocol}//${host}${port}/settings`
|
||||
return `${protocol}//${host}${port}${path}settings`
|
||||
}
|
||||
|
||||
const subEncode = computed({
|
||||
@@ -245,7 +249,6 @@ const subUpdates = computed({
|
||||
set: (v:number) => { settings.value.subUpdates = v.toString() }
|
||||
})
|
||||
|
||||
|
||||
const stateChange = computed(() => {
|
||||
return !FindDiff.deepCompare(settings.value,oldSettings.value)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user