Skip to content

Commit

Permalink
feat: 实装快捷推送
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaviilee committed May 6, 2024
1 parent efee71e commit b78a632
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 10 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@jx3box/jx3box-comment-ui": "^1.8.7",
"@jx3box/jx3box-common": "^8.2.11",
"@jx3box/jx3box-common-ui": "^8.3.2",
"@jx3box/jx3box-common-ui": "^8.3.4",
"@jx3box/jx3box-data": "^3.5.8",
"@jx3box/jx3box-editor": "^2.1.9",
"@jx3box/jx3box-talent": "^1.2.7",
Expand All @@ -24,6 +24,7 @@
"element-ui": "^2.13.0",
"localforage": "^1.7.3",
"lodash": "^4.17.15",
"mitt": "^3.0.1",
"qs": "^6.11.0",
"vue": "^2.6.11",
"vue-clipboard2": "^0.3.3",
Expand Down
26 changes: 26 additions & 0 deletions src/assets/css/list.less
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,26 @@
font-weight: normal;
.lh(2);
font-weight: 400;
.pr;

.u-push {
.pa;
.rt(0);
.flex;
align-items: center;
gap: 2px;
}
.u-push__time {
.fz(12px);
color: #999;

&.is-recent {
color: #00d24b;
}
}
.u-push__btn {
// padding: 8px 14px;
}
}

// 角标
Expand Down Expand Up @@ -407,5 +427,11 @@
.u-desc {
.none;
}

.u-post {
.u-push {
.none;
}
}
}
}
29 changes: 28 additions & 1 deletion src/components/list/list_item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<span class="u-marks" v-if="item.mark && item.mark.length">
<i v-for="mark in item.mark" class="u-mark" :key="mark">{{ mark | showMark }}</i>
</span>

<span class="u-push" v-if="isEditor">
<time v-if="showPushDate" class="u-push__time" :class="{'is-recent': isRecent()}">{{ pushDate }}已推送</time>
<el-button class="u-push__btn" size="mini" type="primary" @click="onPush">推送</el-button>
</span>
</h2>

