Ver código fonte

wip: 基础内容补充

王家程 11 meses atrás
pai
commit
ccfb5ab026

+ 11 - 2
.env.development

@@ -2,10 +2,19 @@
  # @Author: wjc
  # @Date: 2023-05-30 10:50:23
  # @LastEditors: wjc
- # @LastEditTime: 2024-05-08 14:40:26
+ # @LastEditTime: 2024-06-05 11:04:36
  # @Description: 
 ### 
 VITE_ENV = 'development'
 
 # base api
-VITE_APP_BASE_API = 'https://s.mooeen.com'
+VITE_APP_BASE_API = 'https://wy-test.huiguanjia.cn/9ad134a361f8d778/'
+
+VITE_AMAPIOS_KEY = "96447224d7ce6a099f9b100c14b8584a"
+VITE_AMAP_ANDROID_KEY = "27b7d28dab0c4857b9177c7a59cf33f2"
+
+VITE_BMAP_IOS_KEY = "Oa8GWARg5hX1NymZFkoEyNjYjRESYA9A"
+VITE_BMAP_ANDROID_KEY = "D5sf2hXHa4qczmP4KHNkejUdsH2lh7Am"
+
+VITE_JPUSH_IOS_KEY = "163cf8502893e809bad8f796"
+VITE_JPUSH_ANDROID_KEY = "41b513e2ee2ef56590a0115a"

+ 13 - 0
.env.production

@@ -0,0 +1,13 @@
+VITE_ENV = 'production'
+
+# base api
+VITE_APP_BASE_API = 'https://wy.huiguanjia.cn/9ad134a361f8d778/'
+
+VITE_AMAPIOS_KEY = "96447224d7ce6a099f9b100c14b8584a"
+VITE_AMAP_ANDROID_KEY = "27b7d28dab0c4857b9177c7a59cf33f2"
+
+VITE_BMAP_IOS_KEY = "Oa8GWARg5hX1NymZFkoEyNjYjRESYA9A"
+VITE_BMAP_ANDROID_KEY = "lrkZs4kiUEVXNfC6F9vojHXVOwkVUapd"
+
+VITE_JPUSH_IOS_KEY = "163cf8502893e809bad8f796"
+VITE_JPUSH_ANDROID_KEY = "163cf8502893e809bad8f796"

+ 20 - 0
.env.test

@@ -0,0 +1,20 @@
+###
+ # @Author: wjc
+ # @Date: 2024-06-05 10:30:53
+ # @LastEditors: wjc
+ # @LastEditTime: 2024-06-05 11:04:41
+ # @Description: 
+### 
+VITE_ENV = 'test'
+
+# base api
+VITE_APP_BASE_API = 'https://wy-test.huiguanjia.cn/9ad134a361f8d778/'
+
+VITE_AMAPIOS_KEY = "96447224d7ce6a099f9b100c14b8584a"
+VITE_AMAP_ANDROID_KEY = "27b7d28dab0c4857b9177c7a59cf33f2"
+
+VITE_BMAP_IOS_KEY = "Oa8GWARg5hX1NymZFkoEyNjYjRESYA9A"
+VITE_BMAP_ANDROID_KEY = "D5sf2hXHa4qczmP4KHNkejUdsH2lh7Am"
+
+VITE_JPUSH_IOS_KEY = "163cf8502893e809bad8f796"
+VITE_JPUSH_ANDROID_KEY = "41b513e2ee2ef56590a0115a"

+ 2 - 0
.eslintignore

@@ -0,0 +1,2 @@
+src/uni_modules/
+types/**

+ 63 - 0
.eslintrc

@@ -0,0 +1,63 @@
+{
+  "env": {
+    "browser": true,
+    "node": true,
+  },
+  "extends": [
+    "eslint:recommended",
+    "plugin:vue/vue3-recommended",
+    "plugin:import/recommended",
+    "prettier",
+    "plugin:prettier/recommended",
+  ],
+  "parser": "vue-eslint-parser",
+  "parserOptions": {
+    "ecmaVersion": 2020,
+    // 指定eslint解析器
+    "parser": "@typescript-eslint/parser",
+    // 允许使用 import
+    "sourceType": "module",
+    // 允许解析 jsx
+    "ecmaFeatures": {
+      "jsx": true,
+    },
+  },
+  "plugins": ["vue", "@typescript-eslint", "prettier", "import"],
+  "settings": {
+    "import/resolver": {
+      "typescript": {
+        "alwaysTryTypes": true,
+      },
+    },
+  },
+  "globals": {
+    "uni": true,
+    "UniApp": true,
+    "wx": true,
+    "getCurrentPages": true,
+    "UniHelper": true,
+    "Page": true,
+    "App": true,
+    "NodeJS": true,
+  },
+  "rules": {
+    "prettier/prettier": "error",
+    "vue/no-mutating-props": [
+      "error",
+      {
+        "shallowOnly": true, // 启用更改props值但保持引用不变的功能
+      },
+    ],
+    "no-undef": "off",
+    "vue/no-multiple-template-root": "off",
+    "vue/valid-template-root": [0],
+    "vue/no-reserved-component-names": "off",
+    "vue/multi-word-component-names": [0],
+    "@typescript-eslint/no-explicit-any": "off",
+    "@typescript-eslint/ban-ts-ignore": "off",
+    "@typescript-eslint/ban-ts-comment": [0],
+    "@typescript-eslint/no-unused-vars": [0],
+    "@typescript-eslint/no-var-requires": [0],
+    "import/no-unresolved": "off",
+  },
+}

+ 0 - 58
.eslintrc.js

@@ -1,58 +0,0 @@
-/*
- * @Author: wjc
- * @Date: 2024-05-27 11:53:23
- * @LastEditors: wjc
- * @LastEditTime: 2024-06-05 09:24:04
- * @Description:
- */
-module.exports = {
-  env: {
-    browser: true,
-    node: true,
-  },
-  extends: [
-    'eslint:recommended',
-    'plugin:vue/vue3-recommended',
-    'plugin:@typescript-eslint/recommended',
-    'plugin:import/recommended',
-    'prettier',
-    'plugin:prettier/recommended',
-  ],
-  parser: 'vue-eslint-parser',
-  parserOptions: {
-    ecmaVersion: 2020,
-    // 指定eslint解析器
-    parser: '@typescript-eslint/parser',
-    // 允许使用 import
-    sourceType: 'module',
-    // 允许解析 jsx
-    ecmaFeatures: {
-      jsx: true,
-    },
-  },
-  plugins: ['vue', '@typescript-eslint', 'prettier', 'import'],
-  settings: {
-    'import/resolver': {
-      typescript: {
-        alwaysTryTypes: true,
-      },
-    },
-  },
-  rules: {
-    'vue/no-mutating-props': [
-      'error',
-      {
-        shallowOnly: true, // 启用更改props值但保持引用不变的功能
-      },
-    ],
-    'import/no-unresolved': 'off',
-    'vue/valid-template-root': [0],
-    'vue/no-reserved-component-names': 'off',
-    'vue/multi-word-component-names': [1],
-    '@typescript-eslint/no-explicit-any': 'off',
-    '@typescript-eslint/ban-ts-comment': [0],
-    '@typescript-eslint/no-unused-vars': [0],
-    // 'space-before-function-paren': 1,
-    // 'no-unused-vars': 'off',
-  },
-}

+ 7 - 1
.stylelintrc.js

@@ -2,7 +2,7 @@
  * @Author: wjc
  * @Date: 2024-05-29 17:32:17
  * @LastEditors: wjc
- * @LastEditTime: 2024-05-29 17:58:47
+ * @LastEditTime: 2024-06-05 17:39:01
  * @Description:
  */
 module.exports = {
@@ -34,6 +34,12 @@ module.exports = {
         ignoreUnits: ['rpx'],
       },
     ],
+    'selector-type-no-unknown': [
+      true,
+      {
+        ignoreTypes: ['page'],
+      },
+    ],
     'color-function-notation': ['legacy', { ignore: ['with-var-inside'] }],
     // 这里使用正则表达式允许选择器中出现短横线和下划线。
     'selector-class-pattern': '^[a-z][a-zA-Z0-9_-]+$',

+ 4 - 3
package.json

@@ -29,8 +29,10 @@
     "@dcloudio/uni-ui": "^1.5.5",
     "@iconify-json/ep": "^1.1.15",
     "@unocss/reset": "^0.60.3",
+    "clipboard": "^2.0.11",
     "dayjs": "^1.11.11",
     "pinia": "^2.1.7",
