mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-03-14 05:33:42 +08:00
fix avatar pc
This commit is contained in:
@@ -48,7 +48,7 @@ public class IdentityAccessController {
|
||||
produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
public String uploadAvatar(Principal principal, @RequestPart("file") MultipartFile multipartFile)
|
||||
throws Exception {
|
||||
String objectName = String.format("avatar/%s/avatar.jpg", principal.getName());
|
||||
String objectName = String.format("/avatar/%s/avatar.jpg", principal.getName());
|
||||
if (multipartFile.isEmpty()) {
|
||||
throw new BusinessException("上传的文件不能为空");
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ VITE_SOURCE_MAP=true
|
||||
# mock
|
||||
#VITE_ENABLE_MOCK=true
|
||||
#VITE_BASE_URL=http://localhost:5173
|
||||
#VITE_STATIC_URL=http://localhost:5173/static
|
||||
#VITE_STATIC_URL=http://localhost:9000/zhilu
|
||||
# local
|
||||
VITE_ENABLE_MOCK=false
|
||||
VITE_BASE_URL=http://localhost:8080
|
||||
VITE_STATIC_URL=http://localhost:8080/static
|
||||
VITE_STATIC_URL=http://localhost:9000/zhilu
|
||||
# dev
|
||||
#VITE_ENABLE_MOCK=false
|
||||
#VITE_BASE_URL=https://localhost/api
|
||||
#VITE_STATIC_URL=https://localhost/
|
||||
#VITE_STATIC_URL=https://localhost/static
|
||||
|
||||
1
frontend/env.d.ts
vendored
1
frontend/env.d.ts
vendored
@@ -9,6 +9,7 @@ interface ImportMetaEnv {
|
||||
readonly VITE_ENABLE_MOCK: "true" | "false";
|
||||
readonly VITE_BACKEND_PORT: string;
|
||||
readonly VITE_BASE_URL: string;
|
||||
readonly VITE_STATIC_URL: string;
|
||||
readonly VITE_SOURCE_MAP: "true" | "false";
|
||||
}
|
||||
|
||||
|
||||
5
frontend/src/utils/avatarUtil.ts
Normal file
5
frontend/src/utils/avatarUtil.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const getUserAvatarUrl = (avatar?: string): string | undefined => {
|
||||
if (avatar?.startsWith("/")) {
|
||||
return `${import.meta.env.VITE_STATIC_URL}${avatar}`;
|
||||
}
|
||||
};
|
||||
@@ -21,7 +21,12 @@
|
||||
<div class="md:hidden space-y-4">
|
||||
<div v-for="user in users" :key="user.id" class="p-4 bg-white rounded-lg shadow">
|
||||
<div class="flex justify-between items-start mb-3">
|
||||
<div class="font-medium text-gray-900">{{ user.username }}</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="w-10 h-10 rounded-full border border-gray-200 flex items-center justify-center overflow-hidden">
|
||||
<img v-if="user.avatar" :src="getUserAvatarUrl(user.avatar)" class="w-full h-full object-cover">
|
||||
</div>
|
||||
<div class="font-medium text-gray-900">{{ user.username }}</div>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<div class="h-2.5 w-2.5 rounded-full me-2" :class="user.enable ? 'bg-blue-500' : 'bg-red-500'"></div>
|
||||
<span class="text-sm">{{ user.enable === true ? "启用" : "禁用" }}</span>
|
||||
@@ -84,6 +89,9 @@
|
||||
<template #sort-icon="{ field }">
|
||||
<SortIcon :sortField="getSortField(field)" />
|
||||
</template>
|
||||
<template #avatar="{ item }">
|
||||
<img v-if="item.avatar" :src="getUserAvatarUrl(item.avatar)" class="w-10 h-10 object-cover rounded-full">
|
||||
</template>
|
||||
<template #createTime="{ item }">
|
||||
{{ dayjs(item.createTime).format("llll") }}
|
||||
</template>
|
||||
@@ -169,6 +177,7 @@ import useUserDelete from "@/composables/user/useUserDelete";
|
||||
import { useUserQuery } from "@/composables/user/useUserQuery";
|
||||
import { RouteName } from "@/router/constants";
|
||||
import type { UserUpsertSubmitModel } from "@/types/user";
|
||||
import { getUserAvatarUrl } from "@/utils/avatarUtil";
|
||||
import { dayjs, formatDate } from "@/utils/dateUtil";
|
||||
import { Modal, type ModalInterface, initFlowbite } from "flowbite";
|
||||
import { nextTick, onMounted, reactive, ref } from "vue";
|
||||
@@ -221,6 +230,7 @@ const alertStore = useAlertStore();
|
||||
const actionExcStore = useActionExcStore();
|
||||
// 定义表格列配置
|
||||
const columns = [
|
||||
{ title: "头像", field: "avatar" },
|
||||
{ title: "用户名", field: "username", sortable: true },
|
||||
{ title: "创建时间", field: "createTime", sortable: true },
|
||||
{ title: "状态", field: "status" },
|
||||
|
||||
Reference in New Issue
Block a user