feat: 更新 @riwa/api-types 依赖至 0.0.23,添加用户管理功能及相关界面

This commit is contained in:
2026-01-19 18:25:27 +07:00
parent 9b36a114b3
commit a2ef52be99
11 changed files with 145 additions and 12 deletions

View File

@@ -229,7 +229,8 @@ const local: App.I18n.Schema = {
500: 'Server Error',
'iframe-page': 'Iframe',
home: 'Home',
product: 'Product'
product: 'Product',
user: ' User'
},
page: {
login: {

View File

@@ -225,7 +225,8 @@ const local: App.I18n.Schema = {
500: '服务器错误',
'iframe-page': '外链页面',
home: '首页',
product: '产品管理'
product: '产品管理',
user: '用户管理'
},
page: {
login: {

View File

@@ -22,4 +22,5 @@ export const views: Record<LastLevelRouteKey, RouteComponent | (() => Promise<Ro
login: () => import("@/views/_builtin/login/index.vue"),
home: () => import("@/views/home/index.vue"),
product: () => import("@/views/product/index.vue"),
user: () => import("@/views/user/index.vue"),
};

View File

@@ -81,5 +81,14 @@ export const generatedRoutes: GeneratedRoute[] = [
title: 'product',
i18nKey: 'route.product'
}
},
{
name: 'user',
path: '/user',
component: 'layout.base$view.user',
meta: {
title: 'user',
i18nKey: 'route.user'
}
}
];

View File

@@ -169,7 +169,8 @@ const routeMap: RouteMap = {
"home": "/home",
"iframe-page": "/iframe-page/:url",
"login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?",
"product": "/product"
"product": "/product",
"user": "/user"
};
/**

View File

@@ -24,6 +24,7 @@ declare module "@elegant-router/types" {
"iframe-page": "/iframe-page/:url";
"login": "/login/:module(pwd-login|code-login|register|reset-pwd|bind-wechat)?";
"product": "/product";
"user": "/user";
};
/**
@@ -62,6 +63,7 @@ declare module "@elegant-router/types" {
| "iframe-page"
| "login"
| "product"
| "user"
>;
/**
@@ -85,6 +87,7 @@ declare module "@elegant-router/types" {
| "login"
| "home"
| "product"
| "user"
>;
/**

View File

@@ -14,7 +14,8 @@ export async function uploadToS3(file: File, options: UploadOptions) {
const { data } = await safeClient(
client.api.file_storage.upload_url.post({
...fetchOptions
...fetchOptions,
accessControl: 'public'
})
);
@@ -22,7 +23,7 @@ export async function uploadToS3(file: File, options: UploadOptions) {
throw new Error('获取上传 URL 失败');
}
const { fileId, uploadUrl, method, headers } = toRefs(data.value);
const { fileId, uploadUrl, method, headers, publicUrl } = toRefs(data.value);
// 2. 上传文件到 S3
return new Promise<string>((resolve, reject) => {

View File

@@ -0,0 +1,31 @@
<script lang="ts" setup>
import { useTemplateRef } from 'vue';
import { client, safeClient } from '@/service/api';
import type { TableBaseColumns, TableFetchData, TableInst } from '@/components/table';
defineOptions({
name: 'WalletDialog'
});
const props = defineProps<{
userId: string;
}>();
const tableInst = useTemplateRef<TableInst>('tableInst');
const fetchData: TableFetchData = ({ pagination, filter }) => {
return safeClient(() => client.api.admin.wallet.balances.get({ query: { userId: props.userId } }));
};
const columns: TableBaseColumns = [
{
key: 'id',
title: 'ID'
}
];
</script>
<template>
<TableBase ref="tableInst" :fetch-data="fetchData" :columns="columns" />
</template>
<style lang="css" scoped></style>

85
src/views/user/index.vue Normal file
View File

@@ -0,0 +1,85 @@
<script lang="ts" setup>
import { h, useTemplateRef } from 'vue';
import { useDialog } from 'naive-ui';
import dayjs from 'dayjs';
import { client, safeClient } from '@/service/api';
import type { TableBaseColumns, TableFetchData, TableInst } from '@/components/table';
import Wallet from './components/wallet.vue';
const dialog = useDialog();
const tableInst = useTemplateRef<TableInst>('tableInst');
const fetchData: TableFetchData = ({ pagination, filter }) => {
return safeClient(() =>
client.api.admin.users.get({
query: {
...pagination,
...filter
}
})
);
};
const columns: TableBaseColumns = [
{
key: 'uid',
title: 'UID',
width: 120
},
{
key: 'user.name',
title: '姓名'
},
{
key: 'user.username',
title: '手机号'
},
{
key: 'referralCode',
title: '推荐码'
},
{
key: 'createdAt',
title: '创建时间',
render: (row: any) => {
return dayjs(row.createdAt).format('YYYY-MM-DD HH:mm');
}
},
{
key: 'operations',
title: '操作',
width: 120,
fixed: 'right',
operations: (row: any) => [
{
contentText: '钱包',
size: 'small',
onClick: () => {
dialog.create({
title: '用户钱包',
style: { width: '1000px' },
content: () => h(Wallet, { userId: row.userId })
});
}
}
]
}
];
</script>
<template>
<TableBase
ref="tableInst"
:fetch-data="fetchData"
:columns="columns"
:scroll-x="800"
:header-operations="{
add: false,
refresh: true,
columns: true
}"
/>
</template>
<style lang="css" scoped></style>