Skip to content

Commit

Permalink
v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
NianChen authored and NianChen committed Oct 19, 2022
1 parent 9dcd935 commit dbee25c
Show file tree
Hide file tree
Showing 24 changed files with 393 additions and 112 deletions.
25 changes: 16 additions & 9 deletions AiPrompt/AiPrompt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ApplicationTitle>AiPrompt</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.aiprompt</ApplicationId>
<ApplicationId>com.xueque.aiprompt</ApplicationId>
<ApplicationIdGuid>5FBB22BC-690D-4055-91AE-385FF906F628</ApplicationIdGuid>

<!-- Versions -->
Expand All @@ -30,34 +30,41 @@
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<LangVersion>10</LangVersion>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<PackageCertificateThumbprint>EA74CA5ABC054780009410D9CBCB64B048E72F85</PackageCertificateThumbprint>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!--<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />-->
<MauiIcon Include="Resources\AppIcon\aiprompt.svg" />

<!-- Splash Screen -->
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<Content Include="Sources\赛博萨满必修:与AI对话的tag集2.xlsx" />
<Content Include="Sources\赛博萨满必修:与AI对话的tag集.xlsx" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="EPPlus" Version="6.0.8" />
<PackageReference Include="Masa.Blazor" Version="0.5.0" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
</ItemGroup>

<ProjectExtensions><VisualStudio><UserProperties wwwroot_4resource_4config_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>

</Project>
14 changes: 14 additions & 0 deletions AiPrompt/Data/BaseModel.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
12 changes: 12 additions & 0 deletions AiPrompt/Data/Config.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
18 changes: 17 additions & 1 deletion AiPrompt/Data/Prompt.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -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; }


}

7 changes: 4 additions & 3 deletions AiPrompt/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using AiPrompt.Service;
using AiPrompt.Service.Impl;
using Microsoft.AspNetCore.Components.WebView.Maui;
using AiPrompt.Util;

namespace AiPrompt;

Expand All @@ -27,9 +27,10 @@ public static MauiApp CreateMauiApp()
options.Primary = "#7160E8";
});
});

builder.Services.AddSingleton<ISourceService, SourceService>();
builder.Services.AddSingleton<Db>();
builder.Services.AddSingleton<ISourceService, SourceService>();
builder.Services.AddSingleton<IPromptService, PromptService>();
builder.Services.AddSingleton<IConfigService, ConfigService>();
builder.Services.AddSingleton<StateContainer>();

return builder.Build();
Expand Down
17 changes: 12 additions & 5 deletions AiPrompt/Pages/CopyComponent.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<MButton Icon @onclick="@(()=>{
Clipboard.SetTextAsync($"{Text},");
<MButton Icon @onclick="@(async ()=>{
await Clipboard.SetTextAsync(Text);
open = true;
})">
<MIcon>mdi-note-multiple-outline</MIcon>
Expand All @@ -12,16 +12,23 @@
已复制到剪切板
</ChildContent>
<ActionContent>
<MButton Color="indigo"
<MButton Color="blue darken-1"
Text
OnClick="()=>open = false">
Close
关闭
</MButton>
</ActionContent>
</MSnackbar>

@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;
}
4 changes: 3 additions & 1 deletion AiPrompt/Pages/ListItemComponent.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using AiPrompt.Data
@using System.Net
<MCard>
<MImage Src="@(Prompt.Image??defaultImage)" Class="white--text align-end" Gradient="to bottom, rgba(0,0,0,.1), rgba(0,0,0,.5)" Height=200>
<MCardTitle>@Prompt.Name</MCardTitle>
Expand All @@ -17,5 +18,6 @@
public EventCallback<Prompt> PromptChanged { get; set; }



private string defaultImage = "data:image/png;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wAARCABPAFMDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDrriV5IsOQW9qbbDanPXJqNgSMkk1IikDdng1CR2N2POviDq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ycEAH1Hc1YFhNI32OHBkOBKxOAP9n3+vtXSWXw3vJU8yedIuACMjIz06Aj8qIVFFmkIvojmnt1YecASQMEYzgjPJHfAxWjpOjXWp3caWsTTu6AY3BR35OT3yOn4Vag017e3u3H70W0+04ON3bIz34JHT6g16LocdvPo1lNbv5QcZMiqPnK8EEYGcD1wDk9eKyxMmpXN5U7apHHaf8AD69d5ZLe68qVMjymiJR8cYDjp0JxgEccYzjs9B1SeNIdO1ON7a7QbIXIwJQOMAjgsPTqcEVopHF9oiisowZrhd+48YAxk56gZHOMnPIB4I2pvC2n3tg1veI8u7+MMVK46FcHjHp7DOec5U6renQSmoKzRDdQrqNhJHwHHKkdmAyMfgcfiRXNDpgjBAIIPX6fzrdRdQ0QfYph9tJOYZS4UsvAy/oRkA4Bz165rFvWk+2TGWNEfILKhJAyAeCev5CtKb1cTOok1dFNvvGinErnvRW9jnP/2Q==";
}
}
9 changes: 4 additions & 5 deletions AiPrompt/Pages/PromptList.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
@page "/{Key}"
@using AiPrompt.Data
@using AiPrompt.Service
@using AiPrompt.Util
@inject StateContainer stateContainer
@inject IPromptService promptService
@implements IDisposable

<MCard>
<MContainer>
<ListComponent @bind-Data="Prompts"/>
</MContainer>
</MCard>
<MContainer>
<ListComponent @bind-Data="Prompts"/>
</MContainer>



Expand Down
2 changes: 1 addition & 1 deletion AiPrompt/Platforms/Windows/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" />
<Identity Name="maui-package-name-placeholder" Publisher="CN=NianChen" Version="0.0.2.0" />

<Properties>
<DisplayName>$placeholder$</DisplayName>
Expand Down
8 changes: 8 additions & 0 deletions AiPrompt/Resources/AppIcon/aiprompt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions AiPrompt/Service/IConfigService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using AiPrompt.Data;

namespace AiPrompt.Service;

public interface IConfigService
{
public Task SaveConfig(Config config);
public Task<Config> GetConfig();

}
4 changes: 3 additions & 1 deletion AiPrompt/Service/ISourceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public interface ISourceService{

public Task<IEnumerable<Prompt>> ReadCategoriesAsync();

public Task<IEnumerable<Source>> AllSourceAsync();
public Task<List<Source>> AllSourceAsync();

public Task<string> GetSourcePathAsync();

public IEnumerable<Prompt> ReadPrefabPrompts(string key);
public Task<IEnumerable<Prompt>> ReadPrefabPromptsAsync(string key);
Expand Down
44 changes: 44 additions & 0 deletions AiPrompt/Service/Impl/ConfigService.cs
Original file line number Diff line number Diff line change
@@ -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<Config>(fs, config,new JsonSerializerOptions(){ WriteIndented = true });
// }
// catch { }
//}
}

public async Task<Config> GetConfig()
{
return await db.GetAsync<Config>();
//using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))
//{
// try
// {
// var config = await JsonSerializer.DeserializeAsync<Config>(fs);
// return config;
// }
// catch { return null; }

//}
}
}
3 changes: 1 addition & 2 deletions AiPrompt/Service/Impl/PromptService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using AiPrompt.Data;
using OfficeOpenXml;
using System.Linq;
using AiPrompt.Util;

namespace AiPrompt.Service.Impl;

Expand Down
Loading

0 comments on commit dbee25c

Please sign in to comment.