zhuf 1 年之前
父节点
当前提交
6d28685868
共有 5 个文件被更改,包括 2825 次插入913 次删除
  1. 130 0
      __unconfig_vite.config.ts
  2. 22 20
      package.json
  3. 2609 892
      pnpm-lock.yaml
  4. 33 1
      src/store/user.ts
  5. 31 0
      vite.config.ts

+ 130 - 0
__unconfig_vite.config.ts

@@ -0,0 +1,130 @@
+
+let __unconfig_data;
+let __unconfig_stub = function (data = {}) { __unconfig_data = data };
+__unconfig_stub.default = (data = {}) => { __unconfig_data = data };
+import path from 'path'
+import { defineConfig } from 'vite'
+import vue from '@vitejs/plugin-vue'
+import WindiCss from 'vite-plugin-windicss'
+import AutoImport from 'unplugin-auto-import/vite'
+import Components from 'unplugin-vue-components/vite'
+import { ElementPlusResolver, VantResolver } from 'unplugin-vue-components/resolvers'
+import Icons from 'unplugin-icons/vite'
+import IconsResolver from 'unplugin-icons/resolver'
+import ConditionalCompile from './plugins/vite-plugin-conditional-compile'
+import basicSsl from '@vitejs/plugin-basic-ssl'
+import topLevelAwait from 'vite-plugin-top-level-await'
+import legacy from '@vitejs/plugin-legacy'
+
+// https://vitejs.dev/config/
+const __unconfig_default =  defineConfig({
+  resolve: {
+    alias: {
+      '@': path.resolve(__dirname, 'src'),
+      '~': path.resolve(__dirname, 'src'),
+      // '~components': path.resolve(__dirname, 'src/components'),
+      // '~pages': path.resolve(__dirname, 'src/pages'),
+      // '~utils': path.resolve(__dirname, 'src/utils'),
+      // '~assets': path.resolve(__dirname, 'src/assets'),
+      // '~styles': path.resolve(__dirname, 'src/styles'),
+      // '~lib': path.resolve(__dirname, 'src/lib'),
+      // '~plugins': path.resolve(__dirname, 'src/plugins'),
+      // '~router': path.resolve(__dirname, 'src/router'),
+      // '~store': path.resolve(__dirname, 'src/store'),
+      // '~config': path.resolve(__dirname, 'src/config'),
+      // '~api': path.resolve(__dirname, 'src/api'),
+      // '~constants': path.resolve(__dirname, 'src/constants'),
+      // '~locales': path.resolve(__dirname, 'src/locales'),
+    },
+  },
+  css: {
+    preprocessorOptions: {
+      scss: {
+        additionalData: '@use "./element.scss" as *;',
+      },
+    },
+  },
+  plugins: [
+    legacy({
+      targets: ['defaults', 'ie >= 11', 'chrome 52'],  //需要兼容的目标列表,可以设置多个
+      additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
+      renderLegacyChunks: true,
+      polyfills: [
+        'es.symbol',
+        'es.array.filter',
+        'es.promise',
+        'es.promise.finally',
+        'es/map',
+        'es/set',
+        'es.array.for-each',
+        'es.object.define-properties',
+        'es.object.define-property',
+        'es.object.get-own-property-descriptor',
+        'es.object.get-own-property-descriptors',
+        'es.object.keys',
+        'es.object.to-string',
+        'web.dom-collections.for-each',
+        'esnext.global-this',
+        'esnext.string.match-all'
+      ]
+    }),
+    topLevelAwait({
+      // The export name of top-level await promise for each chunk module
+      promiseExportName: '__tla',
+      // The function to generate import names of top-level await promise in each chunk module
+      promiseImportName: i => `__tla_${i}`
+    }),
+    basicSsl(),
+    ConditionalCompile(),
+    vue({
+      reactivityTransform: true,
+    }),
+    WindiCss(),
+    AutoImport({
+      // dts: 'src/auto-imports.d.ts',
+      imports: ['vue', 'vue/macros', 'vue-router'],
+      dirs: [
+        'src/composables',
+        // 'src/store',
+        'src/utils',
+      ],
+      resolvers: [ElementPlusResolver(),VantResolver()],
+      vueTemplate: true,
+      eslintrc: {
+        enabled: true,
+        // enabled: false, // Default `false`
+        // filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
+        // globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
+      },
+    }),
+    Components({
+      // dts: 'src/components.d.ts',
+      dirs: ['src/components/'],
+      // allow auto load markdown components under `./src/components/`
+      extensions: ['vue', 'md'],
+      // allow auto import and register components used in markdown
+      include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
+      resolvers: [ElementPlusResolver({ importStyle: 'sass' }), IconsResolver(),VantResolver()],
+    }),
+    Icons({
+      compiler: 'vue3',
+      autoInstall: true,
+    }),
+  ],
+  server: {
+    host: true,
+    port: 5230,
+    https: true,
+  },
+  build: {
+    // rollupOptions: {
+    //   output: {
+    //     manualChunks: {
+    //       axios: ['axios'],
+    //     },
+    //   },
+    // },
+  },
+})
+
+if (typeof __unconfig_default === "function") __unconfig_default(...[{"command":"serve","mode":"development"}]);export default __unconfig_data;

+ 22 - 20
package.json

@@ -18,36 +18,38 @@
     "prepare": "husky install"
   },
   "dependencies": {
-    "@element-plus/icons-vue": "^2.0.10",
-    "@vueuse/components": "^9.10.0",
-    "@vueuse/core": "^9.10.0",
-    "agora-rtc-sdk-ng": "^4.17.2",
-    "axios": "^1.2.2",
-    "element-plus": "^2.2.28",
-    "tinymce": "^6.3.1",
-    "vant": "^4.1.2",
-    "vconsole": "^3.15.0",
-    "vue": "^3.2.45",
-    "vue-router": "^4.1.6"
+    "@element-plus/icons-vue": "^2.1.0",
+    "@vueuse/components": "^9.13.0",
+    "@vueuse/core": "^9.13.0",
+    "agora-rtc-sdk-ng": "^4.18.2",
+    "axios": "^1.5.0",
+    "element-plus": "^2.3.14",
+    "tinymce": "^6.7.0",
+    "vant": "^4.6.8",
+    "vconsole": "^3.15.1",
+    "vue": "^3.3.4",
+    "vue-router": "^4.2.4"
   },
   "devDependencies": {
     "@antfu/eslint-config": "^0.27.0",
-    "@iconify/json": "^2.2.5",
-    "@types/node": "^18.11.18",
+    "@iconify/json": "^2.2.116",
+    "@types/node": "^18.17.16",
     "@vitejs/plugin-basic-ssl": "^1.0.1",
-    "@vitejs/plugin-vue": "^4.0.0",
+    "@vitejs/plugin-legacy": "^4.1.1",
+    "@vitejs/plugin-vue": "^4.3.4",
     "@windicss/plugin-scrollbar": "^1.2.3",
-    "eslint": "^8.31.0",
+    "eslint": "^8.49.0",
     "husky": "^8.0.3",
     "magic-string": "^0.26.7",
-    "sass": "^1.57.1",
-    "typescript": "^4.9.4",
+    "sass": "^1.67.0",
+    "typescript": "^4.9.5",
     "unplugin-auto-import": "^0.10.3",
     "unplugin-icons": "^0.14.15",
     "unplugin-vue-components": "^0.22.12",
-    "vite": "^4.0.4",
-    "vite-plugin-windicss": "^1.8.10",
-    "vue-tsc": "^1.0.24",
+    "vite": "^4.4.9",
+    "vite-plugin-top-level-await": "^1.3.1",
+    "vite-plugin-windicss": "^1.9.1",
+    "vue-tsc": "^1.8.11",
     "windicss": "^3.5.6"
   }
 }

文件差异内容过多而无法显示
+ 2609 - 892
pnpm-lock.yaml


+ 33 - 1
src/store/user.ts

@@ -1,4 +1,5 @@
 import { IUser } from './user.d';
+import axios from 'axios'
 // #ifdef DEV
 import dictionary from './user.store';
 console.groupCollapsed('user');
@@ -19,7 +20,38 @@ console.log('user :>> ', user);
 export default user
 
 const ROLE_MAP: { [key: string]: 'teacher' | 'student' } = { '72': 'teacher', '75': 'teacher', '76': 'student' }
-export const UserRole: 'teacher' | 'student' | 'admin' | 'other' = user.sm_info.sm_id === '739' ? 'admin' : (ROLE_MAP[user.user_role_id] ?? 'other')
+let TempUserRole: 'teacher' | 'student' | 'admin' | 'other' = user.sm_info.sm_id === '739' ? 'admin' : (ROLE_MAP[user.user_role_id] ?? 'other')
+
+await axios.create({
+  baseURL: window.GLOBAL_CONFIG.api,
+  timeout: 6 * 1000,
+  headers: {
+    'Content-Type': 'application/x-www-form-urlencoded',
+  },
+  method: 'post',
+})({
+  url: '/dyaw/xlfw_pbgl/index',
+  data: {
+    token: user.token,
+    client: 'web',
+    site: 'dyaw',
+    api: 'json',
+    user_id: user.user_id
+  }
+}).then(resp => {
+  const res = resp.data
+  if (res.code === '1') {
+    if (res.data.page_data?.length >= 1) {
+      if (TempUserRole === 'admin')
+        TempUserRole = 'teacher'
+    }
+  }
+})
+
+
+export const UserRole = TempUserRole
+
+console.log('UserRole : ', UserRole)
 
 // #ifdef DEV
 document.title = `${UserRole.toLocaleUpperCase()}-${document.title}`

+ 31 - 0
vite.config.ts

@@ -9,6 +9,8 @@ import Icons from 'unplugin-icons/vite'
 import IconsResolver from 'unplugin-icons/resolver'
 import ConditionalCompile from './plugins/vite-plugin-conditional-compile'
 import basicSsl from '@vitejs/plugin-basic-ssl'
+import topLevelAwait from 'vite-plugin-top-level-await'
+import legacy from '@vitejs/plugin-legacy'
 
 // https://vitejs.dev/config/
 export default defineConfig({
@@ -39,6 +41,35 @@ export default defineConfig({
     },
   },
   plugins: [
+    legacy({
+      targets: ['defaults', 'ie >= 11', 'chrome 52'],  //需要兼容的目标列表,可以设置多个
+      additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
+      renderLegacyChunks: true,
+      polyfills: [
+        'es.symbol',
+        'es.array.filter',
+        'es.promise',
+        'es.promise.finally',
+        'es/map',
+        'es/set',
+        'es.array.for-each',
+        'es.object.define-properties',
+        'es.object.define-property',
+        'es.object.get-own-property-descriptor',
+        'es.object.get-own-property-descriptors',
+        'es.object.keys',
+        'es.object.to-string',
+        'web.dom-collections.for-each',
+        'esnext.global-this',
+        'esnext.string.match-all'
+      ]
+    }),
+    topLevelAwait({
+      // The export name of top-level await promise for each chunk module
+      promiseExportName: '__tla',
+      // The function to generate import names of top-level await promise in each chunk module
+      promiseImportName: i => `__tla_${i}`
+    }),
     basicSsl(),
     ConditionalCompile(),
     vue({