diff --git a/AiPrompt/AiPrompt.csproj b/AiPrompt/AiPrompt.csproj
index 64598ca..67410eb 100644
--- a/AiPrompt/AiPrompt.csproj
+++ b/AiPrompt/AiPrompt.csproj
@@ -16,7 +16,7 @@
AiPrompt
- com.companyname.aiprompt
+ com.xueque.aiprompt
5FBB22BC-690D-4055-91AE-385FF906F628
@@ -30,34 +30,41 @@
10.0.17763.0
6.5
10
+ False
+ True
+ EA74CA5ABC054780009410D9CBCB64B048E72F85
+ SHA256
+ False
+ False
+ True
+ 0
-
+
-
+
+
-
+
-
-
-
-
-
+
+
+
diff --git a/AiPrompt/Data/BaseModel.cs b/AiPrompt/Data/BaseModel.cs
new file mode 100644
index 0000000..f8d4566
--- /dev/null
+++ b/AiPrompt/Data/BaseModel.cs
@@ -0,0 +1,14 @@
+using SQLite;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AiPrompt.Data;
+
+public class BaseModel
+{
+ [PrimaryKey]
+ public string Id { get; set; }
+}
diff --git a/AiPrompt/Data/Config.cs b/AiPrompt/Data/Config.cs
new file mode 100644
index 0000000..5867eb8
--- /dev/null
+++ b/AiPrompt/Data/Config.cs
@@ -0,0 +1,12 @@
+using SQLite;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AiPrompt.Data;
+
+public class Config:BaseModel{
+ public string SourcePath { get; set; }
+}
diff --git a/AiPrompt/Data/Prompt.cs b/AiPrompt/Data/Prompt.cs
index 85eff56..144739e 100644
--- a/AiPrompt/Data/Prompt.cs
+++ b/AiPrompt/Data/Prompt.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -11,8 +12,23 @@ namespace AiPrompt.Data;
public class Prompt{
public string Key { get; set; }
public string Name { get; set; }
- public string Image { get; set; }
+
+ private string image;
+ public string Image { get=> image; set{
+ image = LocalFile2Base64(value);
+ }}
+
+ private string LocalFile2Base64(string value)
+ {
+ if (!File.Exists(value)){
+ return value;
+ }
+ string base64 = $"data:image/png;base64,{Convert.ToBase64String(File.ReadAllBytes(value))}";
+ return base64;
+ }
+
public bool Active { get; set; }
+
}
diff --git a/AiPrompt/MauiProgram.cs b/AiPrompt/MauiProgram.cs
index 584c388..0be68b7 100644
--- a/AiPrompt/MauiProgram.cs
+++ b/AiPrompt/MauiProgram.cs
@@ -1,6 +1,6 @@
using AiPrompt.Service;
using AiPrompt.Service.Impl;
-using Microsoft.AspNetCore.Components.WebView.Maui;
+using AiPrompt.Util;
namespace AiPrompt;
@@ -27,9 +27,10 @@ public static MauiApp CreateMauiApp()
options.Primary = "#7160E8";
});
});
-
- builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
builder.Services.AddSingleton();
+ builder.Services.AddSingleton();
builder.Services.AddSingleton();
return builder.Build();
diff --git a/AiPrompt/Pages/CopyComponent.razor b/AiPrompt/Pages/CopyComponent.razor
index 09180b0..baad093 100644
--- a/AiPrompt/Pages/CopyComponent.razor
+++ b/AiPrompt/Pages/CopyComponent.razor
@@ -1,6 +1,6 @@
-{
- Clipboard.SetTextAsync($"{Text},");
+{
+ await Clipboard.SetTextAsync(Text);
open = true;
})">
mdi-note-multiple-outline
@@ -12,16 +12,23 @@
已复制到剪切板
-
- Close
+ 关闭
@code {
+ private string text;
[Parameter]
- public string Text { get; set; }
+ public string Text { get{
+ if (!text.EndsWith(","))
+ {
+ return $"{text},";
+ }
+ return text;
+ } set=>text=value; }
private bool open = false;
}
diff --git a/AiPrompt/Pages/ListItemComponent.razor b/AiPrompt/Pages/ListItemComponent.razor
index a9f9627..ef303ff 100644
--- a/AiPrompt/Pages/ListItemComponent.razor
+++ b/AiPrompt/Pages/ListItemComponent.razor
@@ -1,4 +1,5 @@
@using AiPrompt.Data
+@using System.Net
@Prompt.Name
@@ -17,5 +18,6 @@
public EventCallback PromptChanged { get; set; }
+
private string defaultImage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MiqPnK8EEYGcD1wDk9eKyxMmpXN5U7apHHaf8AD69d5ZLe68qVMjymiJR8cYDjp0JxgEccYzjs9B1SeNIdO1ON7a7QbIXIwJQOMAjgsPTqcEVopHF9oiisowZrhd+48YAxk56gZHOMnPIB4I2pvC2n3tg1veI8u7+MMVK46FcHjHp7DOec5U6renQSmoKzRDdQrqNhJHwHHKkdmAyMfgcfiRXNDpgjBAIIPX6fzrdRdQ0QfYph9tJOYZS4UsvAy/oRkA4Bz165rFvWk+2TGWNEfILKhJAyAeCev5CtKb1cTOok1dFNvvGinErnvRW9jnP/2Q==";
-}
+}
\ No newline at end of file
diff --git a/AiPrompt/Pages/PromptList.razor b/AiPrompt/Pages/PromptList.razor
index b55f770..373c7c6 100644
--- a/AiPrompt/Pages/PromptList.razor
+++ b/AiPrompt/Pages/PromptList.razor
@@ -1,15 +1,14 @@
@page "/{Key}"
@using AiPrompt.Data
@using AiPrompt.Service
+@using AiPrompt.Util
@inject StateContainer stateContainer
@inject IPromptService promptService
@implements IDisposable
-
-
-
-
-
+
+
+
diff --git a/AiPrompt/Platforms/Windows/Package.appxmanifest b/AiPrompt/Platforms/Windows/Package.appxmanifest
index 2bcb11e..7e50e9f 100644
--- a/AiPrompt/Platforms/Windows/Package.appxmanifest
+++ b/AiPrompt/Platforms/Windows/Package.appxmanifest
@@ -5,7 +5,7 @@
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
-
+
$placeholder$
diff --git a/AiPrompt/Resources/AppIcon/aiprompt.svg b/AiPrompt/Resources/AppIcon/aiprompt.svg
new file mode 100644
index 0000000..8f84506
--- /dev/null
+++ b/AiPrompt/Resources/AppIcon/aiprompt.svg
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/AiPrompt/Service/IConfigService.cs b/AiPrompt/Service/IConfigService.cs
new file mode 100644
index 0000000..d1abdd8
--- /dev/null
+++ b/AiPrompt/Service/IConfigService.cs
@@ -0,0 +1,10 @@
+using AiPrompt.Data;
+
+namespace AiPrompt.Service;
+
+public interface IConfigService
+{
+ public Task SaveConfig(Config config);
+ public Task GetConfig();
+
+}
diff --git a/AiPrompt/Service/ISourceService.cs b/AiPrompt/Service/ISourceService.cs
index 0d93e6c..933ea34 100644
--- a/AiPrompt/Service/ISourceService.cs
+++ b/AiPrompt/Service/ISourceService.cs
@@ -19,7 +19,9 @@ public interface ISourceService{
public Task> ReadCategoriesAsync();
- public Task> AllSourceAsync();
+ public Task> AllSourceAsync();
+
+ public Task GetSourcePathAsync();
public IEnumerable ReadPrefabPrompts(string key);
public Task> ReadPrefabPromptsAsync(string key);
diff --git a/AiPrompt/Service/Impl/ConfigService.cs b/AiPrompt/Service/Impl/ConfigService.cs
new file mode 100644
index 0000000..d3e17bc
--- /dev/null
+++ b/AiPrompt/Service/Impl/ConfigService.cs
@@ -0,0 +1,44 @@
+using AiPrompt.Data;
+using AiPrompt.Util;
+
+namespace AiPrompt.Service.Impl;
+
+public class ConfigService : IConfigService{
+ public ConfigService(Db db)
+ {
+ this.db = db;
+ }
+ private readonly Db db;
+
+ private string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json");
+
+
+ public async Task SaveConfig(Config config)
+ {
+ config.Id = nameof(config);
+ await db.SaveAsync(config);
+ //using(var fs = new FileStream(path, FileMode.Create, FileAccess.Write))
+ //{
+ // try
+ // {
+ // await JsonSerializer.SerializeAsync(fs, config,new JsonSerializerOptions(){ WriteIndented = true });
+ // }
+ // catch { }
+ //}
+ }
+
+ public async Task GetConfig()
+ {
+ return await db.GetAsync();
+ //using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))
+ //{
+ // try
+ // {
+ // var config = await JsonSerializer.DeserializeAsync(fs);
+ // return config;
+ // }
+ // catch { return null; }
+
+ //}
+ }
+}
diff --git a/AiPrompt/Service/Impl/PromptService.cs b/AiPrompt/Service/Impl/PromptService.cs
index 2ac2291..a46e53f 100644
--- a/AiPrompt/Service/Impl/PromptService.cs
+++ b/AiPrompt/Service/Impl/PromptService.cs
@@ -1,6 +1,5 @@
using AiPrompt.Data;
-using OfficeOpenXml;
-using System.Linq;
+using AiPrompt.Util;
namespace AiPrompt.Service.Impl;
diff --git a/AiPrompt/Service/Impl/SourceService.cs b/AiPrompt/Service/Impl/SourceService.cs
index a2684bb..58a1579 100644
--- a/AiPrompt/Service/Impl/SourceService.cs
+++ b/AiPrompt/Service/Impl/SourceService.cs
@@ -1,15 +1,17 @@
using AiPrompt.Data;
+using AiPrompt.Util;
using OfficeOpenXml;
-using OneOf.Types;
namespace AiPrompt.Service.Impl;
internal class SourceService : ISourceService{
- public SourceService(StateContainer stateContainer){
+ public SourceService(StateContainer stateContainer,IConfigService configService){
this.stateContainer = stateContainer;
+ this.configService = configService;
}
private readonly StateContainer stateContainer;
+ private readonly IConfigService configService;
///
/// 获取目录下所有文件
@@ -18,16 +20,25 @@ public SourceService(StateContainer stateContainer){
///
///
private async Task FillDirectoryAllSource(string dir, List
///
- public async Task> AllSourceAsync(){
+ public async Task> AllSourceAsync(){
List