mirror of
https://github.com/0PandaDEV/Qopy.git
synced 2025-06-17 04:17:44 +02:00
feat: add information and update chunk loading
This commit is contained in:
parent
c48a0d8239
commit
149e72802c
7 changed files with 435 additions and 151 deletions
|
@ -1,3 +1,6 @@
|
|||
use active_win_pos_rs::get_active_window;
|
||||
use base64::{engine::general_purpose::STANDARD, Engine};
|
||||
use image::codecs::png::PngEncoder;
|
||||
use tauri::PhysicalPosition;
|
||||
|
||||
pub fn center_window_on_current_monitor(window: &tauri::WebviewWindow) {
|
||||
|
@ -27,4 +30,22 @@ pub fn center_window_on_current_monitor(window: &tauri::WebviewWindow) {
|
|||
))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_app_info() -> (String, Option<String>) {
|
||||
match get_active_window() {
|
||||
Ok(window) => {
|
||||
let app_name = window.app_name;
|
||||
(app_name, None)
|
||||
}
|
||||
Err(_) => ("System".to_string(), None),
|
||||
}
|
||||
}
|
||||
|
||||
fn _process_icon_to_base64(path: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let img = image::open(path)?;
|
||||
let resized = img.resize(128, 128, image::imageops::FilterType::Lanczos3);
|
||||
let mut png_buffer = Vec::new();
|
||||
resized.write_with_encoder(PngEncoder::new(&mut png_buffer))?;
|
||||
Ok(STANDARD.encode(png_buffer))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
use uuid::Uuid;
|
||||
|
||||
|
@ -12,6 +12,7 @@ pub struct HistoryItem {
|
|||
pub content: String,
|
||||
pub favicon: Option<String>,
|
||||
pub timestamp: DateTime<Utc>,
|
||||
pub language: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
|
||||
|
@ -108,7 +109,14 @@ impl From<String> for ContentType {
|
|||
}
|
||||
|
||||
impl HistoryItem {
|
||||
pub fn new(source: String, content_type: ContentType, content: String, favicon: Option<String>, source_icon: Option<String>) -> Self {
|
||||
pub fn new(
|
||||
source: String,
|
||||
content_type: ContentType,
|
||||
content: String,
|
||||
favicon: Option<String>,
|
||||
source_icon: Option<String>,
|
||||
language: Option<String>,
|
||||
) -> Self {
|
||||
Self {
|
||||
id: Uuid::new_v4().to_string(),
|
||||
source,
|
||||
|
@ -117,10 +125,22 @@ impl HistoryItem {
|
|||
content,
|
||||
favicon,
|
||||
timestamp: Utc::now(),
|
||||
language,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_row(&self) -> (String, String, Option<String>, String, String, Option<String>, DateTime<Utc>) {
|
||||
pub fn to_row(
|
||||
&self,
|
||||
) -> (
|
||||
String,
|
||||
String,
|
||||
Option<String>,
|
||||
String,
|
||||
String,
|
||||
Option<String>,
|
||||
DateTime<Utc>,
|
||||
Option<String>,
|
||||
) {
|
||||
(
|
||||
self.id.clone(),
|
||||
self.source.clone(),
|
||||
|
@ -129,6 +149,7 @@ impl HistoryItem {
|
|||
self.content.clone(),
|
||||
self.favicon.clone(),
|
||||
self.timestamp,
|
||||
self.language.clone(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue