YY 2 年之前
父节点
当前提交
30702b4d23
共有 3 个文件被更改,包括 68 次插入10 次删除
  1. 42 0
      src/router/index.ts
  2. 25 9
      src/stores/counter.ts
  3. 1 1
      tsconfig.json

+ 42 - 0
src/router/index.ts

@@ -1,4 +1,5 @@
 import { createRouter, createWebHistory } from 'vue-router';
+import { store } from '@/stores/counter';
 // 公共
 import common from './module/common';
 // 管理员
@@ -29,6 +30,7 @@ const router = createRouter({
     // },
     {
       path: '/',
+      meta: { title: '基础研究动态管理平台', is_filter: true },
       component: () => import('@common/src/components/studio-one-green/home.vue'),
       children: [
         {
@@ -41,4 +43,44 @@ const router = createRouter({
     },
   ],
 });
+router.beforeEach((to, from, next) => {
+  document.title = `${to.meta.title} `;
+  const token = localStorage.getItem('token');
+  if (token) {
+    // let user = jwt.decode(token);
+    const user = {
+      _id: '63b511fa2f41cd4838e478bb',
+      account: 'sunit',
+      card: '220182199603257020',
+      name: '公司负责人',
+      nick_name: '长春市福瑞科技有限公司',
+      email: '1946230922@qq.com',
+      phone: '13174420325',
+      unit_name: '长春市福瑞科技有限公司',
+      unit_address: '长春市朝阳区前进大街1244号',
+      prove: [
+        {
+          id: '20230104134319',
+          name: 'free.png',
+          uri: '/files/jcyjdt/register/20230104134319.png',
+          url: 'http://broadcast.waityou24.cn/files/jcyjdt/register/20230104134319.png',
+          uid: 1672810999458,
+          status: 'success',
+        },
+      ],
+      role: ['63b628619bb09c9905df137b', '63b64a9435df6c6862e0c882', '63b64b4435df6c6862e12d84', '63b62cf19bb09c9905e17543'],
+      exam_status: '1',
+      is_studio: 'Y',
+      role_type: '3',
+      iat: 1679033671,
+      exp: 1679206471,
+    };
+    console.log(store);
+
+    // store.commit('setUser', user, { root: true });
+    next();
+  } else {
+    window.alert('无登录信息,无法打开');
+  }
+});
 export default router;

+ 25 - 9
src/stores/counter.ts

@@ -1,12 +1,28 @@
-import { ref, computed } from 'vue'
-import { defineStore } from 'pinia'
-
-export const useCounterStore = defineStore('counter', () => {
-  const count = ref(0)
-  const doubleCount = computed(() => count.value * 2)
+import { ref, computed } from 'vue';
+import { defineStore } from 'pinia';
+import * as ustate from '@common/src/stores/user/state';
+import * as umutations from '@common/src/stores/user/mutations';
+export const store = defineStore('counter', () => {
+  const count = ref(0);
+  const doubleCount = computed(() => count.value * 2);
   function increment() {
-    count.value++
+    count.value++;
   }
+  const state = { ...ustate, isInAct: false };
 
-  return { count, doubleCount, increment }
-})
+  const getters = {};
+  const mutations = {
+    umutations,
+    setIsInAct(state: { isInAct: object }, payload: { isInAct: object }) {
+      state.isInAct = payload;
+    },
+  };
+  return {
+    state,
+    getters,
+    mutations,
+    count,
+    doubleCount,
+    increment,
+  };
+});

+ 1 - 1
tsconfig.json

@@ -1,6 +1,6 @@
 {
   "extends": "@vue/tsconfig/tsconfig.web.json",
-  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
+  "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "../common/src/stores/user"],
   "compilerOptions": {
     "baseUrl": ".",
     "paths": {