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_AES_KEY=4e2c3d4e5f6a7b8c9d0e1f2g3h4i5j6k7l8m9n0o1p2q3r4s5t6u7v8w9x0y1z2
|
||||
VITE_AES_KEY=st123456654321st
|
||||
|
||||
20
package.json
20
package.json
@@ -11,26 +11,26 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@tinymce/tinymce-vue": "^6.1.0",
|
||||
"axios": "^1.8.2",
|
||||
"axios": "^1.8.4",
|
||||
"crypto-js": "^4.2.0",
|
||||
"pinia": "^3.0.1",
|
||||
"pinia": "^3.0.2",
|
||||
"pinia-plugin-persistedstate": "^4.2.0",
|
||||
"tinymce": "^7.7.2",
|
||||
"tinymce": "^7.8.0",
|
||||
"uqrcodejs": "^4.0.7",
|
||||
"uuid": "^11.1.0",
|
||||
"vite-plugin-vue-devtools": "^7.7.2",
|
||||
"vite-plugin-vue-devtools": "^7.7.5",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@arco-design/web-vue": "^2.56.3",
|
||||
"@arco-design/web-vue": "^2.57.0",
|
||||
"@arco-plugins/vite-vue": "^1.4.5",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"sass": "^1.85.1",
|
||||
"@vitejs/plugin-vue": "^5.2.3",
|
||||
"sass": "^1.86.3",
|
||||
"tailwindcss": "^3.4.17",
|
||||
"unplugin-auto-import": "^19.1.1",
|
||||
"unplugin-vue-components": "^28.4.1",
|
||||
"vite": "^6.2.0"
|
||||
"unplugin-auto-import": "^19.1.2",
|
||||
"unplugin-vue-components": "^28.5.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 admin from './admin.js';
|
||||
|
||||
const Api = {
|
||||
system: {...system}
|
||||
system: {...system},
|
||||
admin: {...admin},
|
||||
}
|
||||
|
||||
export default Api;
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import request from "../utils/request.js";
|
||||
import Method from "./Method.js";
|
||||
|
||||
const system = {
|
||||
getData: async (params) => {
|
||||
return request({
|
||||
url: '/m1/5995958-5684445-default/getList',
|
||||
method: "POST",
|
||||
method: Method.POST,
|
||||
data: params
|
||||
});
|
||||
},
|
||||
getSelect: async () => {
|
||||
return request({
|
||||
url: '/m1/5995958-5684445-default/getSelectList',
|
||||
method: "GET",
|
||||
method: Method.GET,
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<script setup>
|
||||
import {ref, defineProps, defineModel} from 'vue';
|
||||
import {Notification} from "@arco-design/web-vue";
|
||||
import {defineModel, defineProps, ref} from 'vue';
|
||||
import {Message, Notification} from "@arco-design/web-vue";
|
||||
import Api from "../../api/index.js";
|
||||
|
||||
const verificationCode = defineModel('verificationCode', {type: String});
|
||||
const {phone} = defineProps({
|
||||
phone: {
|
||||
const {mobile} = defineProps({
|
||||
mobile: {
|
||||
type: String,
|
||||
default: null,
|
||||
}
|
||||
@@ -13,9 +14,11 @@ const {phone} = defineProps({
|
||||
const time = ref(null);
|
||||
let timer = null;
|
||||
|
||||
const verifyPhone = () => {
|
||||
if (/^1[3-9]\d{9}$/.test(phone)) {
|
||||
const verifyPhone = async () => {
|
||||
if (/^1[3-9]\d{9}$/.test(mobile)) {
|
||||
if (timer === null) {
|
||||
const {msg, code} = await Api.admin.sendSms(mobile);
|
||||
if (code === 1) Message.success(msg);
|
||||
time.value = 10;
|
||||
timer = setInterval(() => {
|
||||
if (time.value <= 0) {
|
||||
@@ -39,7 +42,7 @@ const verifyPhone = () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-input :model-value="verificationCode" placeholder="验证码">
|
||||
<a-input v-model:model-value="verificationCode" placeholder="验证码">
|
||||
<template #append>
|
||||
<a-link @click="verifyPhone" :disabled="Boolean(time)" :hoverable="false">
|
||||
{{ time ? `${time}s后重新获取` : '发送验证码' }}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createApp } from 'vue';
|
||||
import {createApp} from 'vue';
|
||||
import App from './App.vue';
|
||||
import router from "./router";
|
||||
import './scss/index.scss';
|
||||
import {createPinia} from "pinia";
|
||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
|
||||
|
||||
const pinia = createPinia();
|
||||
pinia.use(piniaPluginPersistedstate);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import {ref, reactive} from 'vue';
|
||||
import {reactive, ref} from 'vue';
|
||||
import {toPath} from "../../utils/index.js";
|
||||
import VerificationCode from '../../components/VerificationCode/index.vue';
|
||||
import {useUserStore} from "../../pinia/UserStore/index.js";
|
||||
@@ -12,9 +12,9 @@ const MODE = {
|
||||
}
|
||||
|
||||
const from = reactive({
|
||||
phone: null,
|
||||
verificationCode: null,
|
||||
password: null,
|
||||
mobile: '17502997128',
|
||||
code: null,
|
||||
password: '123456',
|
||||
});
|
||||
|
||||
const mode = ref(MODE.PHONE);
|
||||
@@ -29,21 +29,21 @@ const mode = ref(MODE.PHONE);
|
||||
</div>
|
||||
</div>
|
||||
<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
|
||||
v-if="mode === MODE.PHONE"
|
||||
:phone="from.phone"
|
||||
v-model:verification-code="from.verificationCode">
|
||||
:mobile="from.mobile"
|
||||
v-model:verification-code="from.code">
|
||||
</VerificationCode>
|
||||
<a-input v-else :model-value="from.password" placeholder="密码">
|
||||
<a-input v-else v-model:model-value="from.password" placeholder="密码">
|
||||
<template #append>
|
||||
<a-link @click="toPath('/loginSYS/forgot')" :hoverable="false">忘记密码?</a-link>
|
||||
</template>
|
||||
</a-input>
|
||||
</div>
|
||||
<div class="flex flex-col mt-[50px] gap-[32px]">
|
||||
<a-button @click="login(false)" type="primary">登陆商户端</a-button>
|
||||
<a-button @click="login(true)" type="primary">登陆管理端</a-button>
|
||||
<a-button @click="login(false, from)" type="primary">登陆商户端</a-button>
|
||||
<a-button @click="login(true, from)" type="primary">登陆管理端</a-button>
|
||||
<a-button
|
||||
@click="toPath('/loginSYS/register')"
|
||||
type="text">
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup>
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -4,7 +4,6 @@ import Filter from "../../../../components/Filter/index.vue";
|
||||
import useTableQuery from "../../../../hooks/useTableQuery.js";
|
||||
import Api from "../../../../api/index.js";
|
||||
import TaskPassedReviewModal from "./components/TaskPassedReviewModal.vue";
|
||||
import openTerminateTask from "./components/openTerminateTask.js";
|
||||
import RejectTaskModal from "./components/RejectTaskModal.vue";
|
||||
import TerminateTask from "../../../../components/TerminateTask/TerminateTask.js";
|
||||
|
||||
@@ -74,44 +73,18 @@ const FilterConfig = [
|
||||
type: 'select',
|
||||
label: '任务渠道',
|
||||
placeholder: '请选择任务渠道',
|
||||
api: async () => ({
|
||||
data: [
|
||||
{
|
||||
name: '选项一',
|
||||
id: 1,
|
||||
api: async () => {
|
||||
return await Api.admin.getPlatform();
|
||||
},
|
||||
{
|
||||
name: '选项二',
|
||||
id: 2,
|
||||
},
|
||||
{
|
||||
name: '选项三',
|
||||
id: 3,
|
||||
},
|
||||
]
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'wd',
|
||||
type: 'select',
|
||||
label: '任务状态',
|
||||
placeholder: '请选择任务状态',
|
||||
api: async () => ({
|
||||
data: [
|
||||
{
|
||||
name: '选项一',
|
||||
id: 1,
|
||||
api: async () => {
|
||||
return await Api.admin.getTaskList();
|
||||
},
|
||||
{
|
||||
name: '选项二',
|
||||
id: 2,
|
||||
},
|
||||
{
|
||||
name: '选项三',
|
||||
id: 3,
|
||||
},
|
||||
]
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'wd',
|
||||
@@ -123,22 +96,9 @@ const FilterConfig = [
|
||||
type: 'select',
|
||||
label: '审核状态',
|
||||
placeholder: '请选择审核状态',
|
||||
api: async () => ({
|
||||
data: [
|
||||
{
|
||||
name: '选项一',
|
||||
id: 1,
|
||||
api: async () => {
|
||||
return await Api.admin.getCheckStatusList();
|
||||
},
|
||||
{
|
||||
name: '选项二',
|
||||
id: 2,
|
||||
},
|
||||
{
|
||||
name: '选项三',
|
||||
id: 3,
|
||||
},
|
||||
]
|
||||
}),
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {ref} from "vue";
|
||||
import {mockRoutes1, mockRoutes2} from './mock.js';
|
||||
import router from "../../router/index.js";
|
||||
import generateRouter from "../../router/generateRouter.js";
|
||||
import Api from "../../api/index.js";
|
||||
|
||||
export const useSystemStore = defineStore("SystemStore", () => {
|
||||
const isRoot = ref(false);
|
||||
@@ -26,8 +26,8 @@ export const useSystemStore = defineStore("SystemStore", () => {
|
||||
|
||||
RoutesTemp.value.length = 0;
|
||||
// 请求资源 mockRoutes
|
||||
const routes = generateRouter(isRoot.value ? mockRoutes2 : mockRoutes1);
|
||||
RoutesTemp.value.push(...(isRoot.value ? mockRoutes2 : mockRoutes1));
|
||||
const {data} = await Api.admin.getMenu();
|
||||
RoutesTemp.value.push(...data);
|
||||
await installRoute();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +1,48 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {ref} from "vue";
|
||||
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", () => {
|
||||
const isLogin = ref(false);
|
||||
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;
|
||||
// 获取并安装路由
|
||||
const { setRouter } = useSystemStore();
|
||||
token.value = data.token;
|
||||
userInfo.value = data;
|
||||
// // 获取并安装路由
|
||||
const {setRouter} = useSystemStore();
|
||||
await setRouter(isRoot);
|
||||
// 跳转
|
||||
await router.push('/home');
|
||||
// // 跳转
|
||||
toPath('/home');
|
||||
}
|
||||
|
||||
const logout = async () => {
|
||||
isLogin.value = false;
|
||||
const { clearRouter } = useSystemStore();
|
||||
const {clearRouter} = useSystemStore();
|
||||
await clearRouter();
|
||||
}
|
||||
return {
|
||||
isLogin,
|
||||
userInfo,
|
||||
token,
|
||||
login,
|
||||
logout,
|
||||
}
|
||||
@@ -32,6 +50,6 @@ export const useUserStore = defineStore("UserStore", () => {
|
||||
persist: {
|
||||
key: 'UserStore',
|
||||
storage: localStorage,
|
||||
pick: ['isLogin']
|
||||
pick: ['isLogin', 'token', 'userInfo']
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,29 +1,58 @@
|
||||
import AES from 'crypto-js/aes.js';
|
||||
import utf8 from 'crypto-js/enc-utf8.js';
|
||||
import Crypto from 'crypto-js';
|
||||
|
||||
class AESCrypto {
|
||||
/**
|
||||
* 密钥
|
||||
* @type {string}
|
||||
*/
|
||||
static #AES_KEY = process.env.VITE_AES_KEY;
|
||||
static _AES_KEY = import.meta.env.VITE_AES_KEY;
|
||||
|
||||
/**
|
||||
* AES加密
|
||||
* @param context {string} 加密内容
|
||||
*/
|
||||
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解密
|
||||
* @param context {string}
|
||||
* @param iv {string}
|
||||
* @return {string}
|
||||
*/
|
||||
static decrypt = (context) => {
|
||||
const bytes = AES.decrypt(context, this.#AES_KEY);
|
||||
return bytes.toString(utf8);
|
||||
static decrypt = (context, iv) => {
|
||||
return Crypto.AES.decrypt(
|
||||
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 {useUserStore} from "../pinia/UserStore";
|
||||
import AESCrypto from "./AESCrypto.js";
|
||||
import {Message} from '@arco-design/web-vue';
|
||||
import {useUserStore} from "../pinia/UserStore/index.js";
|
||||
|
||||
// 创建 Axios 实例
|
||||
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, // 请求超时设置
|
||||
});
|
||||
|
||||
// 请求拦截器
|
||||
request.interceptors.request.use(
|
||||
(config) => {
|
||||
// const {userInfo} = useUserStore();
|
||||
request.interceptors.request.use((config) => {
|
||||
const {token} = useUserStore();
|
||||
|
||||
// 如果 token 存在,则将其添加到请求头中
|
||||
// if (userInfo?.token) {
|
||||
// config.headers['token'] = `${userInfo?.token}`;
|
||||
// }
|
||||
if (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;
|
||||
},
|
||||
(error) => {
|
||||
}, (error) => {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// 响应拦截器
|
||||
request.interceptors.response.use(
|
||||
(response) => {
|
||||
return response.data;
|
||||
},
|
||||
(error) => {
|
||||
request.interceptors.response.use((response) => {
|
||||
const {data: {msg, code, data}, config: {url}} = response;
|
||||
console.log(response)
|
||||
if (code !== 1) {
|
||||
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) {
|
||||
return Promise.reject(error.response.data); // 返回错误信息
|
||||
} else { // 网络错误
|
||||
return Promise.reject(error.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
export default request; // 导出 Axios 实例
|
||||
|
||||
@@ -4,8 +4,8 @@ import tailwindcss from 'tailwindcss';
|
||||
import AutoImport from 'unplugin-auto-import/vite';
|
||||
import vueDevTools from 'vite-plugin-vue-devtools';
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
import {vitePluginForArco} from '@arco-plugins/vite-vue';
|
||||
import {ArcoResolver} from 'unplugin-vue-components/resolvers';
|
||||
import {vitePluginForArco} from "@arco-plugins/vite-vue";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
@@ -40,6 +40,13 @@ export default defineConfig({
|
||||
}
|
||||
},
|
||||
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