Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
SunWuyuan committed Aug 30, 2024
1 parent fbf1fb1 commit b9edd52
Show file tree
Hide file tree
Showing 12 changed files with 1,203 additions and 67 deletions.
2 changes: 1 addition & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"dom",
"dom.iterable",
"scripthost"
]
],
}
}
12 changes: 9 additions & 3 deletions src/components/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@

<v-list-item rounded="xl" prepend-icon="mdi-home" title="首页" value="home" to="/"></v-list-item>
<v-list-item rounded="xl" prepend-icon="mdi-xml" title="项目" value="projects" to="/projects"></v-list-item>
<v-list-item rounded="xl" prepend-icon="mdi-plus" title="新作品" value="projects" @click="$refs.NewProjectDialog.show()" v-if="islogin == true"></v-list-item>
<v-list-item rounded="xl" prepend-icon="mdi-plus" title="新作品" value="projects"
@click="$refs.NewProjectDialog.show()" v-if="islogin == true"></v-list-item>
<div v-if="islogin == true"> <v-list-subheader>镜像!</v-list-subheader>

<v-list-item rounded="xl" prepend-icon="mdi-home" title="探索" value="home" to="/proxy"></v-list-item>
<v-list-item rounded="xl" prepend-icon="mdi-xml" title="搜索" value="projects" to="/proxy/search"></v-list-item>
</div>
<div v-if="islogin == true">
<v-list-subheader>账户</v-list-subheader>

Expand All @@ -52,7 +58,7 @@

</v-list>
</v-navigation-drawer>
<NewProjectDialog ref="NewProjectDialog"/>
<NewProjectDialog ref="NewProjectDialog" />
</template>

<script>
Expand Down Expand Up @@ -80,7 +86,7 @@ export default {
console.log(111)
if (this.clicklogout == 1) {
this.$router.push('/account/logout')
this.clicklogout =0
this.clicklogout = 0
this.logoutbutton = '退出'
} else {
Expand Down
107 changes: 107 additions & 0 deletions src/components/proxy/ProjectCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<template>
<v-card>

<v-card flat :to="'/projects/' + info.id">

<v-img v-if="info.type == 'scratch'" gradient="to bottom, rgba(0,0,0,.1), rgba(0,0,0,.5)" class="align-end"
color="surface-variant" :src="'https://s4-1.wuyuan.1r.ink/scratch_slt/' + info.id"
lazy-src="../assets/scratchdefault.png">
<template v-slot:placeholder>
<div class="d-flex align-center justify-center fill-height">
<v-progress-circular color="grey-lighten-4" indeterminate></v-progress-circular>
</div>
</template>
<v-card-title class="text-white">
{{ info.title }}</v-card-title>
</v-img>

</v-card>
<v-card flat :to="'/projects/' + info.id">

<v-card-item v-if="info.type == 'python'">

<v-card-title class="text-white">
{{ info.title }} </v-card-title>
<v-card-subtitle class="text-white">
{{ info.tags }}
{{ info.description }} </v-card-subtitle>

</v-card-item> <v-card-item v-if="info.type == 'text'">

<v-card-title class="text-white">
{{ info.title }} </v-card-title>
<v-card-subtitle class="text-white">
{{ info.tags }}
{{ info.description }} </v-card-subtitle>

</v-card-item>
</v-card>

<v-card flat :to="'/user/' + info.authorid">


<v-card-item>
<template v-slot:prepend>
<v-avatar size="32">
<v-img :alt="user.display_name" :src="'https://s4-1.wuyuan.1r.ink/user/' + user.images"></v-img>
</v-avatar>
</template>
<v-card-title class="text-white">
{{ user.display_name }} </v-card-title>
<v-card-subtitle class="text-white">
{{ user.motto }} </v-card-subtitle>

</v-card-item></v-card>

<v-card-actions v-if="actions">
<div v-for="action in actions" :key="action.name">
<v-btn @click="action.function(info.id, info)">{{ action.name }}</v-btn>
</div>
</v-card-actions>
</v-card>
</template>
<script>
export default {
data() {
return {
tags: [],
}
},
props:
{
info: {
type: Object,
default: ''
},
user: {
type: Object,
default: '{ "id": 1, "username": "yxhyh", "display_name": "已销号用户", "motto": "已销号用户", "images": "0ec4beb623e3bcdbe0f207c9804f0bc2" }'
},
actions: {
type: Array,
required: false,
}
},
watch: {
info: {
immediate: true,
handler(newVal) {
if (newVal.tags) {
this.tags = newVal.tags.split(',')
} else {
this.tags = []
}
}
}
},
methods: {
callFunction(action) {
action(this.info.id, this.info);
}
}
}
</script>
133 changes: 133 additions & 0 deletions src/components/proxy/Projects.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<template><v-progress-linear :active="ProjectsLoading" height="4" indeterminate></v-progress-linear>
<div class="mb-2" v-if="showinfo == true || showinfo == 'true'">
<v-chip><v-icon icon="mdi-counter" start></v-icon>共{{
this.projectscount
}}个作品
</v-chip>
<v-chip><v-icon icon="mdi-clock" start></v-icon>本页加载用时{{
Math.abs(usetime / 1000)
}}秒
</v-chip>
</div>
<ProjectsCards :projects="projects" :actions='actions'></ProjectsCards>

<v-pagination v-model="curPage" :length="totalPage" rounded="circle" :v-model="curPage"
@update:model-value="onPageChange(curPage)" @input="onPageChange(curPage)"></v-pagination>
</template>

<script>
import request from "../../axios/axios";
import ProjectsCards from "./ProjectsCards.vue";
export default {
components: { ProjectsCards },
props: {
authorid: {
type: String,
default: "",
},
title: {
type: String,
default: "",
},
type: {
type: String,
default: "",
},
description: {
type: String,
default: "",
},
order: {
type: String,
default: "view_down",
},
source: {
type: String,
default: "",
},
state: {
type: String,
default: "",
},
tag: {
type: String,
default: '',
},
showinfo: {
type: String,
default: false,
},
actions: {
type: Array,
required: false
}
},
data() {
return {
ProjectsLoading: false,
projects: [],
curPage: 1,
totalPage: 1,
limit: 8,
typeitems: { all: "", scratch: "scratch", python: "python" },
usetime: 0,
projectscount: 0,
search: {
title: "",
type: "",
description: "",
source: "",
order: { name: "观看量升序", type: "view_up" },
authorid: "",
type: { name: "所有", type: "" },
typeitems: [
{ name: "所有", type: "" },
{ name: "Scratch", type: "scratch" },
{ name: "Python", type: "python" },
],
orderitems: [
{ name: "观看量升序", type: "view_up" },
{ name: "观看量降序", type: "view_down" },
{ name: "时间升序", type: "time_up" },
{ name: "时间降序", type: "time_down" },
{ name: "序号升序", type: "id_up" },
{ name: "序号降序", type: "id_down" },
],
state: ''
},
};
},
async created() {
await this.getprojects();
},
methods: {
async getprojects() {
this.onPageChange(1);
},
async onPageChange(page) {
this.usetime = Date.now();
this.ProjectsLoading = true
this.projects = await request({
url: `/proxy/explore/projects?
&search_source=${this.source
}&search_description=${this.description}&search_orderby=${this.order
}&search_state=${this.state}&search_tag=${this.tag}&curr=${page}&limit=${this.limit}`,
method: "get",
});
this.totalPage = Math.ceil(
this.projects.totalCount[0].totalCount / this.limit
);
this.projectscount = this.projects.totalCount[0].totalCount;
this.curPage = page;
console.log(this.projects);
console.log(this.totalPage);
this.ProjectsLoading = false
this.usetime = Date.now() - this.usetime;
},
},
};
</script>
27 changes: 27 additions & 0 deletions src/components/proxy/ProjectsCards.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<v-row>
<v-col cols=" 12" md="3" v-for="info in projects.data" :key="info">
<ProjectCard :info="info" :user="projects.user.find((u) => u.id === info.authorid)" :actions="actions"></ProjectCard>
</v-col></v-row>
</template>

<script>
import ProjectCard from "./ProjectCard.vue";
export default {
components: { ProjectCard },
props: {
projects: {
type: Object,
default: 'text',
},
actions:{
type: Array,
required: false,
}
},
};
</script>
Loading

0 comments on commit b9edd52

Please sign in to comment.