bugfix: 验证码输入状态
feat: 接收语言参数
This commit is contained in:
@@ -1,4 +1,2 @@
|
|||||||
# VITE_APP_URL = http://192.168.31.82:8771
|
VITE_USER_NODE_ENV = 'development'
|
||||||
# VITE_APP_URL = http://18.167.251.121:10095
|
VITE_APP_BASE_URL = 'https://develop.api.aida.com.hk'
|
||||||
VITE_APP_URL = https://www.lc-api.aida.com.hk
|
|
||||||
VITE_GOOGLE_CLIENT_ID = 216037134725-7q8vqp0ohtmohlosltkfg7bd2v29rm5a.apps.googleusercontent.com
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
VITE_APP_URL = https://www.lc-api.aida.com.hk
|
VITE_USER_NODE_ENV = 'production'
|
||||||
# VITE_APP_URL = http://18.167.251.121:10095
|
# VITE_APP_BASE_URL = 'http://18.167.251.121:10086'
|
||||||
VITE_GOOGLE_CLIENT_ID = 29310152396-nnsd3h533fld665oguu8ovrt1nukmt46.apps.googleusercontent.com
|
# VITE_APP_BASE_URL = 'https://polyu.api.aida.com.hk'
|
||||||
|
VITE_APP_BASE_URL = 'https://www.api.aida.com.hk'
|
||||||
@@ -10,23 +10,25 @@ const router = createRouter({
|
|||||||
history: createWebHistory('/'),
|
history: createWebHistory('/'),
|
||||||
// history: createWebHistory(import.meta.env.VITE_APP_URL),
|
// history: createWebHistory(import.meta.env.VITE_APP_URL),
|
||||||
routes: [
|
routes: [
|
||||||
|
// {
|
||||||
|
// path: '/',
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/:lang?',
|
||||||
name:'award',
|
component: () => import('@/views/AwardPage/container.vue'),
|
||||||
component:()=>import('@/views/AwardPage/container.vue'),
|
children: [
|
||||||
children:[
|
|
||||||
{
|
{
|
||||||
path:'',
|
path: '',
|
||||||
name:'AwardIndex',
|
name: 'AwardIndex',
|
||||||
component:()=>import('@/views/AwardPage/index.vue'),
|
component: () => import('@/views/AwardPage/index.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path:'contestants',
|
path: 'contestants',
|
||||||
component:()=>import('@/views/AwardPage/apply.vue')
|
name: 'Contestants',
|
||||||
|
component: () => import('@/views/AwardPage/contestants.vue')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
path: '/:pathMatch(.*)',
|
path: '/:pathMatch(.*)',
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
import router from './index'
|
import router from './index'
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
next()
|
const path = to.path
|
||||||
|
const list = {
|
||||||
|
zh: 'CHINESE_SIMPLIFIED',
|
||||||
|
en: 'ENGLISH'
|
||||||
|
}
|
||||||
|
if (path.startsWith('/zh') || (to.params.lang === 'zh')) {
|
||||||
|
localStorage.setItem('loginLanguage', 'CHINESE_SIMPLIFIED')
|
||||||
|
} else if (path.startsWith('/en') || (to.params.lang === 'en')) {
|
||||||
|
localStorage.setItem('loginLanguage', 'ENGLISH')
|
||||||
|
}
|
||||||
|
|
||||||
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
|
|||||||
@@ -1,191 +1,203 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
// import qs from 'qs'
|
||||||
|
// import message from '@/components/public/message/src'
|
||||||
import router from '@/router/index'
|
import router from '@/router/index'
|
||||||
import { useGlobalStore, useUserInfoStore } from '@/stores'
|
import { getCookie, clonAllCookie } from '@/utils/cookie'
|
||||||
|
// import cookie from '@/tools/cookie.js'
|
||||||
|
|
||||||
// 扩展 AxiosRequestConfig 接口
|
axios.defaults.timeout = 60000 //响应时间
|
||||||
declare module 'axios' {
|
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; //配置请求头
|
||||||
interface AxiosRequestConfig {
|
|
||||||
loading?: boolean
|
|
||||||
loadingDom?: any
|
|
||||||
repeatRequest?: boolean
|
|
||||||
meta?: {
|
|
||||||
responseAll?: boolean
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建axios实例
|
|
||||||
// console.log(import.meta.env,123)
|
|
||||||
|
|
||||||
const service = axios.create({
|
|
||||||
// baseURL: import.meta.env.VITE_APP_URL, // api的base_url
|
|
||||||
timeout: 60000 // 请求超时时间
|
|
||||||
})
|
|
||||||
if (import.meta.env.MODE != 'development') {
|
|
||||||
service.defaults.baseURL = import.meta.env.VITE_APP_URL
|
|
||||||
}
|
|
||||||
axios.defaults.headers.post['Content-Type'] = 'application/json'
|
axios.defaults.headers.post['Content-Type'] = 'application/json'
|
||||||
|
|
||||||
axios.defaults.headers.post['lang'] = 'en' //配置语言请求头
|
axios.defaults.headers.post['lang'] = 'en' //配置语言请求头
|
||||||
axios.defaults.withCredentials = true //跨域携带cookie
|
axios.defaults.withCredentials = true //跨域携带cookie
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
|
||||||
// request拦截器
|
let httpIp = import.meta.env.VITE_USER_NODE_ENV == 'development' ? '' : ''
|
||||||
service.interceptors.request.use(
|
// let httpIp = import.meta.env.VITE_USER_NODE_ENV == 'development' ? "https://192.168.1.8:10086" : "";
|
||||||
(config: any) => {
|
|
||||||
removePending(config)
|
axios.defaults.baseURL = httpIp //配置接口地址
|
||||||
// 如果repeatRequest不配置,那么默认该请求就取消重复接口请求
|
// console.log(axios.defaults.baseURL);
|
||||||
!config.repeatRequest && addPending(config)
|
axios.defaults.baseURL = import.meta.env.VITE_APP_BASE_URL //配置接口地址
|
||||||
// 打开loading
|
console.log(import.meta.env.VITE_APP_BASE_URL)
|
||||||
if (config.loading) {
|
|
||||||
LoadingInstance._count++
|
// 创建取消令牌
|
||||||
if (LoadingInstance._count === 1) {
|
const CancelToken = axios.CancelToken
|
||||||
openLoading(config.loadingDom)
|
const source = CancelToken.source()
|
||||||
}
|
// console.log(import.meta.env.VITE_APP_BASE_URL);
|
||||||
}
|
let isLoginTime = false
|
||||||
// 如果登录了,有token,则请求携带token
|
//POST传参序列化(添加请求拦截器)
|
||||||
// Do something before request is sent
|
axios.interceptors.request.use(
|
||||||
const token = useUserInfoStore().state.token
|
(config) => {
|
||||||
if (token) {
|
//在发送请求之前做某件事
|
||||||
config.headers.Authorization = token // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
|
|
||||||
// config.headers['X-Token'] = getLocal('token') // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
|
if (config.method === 'post' || config.method === 'put' || config.method === 'delete') {
|
||||||
|
// config.data = qs.stringify(config.data);
|
||||||
}
|
}
|
||||||
|
config.headers.Authorization = getCookie('token')
|
||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
// Do something with request error
|
|
||||||
console.log(error) // for debug
|
|
||||||
Promise.reject(error)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// respone拦截器
|
|
||||||
service.interceptors.response.use(
|
|
||||||
// response => response,
|
|
||||||
/**
|
|
||||||
* 下面的注释为通过response自定义code来标示请求状态,当code返回如下情况为权限有问题,登出并返回到登录页
|
|
||||||
* 如通过xmlhttprequest 状态码标识 逻辑可写在下面error中
|
|
||||||
*/
|
|
||||||
(response: any) => {
|
|
||||||
// 如果是llm/streamChat这样的流式接口,不走这样的处理
|
|
||||||
if (response.config.url.includes('llm/streamChat')) {
|
|
||||||
return response
|
|
||||||
}
|
|
||||||
|
|
||||||
// 已完成请求的删除请求中数组
|
|
||||||
removePending(response.config)
|
|
||||||
// 关闭loading
|
|
||||||
if (response.config.loading) {
|
|
||||||
closeLoading()
|
|
||||||
}
|
|
||||||
const res = response.data
|
|
||||||
// 处理异常的情况
|
|
||||||
// console.log(res)
|
|
||||||
if (res.code != 0) {
|
|
||||||
// showToast({
|
|
||||||
// message: res.errMsg || res.message,
|
|
||||||
// // type: 'fail',
|
|
||||||
// duration: 5000,
|
|
||||||
// position: 'top',
|
|
||||||
// icon: 'none'
|
|
||||||
// })
|
|
||||||
return Promise.reject(new Error(res.errMsg || res.message || 'error'))
|
|
||||||
} else {
|
|
||||||
// 默认只返回data,不返回状态码和message
|
|
||||||
// 通过 meta 中的 responseAll 配置来取决后台是否返回所有数据(包括状态码,message和data)
|
|
||||||
const isbackAll = response.config.meta && response.config.meta.responseAll
|
|
||||||
if (isbackAll) {
|
|
||||||
return res
|
|
||||||
} else {
|
|
||||||
return res.data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
if(error?.response){
|
|
||||||
if (error.config?.loading) closeLoading() // 关闭loading
|
|
||||||
if(error?.response?.status === 401){//如果是记录浏览器页面就不跳转login
|
|
||||||
// showConfirmDialog({
|
|
||||||
// title: '确定登出',
|
|
||||||
// message: '你已被登出,可以取消继续留在该页面,或者重新登录',
|
|
||||||
// confirmButtonText: '重新登录',
|
|
||||||
// cancelButtonText: '取消'
|
|
||||||
// }).then(() => {
|
|
||||||
// store.loginOut().then(() => {
|
|
||||||
// location.reload() // 为了重新实例化vue-router对象 避免bug
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// showToast({
|
|
||||||
// message: 'Please log in and try again.',
|
|
||||||
// duration: 5000
|
|
||||||
// })
|
|
||||||
// router.push('/login')
|
|
||||||
// useGenerateStore().clearGenerateData()
|
|
||||||
return Promise.reject(false)
|
|
||||||
}
|
|
||||||
error.config && removePending(error.config)
|
|
||||||
console.log('err' + error) // for debug
|
|
||||||
// showToast({
|
|
||||||
// message: error.message,
|
|
||||||
// type: 'fail',
|
|
||||||
// duration: 5000
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
const binaryToUrl = (binary, type = 'application/json', res) => {
|
||||||
// --------------------------------取消接口重复请求的函数-----------------------------------
|
let blob = new Blob([binary], { 'content-type': type })
|
||||||
// axios.js
|
let url = URL.createObjectURL(blob)
|
||||||
const pendingMap = new Map()
|
return url
|
||||||
/**
|
|
||||||
* 生成每个请求唯一的键
|
|
||||||
* @param {*} config
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
function getPendingKey(config: any) {
|
|
||||||
const { url, method, params } = config
|
|
||||||
let { data } = config
|
|
||||||
if (typeof data === 'string') data = JSON.parse(data) // response里面返回的config.data是个字符串对象
|
|
||||||
return [url, method, JSON.stringify(params), JSON.stringify(data)].join('&')
|
|
||||||
}
|
}
|
||||||
|
//返回状态判断(添加响应拦截器)
|
||||||
|
axios.interceptors.response.use(
|
||||||
|
(res) => {
|
||||||
|
// 允许透传完整响应:请求时传 config.fullData = true
|
||||||
|
|
||||||
/**
|
// if(res.data.data == null){
|
||||||
* 储存每个请求唯一值, 也就是cancel()方法, 用于取消请求
|
// message.warning(res.data.errMsg)
|
||||||
* @param {*} config
|
// return Promise.reject(res.data);
|
||||||
*/
|
// }else
|
||||||
function addPending(config: any) {
|
if (res?.config?.env?.binary) {
|
||||||
const pendingKey = getPendingKey(config)
|
let url = binaryToUrl(res.data, res.config.env.binaryType, res)
|
||||||
config.cancelToken =
|
return Promise.resolve({ url, data: res.data })
|
||||||
config.cancelToken ||
|
}
|
||||||
new axios.CancelToken((cancel) => {
|
if (res?.data) {
|
||||||
if (!pendingMap.has(pendingKey)) {
|
if (res?.data?.errCode === 0) {
|
||||||
pendingMap.set(pendingKey, cancel)
|
// message.error(res?.data?.errMsg)
|
||||||
|
if (res?.config?.fullData) {
|
||||||
|
return Promise.resolve(res.data)
|
||||||
|
}
|
||||||
|
return Promise.resolve(res?.data?.data)
|
||||||
|
} else if (res?.data?.errCode === 1) {
|
||||||
|
message.warning(res?.data?.errMsg)
|
||||||
|
return Promise.reject(res?.data)
|
||||||
|
} else if (res?.data?.errCode === 2) {
|
||||||
|
return Promise.reject(res?.data)
|
||||||
|
} else if (res?.data?.errCode === -1) {
|
||||||
|
message.error(res?.data?.errMsg)
|
||||||
|
return Promise.reject(res?.data)
|
||||||
}
|
}
|
||||||
})
|
} else {
|
||||||
}
|
if (res?.data?.errCode === 0) {
|
||||||
/**
|
message.warning(res?.data?.errMsg)
|
||||||
* 删除重复的请求
|
return Promise.reject(res?.data)
|
||||||
* @param {*} config
|
} else if (res?.data?.errCode === 1) {
|
||||||
*/
|
message.warning(res?.data?.errMsg)
|
||||||
function removePending(config: any) {
|
return Promise.reject(res?.data)
|
||||||
const pendingKey = getPendingKey(config)
|
} else if (res?.data?.errCode === 2) {
|
||||||
if (pendingMap.has(pendingKey)) {
|
return Promise.reject(res?.data)
|
||||||
const cancelToken = pendingMap.get(pendingKey)
|
} else if (res?.data?.errCode === -1) {
|
||||||
cancelToken(pendingKey)
|
message.error(res?.data?.errMsg)
|
||||||
pendingMap.delete(pendingKey)
|
return Promise.reject(res?.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
if (error?.response?.status === 401 && router.currentRoute._value.name != 'setIdentification') {
|
||||||
|
//如果是记录浏览器页面就不跳转login
|
||||||
|
clonAllCookie()
|
||||||
|
if (!isLoginTime) {
|
||||||
|
isLoginTime = true
|
||||||
|
let isSystemUserRouteList = ['/Square'] //如果是这两个页面就无需跳转未登录页
|
||||||
|
let sSystemUser = false
|
||||||
|
for (let index = 0; index < isSystemUserRouteList.length; index++) {
|
||||||
|
if (router.currentRoute.value.path.indexOf(isSystemUserRouteList[index]) > -1) {
|
||||||
|
sSystemUser = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!sSystemUser) {
|
||||||
|
router.replace('/')
|
||||||
|
}
|
||||||
|
message.warning('Please login and try again~')
|
||||||
|
setTimeout(() => [(isLoginTime = false)], 2000)
|
||||||
|
}
|
||||||
|
// source.cancel('取消后续接口调用');
|
||||||
|
return Promise.reject()
|
||||||
|
}
|
||||||
|
let data_new = error?.response?.data
|
||||||
|
// message.error(data_new?.errMsg || 'Error: server exception')
|
||||||
|
return Promise.reject(data_new)
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
// ----------------------------------loading的函数-------------------------------
|
export const Https = {
|
||||||
const LoadingInstance: { _count: number } = {
|
httpUrls: {
|
||||||
_count: 0
|
// award页面
|
||||||
}
|
checkEmail: '/api/global-award/checkEmail', // 检查邮箱是否存在
|
||||||
function openLoading(loadingDom: any) {
|
checkOTP: '/api/global-award/checkCode', // 检查验证码是否正确
|
||||||
useGlobalStore().setLoading(true)
|
initPdfUpload: '/api/global-award/uploads/pdf/init', // 初始化pdf上传
|
||||||
}
|
initVideoUpload: '/api/global-award/uploads/video/init', // 初始化video上传
|
||||||
function closeLoading() {
|
uploadPDF: '/api/global-award/uploads/pdf/chunk', // 上传pdf
|
||||||
if (LoadingInstance._count > 0) LoadingInstance._count--
|
uploadVideo: '/api/global-award/uploads/video/chunk', // 上传video
|
||||||
if (LoadingInstance._count === 0) {
|
uploadPDFComplete: '/api/global-award/uploads/pdf/complete', // 上传pdf完成
|
||||||
useGlobalStore().setLoading(false)
|
uploadVideoComplete: '/api/global-award/uploads/video/complete', // 上传video完成
|
||||||
}
|
submitForm: '/api/global-award/contestants/save', // 提交表单
|
||||||
}
|
getContestantByID: '/api/global-award/contestants/' // 获取表单
|
||||||
|
},
|
||||||
|
|
||||||
export default service
|
axiosGet(url, config) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (isLoginTime && url != '/api/portfolio/page') {
|
||||||
|
resolve('')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
axios
|
||||||
|
.get(url, config)
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
axiosPut(url, data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (isLoginTime && url != '/api/portfolio/page') {
|
||||||
|
resolve('')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
axios
|
||||||
|
.put(url, data)
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
axiosPost(url, data, config) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (isLoginTime && url != '/api/portfolio/page') {
|
||||||
|
resolve('')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
axios
|
||||||
|
.post(url, data, config)
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
axiosDelete(url, newData) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (isLoginTime && url != '/api/portfolio/page') {
|
||||||
|
resolve('')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
axios
|
||||||
|
.delete(url, { data: newData })
|
||||||
|
.then((response) => {
|
||||||
|
resolve(response)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -147,10 +147,11 @@
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
const handleBtnClick = () => {
|
const handleBtnClick = () => {
|
||||||
|
const lang = route.params.lang ? `/${route.params.lang}` : ''
|
||||||
if (btnType.value === 'index') {
|
if (btnType.value === 'index') {
|
||||||
router.push('/award/contestants')
|
router.push(`${lang}/contestants`)
|
||||||
} else {
|
} else {
|
||||||
router.push('/award/index')
|
router.push(`${lang}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
1573
src/views/AwardPage/contestants.vue
Normal file
1573
src/views/AwardPage/contestants.vue
Normal file
File diff suppressed because it is too large
Load Diff
@@ -65,7 +65,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
const handleSubmitApplication = () => {
|
const handleSubmitApplication = () => {
|
||||||
router.push('/award/contestants')
|
router.push('/contestants')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user