pc端调整

This commit is contained in:
Jason 2023-01-10 15:57:36 +08:00
parent 678c5a5fb6
commit 79a3959a17
20 changed files with 101 additions and 112 deletions

View File

@ -11,6 +11,7 @@
:is="widgets[widget?.name]?.attr"
:content="widget?.content"
:styles="widget?.styles"
:type="type"
/>
</keep-alive>
</div>
@ -23,6 +24,10 @@ const props = defineProps({
widget: {
type: Object as PropType<Record<string, any>>,
default: () => ({})
},
type: {
type: String as PropType<'mobile' | 'pc'>,
default: 'mobile'
}
})
</script>

View File

@ -7,10 +7,6 @@ export function login(params: any) {
params: { ...params, client: getClient() }
})
}
// // 登录
export function logout() {
return $request.post({ url: '/login/logout' })
}
//注册
export function register(params: any) {
@ -33,3 +29,8 @@ export function getWxCodeUrl() {
export function wxLogin(params: any) {
return $request.post({ url: '/login/scanLogin', params })
}
//忘记密码
export function forgotPassword(params: Record<string, any>) {
return $request.post({ url: '/login/forgotPassword', params })
}

View File

@ -19,7 +19,7 @@ export function getArticleList(params) {
* @return { Promise }
*/
export function getArticleCenter() {
return $request.get({ url: '/pc/infoCenter' })
return $request.get({ url: '/pc/articleCenter' })
}
/**

View File

@ -9,7 +9,7 @@ export function getUserInfo() {
// 个人编辑
export function userEdit(params: any) {
return $request.post({ url: '/user/setInfo', params })
return $request.post({ url: '/user/edit', params })
}
// 绑定手机
@ -20,17 +20,7 @@ export function userBindMobile(params: any, headers?: any) {
)
}
// 微信电话
export function userMnpMobile(params: any) {
return $request.post({ url: '/user/getMobileByMnp', params })
}
// 更改密码
export function userChangePwd(params: any) {
return $request.post({ url: '/user/changePassword', params })
}
//忘记密码
export function forgotPassword(params: Record<string, any>) {
return $request.post({ url: '/user/resetPassword', params })
return $request.post({ url: '/user/changePwd', params })
}

View File

@ -10,17 +10,17 @@ const config = {
locale: zhCn
}
const appStore = useAppStore()
const { pc_title, pc_ico, pc_keywords, pc_desc } = appStore.getWebsiteConfig
const { pcTitle, pcIco, pcKeywords, pcDesc } = appStore.getWebsiteConfig
useHead({
title: pc_title,
title: pcTitle,
meta: [
{ name: 'description', content: pc_desc },
{ name: 'keywords', content: pc_keywords }
{ name: 'description', content: pcDesc },
{ name: 'keywords', content: pcKeywords }
],
link: [
{
rel: 'icon',
href: pc_ico
href: pcIco
}
]
})

View File

@ -65,7 +65,7 @@ const handleConfirmCropper = () => {
})
const data = await uploadImage({ file: imgFile })
state.cropperVisible = false
emit('change', data.uri)
emit('change', data.path)
uploadRef.value?.clearFiles()
})
}

View File

@ -80,8 +80,9 @@ const formRules: FormRules = {
]
}
const hasMobile = computed(() => !!userStore.userInfo.mobile)
const formData = reactive({
type: hasMobile ? 'change' : 'bind',
type: hasMobile.value ? 'change' : 'bind',
mobile: '',
code: ''
})
@ -89,7 +90,7 @@ const formData = reactive({
const sendSms = async () => {
await formRef.value?.validateField(['mobile'])
await smsSend({
scene: hasMobile ? SMSEnum.CHANGE_MOBILE : SMSEnum.BIND_MOBILE,
scene: hasMobile.value ? SMSEnum.CHANGE_MOBILE : SMSEnum.BIND_MOBILE,
mobile: formData.mobile
})
verificationCodeRef.value?.start()

View File

@ -46,9 +46,9 @@
show-password
/>
</ElFormItem>
<ElFormItem prop="password_confirm">
<ElFormItem prop="passwordConfirm">
<ElInput
v-model="formData.password_confirm"
v-model="formData.passwordConfirm"
placeholder="请再次输入密码"
type="password"
show-password
@ -77,12 +77,13 @@ import {
FormRules
} from 'element-plus'
import { smsSend } from '~~/api/app'
import { forgotPassword } from '~~/api/user'
import { forgotPassword } from '~~/api/account'
import { SMSEnum } from '~~/enums/appEnums'
import { useUserStore } from '~~/stores/user'
import { useAccount, PopupTypeEnum } from './useAccount'
import feedback from '~~/utils/feedback'
const userStore = useUserStore()
const { setPopupType } = useAccount()
const { setPopupType, toggleShowPopup } = useAccount()
const formRef = shallowRef<FormInstance>()
const verificationCodeRef = shallowRef()
const formRules: FormRules = {
@ -119,7 +120,7 @@ const formRules: FormRules = {
trigger: ['change', 'blur']
}
],
password_confirm: [
passwordConfirm: [
{
validator(rule: any, value: any, callback: any) {
if (value === '') {
@ -138,7 +139,7 @@ const formData = reactive({
mobile: '',
password: '',
code: '',
password_confirm: ''
passwordConfirm: ''
})
const sendSms = async () => {
@ -153,6 +154,8 @@ const sendSms = async () => {
const handleConfirm = async () => {
await formRef.value?.validate()
await forgotPassword(formData)
feedback.msgSuccess('操作成功')
userStore.logout()
setPopupType(PopupTypeEnum.LOGIN)
}
const { lockFn: handleConfirmLock, isLock } = useLockFn(handleConfirm)

View File

@ -278,7 +278,7 @@ const handleLogin = async () => {
params.code = formData.code
}
const data = await login(params)
if (isForceBindMobile.value && !data.mobile) {
if (isForceBindMobile.value && !data.isBindMobile) {
userStore.temToken = data.token
setPopupType(PopupTypeEnum.BIND_MOBILE)
return

View File

@ -31,9 +31,9 @@
placeholder="请输入6-20位数字+字母或符号组合"
/>
</ElFormItem>
<ElFormItem prop="password_confirm">
<ElFormItem prop="passwordConfirm">
<ElInput
v-model="formData.password_confirm"
v-model="formData.passwordConfirm"
type="password"
show-password
placeholder="请再次输入密码"
@ -93,7 +93,7 @@ const formRules: FormRules = {
trigger: ['change', 'blur']
}
],
password_confirm: [
passwordConfirm: [
{
validator(rule: any, value: any, callback: any) {
if (value === '') {
@ -111,7 +111,7 @@ const formRules: FormRules = {
const formData = reactive({
username: '',
password: '',
password_confirm: ''
passwordConfirm: ''
})
const handleConfirm = async () => {

View File

@ -1,6 +1,6 @@
<template>
<NuxtLink v-if="appStore.getWebsiteConfig.pc_logo" class="flex" to="/">
<img :src="appStore.getWebsiteConfig.pc_logo" class="h-[26px]" />
<NuxtLink v-if="appStore.getWebsiteConfig.pcLogo" class="flex" to="/">
<img :src="appStore.getWebsiteConfig.pcLogo" class="h-[26px]" />
</NuxtLink>
</template>
<script lang="ts" setup>

View File

@ -45,7 +45,6 @@ import { ArrowDown } from '@element-plus/icons-vue'
import { useUserStore } from '@/stores/user'
import { PopupTypeEnum, useAccount } from '../account/useAccount'
import feedback from '~~/utils/feedback'
import { logout } from '~~/api/account'
const { setPopupType, toggleShowPopup } = useAccount()
const userStore = useUserStore()
@ -58,7 +57,6 @@ const handleCommand = async (command: string) => {
switch (command) {
case 'logout':
await feedback.confirm('确定退出登录吗?')
await logout()
userStore.logout()
}
}

View File

@ -10,14 +10,14 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
const appStore = useAppStore()
const userStore = useUserStore()
const { setPopupType, toggleShowPopup } = useAccount()
const isForceBindMobile = appStore.getLoginConfig.coerce_mobile
const isForceBindMobile = appStore.getLoginConfig.forceBindMobile
const { code, state } = to.query
delete to.query.code
delete to.query.state
try {
if (code && state) {
const data = await wxLogin({ code, state })
if (isForceBindMobile && !data.mobile) {
if (isForceBindMobile && !data.isBindMobile) {
userStore.temToken = data.token
setPopupType(PopupTypeEnum.BIND_MOBILE)
toggleShowPopup(true)

View File

@ -12,7 +12,7 @@
type="primary"
@click="showMobilePopup = true"
>
{{ userInfo.has_password ? '点击修改' : '点击设置' }}
{{ userInfo.isPassword ? '点击修改' : '点击设置' }}
<Icon name="el-icon-ArrowRight" />
</ElButton>
</div>
@ -20,7 +20,7 @@
<div class="info-item leading-10 flex justify-between">
<div class="item-name">绑定微信</div>
<div>
{{ userInfo.has_auth ? '已绑定' : '未绑定' }}
{{ userInfo.isBindMnp ? '已绑定' : '未绑定' }}
</div>
</div>
</div>
@ -34,7 +34,7 @@
<div class="flex justify-between">
<span class="text-4xl">
{{
userInfo.has_password
userInfo.isPassword
? '修改登录密码'
: '设置登录密码'
}}
@ -43,7 +43,7 @@
type="primary"
link
@click="toForgetPwd"
v-if="userInfo.has_password"
v-if="userInfo.isPassword"
>
忘记原密码
</ElButton>
@ -56,11 +56,11 @@
:rules="formRules"
>
<ElFormItem
prop="old_password"
v-if="userInfo.has_password"
prop="oldPassword"
v-if="userInfo.isPassword"
>
<ElInput
v-model="formData.old_password"
v-model="formData.oldPassword"
placeholder="请输入原密码"
type="password"
show-password
@ -74,9 +74,9 @@
show-password
/>
</ElFormItem>
<ElFormItem prop="password_confirm">
<ElFormItem prop="passwordConfirm">
<ElInput
v-model="formData.password_confirm"
v-model="formData.passwordConfirm"
placeholder="请再次输入密码"
type="password"
show-password
@ -113,14 +113,19 @@ import {
PopupTypeEnum,
useAccount
} from '~~/layouts/components/account/useAccount'
import { useUserStore } from '@/stores/user'
import feedback from '~~/utils/feedback'
const { data: userInfo, refresh } = await useAsyncData(() => getUserInfo(), {
default: () => ({})
default: () => ({}),
initialCache: false
})
const userStore = useUserStore()
const showMobilePopup = ref(false)
const { setPopupType, toggleShowPopup } = useAccount()
const formRef = shallowRef<FormInstance>()
const formRules: FormRules = {
old_password: [
oldPassword: [
{
required: true,
message: '请输入原密码',
@ -140,7 +145,7 @@ const formRules: FormRules = {
trigger: ['change', 'blur']
}
],
password_confirm: [
passwordConfirm: [
{
validator(rule: any, value: any, callback: any) {
if (value === '') {
@ -156,9 +161,9 @@ const formRules: FormRules = {
]
}
const formData = reactive({
old_password: '',
oldPassword: '',
password: '',
password_confirm: ''
passwordConfirm: ''
})
const toForgetPwd = () => {
@ -170,6 +175,8 @@ const toForgetPwd = () => {
const handleConfirm = async () => {
await formRef.value?.validate()
await userChangePwd(formData)
feedback.msgSuccess('修改成功')
userStore.logout()
showMobilePopup.value = false
refresh()
}

View File

@ -19,18 +19,18 @@
:key="item.id"
:id="item.id"
:title="item.title"
:desc="item.desc"
:click="item.click"
:desc="item.intro"
:click="item.visit"
:author="item.author"
:create-time="item.create_time"
:create-time="item.createTime"
:image="item.image"
:only-title="false"
/>
<div class="py-4 flex justify-end">
<el-pagination
v-model:current-page="params.page_no"
v-model:current-page="params.pageNo"
:total="data.count"
:page-size="params.page_size"
:page-size="params.pageSize"
hide-on-single-page
@current-change="refresh()"
/>
@ -57,8 +57,8 @@ const sort = computed(() =>
const keyword = computed(() => route.query.keywords || '')
const cid = computed(() => route.query.cid || '')
const params = reactive({
page_no: 1,
page_size: 15,
pageNo: 1,
pageSize: 15,
keyword,
cid,
sort

View File

@ -8,7 +8,7 @@
</el-breadcrumb-item>
<el-breadcrumb-item
:to="{
path: `/information/default`,
path: `/information/search`,
query: {
cid: newsDetail.cid,
name: newsDetail.category
@ -52,12 +52,12 @@
:name="`el-icon-${
newsDetail.isCollect ? 'StarFilled' : 'Star'
}`"
:size="16"
:size="newsDetail.isCollect ? 22 : 18"
:color="
newsDetail.isCollect ? '#FF2C2F' : 'inherit'
"
/>
点击收藏
{{ newsDetail.isCollect ? '取消收藏' : '点击收藏' }}
</ElButton>
</div>
<div class="border-t border-br mt-[30px]">
@ -109,31 +109,20 @@ const route = useRoute()
const { data: newsDetail, refresh } = await useAsyncData(
() =>
getArticleDetail({
id: route.params.id,
source: route.params.source
id: route.params.id
}),
{
initialCache: false
}
)
const getSourceText = computed(() => {
switch (route.params.source) {
case 'hot':
return '热门资讯'
case 'new':
return ' 最新资讯'
default:
return '全部资讯'
}
})
const handelCollect = async () => {
const id = route.params.id
if (newsDetail.value.collect) {
await cancelCollect({ id })
const articleId = route.params.id
if (newsDetail.value.isCollect) {
await cancelCollect({ articleId })
feedback.msgSuccess('已取消收藏')
} else {
await addCollect({ id })
await addCollect({ articleId })
feedback.msgSuccess('收藏成功')
}
refresh()

View File

@ -8,7 +8,7 @@
:key="item.id"
:header="item.name"
:data="item.article"
:link="`/information/default?cid=${item.id}&name=${item.name}`"
:link="`/information/search?cid=${item.id}&name=${item.name}`"
>
<template #content="{ data }">
<div class="px-4 py-5">
@ -23,10 +23,8 @@
:index="index"
:id="item.id"
:title="item.title"
:desc="item.desc"
:click="item.click"
:author="item.author"
:create-time="item.create_time"
:create-time="item.createTime"
:image="item.image || placeholder"
:only-title="false"
:border="false"
@ -51,10 +49,8 @@
<InformationItems
:id="item.id"
:title="item.title"
:desc="item.desc"
:click="item.click"
:author="item.author"
:create-time="item.create_time"
:create-time="item.createTime"
:image="item.image"
:only-title="true"
:show-time="false"

View File

@ -8,7 +8,7 @@
class="cursor-pointer"
v-for="item in data.lists"
:key="item.id"
@click="$router.push(`/information/detail/${item.article_id}`)"
@click="$router.push(`/information/detail/${item.articleId}`)"
>
<div class="border-b border-br py-4 flex items-center">
<ElImage
@ -23,15 +23,15 @@
</div>
<div class="text-tx-regular line-clamp-2 mt-4">
{{ item.desc }}
{{ item.intro }}
</div>
<div
class="mt-5 text-tx-secondary flex justify-between"
>
<div>收藏于{{ item.collect_time }}</div>
<div>收藏于{{ item.createTime }}</div>
<ElButton
link
@click.stop="handelCollect(item.article_id)"
@click.stop="handelCollect(item.articleId)"
>
取消收藏
</ElButton>
@ -41,9 +41,9 @@
</div>
<div class="py-4 flex justify-end">
<el-pagination
v-model:current-page="params.page_no"
v-model:current-page="params.pageNo"
:total="data.count"
:page-size="params.page_size"
:page-size="params.pageSize"
hide-on-single-page
layout="total, prev, pager, next, jumper"
@current-change="refresh()"
@ -66,14 +66,14 @@ import empty_news from '@/assets/images/empty_news.png'
import { ElImage, ElButton, ElPagination, ElEmpty } from 'element-plus'
import feedback from '~~/utils/feedback'
const params = reactive({
page_no: 1,
page_size: 15
pageNo: 1,
pageSize: 15
})
const { data, refresh } = await useAsyncData(() => getCollect(params), {
initialCache: false
})
const handelCollect = async (id) => {
await cancelCollect({ id })
const handelCollect = async (articleId) => {
await cancelCollect({ articleId })
feedback.msgSuccess('已取消收藏')
refresh()
}

View File

@ -9,18 +9,18 @@
<div class="avatar">
<ElAvatar :size="60" :src="userInfo.avatar"></ElAvatar>
<div class="change-btn">
<CropperUploaad
<CropperUpload
@change="setUserInfo($event, UserFieldEnum.AVATAR)"
>
<span class="text-xs text-white">修改</span>
</CropperUploaad>
</CropperUpload>
</div>
</div>
</div>
<div class="info-item leading-10">
<div class="item-name">账号</div>
<div>
{{ userInfo.account }}
{{ userInfo.username }}
<ClientOnly>
<PopoverInput
class="inline-block"
@ -104,25 +104,24 @@
<div class="info-item leading-10">
<div class="item-name">注册时间</div>
<div>
{{ userInfo.create_time }}
{{ userInfo.createTime }}
</div>
</div>
</div>
<div class="mt-[60px] flex justify-center">
<ElButton type="primary" @click="handleLogut">退出登录</ElButton>
<ElButton type="primary" @click="handleLogout">退出登录</ElButton>
</div>
</div>
</template>
<script lang="ts" setup>
import { ElAvatar, ElButton } from 'element-plus'
import { getUserInfo, userEdit } from '@/api/user'
import CropperUploaad from '@/components/cropper-upload/index.vue'
import CropperUpload from '@/components/cropper-upload/index.vue'
import PopoverInput from '@/components/popover-input/index.vue'
import {
useAccount,
PopupTypeEnum
} from '@/layouts/components/account/useAccount'
import { logout } from '~~/api/account'
import feedback from '~~/utils/feedback'
import { useUserStore } from '~~/stores/user'
const { setPopupType, toggleShowPopup, showPopup } = useAccount()
@ -131,7 +130,7 @@ const userStore = useUserStore()
enum UserFieldEnum {
NONE = '',
AVATAR = 'avatar',
USERNAME = 'account',
USERNAME = 'username',
NICKNAME = 'nickname',
SEX = 'sex'
}
@ -147,6 +146,7 @@ const setUserInfo = async (
field: type,
value: value
})
feedback.msgSuccess('操作成功')
refresh()
}
@ -161,9 +161,8 @@ watch(showPopup, (value) => {
}
})
const handleLogut = async () => {
const handleLogout = async () => {
await feedback.confirm('确定退出登录吗?')
await logout()
userStore.logout()
}

View File

@ -16,8 +16,8 @@ export function getLocalIconNames() {
export default defineNuxtPlugin((nuxtApp) => {
for (const [iconName, component] of Object.entries(ElementPlusIcons)) {
const componenName = `${EL_ICON_PREFIX}${iconName}`
elIconsName.push(componenName)
nuxtApp.vueApp.component(componenName, component)
const componentName = `${EL_ICON_PREFIX}${iconName}`
elIconsName.push(componentName)
nuxtApp.vueApp.component(componentName, component)
}
})