guhongwei 2 年 前
コミット
a3f56cb7db

+ 0 - 46
README.md

@@ -1,46 +0,0 @@
-# common
-
-This template should help get you started developing with Vue 3 in Vite.
-
-## Recommended IDE Setup
-
-[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
-
-## Type Support for `.vue` Imports in TS
-
-TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
-
-If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
-
-1. Disable the built-in TypeScript Extension
-    1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
-    2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
-2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
-
-## Customize configuration
-
-See [Vite Configuration Reference](https://vitejs.dev/config/).
-
-## Project Setup
-
-```sh
-npm install
-```
-
-### Compile and Hot-Reload for Development
-
-```sh
-npm run dev
-```
-
-### Type-Check, Compile and Minify for Production
-
-```sh
-npm run build
-```
-
-### Lint with [ESLint](https://eslint.org/)
-
-```sh
-npm run lint
-```

+ 2 - 68
src/App.vue

@@ -1,71 +1,5 @@
-<script setup lang="ts">
-import { RouterLink, RouterView } from 'vue-router'
-</script>
-
 <template>
   <RouterView />
 </template>
-
-<style scoped>
-header {
-  line-height: 1.5;
-  max-height: 100vh;
-}
-
-.logo {
-  display: block;
-  margin: 0 auto 2rem;
-}
-
-nav {
-  width: 100%;
-  font-size: 12px;
-  text-align: center;
-  margin-top: 2rem;
-}
-
-nav a.router-link-exact-active {
-  color: var(--color-text);
-}
-
-nav a.router-link-exact-active:hover {
-  background-color: transparent;
-}
-
-nav a {
-  display: inline-block;
-  padding: 0 1rem;
-  border-left: 1px solid var(--color-border);
-}
-
-nav a:first-of-type {
-  border: 0;
-}
-
-@media (min-width: 1024px) {
-  header {
-    display: flex;
-    place-items: center;
-    padding-right: calc(var(--section-gap) / 2);
-  }
-
-  .logo {
-    margin: 0 2rem 0 0;
-  }
-
-  header .wrapper {
-    display: flex;
-    place-items: flex-start;
-    flex-wrap: wrap;
-  }
-
-  nav {
-    text-align: left;
-    margin-left: -1rem;
-    font-size: 1rem;
-
-    padding: 1rem 0;
-    margin-top: 1rem;
-  }
-}
-</style>
+<script setup lang="ts"></script>
+<style scoped></style>

+ 46 - 0
src/components/studio-one-green copy/home-1.vue

@@ -0,0 +1,46 @@
+<template>
+  <div id="home">
+    <el-container class="main" :style="{ background: styleInfo.main_bg_color }">
+      <el-aside class="one" :style="{ background: styleInfo.aside_bg_color, 'border-color': styleInfo.aside_border_color }">
+        <HomeLeft></HomeLeft>
+      </el-aside>
+      <el-container class="two" :style="{ background: styleInfo.con_bg_color }">
+        <el-header class="two_1">
+          <HomeHead></HomeHead>
+        </el-header>
+        <el-main class="two_2" :style="{ background: styleInfo.conmain_bg_color, 'border-color': styleInfo.aside_border_color }">
+          <router-view></router-view>
+        </el-main>
+      </el-container>
+    </el-container>
+  </div>
+</template>
+<script setup lang="ts">
+import { studio_style_Info } from '../../layout/site';
+import HomeLeft from './homeParts/left-1.vue';
+import HomeHead from './homeParts/header-1.vue';
+let styleInfo = studio_style_Info;
+</script>
+
+<style scoped lang="scss">
+.main {
+  display: flex;
+  width: 100vw;
+  height: 100vh;
+  .one {
+    border-radius: 10px;
+    margin: 0.5vw;
+    padding: 0.5vw;
+    border: 1px solid;
+  }
+  .two {
+    min-width: 1200px;
+    .two_2 {
+      border-radius: 10px;
+      margin: 0.5vw;
+      padding: 0.5vw;
+      border: 1px solid;
+    }
+  }
+}
+</style>

src/components/studio-one-green/home-2.vue → src/components/studio-one-green copy/home-2.vue


src/components/studio-one-green/home-3.vue → src/components/studio-one-green copy/home-3.vue


+ 17 - 0
src/components/studio-one-green copy/home.vue

@@ -0,0 +1,17 @@
+<template>
+  <div id="home">
+    <home1 v-if="type == '1'"></home1>
+    <home2 v-else-if="type == '2'"></home2>
+    <home3 v-else-if="type == '3'"></home3>
+  </div>
+</template>
+<script setup lang="ts">
+import { ref } from 'vue';
+import type { Ref } from 'vue';
+import home1 from './home-1.vue';
+import home2 from './home-2.vue';
+import home3 from './home-3.vue';
+let type: Ref<string> = ref('2');
+</script>
+
+<style scoped lang="scss"></style>

src/components/studio-one-green/homeParts/header-1.vue → src/components/studio-one-green copy/homeParts/header-1.vue


src/components/studio-one-green/homeParts/left-1.vue → src/components/studio-one-green copy/homeParts/left-1.vue


src/components/studio-one-green/parts/header-1.vue → src/components/studio-one-green copy/parts/header-1.vue


src/components/studio-one-green/parts/left-1.vue → src/components/studio-one-green copy/parts/left-1.vue


+ 3 - 43
src/components/studio-one-green/home-1.vue

@@ -1,46 +1,6 @@
 <template>
-  <div id="home">
-    <el-container class="main" :style="{ background: styleInfo.main_bg_color }">
-      <el-aside class="one" :style="{ background: styleInfo.aside_bg_color, 'border-color': styleInfo.aside_border_color }">
-        <HomeLeft></HomeLeft>
-      </el-aside>
-      <el-container class="two" :style="{ background: styleInfo.con_bg_color }">
-        <el-header class="two_1">
-          <HomeHead></HomeHead>
-        </el-header>
-        <el-main class="two_2" :style="{ background: styleInfo.conmain_bg_color, 'border-color': styleInfo.aside_border_color }">
-          <router-view></router-view>
-        </el-main>
-      </el-container>
-    </el-container>
-  </div>
+  <div id="home-1">第一部分</div>
 </template>
-<script setup lang="ts">
-import { studio_style_Info } from '../../layout/site';
-import HomeLeft from './homeParts/left-1.vue';
-import HomeHead from './homeParts/header-1.vue';
-let styleInfo = studio_style_Info;
-</script>
+<script setup lang="ts"></script>
 
-<style scoped lang="scss">
-.main {
-  display: flex;
-  width: 100vw;
-  height: 100vh;
-  .one {
-    border-radius: 10px;
-    margin: 0.5vw;
-    padding: 0.5vw;
-    border: 1px solid;
-  }
-  .two {
-    min-width: 1200px;
-    .two_2 {
-      border-radius: 10px;
-      margin: 0.5vw;
-      padding: 0.5vw;
-      border: 1px solid;
-    }
-  }
-}
-</style>
+<style scoped lang="scss"></style>

+ 42 - 5
src/components/studio-one-green/home.vue

@@ -5,13 +5,50 @@
     <home3 v-else-if="type == '3'"></home3>
   </div>
 </template>
+
 <script setup lang="ts">
-import { ref } from 'vue';
-import type { Ref } from 'vue';
+// 组件
+import store from '@/stores/counter';
 import home1 from './home-1.vue';
-import home2 from './home-2.vue';
-import home3 from './home-3.vue';
-let type: Ref<string> = ref('2');
+import type { Ref } from 'vue';
+import { ref, onMounted } from 'vue';
+import { ElMessage } from 'element-plus';
+
+// 接口
+import { ModuleStore } from '@common/src/stores/admin/module'; //模块
+import { RoleStore } from '@common/src/stores/admin/role'; //模块
+import type { IQueryResult } from '@/util/types.util'; //
+const module = ModuleStore();
+const role = RoleStore();
+// 默认值
+let type: Ref<string> = ref('');
+
+onMounted(async () => {
+  let e = store.state.user;
+  let name = import.meta.env.VITE_APP_ROUTER;
+  const res: IQueryResult = await module.query({ name: name, is_use: 'Y' });
+  if (res && res.errcode == '0') {
+    if (res.total > 0) {
+      let moduleInfo = res.data[0];
+      let roleInfo = await role.um();
+      if (roleInfo.errcode == '0') {
+        if (roleInfo.data) {
+          let menus = roleInfo.data[moduleInfo._id];
+          if (menus && menus.length > 0) {
+            if (e && e.role_type == '1') type.value = '1';
+            else if ((e && e.role_type == '2') || (e && e.role_type == '3')) type.value = '2';
+            localStorage.setItem('is_role', 'true');
+          } else {
+            type.value = '2';
+            localStorage.setItem('is_role', 'false');
+          }
+        }
+      }
+    }
+  } else {
+    ElMessage({ message: `${res.errmsg}`, type: 'error' });
+  }
+});
 </script>
 
 <style scoped lang="scss"></style>

+ 6 - 14
src/main.ts

@@ -1,14 +1,6 @@
-import { createApp } from 'vue'
-import { createPinia } from 'pinia'
-
-import App from './App.vue'
-import router from './router'
-
-import './assets/main.css'
-
-const app = createApp(App)
-
-app.use(createPinia())
-app.use(router)
-
-app.mount('#app')
+import { createApp } from 'vue';
+import { createPinia } from 'pinia';
+import App from './App.vue';
+const app = createApp(App);
+app.use(createPinia());
+app.mount('#app');

+ 0 - 8
src/router/index.ts

@@ -1,8 +0,0 @@
-import { createRouter, createWebHistory } from 'vue-router';
-
-const router = createRouter({
-  history: createWebHistory(import.meta.env.BASE_URL),
-  routes: [],
-});
-
-export default router;

+ 52 - 0
src/stores/admin/module.ts

@@ -0,0 +1,52 @@
+import { ref, computed } from 'vue';
+import { defineStore } from 'pinia';
+import { AxiosWrapper } from '@/util/axios-wrapper';
+import _ from 'lodash';
+
+import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
+const axios = new AxiosWrapper();
+const api = {
+  url: `/jcyjdtglpt/v1/api/module`,
+};
+export const ModuleStore = defineStore('module', () => {
+  const count = ref(0);
+  const doubleCount = computed(() => count.value * 2);
+  function increment() {
+    count.value++;
+  }
+  const query = async ({ skip = 0, limit = undefined, ...info }: IQueryParams = {}): Promise<IQueryResult> => {
+    let cond: IQueryType = {};
+    if (skip) cond.skip = skip;
+    if (limit) cond.limit = limit;
+    cond = { ...cond, ...info };
+    const res = await axios.$get(`${api.url}`, cond);
+    return res;
+  };
+  const fetch = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$get(`${api.url}/${payload}`);
+    return res;
+  };
+  const create = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}`, payload);
+    return res;
+  };
+  const update = async (payload: any): Promise<IQueryResult> => {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  };
+  const del = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$delete(`${api.url}/${payload}`);
+    return res;
+  };
+  return {
+    count,
+    doubleCount,
+    increment,
+    query,
+    fetch,
+    create,
+    update,
+    del,
+  };
+});

+ 62 - 0
src/stores/admin/role.ts

@@ -0,0 +1,62 @@
+import { ref, computed } from 'vue';
+import { defineStore } from 'pinia';
+import { AxiosWrapper } from '@/util/axios-wrapper';
+import _ from 'lodash';
+
+import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
+const axios = new AxiosWrapper();
+const api = {
+  url: `/jcyjdtglpt/v1/api/role`,
+};
+export const RoleStore = defineStore('role', () => {
+  const count = ref(0);
+  const doubleCount = computed(() => count.value * 2);
+  function increment() {
+    count.value++;
+  }
+  const query = async ({ skip = 0, limit = undefined, ...info }: IQueryParams = {}): Promise<IQueryResult> => {
+    let cond: IQueryType = {};
+    if (skip) cond.skip = skip;
+    if (limit) cond.limit = limit;
+    cond = { ...cond, ...info };
+    const res = await axios.$get(`${api.url}`, cond);
+    return res;
+  };
+  const um = async (): Promise<IQueryResult> => {
+    const res = await axios.$get(`${api.url}/um`);
+    return res;
+  };
+  const am = async (): Promise<IQueryResult> => {
+    const res = await axios.$get(`${api.url}/am`);
+    return res;
+  };
+  const fetch = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$get(`${api.url}/${payload}`);
+    return res;
+  };
+  const create = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}`, payload);
+    return res;
+  };
+  const update = async (payload: any): Promise<IQueryResult> => {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  };
+  const del = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$delete(`${api.url}/${payload}`);
+    return res;
+  };
+  return {
+    count,
+    doubleCount,
+    increment,
+    query,
+    um,
+    am,
+    fetch,
+    create,
+    update,
+    del,
+  };
+});

+ 0 - 12
src/stores/counter.ts

@@ -1,12 +0,0 @@
-import { ref, computed } from 'vue'
-import { defineStore } from 'pinia'
-
-export const useCounterStore = defineStore('counter', () => {
-  const count = ref(0)
-  const doubleCount = computed(() => count.value * 2)
-  function increment() {
-    count.value++
-  }
-
-  return { count, doubleCount, increment }
-})

+ 2 - 24
vite.config.ts

@@ -1,29 +1,7 @@
-import { fileURLToPath, URL } from 'node:url';
-
 import { defineConfig } from 'vite';
 import vue from '@vitejs/plugin-vue';
-
-// https://vitejs.dev/config/
 export default defineConfig({
   plugins: [vue()],
-  server: {
-    port: 20001,
-    proxy: {
-      '/files': {
-        target: 'http://basic.waityou24.cn',
-      },
-    },
-  },
-  resolve: {
-    alias: {
-      '@': fileURLToPath(new URL('./src', import.meta.url)),
-    },
-  },
-  css: {
-    preprocessorOptions: {
-      scss: {
-        additionalData: `@import "@/assets/style/mixin.scss";`, // 此处全局的scss文件
-      },
-    },
-  },
+  server: {},
+  resolve: {},
 });