Compare commits
No commits in common. "dc5d53a953a7a0acf16cabc628357e23f1a60f42" and "c9df5b2317efcdc9b3163a989df28fee97fae554" have entirely different histories.
dc5d53a953
...
c9df5b2317
|
|
@ -5,4 +5,3 @@
|
|||
# Generated by Tauri
|
||||
# will have schema files for capabilities auto-completion
|
||||
/gen/schemas
|
||||
resource/
|
||||
|
|
@ -483,10 +483,8 @@ checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
|
|||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
|
|
@ -4037,7 +4035,6 @@ dependencies = [
|
|||
name = "wallitor-gui"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
|
|
|
|||
|
|
@ -22,5 +22,4 @@ serde_json = "1"
|
|||
window-vibrancy = "0.5.2"
|
||||
tauri-plugin-fs = "2.0.0-rc"
|
||||
tauri-plugin-dialog = "2.0.0-rc"
|
||||
chrono = "0.4.38"
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "test1",
|
||||
"info": {
|
||||
"type": "",
|
||||
"description": "test wallpaper 1",
|
||||
"created": 0
|
||||
},
|
||||
"option": {
|
||||
"mute": true
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 386 KiB |
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "test2",
|
||||
"info": {
|
||||
"type": "",
|
||||
"description": "test wallpaper 2",
|
||||
"created": 0
|
||||
},
|
||||
"option": {
|
||||
"mute": true
|
||||
}
|
||||
}
|
||||
|
|
@ -2,11 +2,9 @@ mod setup;
|
|||
mod reader;
|
||||
|
||||
use std::{fs, path};
|
||||
use serde_json::{self,json};
|
||||
use serde_json;
|
||||
use std::path::Path;
|
||||
use tauri::ipc::Response;
|
||||
use serde::{Deserialize,Serialize};
|
||||
use chrono::Local;
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
|
|
@ -14,7 +12,7 @@ pub fn run() {
|
|||
.setup(setup::init)
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.invoke_handler(tauri::generate_handler![read_resource_dir,get_file,new_wallpaper])
|
||||
.invoke_handler(tauri::generate_handler![read_resource_dir,get_file])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
|
@ -40,68 +38,3 @@ async fn get_file(path:String) -> Response{
|
|||
}
|
||||
tauri::ipc::Response::new(String::from(""))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct AddInfo {
|
||||
name: String,
|
||||
preview: String,
|
||||
media: String,
|
||||
description: String
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Info{
|
||||
media_type:String,
|
||||
description:String,
|
||||
created:i64
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Opt{
|
||||
mute:bool
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Config{
|
||||
name:String,
|
||||
info:Info,
|
||||
option:Opt
|
||||
}
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
async fn new_wallpaper(info:AddInfo) -> String{
|
||||
let base_url = String::from("./resource");
|
||||
let current_time:i64 = Local::now().timestamp();
|
||||
let folder = format!("{}/{}",base_url,current_time);
|
||||
if fs::create_dir_all(Path::new(&folder)).is_err(){
|
||||
return String::from("Error creating folder.");
|
||||
}
|
||||
if let Ok(false) = fs::exists(Path::new(&info.preview)){
|
||||
return String::from("Source Image doesn't exist.");
|
||||
}
|
||||
if fs::copy(Path::new(&info.preview), Path::new(&format!("{}/preview.jpg",folder))).is_err(){
|
||||
return String::from("Error copy image.");
|
||||
}
|
||||
let config =json!( Config{
|
||||
name:info.name,
|
||||
info:Info { media_type: String::from("video"), description: info.description, created: current_time},
|
||||
option:Opt{mute:true}
|
||||
});
|
||||
if fs::write(Path::new(&format!("{}/config.json",folder)), config.to_string()).is_err(){
|
||||
return String::from("Error write config.");
|
||||
}
|
||||
if fs::create_dir(Path::new(&format!("{}/res",folder))).is_err(){
|
||||
return String::from("Error creating res folder.");
|
||||
}
|
||||
let media = Path::new(&info.media);
|
||||
if let Some(filename) = media.file_name().and_then(|f| f.to_str()){
|
||||
if fs::copy(Path::new(&info.media), Path::new(&format!("{}/res/{}",folder,filename))).is_err(){
|
||||
return String::from("Error copy media.");
|
||||
}
|
||||
}
|
||||
else{
|
||||
return String::from("Invalid media path.");
|
||||
}
|
||||
String::from("Success")
|
||||
}
|
||||
|
|
@ -18,39 +18,37 @@
|
|||
</header>
|
||||
<main class="item-add-main">
|
||||
<table class="item-add-form">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="item-add-form-title">标题</td>
|
||||
<td><input type="text" v-model="addInfo.name" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="item-add-form-title">文件</td>
|
||||
<td>
|
||||
<template v-if="image_src">
|
||||
<img :src="image_src" class="item-add-image" @click="selectPreview">
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="item-add-preview" @click="selectPreview">
|
||||
<div class="item-add-preview-text">
|
||||
<SvgIcon name="add" size="20px"></SvgIcon>点击添加封面
|
||||
</div>
|
||||
<tr>
|
||||
<td class="item-add-form-title">标题</td>
|
||||
<td><input type="text" v-model="addInfo.name" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="item-add-form-title">文件</td>
|
||||
<td>
|
||||
<template v-if="image_src">
|
||||
<img :src="image_src" class="item-add-image">
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="item-add-preview" @click="selectPreview">
|
||||
<div class="item-add-preview-text">
|
||||
<SvgIcon name="add" size="20px"></SvgIcon>点击添加封面
|
||||
</div>
|
||||
</template>
|
||||
<div class="colbox">
|
||||
<button class="apply-button" @click="selectMedia">选择</button>
|
||||
<div>{{ addInfo.media }}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="item-add-form-title">描述</td>
|
||||
<td><textarea class="item-add-description" v-model="addInfo.description"></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><button class="apply-button" @click="handleAdd">添加</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</template>
|
||||
<div class="colbox">
|
||||
<button class="apply-button" @click="selectMedia">选择</button>
|
||||
<div>{{ addInfo.media }}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="item-add-form-title">描述</td>
|
||||
<td><textarea class="item-add-description" v-model="addInfo.description"></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><button class="apply-button" @click="handleFileOpen">添加</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</main>
|
||||
</div>
|
||||
|
|
@ -115,14 +113,6 @@ function selectPreview() {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
invoke("new_wallpaper", {
|
||||
info: addInfo.value
|
||||
}).then((res) => {
|
||||
console.log(res);
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
@ -218,11 +208,6 @@ function handleAdd() {
|
|||
width: 400px;
|
||||
margin-bottom: 10px;
|
||||
box-shadow: var(--shadow-edge-glow);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.item-add-image:active {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
|
||||
.item-add-form {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
类型
|
||||
</div>
|
||||
<div class="apply-bar-info-main">
|
||||
{{ cell.config.info.media_type }}
|
||||
{{ cell.config.info.type }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="apply-bar-info rowbox">
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
创建时间
|
||||
</div>
|
||||
<div class="apply-bar-info-main">
|
||||
{{ (new Date(cell.config.info.created * 1000)).toLocaleString() }}
|
||||
{{ (new Date(cell.config.info.created)).toLocaleString() }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="apply-bar-info rowbox">
|
||||
|
|
@ -81,7 +81,7 @@ const cell = ref<Cell>({
|
|||
}
|
||||
}
|
||||
})
|
||||
const info_items = ref<(keyof Info)[]>(["media_type", "description", "created"]);
|
||||
const info_items = ref<(keyof Info)[]>(["type", "description", "created"]);
|
||||
const bg = ref<HTMLDivElement | null>(null);
|
||||
defineExpose({ open })
|
||||
watch(() => visible.value, (val, _) => {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export interface wpConfig {
|
|||
}
|
||||
type WallpaperType = 'Video'
|
||||
export interface Info {
|
||||
media_type: WallpaperType
|
||||
type: WallpaperType
|
||||
description: string
|
||||
created: number
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue