-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
19 changed files
with
578 additions
and
419 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,62 @@ | ||
#![cfg_attr(not(debug_assertions),windows_subsystem = "windows")] | ||
use std::process::Command; | ||
use std::os::windows::process::CommandExt; | ||
use std::path::Path; | ||
use serde::{Deserialize, Serialize}; | ||
use notify_rust::Notification; | ||
use std::path::Path; | ||
use serde_json; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
struct Config { | ||
clear_tmp: Option<bool>, | ||
clear_output: Option<bool>, | ||
} | ||
|
||
fn main() { | ||
// //是否缺少檔案 | ||
if !Path::new("core.exe").is_file() { | ||
// core not found | ||
Notification::new() | ||
.summary("找不到 core.exe") | ||
.body("相同目錄缺少檔案\"core.exe\"") | ||
.show().unwrap(); | ||
.summary("找不到 core.exe") | ||
.body("相同目錄缺少檔案\"core.exe\"") | ||
.show().unwrap(); | ||
panic!("core.exe not found"); | ||
} | ||
|
||
|
||
|
||
// //是否缺少檔案,缺少的話創建新的 | ||
let config = "config.json"; | ||
if !Path::new(&config).is_file() { | ||
let config_path = Path::new(&config); | ||
if !config_path.is_file() { | ||
println!("create {}", &config); | ||
std::fs::write(config, "{}").unwrap(); | ||
}; | ||
|
||
|
||
// //是否缺少檔案,缺少的話創建新的 | ||
let tmp = "tmp"; | ||
if !Path::new(&tmp).is_dir() { | ||
let tmp_path = Path::new(&tmp); | ||
if !tmp_path.is_dir() { | ||
println!("create {}", &tmp); | ||
std::fs::create_dir(tmp).unwrap(); | ||
}; | ||
|
||
//運行軟體 | ||
if cfg!(target_os = "windows") { | ||
const CREATE_NO_WINDOW: u32 = 0x08000000; | ||
let mut open_core = Command::new("core.exe"); | ||
let log = open_core.arg("run").creation_flags(CREATE_NO_WINDOW).output().expect("can't open core"); | ||
println!("{}", String::from_utf8_lossy(&log.stdout)); | ||
} | ||
|
||
//如果設定有,刪除暫存檔 | ||
let config_json = std::fs::read_to_string(config_path).expect("can't read config"); | ||
let config:Config = serde_json::from_str(&config_json[..]).expect("can't parse config"); | ||
if config.clear_tmp == Some(true) && tmp_path.is_dir(){ | ||
std::fs::remove_dir_all(tmp_path).unwrap(); | ||
} | ||
|
||
//如果設定有,刪除輸出檔 | ||
let output_path = Path::new("output"); | ||
if config.clear_output == Some(true) && output_path.is_dir(){ | ||
std::fs::remove_dir_all(output_path).unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export default interface Config { | ||
thread_count: number; | ||
thread_count: number | ||
clear_output:boolean | ||
clear_tmp:boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,84 @@ | ||
<template> | ||
<div | ||
@click="this.$refs.input.click" | ||
@drop="drag_file" | ||
@dragenter="drop_inout" | ||
@dragleave="drop_inout" | ||
@dragenter.prevent | ||
@dragover.prevent | ||
class="drop_here" | ||
:class="{ dropping: dragenter !== 0 }" | ||
> | ||
<h1>選擇圖片</h1> | ||
<input | ||
type="file" | ||
@change="file_change" | ||
multiple="multiple" | ||
accept=".gif,.jpg,.png" | ||
ref="input" | ||
/> | ||
</div> | ||
<div | ||
@click="this.$refs.input.click" | ||
@drop="drag_file" | ||
@dragenter="drop_inout" | ||
@dragleave="drop_inout" | ||
@dragenter.prevent | ||
@dragover.prevent | ||
class="drop_here" | ||
:class="{ dropping: dragenter !== 0 }" | ||
> | ||
<h1>選擇圖片</h1> | ||
<input | ||
type="file" | ||
@change="file_change" | ||
multiple="multiple" | ||
accept=".gif,.jpg,.png" | ||
ref="input" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { mixin } from '@/store' | ||
import { defineComponent } from 'vue' | ||
import { mixin } from "@/store"; | ||
import { defineComponent } from "vue"; | ||
export default defineComponent({ | ||
mixins: [mixin], | ||
methods:{ | ||
methods: { | ||
//拖入檔案 | ||
drag_file(e:DragEvent){ | ||
e.stopPropagation() | ||
e.preventDefault() | ||
this.dragenter = 0 | ||
const files = (e.dataTransfer as DataTransfer).files | ||
if(files.length > 0) this.upload(files) | ||
else this.log("無檔案檔案","無法讀取到丟入的檔案") | ||
drag_file(e: DragEvent) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
this.dragenter = 0; | ||
const files = (e.dataTransfer as DataTransfer).files; | ||
if (files.length > 0) this.upload(files); | ||
else this.log("無檔案檔案", "無法讀取到丟入的檔案"); | ||
}, | ||
//拖曳檔案中 | ||
drop_inout(e:DragEvent){ | ||
if(e.type == "dragenter") this.dragenter++ | ||
else this.dragenter-- | ||
drop_inout(e: DragEvent) { | ||
if (e.type == "dragenter") this.dragenter++; | ||
else this.dragenter--; | ||
}, | ||
file_change(e:InputEvent){ | ||
const input = e.target as HTMLInputElement | ||
this.upload(input.files as FileList) | ||
input.value = "" | ||
file_change(e: InputEvent) { | ||
const input = e.target as HTMLInputElement; | ||
this.upload(input.files as FileList); | ||
input.value = ""; | ||
}, | ||
//通知父層 | ||
upload(files:FileList){ | ||
this.$emit("files",files) | ||
upload(files: FileList) { | ||
this.$emit("files", files); | ||
}, | ||
}, | ||
data(){return{ | ||
dragenter:0, | ||
}} | ||
}) | ||
data() { | ||
return { | ||
dragenter: 0, | ||
}; | ||
}, | ||
}); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import "../app.scss"; | ||
.drop_here{ | ||
width:100%; | ||
background-color:$side-3; | ||
transition: background-color 0.3s ease,color 0.3s ease; | ||
.drop_here { | ||
width: 100%; | ||
background-color: $side-3; | ||
transition: background-color 0.3s ease, color 0.3s ease; | ||
position: relative; | ||
cursor: pointer; | ||
&>h1{ | ||
text-align:center; | ||
& > h1 { | ||
text-align: center; | ||
} | ||
&>input{ | ||
& > input { | ||
display: none; | ||
} | ||
&:hover{ | ||
background-color:$side-2; | ||
&:hover { | ||
background-color: $side-2; | ||
} | ||
&.dropping{ | ||
background-color:$main; | ||
&.dropping { | ||
background-color: $main; | ||
color: $bg; | ||
} | ||
} | ||
</style> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
<template> | ||
<div id="logger"> | ||
<transition-group name="fade" mode="out-in"> | ||
<div v-for="(log,index) in logger" :key="index"> | ||
<button @click="logger.splice(index, 1)"></button> | ||
<h2 v-html="log.title"></h2> | ||
<p v-html="log.content"></p> | ||
</div> | ||
</transition-group> | ||
</div> | ||
<div id="logger"> | ||
<transition-group name="fade" mode="out-in"> | ||
<div v-for="(log, index) in logger" :key="index"> | ||
<button @click="logger.splice(index, 1)"></button> | ||
<h2 v-html="log.title"></h2> | ||
<p v-html="log.content"></p> | ||
</div> | ||
</transition-group> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { useStore } from "../store"; | ||
import { defineComponent, toRef} from "vue"; | ||
import { defineComponent, toRef } from "vue"; | ||
export default defineComponent({ | ||
setup(){ | ||
return { | ||
logger: toRef(useStore().state,"logger") | ||
} | ||
} | ||
}) | ||
setup() { | ||
return { | ||
logger: toRef(useStore().state, "logger"), | ||
}; | ||
}, | ||
}); | ||
</script> | ||
|
||
<style lang="scss"> | ||
@import "../app.scss"; | ||
</style> | ||
</style> |
Oops, something went wrong.