mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-04-10 16:07:06 +00:00
fix avatar pc
This commit is contained in:
@@ -48,7 +48,7 @@ public class IdentityAccessController {
|
|||||||
produces = MediaType.TEXT_PLAIN_VALUE)
|
produces = MediaType.TEXT_PLAIN_VALUE)
|
||||||
public String uploadAvatar(Principal principal, @RequestPart("file") MultipartFile multipartFile)
|
public String uploadAvatar(Principal principal, @RequestPart("file") MultipartFile multipartFile)
|
||||||
throws Exception {
|
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()) {
|
if (multipartFile.isEmpty()) {
|
||||||
throw new BusinessException("上传的文件不能为空");
|
throw new BusinessException("上传的文件不能为空");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ VITE_SOURCE_MAP=true
|
|||||||
# mock
|
# mock
|
||||||
#VITE_ENABLE_MOCK=true
|
#VITE_ENABLE_MOCK=true
|
||||||
#VITE_BASE_URL=http://localhost:5173
|
#VITE_BASE_URL=http://localhost:5173
|
||||||
#VITE_STATIC_URL=http://localhost:5173/static
|
#VITE_STATIC_URL=http://localhost:9000/zhilu
|
||||||
# local
|
# local
|
||||||
VITE_ENABLE_MOCK=false
|
VITE_ENABLE_MOCK=false
|
||||||
VITE_BASE_URL=http://localhost:8080
|
VITE_BASE_URL=http://localhost:8080
|
||||||
VITE_STATIC_URL=http://localhost:8080/static
|
VITE_STATIC_URL=http://localhost:9000/zhilu
|
||||||
# dev
|
# dev
|
||||||
#VITE_ENABLE_MOCK=false
|
#VITE_ENABLE_MOCK=false
|
||||||
#VITE_BASE_URL=https://localhost/api
|
#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_ENABLE_MOCK: "true" | "false";
|
||||||
readonly VITE_BACKEND_PORT: string;
|
readonly VITE_BACKEND_PORT: string;
|
||||||
readonly VITE_BASE_URL: string;
|
readonly VITE_BASE_URL: string;
|
||||||
|
readonly VITE_STATIC_URL: string;
|
||||||
readonly VITE_SOURCE_MAP: "true" | "false";
|
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 class="md:hidden space-y-4">
|
||||||
<div v-for="user in users" :key="user.id" class="p-4 bg-white rounded-lg shadow">
|
<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="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="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>
|
<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>
|
<span class="text-sm">{{ user.enable === true ? "启用" : "禁用" }}</span>
|
||||||
@@ -84,6 +89,9 @@
|
|||||||
<template #sort-icon="{ field }">
|
<template #sort-icon="{ field }">
|
||||||
<SortIcon :sortField="getSortField(field)" />
|
<SortIcon :sortField="getSortField(field)" />
|
||||||
</template>
|
</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 }">
|
<template #createTime="{ item }">
|
||||||
{{ dayjs(item.createTime).format("llll") }}
|
{{ dayjs(item.createTime).format("llll") }}
|
||||||
</template>
|
</template>
|
||||||
@@ -169,6 +177,7 @@ import useUserDelete from "@/composables/user/useUserDelete";
|
|||||||
import { useUserQuery } from "@/composables/user/useUserQuery";
|
import { useUserQuery } from "@/composables/user/useUserQuery";
|
||||||
import { RouteName } from "@/router/constants";
|
import { RouteName } from "@/router/constants";
|
||||||
import type { UserUpsertSubmitModel } from "@/types/user";
|
import type { UserUpsertSubmitModel } from "@/types/user";
|
||||||
|
import { getUserAvatarUrl } from "@/utils/avatarUtil";
|
||||||
import { dayjs, formatDate } from "@/utils/dateUtil";
|
import { dayjs, formatDate } from "@/utils/dateUtil";
|
||||||
import { Modal, type ModalInterface, initFlowbite } from "flowbite";
|
import { Modal, type ModalInterface, initFlowbite } from "flowbite";
|
||||||
import { nextTick, onMounted, reactive, ref } from "vue";
|
import { nextTick, onMounted, reactive, ref } from "vue";
|
||||||
@@ -221,6 +230,7 @@ const alertStore = useAlertStore();
|
|||||||
const actionExcStore = useActionExcStore();
|
const actionExcStore = useActionExcStore();
|
||||||
// 定义表格列配置
|
// 定义表格列配置
|
||||||
const columns = [
|
const columns = [
|
||||||
|
{ title: "头像", field: "avatar" },
|
||||||
{ title: "用户名", field: "username", sortable: true },
|
{ title: "用户名", field: "username", sortable: true },
|
||||||
{ title: "创建时间", field: "createTime", sortable: true },
|
{ title: "创建时间", field: "createTime", sortable: true },
|
||||||
{ title: "状态", field: "status" },
|
{ title: "状态", field: "status" },
|
||||||
|
|||||||
Reference in New Issue
Block a user