Quellcode durchsuchen

refactor: 移除与UNI_PLATFORM相关的代码

不再需要处理不同平台的特殊逻辑,简化代码结构
feige996 vor 7 Monaten
Ursprung
Commit
b4273c7d95
4 geänderte Dateien mit 0 neuen und 30 gelöschten Zeilen
  1. 0 1
      src/env.d.ts
  2. 0 2
      src/http/interceptor.ts
  3. 0 26
      src/utils/platform.ts
  4. 0 1
      vite.config.ts

+ 0 - 1
src/env.d.ts

@@ -33,4 +33,3 @@ interface ImportMeta {
 }
 }
 
 
 declare const __VITE_APP_PROXY__: 'true' | 'false'
 declare const __VITE_APP_PROXY__: 'true' | 'false'
-declare const __UNI_PLATFORM__: 'app' | 'h5' | 'mp-alipay' | 'mp-baidu' | 'mp-kuaishou' | 'mp-lark' | 'mp-qq' | 'mp-tiktok' | 'mp-weixin' | 'mp-xiaochengxu'

+ 0 - 2
src/http/interceptor.ts

@@ -1,7 +1,6 @@
 import type { CustomRequestOptions } from '@/http/types'
 import type { CustomRequestOptions } from '@/http/types'
 import { useTokenStore } from '@/store'
 import { useTokenStore } from '@/store'
 import { getEnvBaseUrl } from '@/utils'
 import { getEnvBaseUrl } from '@/utils'
-import { platform } from '@/utils/platform'
 import { stringifyQuery } from './tools/queryString'
 import { stringifyQuery } from './tools/queryString'
 
 
 // 请求基准地址
 // 请求基准地址
@@ -44,7 +43,6 @@ const httpInterceptor = {
     options.header = {
     options.header = {
       ...options.header,
       ...options.header,
       'Content-Type': 'application/json; charset=utf-8',
       'Content-Type': 'application/json; charset=utf-8',
-      platform, // 可选,与 uniapp 定义的平台一致,告诉后台来源
     }
     }
     // 3. 添加 token 请求头标识
     // 3. 添加 token 请求头标识
     const tokenStore = useTokenStore()
     const tokenStore = useTokenStore()

+ 0 - 26
src/utils/platform.ts

@@ -1,26 +0,0 @@
-/*
- * @Author: 菲鸽
- * @Date: 2024-03-28 19:13:55
- * @Last Modified by: 菲鸽
- * @Last Modified time: 2024-03-28 19:24:55
- */
-export const platform = __UNI_PLATFORM__
-export const isH5 = __UNI_PLATFORM__ === 'h5'
-export const isApp = __UNI_PLATFORM__ === 'app'
-export const isMp = __UNI_PLATFORM__.startsWith('mp-')
-export const isMpWeixin = __UNI_PLATFORM__.startsWith('mp-weixin')
-export const isMpAplipay = __UNI_PLATFORM__.startsWith('mp-alipay')
-export const isMpToutiao = __UNI_PLATFORM__.startsWith('mp-toutiao')
-export const isHarmony = __UNI_PLATFORM__.startsWith('app-harmony')
-
-const PLATFORM = {
-  platform,
-  isH5,
-  isApp,
-  isMp,
-  isMpWeixin,
-  isMpAplipay,
-  isMpToutiao,
-  isHarmony,
-}
-export default PLATFORM

+ 0 - 1
vite.config.ts

@@ -138,7 +138,6 @@ export default defineConfig(({ command, mode }) => {
       openDevTools(),
       openDevTools(),
     ],
     ],
     define: {
     define: {
-      __UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
       __VITE_APP_PROXY__: JSON.stringify(VITE_APP_PROXY_ENABLE),
       __VITE_APP_PROXY__: JSON.stringify(VITE_APP_PROXY_ENABLE),
     },
     },
     css: {
     css: {