Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加默认用户头像 #7

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/Apache-2.0)
![GitHub Release Date](https://img.shields.io/github/release-date/devlive-community/incubator-infosphere?style=flat-square)

![Docker Automated build](https://img.shields.io/docker/automated/devlive-community/infosphere)
![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/devlive-community/infosphere?style=flat-square)
![Docker Pulls](https://img.shields.io/docker/pulls/devlive-community/infosphere?style=flat-square)
![Docker Automated build](https://img.shields.io/docker/automated/devliveorg/infosphere)
![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/devliveorg/infosphere?style=flat-square)
![Docker Pulls](https://img.shields.io/docker/pulls/devliveorg/infosphere?style=flat-square)

![GitHub commit activity](https://img.shields.io/github/commit-activity/y/devlive-community/incubator-infosphere?style=flat-square)
![GitHub contributors](https://img.shields.io/github/contributors-anon/devlive-community/incubator-infosphere?style=flat-square)
Expand Down
2 changes: 1 addition & 1 deletion configure/initializer/infosphere.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CREATE TABLE `infosphere_user`
`id` BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(25) NOT NULL,
`password` VARCHAR(255),
`avatar` VARCHAR(255) DEFAULT NULL,
`avatar` VARCHAR(255) DEFAULT '/static/images/default.png',
`alias_name` VARCHAR(25) DEFAULT NULL,
`signature` VARCHAR(200) DEFAULT NULL,
`email` VARCHAR(50),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<meta th:content="${description}" name="description"/>
<meta content="qianmoQ" name="author"/>
<link rel="shortcut icon" type="image/x-icon" th:href="@{'/static/images/logo.png'}"/>
<link rel="stylesheet" th:href="@{/static/css/vender/quick/style.min.css}">
<link rel="stylesheet" th:href="@{/static/css/infosphere.min.css}">
</head>
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
<!-- 文章标题用户信息 -->
<div th:unless="${description == null}" class="navbar-brand ml-10">
<div class="icon text-white rounded-circle icon-shape shadow">
<img th:if="${description.user.avatar}" class="avatar rounded-circle avatar-sm" th:src="${description.user.avatar}" th:alt="${description.user.avatar}"/>
<span th:else th:text="${description.user.username.substring(0, 2)}" class="avatar bg-primary text-white rounded-circle avatar-sm"></span>
<img class="avatar rounded-circle avatar-sm" style="width: 100%; height: 100%;" th:if="${description.user.avatar}" th:src="${description.user.avatar}"
th:alt="${description.user.avatar}"/>
<span class="avatar bg-primary text-white rounded-circle avatar-sm" th:unless="${description.user.avatar}"
th:text="${description.user.username.substring(0, 2)}"></span>
</div>
<!-- <button class="btn btn-primary btn-xs" th:disabled="${session.SPRING_SECURITY_CONTEXT == null}">关注</button>-->
<!-- <button class="btn btn-primary btn-xs" th:disabled="${session.SPRING_SECURITY_CONTEXT == null}">关注</button>-->
</div>

<!-- 文章标题 -->
Expand Down Expand Up @@ -52,9 +54,13 @@
aria-haspopup="true" aria-expanded="false">
<div th:with="userInfo=${authentication.getPrincipal()}"
class="btn-inner--icon" style="margin-left: 1.2rem !important;">
<img th:if="${userInfo.avatar}" class="avatar rounded-circle avatar-sm" th:src="${userInfo.avatar}"
th:alt="${userInfo.avatar}"/>
<span th:else th:text="${userInfo.username.substring(0, 2)}" class="avatar bg-primary text-white rounded-circle avatar-sm"></span>
<div class="icon icon-shape rounded-circle text-white mr-4" th:if="${userInfo.entity.avatar}">
<img class="avatar rounded-circle avatar-sm ml-4" style="width: 100%; height: 100%;" th:if="${userInfo.entity.avatar}"
th:src="${userInfo.entity.avatar}"
th:alt="${userInfo.entity.username}"/>
<span th:unless="${userInfo.entity.avatar}" th:text="${userInfo.entity.username.substring(0, 2)}"
class="avatar bg-primary text-white rounded-circle avatar-sm"></span>
</div>
</div>
</button>
<div class="dropdown-menu dropdown-menu-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
<li class="page-item" th:classappend="${response.page == 1} ? 'disabled'">
<a class="page-link" th:href="${'/' + root}" tabindex="-1" aria-disabled="true">首页</a>
</li>
<li class="page-item" th:classappend="${response.page == 1} ? 'disabled'">
<a class="page-link" th:href="${'/' + root + '/' + (response.page - 1) + '/' + response.size}">上一页</a>
</li>
<li th:each="pageIndex : ${#numbers.sequence(1, response.totalPage)}" class="page-item" th:classappend="${response.page == pageIndex} ? 'active'">
<a class="page-link" th:href="${'/' + root + '/' + pageIndex + '/' + response.size}" th:text="${pageIndex}"></a>
</li>
<li class="page-item" th:classappend="${response.page == response.totalPage} ? 'disabled'">
<a class="page-link" th:href="${'/' + root + '/' + (response.page + 1) + '/' + response.size}">末页</a>
<a class="page-link" th:href="${'/' + root + '/' + (response.page + 1) + '/' + response.size}">下一页</a>
</li>
<li class="page-item" th:classappend="${response.page == response.totalPage} ? 'disabled'">
<a class="page-link" th:href="${'/' + root + '/' + response.totalPage + '/' + response.size}">末页</a>
</li>
</ul>
</nav>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="p-3 d-flex">
<div class="icon icon-shape rounded-circle text-white mr-4">
<img th:if="${article.user.avatar}" class="avatar rounded-circle avatar-sm" th:src="${article.user.avatar}" th:alt="${article.user.avatar}"/>
<span th:else th:text="${article.user.username.substring(0, 2)}" class="avatar bg-primary text-white rounded-circle avatar-sm"></span>
<span th:unless="${article.user.avatar}" th:text="${article.user.username.substring(0, 2)}" class="avatar bg-primary text-white rounded-circle avatar-sm"></span>
</div>
<div class="col-sm-10">
<span class="h6">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.devlive.infosphere.service.security;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import org.devlive.infosphere.service.entity.UserEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
Expand All @@ -16,22 +17,28 @@
public class UserDetailsService
implements UserDetails
{
private Long id;
private String username;
@JsonIgnore
private String password;
private Collection<? extends GrantedAuthority> authorities;
@Getter
private Long id;
@Getter
private String avatar;
@Getter
private UserEntity entity;

public UserDetailsService(Long id, String username, String password,
Collection<? extends GrantedAuthority> authorities,
String avatar)
String avatar,
UserEntity entity)
{
this.id = id;
this.username = username;
this.password = password;
this.authorities = authorities;
this.avatar = avatar;
this.entity = entity;
}

public static UserDetailsService build(UserEntity user)
Expand All @@ -45,7 +52,8 @@ public static UserDetailsService build(UserEntity user)
user.getUsername(),
user.getPassword(),
authorities,
null);
user.getAvatar(),
user);
}

public static UserEntity getUser()
Expand Down Expand Up @@ -107,14 +115,4 @@ public boolean isEnabled()
{
return true;
}

public Long getId()
{
return id;
}

public String getAvatar()
{
return avatar;
}
}
3 changes: 0 additions & 3 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
- pymdownx.snippets
- abbr

Expand Down
Loading