1
0

feat: 优化页面显示

This commit is contained in:
2025-09-29 17:24:37 +08:00
parent 46b1aa8853
commit ccd0767194
5 changed files with 58 additions and 20 deletions

16
.idea/csv-editor.xml generated
View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CsvFileAttributes">
<option name="attributeMap">
<map>
<entry key="/dumpDataPreview">
<value>
<Attribute>
<option name="separator" value="," />
</Attribute>
</value>
</entry>
</map>
</option>
</component>
</project>

View File

@@ -96,7 +96,7 @@ function Bookshelf() {
{ {
name: 'name', name: 'name',
label: '书名', label: '书名',
width: 120, width: 150,
fixed: 'left', fixed: 'left',
}, },
{ {

View File

@@ -65,7 +65,7 @@ function Chapter() {
{ {
type: 'action', type: 'action',
label: '', label: '',
icon: 'fa fa-book-open-reader', icon: 'fa fa-rotate-right',
actionType: 'ajax', actionType: 'ajax',
tooltip: '序号重排', tooltip: '序号重排',
tooltipPlacement: 'top', tooltipPlacement: 'top',
@@ -76,7 +76,7 @@ function Chapter() {
{ {
type: 'action', type: 'action',
label: '', label: '',
icon: 'fa fa-glasses', icon: 'fa fa-book-open-reader',
actionType: 'dialog', actionType: 'dialog',
tooltip: '全文阅读', tooltip: '全文阅读',
tooltipPlacement: 'top', tooltipPlacement: 'top',

View File

@@ -0,0 +1,54 @@
package com.lanyuanxiaoyao.bookstore.helper;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
/**
* 优化工具
*
* @author lanyuanxiaoyao
* @version 20250929
*/
@Slf4j
public class OptimiseHelper {
public static String optimize(String text) {
// 移除空行
text = StrUtil.trimToNull(text);
if (ObjectUtil.isNull(text)) {
return null;
}
// 英文全角字符转换为半角字符
text = halfWidth(text);
return text;
}
private static String halfWidth(String text) {
var builder = new StringBuilder();
for (var c : text.toCharArray()) {
// 检查是否为全角数字 (U+FF10 到 U+FF19)
if (c >= 0xFF10 && c <= 0xFF19) {
// 对应的半角数字是 (c - 0xFEE0)
builder.append((char) (c - 0xFEE0));
}
// 检查是否为全角大写字母 (U+FF21 到 U+FF3A)
else if (c >= 0xFF21 && c <= 0xFF3A) {
// 对应的半角字母是 (c - 0xFEE0)
builder.append((char) (c - 0xFEE0));
}
// 检查是否为全角小写字母 (U+FF41 到 U+FF5A)
else if (c >= 0xFF41 && c <= 0xFF5A) {
// 对应的半角字母是 (c - 0xFEE0)
builder.append((char) (c - 0xFEE0));
}
// 非全角字母和数字字符直接添加
else {
builder.append(c);
}
}
return builder.toString();
}
}

View File

@@ -8,7 +8,7 @@ import org.springframework.stereotype.Repository;
@Repository @Repository
public interface ChapterRepository extends SimpleRepository<Chapter> { public interface ChapterRepository extends SimpleRepository<Chapter> {
@Query("select max(chapter.sequence) from Chapter chapter") @Query("select max(chapter.sequence) from Chapter chapter where chapter.book.id = ?1")
Optional<Double> findMaxSequence(Long bookId); Optional<Double> findMaxSequence(Long bookId);
} }