1
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.13.2",
|
"axios": "^1.13.2",
|
||||||
|
"browser-md5-file": "^1.1.1",
|
||||||
"immer": "^11.0.1",
|
"immer": "^11.0.1",
|
||||||
"lucide-react": "^0.487.0",
|
"lucide-react": "^0.487.0",
|
||||||
"motion": "^12.23.26",
|
"motion": "^12.23.26",
|
||||||
|
|||||||
15
pnpm-lock.yaml
generated
15
pnpm-lock.yaml
generated
@@ -11,6 +11,9 @@ importers:
|
|||||||
axios:
|
axios:
|
||||||
specifier: ^1.13.2
|
specifier: ^1.13.2
|
||||||
version: 1.13.2
|
version: 1.13.2
|
||||||
|
browser-md5-file:
|
||||||
|
specifier: ^1.1.1
|
||||||
|
version: 1.1.1
|
||||||
immer:
|
immer:
|
||||||
specifier: ^11.0.1
|
specifier: ^11.0.1
|
||||||
version: 11.0.1
|
version: 11.0.1
|
||||||
@@ -426,6 +429,9 @@ packages:
|
|||||||
axios@1.13.2:
|
axios@1.13.2:
|
||||||
resolution: {integrity: sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==}
|
resolution: {integrity: sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==}
|
||||||
|
|
||||||
|
browser-md5-file@1.1.1:
|
||||||
|
resolution: {integrity: sha512-9h2UViTtZPhBa7oHvp5mb7MvJaX5OKEPUsplDwJ800OIV+In7BOR3RXOMB78obn2iQVIiS3WkVLhG7Zu1EMwbw==}
|
||||||
|
|
||||||
call-bind-apply-helpers@1.0.2:
|
call-bind-apply-helpers@1.0.2:
|
||||||
resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==}
|
resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
@@ -661,6 +667,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
|
||||||
|
spark-md5@2.0.2:
|
||||||
|
resolution: {integrity: sha512-9WfT+FYBEvlrOOBEs484/zmbtSX4BlGjzXih1qIEWA1yhHbcqgcMHkiwXoWk2Sq1aJjLpcs6ZKV7JxrDNjIlNg==}
|
||||||
|
|
||||||
tinyglobby@0.2.15:
|
tinyglobby@0.2.15:
|
||||||
resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==}
|
resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==}
|
||||||
engines: {node: '>=12.0.0'}
|
engines: {node: '>=12.0.0'}
|
||||||
@@ -969,6 +978,10 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- debug
|
- debug
|
||||||
|
|
||||||
|
browser-md5-file@1.1.1:
|
||||||
|
dependencies:
|
||||||
|
spark-md5: 2.0.2
|
||||||
|
|
||||||
call-bind-apply-helpers@1.0.2:
|
call-bind-apply-helpers@1.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
es-errors: 1.3.0
|
es-errors: 1.3.0
|
||||||
@@ -1232,6 +1245,8 @@ snapshots:
|
|||||||
|
|
||||||
source-map-js@1.2.1: {}
|
source-map-js@1.2.1: {}
|
||||||
|
|
||||||
|
spark-md5@2.0.2: {}
|
||||||
|
|
||||||
tinyglobby@0.2.15:
|
tinyglobby@0.2.15:
|
||||||
dependencies:
|
dependencies:
|
||||||
fdir: 6.5.0(picomatch@4.0.3)
|
fdir: 6.5.0(picomatch@4.0.3)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import toast, {Toaster} from "react-hot-toast";
|
|||||||
import wxShare from "@/wx/wxShare";
|
import wxShare from "@/wx/wxShare";
|
||||||
import {enterpriseAnalyzeApi} from "@/api/service";
|
import {enterpriseAnalyzeApi} from "@/api/service";
|
||||||
import {useUserStore} from "@/store/user-store";
|
import {useUserStore} from "@/store/user-store";
|
||||||
|
import {uploadFileQoi} from "@/utils/upload/upload";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
@@ -27,9 +28,11 @@ export default function App() {
|
|||||||
* 上传文件
|
* 上传文件
|
||||||
*/
|
*/
|
||||||
const handleUpload = async (file) => {
|
const handleUpload = async (file) => {
|
||||||
|
try {
|
||||||
handleNextScreen()
|
handleNextScreen()
|
||||||
|
let fileUrl = await uploadFileQoi(file, "/analyze")
|
||||||
let res = await enterpriseAnalyzeApi({
|
let res = await enterpriseAnalyzeApi({
|
||||||
analys_image: file,
|
analys_image: fileUrl,
|
||||||
analys_type: null,
|
analys_type: null,
|
||||||
}) as any
|
}) as any
|
||||||
if (res.analysis_result.analyze_ret != "success") {
|
if (res.analysis_result.analyze_ret != "success") {
|
||||||
@@ -39,6 +42,9 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
userStore.setAnalysis(res)
|
userStore.setAnalysis(res)
|
||||||
handleNextScreen()
|
handleNextScreen()
|
||||||
|
} catch (e) {
|
||||||
|
setCurrentScreen((prev => prev = 2))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePayment = () => {
|
const handlePayment = () => {
|
||||||
|
|||||||
9
src/api/common.ts
Normal file
9
src/api/common.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import request from "@/utils/http/request";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取七牛token
|
||||||
|
* @param path
|
||||||
|
*/
|
||||||
|
export function getQiuTokenApi(path: string) {
|
||||||
|
return request.get("/get_qiniu_upload_token", {file_key: path})
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import request from "@/utils/http/request";
|
|||||||
|
|
||||||
|
|
||||||
type EnterpriseAnalyzeApi = {
|
type EnterpriseAnalyzeApi = {
|
||||||
analys_image: File,
|
analys_image: string,
|
||||||
analys_type: string,
|
analys_type: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
src/types/index.d.ts
vendored
1
src/types/index.d.ts
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
declare module "weixin-js-sdk"
|
declare module "weixin-js-sdk"
|
||||||
|
|
||||||
|
declare module "browser-md5-file"
|
||||||
14
src/utils/common.ts
Normal file
14
src/utils/common.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import BMF from 'browser-md5-file'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取md5名字
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
export function getMd5Value(value: any): Promise<string> {
|
||||||
|
const bmf = new BMF()
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
bmf.md5(value, (err: any, md5: string) => {
|
||||||
|
return resolve(md5)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
26
src/utils/upload/upload.ts
Normal file
26
src/utils/upload/upload.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import {getMd5Value} from "@/utils/common";
|
||||||
|
import {getQiuTokenApi} from "@/api/common";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 七牛上传文件
|
||||||
|
* @param file
|
||||||
|
* @param path 路径,格式/xx/x
|
||||||
|
*/
|
||||||
|
export async function uploadFileQoi(file: File, path: string): Promise<string | null> {
|
||||||
|
let uploadOptions = new FormData();
|
||||||
|
let md5 = await getMd5Value(file)
|
||||||
|
let suffix = file.name.split('.')[1]
|
||||||
|
let res = await getQiuTokenApi("效灵" + path + "/" + md5 + '.' + suffix) as any
|
||||||
|
uploadOptions.append("token", res.up_token)
|
||||||
|
uploadOptions.append("upload_url", res.upload_url)
|
||||||
|
uploadOptions.append("imgPrefix", res.domain)
|
||||||
|
uploadOptions.append("key", res.file_key)
|
||||||
|
uploadOptions.append("file", file)
|
||||||
|
let res2: any = await axios.post(res.upload_url, uploadOptions)
|
||||||
|
let data = res2.data
|
||||||
|
if (data.key) {
|
||||||
|
return `https://${res.domain}/${data.key}`
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user