Bladeren bron

前端配合修改:分开主/分站的显示

lrf402788946 5 jaren geleden
bovenliggende
commit
9e1508e8a5
3 gewijzigde bestanden met toevoegingen van 43 en 43 verwijderingen
  1. 31 31
      src/store.js
  2. 9 11
      src/views/index/index.vue
  3. 3 1
      vue.config.js

+ 31 - 31
src/store.js

@@ -30,22 +30,24 @@ const api = {
   fairCorp: '/api/jobs/faircorps',
   fairJobs: '/api/jobs/faircorps/{id}/jobs',
   //分站菜单
-  menuQuery: '/api/cms/menu/list',
+  menuQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/menu/list`,
   menuSearch: `/adminapi/menu/fetch/{id}`,
   // 站点管理
-  siteQuery: '/api/cms/site/query',
-  siteFetch: `/api/cms/site/config`,
-  siteContent: `/api/cms/site/content`,
+  siteQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/site/query`,
+  siteFetch: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/site/config`,
+  siteContent: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/site/content`,
   // 新闻管理
-  newsQuery: '/api/cms/news/list',
-  newsFetch: '/api/cms/news/fetch/{id}',
+  newsQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/news/list`,
+  newsFetch: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/news/fetch/{id}`,
+  bugInfo: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/newscreeper/fetch/{id}`,
   //栏目管理
-  columnQuery: `/api/cms/column/list`,
-  columnFetch: `/api/cms/column/fetch/{id}`,
+  columnQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/column/list`,
+  columnFetch: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/column/fetch/{id}`,
+  bugList: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/newscreeper/list`,
   //模块管理
-  moduleQuery: `/api/cms/modules/list`,
+  moduleQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/modules/list`,
   //合作单位/友情链接
-  linkQuery: `/api/cms/img/list`,
+  linkQuery: `${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}/img/list`,
 
   // 学生关注企业
   // stucorp: `/adminapi${process.env.NODE_ENV === 'development' ? '' : ' / jobs'}/studentcorp`,
@@ -57,7 +59,7 @@ const api = {
   stucorpsearch: '/api/stud/studentcorp',
   stucorplist: '/api/stud/studentcorp',
   stucorpdelete: '/api/stud/studentcorp/{id}',
-  //测试前缀${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}
+  //测试前缀${process.env.NODE_ENV === 'development' ? '/adminapi' : '${process.env.NODE_ENV === 'development' ? '/adminapi' : '/api/cms'}'}
 };
 
 export default new Vuex.Store({
@@ -274,18 +276,12 @@ export default new Vuex.Store({
       }
       console.error('create qrcode fail', result);
     },
-    //抓取信息
-    async getBugInfo({ state }, { data }) {
-      let { skip, limit } = data;
-      let result = await this.$axios.$get('/bugInfo/newsinfo', {}, { skip: skip, limit: limit });
-      return result;
-    },
     //分站菜单
     async menuOperation({ state }, { type, data }) {
       let result;
       if (type === 'list') {
         let { site } = data;
-        result = await this.$axios.$get(api.menuQuery, {}, { site: site, is_use: '0' });
+        result = await this.$axios.$get(api.menuQuery, {}, { is_use: '0' });
       }
       if (type === 'search') {
         let { id } = data;
@@ -297,8 +293,7 @@ export default new Vuex.Store({
     async moduleOperation({ state }, { type, data }) {
       let result;
       if (type === 'list') {
-        let { site } = data;
-        result = await this.$axios.$get(api.moduleQuery, {}, { site: site, is_use: '0' });
+        result = await this.$axios.$get(api.moduleQuery, {}, { is_use: '0' });
       }
       return result;
     },
@@ -307,15 +302,16 @@ export default new Vuex.Store({
       let result;
       if (type === 'list') {
         let { site, column } = data;
-        result = await this.$axios.$get(api.siteQuery, { site: site, column: column });
+        result = await this.$axios.$get(api.siteQuery, { column: column });
       }
       if (type === 'search') {
         let { site } = data;
         //_tenant
-        let content = await this.$axios.$get(api.siteContent, {}, { _tenant: site });
-        result = await this.$axios.$get(api.siteFetch, {}, { _tenant: site });
-        if (`${content.errcode}` === '0') {
-          result.data.content = content.data;
+        let content = await this.$axios.$get(api.siteContent, {});
+        result = await this.$axios.$get(api.siteFetch, {});
+        if (content.data && `${content.errcode}` === '0') {
+          console.log('in function:');
+          result.data.content = content && content.data ? content.data : '';
         }
       }
       return result;
@@ -325,12 +321,16 @@ export default new Vuex.Store({
       let { skip, limit } = data;
       let result;
       if (type === 'list') {
-        let { site, parent_id } = data;
-        result = await this.$axios.$get(api.newsQuery, {}, { site: site, parent_id: parent_id, skip: skip, limit: limit, is_use: '0' });
+        let { site, parent_id, news_type } = data;
+        if (news_type === '0') {
+          result = await this.$axios.$get(api.bugList, {}, { parent_id: parent_id, skip: skip, limit: limit, is_use: '0' });
+        } else {
+          result = await this.$axios.$get(api.newsQuery, {}, { parent_id: parent_id, skip: skip, limit: limit, is_use: '0' });
+        }
       }
       if (type === 'search') {
-        let { id } = data;
-        result = await this.$axios.$get(api.newsFetch, { id: id });
+        let { id, news_type } = data;
+        result = await this.$axios.$get(api.bugInfo, { id: id });
       }
       return result;
     },
@@ -341,7 +341,7 @@ export default new Vuex.Store({
       if (type === 'list') {
         //TODO
         let { parent_id, site } = data;
-        result = await this.$axios.$get(api.columnQuery, {}, { parent_id: parent_id, site: site, is_use: '0' });
+        result = await this.$axios.$get(api.columnQuery, {}, { parent_id: parent_id, is_use: '0' });
       }
       if (type === 'search') {
         let { parent_id } = data;
@@ -384,7 +384,7 @@ export default new Vuex.Store({
       let result;
       if (type === 'list') {
         let { site, type } = data;
-        result = await this.$axios.$get(api.linkQuery, {}, { site: site, type: type, is_use: `0` });
+        result = await this.$axios.$get(api.linkQuery, {}, { type: type, is_use: `0` });
       }
       return result;
     },

+ 9 - 11
src/views/index/index.vue

@@ -64,9 +64,9 @@ export default {
   }),
   async created() {
     await this.getSite();
-    this.search();
+    // this.search();
     this.getModule();
-    this.getLink();
+    // this.getLink();
   },
   computed: {},
   methods: {
@@ -74,7 +74,6 @@ export default {
       'jobfairOperation',
       'postTalksInfo',
       'jobinfoOperation',
-      'getBugInfo',
       'newsOperation',
       'siteOperation',
       'moduleOperation',
@@ -127,7 +126,7 @@ export default {
     },
     async getModule() {
       //获取分站所有模块 TODO:site=>_tenant
-      let result = await this.moduleOperation({ type: 'list', data: { site: this.$site } });
+      let result = await this.moduleOperation({ type: 'list' });
       if (`${result.errcode}` === '0') {
         let moduleList = result.data;
         for (let item of moduleList) {
@@ -143,17 +142,17 @@ export default {
       // console.log(item);
       // console.log(this.site);
       if (!item.category.includes('self')) {
-        let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id, site: item.site } });
+        let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id } });
         if (`${res.errcode}` === '0') {
           //组合path:res.data内容都为栏目.所以,点击这些栏目显示的列表应该是信息列表,需要用栏目的id作为查询信息的parten_id查出不同栏目的信息
           for (const col of res.data) {
             col.path = `/info/list/${col.id}`;
             //再将栏目下的前几条数据查出来(暂定limit=6)
-            col.children = await this.getNews(col);
+            col.children = await this.getNews(col, '1');
           }
           item.children = res.data;
         }
-      } else {
+      } else if (this.site && this.site.bug_column) {
         let selfUseList = JSON.parse(this.site.bug_column);
         let res = selfUseList.filter(fil => {
           if (fil) return fil.parent_id === item.id;
@@ -161,15 +160,15 @@ export default {
         for (const col of res) {
           col.id = col.column;
           col.path = `/info/list/${col.id}`;
-          col.children = await this.getNews(col);
+          col.children = await this.getNews(col, '0');
         }
         item.children = res;
       }
       return item;
     },
-    async getNews(item) {
+    async getNews(item, news_type) {
       //这个item是栏目列表,循环查每个栏目6条信息
-      let res = await this.newsOperation({ type: 'list', data: { parent_id: item.id, site: item.site, skip: 0, limit: 6 } });
+      let res = await this.newsOperation({ type: 'list', data: { parent_id: item.id, skip: 0, limit: 6 } });
       if (`${res.errcode}` === '0') {
         return res.data;
       }
@@ -201,7 +200,6 @@ export default {
       } else if (item.category === 'self1') {
         this.$set(this, `self1List`, item.children);
       } else if (item.category === 'self2') {
-        console.log(item);
         this.$set(this, `self2List`, item.children);
       }
     },

+ 3 - 1
vue.config.js

@@ -21,7 +21,6 @@ module.exports = {
     proxy: {
       '/api': {
         target: 'http://smart.cc-lotus.info',
-        changeOrigin: true,
         ws: true,
       },
       '/bugInfo': {
@@ -49,6 +48,9 @@ module.exports = {
         target: 'http://10.16.5.15:8105',
         ws: true,
         pathRewrite: { '^/adminapi': '/api' },
+        onProxyReq(proxyReq, req, res) {
+          proxyReq.setHeader('x-tenant', '99991');
+        },
       },
     },
   },