guhongwei 2 سال پیش
والد
کامیت
79a37cb34f
6فایلهای تغییر یافته به همراه82 افزوده شده و 28 حذف شده
  1. 3 0
      .env.development
  2. 2 0
      .env.production
  3. 4 0
      env.d.ts
  4. 43 1
      src/stores/counter copy.ts
  5. 2 2
      src/views/loginIndex.vue
  6. 28 25
      vite.config.ts

+ 3 - 0
.env.development

@@ -1,2 +1,5 @@
 VITE_APP_HOST="http://basic.waityou24.cn"
 BASE_URL='web'
+VITE_OUT_DIR="build"
+VITE_BASE_URL=""
+g

+ 2 - 0
.env.production

@@ -1,2 +1,4 @@
 VITE_APP_HOST="http://basic.waityou24.cn"
 BASE_URL='web'
+VITE_OUT_DIR="build"
+VITE_BASE_URL=""

+ 4 - 0
env.d.ts

@@ -1 +1,5 @@
 /// <reference types="vite/client" />
+interface ImportMetaEnv {
+  VITE_BASE_URL: string
+  VITE_OUT_DIR: string
+}

+ 43 - 1
src/stores/counter copy.ts

@@ -1,12 +1,54 @@
 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 projectApi = {
+  url: '/api/util/dbInit/project'
+}
 export const useCounterStore = defineStore('counter', () => {
   const count = ref(0)
   const doubleCount = computed(() => count.value * 2)
   function increment() {
     count.value++
   }
+  // #region project
+  const projectQuery = 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(`${projectApi.url}`, cond)
+    return res
+  }
+  const projectFetch = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$get(`${projectApi.url}/${payload}`)
+    return res
+  }
+  const projectCreate = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${projectApi.url}`, payload)
+    return res
+  }
+  const projecUpdate = async (payload: any): Promise<IQueryResult> => {
+    const id = _.get(payload, 'id', _.get(payload, '_id'))
+    const res = await axios.$post(`${projectApi.url}/${id}`, payload)
+    return res
+  }
+  const projecDelete = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$delete(`${projectApi.url}/${payload}`)
+    return res
+  }
 
-  return { count, doubleCount, increment }
+  return {
+    count,
+    doubleCount,
+    increment,
+    projectQuery,
+    projectFetch,
+    projectCreate,
+    projecUpdate,
+    projecDelete
+  }
 })

+ 2 - 2
src/views/loginIndex.vue

@@ -131,8 +131,8 @@ const code: Ref<any> = ref('')
 // 字典
 const typeList: Ref<any> = ref([
   { label: '依托单位账号', value: '0' },
-  { label: '个人账号', value: '1' },
-  { label: '管理员', value: '2' }
+  { label: '个人账号', value: '1' }
+  // { label: '管理员', value: '2' }
 ])
 onMounted(() => {})
 // 验证码

+ 28 - 25
vite.config.ts

@@ -1,33 +1,36 @@
 import { fileURLToPath, URL } from 'node:url'
-import { defineConfig } from 'vite'
+import { defineConfig, loadEnv } from 'vite'
 import vue from '@vitejs/plugin-vue'
 const path = require('path')
 const common = path.resolve(__dirname, '../common')
-export default defineConfig({
-  plugins: [vue()],
-  server: {
-    port: 8001,
-    proxy: {
-      '/files': {
-        target: 'http://basic.waityou24.cn'
-      },
-      '/jcyjdtglpt/v1/api': {
-        target: 'http://basic.waityou24.cn',
-        changeOrigin: true,
-        ws: false
+export default defineConfig(({ mode }) => {
+  const env = loadEnv(mode, __dirname)
+  return {
+    // 静态路径
+    base: env.VITE_BASE_URL,
+    // 打包名称
+    build: {
+      outDir: env.VITE_OUT_DIR
+    },
+    plugins: [vue()],
+    server: {
+      port: 8001,
+      proxy: {
+        '/files': {
+          target: 'http://basic.waityou24.cn'
+        },
+        '/jcyjdtglpt/v1/api': {
+          target: 'http://basic.waityou24.cn',
+          changeOrigin: true,
+          ws: false
+        }
+      }
+    },
+    resolve: {
+      alias: {
+        '@': fileURLToPath(new URL('./src', import.meta.url)),
+        '@common': common
       }
     }
-  },
-  resolve: {
-    alias: {
-      '@': fileURLToPath(new URL('./src', import.meta.url)),
-      '@common': common
-    }
-  },
-  // 静态路径
-  base: '',
-  // 打包名称
-  build: {
-    outDir: ''
   }
 })