mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-07 12:16:04 +00:00
Add Azure AI service (Azure AI Foundry), Add the AppConfig manager
This commit is contained in:
parent
56ee12741c
commit
96dbe7b2cd
|
@ -195,7 +195,7 @@ namespace WelsonJS.Launcher
|
|||
|
||||
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
Program.OpenWebBrowser(Properties.Resources.RepositoryUrl);
|
||||
Program.OpenWebBrowser(Program.GetAppConfig("RepositoryUrl"));
|
||||
}
|
||||
|
||||
private void userdefinedVariablesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -245,7 +245,7 @@ namespace WelsonJS.Launcher
|
|||
{
|
||||
if (Program.resourceServer == null)
|
||||
{
|
||||
Program.resourceServer = new ResourceServer(Properties.Resources.ResourceServerPrefix, "editor.html");
|
||||
Program.resourceServer = new ResourceServer(Program.GetAppConfig("ResourceServerPrefix"), "editor.html");
|
||||
}
|
||||
|
||||
if (!Program.resourceServer.IsRunning())
|
||||
|
@ -273,7 +273,7 @@ namespace WelsonJS.Launcher
|
|||
|
||||
private void openCopilotToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Program.OpenWebBrowser(Properties.Resources.CopilotUrl);
|
||||
Program.OpenWebBrowser(Program.GetAppConfig("CopilotUrl"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Configuration;
|
||||
using WelsonJS.Launcher.Tools;
|
||||
|
||||
namespace WelsonJS.Launcher
|
||||
|
@ -156,5 +157,22 @@ namespace WelsonJS.Launcher
|
|||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
|
||||
public static string GetAppConfig(string key)
|
||||
{
|
||||
string value = ConfigurationManager.AppSettings[key];
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
value = Properties.Resources.ResourceManager.GetString(key);
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,6 +133,14 @@ namespace WelsonJS.Launcher.Tools
|
|||
return;
|
||||
}
|
||||
|
||||
// Serve a value of App Config request
|
||||
const string configPrefix = "config/";
|
||||
if (path.StartsWith(configPrefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ServeConfigRequest(context, path.Substring(configPrefix.Length));
|
||||
return;
|
||||
}
|
||||
|
||||
// Serve a resource
|
||||
ServeResource(context, GetResource(_resourceName), "text/html");
|
||||
}
|
||||
|
@ -272,6 +280,18 @@ namespace WelsonJS.Launcher.Tools
|
|||
ServeResource(context);
|
||||
}
|
||||
|
||||
public void ServeConfigRequest(HttpListenerContext context, string key)
|
||||
{
|
||||
string value = Program.GetAppConfig(key);
|
||||
if (!String.IsNullOrEmpty(value))
|
||||
{
|
||||
ServeResource(context, value, "text/plain", 200);
|
||||
return;
|
||||
}
|
||||
|
||||
ServeResource(context);
|
||||
}
|
||||
|
||||
private void ServeResource(HttpListenerContext context)
|
||||
{
|
||||
ServeResource(context, "<error>Not Found</error>", "application/xml", 404);
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="ResourceServerPrefix" value="http://localhost:3000/"/>
|
||||
<add key="RepositoryUrl" value="https://github.com/gnh1201/welsonjs"/>
|
||||
<add key="CopilotUrl" value="https://copilot.microsoft.com/"/>
|
||||
<add key="AzureAiServiceUrl" value="https://ai-catswords656881030318.services.ai.azure.com/models/chat/completions?api-version=2024-05-01-preview"/>
|
||||
<add key="AzureAiServiceApiKey" value=""/>
|
||||
</appSettings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
|
||||
</startup>
|
||||
|
|
Loading…
Reference in New Issue
Block a user