perf:发布权限处理
This commit is contained in:
@@ -1,49 +1,46 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col
|
||||
>
|
||||
<el-card :body-style="{ padding: '0px' }" shadow="never">
|
||||
<img
|
||||
src=""
|
||||
class="image"
|
||||
/>
|
||||
<div style="padding: 14px">
|
||||
<span>{{props.name}}</span>
|
||||
<div class="bottom">
|
||||
<time class="remarks">{{ props.introduction }}</time>
|
||||
<RouterLink :to="`/discuss/${props.id}`"> <el-button text class="button" type="primary">进入<el-icon><CaretRight /></el-icon></el-button> </RouterLink>
|
||||
</div>
|
||||
<el-row>
|
||||
<el-col>
|
||||
<el-card :body-style="{ padding: '0px' }" shadow="never">
|
||||
<img src="" class="image" />
|
||||
<div style="padding: 14px">
|
||||
<span>{{ props.name }}</span>
|
||||
<div class="bottom">
|
||||
<time class="remarks">{{ props.introduction }}</time>
|
||||
<RouterLink :to="`/discuss/${props.id}/${props.isPublish}`">
|
||||
<el-button text class="button" type="primary"
|
||||
>进入<el-icon><CaretRight /></el-icon
|
||||
></el-button>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted } from 'vue';
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
const props = defineProps(['name','introduction','id'])
|
||||
<script setup>
|
||||
import { onMounted } from "vue";
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.remarks {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
margin-top: 13px;
|
||||
line-height: 12px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
const props = defineProps(["name", "introduction", "id", "isPublish"]);
|
||||
</script>
|
||||
|
||||
|
||||
.image {
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.remarks {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
margin-top: 13px;
|
||||
line-height: 12px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.image {
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -117,7 +117,7 @@ export default function useAuths(opt) {
|
||||
setToken(token);
|
||||
try {
|
||||
// 存储用户信息
|
||||
await getUserInfo(); // 用户信息
|
||||
await useUserStore().getInfo(); // 用户信息
|
||||
// 登录成功后 路由跳转
|
||||
// 如果有记录当前跳转页面
|
||||
const currentPath = Session.get("currentPath");
|
||||
|
||||
@@ -54,7 +54,7 @@ const router = createRouter({
|
||||
},
|
||||
{
|
||||
name: "discuss",
|
||||
path: "/discuss/:plateId?",
|
||||
path: "/discuss/:plateId?/:isPublish?",
|
||||
component: () => import("../views/Discuss.vue"),
|
||||
meta: {
|
||||
title: "板块",
|
||||
|
||||
@@ -121,5 +121,9 @@ const useUserStore = defineStore("user", {
|
||||
this.id = "";
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
key: "userInfo",
|
||||
storage: window.sessionStorage,
|
||||
},
|
||||
});
|
||||
export default useUserStore;
|
||||
|
||||
@@ -20,7 +20,10 @@
|
||||
"
|
||||
>查询</el-button
|
||||
>
|
||||
<el-button @click="enterEditArticle" type="primary"
|
||||
<el-button
|
||||
@click="enterEditArticle"
|
||||
type="primary"
|
||||
:class="[!isEditArticle ? 'el-button--disabled' : '']"
|
||||
>发布主题</el-button
|
||||
>
|
||||
<el-dropdown>
|
||||
@@ -99,9 +102,10 @@
|
||||
<script setup>
|
||||
import DisscussCard from "@/components/DisscussCard.vue";
|
||||
import { getList, getTopList } from "@/apis/discussApi.js";
|
||||
import { ref, reactive, watch } from "vue";
|
||||
import { ref, reactive, watch, computed } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import BottomInfo from "@/components/BottomInfo.vue";
|
||||
import useUserStore from "@/stores/user";
|
||||
|
||||
//数据定义
|
||||
const route = useRoute();
|
||||
@@ -155,23 +159,31 @@ const loadDiscussList = async () => {
|
||||
};
|
||||
|
||||
//进入添加主题页面
|
||||
const isEditArticle = computed(
|
||||
() =>
|
||||
useUserStore().hasPermissions &&
|
||||
!(route.params.isPublish === "false" ? false : true)
|
||||
);
|
||||
const enterEditArticle = () => {
|
||||
//跳转路由
|
||||
var routerPer = {
|
||||
path: "/editArt",
|
||||
query: {
|
||||
operType: "create",
|
||||
artType: "discuss",
|
||||
plateId: route.params.plateId,
|
||||
},
|
||||
};
|
||||
router.push(routerPer);
|
||||
if (isEditArticle.value) {
|
||||
//跳转路由
|
||||
var routerPer = {
|
||||
path: "/editArt",
|
||||
query: {
|
||||
operType: "create",
|
||||
artType: "discuss",
|
||||
plateId: route.params.plateId,
|
||||
},
|
||||
};
|
||||
router.push(routerPer);
|
||||
} else {
|
||||
ElMessage.warning("暂无发布权限!");
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => route.query.q,
|
||||
async (val) => {
|
||||
console.log(val);
|
||||
if (val) {
|
||||
query.title = val ?? "";
|
||||
}
|
||||
@@ -245,4 +257,9 @@ watch(
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
}
|
||||
/* 禁用状态下的样式 */
|
||||
.el-button.el-button--disabled {
|
||||
opacity: 0.6;
|
||||
pointer-events: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
:name="i.name"
|
||||
:introduction="i.introduction"
|
||||
:id="i.id"
|
||||
:isPublish="i.isDisableCreateDiscuss"
|
||||
/>
|
||||
</el-col>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user