diff --git a/activitylink/.env.development b/activitylink/.env.development
index 40cb689..663e7fc 100644
--- a/activitylink/.env.development
+++ b/activitylink/.env.development
@@ -2,5 +2,6 @@ VITE_ENV = 'development'
VITE_OUTPUT_DIR = 'dev'
VITE_PUBLIC_PATH = '/testBack/'
VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi/'
+# VITE_APP_BASE_API = 'http://localhost:12699'
VITE_USE_MOCK = true
-VITE_UPLOAD_URL=http://39.101.133.168:8828/hljw/api/aws/upload
\ No newline at end of file
+VITE_UPLOAD_URL='http://39.101.133.168:8828/hljw/api/aws/upload'
diff --git a/activitylink/.env.production b/activitylink/.env.production
index b4c1ecc..bbe0ab8 100644
--- a/activitylink/.env.production
+++ b/activitylink/.env.production
@@ -2,6 +2,11 @@ VITE_ENV = 'production'
VITE_OUTPUT_DIR = 'dist'
VITE_PUBLIC_PATH = '/testBack/'
VITE_USE_MOCK = true
+VITE_UPLOAD_URL='https://api.homilychart.com/hljw/api/aws/upload'
+VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi'
+
+
VITE_BUILD_COMPRESS = 'none'
VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false
-VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi/'
\ No newline at end of file
+VITE_UPLOAD_URL='https://api.homilychart.com/hljw/api/aws/upload'
+VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi/'
diff --git a/activitylink/.env.test b/activitylink/.env.test
new file mode 100644
index 0000000..9b0e01d
--- /dev/null
+++ b/activitylink/.env.test
@@ -0,0 +1,7 @@
+VITE_ENV = 'test'
+VITE_OUTPUT_DIR = 'test'
+VITE_PUBLIC_PATH = '/testBack/'
+VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi/'
+VITE_USE_MOCK = true
+# VITE_UPLOAD_URL='http://39.101.133.168:8828/hljw/api/aws/upload'
+VITE_UPLOAD_URL='https://api.homilychart.com/hljw/api/aws/upload'
\ No newline at end of file
diff --git a/activitylink/package.json b/activitylink/package.json
index 7ab17df..4b7951e 100644
--- a/activitylink/package.json
+++ b/activitylink/package.json
@@ -5,7 +5,8 @@
"type": "module",
"scripts": {
"dev": "vite --host",
- "build": "vite build",
+ "build:test": "vite build --mode test",
+ "build:prod": "vite build --mode production",
"preview": "vite preview"
},
"dependencies": {
diff --git a/activitylink/src/api/manage/gift.js b/activitylink/src/api/manage/gift.js
index c1c7fab..c32a17e 100644
--- a/activitylink/src/api/manage/gift.js
+++ b/activitylink/src/api/manage/gift.js
@@ -21,11 +21,14 @@ export function deletePrize(id) {
})
}
//奖品分页查询
-export function getPrizeList(params) {
+export function getPrizeList(data) {
return request({
url: '/admin/prize/list',
method: 'post',
- params: params
+ data: data,
+ headers: {
+ 'Content-Type': 'application/json'
+ }
})
}
// 根据id查询奖品
diff --git a/activitylink/src/api/manage/level.js b/activitylink/src/api/manage/level.js
index 8e3bb68..73210f3 100644
--- a/activitylink/src/api/manage/level.js
+++ b/activitylink/src/api/manage/level.js
@@ -2,11 +2,14 @@
import request from '@/utils/request'
const baseUrl = import.meta.env.VITE_APP_BASE_API
// 等级查询
-export function getLevelList(params) {
+export function getLevelList(data) {
return request({
url: '/admin/grade/list',
method: 'post',
- params: params
+ data: data,
+ headers: {
+ 'Content-Type': 'application/json'
+ }
})
}
// 等级新增
diff --git a/activitylink/src/router/index.js b/activitylink/src/router/index.js
index 97c73a5..4ce3131 100644
--- a/activitylink/src/router/index.js
+++ b/activitylink/src/router/index.js
@@ -1,3 +1,4 @@
+import { ElMessage } from 'element-plus';
import { createRouter, createWebHistory } from 'vue-router'
import { ElMessageBox, ElMessage } from 'element-plus';
const routes = [
@@ -76,14 +77,13 @@ const router = createRouter({
history: createWebHistory('/testBack/'),
routes
})
-
router.beforeEach((to, from, next) => {
const token = localStorage.getItem("token");
- if (to.name != "homePage" && !token ) {
- ElMessage.error("请先登录!");
+ if (to.name != "homePage" && !token) {
next('/homePage');
+ ElMessage.error('请先登录!');
}
next();
})
-// 导出
+// 暴露
export default router
diff --git a/activitylink/src/utils/request.js b/activitylink/src/utils/request.js
index 2b18d0d..dbce302 100644
--- a/activitylink/src/utils/request.js
+++ b/activitylink/src/utils/request.js
@@ -36,14 +36,4 @@ service.interceptors.response.use(
return Promise.reject(error)
}
)
-export const uploadFile = (file) => {
- const formData = new FormData();
- formData.append('file', file);
-
- return service.post(import.meta.env.VITE_UPLOAD_URL, formData, {
- headers: {
- 'Content-Type': 'multipart/form-data'
- }
- });
-};
export default service
\ No newline at end of file
diff --git a/activitylink/src/views/homePage.vue b/activitylink/src/views/homePage.vue
index 6f5916c..4ec9414 100644
--- a/activitylink/src/views/homePage.vue
+++ b/activitylink/src/views/homePage.vue
@@ -43,7 +43,7 @@ const loginHandler = async () => {
if (response.code == 200 ) {
const token = response.data.token
- // console.log(token)
+ console.log('登录时候的token',token)
localStorage.setItem('token', token)
ElMessage.success('登录成功,欢迎您使用本系统')
router.push('/zhongchou/mainimg')
diff --git a/activitylink/src/views/zhongchou/gift/index.vue b/activitylink/src/views/zhongchou/gift/index.vue
index a9ddfa5..844ae1c 100644
--- a/activitylink/src/views/zhongchou/gift/index.vue
+++ b/activitylink/src/views/zhongchou/gift/index.vue
@@ -48,9 +48,10 @@
-
+
@@ -85,9 +86,10 @@
-
+
@@ -120,7 +122,7 @@ import { useRouter } from 'vue-router';
import { usegiftFixedListStone } from '@/stone/giftFixedListStone';
import { getPrizeList, addPrize, deletePrize, updatePrize } from '@/api/manage/gift';
import { getGradeNameList } from '@/api/manage/level';
-
+const validator = /^[a-zA-Z0-9\u4e00-\u9fa5]+$/ // 中英文和数字
const router = useRouter();
const gradeNames = ref([])
const tableData = ref([])
@@ -143,11 +145,7 @@ const editForm = ref({
gradeId: '',
imageUrl: null
})
-// const uploadUrl = 'https://api.homilychart.com/hljw/api/aws/upload'; //生产
-const uploadUrl = 'http://39.101.133.168:8828/hljw/api/aws/upload'; //测试
-// const uploadUrl = '/hljw/api/aws/upload'
-// const uploadUrl = 'https://39.101.133.168:8828/hljw/api/aws/upload'
-// const uploadUrl = '/api/upload/upload'
+const uploadUrl = import.meta.env.VITE_UPLOAD_URL
const formRef = ref(null)
const uploadRef = ref(null)
@@ -216,6 +214,14 @@ const submitAdd = async () => {
ElMessage.error('请上传图片');
return;
}
+ if(addForm.value.prizeName.length > 15){
+ ElMessage.error('奖品名称最多输入15个字符');
+ return;
+ }
+ if (!validator.test(addForm.value.prizeName)) {
+ ElMessage.error('礼品名称只能输入中英文和数字')
+ return
+ }
try {
const data = {
prizeName: addForm.value.prizeName,
@@ -243,7 +249,7 @@ const submitAdd = async () => {
}
// 删除
const deleteGift = (row) => {
- ElMessageBox.confirm('确定要删除该等级吗?', '提示', {
+ ElMessageBox.confirm('确定要删除该礼品吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
@@ -274,6 +280,14 @@ const submitEdit = async () => {
ElMessage.error('请上传图片');
return;
}
+ if(editForm.value.prizeName.length > 15){
+ ElMessage.error('奖品名称最多输入15个字符');
+ return;
+ }
+ if (!validator.test(editForm.value.prizeName)) {
+ ElMessage.error('礼品名称只能输入中英文和数字')
+ return
+ }
try {
const data = {
id: editForm.value.id,
@@ -308,7 +322,30 @@ const goToimportFixedList = (row) => {
}
});
}
+const customUpload = async (options) => {
+ try {
+ const formData = new FormData();
+ formData.append('file', options.file);
+
+ const response = await axios.post(import.meta.env.VITE_UPLOAD_URL, formData, {
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ 'Authorization': `Bearer ${localStorage.getItem('token')}`
+ }
+ });
+ if (response.data.code === 200 && response.data.data) {
+ // 传递原始文件对象和响应数据
+ handleUploadSuccess(response.data, options.file);
+ ElMessage.success('上传成功');
+ } else {
+ ElMessage.error(response.data.msg || '上传失败');
+ }
+ } catch (error) {
+ console.error('上传错误:', error);
+ ElMessage.error(`上传失败: ${error.response?.data?.message || error.message}`);
+ }
+};
const goToimportUsers = () => {
router.push({ name: 'importUsers' });
}
diff --git a/activitylink/src/views/zhongchou/index.vue b/activitylink/src/views/zhongchou/index.vue
index 487be2a..4f3df3c 100644
--- a/activitylink/src/views/zhongchou/index.vue
+++ b/activitylink/src/views/zhongchou/index.vue
@@ -95,10 +95,7 @@ const handleClose = (key, keyPath) => {
管理员管理
-
+
diff --git a/activitylink/src/views/zhongchou/level/index.vue b/activitylink/src/views/zhongchou/level/index.vue
index ffc7b49..1fd1884 100644
--- a/activitylink/src/views/zhongchou/level/index.vue
+++ b/activitylink/src/views/zhongchou/level/index.vue
@@ -43,16 +43,16 @@
-
+
-
+
-
+
@@ -69,16 +69,16 @@
-
+
-
+
-
+
@@ -96,6 +96,7 @@
import { ref, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getLevelList, addLevel, deleteGrade, updateGrade } from '@/api/manage/level'
+const validator = /^[a-zA-Z0-9\u4e00-\u9fa5]+$/ // 中英文和数字
const tableData = ref([])
const pagination = ref({
pageNum: 1,
@@ -156,6 +157,14 @@ const submitAdd = async () => {
ElMessage.error('请填写完整信息')
return
}
+ if (addForm.value.gradeName.length > 15) {
+ ElMessage.error('等级名称最多输入15个字符')
+ return
+ }
+ if (!validator.test(addForm.value.gradeName)) {
+ ElMessage.error('等级名称只能输入中英文和数字')
+ return
+ }
try {
const data = {
gradeName: String(addForm.value.gradeName),
@@ -184,6 +193,14 @@ const submitEdit = async () => {
ElMessage.error('请填写完整信息')
return
}
+ if (editForm.value.gradeName.length > 15) {
+ ElMessage.error('等级名称最多输入15个字符')
+ return
+ }
+ if (!validator.test(editForm.value.gradeName)) {
+ ElMessage.error('等级名称只能输入中英文和数字')
+ return
+ }
try {
const editData = {
id: editForm.value.id,
diff --git a/activitylink/vite.config.js b/activitylink/vite.config.js
index 4250ced..36e8f7e 100644
--- a/activitylink/vite.config.js
+++ b/activitylink/vite.config.js
@@ -3,7 +3,7 @@ import vue from '@vitejs/plugin-vue';
import path from 'path';
export default defineConfig({
- base: '/testBack/',
+ base: '/testBack/',
plugins: [vue()],
resolve: {
alias: {
@@ -12,21 +12,11 @@ export default defineConfig({
},
server: {
proxy: {
-
- // 新增 /upload 代理
- '/hljw/api/aws/upload': {
- target: 'http://39.101.133.168:8828', // 目标服务器(HTTP)
- changeOrigin: true, // 改变请求头中的 host
- secure: false, // 忽略 HTTPS 证书验证(如果目标是 HTTPS)
- rewrite: (path) => path // 保持路径不变
- },
- // 原有 /api 代理
'/api': {
target: 'https://dbqb.nfdxy.net',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
},
-
}
}
-});
\ No newline at end of file
+});