+    "pinia-plugin-persistedstate": "^3.2.1",
     "unocss": "^0.58.3",
     "uview-plus": "^3.2.22",
     "vue": "^3.4.27",
@@ -51,9 +53,8 @@
     "@vue/runtime-core": "^3.4.27",
     "@vue/tsconfig": "^0.5.1",
     "commitlint": "^19.3.0",
-    "eslint": "^8.57.0",
+    "eslint": "8.56.0",
     "eslint-config-prettier": "^9.1.0",
-    "eslint-config-standard": "^17.1.0",
     "eslint-import-resolver-typescript": "^3.6.1",
     "eslint-plugin-import": "^2.29.1",
     "eslint-plugin-n": "^17.7.0",
@@ -65,7 +66,7 @@
     "postcss": "^8.4.38",
     "postcss-html": "^1.7.0",
     "postcss-scss": "^4.0.9",
-    "prettier": "^3.2.5",
+    "prettier": "^3.3.0",
     "sass": "^1.77.2",
     "sass-loader": "^14.2.1",
     "stylelint": "16.0.2",

Diferenças do arquivo suprimidas por serem muito extensas
+ 240 - 241
pnpm-lock.yaml


+ 1 - 1
prettier.config.js

@@ -2,7 +2,7 @@
  * @Author: wjc
  * @Date: 2023-05-07 12:04:34
  * @LastEditors: wjc
- * @LastEditTime: 2024-05-27 17:33:13
+ * @LastEditTime: 2024-06-06 10:52:03
  * @Description:
  */
 module.exports = {

+ 5 - 1
src/App.vue

@@ -2,7 +2,7 @@
  * @Author: wjc
  * @Date: 2024-05-27 11:50:13
  * @LastEditors: wjc
- * @LastEditTime: 2024-06-05 09:45:34
+ * @LastEditTime: 2024-06-05 17:25:51
  * @Description: 
 -->
 <script setup lang="ts">
@@ -22,4 +22,8 @@
 <style lang="scss">
   /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
   @import 'uview-plus/index';
+
+  page {
+    @apply h-full;
+  }
 </style>

+ 6 - 1
src/main.ts

@@ -2,20 +2,25 @@
  * @Author: wjc
  * @Date: 2024-05-27 11:49:45
  * @LastEditors: wjc
- * @LastEditTime: 2024-05-29 17:03:27
+ * @LastEditTime: 2024-06-05 16:44:22
  * @Description:
  */
 import { createSSRApp } from 'vue'
+import * as Pinia from 'pinia'
 import uviewPlus from 'uview-plus'
 import 'virtual:uno.css'
+import { setupStores } from '@/stores'
 
 import App from './App.vue'
 
 export function createApp() {
   const app = createSSRApp(App)
+
   app.use(uviewPlus)
+  setupStores(app)
 
   return {
     app,
+    Pinia,
   }
 }

+ 1 - 0
src/models/appTypes.ts

@@ -0,0 +1 @@
+export interface AppState {}

+ 10 - 0
src/models/userTypes.ts

@@ -0,0 +1,10 @@
+/*
+ * @Author: wjc
+ * @Date: 2024-06-05 17:14:01
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-06-05 17:14:47
+ * @Description:
+ */
+export interface UserState {
+  isInstall: boolean
+}

+ 32 - 24
src/pages.json

@@ -1,24 +1,32 @@
-{
-	"easycom": {
-		"autoscan" : true,
-		"custom": {
-			"^u-(.*)": "uview-plus/components/u-$1/u-$1.vue",
-			"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
-		}
-	},
-	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
-		{
-			"path": "pages/index/index",
-			"style": {
-				"navigationBarTitleText": "uni-app"
-			}
-		}
-	],
-	"globalStyle": {
-		"navigationBarTextStyle": "black",
-		"navigationBarTitleText": "uni-app",
-		"navigationBarBackgroundColor": "#F8F8F8",
-		"backgroundColor": "#F8F8F8"
-	},
-	"uniIdRouter": {}
-}
+{
+	"easycom": {
+		"autoscan": true,
+		"custom": {
+			"^u--(.*)": "uview-plus/components/u-$1/u-$1.vue",
+			"^up-(.*)": "uview-plus/components/u-$1/u-$1.vue",
+			"^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue",
+			"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
+		}
+	},
+	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
+		{
+			"path": "pages/splash/index",
+			"style": {
+				"navigationStyle": "custom"
+			}
+		},
+		{
+			"path": "pages/index/index",
+			"style": {
+				"navigationBarTitleText": "uni-app"
+			}
+		}
+	],
+	"globalStyle": {
+		"navigationBarTextStyle": "black",
+		"navigationBarTitleText": "uni-app",
+		"navigationBarBackgroundColor": "#F8F8F8",
+		"backgroundColor": "#F8F8F8"
+	},
+	"uniIdRouter": {}
+}

+ 39 - 0
src/pages/splash/index.vue

@@ -0,0 +1,39 @@
+<!--
+ * @Author: wjc
+ * @Date: 2024-06-05 15:04:50
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-06-05 17:27:16
+ * @Description: 
+-->
+<template>
+  <view class="splash-container">
+    <template v-if="isInstall">
+      <image :src="splash" class="splash-img"></image>
+    </template>
+    <up-swiper v-else :list="list" height="100vh" :autoplay="false"></up-swiper>
+  </view>
+</template>
+
+<script setup lang="ts">
+  import { useUserStore } from '@/stores/modules/userStore'
+
+  import guide1 from '@/static/images/guide1.png'
+  import guide2 from '@/static/images/guide2.png'
+  import guide3 from '@/static/images/guide3.png'
+  import splash from '@/static/images/splash.png'
+
+  defineOptions({ name: 'Splash' })
+
+  const userStore = useUserStore()
+  const isInstall = computed(() => userStore.isInstall)
+  const list = ref([guide1, guide2, guide3])
+</script>
+
+<style scoped lang="scss">
+  .splash-container {
+    @apply wh-full;
+    .splash-img {
+      @apply wh-full;
+    }
+  }
+</style>

BIN
src/static/images/guide1.png


BIN
src/static/images/guide2.png


BIN
src/static/images/guide3.png


BIN
src/static/images/qidong.png


BIN
src/static/images/splash.png


+ 19 - 0
src/stores/index.ts

@@ -0,0 +1,19 @@
+/*
+ * @Author: wjc
+ * @Date: 2024-06-05 11:23:46
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-06-05 11:26:42
+ * @Description:
+ */
+import type { App } from 'vue'
+import * as Pinia from 'pinia'
+import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
+
+const store = Pinia.createPinia()
+store.use(piniaPluginPersistedstate)
+
+export function setupStores(app: App<Element>) {
+  app.use(store)
+}
+
+export { store }

+ 17 - 0
src/stores/modules/appStore.ts

@@ -0,0 +1,17 @@
+/*
+ * @Author: wjc
+ * @Date: 2024-06-05 11:22:45
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-06-05 17:16:15
+ * @Description:
+ */
+import { defineStore } from 'pinia'
+
+import type { AppState } from '@/models/appTypes'
+
+export const useAppStore = defineStore('app', {
+  state: (): AppState => {
+    return {}
+  },
+  actions: {},
+})

+ 19 - 0
src/stores/modules/userStore.ts

@@ -0,0 +1,19 @@
+/*
+ * @Author: wjc
+ * @Date: 2024-06-05 17:13:30
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-06-05 17:19:23
+ * @Description:
+ */
+import { defineStore } from 'pinia'
+
+import type { UserState } from '@/models/userTypes'
+
+export const useUserStore = defineStore('user', {
+  state: (): UserState => {
+    return {
+      isInstall: true,
+    }
+  },
+  actions: {},
+})

+ 42 - 0
src/utils/request/checkStatus.ts

@@ -0,0 +1,42 @@
+/*
+ * @Author: wjc
+ * @Date: 2024-06-05 10:36:43
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-06-05 17:48:00
+ * @Description:
+ */
+export function checkStatus(status: number, msg?: string) {
+  let errMessage = ''
+
+  switch (status) {
+    case 400:
+      errMessage = `${msg}`
+      break
+    case 401:
+      errMessage = '登录超时,请重新登录'
+      break
+    case 403:
+      errMessage = '暂无权限查看'
+      break
+    case 404:
+      errMessage = '网络请求错误,未找到该资源'
+      break
+    case 500:
+      errMessage = '服务器错误,请联系管理员'
+      break
+    case 503:
+      errMessage = '服务不可用,请稍候再试'
+      break
+    default:
+      errMessage = `${msg}`
+  }
+
+  if (errMessage) {
+    uni.showToast({
+      icon: 'error',
+      title: errMessage,
+    })
+    return false
+  }
+  return true
+}

+ 33 - 0
src/utils/request/index.ts

@@ -0,0 +1,33 @@
+/*
+ * @Author: wjc
+ * @Date: 2024-06-05 10:21:23
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-06-05 17:46:23
+ * @Description:
+ */
+import { checkStatus } from './checkStatus'
+
+export type RequestOptions = UniApp.RequestOptions
+
+export const request = <T>(options: RequestOptions) => {
+  return new Promise<T>((resolve, reject) => {
+    uni.request({
+      responseType: 'json',
+      ...options,
+      success(res) {
+        if (checkStatus(res.statusCode)) {
+          reject(res)
+        } else {
+          resolve(res.data as T)
+        }
+      },
+      fail(err) {
+        uni.showToast({
+          icon: 'none',
+          title: 'error',
+        })
+        reject(err)
+      },
+    })
+  })
+}

+ 0 - 0
src/utils/settings.ts


+ 7 - 17
tsconfig.json

@@ -1,29 +1,19 @@
 {
   "compilerOptions": {
-    "target": "ES2020",
-    "useDefineForClassFields": true,
-    "lib": ["ES2020", "DOM", "DOM.Iterable"],
-    /* Bundler mode */
-    "allowImportingTsExtensions": true,
-    "resolveJsonModule": true,
-    "isolatedModules": true,
-    "noEmit": true,
-    "jsx": "preserve",
-    /* Linting */
-    "strict": true,
-    "noUnusedLocals": true,
-    "noUnusedParameters": true,
-    "noFallthroughCasesInSwitch": true,
     "composite": true,
     "skipLibCheck": true,
     "module": "ESNext",
-    "moduleResolution": "bundler",
+    "moduleResolution": "Node",
+    "resolveJsonModule": true,
+    "noImplicitThis": true,
     "allowSyntheticDefaultImports": true,
+    "allowJs": true,
+    "sourceMap": true,
     "baseUrl": ".",
     "types": ["@dcloudio/types"],
     "paths": {
-      "@/*": ["/*"],
-      "#/*": ["types/*"],
+      "@/*": ["./src/*"],
+      "#/*": ["./types/*"],
     }
   },
   "include": [

+ 7 - 8
types/global.d.ts

@@ -1,8 +1,7 @@
-/// <reference types="vite/client" />
-
-declare module '*.vue' {
-  import type { DefineComponent } from 'vue'
-  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
-  const component: DefineComponent<{}, {}, any>
-  export default component
-}
+/*
+ * @Author: wjc
+ * @Date: 2024-05-31 09:26:09
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-06-05 16:00:04
+ * @Description:
+ */

+ 12 - 0
types/images.d.ts

@@ -0,0 +1,12 @@
+/*
+ * @Author: wjc
+ * @Date: 2024-06-05 15:59:59
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-06-05 16:00:02
+ * @Description:
+ */
+declare module '*.svg'
+declare module '*.png'
+declare module '*.jpg'
+declare module '*.jpeg'
+declare module '*.gif'

+ 14 - 0
types/shims-uni.d.ts

@@ -0,0 +1,14 @@
+/*
+ * @Author: wjc
+ * @Date: 2024-06-05 15:57:41
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-06-05 17:42:44
+ * @Description:
+ */
+/// <reference types='@dcloudio/types' />
+import 'vue'
+
+declare module '@vue/runtime-core' {
+  type Hooks = App.AppInstance & Page.PageInstance
+  interface ComponentCustomOptions extends Hooks {}
+}

+ 3 - 3
vite.config.ts

@@ -2,10 +2,10 @@
  * @Author: wjc
  * @Date: 2024-05-27 10:17:11
  * @LastEditors: wjc
- * @LastEditTime: 2024-05-29 15:56:51
+ * @LastEditTime: 2024-06-06 09:42:32
  * @Description:
  */
-import path from 'path'
+import path from 'node:path'
 import { defineConfig, loadEnv } from 'vite'
 import UnoCSS from 'unocss/vite'
 import uni from '@dcloudio/vite-plugin-uni'
@@ -26,7 +26,7 @@ export default defineConfig(({ mode }) => {
   return {
     resolve: {
       alias: {
-        '@': path.resolve(__dirname, 'src'),
+        '@': pathResolve('src'),
       },
     },
     server: {

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff