From dcabf6707255fadf0c0236037450e07547127460 Mon Sep 17 00:00:00 2001 From: lihuilin Date: Tue, 22 Jul 2025 15:43:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B7=A8=E5=9F=9F=E4=B8=8D=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- activitylink/.env.development | 3 ++- activitylink/.env.production | 3 ++- activitylink/package.json | 3 ++- activitylink/src/utils/request.js | 7 ++---- activitylink/src/views/zhongchou/gift/index.vue | 29 ++++++++++++++++++++++--- activitylink/vite.config.js | 5 +++++ 6 files changed, 39 insertions(+), 11 deletions(-) diff --git a/activitylink/.env.development b/activitylink/.env.development index 40cb689..123b1ff 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='/hljw/api/aws/upload' \ No newline at end of file diff --git a/activitylink/.env.production b/activitylink/.env.production index b4c1ecc..7ad2e01 100644 --- a/activitylink/.env.production +++ b/activitylink/.env.production @@ -4,4 +4,5 @@ VITE_PUBLIC_PATH = '/testBack/' VITE_USE_MOCK = true 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' + diff --git a/activitylink/package.json b/activitylink/package.json index 557f07f..b2fe597 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/utils/request.js b/activitylink/src/utils/request.js index c0fa594..fc242c9 100644 --- a/activitylink/src/utils/request.js +++ b/activitylink/src/utils/request.js @@ -29,11 +29,8 @@ service.interceptors.response.use( 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' - } + return service.post('/api/upload/hljw/api/aws/upload', formData, { + headers: {'Content-Type': 'multipart/form-data'} }); }; export default service \ No newline at end of file diff --git a/activitylink/src/views/zhongchou/gift/index.vue b/activitylink/src/views/zhongchou/gift/index.vue index 829fa1a..d528bbd 100644 --- a/activitylink/src/views/zhongchou/gift/index.vue +++ b/activitylink/src/views/zhongchou/gift/index.vue @@ -48,7 +48,7 @@ - @@ -143,7 +143,7 @@ const editForm = ref({ gradeId: '', imageUrl: null }) -const uploadUrl = '/hljw/api/aws/upload'; +const uploadUrl = ref('/upload') const formRef = ref(null) const uploadRef = ref(null) @@ -239,7 +239,7 @@ const submitAdd = async () => { } // 删除 const deleteGift = (row) => { - ElMessageBox.confirm('确定要删除该等级吗?', '提示', { + ElMessageBox.confirm('确定要删除该礼品吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' @@ -304,7 +304,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/vite.config.js b/activitylink/vite.config.js index 26441e2..c23f85b 100644 --- a/activitylink/vite.config.js +++ b/activitylink/vite.config.js @@ -19,6 +19,11 @@ export default defineConfig({ rewrite: (path) => path.replace(/^\/api/, ''), // 移除 /api 前缀 // 或者更精确的重写(根据后端路径调整): // rewrite: (path) => path.replace(/^\/api\/admin/, '/admin'), + }, + '/upload': { + target: 'http://39.101.133.168:8828', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/upload/, ''), } }, }, From 78fae4c09925516e38e85c69ddf6207737d47348 Mon Sep 17 00:00:00 2001 From: lihuilin Date: Wed, 23 Jul 2025 10:46:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- activitylink/.env.development | 3 +- activitylink/.env.production | 1 + activitylink/.env.test | 7 ++++ activitylink/package.json | 3 +- activitylink/src/api/manage/gift.js | 7 ++-- activitylink/src/api/manage/level.js | 7 ++-- activitylink/src/views/homePage.vue | 2 +- activitylink/src/views/zhongchou/gift/index.vue | 24 ++++++++++---- activitylink/src/views/zhongchou/level/index.vue | 41 +++++++++++++++++------- activitylink/vite.config.js | 33 ++++++++----------- 10 files changed, 83 insertions(+), 45 deletions(-) create mode 100644 activitylink/.env.test diff --git a/activitylink/.env.development b/activitylink/.env.development index 40cb689..38be259 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' \ No newline at end of file diff --git a/activitylink/.env.production b/activitylink/.env.production index b4c1ecc..9c652b5 100644 --- a/activitylink/.env.production +++ b/activitylink/.env.production @@ -4,4 +4,5 @@ VITE_PUBLIC_PATH = '/testBack/' VITE_USE_MOCK = true VITE_BUILD_COMPRESS = 'none' VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false +VITE_UPLOAD_URL='https://api.homilychart.com/hljw/api/aws/upload' VITE_APP_BASE_API = 'https://dbqb.nfdxy.net/devLotApi/' \ No newline at end of file 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/views/homePage.vue b/activitylink/src/views/homePage.vue index 68a0a80..3e4ffdd 100644 --- a/activitylink/src/views/homePage.vue +++ b/activitylink/src/views/homePage.vue @@ -38,7 +38,7 @@ const loginHandler = async () => { // router.push('/zhongchou/mainimg') 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..5c8aa80 100644 --- a/activitylink/src/views/zhongchou/gift/index.vue +++ b/activitylink/src/views/zhongchou/gift/index.vue @@ -120,7 +120,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 +143,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 +212,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, @@ -274,6 +278,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, diff --git a/activitylink/src/views/zhongchou/level/index.vue b/activitylink/src/views/zhongchou/level/index.vue index 47b6165..dc49ae4 100644 --- a/activitylink/src/views/zhongchou/level/index.vue +++ b/activitylink/src/views/zhongchou/level/index.vue @@ -43,16 +43,16 @@ - + - + - +