mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-07 12:16:04 +00:00
Some updates
This commit is contained in:
parent
53a84b2349
commit
916154499c
|
@ -242,10 +242,7 @@ namespace WelsonJS.Launcher
|
||||||
|
|
||||||
private void startCodeEditorToolStripMenuItem_Click(object sender, EventArgs e)
|
private void startCodeEditorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Program.resourceServer == null)
|
Program.StartResourceServer();
|
||||||
{
|
|
||||||
Program.resourceServer = new ResourceServer(Program.GetAppConfig("ResourceServerPrefix"), "editor.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Program.resourceServer.IsRunning())
|
if (!Program.resourceServer.IsRunning())
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,13 +138,22 @@ namespace WelsonJS.Launcher
|
||||||
return workingDirectory;
|
return workingDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void StartResourceServer()
|
||||||
|
{
|
||||||
|
if (resourceServer == null)
|
||||||
|
{
|
||||||
|
resourceServer = new ResourceServer(GetAppConfig("ResourceServerPrefix"), "editor.html");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void OpenWebBrowser(string url)
|
public static void OpenWebBrowser(string url)
|
||||||
{
|
{
|
||||||
string userDataDir = Path.Combine(GetAppDataPath(), "EdgeUserProfile");
|
string userDataDir = Path.Combine(GetAppDataPath(), "EdgeUserProfile");
|
||||||
string remoteAllowOrigins = "http://localhost:3000";
|
string remoteAllowOrigins = GetAppConfig("ResourceServerPrefix");
|
||||||
|
int remoteDebuggingPort = new Uri(GetAppConfig("DevToolsPrefix")).Port;
|
||||||
string[] arguments = {
|
string[] arguments = {
|
||||||
$"\"{url}\"",
|
$"\"{url}\"",
|
||||||
"--remote-debugging-port=9222",
|
$"--remote-debugging-port={remoteDebuggingPort}",
|
||||||
$"--remote-allow-origins={remoteAllowOrigins}", // for security reason
|
$"--remote-allow-origins={remoteAllowOrigins}", // for security reason
|
||||||
$"--user-data-dir=\"{userDataDir}\""
|
$"--user-data-dir=\"{userDataDir}\""
|
||||||
};
|
};
|
||||||
|
|
29
WelsonJS.Toolkit/WelsonJS.Launcher/ResourceTools/AzureAi.cs
Normal file
29
WelsonJS.Toolkit/WelsonJS.Launcher/ResourceTools/AzureAi.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WelsonJS.Launcher.ResourceTools
|
||||||
|
{
|
||||||
|
public class AzureAi : IResourceTool
|
||||||
|
{
|
||||||
|
private ResourceServer Server;
|
||||||
|
private const string Prefix = "azure-ai/";
|
||||||
|
|
||||||
|
public AzureAi(ResourceServer server)
|
||||||
|
{
|
||||||
|
Server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanHandle(string path)
|
||||||
|
{
|
||||||
|
return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task HandleAsync(HttpListenerContext context, string path)
|
||||||
|
{
|
||||||
|
await Task.Delay(0);
|
||||||
|
|
||||||
|
// TODO: Pass Azure AI request to Azure AI Foundry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -74,6 +74,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="IResourceTool.cs" />
|
<Compile Include="IResourceTool.cs" />
|
||||||
|
<Compile Include="ResourceTools\AzureAi.cs" />
|
||||||
<Compile Include="ResourceTools\Config.cs" />
|
<Compile Include="ResourceTools\Config.cs" />
|
||||||
<Compile Include="ResourceTools\Completion.cs" />
|
<Compile Include="ResourceTools\Completion.cs" />
|
||||||
<Compile Include="ResourceTools\DevTools.cs" />
|
<Compile Include="ResourceTools\DevTools.cs" />
|
||||||
|
@ -165,6 +166,5 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="editor.html" />
|
<EmbeddedResource Include="editor.html" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -50,16 +50,14 @@
|
||||||
<span class="icon mif-floppy-disks"></span>
|
<span class="icon mif-floppy-disks"></span>
|
||||||
<span class="caption">Save File</span>
|
<span class="caption">Save File</span>
|
||||||
</button>
|
</button>
|
||||||
<button id="btnGenerate" class="ribbon-button">
|
<span class="title">File</span>
|
||||||
|
</div>
|
||||||
|
<div class="group">
|
||||||
|
<button id="btnCopilot" class="ribbon-button">
|
||||||
<span class="icon mif-rocket"></span>
|
<span class="icon mif-rocket"></span>
|
||||||
<span class="caption">Generate</span>
|
<span class="caption">Copilot</span>
|
||||||
</button>
|
</button>
|
||||||
<button id="btnSponsor" class="ribbon-button">
|
<span class="title">Generative</span>
|
||||||
<span class="icon mif-heart"></span>
|
|
||||||
<span class="caption">Sponsor</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<span class="title">Common</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<button id="btnWhois" class="ribbon-button">
|
<button id="btnWhois" class="ribbon-button">
|
||||||
|
@ -70,8 +68,7 @@
|
||||||
<span class="icon mif-earth"></span>
|
<span class="icon mif-earth"></span>
|
||||||
<span class="caption">DNS</span>
|
<span class="caption">DNS</span>
|
||||||
</button>
|
</button>
|
||||||
|
<span class="title">Network</span>
|
||||||
<span class="title">Network tools</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -240,18 +237,14 @@
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById("btnSponsor").onclick = function () {
|
document.getElementById("btnCopilot").onclick = function () {
|
||||||
navigate('https://github.com/sponsors/gnh1201');
|
|
||||||
};
|
|
||||||
|
|
||||||
document.getElementById("btnGenerate").onclick = function () {
|
|
||||||
const promptMessage = prompt("Enter a prompt message:", '');
|
const promptMessage = prompt("Enter a prompt message:", '');
|
||||||
if (!promptMessage || promptMessage.trim() == '') {
|
if (!promptMessage || promptMessage.trim() == '') {
|
||||||
alert("A prompt message is required.");
|
alert("A prompt message is required.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
appendTextToEditor(`\n//${promptMessage}... Thinking with Generative AI...`);
|
appendTextToEditor(`\n//${promptMessage}... Generating text with Copilot...`);
|
||||||
|
|
||||||
(async function () {
|
(async function () {
|
||||||
const targetWsUrl = await getTargetByUrl('copilot.microsoft.com');
|
const targetWsUrl = await getTargetByUrl('copilot.microsoft.com');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user