1
0

feat: 优化界面,增加AI依赖

This commit is contained in:
2025-11-28 15:02:10 +08:00
parent a36d195d4d
commit ce603c6598
6 changed files with 26 additions and 52 deletions

View File

@@ -203,7 +203,6 @@ function Book() {
{ {
name: 'description', name: 'description',
label: '描述', label: '描述',
width: 250,
}, },
{ {
label: '创建时间', label: '创建时间',
@@ -223,6 +222,7 @@ function Book() {
type: 'action', type: 'action',
label: '详情', label: '详情',
level: 'link', level: 'link',
size: 'sm',
onEvent: { onEvent: {
click: { click: {
actions: [ actions: [
@@ -250,6 +250,7 @@ function Book() {
type: 'action', type: 'action',
label: '删除', label: '删除',
level: 'link', level: 'link',
size: 'sm',
actionType: 'ajax', actionType: 'ajax',
api: `get:${commonInfo.baseUrl}/chapter/remove/\${id}`, api: `get:${commonInfo.baseUrl}/chapter/remove/\${id}`,
confirmText: '确认删除章节<span class="text-lg font-bold mx-2">${name}</span>', confirmText: '确认删除章节<span class="text-lg font-bold mx-2">${name}</span>',

View File

@@ -107,7 +107,7 @@ function Bookshelf() {
{ {
name: 'description', name: 'description',
label: '描述', label: '描述',
width: 250, width: 500,
}, },
{ {
name: 'source', name: 'source',
@@ -130,13 +130,14 @@ function Bookshelf() {
{ {
type: 'operation', type: 'operation',
label: '操作', label: '操作',
width: 150, width: 180,
fixed: 'right', fixed: 'right',
buttons: [ buttons: [
{ {
type: 'action', type: 'action',
label: '详情', label: '详情',
level: 'link', level: 'link',
size: 'sm',
onEvent: { onEvent: {
click: { click: {
actions: [ actions: [
@@ -172,6 +173,7 @@ function Bookshelf() {
type: 'action', type: 'action',
label: '删除', label: '删除',
level: 'link', level: 'link',
size: 'sm',
actionType: 'ajax', actionType: 'ajax',
api: `get:${commonInfo.baseUrl}/book/remove/\${id}`, api: `get:${commonInfo.baseUrl}/book/remove/\${id}`,
confirmText: '确认删除书籍<span class="text-lg font-bold mx-2">${name}</span>', confirmText: '确认删除书籍<span class="text-lg font-bold mx-2">${name}</span>',

View File

@@ -159,6 +159,7 @@ function Chapter() {
type: 'action', type: 'action',
label: '删除', label: '删除',
level: 'link', level: 'link',
size: 'sm',
actionType: 'ajax', actionType: 'ajax',
api: `get:${commonInfo.baseUrl}/line/remove/\${id}`, api: `get:${commonInfo.baseUrl}/line/remove/\${id}`,
confirmText: '确认删除行?', confirmText: '确认删除行?',

12
pom.xml
View File

@@ -16,6 +16,7 @@
<spring-boot.version>3.5.0</spring-boot.version> <spring-boot.version>3.5.0</spring-boot.version>
<spring-cloud.version>2025.0.0</spring-cloud.version> <spring-cloud.version>2025.0.0</spring-cloud.version>
<spring-ai.version>1.1.0</spring-ai.version>
<hibernate.version>6.6.15.Final</hibernate.version> <hibernate.version>6.6.15.Final</hibernate.version>
<querydsl.version>7.0</querydsl.version> <querydsl.version>7.0</querydsl.version>
@@ -38,6 +39,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-openai</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
@@ -94,6 +99,13 @@
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>${spring-ai.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency> <dependency>
<groupId>org.seleniumhq.selenium</groupId> <groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-dependencies-bom</artifactId> <artifactId>selenium-dependencies-bom</artifactId>

View File

@@ -1,22 +1,9 @@
package com.lanyuanxiaoyao.bookstore; package com.lanyuanxiaoyao.bookstore;
import cn.hutool.core.io.FileUtil;
import com.blinkfox.fenix.EnableFenix; import com.blinkfox.fenix.EnableFenix;
import com.lanyuanxiaoyao.bookstore.entity.Chapter;
import com.lanyuanxiaoyao.bookstore.service.BookService;
import com.lanyuanxiaoyao.bookstore.service.ChapterService;
import com.lanyuanxiaoyao.bookstore.service.LineService;
import jakarta.annotation.Resource;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Comparator;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.event.EventListener;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
/** /**
@@ -30,43 +17,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
@EnableFenix @EnableFenix
@EnableConfigurationProperties @EnableConfigurationProperties
public class BookStoreApplication { public class BookStoreApplication {
@Resource
private BookService bookService;
@Resource
private ChapterService chapterService;
@Resource
private LineService lineService;
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(BookStoreApplication.class, args); SpringApplication.run(BookStoreApplication.class, args);
} }
@EventListener(ApplicationReadyEvent.class)
public void importIntoDatabase() throws IOException {
var items = new ArrayList<Item>();
Files.list(Path.of("out"))
.sorted(Comparator.comparing(path -> FileUtil.lastModifiedTime(path.toFile())))
.forEach(path -> {
try {
items.add(new Item(
path.getFileName().toString(),
Files.readString(path)
));
} catch (IOException e) {
throw new RuntimeException(e);
}
});
for (var item : items) {
var chapter = new Chapter();
chapter.setSequence(chapterService.latestSequence(3608359126886400L) + 1);
chapter.setName(null);
chapter.setDescription(null);
chapter.setBook(bookService.detailOrThrow(3608359126886400L));
var chapterId = chapterService.save(chapter);
lineService.load(chapterId, item.content());
}
}
private record Item(String title, String content) {
}
} }

View File

@@ -19,6 +19,13 @@ spring:
ddl-auto: update ddl-auto: update
main: main:
banner-mode: off banner-mode: off
ai:
openai:
base-url: https://openrouter.ai/api/v1
api-key: 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
chat:
options:
model: "x-ai/grok-4.1-fast:free"
fenix: fenix:
print-banner: false print-banner: false
liteflow: liteflow: