update
This commit is contained in:
4
.env
4
.env
@@ -1,3 +1,3 @@
|
|||||||
VITE_API_URL=https://m1.apifoxmock.com
|
VITE_API_URL=http://192.168.1.105
|
||||||
VITE_TINYMCE_KEY=agmu6i1c6k7bcp36oenzyz7yi1yplptq7goyx88y1g6ofnqu
|
VITE_TINYMCE_KEY=agmu6i1c6k7bcp36oenzyz7yi1yplptq7goyx88y1g6ofnqu
|
||||||
VITE_AES_KEY=4e2c3d4e5f6a7b8c9d0e1f2g3h4i5j6k7l8m9n0o1p2q3r4s5t6u7v8w9x0y1z2
|
VITE_AES_KEY=st123456654321st
|
||||||
|
|||||||
20
package.json
20
package.json
@@ -11,26 +11,26 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tinymce/tinymce-vue": "^6.1.0",
|
"@tinymce/tinymce-vue": "^6.1.0",
|
||||||
"axios": "^1.8.2",
|
"axios": "^1.8.4",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"pinia": "^3.0.1",
|
"pinia": "^3.0.2",
|
||||||
"pinia-plugin-persistedstate": "^4.2.0",
|
"pinia-plugin-persistedstate": "^4.2.0",
|
||||||
"tinymce": "^7.7.2",
|
"tinymce": "^7.8.0",
|
||||||
"uqrcodejs": "^4.0.7",
|
"uqrcodejs": "^4.0.7",
|
||||||
"uuid": "^11.1.0",
|
"uuid": "^11.1.0",
|
||||||
"vite-plugin-vue-devtools": "^7.7.2",
|
"vite-plugin-vue-devtools": "^7.7.5",
|
||||||
"vue": "^3.5.13",
|
"vue": "^3.5.13",
|
||||||
"vue-router": "^4.5.0"
|
"vue-router": "^4.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@arco-design/web-vue": "^2.56.3",
|
"@arco-design/web-vue": "^2.57.0",
|
||||||
"@arco-plugins/vite-vue": "^1.4.5",
|
"@arco-plugins/vite-vue": "^1.4.5",
|
||||||
"@types/crypto-js": "^4.2.2",
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@vitejs/plugin-vue": "^5.2.1",
|
"@vitejs/plugin-vue": "^5.2.3",
|
||||||
"sass": "^1.85.1",
|
"sass": "^1.86.3",
|
||||||
"tailwindcss": "^3.4.17",
|
"tailwindcss": "^3.4.17",
|
||||||
"unplugin-auto-import": "^19.1.1",
|
"unplugin-auto-import": "^19.1.2",
|
||||||
"unplugin-vue-components": "^28.4.1",
|
"unplugin-vue-components": "^28.5.0",
|
||||||
"vite": "^6.2.0"
|
"vite": "^6.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1176
pnpm-lock.yaml
generated
1176
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
8
src/api/Method.js
Normal file
8
src/api/Method.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
const Method = {
|
||||||
|
GET: 'GET',
|
||||||
|
POST: 'POST',
|
||||||
|
PUT: 'PUT',
|
||||||
|
DELETE: 'DELETE',
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Method;
|
||||||
52
src/api/admin.js
Normal file
52
src/api/admin.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import request from "../utils/request.js";
|
||||||
|
import Method from "./Method.js";
|
||||||
|
|
||||||
|
const admin = {
|
||||||
|
login: async (data) => {
|
||||||
|
return request({
|
||||||
|
url: '/admin/login/login',
|
||||||
|
method: Method.POST,
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
phoneLogin: async (data) => {
|
||||||
|
return request({
|
||||||
|
url: '/admin/login/mobileLogin',
|
||||||
|
method: Method.POST,
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
sendSms: async (mobile) => {
|
||||||
|
return request({
|
||||||
|
url: '/admin/login/sendSms',
|
||||||
|
method: Method.POST,
|
||||||
|
data: {mobile},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getMenu: async () => {
|
||||||
|
return request({
|
||||||
|
url: '/admin/admin/menu',
|
||||||
|
method: Method.POST,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getTaskList: async () => {
|
||||||
|
return request({
|
||||||
|
url: '/admin/task/getStatusList',
|
||||||
|
method: Method.POST,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getPlatform: async () => {
|
||||||
|
return request({
|
||||||
|
url: '/admin/platform/getList',
|
||||||
|
method: Method.POST,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getCheckStatusList: async () => {
|
||||||
|
return request({
|
||||||
|
url: '/admin/task/getCheckStatusList',
|
||||||
|
method: Method.POST,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default admin;
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import system from './system.js';
|
import system from './system.js';
|
||||||
|
import admin from './admin.js';
|
||||||
|
|
||||||
const Api = {
|
const Api = {
|
||||||
system: {...system}
|
system: {...system},
|
||||||
|
admin: {...admin},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Api;
|
export default Api;
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
import request from "../utils/request.js";
|
import request from "../utils/request.js";
|
||||||
|
import Method from "./Method.js";
|
||||||
|
|
||||||
const system = {
|
const system = {
|
||||||
getData: async (params) => {
|
getData: async (params) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/m1/5995958-5684445-default/getList',
|
url: '/m1/5995958-5684445-default/getList',
|
||||||
method: "POST",
|
method: Method.POST,
|
||||||
data: params
|
data: params
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getSelect: async () => {
|
getSelect: async () => {
|
||||||
return request({
|
return request({
|
||||||
url: '/m1/5995958-5684445-default/getSelectList',
|
url: '/m1/5995958-5684445-default/getSelectList',
|
||||||
method: "GET",
|
method: Method.GET,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {ref, defineProps, defineModel} from 'vue';
|
import {defineModel, defineProps, ref} from 'vue';
|
||||||
import {Notification} from "@arco-design/web-vue";
|
import {Message, Notification} from "@arco-design/web-vue";
|
||||||
|
import Api from "../../api/index.js";
|
||||||
|
|
||||||
const verificationCode = defineModel('verificationCode', {type: String});
|
const verificationCode = defineModel('verificationCode', {type: String});
|
||||||
const {phone} = defineProps({
|
const {mobile} = defineProps({
|
||||||
phone: {
|
mobile: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
}
|
}
|
||||||
@@ -13,9 +14,11 @@ const {phone} = defineProps({
|
|||||||
const time = ref(null);
|
const time = ref(null);
|
||||||
let timer = null;
|
let timer = null;
|
||||||
|
|
||||||
const verifyPhone = () => {
|
const verifyPhone = async () => {
|
||||||
if (/^1[3-9]\d{9}$/.test(phone)) {
|
if (/^1[3-9]\d{9}$/.test(mobile)) {
|
||||||
if (timer === null) {
|
if (timer === null) {
|
||||||
|
const {msg, code} = await Api.admin.sendSms(mobile);
|
||||||
|
if (code === 1) Message.success(msg);
|
||||||
time.value = 10;
|
time.value = 10;
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
if (time.value <= 0) {
|
if (time.value <= 0) {
|
||||||
@@ -39,7 +42,7 @@ const verifyPhone = () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<a-input :model-value="verificationCode" placeholder="验证码">
|
<a-input v-model:model-value="verificationCode" placeholder="验证码">
|
||||||
<template #append>
|
<template #append>
|
||||||
<a-link @click="verifyPhone" :disabled="Boolean(time)" :hoverable="false">
|
<a-link @click="verifyPhone" :disabled="Boolean(time)" :hoverable="false">
|
||||||
{{ time ? `${time}s后重新获取` : '发送验证码' }}
|
{{ time ? `${time}s后重新获取` : '发送验证码' }}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import App from './App.vue';
|
|||||||
import router from "./router";
|
import router from "./router";
|
||||||
import './scss/index.scss';
|
import './scss/index.scss';
|
||||||
import {createPinia} from "pinia";
|
import {createPinia} from "pinia";
|
||||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
|
||||||
|
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
pinia.use(piniaPluginPersistedstate);
|
pinia.use(piniaPluginPersistedstate);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {ref, reactive} from 'vue';
|
import {reactive, ref} from 'vue';
|
||||||
import {toPath} from "../../utils/index.js";
|
import {toPath} from "../../utils/index.js";
|
||||||
import VerificationCode from '../../components/VerificationCode/index.vue';
|
import VerificationCode from '../../components/VerificationCode/index.vue';
|
||||||
import {useUserStore} from "../../pinia/UserStore/index.js";
|
import {useUserStore} from "../../pinia/UserStore/index.js";
|
||||||
@@ -12,9 +12,9 @@ const MODE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const from = reactive({
|
const from = reactive({
|
||||||
phone: null,
|
mobile: '17502997128',
|
||||||
verificationCode: null,
|
code: null,
|
||||||
password: null,
|
password: '123456',
|
||||||
});
|
});
|
||||||
|
|
||||||
const mode = ref(MODE.PHONE);
|
const mode = ref(MODE.PHONE);
|
||||||
@@ -29,21 +29,21 @@ const mode = ref(MODE.PHONE);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-[38px] flex flex-col gap-[20px]">
|
<div class="mt-[38px] flex flex-col gap-[20px]">
|
||||||
<a-input v-model:model-value="from.phone" placeholder="手机号"></a-input>
|
<a-input v-model:model-value="from.mobile" placeholder="手机号"></a-input>
|
||||||
<VerificationCode
|
<VerificationCode
|
||||||
v-if="mode === MODE.PHONE"
|
v-if="mode === MODE.PHONE"
|
||||||
:phone="from.phone"
|
:mobile="from.mobile"
|
||||||
v-model:verification-code="from.verificationCode">
|
v-model:verification-code="from.code">
|
||||||
</VerificationCode>
|
</VerificationCode>
|
||||||
<a-input v-else :model-value="from.password" placeholder="密码">
|
<a-input v-else v-model:model-value="from.password" placeholder="密码">
|
||||||
<template #append>
|
<template #append>
|
||||||
<a-link @click="toPath('/loginSYS/forgot')" :hoverable="false">忘记密码?</a-link>
|
<a-link @click="toPath('/loginSYS/forgot')" :hoverable="false">忘记密码?</a-link>
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col mt-[50px] gap-[32px]">
|
<div class="flex flex-col mt-[50px] gap-[32px]">
|
||||||
<a-button @click="login(false)" type="primary">登陆商户端</a-button>
|
<a-button @click="login(false, from)" type="primary">登陆商户端</a-button>
|
||||||
<a-button @click="login(true)" type="primary">登陆管理端</a-button>
|
<a-button @click="login(true, from)" type="primary">登陆管理端</a-button>
|
||||||
<a-button
|
<a-button
|
||||||
@click="toPath('/loginSYS/register')"
|
@click="toPath('/loginSYS/register')"
|
||||||
type="text">
|
type="text">
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import Filter from "../../../../components/Filter/index.vue";
|
|||||||
import useTableQuery from "../../../../hooks/useTableQuery.js";
|
import useTableQuery from "../../../../hooks/useTableQuery.js";
|
||||||
import Api from "../../../../api/index.js";
|
import Api from "../../../../api/index.js";
|
||||||
import TaskPassedReviewModal from "./components/TaskPassedReviewModal.vue";
|
import TaskPassedReviewModal from "./components/TaskPassedReviewModal.vue";
|
||||||
import openTerminateTask from "./components/openTerminateTask.js";
|
|
||||||
import RejectTaskModal from "./components/RejectTaskModal.vue";
|
import RejectTaskModal from "./components/RejectTaskModal.vue";
|
||||||
import TerminateTask from "../../../../components/TerminateTask/TerminateTask.js";
|
import TerminateTask from "../../../../components/TerminateTask/TerminateTask.js";
|
||||||
|
|
||||||
@@ -74,44 +73,18 @@ const FilterConfig = [
|
|||||||
type: 'select',
|
type: 'select',
|
||||||
label: '任务渠道',
|
label: '任务渠道',
|
||||||
placeholder: '请选择任务渠道',
|
placeholder: '请选择任务渠道',
|
||||||
api: async () => ({
|
api: async () => {
|
||||||
data: [
|
return await Api.admin.getPlatform();
|
||||||
{
|
|
||||||
name: '选项一',
|
|
||||||
id: 1,
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: '选项二',
|
|
||||||
id: 2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '选项三',
|
|
||||||
id: 3,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'wd',
|
key: 'wd',
|
||||||
type: 'select',
|
type: 'select',
|
||||||
label: '任务状态',
|
label: '任务状态',
|
||||||
placeholder: '请选择任务状态',
|
placeholder: '请选择任务状态',
|
||||||
api: async () => ({
|
api: async () => {
|
||||||
data: [
|
return await Api.admin.getTaskList();
|
||||||
{
|
|
||||||
name: '选项一',
|
|
||||||
id: 1,
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: '选项二',
|
|
||||||
id: 2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '选项三',
|
|
||||||
id: 3,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'wd',
|
key: 'wd',
|
||||||
@@ -123,22 +96,9 @@ const FilterConfig = [
|
|||||||
type: 'select',
|
type: 'select',
|
||||||
label: '审核状态',
|
label: '审核状态',
|
||||||
placeholder: '请选择审核状态',
|
placeholder: '请选择审核状态',
|
||||||
api: async () => ({
|
api: async () => {
|
||||||
data: [
|
return await Api.admin.getCheckStatusList();
|
||||||
{
|
|
||||||
name: '选项一',
|
|
||||||
id: 1,
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: '选项二',
|
|
||||||
id: 2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '选项三',
|
|
||||||
id: 3,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {defineStore} from "pinia";
|
import {defineStore} from "pinia";
|
||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
import {mockRoutes1, mockRoutes2} from './mock.js';
|
|
||||||
import router from "../../router/index.js";
|
import router from "../../router/index.js";
|
||||||
import generateRouter from "../../router/generateRouter.js";
|
import generateRouter from "../../router/generateRouter.js";
|
||||||
|
import Api from "../../api/index.js";
|
||||||
|
|
||||||
export const useSystemStore = defineStore("SystemStore", () => {
|
export const useSystemStore = defineStore("SystemStore", () => {
|
||||||
const isRoot = ref(false);
|
const isRoot = ref(false);
|
||||||
@@ -26,8 +26,8 @@ export const useSystemStore = defineStore("SystemStore", () => {
|
|||||||
|
|
||||||
RoutesTemp.value.length = 0;
|
RoutesTemp.value.length = 0;
|
||||||
// 请求资源 mockRoutes
|
// 请求资源 mockRoutes
|
||||||
const routes = generateRouter(isRoot.value ? mockRoutes2 : mockRoutes1);
|
const {data} = await Api.admin.getMenu();
|
||||||
RoutesTemp.value.push(...(isRoot.value ? mockRoutes2 : mockRoutes1));
|
RoutesTemp.value.push(...data);
|
||||||
await installRoute();
|
await installRoute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,37 @@
|
|||||||
import {defineStore} from "pinia";
|
import {defineStore} from "pinia";
|
||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
import {useSystemStore} from "../SystemStore/index.js";
|
import {useSystemStore} from "../SystemStore/index.js";
|
||||||
import router from "../../router/index.js";
|
import Api from "../../api/index.js";
|
||||||
|
import {toPath} from "../../utils/index.js";
|
||||||
|
|
||||||
export const useUserStore = defineStore("UserStore", () => {
|
export const useUserStore = defineStore("UserStore", () => {
|
||||||
const isLogin = ref(false);
|
const isLogin = ref(false);
|
||||||
const userInfo = ref(null);
|
const userInfo = ref(null);
|
||||||
|
const token = ref(null);
|
||||||
|
|
||||||
const login = async (isRoot = false) => {
|
const login = async (isRoot = false, form) => {
|
||||||
// 请求
|
// 请求
|
||||||
|
const data = {};
|
||||||
|
if (isRoot) { // 管理员
|
||||||
|
if (form.code) {
|
||||||
|
const {data: _data} = await Api.admin.phoneLogin(form);
|
||||||
|
Object.assign(data, _data);
|
||||||
|
} else {
|
||||||
|
const {data: _data} = await Api.admin.login(form);
|
||||||
|
Object.assign(data, _data);
|
||||||
|
}
|
||||||
|
} else { // 商户
|
||||||
|
|
||||||
|
}
|
||||||
|
// 修改状态
|
||||||
isLogin.value = true;
|
isLogin.value = true;
|
||||||
// 获取并安装路由
|
token.value = data.token;
|
||||||
|
userInfo.value = data;
|
||||||
|
// // 获取并安装路由
|
||||||
const {setRouter} = useSystemStore();
|
const {setRouter} = useSystemStore();
|
||||||
await setRouter(isRoot);
|
await setRouter(isRoot);
|
||||||
// 跳转
|
// // 跳转
|
||||||
await router.push('/home');
|
toPath('/home');
|
||||||
}
|
}
|
||||||
|
|
||||||
const logout = async () => {
|
const logout = async () => {
|
||||||
@@ -25,6 +42,7 @@ export const useUserStore = defineStore("UserStore", () => {
|
|||||||
return {
|
return {
|
||||||
isLogin,
|
isLogin,
|
||||||
userInfo,
|
userInfo,
|
||||||
|
token,
|
||||||
login,
|
login,
|
||||||
logout,
|
logout,
|
||||||
}
|
}
|
||||||
@@ -32,6 +50,6 @@ export const useUserStore = defineStore("UserStore", () => {
|
|||||||
persist: {
|
persist: {
|
||||||
key: 'UserStore',
|
key: 'UserStore',
|
||||||
storage: localStorage,
|
storage: localStorage,
|
||||||
pick: ['isLogin']
|
pick: ['isLogin', 'token', 'userInfo']
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,29 +1,58 @@
|
|||||||
import AES from 'crypto-js/aes.js';
|
import Crypto from 'crypto-js';
|
||||||
import utf8 from 'crypto-js/enc-utf8.js';
|
|
||||||
|
|
||||||
class AESCrypto {
|
class AESCrypto {
|
||||||
/**
|
/**
|
||||||
* 密钥
|
* 密钥
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
static #AES_KEY = process.env.VITE_AES_KEY;
|
static _AES_KEY = import.meta.env.VITE_AES_KEY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AES加密
|
* AES加密
|
||||||
* @param context {string} 加密内容
|
* @param context {string} 加密内容
|
||||||
*/
|
*/
|
||||||
static encrypt = (context) => {
|
static encrypt = (context) => {
|
||||||
return AES.encrypt(context, this.#AES_KEY).toString();
|
const IV = this.createIV();
|
||||||
|
return {
|
||||||
|
context: Crypto.AES.encrypt(
|
||||||
|
context,
|
||||||
|
Crypto.enc.Utf8.parse(this._AES_KEY),
|
||||||
|
{
|
||||||
|
iv: Crypto.enc.Utf8.parse(IV),
|
||||||
|
mode: Crypto.mode.CBC,
|
||||||
|
padding: Crypto.pad.Pkcs7
|
||||||
|
}
|
||||||
|
).toString(),
|
||||||
|
iv: IV,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AES解密
|
* AES解密
|
||||||
* @param context {string}
|
* @param context {string}
|
||||||
|
* @param iv {string}
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
static decrypt = (context) => {
|
static decrypt = (context, iv) => {
|
||||||
const bytes = AES.decrypt(context, this.#AES_KEY);
|
return Crypto.AES.decrypt(
|
||||||
return bytes.toString(utf8);
|
context,
|
||||||
|
Crypto.enc.Utf8.parse(this._AES_KEY),
|
||||||
|
{
|
||||||
|
iv: Crypto.enc.Utf8.parse(iv),
|
||||||
|
mode: Crypto.mode.CBC,
|
||||||
|
padding: Crypto.pad.Pkcs7
|
||||||
|
}
|
||||||
|
).toString(Crypto.enc.Utf8);
|
||||||
|
};
|
||||||
|
|
||||||
|
static createIV = (length = 16) => {
|
||||||
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
let result = '';
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
const randomIndex = Math.floor(Math.random() * characters.length);
|
||||||
|
result += characters[randomIndex];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +1,56 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
// import {useUserStore} from "../pinia/UserStore";
|
import AESCrypto from "./AESCrypto.js";
|
||||||
|
import {Message} from '@arco-design/web-vue';
|
||||||
|
import {useUserStore} from "../pinia/UserStore/index.js";
|
||||||
|
|
||||||
// 创建 Axios 实例
|
// 创建 Axios 实例
|
||||||
const request = axios.create({
|
const request = axios.create({
|
||||||
baseURL: import.meta.env.VITE_API_URL, // 替换为你的基础 URL
|
baseURL: import.meta.env.MODE === 'development' ? '/api' : import.meta.env.VITE_API_URL, // 替换为你的基础 URL
|
||||||
timeout: 10000, // 请求超时设置
|
timeout: 10000, // 请求超时设置
|
||||||
});
|
});
|
||||||
|
|
||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
request.interceptors.request.use(
|
request.interceptors.request.use((config) => {
|
||||||
(config) => {
|
const {token} = useUserStore();
|
||||||
// const {userInfo} = useUserStore();
|
|
||||||
|
|
||||||
// 如果 token 存在,则将其添加到请求头中
|
// 如果 token 存在,则将其添加到请求头中
|
||||||
// if (userInfo?.token) {
|
if (token) {
|
||||||
// config.headers['token'] = `${userInfo?.token}`;
|
config.headers['Access-Token'] = token;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
console.log('请求拦截器', config.data);
|
||||||
|
|
||||||
|
const {context, iv} = AESCrypto.encrypt(JSON.stringify(config.data));
|
||||||
|
|
||||||
|
config.data = {
|
||||||
|
requestData: context, iv: iv,
|
||||||
|
};
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
},
|
}, (error) => {
|
||||||
(error) => {
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
request.interceptors.response.use(
|
request.interceptors.response.use((response) => {
|
||||||
(response) => {
|
const {data: {msg, code, data}, config: {url}} = response;
|
||||||
return response.data;
|
console.log(response)
|
||||||
},
|
if (code !== 1) {
|
||||||
(error) => {
|
Message.error(msg);
|
||||||
|
}
|
||||||
|
if (!data.data) {
|
||||||
|
return {msg, code, data}
|
||||||
|
} else {
|
||||||
|
const resp = JSON.parse(AESCrypto.decrypt(data.data, data.iv));
|
||||||
|
console.log(`接口${url}返回`, resp);
|
||||||
|
return {data: resp};
|
||||||
|
}
|
||||||
|
}, (error) => {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
return Promise.reject(error.response.data); // 返回错误信息
|
return Promise.reject(error.response.data); // 返回错误信息
|
||||||
} else { // 网络错误
|
} else { // 网络错误
|
||||||
return Promise.reject(error.message);
|
return Promise.reject(error.message);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
export default request; // 导出 Axios 实例
|
export default request; // 导出 Axios 实例
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import tailwindcss from 'tailwindcss';
|
|||||||
import AutoImport from 'unplugin-auto-import/vite';
|
import AutoImport from 'unplugin-auto-import/vite';
|
||||||
import vueDevTools from 'vite-plugin-vue-devtools';
|
import vueDevTools from 'vite-plugin-vue-devtools';
|
||||||
import Components from 'unplugin-vue-components/vite';
|
import Components from 'unplugin-vue-components/vite';
|
||||||
import {vitePluginForArco} from '@arco-plugins/vite-vue';
|
|
||||||
import {ArcoResolver} from 'unplugin-vue-components/resolvers';
|
import {ArcoResolver} from 'unplugin-vue-components/resolvers';
|
||||||
|
import {vitePluginForArco} from "@arco-plugins/vite-vue";
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@@ -40,6 +40,13 @@ export default defineConfig({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 9050
|
port: 9050,
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://192.168.1.105',
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user