Compare commits
4 Commits
a186066641
...
6c3d98eaac
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c3d98eaac | |||
| b7f3ae2854 | |||
| 2907acac95 | |||
| 0947009ee6 |
@@ -22,12 +22,15 @@ public class EasyflowLicenseBootstrapValidator implements BeanFactoryPostProcess
|
|||||||
|
|
||||||
private final EasyflowLicenseVerifier easyflowLicenseVerifier;
|
private final EasyflowLicenseVerifier easyflowLicenseVerifier;
|
||||||
private String location;
|
private String location;
|
||||||
|
private String machineIdFile;
|
||||||
|
private String productUuidFile;
|
||||||
|
private String macAddressFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造启动前校验器。
|
* 构造启动前校验器。
|
||||||
*/
|
*/
|
||||||
public EasyflowLicenseBootstrapValidator() {
|
public EasyflowLicenseBootstrapValidator() {
|
||||||
this(new EasyflowLicenseVerifier(new DefaultResourceLoader(), new MachineIdentityCollector()));
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,6 +50,9 @@ public class EasyflowLicenseBootstrapValidator implements BeanFactoryPostProcess
|
|||||||
@Override
|
@Override
|
||||||
public void setEnvironment(Environment environment) {
|
public void setEnvironment(Environment environment) {
|
||||||
this.location = environment.getProperty("easyflow.license.location");
|
this.location = environment.getProperty("easyflow.license.location");
|
||||||
|
this.machineIdFile = environment.getProperty("easyflow.license.machine-id-file");
|
||||||
|
this.productUuidFile = environment.getProperty("easyflow.license.product-uuid-file");
|
||||||
|
this.macAddressFile = environment.getProperty("easyflow.license.mac-address-file");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,7 +64,7 @@ public class EasyflowLicenseBootstrapValidator implements BeanFactoryPostProcess
|
|||||||
@Override
|
@Override
|
||||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||||
try {
|
try {
|
||||||
EasyflowLicenseVerificationResult result = easyflowLicenseVerifier.verify(location);
|
EasyflowLicenseVerificationResult result = resolveVerifier().verify(location);
|
||||||
LOG.info("license 校验通过: location={}, licenseId={}, keyId={}, licenseType={}, expiresAt={}",
|
LOG.info("license 校验通过: location={}, licenseId={}, keyId={}, licenseType={}, expiresAt={}",
|
||||||
result.location(),
|
result.location(),
|
||||||
result.licenseId(),
|
result.licenseId(),
|
||||||
@@ -92,4 +98,18 @@ public class EasyflowLicenseBootstrapValidator implements BeanFactoryPostProcess
|
|||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return Ordered.HIGHEST_PRECEDENCE;
|
return Ordered.HIGHEST_PRECEDENCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EasyflowLicenseVerifier resolveVerifier() {
|
||||||
|
if (easyflowLicenseVerifier != null) {
|
||||||
|
return easyflowLicenseVerifier;
|
||||||
|
}
|
||||||
|
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||||
|
MachineIdentityCollector collector = new MachineIdentityCollector(
|
||||||
|
resourceLoader,
|
||||||
|
machineIdFile,
|
||||||
|
productUuidFile,
|
||||||
|
macAddressFile
|
||||||
|
);
|
||||||
|
return new EasyflowLicenseVerifier(resourceLoader, collector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,21 @@ public class EasyflowLicenseProperties {
|
|||||||
*/
|
*/
|
||||||
private String location;
|
private String location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机器 machineId 文件位置,支持 classpath: 与 file: 形式。
|
||||||
|
*/
|
||||||
|
private String machineIdFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备 productUuid 文件位置,支持 classpath: 与 file: 形式。
|
||||||
|
*/
|
||||||
|
private String productUuidFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MAC 地址文件位置,支持 classpath: 与 file: 形式。
|
||||||
|
*/
|
||||||
|
private String macAddressFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 license 资源位置。
|
* 获取 license 资源位置。
|
||||||
*
|
*
|
||||||
@@ -32,4 +47,58 @@ public class EasyflowLicenseProperties {
|
|||||||
public void setLocation(String location) {
|
public void setLocation(String location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 machineId 文件位置。
|
||||||
|
*
|
||||||
|
* @return machineId 文件位置
|
||||||
|
*/
|
||||||
|
public String getMachineIdFile() {
|
||||||
|
return machineIdFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 machineId 文件位置。
|
||||||
|
*
|
||||||
|
* @param machineIdFile machineId 文件位置
|
||||||
|
*/
|
||||||
|
public void setMachineIdFile(String machineIdFile) {
|
||||||
|
this.machineIdFile = machineIdFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 productUuid 文件位置。
|
||||||
|
*
|
||||||
|
* @return productUuid 文件位置
|
||||||
|
*/
|
||||||
|
public String getProductUuidFile() {
|
||||||
|
return productUuidFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 productUuid 文件位置。
|
||||||
|
*
|
||||||
|
* @param productUuidFile productUuid 文件位置
|
||||||
|
*/
|
||||||
|
public void setProductUuidFile(String productUuidFile) {
|
||||||
|
this.productUuidFile = productUuidFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 MAC 地址文件位置。
|
||||||
|
*
|
||||||
|
* @return MAC 地址文件位置
|
||||||
|
*/
|
||||||
|
public String getMacAddressFile() {
|
||||||
|
return macAddressFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置 MAC 地址文件位置。
|
||||||
|
*
|
||||||
|
* @param macAddressFile MAC 地址文件位置
|
||||||
|
*/
|
||||||
|
public void setMacAddressFile(String macAddressFile) {
|
||||||
|
this.macAddressFile = macAddressFile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package tech.easyflow.autoconfig.license;
|
package tech.easyflow.autoconfig.license;
|
||||||
|
|
||||||
|
import org.springframework.core.io.DefaultResourceLoader;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.ResourceLoader;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@@ -20,6 +23,36 @@ public class MachineIdentityCollector {
|
|||||||
|
|
||||||
private static final Duration COMMAND_TIMEOUT = Duration.ofSeconds(10);
|
private static final Duration COMMAND_TIMEOUT = Duration.ofSeconds(10);
|
||||||
|
|
||||||
|
private final ResourceLoader resourceLoader;
|
||||||
|
private final String machineIdFile;
|
||||||
|
private final String productUuidFile;
|
||||||
|
private final String macAddressFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造默认机器信息采集器。
|
||||||
|
*/
|
||||||
|
public MachineIdentityCollector() {
|
||||||
|
this(new DefaultResourceLoader(), null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造支持外部文件覆盖的机器信息采集器。
|
||||||
|
*
|
||||||
|
* @param resourceLoader 资源加载器
|
||||||
|
* @param machineIdFile machineId 文件位置
|
||||||
|
* @param productUuidFile productUuid 文件位置
|
||||||
|
* @param macAddressFile MAC 地址文件位置
|
||||||
|
*/
|
||||||
|
public MachineIdentityCollector(ResourceLoader resourceLoader,
|
||||||
|
String machineIdFile,
|
||||||
|
String productUuidFile,
|
||||||
|
String macAddressFile) {
|
||||||
|
this.resourceLoader = resourceLoader;
|
||||||
|
this.machineIdFile = machineIdFile;
|
||||||
|
this.productUuidFile = productUuidFile;
|
||||||
|
this.macAddressFile = macAddressFile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采集当前机器的授权标识信息。
|
* 采集当前机器的授权标识信息。
|
||||||
*
|
*
|
||||||
@@ -27,16 +60,11 @@ public class MachineIdentityCollector {
|
|||||||
*/
|
*/
|
||||||
public MachineIdentity collect() {
|
public MachineIdentity collect() {
|
||||||
String osName = currentOsName().toLowerCase(Locale.ROOT);
|
String osName = currentOsName().toLowerCase(Locale.ROOT);
|
||||||
if (osName.contains("win")) {
|
return switch (resolveOsType(osName)) {
|
||||||
return collectWindowsIdentity();
|
case WINDOWS -> collectWindowsIdentity();
|
||||||
}
|
case MAC -> collectMacIdentity();
|
||||||
if (osName.contains("mac") || osName.contains("darwin")) {
|
case LINUX -> collectLinuxIdentity();
|
||||||
return collectMacIdentity();
|
};
|
||||||
}
|
|
||||||
if (osName.contains("nux") || osName.contains("linux")) {
|
|
||||||
return collectLinuxIdentity();
|
|
||||||
}
|
|
||||||
throw new IllegalStateException("不支持的操作系统: " + currentOsName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,10 +82,19 @@ public class MachineIdentityCollector {
|
|||||||
* @return 机器信息
|
* @return 机器信息
|
||||||
*/
|
*/
|
||||||
protected MachineIdentity collectLinuxIdentity() {
|
protected MachineIdentity collectLinuxIdentity() {
|
||||||
String machineId = executeShellCommand("读取 Linux machineId", "cat /etc/machine-id");
|
String machineId = readConfiguredValue("读取 Linux machineId 文件", machineIdFile);
|
||||||
String productUuid = executeShellCommand("读取 Linux productUuid", "cat /sys/class/dmi/id/product_uuid");
|
if (!StringUtils.hasText(machineId)) {
|
||||||
String macAddress = executeShellCommand("读取 Linux 默认网卡 MAC",
|
machineId = executeShellCommand("读取 Linux machineId", "cat /etc/machine-id");
|
||||||
"cat /sys/class/net/$(ip route | awk '/default/ {print $5; exit}')/address");
|
}
|
||||||
|
String productUuid = readConfiguredValue("读取 Linux productUuid 文件", productUuidFile);
|
||||||
|
if (!StringUtils.hasText(productUuid)) {
|
||||||
|
productUuid = executeShellCommand("读取 Linux productUuid", "cat /sys/class/dmi/id/product_uuid");
|
||||||
|
}
|
||||||
|
String macAddress = readConfiguredValue("读取 Linux MAC 文件", macAddressFile);
|
||||||
|
if (!StringUtils.hasText(macAddress)) {
|
||||||
|
macAddress = executeShellCommand("读取 Linux 默认网卡 MAC",
|
||||||
|
"cat /sys/class/net/$(ip route | awk '/default/ {print $5; exit}')/address");
|
||||||
|
}
|
||||||
return new MachineIdentity(machineId, productUuid, macAddress);
|
return new MachineIdentity(machineId, productUuid, macAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,12 +104,21 @@ public class MachineIdentityCollector {
|
|||||||
* @return 机器信息
|
* @return 机器信息
|
||||||
*/
|
*/
|
||||||
protected MachineIdentity collectMacIdentity() {
|
protected MachineIdentity collectMacIdentity() {
|
||||||
String machineId = executeShellCommand("读取 macOS machineId",
|
String machineId = readConfiguredValue("读取 macOS machineId 文件", machineIdFile);
|
||||||
"ioreg -rd1 -c IOPlatformExpertDevice | awk -F'\"' '/IOPlatformUUID/ {print $(NF-1)}'");
|
if (!StringUtils.hasText(machineId)) {
|
||||||
String productUuid = executeShellCommand("读取 macOS productUuid",
|
machineId = executeShellCommand("读取 macOS machineId",
|
||||||
"ioreg -rd1 -c IOPlatformExpertDevice | awk -F'\"' '/IOPlatformUUID/ {print $(NF-1)}'");
|
"ioreg -rd1 -c IOPlatformExpertDevice | awk -F'\"' '/IOPlatformUUID/ {print $(NF-1)}'");
|
||||||
String macAddress = executeShellCommand("读取 macOS 默认网卡 MAC",
|
}
|
||||||
"networksetup -listallhardwareports | awk '/Device/ {device=$2} /Ethernet Address/ {print $3; exit}'");
|
String productUuid = readConfiguredValue("读取 macOS productUuid 文件", productUuidFile);
|
||||||
|
if (!StringUtils.hasText(productUuid)) {
|
||||||
|
productUuid = executeShellCommand("读取 macOS productUuid",
|
||||||
|
"ioreg -rd1 -c IOPlatformExpertDevice | awk -F'\"' '/IOPlatformUUID/ {print $(NF-1)}'");
|
||||||
|
}
|
||||||
|
String macAddress = readConfiguredValue("读取 macOS MAC 文件", macAddressFile);
|
||||||
|
if (!StringUtils.hasText(macAddress)) {
|
||||||
|
macAddress = executeShellCommand("读取 macOS 默认网卡 MAC",
|
||||||
|
"networksetup -listallhardwareports | awk '/Device/ {device=$2} /Ethernet Address/ {print $3; exit}'");
|
||||||
|
}
|
||||||
return new MachineIdentity(machineId, productUuid, macAddress);
|
return new MachineIdentity(machineId, productUuid, macAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,15 +128,50 @@ public class MachineIdentityCollector {
|
|||||||
* @return 机器信息
|
* @return 机器信息
|
||||||
*/
|
*/
|
||||||
protected MachineIdentity collectWindowsIdentity() {
|
protected MachineIdentity collectWindowsIdentity() {
|
||||||
String machineId = executePowerShellCommand("读取 Windows machineId",
|
String machineId = readConfiguredValue("读取 Windows machineId 文件", machineIdFile);
|
||||||
"(Get-ItemProperty 'HKLM:\\SOFTWARE\\Microsoft\\Cryptography').MachineGuid");
|
if (!StringUtils.hasText(machineId)) {
|
||||||
String productUuid = executePowerShellCommand("读取 Windows productUuid",
|
machineId = executePowerShellCommand("读取 Windows machineId",
|
||||||
"(Get-CimInstance Win32_ComputerSystemProduct).UUID");
|
"(Get-ItemProperty 'HKLM:\\SOFTWARE\\Microsoft\\Cryptography').MachineGuid");
|
||||||
String macAddress = executePowerShellCommand("读取 Windows 默认网卡 MAC",
|
}
|
||||||
"(Get-NetAdapter | Where-Object {$_.Status -eq 'Up' -and $_.MacAddress} | Select-Object -First 1 -ExpandProperty MacAddress)");
|
String productUuid = readConfiguredValue("读取 Windows productUuid 文件", productUuidFile);
|
||||||
|
if (!StringUtils.hasText(productUuid)) {
|
||||||
|
productUuid = executePowerShellCommand("读取 Windows productUuid",
|
||||||
|
"(Get-CimInstance Win32_ComputerSystemProduct).UUID");
|
||||||
|
}
|
||||||
|
String macAddress = readConfiguredValue("读取 Windows MAC 文件", macAddressFile);
|
||||||
|
if (!StringUtils.hasText(macAddress)) {
|
||||||
|
macAddress = executePowerShellCommand("读取 Windows 默认网卡 MAC",
|
||||||
|
"(Get-NetAdapter | Where-Object {$_.Status -eq 'Up' -and $_.MacAddress} | Select-Object -First 1 -ExpandProperty MacAddress)");
|
||||||
|
}
|
||||||
return new MachineIdentity(machineId, productUuid, macAddress);
|
return new MachineIdentity(machineId, productUuid, macAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取外部配置文件中的机器参数。
|
||||||
|
*
|
||||||
|
* @param description 描述
|
||||||
|
* @param location 资源位置
|
||||||
|
* @return 文件内容;未配置时返回空字符串
|
||||||
|
*/
|
||||||
|
protected String readConfiguredValue(String description, String location) {
|
||||||
|
if (!StringUtils.hasText(location)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Resource resource = resourceLoader.getResource(location);
|
||||||
|
if (!resource.exists() || !resource.isReadable()) {
|
||||||
|
throw new IllegalStateException(description + "失败,资源不存在或不可读: " + location);
|
||||||
|
}
|
||||||
|
String output = readStream(resource.getInputStream()).trim();
|
||||||
|
if (!StringUtils.hasText(output)) {
|
||||||
|
throw new IllegalStateException(description + "失败,输出为空");
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException(description + "失败,无法读取资源: " + location, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 shell 执行命令。
|
* 通过 shell 执行命令。
|
||||||
*
|
*
|
||||||
@@ -164,4 +245,26 @@ public class MachineIdentityCollector {
|
|||||||
inputStream.transferTo(outputStream);
|
inputStream.transferTo(outputStream);
|
||||||
return outputStream.toString(StandardCharsets.UTF_8);
|
return outputStream.toString(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OsType resolveOsType(String osName) {
|
||||||
|
if (osName.contains("win")) {
|
||||||
|
return OsType.WINDOWS;
|
||||||
|
}
|
||||||
|
if (osName.contains("mac") || osName.contains("darwin")) {
|
||||||
|
return OsType.MAC;
|
||||||
|
}
|
||||||
|
if (osName.contains("nux") || osName.contains("linux")) {
|
||||||
|
return OsType.LINUX;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("不支持的操作系统: " + currentOsName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前操作系统分类。
|
||||||
|
*/
|
||||||
|
private enum OsType {
|
||||||
|
WINDOWS,
|
||||||
|
MAC,
|
||||||
|
LINUX
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ package tech.easyflow.autoconfig.license;
|
|||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.springframework.core.io.DefaultResourceLoader;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,6 +62,35 @@ public class MachineIdentityCollectorTest {
|
|||||||
Assert.assertEquals("AA-BB-CC-DD-EE-FF", identity.macAddresses());
|
Assert.assertEquals("AA-BB-CC-DD-EE-FF", identity.macAddresses());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已配置的覆盖文件应优先于系统命令。
|
||||||
|
*
|
||||||
|
* @throws Exception 创建临时文件失败
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void shouldPreferConfiguredIdentityFiles() throws Exception {
|
||||||
|
Path tempDir = Files.createTempDirectory("machine-identity-collector");
|
||||||
|
Path machineIdFile = tempDir.resolve("machine-id.txt");
|
||||||
|
Path productUuidFile = tempDir.resolve("product-uuid.txt");
|
||||||
|
Path macAddressFile = tempDir.resolve("mac-address.txt");
|
||||||
|
Files.writeString(machineIdFile, "mounted-machine\n", StandardCharsets.UTF_8);
|
||||||
|
Files.writeString(productUuidFile, "mounted-product\n", StandardCharsets.UTF_8);
|
||||||
|
Files.writeString(macAddressFile, "02:42:ac:20:00:11\n", StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
TestMachineIdentityCollector collector = new TestMachineIdentityCollector(
|
||||||
|
"Linux",
|
||||||
|
new DefaultResourceLoader(),
|
||||||
|
machineIdFile.toUri().toString(),
|
||||||
|
productUuidFile.toUri().toString(),
|
||||||
|
macAddressFile.toUri().toString()
|
||||||
|
);
|
||||||
|
|
||||||
|
MachineIdentity identity = collector.collect();
|
||||||
|
Assert.assertEquals("mounted-machine", identity.machineId());
|
||||||
|
Assert.assertEquals("mounted-product", identity.productUuid());
|
||||||
|
Assert.assertEquals("02:42:ac:20:00:11", identity.macAddresses());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空输出应被识别为采集失败。
|
* 空输出应被识别为采集失败。
|
||||||
*/
|
*/
|
||||||
@@ -85,6 +117,15 @@ public class MachineIdentityCollectorTest {
|
|||||||
private final Map<String, String> powerShellOutputs = new HashMap<>();
|
private final Map<String, String> powerShellOutputs = new HashMap<>();
|
||||||
|
|
||||||
private TestMachineIdentityCollector(String osName) {
|
private TestMachineIdentityCollector(String osName) {
|
||||||
|
this(osName, new DefaultResourceLoader(), null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestMachineIdentityCollector(String osName,
|
||||||
|
DefaultResourceLoader resourceLoader,
|
||||||
|
String machineIdFile,
|
||||||
|
String productUuidFile,
|
||||||
|
String macAddressFile) {
|
||||||
|
super(resourceLoader, machineIdFile, productUuidFile, macAddressFile);
|
||||||
this.osName = osName;
|
this.osName = osName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -509,33 +509,6 @@ async function handleCopyMessage(item: ChatTimeTimelineItem) {
|
|||||||
|
|
||||||
.chat-history-detail__markdown {
|
.chat-history-detail__markdown {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
font-size: 14px;
|
|
||||||
line-height: 1.72;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-history-detail__markdown :deep(.markdown-body) {
|
|
||||||
font-size: inherit;
|
|
||||||
line-height: inherit;
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-history-detail__markdown :deep(.markdown-body > :first-child) {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-history-detail__markdown :deep(.markdown-body > :last-child) {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-history-detail__markdown :deep(.markdown-body p) {
|
|
||||||
font-size: inherit;
|
|
||||||
line-height: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-history-detail__markdown :deep(pre) {
|
|
||||||
max-width: 100%;
|
|
||||||
margin-top: 0;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-history-detail__tool-panel :deep(.el-collapse-item__wrap) {
|
.chat-history-detail__tool-panel :deep(.el-collapse-item__wrap) {
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import type {
|
|||||||
} from '@easyflow/types';
|
} from '@easyflow/types';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { XMarkdown as ElXMarkdown } from 'vue-element-plus-x';
|
|
||||||
|
|
||||||
import { ChatThinkingBlock } from '@easyflow/common-ui';
|
import { ChatThinkingBlock, ChatTimeMarkdown } from '@easyflow/common-ui';
|
||||||
import { IconifyIcon } from '@easyflow/icons';
|
import { IconifyIcon } from '@easyflow/icons';
|
||||||
|
|
||||||
import { CircleCheck } from '@element-plus/icons-vue';
|
import { CircleCheck } from '@element-plus/icons-vue';
|
||||||
@@ -75,7 +74,7 @@ function toggleToolExpanded() {
|
|||||||
:status="segment.status"
|
:status="segment.status"
|
||||||
class="chat-thinking-block-item"
|
class="chat-thinking-block-item"
|
||||||
/>
|
/>
|
||||||
<ElXMarkdown v-else :markdown="segment.content" />
|
<ChatTimeMarkdown v-else :content="segment.content" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -125,7 +124,7 @@ function toggleToolExpanded() {
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<ElXMarkdown v-else :markdown="item.content" />
|
<ChatTimeMarkdown v-else :content="item.content" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ interface PageDataProps {
|
|||||||
requestClient?: any;
|
requestClient?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PageDataRow = Record<string, any>;
|
||||||
|
|
||||||
const props = withDefaults(defineProps<PageDataProps>(), {
|
const props = withDefaults(defineProps<PageDataProps>(), {
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
pageSizes: () => [10, 20, 50, 100],
|
pageSizes: () => [10, 20, 50, 100],
|
||||||
@@ -24,7 +26,7 @@ const props = withDefaults(defineProps<PageDataProps>(), {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 响应式数据
|
// 响应式数据
|
||||||
const pageList = ref([]);
|
const pageList = ref<PageDataRow[]>([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const queryParams = ref<Record<string, any>>({});
|
const queryParams = ref<Record<string, any>>({});
|
||||||
|
|
||||||
@@ -83,7 +85,7 @@ const patchRowById = (
|
|||||||
patch: Record<string, any>,
|
patch: Record<string, any>,
|
||||||
): boolean => {
|
): boolean => {
|
||||||
const rowIndex = pageList.value.findIndex(
|
const rowIndex = pageList.value.findIndex(
|
||||||
(item: Record<string, any>) => String(item?.id ?? '') === String(id ?? ''),
|
(item) => String(item?.id ?? '') === String(id ?? ''),
|
||||||
);
|
);
|
||||||
if (rowIndex === -1) {
|
if (rowIndex === -1) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -380,9 +380,22 @@ async function fetchAssistants() {
|
|||||||
raw: item,
|
raw: item,
|
||||||
value: String(item.id),
|
value: String(item.id),
|
||||||
}));
|
}));
|
||||||
|
await selectDefaultAssistantIfNeeded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function selectDefaultAssistantIfNeeded() {
|
||||||
|
if (
|
||||||
|
currentSessionId.value ||
|
||||||
|
currentSession.value?.sessionId ||
|
||||||
|
currentAssistantId.value ||
|
||||||
|
assistants.value.length === 0
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await handleAssistantChange(assistants.value[0]?.value);
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchKnowledgeOptions() {
|
async function fetchKnowledgeOptions() {
|
||||||
loadingKnowledgeOptions.value = true;
|
loadingKnowledgeOptions.value = true;
|
||||||
const [, res] = await tryit(api.get)('/api/v1/documentCollection/list', {
|
const [, res] = await tryit(api.get)('/api/v1/documentCollection/list', {
|
||||||
@@ -2274,39 +2287,13 @@ async function deleteSession(targetSession?: SessionItem) {
|
|||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-workspace__message-bubble.is-assistant :deep(.markdown-body),
|
.chat-workspace__message-bubble.is-user :deep(.chat-time-markdown),
|
||||||
.chat-workspace__message-bubble.is-user :deep(.markdown-body),
|
|
||||||
.chat-workspace__message-bubble.is-tool :deep(.markdown-body) {
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: 1.72;
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-workspace__message-bubble.is-user :deep(.elx-xmarkdown-container),
|
.chat-workspace__message-bubble.is-user :deep(.elx-xmarkdown-container),
|
||||||
.chat-workspace__message-bubble.is-user :deep(.elx-xmarkdown-provider) {
|
.chat-workspace__message-bubble.is-user :deep(.elx-xmarkdown-provider) {
|
||||||
width: auto;
|
width: auto;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-workspace__message-bubble.is-assistant :deep(.markdown-body > :first-child),
|
|
||||||
.chat-workspace__message-bubble.is-user :deep(.markdown-body > :first-child),
|
|
||||||
.chat-workspace__message-bubble.is-tool :deep(.markdown-body > :first-child) {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-workspace__message-bubble.is-assistant :deep(.markdown-body > :last-child),
|
|
||||||
.chat-workspace__message-bubble.is-user :deep(.markdown-body > :last-child),
|
|
||||||
.chat-workspace__message-bubble.is-tool :deep(.markdown-body > :last-child) {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-workspace__message-bubble.is-assistant :deep(.markdown-body p),
|
|
||||||
.chat-workspace__message-bubble.is-user :deep(.markdown-body p),
|
|
||||||
.chat-workspace__message-bubble.is-tool :deep(.markdown-body p) {
|
|
||||||
font-size: inherit;
|
|
||||||
line-height: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-workspace__message-bubble.is-assistant :deep(pre),
|
.chat-workspace__message-bubble.is-assistant :deep(pre),
|
||||||
.chat-workspace__message-bubble.is-user :deep(pre),
|
.chat-workspace__message-bubble.is-user :deep(pre),
|
||||||
.chat-workspace__message-bubble.is-tool :deep(pre) {
|
.chat-workspace__message-bubble.is-tool :deep(pre) {
|
||||||
|
|||||||
@@ -162,10 +162,11 @@ const parseWorkflowNodeValue = (node: TreeTableNode): any => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const parseArrayValue = (node: TreeTableNode): any[] => {
|
const parseArrayValue = (node: TreeTableNode): any[] => {
|
||||||
if (Array.isArray(node.defaultValue as any)) {
|
const defaultValue = node.defaultValue as unknown;
|
||||||
return node.defaultValue as any[];
|
if (Array.isArray(defaultValue)) {
|
||||||
|
return defaultValue;
|
||||||
}
|
}
|
||||||
const raw = String(node.defaultValue || '').trim();
|
const raw = String(defaultValue || '').trim();
|
||||||
if (!raw) {
|
if (!raw) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,9 @@ import {
|
|||||||
ref,
|
ref,
|
||||||
watch,
|
watch,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import ElXMarkdown from 'vue-element-plus-x/es/XMarkdown/index.js';
|
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
import { ChatThinkingBlock } from '@easyflow/common-ui';
|
import { ChatThinkingBlock, ChatTimeMarkdown } from '@easyflow/common-ui';
|
||||||
import { LOGIN_PATH } from '@easyflow/constants';
|
import { LOGIN_PATH } from '@easyflow/constants';
|
||||||
import { IconifyIcon } from '@easyflow/icons';
|
import { IconifyIcon } from '@easyflow/icons';
|
||||||
import { $t } from '@easyflow/locales';
|
import { $t } from '@easyflow/locales';
|
||||||
@@ -1854,9 +1853,9 @@ function prefetchVisibleVariants() {
|
|||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<template v-if="segment.type === 'text'">
|
<template v-if="segment.type === 'text'">
|
||||||
<ElXMarkdown
|
<ChatTimeMarkdown
|
||||||
class="public-chat-markdown"
|
class="public-chat-markdown"
|
||||||
:markdown="segment.content"
|
:content="segment.content"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="segment.type === 'thinking'">
|
<template v-else-if="segment.type === 'thinking'">
|
||||||
@@ -2342,50 +2341,10 @@ function prefetchVisibleVariants() {
|
|||||||
box-shadow: 0 2px 6px rgb(15 23 42 / 5%);
|
box-shadow: 0 2px 6px rgb(15 23 42 / 5%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.public-chat-markdown {
|
|
||||||
color: var(--pc-ink);
|
|
||||||
}
|
|
||||||
|
|
||||||
.public-chat-thinking-block {
|
.public-chat-thinking-block {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.public-chat-markdown :deep(*) {
|
|
||||||
overflow-wrap: anywhere;
|
|
||||||
}
|
|
||||||
|
|
||||||
.public-chat-markdown :deep(p) {
|
|
||||||
margin: 0 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.public-chat-markdown :deep(p:last-child) {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.public-chat-markdown :deep(a) {
|
|
||||||
color: var(--pc-primary);
|
|
||||||
word-break: break-all;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.public-chat-markdown :deep(img) {
|
|
||||||
display: block;
|
|
||||||
max-width: min(100%, 420px);
|
|
||||||
height: auto;
|
|
||||||
margin: 10px 0;
|
|
||||||
border: 1px solid #dbe5f1;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 6px 18px rgb(15 23 42 / 8%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.public-chat-markdown :deep(pre) {
|
|
||||||
padding: 10px 12px;
|
|
||||||
overflow: auto;
|
|
||||||
background: #f8fafc;
|
|
||||||
border: 1px solid #e2e8f0;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.public-chat-tool-header {
|
.public-chat-tool-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"qrcode": "catalog:",
|
"qrcode": "catalog:",
|
||||||
"tippy.js": "catalog:",
|
"tippy.js": "catalog:",
|
||||||
"vue": "catalog:",
|
"vue": "catalog:",
|
||||||
|
"vue-element-plus-x": "catalog:",
|
||||||
"vue-json-viewer": "catalog:",
|
"vue-json-viewer": "catalog:",
|
||||||
"vue-router": "catalog:",
|
"vue-router": "catalog:",
|
||||||
"vue-tippy": "catalog:"
|
"vue-tippy": "catalog:"
|
||||||
|
|||||||
@@ -0,0 +1,308 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { XMarkdown as ElXMarkdown } from 'vue-element-plus-x';
|
||||||
|
|
||||||
|
import { usePreferences } from '@easyflow-core/preferences';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
content?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
content: '',
|
||||||
|
});
|
||||||
|
const { isDark } = usePreferences();
|
||||||
|
const normalizedContent = computed(() => String(props.content || ''));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ElXMarkdown
|
||||||
|
class="chat-time-markdown"
|
||||||
|
:allow-html="false"
|
||||||
|
:enable-breaks="true"
|
||||||
|
:enable-code-line-number="false"
|
||||||
|
:enable-latex="true"
|
||||||
|
:default-theme-mode="isDark ? 'dark' : 'light'"
|
||||||
|
:markdown="normalizedContent"
|
||||||
|
:need-view-code-btn="false"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.chat-time-markdown {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
color: hsl(var(--text-strong));
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.72;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.elx-xmarkdown-container),
|
||||||
|
.chat-time-markdown :deep(.elx-xmarkdown-provider),
|
||||||
|
.chat-time-markdown :deep(.markdown-body) {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
color: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
line-height: inherit;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.markdown-body) {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.markdown-body > :first-child) {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.markdown-body > :last-child) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h1),
|
||||||
|
.chat-time-markdown :deep(h2),
|
||||||
|
.chat-time-markdown :deep(h3),
|
||||||
|
.chat-time-markdown :deep(h4),
|
||||||
|
.chat-time-markdown :deep(h5),
|
||||||
|
.chat-time-markdown :deep(h6) {
|
||||||
|
margin: 1.35em 0 0.62em;
|
||||||
|
color: hsl(var(--text-strong));
|
||||||
|
font-weight: 650;
|
||||||
|
line-height: 1.28;
|
||||||
|
letter-spacing: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h1) {
|
||||||
|
font-size: 1.55em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h2) {
|
||||||
|
font-size: 1.34em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h3) {
|
||||||
|
font-size: 1.18em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h4) {
|
||||||
|
font-size: 1.06em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h5),
|
||||||
|
.chat-time-markdown :deep(h6) {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(p) {
|
||||||
|
margin: 0.72em 0;
|
||||||
|
font-size: inherit;
|
||||||
|
line-height: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(strong) {
|
||||||
|
color: hsl(var(--text-strong));
|
||||||
|
font-weight: 650;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(em) {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(del) {
|
||||||
|
color: hsl(var(--text-muted));
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(a) {
|
||||||
|
color: hsl(var(--primary));
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 3px;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(a:hover) {
|
||||||
|
color: hsl(var(--primary) / 0.82);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(hr) {
|
||||||
|
height: 1px;
|
||||||
|
margin: 1.25em 0;
|
||||||
|
background: hsl(var(--divider-faint) / 0.84);
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(blockquote) {
|
||||||
|
margin: 0.95em 0;
|
||||||
|
padding: 8px 12px;
|
||||||
|
color: hsl(var(--text-muted));
|
||||||
|
background: hsl(var(--surface-subtle) / 0.72);
|
||||||
|
border-left: 3px solid hsl(var(--primary) / 0.32);
|
||||||
|
border-radius: 0 10px 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(blockquote > :first-child) {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(blockquote > :last-child) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(ul),
|
||||||
|
.chat-time-markdown :deep(ol) {
|
||||||
|
margin: 0.72em 0;
|
||||||
|
padding-left: 1.45em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(ul) {
|
||||||
|
list-style: disc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(ol) {
|
||||||
|
list-style: decimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(ul ul),
|
||||||
|
.chat-time-markdown :deep(ol ul) {
|
||||||
|
list-style: circle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(ul ul ul),
|
||||||
|
.chat-time-markdown :deep(ol ul ul) {
|
||||||
|
list-style: square;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(li) {
|
||||||
|
margin: 0.28em 0;
|
||||||
|
padding-left: 0.12em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(li > p) {
|
||||||
|
margin: 0.36em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(li.task-list-item) {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.task-list-item-checkbox) {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
margin: 0 0.48em 0 -1.45em;
|
||||||
|
vertical-align: -0.12em;
|
||||||
|
accent-color: hsl(var(--primary));
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(table) {
|
||||||
|
display: block;
|
||||||
|
width: max-content;
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 1em 0;
|
||||||
|
overflow: auto;
|
||||||
|
border-spacing: 0;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(th),
|
||||||
|
.chat-time-markdown :deep(td) {
|
||||||
|
min-width: 96px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
vertical-align: top;
|
||||||
|
border: 1px solid hsl(var(--divider-faint) / 0.88);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(th) {
|
||||||
|
color: hsl(var(--text-strong));
|
||||||
|
font-weight: 650;
|
||||||
|
background: hsl(var(--surface-subtle));
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(tr:nth-child(2n) td) {
|
||||||
|
background: hsl(var(--surface-subtle) / 0.42);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(code) {
|
||||||
|
padding: 0.12em 0.34em;
|
||||||
|
color: hsl(var(--primary));
|
||||||
|
font-size: 0.92em;
|
||||||
|
font-family:
|
||||||
|
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
|
||||||
|
'Courier New', monospace;
|
||||||
|
background: hsl(var(--surface-subtle));
|
||||||
|
border: 1px solid hsl(var(--divider-faint) / 0.7);
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(pre) {
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 1em 0;
|
||||||
|
padding: 12px 14px;
|
||||||
|
overflow: auto;
|
||||||
|
color: hsl(var(--text-strong));
|
||||||
|
background: hsl(var(--surface-subtle));
|
||||||
|
border: 1px solid hsl(var(--divider-faint) / 0.82);
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(pre code) {
|
||||||
|
display: block;
|
||||||
|
min-width: max-content;
|
||||||
|
padding: 0;
|
||||||
|
color: inherit;
|
||||||
|
font-size: 0.92em;
|
||||||
|
line-height: 1.68;
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
overflow-wrap: normal;
|
||||||
|
word-break: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.shiki),
|
||||||
|
.chat-time-markdown :deep(.shiki code) {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(img) {
|
||||||
|
display: block;
|
||||||
|
max-width: min(100%, 460px);
|
||||||
|
height: auto;
|
||||||
|
margin: 1em 0;
|
||||||
|
border: 1px solid hsl(var(--divider-faint) / 0.82);
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.katex-display) {
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 1em 0;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.katex) {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.mermaid),
|
||||||
|
.chat-time-markdown :deep([class*='mermaid']) {
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 1em 0;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(svg) {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.dark) .chat-time-markdown :deep(blockquote) {
|
||||||
|
background: hsl(var(--surface-subtle) / 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.dark) .chat-time-markdown :deep(code),
|
||||||
|
:global(.dark) .chat-time-markdown :deep(pre) {
|
||||||
|
background: hsl(var(--surface-subtle) / 0.78);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { default as ChatTimeMarkdown } from './ChatTimeMarkdown.vue';
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
export * from './api-component';
|
export * from './api-component';
|
||||||
export * from './captcha';
|
export * from './captcha';
|
||||||
|
export * from './chat-markdown';
|
||||||
export * from './chat-thinking';
|
export * from './chat-thinking';
|
||||||
export * from './col-page';
|
export * from './col-page';
|
||||||
export * from './count-to';
|
export * from './count-to';
|
||||||
|
|||||||
@@ -171,10 +171,6 @@ function isCollectionOutputParameter(parameter?: Parameter | null) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCollectionDisplayName(label: string) {
|
|
||||||
return label.endsWith('.[]') ? label : `${label}.[]`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildCollectionAwareLabel(
|
function buildCollectionAwareLabel(
|
||||||
referenceLabel: string,
|
referenceLabel: string,
|
||||||
parentLabel: string,
|
parentLabel: string,
|
||||||
|
|||||||
3
easyflow-ui-admin/pnpm-lock.yaml
generated
3
easyflow-ui-admin/pnpm-lock.yaml
generated
@@ -1366,6 +1366,9 @@ importers:
|
|||||||
vue:
|
vue:
|
||||||
specifier: ^3.5.17
|
specifier: ^3.5.17
|
||||||
version: 3.5.24(typescript@5.9.3)
|
version: 3.5.24(typescript@5.9.3)
|
||||||
|
vue-element-plus-x:
|
||||||
|
specifier: 'catalog:'
|
||||||
|
version: 1.3.7(rollup@4.53.2)(vue@3.5.24(typescript@5.9.3))
|
||||||
vue-json-viewer:
|
vue-json-viewer:
|
||||||
specifier: 'catalog:'
|
specifier: 'catalog:'
|
||||||
version: 3.0.4(vue@3.5.24(typescript@5.9.3))
|
version: 3.0.4(vue@3.5.24(typescript@5.9.3))
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { ChatTimeTimelineItem } from '@easyflow/types';
|
import type { ChatTimeTimelineItem } from '@easyflow/types';
|
||||||
|
|
||||||
import { XMarkdown as ElXMarkdown } from 'vue-element-plus-x';
|
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
import { ChatThinkingBlock } from '@easyflow/common-ui';
|
import { ChatThinkingBlock, ChatTimeMarkdown } from '@easyflow/common-ui';
|
||||||
import { IconifyIcon } from '@easyflow/icons';
|
import { IconifyIcon } from '@easyflow/icons';
|
||||||
import { useUserStore } from '@easyflow/stores';
|
import { useUserStore } from '@easyflow/stores';
|
||||||
|
|
||||||
@@ -200,7 +198,7 @@ async function handleCopy(item: ChatTimeTimelineItem) {
|
|||||||
:status="segment.status"
|
:status="segment.status"
|
||||||
class="chat-thinking-block-item"
|
class="chat-thinking-block-item"
|
||||||
/>
|
/>
|
||||||
<ElXMarkdown v-else :markdown="segment.content" />
|
<ChatTimeMarkdown v-else :content="segment.content" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -256,7 +254,7 @@ async function handleCopy(item: ChatTimeTimelineItem) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<ElXMarkdown v-else :markdown="item.content" />
|
<ChatTimeMarkdown v-else :content="item.content" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #footer="{ item }">
|
<template #footer="{ item }">
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"qrcode": "catalog:",
|
"qrcode": "catalog:",
|
||||||
"tippy.js": "catalog:",
|
"tippy.js": "catalog:",
|
||||||
"vue": "catalog:",
|
"vue": "catalog:",
|
||||||
|
"vue-element-plus-x": "catalog:",
|
||||||
"vue-json-viewer": "catalog:",
|
"vue-json-viewer": "catalog:",
|
||||||
"vue-router": "catalog:",
|
"vue-router": "catalog:",
|
||||||
"vue-tippy": "catalog:"
|
"vue-tippy": "catalog:"
|
||||||
|
|||||||
@@ -0,0 +1,308 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { XMarkdown as ElXMarkdown } from 'vue-element-plus-x';
|
||||||
|
|
||||||
|
import { usePreferences } from '@easyflow-core/preferences';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
content?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
content: '',
|
||||||
|
});
|
||||||
|
const { isDark } = usePreferences();
|
||||||
|
const normalizedContent = computed(() => String(props.content || ''));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ElXMarkdown
|
||||||
|
class="chat-time-markdown"
|
||||||
|
:allow-html="false"
|
||||||
|
:enable-breaks="true"
|
||||||
|
:enable-code-line-number="false"
|
||||||
|
:enable-latex="true"
|
||||||
|
:default-theme-mode="isDark ? 'dark' : 'light'"
|
||||||
|
:markdown="normalizedContent"
|
||||||
|
:need-view-code-btn="false"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.chat-time-markdown {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
color: hsl(var(--text-strong));
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.72;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.elx-xmarkdown-container),
|
||||||
|
.chat-time-markdown :deep(.elx-xmarkdown-provider),
|
||||||
|
.chat-time-markdown :deep(.markdown-body) {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
color: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
line-height: inherit;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.markdown-body) {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.markdown-body > :first-child) {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.markdown-body > :last-child) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h1),
|
||||||
|
.chat-time-markdown :deep(h2),
|
||||||
|
.chat-time-markdown :deep(h3),
|
||||||
|
.chat-time-markdown :deep(h4),
|
||||||
|
.chat-time-markdown :deep(h5),
|
||||||
|
.chat-time-markdown :deep(h6) {
|
||||||
|
margin: 1.35em 0 0.62em;
|
||||||
|
color: hsl(var(--text-strong));
|
||||||
|
font-weight: 650;
|
||||||
|
line-height: 1.28;
|
||||||
|
letter-spacing: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h1) {
|
||||||
|
font-size: 1.55em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h2) {
|
||||||
|
font-size: 1.34em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h3) {
|
||||||
|
font-size: 1.18em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h4) {
|
||||||
|
font-size: 1.06em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(h5),
|
||||||
|
.chat-time-markdown :deep(h6) {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(p) {
|
||||||
|
margin: 0.72em 0;
|
||||||
|
font-size: inherit;
|
||||||
|
line-height: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(strong) {
|
||||||
|
color: hsl(var(--text-strong));
|
||||||
|
font-weight: 650;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(em) {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(del) {
|
||||||
|
color: hsl(var(--text-muted));
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(a) {
|
||||||
|
color: hsl(var(--primary));
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 3px;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(a:hover) {
|
||||||
|
color: hsl(var(--primary) / 0.82);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(hr) {
|
||||||
|
height: 1px;
|
||||||
|
margin: 1.25em 0;
|
||||||
|
background: hsl(var(--divider-faint) / 0.84);
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(blockquote) {
|
||||||
|
margin: 0.95em 0;
|
||||||
|
padding: 8px 12px;
|
||||||
|
color: hsl(var(--text-muted));
|
||||||
|
background: hsl(var(--surface-subtle) / 0.72);
|
||||||
|
border-left: 3px solid hsl(var(--primary) / 0.32);
|
||||||
|
border-radius: 0 10px 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(blockquote > :first-child) {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(blockquote > :last-child) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(ul),
|
||||||
|
.chat-time-markdown :deep(ol) {
|
||||||
|
margin: 0.72em 0;
|
||||||
|
padding-left: 1.45em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(ul) {
|
||||||
|
list-style: disc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(ol) {
|
||||||
|
list-style: decimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(ul ul),
|
||||||
|
.chat-time-markdown :deep(ol ul) {
|
||||||
|
list-style: circle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(ul ul ul),
|
||||||
|
.chat-time-markdown :deep(ol ul ul) {
|
||||||
|
list-style: square;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(li) {
|
||||||
|
margin: 0.28em 0;
|
||||||
|
padding-left: 0.12em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(li > p) {
|
||||||
|
margin: 0.36em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(li.task-list-item) {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.task-list-item-checkbox) {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
margin: 0 0.48em 0 -1.45em;
|
||||||
|
vertical-align: -0.12em;
|
||||||
|
accent-color: hsl(var(--primary));
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(table) {
|
||||||
|
display: block;
|
||||||
|
width: max-content;
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 1em 0;
|
||||||
|
overflow: auto;
|
||||||
|
border-spacing: 0;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(th),
|
||||||
|
.chat-time-markdown :deep(td) {
|
||||||
|
min-width: 96px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
vertical-align: top;
|
||||||
|
border: 1px solid hsl(var(--divider-faint) / 0.88);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(th) {
|
||||||
|
color: hsl(var(--text-strong));
|
||||||
|
font-weight: 650;
|
||||||
|
background: hsl(var(--surface-subtle));
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(tr:nth-child(2n) td) {
|
||||||
|
background: hsl(var(--surface-subtle) / 0.42);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(code) {
|
||||||
|
padding: 0.12em 0.34em;
|
||||||
|
color: hsl(var(--primary));
|
||||||
|
font-size: 0.92em;
|
||||||
|
font-family:
|
||||||
|
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
|
||||||
|
'Courier New', monospace;
|
||||||
|
background: hsl(var(--surface-subtle));
|
||||||
|
border: 1px solid hsl(var(--divider-faint) / 0.7);
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(pre) {
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 1em 0;
|
||||||
|
padding: 12px 14px;
|
||||||
|
overflow: auto;
|
||||||
|
color: hsl(var(--text-strong));
|
||||||
|
background: hsl(var(--surface-subtle));
|
||||||
|
border: 1px solid hsl(var(--divider-faint) / 0.82);
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(pre code) {
|
||||||
|
display: block;
|
||||||
|
min-width: max-content;
|
||||||
|
padding: 0;
|
||||||
|
color: inherit;
|
||||||
|
font-size: 0.92em;
|
||||||
|
line-height: 1.68;
|
||||||
|
background: transparent;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
overflow-wrap: normal;
|
||||||
|
word-break: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.shiki),
|
||||||
|
.chat-time-markdown :deep(.shiki code) {
|
||||||
|
background: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(img) {
|
||||||
|
display: block;
|
||||||
|
max-width: min(100%, 460px);
|
||||||
|
height: auto;
|
||||||
|
margin: 1em 0;
|
||||||
|
border: 1px solid hsl(var(--divider-faint) / 0.82);
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.katex-display) {
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 1em 0;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.katex) {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(.mermaid),
|
||||||
|
.chat-time-markdown :deep([class*='mermaid']) {
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 1em 0;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-time-markdown :deep(svg) {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.dark) .chat-time-markdown :deep(blockquote) {
|
||||||
|
background: hsl(var(--surface-subtle) / 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.dark) .chat-time-markdown :deep(code),
|
||||||
|
:global(.dark) .chat-time-markdown :deep(pre) {
|
||||||
|
background: hsl(var(--surface-subtle) / 0.78);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { default as ChatTimeMarkdown } from './ChatTimeMarkdown.vue';
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
export * from './api-component';
|
export * from './api-component';
|
||||||
export * from './captcha';
|
export * from './captcha';
|
||||||
|
export * from './chat-markdown';
|
||||||
export * from './chat-thinking';
|
export * from './chat-thinking';
|
||||||
export * from './col-page';
|
export * from './col-page';
|
||||||
export * from './count-to';
|
export * from './count-to';
|
||||||
|
|||||||
3
easyflow-ui-usercenter/pnpm-lock.yaml
generated
3
easyflow-ui-usercenter/pnpm-lock.yaml
generated
@@ -1342,6 +1342,9 @@ importers:
|
|||||||
vue:
|
vue:
|
||||||
specifier: ^3.5.17
|
specifier: ^3.5.17
|
||||||
version: 3.5.24(typescript@5.9.3)
|
version: 3.5.24(typescript@5.9.3)
|
||||||
|
vue-element-plus-x:
|
||||||
|
specifier: 'catalog:'
|
||||||
|
version: 1.3.7(rollup@4.53.2)(vue@3.5.24(typescript@5.9.3))
|
||||||
vue-json-viewer:
|
vue-json-viewer:
|
||||||
specifier: 'catalog:'
|
specifier: 'catalog:'
|
||||||
version: 3.0.4(vue@3.5.24(typescript@5.9.3))
|
version: 3.0.4(vue@3.5.24(typescript@5.9.3))
|
||||||
|
|||||||
Reference in New Issue
Block a user