| | |
| | | # h5é¨ç½²ç½ç«çbaseï¼é
ç½®å° manifest.config.ts éç h5.router.base |
| | | VITE_APP_PUBLIC_BASE=/ |
| | | |
| | | VITE_SERVER_BASEURL = 'https://ukw0y1.laf.run' |
| | | VITE_SERVER_BASEURL = 'http://192.168.12.33:8080' |
| | | VITE_UPLOAD_BASEURL = 'https://ukw0y1.laf.run/upload' |
| | | |
| | | # æäºåå¦å¯è½éè¦å¨å¾®ä¿¡å°ç¨åºé颿 ¹æ® developãtrialãrelease åå«è®¾ç½®ä¸ä¼ å°åï¼åè代ç å¦ä¸ã |
| | |
| | | # h5æ¯å¦éè¦é
置代ç |
| | | VITE_APP_PROXY=false |
| | | VITE_APP_PROXY_PREFIX = '/api' |
| | | |
| | | |
| | | # åç«¯åæ°é
ç½® |
| | | VITE_APP_CLIENT_ID = '428a8310cd442757ae699df5d894f051' |
| | |
| | | globalStyle: { |
| | | navigationStyle: 'default', |
| | | navigationBarTitleText: 'å
°å®è®¾å¤ç®¡ç', |
| | | navigationBarBackgroundColor: '#f8f8f8', |
| | | navigationBarTextStyle: 'black', |
| | | navigationBarBackgroundColor: '#4D80F0', |
| | | navigationBarTextStyle: 'white', |
| | | backgroundColor: '#FFFFFF', |
| | | }, |
| | | easycom: { |
| | |
| | | tabBar: { |
| | | custom: true, |
| | | color: '#999999', |
| | | selectedColor: '#007aff', |
| | | selectedColor: '#4D80F0', |
| | | borderStyle: 'black', |
| | | height: '50px', |
| | | fontSize: '10px', |
| | |
| | | safeAreaInsetBottom |
| | | placeholder |
| | | @change="selectTabBar" |
| | | active-color="#007aff" |
| | | active-color="#4D80F0" |
| | | inactive-color="#7d7e80" |
| | | > |
| | | <block v-for="(item, idx) in tabbarList" :key="item.path"> |
| | |
| | | readonly VITE_UPLOAD_BASEURL: string |
| | | /** æ¯å¦æ¸
é¤console */ |
| | | readonly VITE_DELETE_CONSOLE: string |
| | | readonly VITE_APP_CLIENT_ID: string |
| | | // æ´å¤ç¯å¢åé... |
| | | } |
| | | |
| | |
| | | * å¯ä»¥è®¾ç½®è·¯ç±ç½ååï¼æè
é»ååï¼çä¸å¡éè¦éåªä¸ä¸ª |
| | | * æè¿éåºä¸ºå¤§é¨åé½å¯ä»¥é便è¿å
¥ï¼æä»¥ä½¿ç¨é»åå |
| | | */ |
| | | import { useUserStore } from '@/store' |
| | | import { useUserStore, useAccessStore } from '@/store' |
| | | import { needLoginPages as _needLoginPages, getNeedLoginPages } from '@/utils' |
| | | |
| | | // TODO Check |
| | | const loginRoute = '/pages/login/index' |
| | | |
| | | const isLogined = () => { |
| | | const userStore = useUserStore() |
| | | return userStore.isLogined |
| | | const accessStore = useAccessStore() |
| | | return accessStore.isLogined |
| | | } |
| | | |
| | | const isDev = import.meta.env.DEV |
| | |
| | | "globalStyle": { |
| | | "navigationStyle": "default", |
| | | "navigationBarTitleText": "å
°å®è®¾å¤ç®¡ç", |
| | | "navigationBarBackgroundColor": "#f8f8f8", |
| | | "navigationBarTextStyle": "black", |
| | | "navigationBarBackgroundColor": "#4D80F0", |
| | | "navigationBarTextStyle": "white", |
| | | "backgroundColor": "#FFFFFF" |
| | | }, |
| | | "easycom": { |
| | |
| | | "tabBar": { |
| | | "custom": true, |
| | | "color": "#999999", |
| | | "selectedColor": "#007aff", |
| | | "selectedColor": "#4D80F0", |
| | | "borderStyle": "black", |
| | | "height": "50px", |
| | | "fontSize": "10px", |
| | |
| | | "type": "home", |
| | | "layout": "tabbar", |
| | | "style": { |
| | | "navigationStyle": "custom", |
| | | "navigationBarTitleText": "é¦é¡µ" |
| | | } |
| | | }, |
| | |
| | | "path": "pages/equ/index", |
| | | "type": "page", |
| | | "layout": "tabbar", |
| | | "needLogin": true, |
| | | "style": { |
| | | "navigationBarTitleText": "å
³äº" |
| | | } |
| | |
| | | "type": "page", |
| | | "layout": "default", |
| | | "style": { |
| | | "navigationStyle": "custom", |
| | | "navigationBarTitleText": "ç»å½" |
| | | } |
| | | }, |
¶Ô±ÈÐÂÎļþ |
| | |
| | | export interface LoginParams { |
| | | username: string; |
| | | password: string; |
| | | clientId?: string; |
| | | tenantId?: string; |
| | | grantType?: string; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import { http } from '@/utils/http' |
| | | import type { LoginParams } from './login.d' |
| | | const clientId = import.meta.env.VITE_APP_CLIENT_ID |
| | | |
| | | const DEFAULT_TENANT_ID = '000000' |
| | | const GRANT_TYPE = 'password' |
| | | |
| | | /** GET è¯·æ± */ |
| | | export const getFooAPI = (name: string) => { |
| | | return http.get<LoginParams>('/foo', { name }) |
| | | } |
| | | |
| | | /** POST è¯·æ± */ |
| | | export const login = (params: LoginParams) => { |
| | | const { username, password } = params |
| | | // æé æ°ç请æ±åæ°ï¼é¿å
ç´æ¥ä¿®æ¹åå§å¯¹è±¡ |
| | | const requestData = { |
| | | username, |
| | | password, |
| | | clientId, |
| | | tenantId: DEFAULT_TENANT_ID, |
| | | grantType: GRANT_TYPE, |
| | | } |
| | | return http.post<any>('/auth/login', requestData) |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | import { defineStore } from 'pinia' |
| | | import { ref } from 'vue' |
| | | |
| | | type AccessToken = null | string |
| | | const initState = { |
| | | access_codes: [], |
| | | access_menus: [], |
| | | access_routes: [], |
| | | access_token: null, |
| | | is_access_checked: false, |
| | | login_expired: false, |
| | | refresh_token: null, |
| | | } |
| | | |
| | | interface AccessInfo { |
| | | /** |
| | | * æéç |
| | | */ |
| | | access_codes: string[] |
| | | /** |
| | | * å¯è®¿é®çèåå表 |
| | | */ |
| | | access_menus: string[] |
| | | /** |
| | | * å¯è®¿é®çè·¯ç±å表 |
| | | */ |
| | | access_routes: string[] |
| | | /** |
| | | * ç»å½ accessToken |
| | | */ |
| | | access_token: AccessToken |
| | | /** |
| | | * æ¯å¦å·²ç»æ£æ¥è¿æé |
| | | */ |
| | | is_access_checked: boolean |
| | | /** |
| | | * ç»å½æ¯å¦è¿æ |
| | | */ |
| | | login_expired: boolean |
| | | /** |
| | | * ç»å½ accessToken |
| | | */ |
| | | refresh_token: AccessToken |
| | | } |
| | | |
| | | export const useAccessStore = defineStore( |
| | | 'access', |
| | | () => { |
| | | const accessInfo = ref<AccessInfo>({ ...initState }) |
| | | |
| | | const setAccessInfo = (val: AccessInfo) => { |
| | | accessInfo.value = val |
| | | } |
| | | const setAccessToken = (val: AccessToken) => { |
| | | accessInfo.value.access_token = val |
| | | } |
| | | |
| | | const clearAccessInfo = () => { |
| | | accessInfo.value = { ...initState } |
| | | } |
| | | // ä¸è¬æ²¡æresetéæ±ï¼ä¸éè¦çå¯ä»¥å é¤ |
| | | const reset = () => { |
| | | accessInfo.value = { ...initState } |
| | | } |
| | | const isLogined = computed(() => !!accessInfo.value.access_token) |
| | | |
| | | return { |
| | | accessInfo, |
| | | setAccessInfo, |
| | | setAccessToken, |
| | | clearAccessInfo, |
| | | isLogined, |
| | | reset, |
| | | } |
| | | }, |
| | | { |
| | | persist: true, |
| | | }, |
| | | ) |
| | |
| | | |
| | | // 模åç»ä¸å¯¼åº |
| | | export * from './user' |
| | | export * from './access' |
| | |
| | | // ä¿®æ¹æé®èæ¯è² |
| | | // --wot-button-primary-bg-color: green; |
| | | } |
| | | |
| | | // baseæåé¢è² |
| | | .text-color-base { |
| | | color: $uni-text-color; |
| | | } |
| | | .text-color-gray { |
| | | color: $uni-text-color-grey; |
| | | } |
| | | |
| | | // 徿 é¢è² |
| | | .icon-color-base { |
| | | color: $uni-color-primary; |
| | | } |
| | | |
| | | .bg-base { |
| | | background: $uni-bg-color-grey; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | /* é¢è²åé */ |
| | | |
| | | /* è¡ä¸ºç¸å
³é¢è² */ |
| | | $uni-color-primary: #007aff; |
| | | $uni-color-primary: #4D80F0; |
| | | $uni-color-success: #4cd964; |
| | | $uni-color-warning: #f0ad4e; |
| | | $uni-color-error: #dd524d; |
| | |
| | | // ç¶æç 2xxï¼åè axios ç设计 |
| | | if (res.statusCode >= 200 && res.statusCode < 300) { |
| | | // 2.1 æåæ ¸å¿æ°æ® res.data |
| | | resolve(res.data as IResData<T>) |
| | | if ((res.data as IResData<T>).code === 200) { |
| | | resolve((res.data as IResData<T>).data as IResData<T>) |
| | | } else { |
| | | uni.showToast({ |
| | | icon: 'none', |
| | | title: (res.data as IResData<T>).msg || '请æ±é误', |
| | | }) |
| | | } |
| | | } else if (res.statusCode === 401) { |
| | | // 401é误 -> æ¸
çç¨æ·ä¿¡æ¯ï¼è·³è½¬å°ç»å½é¡µ |
| | | // userStore.clearUserInfo() |
| | | // uni.navigateTo({ url: '/pages/login/login' }) |
| | | uni.navigateTo({ url: '/pages/login/index' }) |
| | | reject(res) |
| | | } else { |
| | | // å
¶ä»é误 -> æ ¹æ®å端é误信æ¯è½»æç¤º |
| | |
| | | VITE_SHOW_SOURCEMAP, |
| | | VITE_APP_PROXY, |
| | | VITE_APP_PROXY_PREFIX, |
| | | VITE_APP_CLIENT_ID, |
| | | } = env |
| | | console.log('ç¯å¢åé env -> ', env) |
| | | |