代码优化
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<a href="/me/videos" class="btn btn-primary">返回列表</a>
|
||||
</div>
|
||||
<div class="col-sm-6 py-md-5 flex flex-column justify-content">
|
||||
<form action="/me/videos/create" method="post">
|
||||
<form action="/me/videos/update" method="post">
|
||||
{{if .ID}}
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
@@ -26,8 +26,8 @@
|
||||
<input type="text" name="title" class="form-control" required id="title" value="{{.Title}}"
|
||||
aria-describedby="titleValid">
|
||||
</div>
|
||||
{{if .TitleErr}}
|
||||
<small id="titleValid" style="color: #f44336;" class="form-text">{{.TitleErr}}</small>
|
||||
{{if .TitleMsg}}
|
||||
<small id="titleValid" style="color: #f44336;" class="form-text">{{.TitleMsg}}</small>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -37,15 +37,16 @@
|
||||
</div>
|
||||
<input type="file" class="form-control" id="upload_images">
|
||||
<input type="button" class="btn btn-secondary" value="上传" onclick="uploadImage()" />
|
||||
<input type="hidden" id="images" name="images" required value="{{.Images}}" aria-describedby="imagesValid">
|
||||
<input type="hidden" id="images" name="images" required value="{{.Images}}"
|
||||
aria-describedby="imagesValid">
|
||||
</div>
|
||||
<div class="image-box" style="margin-top: 8px;">
|
||||
{{if .Images}}
|
||||
<img width="120px" src="{{.Images}}" />
|
||||
{{end}}
|
||||
</div>
|
||||
{{if .ImagesErr}}
|
||||
<small id="imagesValid" style="color: #f44336;" class="form-text">{{.ImagesErr}}</small>
|
||||
{{if .ImagesMsg}}
|
||||
<small id="imagesValid" style="color: #f44336;" class="form-text">{{.ImagesMsg}}</small>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -56,8 +57,8 @@
|
||||
<textarea class="form-control" id="description" name="description" required
|
||||
aria-describedby="descriptionValid" rows="3">{{.Description}}</textarea>
|
||||
</div>
|
||||
{{if .DescriptionErr}}
|
||||
<small id="descriptionValid" style="color: #f44336;" class="form-text">{{.DescriptionErr}}</small>
|
||||
{{if .DescriptionMsg}}
|
||||
<small id="descriptionValid" style="color: #f44336;" class="form-text">{{.DescriptionMsg}}</small>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -75,9 +76,30 @@
|
||||
{{end}}
|
||||
</div>
|
||||
<small id="upload_video_msg" style="color: #f44336;" class="form-text">
|
||||
{{.OriginLinkErr}}
|
||||
{{.OriginLinkMsg}}
|
||||
</small>
|
||||
</div>
|
||||
{{if eq .Status -1 200}}
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">状态</span>
|
||||
</div>
|
||||
<select id="status" class="form-control" name="status">
|
||||
{{if eq .Status 200}}
|
||||
<option value="200" selected>正常</option>
|
||||
{{else}}
|
||||
<option value="200">正常</option>
|
||||
{{end}}
|
||||
{{if eq .Status -1}}
|
||||
<option value="-1" selected>下架</option>
|
||||
{{else}}
|
||||
<option value="-1">下架</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
{{template "header" .}}
|
||||
<div class="container-fluid flex justify-content">
|
||||
<div class="main">
|
||||
<div class="title">
|
||||
<h3>视频转码</h3>
|
||||
</div>
|
||||
<div>
|
||||
<h5>{{.Video.Title}}</h5>
|
||||
<p>{{.Video.Description}}</p>
|
||||
<p><img src="{{.Video.Images}}" width="120px" /></p>
|
||||
{{if eq .Video.Status 0}}
|
||||
<p>该视频需要转码才能播放</p>
|
||||
<button id="transfer" class="btn btn-primary">转码</button>
|
||||
{{else if eq .Video.Status 1}}
|
||||
<p>转码中...</p>
|
||||
{{else if eq .Video.Status 2}}
|
||||
<p>转码失败, 请联系管理员</p>
|
||||
{{else if eq .Video.Status 200}}
|
||||
<p>恭喜您, 转码成功!</p>
|
||||
{{end}}
|
||||
<p id="msg"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{define "js"}}
|
||||
<script>
|
||||
$('#transfer').click(function () {
|
||||
let that = $(this)
|
||||
that.attr("disable", true).html('转码中...')
|
||||
$.ajax({
|
||||
url: '/transfer/{{.Video.ID}}',
|
||||
type: 'post',
|
||||
success: function (obj) {
|
||||
$('#msg').html(obj)
|
||||
},
|
||||
error: function (ex) {
|
||||
console.log(ex)
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
{{template "footer" .}}
|
||||
73
web/templates/video/videos.html.tmpl
Normal file
73
web/templates/video/videos.html.tmpl
Normal file
@@ -0,0 +1,73 @@
|
||||
{{template "header" .}}
|
||||
<div class="container-fluid flex justify-content">
|
||||
<div class="main">
|
||||
<div class="title">
|
||||
<h3>我的视频</h3>
|
||||
<a href="/me/videos/update" class="btn btn-primary">添加</a>
|
||||
</div>
|
||||
<div class="video-list">
|
||||
{{range .Videos}}
|
||||
<div class="card">
|
||||
<img src="{{.Images}}" class="card-img-top" alt="{{.Title}}">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{.Title}}</h5>
|
||||
<p class="card-text">{{.Description}}</p>
|
||||
|
||||
<a href="/me/videos/update/{{.ID}}" class="btn btn-warning">编辑</a>
|
||||
<button id="del" data-id="{{.ID}}" class="btn btn-danger">删除</button>
|
||||
|
||||
{{if eq .Status 0}}
|
||||
<button id="transfer" data-id="{{.ID}}" class="btn btn-info">转码</button>
|
||||
{{else if eq .Status 200}}
|
||||
<a href="/play/{{.ID}}" class="btn btn-primary">播放</a>
|
||||
{{end}}
|
||||
|
||||
<div>
|
||||
{{if eq .Status 1}}
|
||||
<p>转码中...</p>
|
||||
{{else if eq .Status 2}}
|
||||
<p>转码失败</p>
|
||||
{{end}}
|
||||
<p id="msg"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{define "js"}}
|
||||
<script>
|
||||
$('#transfer').click(function () {
|
||||
let that = $(this)
|
||||
that.attr("disable", true).html('转码中...')
|
||||
let id = that.attr("data-id")
|
||||
$.ajax({
|
||||
url: '/transfer/' + id,
|
||||
type: 'post',
|
||||
success: function (obj) {
|
||||
$('#msg').html(obj)
|
||||
},
|
||||
error: function (ex) {
|
||||
console.log(ex)
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#del').click(function () {
|
||||
let that = $(this)
|
||||
that.attr("disable", true).html('删除中...')
|
||||
let id = that.attr("data-id")
|
||||
$.ajax({
|
||||
url: '/transfer/' + id,
|
||||
type: 'post',
|
||||
success: function (obj) {
|
||||
$('#msg').html(obj)
|
||||
},
|
||||
error: function (ex) {
|
||||
console.log(ex)
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
{{template "footer" .}}
|
||||
Reference in New Issue
Block a user