Skip to content

Commit b087de2

Browse files
committed
change
1 parent c19c601 commit b087de2

5 files changed

Lines changed: 35 additions & 44 deletions

File tree

src/api/aslsystem.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { http } from "@/utils/http";
22
// 获取图片验证码
33
export function getCodeImg(params) {
4-
return http.request("get", "/slbma/manager/captcha", { params }, {responseType: 'blob'});
4+
return http.request(
5+
"get",
6+
"/slbma/data/captcha",
7+
{ params },
8+
{ responseType: "json" },
9+
// responseType还有什么选项
10+
);
511
}
6-
7-

src/api/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ type ResultTable = {
100100
export const getLogin = (data?: object) => {
101101
console.log("进登陆借口");
102102
// slbm
103-
return http.request<UserResult>("post", "/slbma/manager/login", { data });
103+
return http.request<UserResult>("post", "/slbma/data/login", { data });
104104
};
105105

106106
/** 刷新`token` */
Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,23 @@
11
import { message } from "@/utils/message";
22
import { getCodeImg } from "@/api/aslsystem";
3-
/**
3+
/**
44
* 获取图片验证码
55
* @returns 验证码图片
66
*/
77
export const getImgCode = async () => {
8-
let key=new Date().getTime();
8+
let key = new Date().getTime();
99
let params = {
1010
key,
1111
};
12-
let blob:Blob|any = await getCodeImg(params);
12+
let blob: Blob | any = await getCodeImg(params);
1313
if (blob) {
14-
const canvas: any = document.getElementById('captchaCanvas');
15-
const ctx = canvas.getContext('2d');
16-
const img = new Image();
17-
const url = URL.createObjectURL(blob); // 将 Blob 转换为可用的 URL
18-
img.onload = function () {
19-
canvas.width = img.width;
20-
canvas.height = img.height;
21-
ctx.drawImage(img, 0, 0);
22-
URL.revokeObjectURL(url);
23-
};
24-
img.src = url;
14+
let imgElement = document.getElementById("captchaCanvas");
15+
16+
imgElement.setAttribute("src", blob.info.img); // 将 Blob 转换为可用的 URL
2517
// 将key进行缓存
26-
localStorage.setItem('slVerifyKey', JSON.stringify(key));
27-
message('获取验证码成功', { type: "success" });
18+
localStorage.setItem("slVerifyKey", JSON.stringify(key));
19+
message("获取验证码成功", { type: "success" });
2820
} else {
29-
message('获取验证码失败', { type: "error" });
21+
message("获取验证码失败", { type: "error" });
3022
}
3123
};
32-
33-
34-
35-
36-

src/components/ReImageVerify/src/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ defineExpose({ getImgCode });
1515
</script>
1616

1717
<template>
18-
<canvas id="captchaCanvas" @click="handleRefresh" />
18+
<img id="captchaCanvas" @click="handleRefresh" />
1919
</template>

vite.config.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
alias,
77
wrapperEnv,
88
pathResolve,
9-
__APP_INFO__
9+
__APP_INFO__,
1010
} from "./build/utils";
1111

1212
export default ({ mode }: ConfigEnv): UserConfigExport => {
@@ -16,31 +16,31 @@ export default ({ mode }: ConfigEnv): UserConfigExport => {
1616
base: VITE_PUBLIC_PATH,
1717
root,
1818
resolve: {
19-
alias
19+
alias,
2020
},
2121
// 服务端渲染
2222
server: {
2323
// 端口号
2424
port: VITE_PORT,
2525
host: "0.0.0.0",
2626
// 本地跨域代理 https://cn.vitejs.dev/config/server-options.html#server-proxy
27-
proxy: {
28-
"/slbma": {
29-
target: "https://slwl-api.itheima.net", //本地调试时使用
30-
changeOrigin: true,
31-
rewrite: (path) => path.replace(/^\/slbma/, ''),
27+
proxy: {
28+
"/slbma": {
29+
target: "http://localhost:8989", //本地调试时使用
30+
changeOrigin: true,
31+
rewrite: (path) => path.replace(/^\/slbma/, ""),
32+
},
3233
},
33-
},
3434
// 预热文件以提前转换和缓存结果,降低启动期间的初始页面加载时长并防止转换瀑布
3535
warmup: {
36-
clientFiles: ["./index.html", "./src/{views,components}/*"]
37-
}
36+
clientFiles: ["./index.html", "./src/{views,components}/*"],
37+
},
3838
},
3939
plugins: getPluginsList(VITE_CDN, VITE_COMPRESSION),
4040
// https://cn.vitejs.dev/config/dep-optimization-options.html#dep-optimization-options
4141
optimizeDeps: {
4242
include,
43-
exclude
43+
exclude,
4444
},
4545
build: {
4646
// https://cn.vitejs.dev/guide/build.html#browser-compatibility
@@ -50,19 +50,19 @@ export default ({ mode }: ConfigEnv): UserConfigExport => {
5050
chunkSizeWarningLimit: 4000,
5151
rollupOptions: {
5252
input: {
53-
index: pathResolve("./index.html", import.meta.url)
53+
index: pathResolve("./index.html", import.meta.url),
5454
},
5555
// 静态资源分类打包
5656
output: {
5757
chunkFileNames: "static/js/[name]-[hash].js",
5858
entryFileNames: "static/js/[name]-[hash].js",
59-
assetFileNames: "static/[ext]/[name]-[hash].[ext]"
60-
}
61-
}
59+
assetFileNames: "static/[ext]/[name]-[hash].[ext]",
60+
},
61+
},
6262
},
6363
define: {
6464
__INTLIFY_PROD_DEVTOOLS__: false,
65-
__APP_INFO__: JSON.stringify(__APP_INFO__)
66-
}
65+
__APP_INFO__: JSON.stringify(__APP_INFO__),
66+
},
6767
};
6868
};

0 commit comments

Comments
 (0)