mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2025-12-11 17:42:47 +00:00
update web
This commit is contained in:
parent
89abab8153
commit
37c3d53188
@ -2,14 +2,14 @@
|
||||
* 用户名登录
|
||||
*/
|
||||
export function usernameLogin(data: AnyObject) {
|
||||
return request.get('login', data, { showErrorMessage: true })
|
||||
return request.get('login', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机验证码登录
|
||||
*/
|
||||
export function mobileLogin(data: AnyObject) {
|
||||
return request.post('login/mobile', data, { showErrorMessage: true })
|
||||
return request.post('login/mobile', data)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,14 +30,14 @@ export function logout() {
|
||||
* 用户名注册
|
||||
*/
|
||||
export function usernameRegister(data: AnyObject) {
|
||||
return request.post('register', data, { showErrorMessage: true })
|
||||
return request.post('register', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号注册
|
||||
*/
|
||||
export function mobileRegister(data: AnyObject) {
|
||||
return request.post('register/mobile', data, { showErrorMessage: true })
|
||||
return request.post('register/mobile', data)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,19 +58,19 @@ export function weappLogin(data: AnyObject) {
|
||||
* 绑定手机号
|
||||
*/
|
||||
export function bind(data: AnyObject) {
|
||||
return request.post('bind', data, { showErrorMessage: true })
|
||||
return request.post('bind', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码登录
|
||||
*/
|
||||
export function scanlogin() {
|
||||
return request.post('wechat/scanlogin', { showErrorMessage: true })
|
||||
return request.post('wechat/scanlogin')
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验扫码信息
|
||||
*/
|
||||
export function checkscan(data: AnyObject) {
|
||||
return request.get('checkscan', data, { showErrorMessage: true })
|
||||
return request.get('checkscan', data)
|
||||
}
|
||||
@ -6,7 +6,7 @@ export function getMemberInfo() {
|
||||
* 会员信息修改
|
||||
*/
|
||||
export function modifyMember(data: AnyObject) {
|
||||
return request.put(`member/modify/${data.field}`, data, { showErrorMessage: true })
|
||||
return request.put(`member/modify/${data.field}`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -27,5 +27,5 @@ export function getBalanceList(data: AnyObject) {
|
||||
* 登录会员绑定手机号
|
||||
*/
|
||||
export function bindMobile(data: AnyObject) {
|
||||
return request.put('member/mobile', data, { showErrorMessage: true })
|
||||
return request.put('member/mobile', data)
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
* 获取验证码
|
||||
*/
|
||||
export function getCaptcha() {
|
||||
return request.get('captcha', {}, { showErrorMessage: true })
|
||||
return request.get('captcha', {})
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,14 +30,14 @@ export function getAgreementInfo(key: string) {
|
||||
* 重置密码
|
||||
*/
|
||||
export function resetPassword(data: AnyObject) {
|
||||
return request.post(`/password/reset`, data, { showErrorMessage: true })
|
||||
return request.post(`password/reset`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信验证码
|
||||
*/
|
||||
export function sendSms(data: AnyObject) {
|
||||
return request.post(`send/mobile/${data.type}`, data, { showErrorMessage: true })
|
||||
return request.post(`send/mobile/${data.type}`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,4 +66,11 @@ export function fetchBase64Image(data: AnyObject) {
|
||||
*/
|
||||
export function getCopyRight(data: AnyObject) {
|
||||
return request.get('copyright', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点信息
|
||||
*/
|
||||
export function getSiteInfo() {
|
||||
return request.get('site')
|
||||
}
|
||||
@ -32,6 +32,9 @@ const locale = computed(() => (systemStore.lang === 'zh-cn' ? zhCn : en))
|
||||
const configStore = useConfigStore()
|
||||
configStore.getLoginConfig()
|
||||
|
||||
// 查询站点信息
|
||||
systemStore.getSitenfo()
|
||||
|
||||
// 如果已登录
|
||||
getToken() && useMemberStore().setToken(getToken())
|
||||
|
||||
@ -63,8 +66,8 @@ language.loadLocaleMessages(route.path, useSystemStore().lang)
|
||||
useHead({
|
||||
titleTemplate: (productCategory) => {
|
||||
return productCategory
|
||||
? `${productCategory} - NIUCLOUD-ADMIN 一款快速开发SAAS通用管理系统后台框架`
|
||||
: 'NIUCLOUD-ADMIN 一款快速开发SAAS通用管理系统后台框架'
|
||||
? `${productCategory} - ${systemStore.site.front_end_name || systemStore.site.site_name}`
|
||||
: systemStore.site.front_end_name
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@ -11,7 +11,7 @@ export function useCaptcha(formData: formData) {
|
||||
const refresh = async () => {
|
||||
try {
|
||||
await getCaptcha().then((res: any) => {
|
||||
if (res.code == 200) {
|
||||
if (res.code == 1) {
|
||||
formData.captcha_key = res.data.captcha_key
|
||||
formData.captcha_code = ''
|
||||
image.value = res.data.img.replace(/\r\n/g, '')
|
||||
|
||||
@ -13,7 +13,7 @@ export function useSendSms() {
|
||||
|
||||
let result: string | boolean = false
|
||||
await sendSms(param).then((res: responseResult) => {
|
||||
if (res.code == 200) {
|
||||
if (res.code == 1) {
|
||||
start()
|
||||
result = res.data.key
|
||||
} else {
|
||||
|
||||
4
web/env/.env.dev
vendored
4
web/env/.env.dev
vendored
@ -1,8 +1,8 @@
|
||||
# api请求地址
|
||||
VITE_APP_BASE_URL=''
|
||||
VITE_APP_BASE_URL='https://www.niucloud.com/api/'
|
||||
|
||||
# 图片服务器地址
|
||||
VITE_IMG_DOMAIN=''
|
||||
VITE_IMG_DOMAIN='https://www.niucloud.com'
|
||||
|
||||
# 本地开发时站点id
|
||||
VITE_SITE_ID = 1
|
||||
|
||||
@ -9,5 +9,27 @@
|
||||
"captchaPlaceholder": "请输入验证码",
|
||||
"mobilePlaceholder": "请输入手机号码",
|
||||
"mobileError": "请输入正确的手机号",
|
||||
"codePlaceholder": "请输入手机验证码"
|
||||
"codePlaceholder": "请输入手机验证码",
|
||||
"userAgreement": "用户协议",
|
||||
"privacyAgreement": "隐私协议",
|
||||
"protocolNotConfigured": "未配置协议",
|
||||
"siteClose": "站点已关闭",
|
||||
"siteNonexistence": "站点不存在",
|
||||
"request": {
|
||||
"unknownError": "未知错误",
|
||||
"400": "错误的请求",
|
||||
"401": "请重新登录",
|
||||
"403": "拒绝访问",
|
||||
"404": "请求错误",
|
||||
"405": "请求方法未允许",
|
||||
"408": "请求超时",
|
||||
"409": "请求跨域",
|
||||
"500": "服务器端出错,错误原因:",
|
||||
"501": "网络未实现",
|
||||
"502": "网络错误",
|
||||
"503": "服务不可用",
|
||||
"504": "网络超时",
|
||||
"505": "http版本不支持该请求",
|
||||
"timeout": "网络请求超时!"
|
||||
}
|
||||
}
|
||||
@ -15,6 +15,10 @@
|
||||
"article": {
|
||||
"list": "文章",
|
||||
"detail": "文章"
|
||||
}
|
||||
},
|
||||
"site": {
|
||||
"close": "站点已关闭",
|
||||
"nonexistence": "站点不存在"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,6 @@ onMounted(() => {
|
||||
|
||||
const obtainArricleInfo = (id) => {
|
||||
getArticleDetail(id).then(res => {
|
||||
console.log(res)
|
||||
articleDeatail.value = res.data;
|
||||
})
|
||||
}
|
||||
|
||||
29
web/pages/auth/agreement.vue
Normal file
29
web/pages/auth/agreement.vue
Normal file
@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<div class="w-full pt-6 min-h-[100%] flex flex-col justify-center">
|
||||
<template v-if="agreement">
|
||||
<div class="main-container" v-if="agreement.title && agreement.content">
|
||||
<h2 class="text-center">{{ agreement.title }}</h2>
|
||||
<div v-html="agreement.content"></div>
|
||||
</div>
|
||||
<el-empty :description="t('protocolNotConfigured')" v-else />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { getAgreementInfo } from '@/api/system'
|
||||
|
||||
const agreement = ref<any | null>(null)
|
||||
const route = useRoute()
|
||||
|
||||
getAgreementInfo(route.query.key).then(({ data }) => {
|
||||
agreement.value = data
|
||||
|
||||
useHead({
|
||||
title: data.title
|
||||
})
|
||||
}).catch(err => {
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@ -64,6 +64,18 @@
|
||||
<el-button type="primary" class="mt-[20px] w-full" size="large" @click="handleLogin"
|
||||
:loading="loading">{{ loading ? t('logining') : t('login') }}</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<div class="text-xs py-[50rpx] flex justify-center w-full" v-if="configStore.login.agreement_show">
|
||||
{{ t('agreeTips') }}
|
||||
<NuxtLink to="/auth/agreement?key=service">
|
||||
<span class="text-primary">{{ t('userAgreement') }}</span>
|
||||
</NuxtLink>
|
||||
{{ t('and') }}
|
||||
<NuxtLink to="/auth/agreement?key=privacy">
|
||||
<span class="text-primary">{{ t('privacyAgreement') }}</span>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -73,6 +73,17 @@
|
||||
<el-button type="primary" class="mt-[20px] w-full" size="large" @click="handleRegister"
|
||||
:loading="loading">{{ loading ? t('registering') : t('register') }}</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<div class="text-xs py-[50rpx] flex justify-center w-full" v-if="configStore.login.agreement_show">
|
||||
{{ t('registerAgreeTips') }}
|
||||
<NuxtLink to="/auth/agreement?key=service">
|
||||
<span class="text-primary">{{ t('userAgreement') }}</span>
|
||||
</NuxtLink>
|
||||
{{ t('and') }}
|
||||
<NuxtLink to="/auth/agreement?key=privacy">
|
||||
<span class="text-primary">{{ t('privacyAgreement') }}</span>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -85,7 +85,6 @@ const upload = computed(() => {
|
||||
limit: 1,
|
||||
headers,
|
||||
onSuccess: (response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
||||
console.log('uploadFile',);
|
||||
let img = uploadFile?.response?.data?.url;
|
||||
if (response.code == 200) {
|
||||
modifyMember({
|
||||
|
||||
14
web/pages/site/close.vue
Normal file
14
web/pages/site/close.vue
Normal file
@ -0,0 +1,14 @@
|
||||
<template>
|
||||
<div class="w-screen h-screen flex flex-col items-center justify-center">
|
||||
<el-empty :description="t('siteClose')" :image="img('static/resource/images/site/close.png')" image-size="300px" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
definePageMeta({
|
||||
layout: "container"
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
15
web/pages/site/nonexistence.vue
Normal file
15
web/pages/site/nonexistence.vue
Normal file
@ -0,0 +1,15 @@
|
||||
<template>
|
||||
<div class="w-screen h-screen flex flex-col items-center justify-center">
|
||||
<el-empty :description="t('siteNonexistence')" :image="img('static/resource/images/site/close.png')"
|
||||
image-size="300px" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
definePageMeta({
|
||||
layout: "container"
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@ -5,7 +5,8 @@ interface loginConfig {
|
||||
is_username: number | boolean,
|
||||
is_mobile: number | boolean,
|
||||
is_auth_register: number | boolean,
|
||||
is_bind_mobile: number | boolean
|
||||
is_bind_mobile: number | boolean,
|
||||
agreement_show: number | boolean
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +22,8 @@ const useConfigStore = defineStore('config', {
|
||||
is_username: 0,
|
||||
is_mobile: 0,
|
||||
is_auth_register: 0,
|
||||
is_bind_mobile: 0
|
||||
is_bind_mobile: 0,
|
||||
agreement_show: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -32,6 +34,7 @@ const useConfigStore = defineStore('config', {
|
||||
this.login.is_mobile = parseInt(data.is_mobile)
|
||||
this.login.is_auth_register = parseInt(data.is_auth_register)
|
||||
this.login.is_bind_mobile = parseInt(data.is_bind_mobile)
|
||||
this.login.agreement_show = parseInt(data.agreement_show)
|
||||
}).catch(() => {
|
||||
|
||||
})
|
||||
|
||||
@ -1,14 +1,32 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import storage from '@/utils/storage'
|
||||
import { getSiteInfo } from '@/api/system'
|
||||
|
||||
interface System {
|
||||
lang: string
|
||||
lang: string,
|
||||
site: Record<string, any>
|
||||
}
|
||||
|
||||
const useSystemStore = defineStore('system', {
|
||||
state: (): System => {
|
||||
return {
|
||||
lang: storage.get('lang') ?? 'zh-cn'
|
||||
lang: storage.get('lang') ?? 'zh-cn',
|
||||
site: {
|
||||
front_end_name: '',
|
||||
site_name: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async getSitenfo() {
|
||||
await getSiteInfo()
|
||||
.then((res: any) => {
|
||||
this.site = res.data
|
||||
if (this.site.status == 3) navigateTo('/site/close', { replace: true })
|
||||
})
|
||||
.catch((err) => {
|
||||
navigateTo('/site/nonexistence', { replace: true })
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -23,5 +23,6 @@ export function isUrl(str: string): boolean {
|
||||
* @returns
|
||||
*/
|
||||
export function img(path: string): string {
|
||||
return isUrl(path) ? path : `${import.meta.env.VITE_IMG_DOMAIN || location.origin}/${path}`
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
return isUrl(path) ? path : `${runtimeConfig.public.VITE_IMG_DOMAIN || location.origin}/${path}`
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
import { breakpointsTailwind } from '@vueuse/core'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
interface ShowMessageConfig {
|
||||
@ -47,11 +48,13 @@ class Http {
|
||||
*/
|
||||
this.options.onResponse = ({ response, options }) => {
|
||||
const { _data: data } = response
|
||||
|
||||
if (data.code == 1) {
|
||||
if (options.showMessageConfig.showSuccessMessage) ElMessage({ message: data.msg, type: 'success' })
|
||||
} else {
|
||||
if (options.showMessageConfig.showErrorMessage) ElMessage({ message: data.msg, type: 'error' })
|
||||
this.handleNetworkError(response)
|
||||
if (data.code != undefined) {
|
||||
if (data.code == 1) {
|
||||
if (options.showMessageConfig.showSuccessMessage) ElMessage({ message: data.msg, type: 'success' })
|
||||
} else {
|
||||
ElMessage({ message: data.msg, type: 'error' })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,23 +90,77 @@ class Http {
|
||||
this.options.showMessageConfig = showMessageConfig
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
useFetch(url, { ...this.options }).then((response) => {
|
||||
const { data: { value }, error } = response
|
||||
setTimeout(() => {
|
||||
// 处理首次请求baseurl空的问题
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
!this.options.baseURL && (this.options.baseURL = runtimeConfig.public.VITE_APP_BASE_URL || `${location.origin}/api/`)
|
||||
|
||||
if (value) {
|
||||
if (value.code == 1) {
|
||||
resolve(value)
|
||||
useFetch(url, { ...this.options }).then((response) => {
|
||||
const { data: { value }, error } = response
|
||||
|
||||
if (value) {
|
||||
if (value.code == 1) {
|
||||
resolve(value)
|
||||
} else {
|
||||
reject(value)
|
||||
}
|
||||
} else {
|
||||
reject(value)
|
||||
reject(error)
|
||||
}
|
||||
} else {
|
||||
reject(error)
|
||||
}
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
}, this.options.baseURL ? 0 : 500);
|
||||
})
|
||||
}
|
||||
|
||||
private handleNetworkError(err: any) {
|
||||
if (err.status && err.status != 200) {
|
||||
let errMessage = ''
|
||||
switch (err.status) {
|
||||
case 400:
|
||||
errMessage = t('request.400')
|
||||
break
|
||||
case 401:
|
||||
errMessage = t('request.401')
|
||||
break
|
||||
case 403:
|
||||
errMessage = t('request.403')
|
||||
break
|
||||
case 404:
|
||||
errMessage = err.url + t('request.404')
|
||||
break
|
||||
case 405:
|
||||
errMessage = t('request.405')
|
||||
break
|
||||
case 408:
|
||||
errMessage = t('request.408')
|
||||
break
|
||||
case 409:
|
||||
errMessage = t('request.409')
|
||||
break
|
||||
case 500:
|
||||
errMessage = t('request.500')
|
||||
break
|
||||
case 501:
|
||||
errMessage = t('request.501')
|
||||
break
|
||||
case 502:
|
||||
errMessage = t('request.502')
|
||||
break
|
||||
case 503:
|
||||
errMessage = t('request.503')
|
||||
break
|
||||
case 504:
|
||||
errMessage = t('request.504')
|
||||
break
|
||||
case 505:
|
||||
errMessage = t('request.505')
|
||||
break
|
||||
}
|
||||
ElMessage({ message: errMessage, type: 'error' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const request = new Http()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user