代码优化
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
{{template "header" .}}
|
||||
<div class="container">
|
||||
<form id="form" enctype="multipart/form-data" action="/upload" method="POST">
|
||||
<label for="avatar">请选择文件:</label><br>
|
||||
<input type="file" id="file" name="file" /><br>
|
||||
<button class="button" type="submit">提交</button>
|
||||
</form>
|
||||
</div>
|
||||
{{template "footer" .}}
|
||||
@@ -12,8 +12,8 @@
|
||||
<input type="email" name="email" class="form-control" required id="email" value="{{.Email}}"
|
||||
aria-describedby="emailValid">
|
||||
</div>
|
||||
{{if .EmailErr}}
|
||||
<small id="emailValid" style="color: #f44336;" class="form-text">{{.EmailErr}}</small>
|
||||
{{if .EmailMsg}}
|
||||
<small id="emailValid" style="color: #f44336;" class="form-text">{{.EmailMsg}}</small>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -24,8 +24,8 @@
|
||||
<input type="password" name="password" class="form-control" required id="password" value="{{.Password}}"
|
||||
aria-describedby="passwordValid">
|
||||
</div>
|
||||
{{if .PasswordErr}}
|
||||
<small id="passwordValid" style="color: #f44336;" class="form-text">{{.PasswordErr}}</small>
|
||||
{{if .PasswordMsg}}
|
||||
<small id="passwordValid" style="color: #f44336;" class="form-text">{{.PasswordMsg}}</small>
|
||||
{{end}}
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">提交</button>
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<input type="email" name="email" class="form-control" required id="email" value="{{.Email}}"
|
||||
aria-describedby="emailValid">
|
||||
</div>
|
||||
{{if .EmailErr}}
|
||||
<small id="emailValid" style="color: #f44336;" class="form-text">{{.EmailErr}}</small>
|
||||
{{if .EmailMsg}}
|
||||
<small id="emailValid" style="color: #f44336;" class="form-text">{{.EmailMsg}}</small>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -24,8 +24,8 @@
|
||||
<input type="text" name="username" class="form-control" required id="username" value="{{.Username}}"
|
||||
aria-describedby="usernameValid">
|
||||
</div>
|
||||
{{if .UsernameErr}}
|
||||
<small id="usernameValid" style="color: #f44336;" class="form-text">{{.UsernameErr}}</small>
|
||||
{{if .UsernameMsg}}
|
||||
<small id="usernameValid" style="color: #f44336;" class="form-text">{{.UsernameMsg}}</small>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -36,8 +36,8 @@
|
||||
<input type="password" name="password" class="form-control" required id="password" value="{{.Password}}"
|
||||
aria-describedby="passwordValid">
|
||||
</div>
|
||||
{{if .PasswordErr}}
|
||||
<small id="passwordValid" style="color: #f44336;" class="form-text">{{.PasswordErr}}</small>
|
||||
{{if .PasswordMsg}}
|
||||
<small id="passwordValid" style="color: #f44336;" class="form-text">{{.PasswordMsg}}</small>
|
||||
{{end}}
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">提交</button>
|
||||
|
||||
@@ -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" .}}
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="main">
|
||||
<div class="title">
|
||||
<h3>我的视频</h3>
|
||||
<a href="/me/videos/create" class="btn btn-primary">添加</a>
|
||||
<a href="/me/videos/update" class="btn btn-primary">添加</a>
|
||||
</div>
|
||||
<div class="video-list">
|
||||
{{range .Videos}}
|
||||
@@ -13,7 +13,7 @@
|
||||
<h5 class="card-title">{{.Title}}</h5>
|
||||
<p class="card-text">{{.Description}}</p>
|
||||
|
||||
<a href="/me/videos/create/{{.ID}}" class="btn btn-warning">编辑</a>
|
||||
<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}}
|
||||
Reference in New Issue
Block a user