Compare commits
2 Commits
74fa884eda
...
93c7f0138c
| Author | SHA1 | Date |
|---|---|---|
|
|
93c7f0138c | |
|
|
ca6a8d6ad8 |
|
|
@ -0,0 +1,13 @@
|
|||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider 忽略的文件
|
||||
/contentModel.xml
|
||||
/projectSettingsUpdater.xml
|
||||
/modules.xml
|
||||
/.idea.外业端.iml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
|
|
@ -12,14 +12,20 @@
|
|||
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.3" />
|
||||
<PackageReference Include="Minio" Version="6.0.4" />
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.6" />
|
||||
<PackageReference Include="WPF-UI" Version="4.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
<Folder Include="Views\" />
|
||||
<Folder Include="Assets\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,82 @@
|
|||
<Window x:Class="Hopytry.MainWindow"
|
||||
<Window x:Class="Hopetry.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Hopytry"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
Title="云端文件管理器" Height="680" Width="1000">
|
||||
<Window.Resources>
|
||||
<Style x:Key="ModernButton" TargetType="Button">
|
||||
<Setter Property="Background" Value="#1976D2"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="Padding" Value="12,6"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Margin" Value="0,0,10,0"/>
|
||||
</Style>
|
||||
|
||||
<Grid>
|
||||
|
||||
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="Padding" Value="8,2"/>
|
||||
<Setter Property="Background" Value="#FFFFFF"/>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Margin="16" x:Name="ContentGrid">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Frame x:Name="MainFrame" NavigationUIVisibility="Hidden" />
|
||||
<!-- 原有操作工具栏和文件网格视图 -->
|
||||
|
||||
<!-- 右侧详情面板 -->
|
||||
<Border Grid.Column="1" Margin="16,0,0,0" Background="White"
|
||||
CornerRadius="8">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="12" ShadowDepth="4" Color="#10000000"/>
|
||||
</Border.Effect>
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock Text="文件详情" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,12"/>
|
||||
|
||||
<TextBlock Text="文件名:" FontWeight="Medium"/>
|
||||
<TextBlock Text="{Binding SelectedFile.FileName}" Margin="0,0,0,8"/>
|
||||
<TextBlock Text="大小:" FontWeight="Medium"/>
|
||||
<TextBlock Text="{Binding SelectedFile.Size}" Margin="0,0,0,8"/>
|
||||
<TextBlock Text="修改时间:" FontWeight="Medium"/>
|
||||
<TextBlock Text="{Binding SelectedFile.ModifiedTime}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 悬浮操作按钮 -->
|
||||
<StackPanel Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Bottom"
|
||||
Margin="0,0,32,32" Orientation="Horizontal">
|
||||
<Button Style="{StaticResource ModernButton}" Content="新建"
|
||||
Padding="16,8" Background="#1976D2"
|
||||
Margin="0,0,12,0">
|
||||
<Button.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Data="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"
|
||||
Fill="White" Stretch="Uniform" Width="16" Height="16"/>
|
||||
<TextBlock Text="新建" Margin="8,0,0,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Button.ContentTemplate>
|
||||
</Button>
|
||||
<Button Style="{StaticResource ModernButton}" Content="上传"
|
||||
Padding="16,8" Background="#1976D2">
|
||||
<Button.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Data="M9,16V10H5L12,3L19,10H15V16H9Z"
|
||||
Fill="White" Stretch="Uniform" Width="16" Height="16"/>
|
||||
<TextBlock Text="上传" Margin="8,0,0,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Button.ContentTemplate>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
|
|||
|
|
@ -1,31 +1,20 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using FileUploader.Models;
|
||||
using Hopetry.Services;
|
||||
namespace Hopytry
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Win32;
|
||||
using ModernWpf.Controls;
|
||||
|
||||
namespace Hopetry
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
/* public partial class MainWindow : Window
|
||||
{
|
||||
private AppDbContext _db = new AppDbContext();
|
||||
private MinioService _minioService;
|
||||
|
|
@ -35,5 +24,93 @@ namespace Hopytry
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}*/
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private AppDbContext _db = new AppDbContext();
|
||||
private MinioService _minioService;
|
||||
public ObservableCollection<FileRecord> UploadQueue { get; } = new ObservableCollection<FileRecord>();
|
||||
public bool ShutdownAfterUpload { get; set; }
|
||||
Dictionary<string, Uri> _pages;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
/* _pages = new Dictionary<string, Uri>
|
||||
{
|
||||
{ "home", new Uri("Views/HomePage.xaml", UriKind.Relative) },
|
||||
{ "files", new Uri("Views/FilesPage.xaml", UriKind.Relative) },
|
||||
{ "share", new Uri("Views/SharePage.xaml", UriKind.Relative) },
|
||||
{ "trash", new Uri("Views/TrashPage.xaml", UriKind.Relative) }
|
||||
};
|
||||
MainFrame.Navigate(_pages["home"]);*/
|
||||
DataContext = this;
|
||||
// 初始化导航完成
|
||||
_db.Database.Migrate();
|
||||
Console.WriteLine(Directory.GetCurrentDirectory());
|
||||
var config = new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("global.json")
|
||||
.Build();
|
||||
|
||||
_minioService = new MinioService(config);
|
||||
}
|
||||
|
||||
private void NavigationView_SelectionChanged(object sender,
|
||||
NavigationViewSelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.SelectedItemContainer?.Tag is string tag && _pages.TryGetValue(tag, out Uri uri))
|
||||
{
|
||||
MainFrame.Navigate(uri);
|
||||
}
|
||||
}
|
||||
|
||||
private async void AddUser_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
/* var dialog = new UserDialog();
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
_db.Users.Add(new User { Username = dialog.Username });
|
||||
await _db.SaveChangesAsync();
|
||||
//LogTextBox.AppendText($"用户 {dialog.Username} 添加成功\n");
|
||||
}*/
|
||||
}
|
||||
|
||||
private void SelectFile_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog();
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
UploadQueue.Add(new FileRecord
|
||||
{
|
||||
FileName = Path.GetFileName(dialog.FileName),
|
||||
LocalPath = dialog.FileName,
|
||||
UserId = 1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async void StartUpload_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
foreach (var file in UploadQueue)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _minioService.UploadFileAsync(file);
|
||||
file.MinioPath = $"uploads/{file.FileName}";
|
||||
file.UploadTime = DateTime.Now;
|
||||
_db.FileRecords.Add(file);
|
||||
await _db.SaveChangesAsync();
|
||||
//LogTextBox.AppendText($"文件 {file.FileName} 上传成功\n");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//LogTextBox.AppendText($"上传失败: {ex.Message}\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (ShutdownAfterUpload)
|
||||
Process.Start("shutdown", "/s /t 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style x:Key="ModernButton" TargetType="Button">
|
||||
<Setter Property="Background" Value="#1976D2"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="Padding" Value="12,6"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
<Setter Property="Margin" Value="0,0,10,0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Height" Value="32"/>
|
||||
<Setter Property="Padding" Value="8,2"/>
|
||||
<Setter Property="Background" Value="#FFFFFF"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="DataGrid">
|
||||
<Setter Property="HeadersVisibility" Value="Column"/>
|
||||
<Setter Property="AutoGenerateColumns" Value="False"/>
|
||||
<Setter Property="Margin" Value="0,10,0,0"/>
|
||||
<Setter Property="RowHeight" Value="30"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<Page x:Class="FileUploader.Views.FilesPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FileUploader.Views"
|
||||
Title="FilesPage" Height="Auto" Width="Auto">
|
||||
<Grid>
|
||||
<!-- 文件管理页面内容 -->
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<Page x:Class="FileUploader.Views.HomePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="http://schemas.wpfui.net/winfx/xaml/controls"
|
||||
Title="HomePage"
|
||||
Background="White">
|
||||
<Grid>
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Text="欢迎使用云端存储管理系统" FontSize="24"
|
||||
Foreground="#333"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<Page x:Class="FileUploader.Views.SharePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FileUploader.Views"
|
||||
Title="SharePage" Height="Auto" Width="Auto">
|
||||
<Grid>
|
||||
<!-- 文件分享页面内容 -->
|
||||
<TextBlock Text="文件分享管理"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<Page x:Class="FileUploader.Views.TrashPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FileUploader.Views"
|
||||
Title="TrashPage" Height="Auto" Width="Auto">
|
||||
<Grid>
|
||||
<!-- 回收站页面内容 -->
|
||||
<TextBlock Text="回收站管理"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "6.0.0",
|
||||
"rollForward": "latestMajor",
|
||||
"allowPrerelease": true
|
||||
},
|
||||
"Minio": {
|
||||
"Endpoint": "your-minio-endpoint",
|
||||
"AccessKey": "your-access-key",
|
||||
"SecretKey": "your-secret-key",
|
||||
"BucketName": "uploads"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue