Michael Wang hace 3 años
padre
commit
69d1c23564
Se han modificado 12 ficheros con 239 adiciones y 10 borrados
  1. 8 0
      .editorconfig
  2. 73 0
      .eslintrc.js
  3. 6 1
      .vscode/extensions.json
  4. 1 1
      index.html
  5. 3 1
      package.json
  6. 41 0
      pnpm-lock.yaml
  7. 6 0
      postcss.config.js
  8. 27 0
      prebuild.mjs
  9. 4 0
      prettier.config.js
  10. 12 0
      tailwind.config.js
  11. 17 3
      tsconfig.json
  12. 41 4
      vite.config.ts

+ 8 - 0
.editorconfig

@@ -0,0 +1,8 @@
+# http://editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+end_of_line = lf

+ 73 - 0
.eslintrc.js

@@ -0,0 +1,73 @@
+/**
+ * @type {import("eslint").Linter.Config}
+ */
+module.exports = {
+  root: true,
+  env: {
+    node: true,
+    browser: true,
+    "vue/setup-compiler-macros": true,
+  },
+  parser: "@typescript-eslint/parser",
+  parserOptions: {
+    ecmaVersion: "2021",
+    sourceType: "module",
+    ecmaFeatures: {
+      jsx: true,
+    },
+    tsconfigRootDir: "./",
+    project: ["tsconfig.json"],
+    extraFileExtensions: [".vue", ".config.js"],
+  },
+  plugins: ["@typescript-eslint"],
+  extends: [
+    "eslint:recommended",
+    "plugin:@typescript-eslint/recommended",
+    "plugin:@typescript-eslint/recommended-requiring-type-checking",
+    "plugin:vue/vue3-recommended",
+    "prettier",
+  ],
+  rules: {
+    "@typescript-eslint/no-explicit-any": "off",
+    "@typescript-eslint/ban-ts-comment": "off",
+    "@typescript-eslint/no-unsafe-assignment": "off",
+    "@typescript-eslint/no-unsafe-member-access": "off",
+    "@typescript-eslint/restrict-plus-operands": "off",
+    "@typescript-eslint/restrict-template-expressions": "off",
+    "@typescript-eslint/no-non-null-assertion": "off",
+    // 一处使用hypen和一处不使用hypen,让字符搜索变得困难
+    "vue/attribute-hyphenation": ["error", "never"],
+    "vue/v-on-event-hyphenation": ["error", "never", { autofix: true }],
+    "vue/no-v-html": "off",
+  },
+  ignorePatterns: [
+    ".eslintrc.js",
+    "vite.config.ts",
+    "src/test",
+    "prebuild.mjs",
+  ],
+  overrides: [
+    {
+      files: ["src/**/**.vue"],
+      parser: "vue-eslint-parser",
+      parserOptions: {
+        parser: {
+          // Script parser for `<script>`
+          js: "espree",
+          // Script parser for `<script lang="ts">`
+          ts: "@typescript-eslint/parser",
+          // Script parser for vue directives (e.g. `v-if=` or `:attribute=`)
+          // and vue interpolations (e.g. `{{variable}}`).
+          // If not specified, the parser determined by `<script lang ="...">` is used.
+          "<template>": "espree",
+        },
+        project: ["tsconfig.json"],
+      },
+      globals: {
+        $ref: true,
+        $computed: true,
+        $$: true,
+      },
+    },
+  ],
+};

+ 6 - 1
.vscode/extensions.json

@@ -1,3 +1,8 @@
 {
-  "recommendations": ["johnsoncodehk.volar"]
+  "recommendations": [
+    "johnsoncodehk.volar",
+    "bradlc.vscode-tailwindcss",
+    "esbenp.prettier-vscode",
+    "phoenisx.cssvar"
+  ]
 }

+ 1 - 1
index.html

@@ -4,7 +4,7 @@
     <meta charset="UTF-8" />
     <link rel="icon" href="/favicon.ico" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>Vite App</title>
+    <title>网考学生端</title>
   </head>
   <body>
     <div id="app"></div>

+ 3 - 1
package.json

@@ -20,6 +20,8 @@
     "lodash-es": "^4.17.21",
     "tailwindcss": "^3.0.23",
     "ua-parser-js": "^1.0.2",
+    "moment": "^2.29.1",
+    "pinia": "^2.0.11",
     "vue": "^3.2.31",
     "vue-router": "^4.0.12"
   },
@@ -42,4 +44,4 @@
     "vue-eslint-parser": "^8.3.0",
     "vue-tsc": "^0.31.4"
   }
-}
+}

+ 41 - 0
pnpm-lock.yaml

@@ -15,6 +15,8 @@ specifiers:
   eslint-config-prettier: ^8.4.0
   eslint-plugin-vue: ^8.5.0
   lodash-es: ^4.17.21
+  moment: ^2.29.1
+  pinia: ^2.0.11
   postcss: ^8.4.7
   prettier: ^2.5.1
   tailwindcss: ^3.0.23
@@ -32,6 +34,8 @@ dependencies:
   axios-progress-bar: 1.2.0_axios@0.26.0
   axios-retry: 3.2.4
   lodash-es: 4.17.21
+  moment: 2.29.1
+  pinia: 2.0.11_typescript@4.5.5+vue@3.2.31
   tailwindcss: 3.0.23_autoprefixer@10.4.2
   ua-parser-js: 1.0.2
   vue: 3.2.31
@@ -1608,6 +1612,10 @@ packages:
     resolution: {integrity: sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==}
     dev: false
 
+  /moment/2.29.1:
+    resolution: {integrity: sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==}
+    dev: false
+
   /ms/2.1.2:
     resolution: {integrity: sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk=, tarball: ms/download/ms-2.1.2.tgz}
     dev: true
@@ -1702,6 +1710,24 @@ packages:
     resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
     engines: {node: '>=8.6'}
 
+  /pinia/2.0.11_typescript@4.5.5+vue@3.2.31:
+    resolution: {integrity: sha512-JzcmnMqu28PNWOjDgEDK6fTrIzX8eQZKPPKvu/fpHdpXARUj1xeVdFi3YFIMOWswqaBd589cpmAMdSSTryI9iw==}
+    peerDependencies:
+      '@vue/composition-api': ^1.4.0
+      typescript: '>=4.4.4'
+      vue: ^2.6.14 || ^3.2.0
+    peerDependenciesMeta:
+      '@vue/composition-api':
+        optional: true
+      typescript:
+        optional: true
+    dependencies:
+      '@vue/devtools-api': 6.0.12
+      typescript: 4.5.5
+      vue: 3.2.31
+      vue-demi: 0.12.1_vue@3.2.31
+    dev: false
+
   /postcss-js/4.0.0_postcss@8.4.7:
     resolution: {integrity: sha512-77QESFBwgX4irogGVPgQ5s07vLvFqWr228qZY+w6lW599cRlK/HmnlivnnVUxkjHnCu4J16PDMHcH+e+2HbvTQ==}
     engines: {node: ^12 || ^14 || >= 16}
@@ -2290,6 +2316,21 @@ packages:
       vscode-typescript-languageservice: 0.31.4
     dev: true
 
+  /vue-demi/0.12.1_vue@3.2.31:
+    resolution: {integrity: sha512-QL3ny+wX8c6Xm1/EZylbgzdoDolye+VpCXRhI2hug9dJTP3OUJ3lmiKN3CsVV3mOJKwFi0nsstbgob0vG7aoIw==}
+    engines: {node: '>=12'}
+    hasBin: true
+    requiresBuild: true
+    peerDependencies:
+      '@vue/composition-api': ^1.0.0-rc.1
+      vue: ^3.0.0-0 || ^2.6.0
+    peerDependenciesMeta:
+      '@vue/composition-api':
+        optional: true
+    dependencies:
+      vue: 3.2.31
+    dev: false
+
   /vue-eslint-parser/8.3.0_eslint@8.10.0:
     resolution: {integrity: sha512-dzHGG3+sYwSf6zFBa0Gi9ZDshD7+ad14DGOdTLjruRVgZXe2J+DcZ9iUhyR48z5g1PqRa20yt3Njna/veLJL/g==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}

+ 6 - 0
postcss.config.js

@@ -0,0 +1,6 @@
+module.exports = {
+  plugins: {
+    tailwindcss: {},
+    autoprefixer: {},
+  },
+}

+ 27 - 0
prebuild.mjs

@@ -0,0 +1,27 @@
+import { writeFileSync } from "fs";
+import { execSync } from "child_process";
+import moment from "moment";
+import packageJson from "./package.json" assert { type: "json" };
+
+console.log("> prebuild");
+console.log("> prebuild create .env.*.local");
+
+// const packageJson = require("./package.json");
+
+const buildDate = moment().format("YYYY-MM-DD HH:mm:ss");
+console.log("  构建日期为 " + buildDate);
+
+// eslint-disable-next-line @typescript-eslint/no-unsafe-call
+const revision = execSync("git rev-parse HEAD").toString().trim().slice(0, 7);
+console.log("  当前的git版本为 " + revision);
+
+// eslint-disable-next-line @typescript-eslint/no-unsafe-call
+writeFileSync(
+  ".env.production.local",
+  `VITE_FE_VERSION=${packageJson.version}
+VITE_BUILD_DATE=${buildDate}
+VITE_GIT_REPO_VERSION=${revision}
+`
+);
+
+console.log();

+ 4 - 0
prettier.config.js

@@ -0,0 +1,4 @@
+module.exports = {
+  // Default value changed from none to es5 in v2.0.0
+  // trailingComma: "es5",
+};

+ 12 - 0
tailwind.config.js

@@ -0,0 +1,12 @@
+module.exports = {
+  content: ["./index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
+  prefix: "tw-",
+  darkMode: "media", // or 'media' or 'class'
+  theme: {
+    extend: {},
+  },
+  variants: {
+    extend: {},
+  },
+  plugins: [],
+};

+ 17 - 3
tsconfig.json

@@ -7,10 +7,24 @@
     "strict": true,
     "jsx": "preserve",
     "sourceMap": true,
+    "isolatedModules": true,
     "resolveJsonModule": true,
     "esModuleInterop": true,
-    "lib": ["esnext", "dom"]
+    "lib": ["esnext", "dom"],
+    "types": ["./node_modules/vite/client", "./node_modules/vue/macros-global"],
+    "baseUrl": "./",
+    "paths": {
+      "@/*": ["src/*"]
+    }
   },
-  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
-  "references": [{ "path": "./tsconfig.node.json" }]
+  "include": [
+    ".eslintrc.js",
+    "src/**/*.ts",
+    "src/**/*.d.ts",
+    "src/**/*.tsx",
+    "src/**/*.vue",
+    "src/*.vue",
+    "*.js",
+    "components.d.ts"
+  ]
 }

+ 41 - 4
vite.config.ts

@@ -1,7 +1,44 @@
-import { defineConfig } from 'vite'
-import vue from '@vitejs/plugin-vue'
+import { defineConfig } from "vite";
+import vue from "@vitejs/plugin-vue";
+import ViteComponents from "unplugin-vue-components/vite";
+import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
+
+const SERVER_URL = "https://192.168.10.39";
+const path = require("path");
 
 // https://vitejs.dev/config/
 export default defineConfig({
-  plugins: [vue()]
-})
+  plugins: [
+    vue({
+      reactivityTransform: true,
+    }),
+    ViteComponents({
+      resolvers: [AntDesignVueResolver()],
+      dts: true,
+    }),
+  ],
+  server: {
+    port: 3000,
+    // strictPort: true,
+    fs: {
+      strict: true,
+      allow: ["./"],
+    },
+    proxy: {
+      "/api": {
+        target: SERVER_URL,
+        changeOrigin: true,
+      },
+    },
+  },
+  resolve: {
+    alias: [{ find: "@", replacement: path.resolve(__dirname, "./src") }],
+    extensions: [".js", ".mjs", ".ts", ".vue", ".json", ".scss", ".css"],
+  },
+  build: {
+    ssr: false,
+  },
+  // define: {
+  //   __VUE_PROD_DEVTOOLS__: true, // no effect
+  // },
+});