Skip to content

Commit

Permalink
fix:任务百科 #9
Browse files Browse the repository at this point in the history
  • Loading branch information
fifthThirteen committed Jan 6, 2024
1 parent 8cbc190 commit 5a8961a
Show file tree
Hide file tree
Showing 19 changed files with 158 additions and 65 deletions.
2 changes: 1 addition & 1 deletion src/assets/css/cj/home.less
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@

.u-desc,
.u-rank {
margin-top: 2px;
margin-top: 3px;
font-size: 12px;
line-height: 16px;
}
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/item/home.less
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@

.u-desc,
.u-rank {
margin-top: 2px;
margin-top: 3px;
font-size: 12px;
line-height: 16px;
}
Expand Down
12 changes: 9 additions & 3 deletions src/assets/css/quest/home/quest-carousel.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.m-carousel {
.m-quest-carousel {
.m-carousel-content {
.flex;
flex-direction: column;
Expand All @@ -14,7 +14,7 @@

.u-desc,
.u-rank {
margin-top: 2px;
margin-top: 3px;
.fz(12px, 16px);
}

Expand Down Expand Up @@ -58,7 +58,8 @@
position: relative;
.db;
.w(100%);
padding: 5px;
padding-left: 15px;
padding-right: 10px;
box-sizing: border-box;
border: 1px solid #d7dae1;
border-left: none;
Expand All @@ -67,6 +68,11 @@
color: #3d454d;
overflow: hidden;
.h(66px);
.m-carousel-content {
.u-desc {
margin-top: 3px;
}
}

&:before {
content: "";
Expand Down
File renamed without changes.
26 changes: 19 additions & 7 deletions src/components/common/wiki-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
params: getViewParams(),
}"
>
<div class="u-icon">
<div v-if="type !== 'quest'" class="u-icon">
<img :src="iconUrl(item.IconID)" />
</div>
<div class="m-carousel-content">
<span class="u-title">
<div class="u-title">
<i class="el-icon-medal"></i>
<span v-text="` ${item.Name}`"></span>
</span>
<span class="u-desc">
<span v-text="` ${type === 'quest' ? item.name : item.Name}`"></span>
</div>
<div class="u-desc">
<i class="el-icon-mic"></i>
<span v-html="` ${parseDesc(item.Desc)}`"></span>
</span>
<span v-html="` ${type === 'quest' ? item.target : parseDesc(item.Desc)}`"></span>
</div>
</div>
</router-link>
</template>
Expand Down Expand Up @@ -54,6 +54,11 @@ export default {
item_id: this.item.id,
};
}
if (this.type === "quest") {
params = {
quest_id: this.item.id,
};
}
return params;
},
parseDesc(desc) {
Expand All @@ -67,3 +72,10 @@ export default {
},
};
</script>
<style lang="less">
.m-carousel-content {
.u-desc {
margin-top: 3px;
}
}
</style>
2 changes: 1 addition & 1 deletion src/components/quest/home/newest-post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<router-link
class="u-quest-name"
:to="{
name: 'single',
name: 'view',
params: {
quest_id: post.source_id,
post_id: post.id,
Expand Down
11 changes: 8 additions & 3 deletions src/components/quest/home/quest-carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
>
<el-row :gutter="20">
<el-col :md="8" v-for="(item, k) in items" :key="k">
<router-link
<WikiItem type="quest" :class="`u-item-${k}`" :item="item" />
<!-- <router-link
class="u-item"
:class="{
[`u-item-${k}`]: true,
'u-item-new': !hot,
}"
:to="{
name: 'single',
name: 'view',
params: { quest_id: item.id },
}"
>
Expand All @@ -38,7 +39,7 @@
<span v-text="`三十天 - ${views[item.id]['30days']}`"></span>
</span>
</div>
</router-link>
</router-link> -->
</el-col>
</el-row>
</el-carousel-item>
Expand All @@ -48,8 +49,12 @@

<script>
import { chunk } from "lodash";
import WikiItem from "@/components/common/wiki-item.vue";
export default {
name: "QuestCarousel",
components: {
WikiItem,
},
props: {
quests: {
type: Array,
Expand Down
2 changes: 1 addition & 1 deletion src/components/quest/nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
node-key="id"
@node-click="clickNode"
ref="tree"
:indent="42"
>
<template slot-scope="{ node, data }">
<span v-if="!node.isLeaf" class="el-tree-node__label">
Expand Down Expand Up @@ -64,7 +65,6 @@ export default {
const mapObj = res.data?.data || {};
const maps = [];
for (let key in mapObj) {
console.log(questType[key]);
if (questType[key]) {
maps.push({
id: key,
Expand Down
2 changes: 1 addition & 1 deletion src/components/quest/result/quest-card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default {
},
methods: {
go(id) {
this.$router.push({ name: "single", params: { quest_id: id } });
this.$router.push({ name: "view", params: { quest_id: id } });
},
schoolIcon,
moneyFormat(price) {
Expand Down
45 changes: 45 additions & 0 deletions src/components/quest/single/notice.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<template>
<div class="m-wiki-top">
<div class="m-wiki-top__header">
<h3 class="u-title"><i class="el-icon-news"></i>公告</h3>
</div>
<div class="m-wiki-top__content" v-html="data"></div>
</div>
</template>

<script>
import { getBreadcrumb } from "@/service/quest";
export default {
name: "WikiNotice",
data() {
return {
data: [],
};
},
mounted() {
this.loadData();
},
methods: {
loadData() {
try {
const data = sessionStorage.getItem("wiki_quest_ac");
if (data) {
this.data = JSON.parse(data);
} else {
getBreadcrumb("wiki_quest_ac").then((res) => {
this.data = res;
sessionStorage.setItem("wiki_quest_ac", JSON.stringify(this.data));
});
}
} catch (e) {
this.data = "";
}
},
},
};
</script>

<style lang="less">
@import "~@/assets/css/common/notice.less";
</style>
6 changes: 3 additions & 3 deletions src/components/quest/single/quest-chain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
「<router-link
class="u-chain-link"
:class="{ current: current == b.id }"
:to="{ name: 'single', params: { quest_id: b.id } }"
:to="{ name: 'view', params: { quest_id: b.id } }"
>{{ b.name }}</router-link
>」
</span>
Expand All @@ -23,7 +23,7 @@
「<router-link
class="u-chain-link"
:class="{ current: current == item.id }"
:to="{ name: 'single', params: { quest_id: item.id } }"
:to="{ name: 'view', params: { quest_id: item.id } }"
>{{ item.name }}</router-link
>」
</span>
Expand All @@ -33,7 +33,7 @@
<div class="branch" v-if="showBranch">
<el-divider><i class="el-icon-rank"></i> 任务分支</el-divider>
<span class="u-chain-name" v-for="item in display_data.branch" :key="item.id">
「<router-link class="u-chain-link" :to="{ name: 'single', params: { quest_id: item.id } }">{{
「<router-link class="u-chain-link" :to="{ name: 'view', params: { quest_id: item.id } }">{{
item.name
}}</router-link
>」
Expand Down
6 changes: 5 additions & 1 deletion src/components/quest/single/quest-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ export default {
<style lang="less">
.m-quest-dialog {
.u-dialog {
margin-bottom: 16px;
margin-bottom: 10px;
}
.u-dialog-content {
padding: 5px 0;
padding-left: 16px;
}
.u-dialog-name {
color: #8a6d3b;
}
.u-dialog-desc {
padding: 5px 0;
}
}
</style>
16 changes: 8 additions & 8 deletions src/router/quest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);

const VueRouterPush = VueRouter.prototype.push
const VueRouterPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(to) {
return VueRouterPush.call(this, to).catch(err => err)
}
return VueRouterPush.call(this, to).catch((err) => err);
};

const routes = [
{
Expand All @@ -28,7 +28,7 @@ const routes = [
component: () => import("@/views/quest/search-result.vue"),
},
{
name: "single",
name: "view",
path: "/view/:quest_id([_\\d]+)/:post_id(\\d+)?",
component: () => import("@/views/quest/single.vue"),
},
Expand All @@ -41,7 +41,7 @@ const routes = [
name: "newest",
path: "/newest",
component: () => import("@/views/quest/newest.vue"),
}
},
];

const router = new VueRouter({
Expand All @@ -51,10 +51,10 @@ const router = new VueRouter({
});

router.beforeEach((to, from, next) => {
if (to.fullPath.includes('/#')) {
next(to.fullPath.replace('/#', ''));
if (to.fullPath.includes("/#")) {
next(to.fullPath.replace("/#", ""));
}
next()
next();
});

export default router;
9 changes: 9 additions & 0 deletions src/service/quest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ export function getWaiting(params) {
export function getQuestMaps() {
return $.get(`/quest/maps`);
}

// 获取任务公告
export function getBreadcrumb(key = "wiki_quest_ac") {
return $cms()
.get(`/api/cms/breadcrumb/${key}`)
.then((res) => {
return res.data.data.html || "";
});
}
Loading

0 comments on commit 5a8961a

Please sign in to comment.