Commit 0f51d9b6 by lijiabin

【需求 17679】 perf: 优化类型删除无用代码等

parent 8e1b042a
import service from '@/utils/request/index'
import type { LoginParams, LoginResponseDto } from './types'
import type { LoginParams, LoginResponseDto, GetWxSignatureResponseDto } from './types'
import { app_config } from '@/config'
/**
......@@ -60,7 +60,7 @@ export const generateLoginKey = (data: GenerateLoginKeyData) => {
*/
export const getWxSignature = (url: string) => {
const loginType = app_config[import.meta.env.MODE]?.loginType
return service.request({
return service.request<GetWxSignatureResponseDto>({
url: '/api/auth/getSign',
method: 'POST',
data: {
......
......@@ -31,3 +31,11 @@ export interface LoginResponseDto {
hiddenName: string
signature: string
}
export interface GetWxSignatureResponseDto {
timestamp: string
nonceStr: string
signature: string
corpid: string
agentid: string
}
......@@ -180,11 +180,6 @@ export const constantsRoute = [
],
},
{
path: '/test',
name: 'Test',
component: () => import('@/test.vue'),
},
{
path: '/backend',
name: 'Backend',
component: () => import('@/views/backend/index.vue'),
......
export default function Test() {
return <el-button>测试</el-button>
}
<template>
<el-button>111111{{ a }}</el-button>
</template>
<script setup lang="ts">
const a = 33
console.log(a)
</script>
import axios, {
type AxiosInstance,
type AxiosRequestConfig,
type AxiosRequestHeaders,
type InternalAxiosRequestConfig,
} from 'axios'
import axios, { type AxiosInstance, type AxiosRequestConfig } from 'axios'
import { handleBackendError, handleRequestError, handleResponseError } from './error'
import type { BackendServiceResult } from './types'
import { useUserStore } from '@/stores/user'
......
......@@ -15,7 +15,7 @@ import type { AxiosError, AxiosResponse } from 'axios'
* 后端逻辑code报错处理
* @param backendServiceResult 后端传来错误信息
*/
export function handleBackendError(backendServiceResult: BackendServiceResult) {
export function handleBackendError<T>(backendServiceResult: BackendServiceResult<T>) {
const error: RequestServiceError = {
type: 'backend',
code: backendServiceResult.code || DEFAULT_REQUEST_ERROR_CODE,
......@@ -53,7 +53,7 @@ export function handleResponseError(response: AxiosResponse) {
* 处理请求失败
*/
type ErrorStatus = keyof typeof ERROR_STATUS
export function handleRequestError(axiosError: AxiosError<BackendServiceResult>) {
export function handleRequestError<T>(axiosError: AxiosError<BackendServiceResult<T>>) {
const error: RequestServiceError = {
type: 'axios',
code: DEFAULT_REQUEST_ERROR_CODE,
......
......@@ -24,9 +24,9 @@ interface IShareWxOption {
// }
// })
// }
export function wxShare(option: IShareWxOption) {
export async function wxShare(option: IShareWxOption) {
const url = location.href.split('#')[0]
option.link = ww.shareAppMessage({
await ww.shareAppMessage({
title: '测试一下',
desc: '让每个企业都有自己的微信',
link: url + '#' + option.link,
......
......@@ -30,8 +30,8 @@ import * as ww from '@wecom/jssdk'
// }
export async function initWxConfig() {
const url = location.href.split('#')[0]
const response = await getWxSignature(url)
console.log('response', response)
const response = await getWxSignature(url!)
// console.log('response', response)
const timestamp = response.data.timestamp //时间戳
const nonceStr = response.data.nonceStr //随机字符串
const signature = response.data.signature //签名
......
<template>
<el-button>{{ count }}</el-button>
<ElButton>{{ count }}</ElButton>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const count = ref(0)
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment