feat: shrimp-admin v0.1.0 — 从 hand-admin 抽离的框架前端
Shrimp 框架前端 — 一种消费 ShrimpServer + ShrimpTable 契约的经典 Vue3 +
Element Plus 实现。不是框架本身,只是按 shrimp-server 约定写的一份参考解法。
包含:
- ShrimpClient + VueAdmin(factory:createShrimpAdmin)
- 5 个 Shrimp* 组件 + 10 个内置 Field*.vue + PowerTree + LangSwitch
- 4 个内置模块:user / role / operationLog / FieldRelativeTime
- 完整后台壳 views(layout/login/sideM/topbar/userbar/navMenu/App/404/logo)
- composables/useTableUrlSync, locales(zh-cn/en 框架默认), style 全套
API 改造:
- createShrimpAdmin({ config, moduleSources, customFields, locales }) factory
- vueAdmin 改为 Proxy 单例,createShrimpAdmin 调用前访问会抛错
- import.meta.glob 业务字段/模块由消费侧传入(vite 静态扫描机制限制)
- 框架默认 locales 与消费侧 locales 在 i18n 初始化时合并
源码 ship 不打包,消费侧靠 vite 直接吃 .ts/.vue。
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<div class="op-log-page">
|
||||
<div v-if="user" class="page-header">
|
||||
<span class="page-subtitle">{{ user.nickname || user.username }}</span>
|
||||
</div>
|
||||
<div class="page-body">
|
||||
<ShrimpTable v-if="userId" :key="userId" moduleKey="operationLog" />
|
||||
<el-empty v-else :description="t('base.notFound')" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, onMounted, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import ShrimpTable from '../../components/ShrimpTable.vue'
|
||||
import { vueAdmin } from '../../VueAdmin'
|
||||
|
||||
const route = useRoute()
|
||||
const { t } = useI18n()
|
||||
|
||||
const userId = computed(() => route.query.id as string)
|
||||
const user = ref<any>(null)
|
||||
|
||||
async function loadUser() {
|
||||
if (!userId.value) {
|
||||
user.value = null
|
||||
return
|
||||
}
|
||||
try {
|
||||
const api = vueAdmin.getModule<any>('user')
|
||||
user.value = await api.get(userId.value)
|
||||
} catch (e: any) {
|
||||
console.warn('[operationLog] load user failed', e?.message || e)
|
||||
}
|
||||
}
|
||||
|
||||
watch(userId, loadUser)
|
||||
onMounted(loadUser)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.op-log-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
padding: 8px 16px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.page-subtitle {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.page-body {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
min-height: 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user