Browse Source

feat: 增加调取服务接口

zhenyulei 5 years ago
parent
commit
71437d2422
3 changed files with 15 additions and 3 deletions
  1. 7 2
      src/sites/doc/router.ts
  2. 7 0
      src/sites/service/ArticleApiService.ts
  3. 1 1
      vue.config.js

+ 7 - 2
src/sites/doc/router.ts

@@ -3,7 +3,7 @@ import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
 import Index from './views/Index.vue';
 import Resource from './views/Resource.vue';
 import Main from './views/Main.vue';
-
+import { HttpClient } from '../service/HttpClient';
 const pagesRouter: Array<RouteRecordRaw> = [];
 const files = require.context('@/packages', true, /doc\.md$/);
 files.keys().forEach(component => {
@@ -57,5 +57,10 @@ const router = createRouter({
     }
   }
 });
-
+router.afterEach((to, from) => {
+  new HttpClient().request('/user/saveVisitInfo', 'post', {
+    headers: '',
+    componentName: to.path.split('/')[1]
+  });
+});
 export default router;

+ 7 - 0
src/sites/service/ArticleApiService.ts

@@ -13,4 +13,11 @@ export class ArticleApiService {
   getArticle() {
     return this.httpClient.request('/article/list', 'get', {});
   }
+  /**
+   * 保存用户访问数据
+   * @returns
+   */
+  saveUserInfo(parmas) {
+    return this.httpClient.request('/user/saveVisitInfo', 'post', parmas);
+  }
 }

+ 1 - 1
vue.config.js

@@ -1,6 +1,6 @@
 // vue.config.js
 const path = require('path');
-
+//target: 'http://localhost:7004',
 module.exports = {
   productionSourceMap: process.env.NODE_ENV != 'production',
   publicPath: './',