123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <!-- 文章右部分 -->
- <template>
- <div class="right_wrap">
- <!-- 分类列表显示 -->
- <div class="nch_article_con" v-if="!showContent">
- <div class="title_bar">
- <h3>{{ title }}</h3>
- </div>
- <!-- 分类显示 -->
- <ul class="nch_article_list">
- <li v-for="(item, index) in cate" :key="index">
- <i></i>
- <a @click="getContent(item.articleId)" style="cursor: pointer">{{
- item.title
- }}</a>
- <time></time>
- </li>
- </ul>
- </div>
- <!-- 文章内容显示 -->
- <div v-if="showContent">
- <h2 v-html="data.articeContent.title" class="article_title"></h2>
- <!-- <p v-html="data.articeContent.createTime" class="article_time"></p> -->
- <div class="article_content ql-container">
- <div class="ql-editor" v-html="data.articeContent.content"></div>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { reactive, getCurrentInstance, onMounted, ref, watchEffect } from "vue";
- import { getCurLanguage } from '@/composables/common.js';
- const L = getCurLanguage();
- defineProps(["cate", "title"]);
- const route = useRoute();
- const router = useRouter();
- const { proxy } = getCurrentInstance();
- const data = reactive({
- articeContent: {},
- });
- const showContent = ref(false); //单独声明showContent以便引用
- const childMethod = (val) => {
- showContent.value = false;
- }
- //通过articleId获取文章详情
- const getContent = (articleId) => {
- const params = {
- articleId: articleId,
- };
- get("v3/cms/front/article/articleDetail", params).then((res) => {
- if (res.state === 200) {
- if (res.data.outUrl) {
- window.open(res.data.outUrl,'_blank');
- return
- }
- if (res.data.content) {
- res.data.content = quillEscapeToHtml(res.data.content);
- }
- data.articeContent = res.data;
- showContent.value = true;
- }
- });
- };
- defineExpose({ childMethod,getContent});
- onMounted(() => {
- if (route.query.articleId) {
- getContent(route.query.articleId);
- }
- });
- watchEffect(() => {
- if (route.query.articleId) {
- getContent(route.query.articleId);
- }
- });
- </script>
- <style lang="scss" scoped>
- @import "@/assets/style/vendors.css";
- .right_wrap {
- background: #fff;
- margin-left: 15px;
- width: calc(100% - 259px);
- float: right;
- .nch_article_con {
- display: block;
- padding: 19px 50px;
- margin: 0 auto 10px;
- overflow: hidden;
- .title_bar {
- border-bottom: solid 1px #e6e6e6;
- padding-bottom: 15px;
- margin-bottom: 15px;
- h3 {
- font: normal 18px/20px "microsoft yahei";
- }
- }
- .nch_article_list li {
- line-height: 20px;
- display: block;
- height: 30px;
- padding: 5px 0;
- i {
- background: #555555;
- vertical-align: middle;
- display: inline-block;
- width: 3px;
- height: 3px;
- margin-right: 10px;
- }
- a {
- color: #666;
- word-break: break-all;
- }
- }
- }
- .article_title {
- text-align: center;
- font-size: 24px;
- line-height: 24px;
- margin-top: 20px;
- margin-bottom: 20px;
- }
- .article_time {
- font-size: 16px;
- text-align: center;
- line-height: 40px;
- color: #666;
- margin-bottom: 20px;
- }
- .article_content {
- padding: 0 20px;
- word-break: break-all;
- .ql-editor {
- padding: 0;
- }
- }
- }
- </style>
- <style lang="scss">
- .right_wrap {
- .article_content {
- img {
- max-width: 900px;
- }
- a {
- display: inline-block;
- margin: 5px auto;
- color: #0000ff;
- text-decoration: underline;
- }
- table {
- border-collapse: collapse;
- padding: 0;
- }
- td,
- th {
- border: 1px solid #ddd;
- padding: 5px 10px;
- }
- ol li,
- ul li {
- list-style: unset;
- }
- }
- }
- </style>
|