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