feat: 优化界面,增加AI依赖
This commit is contained in:
@@ -203,7 +203,6 @@ function Book() {
|
||||
{
|
||||
name: 'description',
|
||||
label: '描述',
|
||||
width: 250,
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
@@ -223,6 +222,7 @@ function Book() {
|
||||
type: 'action',
|
||||
label: '详情',
|
||||
level: 'link',
|
||||
size: 'sm',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
@@ -250,6 +250,7 @@ function Book() {
|
||||
type: 'action',
|
||||
label: '删除',
|
||||
level: 'link',
|
||||
size: 'sm',
|
||||
actionType: 'ajax',
|
||||
api: `get:${commonInfo.baseUrl}/chapter/remove/\${id}`,
|
||||
confirmText: '确认删除章节<span class="text-lg font-bold mx-2">${name}</span>?',
|
||||
|
||||
@@ -107,7 +107,7 @@ function Bookshelf() {
|
||||
{
|
||||
name: 'description',
|
||||
label: '描述',
|
||||
width: 250,
|
||||
width: 500,
|
||||
},
|
||||
{
|
||||
name: 'source',
|
||||
@@ -130,13 +130,14 @@ function Bookshelf() {
|
||||
{
|
||||
type: 'operation',
|
||||
label: '操作',
|
||||
width: 150,
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
buttons: [
|
||||
{
|
||||
type: 'action',
|
||||
label: '详情',
|
||||
level: 'link',
|
||||
size: 'sm',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
@@ -172,6 +173,7 @@ function Bookshelf() {
|
||||
type: 'action',
|
||||
label: '删除',
|
||||
level: 'link',
|
||||
size: 'sm',
|
||||
actionType: 'ajax',
|
||||
api: `get:${commonInfo.baseUrl}/book/remove/\${id}`,
|
||||
confirmText: '确认删除书籍<span class="text-lg font-bold mx-2">${name}</span>?',
|
||||
|
||||
@@ -159,6 +159,7 @@ function Chapter() {
|
||||
type: 'action',
|
||||
label: '删除',
|
||||
level: 'link',
|
||||
size: 'sm',
|
||||
actionType: 'ajax',
|
||||
api: `get:${commonInfo.baseUrl}/line/remove/\${id}`,
|
||||
confirmText: '确认删除行?',
|
||||
|
||||
12
pom.xml
12
pom.xml
@@ -16,6 +16,7 @@
|
||||
|
||||
<spring-boot.version>3.5.0</spring-boot.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>
|
||||
<querydsl.version>7.0</querydsl.version>
|
||||
|
||||
@@ -38,6 +39,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-starter-model-openai</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
@@ -94,6 +99,13 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</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>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-dependencies-bom</artifactId>
|
||||
|
||||
@@ -1,22 +1,9 @@
|
||||
package com.lanyuanxiaoyao.bookstore;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
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.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
|
||||
/**
|
||||
@@ -30,43 +17,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
@EnableFenix
|
||||
@EnableConfigurationProperties
|
||||
public class BookStoreApplication {
|
||||
@Resource
|
||||
private BookService bookService;
|
||||
@Resource
|
||||
private ChapterService chapterService;
|
||||
@Resource
|
||||
private LineService lineService;
|
||||
|
||||
public static void main(String[] 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) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,13 @@ spring:
|
||||
ddl-auto: update
|
||||
main:
|
||||
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:
|
||||
print-banner: false
|
||||
liteflow:
|
||||
|
||||
Reference in New Issue
Block a user