Skip to content

Commit 72d44db

Browse files
committed
合并 master 上的功能
2 parents d40092a + 9bd9c3e commit 72d44db

28 files changed

Lines changed: 136 additions & 95 deletions

File tree

AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
55
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
6-
<AssemblyVersion>1.6.6</AssemblyVersion>
7-
<Version>1.6.6</Version>
8-
<PackageVersion>1.6.5</PackageVersion>
6+
<AssemblyVersion>1.6.7</AssemblyVersion>
7+
<Version>1.6.7</Version>
8+
<PackageVersion>1.6.7</PackageVersion>
99
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
10-
<FileVersion>1.6.6</FileVersion>
10+
<FileVersion>1.6.7</FileVersion>
1111
</PropertyGroup>
1212

1313
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

AgileConfig.Server.Apisite/Appsettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@ public class Appsettings
2222
/// </summary>
2323
public static bool Cluster => "true".Equals(Global.Config["cluster"], StringComparison.CurrentCultureIgnoreCase);
2424

25+
/// <summary>
26+
/// path base
27+
/// </summary>
28+
public static string PathBase => Global.Config["pathBase"];
2529
}
2630
}

AgileConfig.Server.Apisite/UIExtension/ReactUIMiddleware.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,40 @@ private bool ShouldHandleUIStaticFilesRequest(HttpContext context)
5454
return false;
5555
}
5656

57+
/// <summary>
58+
/// 为了适配 pathbase ,index.html 注入的 js css ,需要使用相对路径,所以要去除 /
59+
/// </summary>
60+
/// <param name="filePath"></param>
61+
/// <returns></returns>
62+
private async Task RewriteIndexHtml(string filePath)
63+
{
64+
var rows = await File.ReadAllLinesAsync(filePath);
65+
for (int i = 0; i < rows.Length; i++)
66+
{
67+
var line = rows[i];
68+
if (line.Contains("window.resourceBaseUrl = \"/\""))
69+
{
70+
if (!string.IsNullOrWhiteSpace(Appsettings.PathBase))
71+
{
72+
line = line.Replace("/", $"{Appsettings.PathBase}/");
73+
rows[i] = line;
74+
}
75+
}
76+
if (line.Contains("<link rel=\"stylesheet\" href=\"/umi."))
77+
{
78+
line = line.Replace("/umi.", "umi.");
79+
rows[i] = line;
80+
}
81+
if (line.Contains("<script src=\"/umi."))
82+
{
83+
line = line.Replace("/umi.", "umi.");
84+
rows[i] = line;
85+
}
86+
87+
}
88+
await File.WriteAllLinesAsync(filePath, rows);
89+
}
90+
5791
private static readonly string UiDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot/ui");
5892
public async Task Invoke(HttpContext context)
5993
{
@@ -93,6 +127,11 @@ public async Task Invoke(HttpContext context)
93127
}
94128
else
95129
{
130+
if (filePath.EndsWith("index.html"))
131+
{
132+
await RewriteIndexHtml(filePath);
133+
}
134+
96135
var fileData = await File.ReadAllBytesAsync(filePath); //read file bytes
97136
var lastModified = File.GetLastWriteTime(filePath);
98137
var extType = Path.GetExtension(filePath);

AgileConfig.Server.Apisite/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"serviceHealthCheckInterval": 15, // 服务健康检测的间隔时间,单位:秒
1212
"serviceUnhealthInterval": 30, // 判断服务不健康的间隔,超出这个时间没响应过则认为不健康,单位:秒
1313
"removeServiceInterval": 0, // 如果一个服务超出这个时间没有响应,则直接移除这个服务,单位:秒;如果设定为 <= 0,则不会移除,默认 0 。
14-
"pathBase": "", //使用反向代理的时候,或许需要修改这个值 /xxx
14+
"pathBase": "", //使用反向代理的时候,或许需要修改这个值 /xxx 必须/开头
1515
"adminConsole": true,
1616
"cluster": false, // 集群模式:服务启动后自动加入节点列表,服务启动的时候会获取容器的ip,端口默认5000,适合 docker compose 环境使用
1717
"preview_mode": true,

AgileConfig.Server.Apisite/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"serviceHealthCheckInterval": 15, // 服务健康检测的间隔时间,单位:秒
1212
"serviceUnhealthInterval": 60, // 判断服务不健康的间隔,超出这个时间没响应过则认为不健康,默认60,单位:秒
1313
"removeServiceInterval": 0, // 如果一个服务超出这个时间没有响应,则直接移除这个服务,单位:秒;如果设定为 <= 0,则不会移除,默认 0 。
14-
"pathBase": "", //使用反向代理的时候,或许需要修改这个值
14+
"pathBase": "", //使用反向代理的时候,或许需要修改这个值 /xxx 必须/开头
1515
"adminConsole": false,
1616
"cluster": false, // 集群模式:服务启动后自动加入节点列表,服务启动的时候会获取容器的ip,端口默认5000,适合 docker compose 环境使用
1717
"preview_mode": false,

AgileConfig.Server.Service/RemoteServerNodeProxy.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using System.Collections.Concurrent;
1313
using System.Collections.Generic;
1414
using System.Threading.Tasks;
15+
using Microsoft.EntityFrameworkCore;
1516

1617
namespace AgileConfig.Server.Service
1718
{
@@ -272,7 +273,12 @@ public async Task TestEchoAsync(string address)
272273

273274
if (node.Status == NodeStatus.Offline)
274275
{
275-
if (node.LastEchoTime.HasValue && (DateTime.Now - node.LastEchoTime.Value).TotalMinutes >= 30)
276+
DateTime? time = node.LastEchoTime;
277+
if (!time.HasValue)
278+
{
279+
time = node.CreateTime;
280+
}
281+
if (time.HasValue && (DateTime.Now - time.Value).TotalMinutes >= 30)
276282
{
277283
// 超过 30 分钟没有回应,则移除节点
278284
await service.DeleteAsync(address);

AgileConfig.Server.UI/react-ui-antd/config/config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export default defineConfig({
2222
// default true, when it is true, will use `navigator.language` overwrite default
2323
baseNavigator: true,
2424
},
25-
dynamicImport: {
26-
loading: '@/components/PageLoading/index',
27-
},
25+
dynamicImport: false,
2826
targets: {
2927
ie: 11,
3028
},
@@ -40,5 +38,7 @@ export default defineConfig({
4038
manifest: {
4139
basePath: '/a/',
4240
},
43-
esbuild: {}
41+
esbuild: {},
42+
publicPath: '/',
43+
runtimePublicPath: true
4444
});

AgileConfig.Server.UI/react-ui-antd/public/icons/avatar.png renamed to AgileConfig.Server.UI/react-ui-antd/src/assets/avatar.png

File renamed without changes.
12.8 KB
Loading

AgileConfig.Server.UI/react-ui-antd/src/components/GlobalHeader/AvatarDropdown.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { CurrentUser } from '@/models/user';
88
import HeaderDropdown from '../HeaderDropdown';
99
import styles from './index.less';
1010
import Changepassword from '../ChangePassword/changePassword';
11+
import avatar from '../../assets/avatar.png'
1112

1213
export type GlobalHeaderRightProps = {
1314
currentUser?: CurrentUser;
@@ -114,7 +115,7 @@ class AvatarDropdown extends React.Component<GlobalHeaderRightProps,{changePassw
114115
width:30
115116
}
116117
}
117-
src="/icons/avatar.png"></img>
118+
src={avatar}></img>
118119
{
119120
currentUser?.name
120121
}

0 commit comments

Comments
 (0)