demo: 加 Vue 前端到 examples/basic-admin/web

为了端到端验证 Shrimp 框架,把 hand-admin 前端拷进 examples/basic-admin/web
作为临时演示用前端,@shrimp alias 直接指向同仓 src/,免构建。

修改要点:
- web/vite.config.ts: @shrimp 改成 ../../../src; proxy /admin-api 到 :3100
- web/tsconfig.json: 同步 @shrimp 路径; 删掉 hand-server-2 的 paths
- web/src/locales: 删掉 matter_*/zerobase 业务 key
- web/src/module: 删掉 matter_*/zerobase 业务 vue,只留 user/role/FieldRelativeTime
- examples/basic-admin/index.ts:
  - mount 到 /admin-api/* 而不是 /api/*
  - 加 /config /login /me 端点 (mock super-admin operator,固定 token)
  - DemoShrimp 子类覆盖 getMenuTree 用模块自身 label
  - MemoryShrimpCrud 的 getRelatedCrud 手动 wire 到 crudRegistry,
    populate 才能跑 (后续 70→90 改进项)

curl 已验证 /config /login /me /product/list 全通,tagIds_label 正确旁挂。
This commit is contained in:
2026-05-23 15:28:10 +08:00
parent 8548a1760a
commit 27a2348815
68 changed files with 7345 additions and 23 deletions
@@ -0,0 +1,65 @@
<template>
<template v-if="mode === 'display'">
<template v-if="Array.isArray(modelValue)"
>{{ displayLabels.join(', ') || '-' }}</template
>
<template v-else>{{ displayText }}</template>
</template>
<el-select
v-else-if="mode === 'filter'"
:model-value="modelValue"
@update:model-value="$emit('update:modelValue', $event)"
multiple
clearable
style="width: 100%"
>
<el-option v-for="opt in resolvedOptions" :key="opt.value" :label="vueAdmin.t(opt.label)" :value="opt.value" />
</el-select>
<el-select
v-else
:model-value="modelValue"
@update:model-value="$emit('update:modelValue', $event)"
:disabled="disabled"
:multiple="field.multiple"
style="width: 100%"
>
<el-option v-for="opt in resolvedOptions" :key="opt.value" :label="vueAdmin.t(opt.label)" :value="opt.value" />
</el-select>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import { vueAdmin } from '@/VueAdmin'
const props = defineProps<{
field: any
modelValue: any
mode: 'display' | 'edit' | 'filter'
disabled?: boolean
}>()
defineEmits<{
'update:modelValue': [value: any]
}>()
const resolvedOptions = computed(() => {
const opts = props.field.options
if (typeof opts === 'string') {
return vueAdmin.globalOptions[opts] || []
}
return opts || []
})
const displayText = computed(() => {
const label = resolvedOptions.value.find((o: any) => o.value === props.modelValue)?.label
return label ? vueAdmin.t(label) : (props.modelValue ?? '-')
})
const displayLabels = computed(() => {
if (!Array.isArray(props.modelValue)) return []
return props.modelValue.map((val: any) => {
const opt = resolvedOptions.value.find((o: any) => o.value === val)
return opt ? vueAdmin.t(opt.label) : val
})
})
</script>