Skip to content

Commit

Permalink
修复了Web端执行时任务状态不改变的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
autodotua committed Sep 10, 2024
1 parent 40d1dd5 commit fb1d85c
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 179 deletions.
2 changes: 1 addition & 1 deletion SimpleFFmpegGUI.Core/DependencyInjectionExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static class DependencyInjectionExtension
{
public static void AddFFmpegServices(this IServiceCollection services)
{
services.AddDbContext<FFmpegDbContext>(ServiceLifetime.Transient)
services.AddDbContext<FFmpegDbContext>()
.AddTransient<LogManager>()
.AddTransient<ConfigManager>()
.AddTransient<PresetManager>()
Expand Down
1 change: 1 addition & 0 deletions SimpleFFmpegGUI.Web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"devDependencies": {
"@types/js-cookie": "^2.2.7",
"@types/node": "^22.5.4",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"@vue/cli-plugin-babel": "^5.0.8",
Expand Down
2 changes: 1 addition & 1 deletion SimpleFFmpegGUI.Web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
远程FFmpeg工具箱
</h2>
<a
v-show="netError"
v-if="netError"
style="
color: red;
display: inline-block;
Expand Down
3 changes: 1 addition & 2 deletions SimpleFFmpegGUI.Web/src/components/CodeArguments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
>
<el-option
v-for="item in formats"
:key="item.name"
:key="item.extension"
:label="item.extension"
:value="item.name"
>
Expand Down Expand Up @@ -555,7 +555,6 @@ export default Vue.component("code-arguments", {
.getPresets(this.type)
.then((r) => {
this.presets = r.data;
action(r.data);
})
.catch(showError);
Expand Down
182 changes: 43 additions & 139 deletions SimpleFFmpegGUI.Web/src/components/StatusBar.vue
Original file line number Diff line number Diff line change
@@ -1,187 +1,90 @@

<template>
<div class="status-bar" v-if="status != null && status.isProcessing">
<div v-if="status.hasDetail">
<div v-if="windowWidth > 768">
<el-row>
<el-col style="width: 108px; height: 64px">
<div style="background-color: #7dd07d; width: 100%; height: 100%">
<img
width="108"
height="64"
style="cursor: pointer"
:src="snapshotSrc"
v-show="snapshotSrc != ''"
@click="clickSnapshot"
/>
<img width="108" height="64" style="cursor: pointer" :src="snapshotSrc" v-show="snapshotSrc != ''"
@click="clickSnapshot" />
</div>
</el-col>
<el-col style="width: calc(100% - 120px); padding-left: 12px">
<el-row>
<el-col :span="7">
<el-row><b>码率:</b>{{ status.bitrate }}</el-row>
<el-row
><b>已用:</b
>{{ formatDoubleTimeSpan(status.progress.duration) }}</el-row
>
<el-row><b>已用:</b>{{ formatDoubleTimeSpan(status.progress.duration) }}</el-row>
</el-col>
<el-col :span="7">
<el-row
><b>速度:</b>{{ status.fps }}FPS{{ " " }}
{{ status.speed }}X</el-row
>
<el-row
><b>剩余:</b
>{{ formatDoubleTimeSpan(status.progress.lastTime) }}</el-row
>
<el-row><b>速度:</b>{{ status.fps }}FPS{{ " " }}
{{ status.speed }}X</el-row>
<el-row><b>剩余:</b>{{ formatDoubleTimeSpan(status.progress.lastTime) }}</el-row>
</el-col>
<el-col :span="7">
<el-row
><b>进度:</b>{{ status.frame }}帧
<el-row><b>进度:</b>{{ status.frame }}帧
{{ formatDoubleTimeSpan(status.time, true) }}
</el-row>
<el-row
><b>预计:</b>
{{ formatDateTime(finishTime(), true, true, false) }}</el-row
>
<el-row><b>预计:</b>
{{ formatDateTime(finishTime(), true, true, false) }}</el-row>
</el-col>

<el-col :span="3">
<el-popconfirm title="真的要取消任务吗?" @confirm="cancel">
<el-button
type="text"
style="color: red"
slot="reference"
size="big"
>取消</el-button
></el-popconfirm
>
<el-button type="text" style="color: red" slot="reference" size="big">取消</el-button></el-popconfirm>
</el-col>
</el-row>
<el-row class="right24">
<el-col :span="8" class="one-line"
><b>任务:</b
>{{ status.isPaused ? "暂停中" : status.progress.name }}</el-col
>
<el-col :span="8" class="one-line"><b>任务:</b>{{ status.isPaused ? "暂停中" : status.progress.name }}</el-col>
<el-col :span="16">
<el-progress
:text-inside="true"
class="unknown-progress"
:stroke-width="20"
color="transparent"
:percentage="100"
v-show="status.progress.isIndeterminate"
style="margin-right: 24px; margin-top: 4px"
:show-text="true"
text-color="black"
:format="(p) => '进度未知'"
define-back-color="#CCCA"
></el-progress>
<el-progress
:text-inside="true"
v-show="status.progress.isIndeterminate == false"
:stroke-width="20"
:color="progressColor"
style="margin-right: 24px; margin-top: 4px"
:percentage="status.progress.percent * 100"
:format="(p) => p.toFixed(2) + '%'"
text-color="white"
define-back-color="#CCCA"
></el-progress
></el-col>
</el-row> </el-col
></el-row>
<el-progress :text-inside="true" class="unknown-progress" :stroke-width="20" color="transparent"
:percentage="100" v-show="status.progress.isIndeterminate" style="margin-right: 24px; margin-top: 4px"
:show-text="true" text-color="black" :format="(p) => '进度未知'" define-back-color="#CCCA"></el-progress>
<el-progress :text-inside="true" v-show="status.progress.isIndeterminate == false" :stroke-width="20"
:color="progressColor" style="margin-right: 24px; margin-top: 4px"
:percentage="status.progress.percent * 100" :format="(p) => p.toFixed(2) + '%'" text-color="white"
define-back-color="#CCCA"></el-progress></el-col>
</el-row> </el-col></el-row>
</div>
<div v-else>
<el-row>
<el-col :span="12">
<el-row><b>码率:</b>{{ status.bitrate }}</el-row>
<el-row
><b>速度:</b>{{ status.fps }}FPS{{ " " }}
{{ status.speed }}X</el-row
>
<el-row
><b>进度:</b>{{ status.frame }}帧
<el-row><b>速度:</b>{{ status.fps }}FPS{{ " " }}
{{ status.speed }}X</el-row>
<el-row><b>进度:</b>{{ status.frame }}帧
{{ formatDoubleTimeSpan(status.time, true) }}
</el-row>
</el-col>
<el-col :span="12">
<el-row
><b>已用:</b
>{{ formatDoubleTimeSpan(status.progress.duration) }}</el-row
>
<el-row
><b>剩余:</b
>{{ formatDoubleTimeSpan(status.progress.lastTime) }}</el-row
>
<el-row
><b>预计:</b
>{{ formatDateTime(finishTime(), true, true, false) }}</el-row
>
<el-row><b>已用:</b>{{ formatDoubleTimeSpan(status.progress.duration) }}</el-row>
<el-row><b>剩余:</b>{{ formatDoubleTimeSpan(status.progress.lastTime) }}</el-row>
<el-row><b>预计:</b>{{ formatDateTime(finishTime(), true, true, false) }}</el-row>
</el-col>
</el-row>
<el-row class="single-line">
<b>任务:</b>{{ status.isPaused ? "暂停中" : status.progress.name }}
</el-row>
<el-row>
<el-col :span="20">
<el-progress
:text-inside="true"
class="unknown-progress"
:stroke-width="20"
color="transparent"
:percentage="100"
style="margin-right: 24px; margin-top: 4px"
:show-text="true"
v-show="status.progress.isIndeterminate"
text-color="black"
:format="(p) => '进度未知'"
define-back-color="#CCCA"
></el-progress>
<el-progress
:text-inside="true"
:stroke-width="20"
:color="progressColor"
style="margin-top: 10px"
v-show="status.progress.isIndeterminate == false"
:percentage="status.progress.percent * 100"
:format="(p) => p.toFixed(2) + '%'"
text-color="white"
define-back-color="#CCCA"
></el-progress></el-col
><el-col :span="4">
<el-progress :text-inside="true" class="unknown-progress" :stroke-width="20" color="transparent"
:percentage="100" style="margin-right: 24px; margin-top: 4px" :show-text="true"
v-show="status.progress.isIndeterminate" text-color="black" :format="(p) => '进度未知'"
define-back-color="#CCCA"></el-progress>
<el-progress :text-inside="true" :stroke-width="20" :color="progressColor" style="margin-top: 10px"
v-show="status.progress.isIndeterminate == false" :percentage="status.progress.percent * 100"
:format="(p) => p.toFixed(2) + '%'" text-color="white"
define-back-color="#CCCA"></el-progress></el-col><el-col :span="4">
<el-popconfirm title="真的要取消任务吗?" @confirm="cancel">
<el-button
style="width: 75%; color: red"
type="text"
slot="reference"
size="big"
>取消</el-button
></el-popconfirm
></el-col
>
<el-button style="width: 75%; color: red" type="text" slot="reference"
size="big">取消</el-button></el-popconfirm></el-col>
</el-row>
</div>
</div>
<div v-else style="height: 60px">
<i
v-if="windowWidth > 988"
class="el-icon-loading"
style="float: left; font-size: 2em; margin-top: 12px"
></i>
<el-popconfirm
title="真的要取消任务吗?"
style="float: right; margin-right: 36px; margin-top: 8px"
@confirm="cancel"
>
<el-button type="text" style="color: red" slot="reference" size="big"
>取消</el-button
></el-popconfirm
>
<div
v-if="windowWidth > 988"
style="margin-left: 48px; text-align: center; padding-top: 16px"
>
<i v-if="windowWidth > 988" class="el-icon-loading" style="float: left; font-size: 2em; margin-top: 12px"></i>
<el-popconfirm title="真的要取消任务吗?" style="float: right; margin-right: 36px; margin-top: 8px" @confirm="cancel">
<el-button type="text" style="color: red" slot="reference" size="big">取消</el-button></el-popconfirm>
<div v-if="windowWidth > 988" style="margin-left: 48px; text-align: center; padding-top: 16px">
{{ status.lastOutput }}
</div>
<div v-else style="text-align: center; transform: translate(0, -4px)">
Expand All @@ -190,7 +93,7 @@
</div>
</div>
</template>
<script >
<script>
import Vue from "vue";
import Cookies from "js-cookie";
import * as net from "../net";
Expand Down Expand Up @@ -243,7 +146,7 @@ export default Vue.component("status-bar", {
);
},
updateSnapshot() {
if (this.status.isPaused) {
if (this.status == null || this.status.isPaused) {
return;
}
if (
Expand Down Expand Up @@ -311,9 +214,10 @@ export default Vue.component("status-bar", {
</style>

<style>
.unknown-progress > div > div > div {
.unknown-progress>div>div>div {
text-align: center;
}
.el-message-box {
width: 80% !important;
}
Expand Down
2 changes: 1 addition & 1 deletion SimpleFFmpegGUI.Web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
"node"
],
"paths": {
"@/*": [
Expand Down
33 changes: 1 addition & 32 deletions SimpleFFmpegGUI.WebAPI/PipeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@ public class PipeClient
public PipeClient(IConfiguration config)
{
pipeName = Program.PipeName ?? config.GetValue<string>("PipeName") ?? throw new Exception("不存在PipeName配置项");
hostName = config.GetValue<string>("HostName", null);
hostPath = config.GetValue<string>("HostPath", null);
try
{
EnsureHost();
}
catch (Exception ex)
{
}

ServiceProvider serviceProvider = new ServiceCollection()
.AddNamedPipeIpcClient<IPipeService>("m", pipeName: pipeName)
.BuildServiceProvider();
Expand Down Expand Up @@ -92,28 +84,5 @@ public async Task InvokeAsync(Expression<Func<IPipeService,Task>> exp)
throw (ex.InnerException ?? ex).InnerException ?? ex.InnerException ?? ex;
}
}

private void EnsureHost()
{
if (hostName != null)
{
var hosts = Process.GetProcessesByName(hostName);
if (hosts.Length == 0)
{
if (hostPath == null)
{
throw new Exception("服务提供进程未运行且没有配置路径");
}
Process p = new Process()
{
StartInfo = new ProcessStartInfo(hostPath, "-p " + pipeName)
{
UseShellExecute = true,
},
};
p.Start();
}
}
}
}
}
4 changes: 1 addition & 3 deletions SimpleFFmpegGUI.WebAPI/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
"PipeName": "ffpipe", //管道名
"InputFtpPort": 36734, //输入文件夹FTP端口
"OutputFtpPort": 36735, //输出文件夹FTP端口
//"HostName": "SimpleFFmpegGUI.Host",//设置该项时,若检测到Host未启动(找不到以此为名称的进程)则会自动启动
"HostPath": "D:\\临时\\SimpleFFmpegGUI\\SimpleFFmpegGUI.Host\\bin\\Debug\\netcoreapp3.1\\SimpleFFmpegGUI.Host.exe" //自动启动的Host位置
//"Token": "123456" //设置该值后,需要在Header中配置“Authorization”属性并确保值与该值相同才可以访问API
"Token": "123456" //设置该值后,需要在Header中配置“Authorization”属性并确保值与该值相同才可以访问API
}

0 comments on commit fb1d85c

Please sign in to comment.