init
This commit is contained in:
4
frontend/admin/src/App.vue
Normal file
4
frontend/admin/src/App.vue
Normal file
@@ -0,0 +1,4 @@
|
||||
<template>
|
||||
<router-view />
|
||||
</template>
|
||||
|
||||
7
frontend/admin/src/api.ts
Normal file
7
frontend/admin/src/api.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import axios from 'axios'
|
||||
import { getApiBaseURL } from './tenant'
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: getApiBaseURL(),
|
||||
})
|
||||
|
||||
2
frontend/admin/src/env.d.ts
vendored
Normal file
2
frontend/admin/src/env.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
6
frontend/admin/src/main.ts
Normal file
6
frontend/admin/src/main.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createApp } from 'vue'
|
||||
import { router } from './router'
|
||||
import App from './App.vue'
|
||||
|
||||
createApp(App).use(router).mount('#app')
|
||||
|
||||
12
frontend/admin/src/router.ts
Normal file
12
frontend/admin/src/router.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { getAdminRouterBase } from './tenant'
|
||||
import DashboardPage from './views/DashboardPage.vue'
|
||||
|
||||
export const router = createRouter({
|
||||
history: createWebHistory(getAdminRouterBase()),
|
||||
routes: [
|
||||
{ path: '/', component: DashboardPage },
|
||||
{ path: '/:pathMatch(.*)*', redirect: '/' },
|
||||
],
|
||||
})
|
||||
|
||||
16
frontend/admin/src/tenant.ts
Normal file
16
frontend/admin/src/tenant.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export function getTenantCodeFromPath(pathname = window.location.pathname): string {
|
||||
const parts = pathname.split('/').filter(Boolean)
|
||||
if (parts.length < 2 || parts[0] !== 't') return ''
|
||||
return decodeURIComponent(parts[1] || '').toLowerCase()
|
||||
}
|
||||
|
||||
export function getAdminRouterBase(pathname = window.location.pathname): string {
|
||||
const tenantCode = getTenantCodeFromPath(pathname)
|
||||
return `/t/${tenantCode}/admin/`
|
||||
}
|
||||
|
||||
export function getApiBaseURL(pathname = window.location.pathname): string {
|
||||
const tenantCode = getTenantCodeFromPath(pathname)
|
||||
return `/t/${tenantCode}/v1`
|
||||
}
|
||||
|
||||
20
frontend/admin/src/views/DashboardPage.vue
Normal file
20
frontend/admin/src/views/DashboardPage.vue
Normal file
@@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<main style="padding: 16px">
|
||||
<h1 style="font-size: 20px; font-weight: 600">QuyUn Admin</h1>
|
||||
<p style="margin-top: 8px; color: #666">
|
||||
Router base: <code>{{ base }}</code>
|
||||
</p>
|
||||
<p style="margin-top: 4px; color: #666">
|
||||
API baseURL: <code>{{ apiBase }}</code>
|
||||
</p>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { getAdminRouterBase, getApiBaseURL } from '../tenant'
|
||||
|
||||
const base = computed(() => getAdminRouterBase())
|
||||
const apiBase = computed(() => getApiBaseURL())
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user