diff --git a/backend/app/http/super/dto/tenant.go b/backend/app/http/super/dto/tenant.go
index 295c4d9..40b4f39 100644
--- a/backend/app/http/super/dto/tenant.go
+++ b/backend/app/http/super/dto/tenant.go
@@ -18,8 +18,9 @@ type TenantFilter struct {
type TenantItem struct {
*models.Tenant
- UserCount int64
- UserBalance int64
+ UserCount int64 `json:"user_count"`
+ UserBalance int64 `json:"user_balance"`
+ StatusDescription string `json:"status_description"`
}
type TenantExpireUpdateForm struct {
diff --git a/backend/app/http/super/static.go b/backend/app/http/super/static.go
index 7bb6011..a0db12b 100644
--- a/backend/app/http/super/static.go
+++ b/backend/app/http/super/static.go
@@ -1,6 +1,9 @@
package super
import (
+ "os"
+ "path/filepath"
+
"github.com/gofiber/fiber/v3"
)
@@ -12,9 +15,14 @@ type staticController struct{}
// @Tags Super
// @Router /super/*
func (ctl *staticController) static(ctx fiber.Ctx) error {
+ root := "/home/rogee/Projects/quyun_v2/frontend/superadmin/dist/"
param := ctx.Params("*")
- if param == "" {
- param = "index.html"
+ file := filepath.Join(root, param)
+
+ // if file not exits use index.html
+ if _, err := os.Stat(file); os.IsNotExist(err) {
+ file = filepath.Join(root, "index.html")
}
- return ctx.SendFile("/home/rogee/Projects/quyun_v2/frontend/superadmin/dist/" + param)
+
+ return ctx.SendFile(file)
}
diff --git a/backend/app/services/tenant.go b/backend/app/services/tenant.go
index 030dc93..28e5788 100644
--- a/backend/app/services/tenant.go
+++ b/backend/app/services/tenant.go
@@ -102,9 +102,10 @@ func (t *tenant) Pager(ctx context.Context, filter *dto.TenantFilter) (*requests
items := lo.Map(mm, func(model *models.Tenant, _ int) *dto.TenantItem {
return &dto.TenantItem{
- Tenant: model,
- UserCount: lo.ValueOr(userCountMapping, model.ID, 0),
- UserBalance: lo.ValueOr(userBalanceMapping, model.ID, 0),
+ Tenant: model,
+ UserCount: lo.ValueOr(userCountMapping, model.ID, 0),
+ UserBalance: lo.ValueOr(userBalanceMapping, model.ID, 0),
+ StatusDescription: model.Status.Description(),
}
})
diff --git a/backend/pkg/consts/consts.go b/backend/pkg/consts/consts.go
index 3308f4f..5398dfb 100644
--- a/backend/pkg/consts/consts.go
+++ b/backend/pkg/consts/consts.go
@@ -21,6 +21,20 @@ type UserStatus string
// ENUM( pending_verify, verified, banned )
type TenantStatus string
+// Description in chinese
+func (t TenantStatus) Description() string {
+ switch t {
+ case "pending_verify":
+ return "待审核"
+ case "verified":
+ return "已审核"
+ case "banned":
+ return "已封禁"
+ default:
+ return "未知状态"
+ }
+}
+
// swagger:enum TenantUserRole
// ENUM( member, tenant_admin)
type TenantUserRole string
diff --git a/frontend/superadmin/dist/index.html b/frontend/superadmin/dist/index.html
index 98d8d8a..58bfb6b 100644
--- a/frontend/superadmin/dist/index.html
+++ b/frontend/superadmin/dist/index.html
@@ -4,8 +4,8 @@
QuyUn Super Admin
-
-
+
+
diff --git a/frontend/superadmin/src/App.vue b/frontend/superadmin/src/App.vue
index 6fcd9cc..b0f5b10 100644
--- a/frontend/superadmin/src/App.vue
+++ b/frontend/superadmin/src/App.vue
@@ -1,20 +1,31 @@
+
-
-
+
+
Super Admin
-
-
+
@@ -22,16 +33,30 @@
diff --git a/frontend/superadmin/src/auth.ts b/frontend/superadmin/src/auth.ts
index 4d1deb8..32fb1da 100644
--- a/frontend/superadmin/src/auth.ts
+++ b/frontend/superadmin/src/auth.ts
@@ -1,7 +1,9 @@
import { computed, ref } from 'vue'
const STORAGE_KEY = 'super_admin_token'
+const USERNAME_KEY = 'super_admin_username'
const tokenRef = ref(localStorage.getItem(STORAGE_KEY) || '')
+const usernameRef = ref(localStorage.getItem(USERNAME_KEY) || '')
export const isAuthed = computed(() => Boolean(tokenRef.value))
@@ -16,3 +18,13 @@ export function setToken(token: string) {
else localStorage.setItem(STORAGE_KEY, t)
}
+export function getRememberedUsername(): string {
+ return usernameRef.value
+}
+
+export function setRememberedUsername(username: string) {
+ const u = username.trim()
+ usernameRef.value = u
+ if (!u) localStorage.removeItem(USERNAME_KEY)
+ else localStorage.setItem(USERNAME_KEY, u)
+}
diff --git a/frontend/superadmin/src/main.ts b/frontend/superadmin/src/main.ts
index 1c62e9e..5ce4cd6 100644
--- a/frontend/superadmin/src/main.ts
+++ b/frontend/superadmin/src/main.ts
@@ -3,7 +3,9 @@ import App from './App.vue'
import { router } from './router'
import PrimeVue from 'primevue/config'
import ToastService from 'primevue/toastservice'
+import ConfirmationService from 'primevue/confirmationservice'
import Aura from '@primevue/themes/aura'
+import Tooltip from 'primevue/tooltip'
import 'primeicons/primeicons.css'
import './styles.css'
@@ -12,4 +14,6 @@ createApp(App)
.use(router)
.use(PrimeVue, { theme: { preset: Aura } })
.use(ToastService)
+ .use(ConfirmationService)
+ .directive('tooltip', Tooltip)
.mount('#app')
diff --git a/frontend/superadmin/src/router.ts b/frontend/superadmin/src/router.ts
index ae5b25e..902f297 100644
--- a/frontend/superadmin/src/router.ts
+++ b/frontend/superadmin/src/router.ts
@@ -6,9 +6,9 @@ import { isAuthed } from './auth'
export const router = createRouter({
history: createWebHistory('/super/'),
routes: [
- { path: '/login', component: LoginPage },
+ { path: '/login', component: LoginPage, meta: { title: '登录' } },
{ path: '/', redirect: '/tenants' },
- { path: '/tenants', component: TenantsPage },
+ { path: '/tenants', component: TenantsPage, meta: { title: '租户' } },
{ path: '/:pathMatch(.*)*', redirect: '/' },
],
})
diff --git a/frontend/superadmin/src/views/LoginPage.vue b/frontend/superadmin/src/views/LoginPage.vue
index 3fa8018..fd56343 100644
--- a/frontend/superadmin/src/views/LoginPage.vue
+++ b/frontend/superadmin/src/views/LoginPage.vue
@@ -1,44 +1,70 @@
-
-
-
-
-
超级管理员登录
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
Super Admin
+
租户与运营管理控制台
+
+
-
-
-
-
接口:/super/v1/auth/login
+
+
-
diff --git a/frontend/superadmin/src/views/TenantsPage.vue b/frontend/superadmin/src/views/TenantsPage.vue
index 9114e7a..7f3566f 100644
--- a/frontend/superadmin/src/views/TenantsPage.vue
+++ b/frontend/superadmin/src/views/TenantsPage.vue
@@ -1,72 +1,140 @@
-
-
租户列表
+
+
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-