TODO: 完成自动化编译. 后台服务器编译
This commit is contained in:
parent
df661cb3c5
commit
5383e2fa60
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -21,5 +21,4 @@ pnpm-debug.log*
|
||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
movie
|
|
||||||
*.mp4
|
*.mp4
|
||||||
|
|
1
server/.gitignore
vendored
1
server/.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
server
|
server
|
||||||
|
movie
|
||||||
|
|
|
@ -2,4 +2,4 @@ module server
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require github.com/gin-gonic/gin v1.6.3 // indirect
|
require github.com/gin-gonic/gin v1.6.3
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
|
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
|
||||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||||
|
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
|
||||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||||
|
@ -24,9 +26,11 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OH
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||||
|
@ -36,6 +40,7 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtD
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
|
|
52
server/handler.go
Normal file
52
server/handler.go
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MovieList 电影列表
|
||||||
|
func MovieList(c *gin.Context) {
|
||||||
|
|
||||||
|
data := gin.H{}
|
||||||
|
response := gin.H{
|
||||||
|
"code": http.StatusInternalServerError,
|
||||||
|
"message": "",
|
||||||
|
"data": data,
|
||||||
|
}
|
||||||
|
defer c.JSON(0, response)
|
||||||
|
|
||||||
|
var page int = 0
|
||||||
|
spage := c.Query("page")
|
||||||
|
if spage != "" {
|
||||||
|
p, err := strconv.Atoi(spage)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
page = p - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
var limit int = 10
|
||||||
|
slimit := c.Query("limit")
|
||||||
|
if slimit != "" {
|
||||||
|
l, err := strconv.Atoi(slimit)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
limit = l
|
||||||
|
}
|
||||||
|
|
||||||
|
start := page * limit
|
||||||
|
var end int = start + limit
|
||||||
|
if end > len(movies) {
|
||||||
|
end = len(movies)
|
||||||
|
}
|
||||||
|
|
||||||
|
response["code"] = http.StatusOK
|
||||||
|
|
||||||
|
data["items"] = movies[start:end]
|
||||||
|
data["total"] = len(movies)
|
||||||
|
}
|
|
@ -5,10 +5,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
@ -58,7 +56,7 @@ func initMovie() {
|
||||||
}
|
}
|
||||||
|
|
||||||
filepath.Walk("./movie", func(path string, info fs.FileInfo, err error) error {
|
filepath.Walk("./movie", func(path string, info fs.FileInfo, err error) error {
|
||||||
if !info.IsDir() && filepath.Ext(info.Name()) != "webp" {
|
if !info.IsDir() && filepath.Ext(info.Name()) != ".webp" {
|
||||||
base := info.Name()
|
base := info.Name()
|
||||||
log.Println(path, info.Name())
|
log.Println(path, info.Name())
|
||||||
movies = append(movies, Movie{
|
movies = append(movies, Movie{
|
||||||
|
@ -81,35 +79,7 @@ func main() {
|
||||||
eg.Static("/res", "movie/")
|
eg.Static("/res", "movie/")
|
||||||
|
|
||||||
movie := eg.Group("movie")
|
movie := eg.Group("movie")
|
||||||
movie.GET("/", func(c *gin.Context) {
|
movie.GET("/", MovieList)
|
||||||
var page int = 0
|
|
||||||
spage := c.Query("page")
|
|
||||||
if spage != "" {
|
|
||||||
p, err := strconv.Atoi(spage)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
page = p - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
var limit int = 10
|
|
||||||
slimit := c.Query("limit")
|
|
||||||
if slimit != "" {
|
|
||||||
l, err := strconv.Atoi(slimit)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
limit = l
|
|
||||||
}
|
|
||||||
|
|
||||||
start := page * limit
|
|
||||||
log.Println(limit)
|
|
||||||
c.JSON(0, gin.H{
|
|
||||||
"code": http.StatusOK,
|
|
||||||
"message": "",
|
|
||||||
"data": movies[start : start+limit],
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
eg.Run(":4444")
|
eg.Run(":4444")
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var Host = "http://localhost:4444"
|
var Host = "http://localhost:4444"
|
||||||
|
|
||||||
|
|
||||||
export default ({
|
export default ({
|
||||||
Host: Host
|
Host: Host,
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<v-container>
|
<v-container>
|
||||||
<div>
|
<div>
|
||||||
<v-row >
|
<v-row >
|
||||||
<v-col v-for="item in list" :key="item.filename">
|
<v-col cols="3" class="pa-2 justify-space-between" v-for="item in pagination.movies" :key="item.filename">
|
||||||
<v-card
|
<v-card
|
||||||
class="d-flex align-start flex-column ma-2"
|
|
||||||
|
class="d-flex flex-column"
|
||||||
width="160"
|
width="160"
|
||||||
height="200"
|
height="200"
|
||||||
link
|
link
|
||||||
:href='Host+"/res/"+item.filename'
|
:href="Host+'/res/'+item.filename"
|
||||||
>
|
>
|
||||||
<v-img height="120" :src='Host+"/res/" + item.image' :ref='Host+"/res/"+item.filename'></v-img>
|
<v-img height="120" :src="Host+'/res/'+item.image"></v-img>
|
||||||
<v-card-text>{{ item.filename }}</v-card-text>
|
<v-card-text>{{ item.filename }}</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
@ -20,36 +21,55 @@
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
|
|
||||||
<div class="text-center d-flex align-bottom flex-column">
|
<div class="text-center d-flex align-bottom flex-column">
|
||||||
<v-pagination v-model="page" :length="100" circle></v-pagination>
|
<v-pagination
|
||||||
|
v-model="pagination.page"
|
||||||
|
:length="pagination.length"
|
||||||
|
:total-visible="8"
|
||||||
|
@input="nextpage"
|
||||||
|
circle
|
||||||
|
></v-pagination>
|
||||||
</div>
|
</div>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import config from "../Config";
|
import config from "../Config";
|
||||||
|
|
||||||
var info = [];
|
var pagination = {
|
||||||
|
movies: [],
|
||||||
|
page: 1,
|
||||||
|
total: 1,
|
||||||
|
length: 1,
|
||||||
|
};
|
||||||
|
|
||||||
axios.get(config.Host + "/movie/?page=1&limit=10").then((response) => {
|
var limit = 8;
|
||||||
if (response.status === 200) {
|
|
||||||
for (var o of response.data["data"]) {
|
var nextpage = (page) => {
|
||||||
info.push(o);
|
axios
|
||||||
console.log(o);
|
.get(config.Host + "/movie/?page=" + page + "&limit=" + limit)
|
||||||
}
|
.then((response) => {
|
||||||
// console.log(response.data["data"])
|
|
||||||
}
|
if (response.status === 200) {
|
||||||
});
|
var data = response.data.data;
|
||||||
|
pagination.movies = data.items;
|
||||||
|
pagination.page = page;
|
||||||
|
pagination.total = data.total;
|
||||||
|
pagination.length = Math.ceil(data.total / limit)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
nextpage(pagination.page);
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Main",
|
|
||||||
|
|
||||||
|
name: "Main",
|
||||||
data: () => ({
|
data: () => ({
|
||||||
src: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",
|
src: "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",
|
||||||
page: 1,
|
pagination: pagination,
|
||||||
list: info,
|
|
||||||
Host: config.Host,
|
Host: config.Host,
|
||||||
|
nextpage: nextpage,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -2,7 +2,8 @@ import Vue from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import vuetify from './plugins/vuetify';
|
import vuetify from './plugins/vuetify';
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false;
|
||||||
|
Vue.config.devtools = true;
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
vuetify,
|
vuetify,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user