add base url

This commit is contained in:
Alireza Ahmadi
2024-02-26 19:01:01 +01:00
parent 30c9ed6aa7
commit c54d9c15bc
16 changed files with 80 additions and 30 deletions
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -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')
}
+1 -1
View File
@@ -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"
+1
View File
@@ -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",
+1
View File
@@ -86,6 +86,7 @@ export default {
sub: "سابسکریپشن",
addr: "آدرس",
port: "پورت",
webPath: "مسیر پایه",
domain: "دامنه",
sslKey: "مسیر فایل کلید",
sslCert: "مسیر فایل گواهی",
+2
View File
@@ -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) {
+1 -1
View File
@@ -54,7 +54,7 @@ const routes = [
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
history: createWebHistory((window as any).BASE_URL),
routes,
})
+4 -4
View File
@@ -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()
}
+1 -1
View File
@@ -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>
+1 -1
View File
@@ -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
+10 -7
View File
@@ -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)
})