<!-- 字段 -->
Expand Down Expand Up @@ -95,6 +100,10 @@ import { __ossMirror, __imgPath } from "@jx3box/jx3box-common/data/jx3box";
import { cms as mark_map } from "@jx3box/jx3box-common/data/mark.json";
import { showDate } from "@jx3box/jx3box-common/js/moment.js";
import xfmap from "@jx3box/jx3box-data/data/xf/xf.json";
import User from "@jx3box/jx3box-common/js/user";
import dayjs from "dayjs";
import bus from "@/utils/bus";
export default {
name: "ListItem",
props: ["item", "order", "caller"],
Expand All @@ -119,8 +128,17 @@ export default {
client() {
return this.item?.client;
},
isEditor() {
return User.isEditor();
},
pushDate({item}) {
const date = item?.log?.push_at || item?.banner?.created_at
return showDate(new Date(date));
},
showPushDate() {
return Boolean(this.item?.log || this.item?.banner);
},
},
watch: {},
methods: {
getBanner: function (val, subtype) {
if (val) {
Expand All @@ -137,6 +155,15 @@ export default {
const prefix = this.client === 'std' ? 'www' : 'origin'
return`${prefix}:/${appKey}/` + val;
},
showDate,
// 是否为30天内
isRecent: function () {
const date = this.item?.log?.push_at || this.item?.banner?.created_at
return dayjs().diff(dayjs(date), "day") < 30;
},
onPush() {
bus.emit("design-task", this.item);
},
},
filters: {
authorLink,
Expand Down
7 changes: 4 additions & 3 deletions src/layout/SingleLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
:adminMarks="{}"
>
<template #op-prepend>
<AdminDirectMessage :user-id="user_id" :sourceId="String(post.ID)" :sourceType="post.post_type"></AdminDirectMessage>
<!-- <AdminDirectMessage :user-id="user_id" :sourceId="String(post.ID)" :sourceType="post.post_type"></AdminDirectMessage> -->
<AdminDrop :post="post" :user-id="user_id" />
</template>
<template #title>
<span>
Expand All @@ -37,7 +38,7 @@
import Nav from "@/components/single/single_nav.vue";
import Side from "@/components/single/single_side.vue";
import { getAppIcon, getAppID } from "@jx3box/jx3box-common/js/utils";
import AdminDirectMessage from "@jx3box/jx3box-common-ui/src/bread/AdminDirectMessage.vue"
import AdminDrop from "@jx3box/jx3box-common-ui/src/bread/AdminDrop.vue"
export default {
name: "SingleLayout",
props: {
Expand Down Expand Up @@ -66,7 +67,7 @@ export default {
components: {
Nav,
Side,
AdminDirectMessage
AdminDrop
},
};
</script>
Expand Down
9 changes: 9 additions & 0 deletions src/service/design.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { $cms } from "@jx3box/jx3box-common/js/https";

export const getDesignLog = (params) => {
return $cms().get(`/api/cms/design/task/log`, { params });
};

export const getBannerList = (params) => {
return $cms().get(`/api/cms/news/v2`, { params });
}
5 changes: 5 additions & 0 deletions src/utils/bus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import mitt from "mitt";

const bus = mitt();

export default bus;
45 changes: 40 additions & 5 deletions src/views/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<!-- 列表 -->
<div class="m-archive-list" v-if="data && data.length">
<ul class="u-list">
<list-item v-for="(item, i) in data" :key="i + item" :item="item" :order="order" caller="bps_index_click" />
<list-item v-for="(item) in data" :key="item.ID" :item="item" :order="order" caller="bps_index_click" />
</ul>
</div>

Expand Down Expand Up @@ -68,18 +68,24 @@
@current-change="changePage"
></el-pagination>
</div>

<design-task v-model="showDesignTask" :post="currentPost"></design-task>
</ListLayout>
</template>
<script>
import ListLayout from "@/layout/ListLayout.vue";
import listItem from "@/components/list/list_item.vue";
// import recTable from "@/components/list/rec_table.vue";
import User from "@jx3box/jx3box-common/js/user";
import bus from "@/utils/bus";
import { appKey } from "@/../setting.json";
import { publishLink } from "@jx3box/jx3box-common/js/utils";
import { getPosts } from "@/service/post";
import post_topics from "@jx3box/jx3box-common/data/post_topics.json";
import { reportNow } from "@jx3box/jx3box-common/js/reporter";
import {getDesignLog,getBannerList} from "@/service/design";
import DesignTask from "@jx3box/jx3box-common-ui/src/bread/DesignTask.vue";
export default {
name: "Index",
props: [],
Expand Down Expand Up @@ -107,6 +113,9 @@ export default {
"PVE": "PVE",
"PVP": "PVP",
},
currentPost: null,
showDesignTask: false,
};
},
computed: {
Expand Down Expand Up @@ -150,6 +159,12 @@ export default {
}
return [...new Set([...post_topics['bps_pve'], ...post_topics['bps_pvp']])]
},
isEditor: function () {
return User.isEditor();
},
isPhone: function () {
return window.innerWidth < 768;
},
},
methods: {
reporterLink: function (val) {
Expand Down Expand Up @@ -200,7 +215,7 @@ export default {
this.loading = true;
return getPosts(query)
.then((res) => {
.then(async (res) => {
if (appendMode) {
this.data = this.data.concat(res.data?.data?.list);
} else {
Expand All @@ -214,7 +229,21 @@ export default {
data: {
aggregate: res.data?.data?.list.map(item => this.reporterLink(item.ID)),
}
})
});
if (this.isEditor && !this.isPhone) {
const ids = this.data.map(item => item.ID);
const logs = await getDesignLog({ source_type: 'bps', ids: ids.join(',') }).then(res => res.data.data);
const banners = await getBannerList({ source_type: 'bps', source_ids: ids.join(','), limit: ids.length, page: 1 }).then(res => res.data.data.list || []);
this.data = this.data.map(item => {
const log = logs.find(log => log.source_id == item.ID) || null;
const banner = banners.find(banner => banner.source_id == item.ID) || null;
this.$set(item, 'log', log);
this.$set(item, 'banner', banner);
return item;
});
}
})
.finally(() => {
this.loading = false;
Expand Down Expand Up @@ -288,11 +317,17 @@ export default {
},
},
},
mounted: function () {},
mounted: function () {
bus.on("design-task", (post) => {
this.currentPost = post;
this.showDesignTask = true;
});
},
components: {
listItem,
ListLayout,
// recTable
// recTable,
DesignTask,
},
};
</script>
Expand Down

0 comments on commit b78a632

Please sign in to comment.