Merge branch 'abp' of https://gitee.com/ccnetcore/Yi into abp
This commit is contained in:
@@ -15,14 +15,19 @@
|
||||
</div>
|
||||
|
||||
<el-divider />
|
||||
<div v-hasPer="['bbs:comment:add']">
|
||||
<div>
|
||||
<el-input
|
||||
:disabled="!isAddComment"
|
||||
v-model="topContent"
|
||||
placeholder="发表一个友善的评论吧~"
|
||||
:rows="5"
|
||||
type="textarea"
|
||||
></el-input>
|
||||
<el-button @click="addTopComment" type="primary" class="btn-top-comment"
|
||||
<el-button
|
||||
@click="addTopComment"
|
||||
type="primary"
|
||||
class="btn-top-comment"
|
||||
:disabled="!isAddComment"
|
||||
>发表评论</el-button
|
||||
>
|
||||
<el-button class="btn-top-comment">其他</el-button>
|
||||
@@ -134,10 +139,23 @@
|
||||
/>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { onMounted, reactive, ref, defineProps } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { getListByDiscussId, add, del } from "@/apis/commentApi.js";
|
||||
import AvatarInfo from "./AvatarInfo.vue";
|
||||
import { getPermission } from "@/utils/auth";
|
||||
|
||||
const props = defineProps({
|
||||
isComment: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
const { isHasPermission: isAddComment } = getPermission(
|
||||
"bbs:comment:add",
|
||||
props.isComment
|
||||
);
|
||||
|
||||
//数据定义
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -75,7 +75,7 @@ import useConfigStore from "@/stores/config";
|
||||
import useAuths from "@/hooks/useAuths";
|
||||
import { Session } from "@/utils/storage";
|
||||
|
||||
const { getToken } = useAuths();
|
||||
const { getToken, clearStorage } = useAuths();
|
||||
const configStore = useConfigStore();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -108,6 +108,7 @@ const enterProfile = () => {
|
||||
router.push("/profile");
|
||||
};
|
||||
const toLogin = () => {
|
||||
clearStorage();
|
||||
Session.set("currentPath", route.path);
|
||||
router.push("/login");
|
||||
};
|
||||
|
||||
@@ -14,7 +14,6 @@ const useUserStore = defineStore("user", {
|
||||
icon: null,
|
||||
roles: [],
|
||||
permissions: [],
|
||||
hasPermissions: false,
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
@@ -48,17 +47,10 @@ const useUserStore = defineStore("user", {
|
||||
user.icon == "" || user.icon == null
|
||||
? "/favicon.ico"
|
||||
: import.meta.env.VITE_APP_BASEAPI + "/file/" + user.icon;
|
||||
const all_permission = "*:*:*";
|
||||
if (res.roleCodes && res.roleCodes.length > 0) {
|
||||
// 验证返回的roles是否是一个非空数组
|
||||
this.roles = res.roleCodes;
|
||||
this.permissions = res.permissionCodes;
|
||||
this.hasPermissions = res.permissionCodes.some((permission) => {
|
||||
return (
|
||||
all_permission === permission ||
|
||||
permissionFlag.includes(permission)
|
||||
);
|
||||
});
|
||||
// this.roles = ["admin"];
|
||||
// this.permissions=["*:*:*"]
|
||||
} else {
|
||||
|
||||
@@ -1,13 +1,28 @@
|
||||
const TokenKey = 'Admin-Token'
|
||||
import useUserStore from "@/stores/user";
|
||||
const TokenKey = "Admin-Token";
|
||||
|
||||
export function getToken() {
|
||||
return localStorage.getItem(TokenKey)
|
||||
return localStorage.getItem(TokenKey);
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
return localStorage.setItem(TokenKey, token)
|
||||
return localStorage.setItem(TokenKey, token);
|
||||
}
|
||||
|
||||
export function removeToken() {
|
||||
return localStorage.removeItem (TokenKey)
|
||||
return localStorage.removeItem(TokenKey);
|
||||
}
|
||||
|
||||
export function getPermission(code, isDisabled) {
|
||||
const all_permission = "*:*:*";
|
||||
const isHasPermission = useUserStore().permissions.some((permission) => {
|
||||
if (all_permission === permission) {
|
||||
return true;
|
||||
} else {
|
||||
return code.includes(permission) && !isDisabled;
|
||||
}
|
||||
});
|
||||
return {
|
||||
isHasPermission,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
>主题封面</el-button
|
||||
>
|
||||
<el-button
|
||||
v-hasPer="['bbs:article:add']"
|
||||
v-if="isAddArticle"
|
||||
@click="addArticle('00000000-0000-0000-0000-000000000000')"
|
||||
type="primary"
|
||||
style="width: 100%; margin-bottom: 0.8rem; margin-left: 0"
|
||||
@@ -83,7 +83,7 @@
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="comment">
|
||||
<CommentInfo />
|
||||
<CommentInfo :isComment="isDisabledCreateComment" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<BottomInfo />
|
||||
@@ -105,14 +105,14 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
size="default"
|
||||
v-hasPer="['bbs:discuss:edit']"
|
||||
v-if="isEditTheme"
|
||||
@click="updateHander(route.params.discussId)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button
|
||||
style="margin-left: 1rem"
|
||||
type="danger"
|
||||
v-hasPer="['bbs:discuss:remove']"
|
||||
v-if="isRemoveTheme"
|
||||
@click="delHander(route.params.discussId)"
|
||||
>删除</el-button
|
||||
>
|
||||
@@ -170,7 +170,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { h, ref, onMounted, watch } from "vue";
|
||||
import { h, ref, onMounted, watch, computed } from "vue";
|
||||
import AvatarInfo from "@/components/AvatarInfo.vue";
|
||||
import InfoCard from "@/components/InfoCard.vue";
|
||||
import ArticleContentInfo from "@/components/ArticleContentInfo.vue";
|
||||
@@ -186,6 +186,7 @@ import {
|
||||
get as articleGet,
|
||||
} from "@/apis/articleApi.js";
|
||||
import Breadcrumb from "@/components/Breadcrumb/index.vue";
|
||||
import { getPermission } from "@/utils/auth";
|
||||
|
||||
//数据定义
|
||||
const route = useRoute();
|
||||
@@ -219,12 +220,26 @@ const loadArticleData = async () => {
|
||||
};
|
||||
|
||||
//主题初始化
|
||||
const isDisabledCreateComment = ref(false);
|
||||
const { isHasPermission: isAddArticle } = getPermission(
|
||||
"bbs:article:add",
|
||||
isDisabledCreateComment.value
|
||||
);
|
||||
const { isHasPermission: isEditTheme } = getPermission(
|
||||
"bbs:discuss:edit",
|
||||
isDisabledCreateComment.value
|
||||
);
|
||||
const { isHasPermission: isRemoveTheme } = getPermission(
|
||||
"bbs:discuss:remove",
|
||||
isDisabledCreateComment.value
|
||||
);
|
||||
const loadDiscuss = async (isRewrite) => {
|
||||
if (isRewrite) {
|
||||
//跳转路由
|
||||
router.push(`/article/${route.params.discussId}`);
|
||||
}
|
||||
discuss.value = (await discussGet(route.params.discussId)).data;
|
||||
isDisabledCreateComment.value = discuss.value.isDisabledCreateComment;
|
||||
if (route.params.articleId != "") {
|
||||
const response = await articleGet(route.params.articleId);
|
||||
discuss.value.content = response.data.content;
|
||||
@@ -384,7 +399,7 @@ watch(
|
||||
<style scoped lang="scss">
|
||||
.article-box {
|
||||
position: absolute;
|
||||
width: 1400px;
|
||||
width: 1500px;
|
||||
height: 100%;
|
||||
.comment {
|
||||
min-height: 40rem;
|
||||
|
||||
@@ -106,6 +106,7 @@ import { ref, reactive, watch, computed } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import BottomInfo from "@/components/BottomInfo.vue";
|
||||
import useUserStore from "@/stores/user";
|
||||
import { getPermission } from "@/utils/auth";
|
||||
|
||||
//数据定义
|
||||
const route = useRoute();
|
||||
@@ -159,11 +160,11 @@ const loadDiscussList = async () => {
|
||||
};
|
||||
|
||||
//进入添加主题页面
|
||||
const isEditArticle = computed(
|
||||
() =>
|
||||
useUserStore().hasPermissions &&
|
||||
!(route.params.isPublish === "false" ? false : true)
|
||||
const { isHasPermission: isEditArticle } = getPermission(
|
||||
"bbs:discuss:add",
|
||||
route.params.isPublish === "false" ? false : true
|
||||
);
|
||||
|
||||
const enterEditArticle = () => {
|
||||
if (isEditArticle.value) {
|
||||
//跳转路由
|
||||
|
||||
Reference in New Issue
Block a user