pc端调整
This commit is contained in:
parent
678c5a5fb6
commit
79a3959a17
|
|
@ -11,6 +11,7 @@
|
||||||
:is="widgets[widget?.name]?.attr"
|
:is="widgets[widget?.name]?.attr"
|
||||||
:content="widget?.content"
|
:content="widget?.content"
|
||||||
:styles="widget?.styles"
|
:styles="widget?.styles"
|
||||||
|
:type="type"
|
||||||
/>
|
/>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -23,6 +24,10 @@ const props = defineProps({
|
||||||
widget: {
|
widget: {
|
||||||
type: Object as PropType<Record<string, any>>,
|
type: Object as PropType<Record<string, any>>,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: String as PropType<'mobile' | 'pc'>,
|
||||||
|
default: 'mobile'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,6 @@ export function login(params: any) {
|
||||||
params: { ...params, client: getClient() }
|
params: { ...params, client: getClient() }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// // 登录
|
|
||||||
export function logout() {
|
|
||||||
return $request.post({ url: '/login/logout' })
|
|
||||||
}
|
|
||||||
|
|
||||||
//注册
|
//注册
|
||||||
export function register(params: any) {
|
export function register(params: any) {
|
||||||
|
|
@ -33,3 +29,8 @@ export function getWxCodeUrl() {
|
||||||
export function wxLogin(params: any) {
|
export function wxLogin(params: any) {
|
||||||
return $request.post({ url: '/login/scanLogin', params })
|
return $request.post({ url: '/login/scanLogin', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//忘记密码
|
||||||
|
export function forgotPassword(params: Record<string, any>) {
|
||||||
|
return $request.post({ url: '/login/forgotPassword', params })
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export function getArticleList(params) {
|
||||||
* @return { Promise }
|
* @return { Promise }
|
||||||
*/
|
*/
|
||||||
export function getArticleCenter() {
|
export function getArticleCenter() {
|
||||||
return $request.get({ url: '/pc/infoCenter' })
|
return $request.get({ url: '/pc/articleCenter' })
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export function getUserInfo() {
|
||||||
|
|
||||||
// 个人编辑
|
// 个人编辑
|
||||||
export function userEdit(params: any) {
|
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) {
|
export function userChangePwd(params: any) {
|
||||||
return $request.post({ url: '/user/changePassword', params })
|
return $request.post({ url: '/user/changePwd', params })
|
||||||
}
|
|
||||||
|
|
||||||
//忘记密码
|
|
||||||
export function forgotPassword(params: Record<string, any>) {
|
|
||||||
return $request.post({ url: '/user/resetPassword', params })
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
pc/app.vue
10
pc/app.vue
|
|
@ -10,17 +10,17 @@ const config = {
|
||||||
locale: zhCn
|
locale: zhCn
|
||||||
}
|
}
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const { pc_title, pc_ico, pc_keywords, pc_desc } = appStore.getWebsiteConfig
|
const { pcTitle, pcIco, pcKeywords, pcDesc } = appStore.getWebsiteConfig
|
||||||
useHead({
|
useHead({
|
||||||
title: pc_title,
|
title: pcTitle,
|
||||||
meta: [
|
meta: [
|
||||||
{ name: 'description', content: pc_desc },
|
{ name: 'description', content: pcDesc },
|
||||||
{ name: 'keywords', content: pc_keywords }
|
{ name: 'keywords', content: pcKeywords }
|
||||||
],
|
],
|
||||||
link: [
|
link: [
|
||||||
{
|
{
|
||||||
rel: 'icon',
|
rel: 'icon',
|
||||||
href: pc_ico
|
href: pcIco
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ const handleConfirmCropper = () => {
|
||||||
})
|
})
|
||||||
const data = await uploadImage({ file: imgFile })
|
const data = await uploadImage({ file: imgFile })
|
||||||
state.cropperVisible = false
|
state.cropperVisible = false
|
||||||
emit('change', data.uri)
|
emit('change', data.path)
|
||||||
uploadRef.value?.clearFiles()
|
uploadRef.value?.clearFiles()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,9 @@ const formRules: FormRules = {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
const hasMobile = computed(() => !!userStore.userInfo.mobile)
|
const hasMobile = computed(() => !!userStore.userInfo.mobile)
|
||||||
|
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
type: hasMobile ? 'change' : 'bind',
|
type: hasMobile.value ? 'change' : 'bind',
|
||||||
mobile: '',
|
mobile: '',
|
||||||
code: ''
|
code: ''
|
||||||
})
|
})
|
||||||
|
|
@ -89,7 +90,7 @@ const formData = reactive({
|
||||||
const sendSms = async () => {
|
const sendSms = async () => {
|
||||||
await formRef.value?.validateField(['mobile'])
|
await formRef.value?.validateField(['mobile'])
|
||||||
await smsSend({
|
await smsSend({
|
||||||
scene: hasMobile ? SMSEnum.CHANGE_MOBILE : SMSEnum.BIND_MOBILE,
|
scene: hasMobile.value ? SMSEnum.CHANGE_MOBILE : SMSEnum.BIND_MOBILE,
|
||||||
mobile: formData.mobile
|
mobile: formData.mobile
|
||||||
})
|
})
|
||||||
verificationCodeRef.value?.start()
|
verificationCodeRef.value?.start()
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,9 @@
|
||||||
show-password
|
show-password
|
||||||
/>
|
/>
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
<ElFormItem prop="password_confirm">
|
<ElFormItem prop="passwordConfirm">
|
||||||
<ElInput
|
<ElInput
|
||||||
v-model="formData.password_confirm"
|
v-model="formData.passwordConfirm"
|
||||||
placeholder="请再次输入密码"
|
placeholder="请再次输入密码"
|
||||||
type="password"
|
type="password"
|
||||||
show-password
|
show-password
|
||||||
|
|
@ -77,12 +77,13 @@ import {
|
||||||
FormRules
|
FormRules
|
||||||
} from 'element-plus'
|
} from 'element-plus'
|
||||||
import { smsSend } from '~~/api/app'
|
import { smsSend } from '~~/api/app'
|
||||||
import { forgotPassword } from '~~/api/user'
|
import { forgotPassword } from '~~/api/account'
|
||||||
import { SMSEnum } from '~~/enums/appEnums'
|
import { SMSEnum } from '~~/enums/appEnums'
|
||||||
import { useUserStore } from '~~/stores/user'
|
import { useUserStore } from '~~/stores/user'
|
||||||
import { useAccount, PopupTypeEnum } from './useAccount'
|
import { useAccount, PopupTypeEnum } from './useAccount'
|
||||||
|
import feedback from '~~/utils/feedback'
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const { setPopupType } = useAccount()
|
const { setPopupType, toggleShowPopup } = useAccount()
|
||||||
const formRef = shallowRef<FormInstance>()
|
const formRef = shallowRef<FormInstance>()
|
||||||
const verificationCodeRef = shallowRef()
|
const verificationCodeRef = shallowRef()
|
||||||
const formRules: FormRules = {
|
const formRules: FormRules = {
|
||||||
|
|
@ -119,7 +120,7 @@ const formRules: FormRules = {
|
||||||
trigger: ['change', 'blur']
|
trigger: ['change', 'blur']
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
password_confirm: [
|
passwordConfirm: [
|
||||||
{
|
{
|
||||||
validator(rule: any, value: any, callback: any) {
|
validator(rule: any, value: any, callback: any) {
|
||||||
if (value === '') {
|
if (value === '') {
|
||||||
|
|
@ -138,7 +139,7 @@ const formData = reactive({
|
||||||
mobile: '',
|
mobile: '',
|
||||||
password: '',
|
password: '',
|
||||||
code: '',
|
code: '',
|
||||||
password_confirm: ''
|
passwordConfirm: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const sendSms = async () => {
|
const sendSms = async () => {
|
||||||
|
|
@ -153,6 +154,8 @@ const sendSms = async () => {
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
await formRef.value?.validate()
|
await formRef.value?.validate()
|
||||||
await forgotPassword(formData)
|
await forgotPassword(formData)
|
||||||
|
feedback.msgSuccess('操作成功')
|
||||||
|
userStore.logout()
|
||||||
setPopupType(PopupTypeEnum.LOGIN)
|
setPopupType(PopupTypeEnum.LOGIN)
|
||||||
}
|
}
|
||||||
const { lockFn: handleConfirmLock, isLock } = useLockFn(handleConfirm)
|
const { lockFn: handleConfirmLock, isLock } = useLockFn(handleConfirm)
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ const handleLogin = async () => {
|
||||||
params.code = formData.code
|
params.code = formData.code
|
||||||
}
|
}
|
||||||
const data = await login(params)
|
const data = await login(params)
|
||||||
if (isForceBindMobile.value && !data.mobile) {
|
if (isForceBindMobile.value && !data.isBindMobile) {
|
||||||
userStore.temToken = data.token
|
userStore.temToken = data.token
|
||||||
setPopupType(PopupTypeEnum.BIND_MOBILE)
|
setPopupType(PopupTypeEnum.BIND_MOBILE)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@
|
||||||
placeholder="请输入6-20位数字+字母或符号组合"
|
placeholder="请输入6-20位数字+字母或符号组合"
|
||||||
/>
|
/>
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
<ElFormItem prop="password_confirm">
|
<ElFormItem prop="passwordConfirm">
|
||||||
<ElInput
|
<ElInput
|
||||||
v-model="formData.password_confirm"
|
v-model="formData.passwordConfirm"
|
||||||
type="password"
|
type="password"
|
||||||
show-password
|
show-password
|
||||||
placeholder="请再次输入密码"
|
placeholder="请再次输入密码"
|
||||||
|
|
@ -93,7 +93,7 @@ const formRules: FormRules = {
|
||||||
trigger: ['change', 'blur']
|
trigger: ['change', 'blur']
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
password_confirm: [
|
passwordConfirm: [
|
||||||
{
|
{
|
||||||
validator(rule: any, value: any, callback: any) {
|
validator(rule: any, value: any, callback: any) {
|
||||||
if (value === '') {
|
if (value === '') {
|
||||||
|
|
@ -111,7 +111,7 @@ const formRules: FormRules = {
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
password_confirm: ''
|
passwordConfirm: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<NuxtLink v-if="appStore.getWebsiteConfig.pc_logo" class="flex" to="/">
|
<NuxtLink v-if="appStore.getWebsiteConfig.pcLogo" class="flex" to="/">
|
||||||
<img :src="appStore.getWebsiteConfig.pc_logo" class="h-[26px]" />
|
<img :src="appStore.getWebsiteConfig.pcLogo" class="h-[26px]" />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ import { ArrowDown } from '@element-plus/icons-vue'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { PopupTypeEnum, useAccount } from '../account/useAccount'
|
import { PopupTypeEnum, useAccount } from '../account/useAccount'
|
||||||
import feedback from '~~/utils/feedback'
|
import feedback from '~~/utils/feedback'
|
||||||
import { logout } from '~~/api/account'
|
|
||||||
const { setPopupType, toggleShowPopup } = useAccount()
|
const { setPopupType, toggleShowPopup } = useAccount()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
|
||||||
|
|
@ -58,7 +57,6 @@ const handleCommand = async (command: string) => {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'logout':
|
case 'logout':
|
||||||
await feedback.confirm('确定退出登录吗?')
|
await feedback.confirm('确定退出登录吗?')
|
||||||
await logout()
|
|
||||||
userStore.logout()
|
userStore.logout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const { setPopupType, toggleShowPopup } = useAccount()
|
const { setPopupType, toggleShowPopup } = useAccount()
|
||||||
const isForceBindMobile = appStore.getLoginConfig.coerce_mobile
|
const isForceBindMobile = appStore.getLoginConfig.forceBindMobile
|
||||||
const { code, state } = to.query
|
const { code, state } = to.query
|
||||||
delete to.query.code
|
delete to.query.code
|
||||||
delete to.query.state
|
delete to.query.state
|
||||||
try {
|
try {
|
||||||
if (code && state) {
|
if (code && state) {
|
||||||
const data = await wxLogin({ code, state })
|
const data = await wxLogin({ code, state })
|
||||||
if (isForceBindMobile && !data.mobile) {
|
if (isForceBindMobile && !data.isBindMobile) {
|
||||||
userStore.temToken = data.token
|
userStore.temToken = data.token
|
||||||
setPopupType(PopupTypeEnum.BIND_MOBILE)
|
setPopupType(PopupTypeEnum.BIND_MOBILE)
|
||||||
toggleShowPopup(true)
|
toggleShowPopup(true)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="showMobilePopup = true"
|
@click="showMobilePopup = true"
|
||||||
>
|
>
|
||||||
{{ userInfo.has_password ? '点击修改' : '点击设置' }}
|
{{ userInfo.isPassword ? '点击修改' : '点击设置' }}
|
||||||
<Icon name="el-icon-ArrowRight" />
|
<Icon name="el-icon-ArrowRight" />
|
||||||
</ElButton>
|
</ElButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
<div class="info-item leading-10 flex justify-between">
|
<div class="info-item leading-10 flex justify-between">
|
||||||
<div class="item-name">绑定微信</div>
|
<div class="item-name">绑定微信</div>
|
||||||
<div>
|
<div>
|
||||||
{{ userInfo.has_auth ? '已绑定' : '未绑定' }}
|
{{ userInfo.isBindMnp ? '已绑定' : '未绑定' }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<span class="text-4xl">
|
<span class="text-4xl">
|
||||||
{{
|
{{
|
||||||
userInfo.has_password
|
userInfo.isPassword
|
||||||
? '修改登录密码'
|
? '修改登录密码'
|
||||||
: '设置登录密码'
|
: '设置登录密码'
|
||||||
}}
|
}}
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
type="primary"
|
type="primary"
|
||||||
link
|
link
|
||||||
@click="toForgetPwd"
|
@click="toForgetPwd"
|
||||||
v-if="userInfo.has_password"
|
v-if="userInfo.isPassword"
|
||||||
>
|
>
|
||||||
忘记原密码
|
忘记原密码
|
||||||
</ElButton>
|
</ElButton>
|
||||||
|
|
@ -56,11 +56,11 @@
|
||||||
:rules="formRules"
|
:rules="formRules"
|
||||||
>
|
>
|
||||||
<ElFormItem
|
<ElFormItem
|
||||||
prop="old_password"
|
prop="oldPassword"
|
||||||
v-if="userInfo.has_password"
|
v-if="userInfo.isPassword"
|
||||||
>
|
>
|
||||||
<ElInput
|
<ElInput
|
||||||
v-model="formData.old_password"
|
v-model="formData.oldPassword"
|
||||||
placeholder="请输入原密码"
|
placeholder="请输入原密码"
|
||||||
type="password"
|
type="password"
|
||||||
show-password
|
show-password
|
||||||
|
|
@ -74,9 +74,9 @@
|
||||||
show-password
|
show-password
|
||||||
/>
|
/>
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
<ElFormItem prop="password_confirm">
|
<ElFormItem prop="passwordConfirm">
|
||||||
<ElInput
|
<ElInput
|
||||||
v-model="formData.password_confirm"
|
v-model="formData.passwordConfirm"
|
||||||
placeholder="请再次输入密码"
|
placeholder="请再次输入密码"
|
||||||
type="password"
|
type="password"
|
||||||
show-password
|
show-password
|
||||||
|
|
@ -113,14 +113,19 @@ import {
|
||||||
PopupTypeEnum,
|
PopupTypeEnum,
|
||||||
useAccount
|
useAccount
|
||||||
} from '~~/layouts/components/account/useAccount'
|
} from '~~/layouts/components/account/useAccount'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import feedback from '~~/utils/feedback'
|
||||||
const { data: userInfo, refresh } = await useAsyncData(() => getUserInfo(), {
|
const { data: userInfo, refresh } = await useAsyncData(() => getUserInfo(), {
|
||||||
default: () => ({})
|
default: () => ({}),
|
||||||
|
initialCache: false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const userStore = useUserStore()
|
||||||
const showMobilePopup = ref(false)
|
const showMobilePopup = ref(false)
|
||||||
const { setPopupType, toggleShowPopup } = useAccount()
|
const { setPopupType, toggleShowPopup } = useAccount()
|
||||||
const formRef = shallowRef<FormInstance>()
|
const formRef = shallowRef<FormInstance>()
|
||||||
const formRules: FormRules = {
|
const formRules: FormRules = {
|
||||||
old_password: [
|
oldPassword: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入原密码',
|
message: '请输入原密码',
|
||||||
|
|
@ -140,7 +145,7 @@ const formRules: FormRules = {
|
||||||
trigger: ['change', 'blur']
|
trigger: ['change', 'blur']
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
password_confirm: [
|
passwordConfirm: [
|
||||||
{
|
{
|
||||||
validator(rule: any, value: any, callback: any) {
|
validator(rule: any, value: any, callback: any) {
|
||||||
if (value === '') {
|
if (value === '') {
|
||||||
|
|
@ -156,9 +161,9 @@ const formRules: FormRules = {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
old_password: '',
|
oldPassword: '',
|
||||||
password: '',
|
password: '',
|
||||||
password_confirm: ''
|
passwordConfirm: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const toForgetPwd = () => {
|
const toForgetPwd = () => {
|
||||||
|
|
@ -170,6 +175,8 @@ const toForgetPwd = () => {
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
await formRef.value?.validate()
|
await formRef.value?.validate()
|
||||||
await userChangePwd(formData)
|
await userChangePwd(formData)
|
||||||
|
feedback.msgSuccess('修改成功')
|
||||||
|
userStore.logout()
|
||||||
showMobilePopup.value = false
|
showMobilePopup.value = false
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,18 @@
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:id="item.id"
|
:id="item.id"
|
||||||
:title="item.title"
|
:title="item.title"
|
||||||
:desc="item.desc"
|
:desc="item.intro"
|
||||||
:click="item.click"
|
:click="item.visit"
|
||||||
:author="item.author"
|
:author="item.author"
|
||||||
:create-time="item.create_time"
|
:create-time="item.createTime"
|
||||||
:image="item.image"
|
:image="item.image"
|
||||||
:only-title="false"
|
:only-title="false"
|
||||||
/>
|
/>
|
||||||
<div class="py-4 flex justify-end">
|
<div class="py-4 flex justify-end">
|
||||||
<el-pagination
|
<el-pagination
|
||||||
v-model:current-page="params.page_no"
|
v-model:current-page="params.pageNo"
|
||||||
:total="data.count"
|
:total="data.count"
|
||||||
:page-size="params.page_size"
|
:page-size="params.pageSize"
|
||||||
hide-on-single-page
|
hide-on-single-page
|
||||||
@current-change="refresh()"
|
@current-change="refresh()"
|
||||||
/>
|
/>
|
||||||
|
|
@ -57,8 +57,8 @@ const sort = computed(() =>
|
||||||
const keyword = computed(() => route.query.keywords || '')
|
const keyword = computed(() => route.query.keywords || '')
|
||||||
const cid = computed(() => route.query.cid || '')
|
const cid = computed(() => route.query.cid || '')
|
||||||
const params = reactive({
|
const params = reactive({
|
||||||
page_no: 1,
|
pageNo: 1,
|
||||||
page_size: 15,
|
pageSize: 15,
|
||||||
keyword,
|
keyword,
|
||||||
cid,
|
cid,
|
||||||
sort
|
sort
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
</el-breadcrumb-item>
|
</el-breadcrumb-item>
|
||||||
<el-breadcrumb-item
|
<el-breadcrumb-item
|
||||||
:to="{
|
:to="{
|
||||||
path: `/information/default`,
|
path: `/information/search`,
|
||||||
query: {
|
query: {
|
||||||
cid: newsDetail.cid,
|
cid: newsDetail.cid,
|
||||||
name: newsDetail.category
|
name: newsDetail.category
|
||||||
|
|
@ -52,12 +52,12 @@
|
||||||
:name="`el-icon-${
|
:name="`el-icon-${
|
||||||
newsDetail.isCollect ? 'StarFilled' : 'Star'
|
newsDetail.isCollect ? 'StarFilled' : 'Star'
|
||||||
}`"
|
}`"
|
||||||
:size="16"
|
:size="newsDetail.isCollect ? 22 : 18"
|
||||||
:color="
|
:color="
|
||||||
newsDetail.isCollect ? '#FF2C2F' : 'inherit'
|
newsDetail.isCollect ? '#FF2C2F' : 'inherit'
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
点击收藏
|
{{ newsDetail.isCollect ? '取消收藏' : '点击收藏' }}
|
||||||
</ElButton>
|
</ElButton>
|
||||||
</div>
|
</div>
|
||||||
<div class="border-t border-br mt-[30px]">
|
<div class="border-t border-br mt-[30px]">
|
||||||
|
|
@ -109,31 +109,20 @@ const route = useRoute()
|
||||||
const { data: newsDetail, refresh } = await useAsyncData(
|
const { data: newsDetail, refresh } = await useAsyncData(
|
||||||
() =>
|
() =>
|
||||||
getArticleDetail({
|
getArticleDetail({
|
||||||
id: route.params.id,
|
id: route.params.id
|
||||||
source: route.params.source
|
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
initialCache: false
|
initialCache: false
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const getSourceText = computed(() => {
|
|
||||||
switch (route.params.source) {
|
|
||||||
case 'hot':
|
|
||||||
return '热门资讯'
|
|
||||||
case 'new':
|
|
||||||
return ' 最新资讯'
|
|
||||||
default:
|
|
||||||
return '全部资讯'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const handelCollect = async () => {
|
const handelCollect = async () => {
|
||||||
const id = route.params.id
|
const articleId = route.params.id
|
||||||
if (newsDetail.value.collect) {
|
if (newsDetail.value.isCollect) {
|
||||||
await cancelCollect({ id })
|
await cancelCollect({ articleId })
|
||||||
feedback.msgSuccess('已取消收藏')
|
feedback.msgSuccess('已取消收藏')
|
||||||
} else {
|
} else {
|
||||||
await addCollect({ id })
|
await addCollect({ articleId })
|
||||||
feedback.msgSuccess('收藏成功')
|
feedback.msgSuccess('收藏成功')
|
||||||
}
|
}
|
||||||
refresh()
|
refresh()
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:header="item.name"
|
:header="item.name"
|
||||||
:data="item.article"
|
:data="item.article"
|
||||||
:link="`/information/default?cid=${item.id}&name=${item.name}`"
|
:link="`/information/search?cid=${item.id}&name=${item.name}`"
|
||||||
>
|
>
|
||||||
<template #content="{ data }">
|
<template #content="{ data }">
|
||||||
<div class="px-4 py-5">
|
<div class="px-4 py-5">
|
||||||
|
|
@ -23,10 +23,8 @@
|
||||||
:index="index"
|
:index="index"
|
||||||
:id="item.id"
|
:id="item.id"
|
||||||
:title="item.title"
|
:title="item.title"
|
||||||
:desc="item.desc"
|
|
||||||
:click="item.click"
|
|
||||||
:author="item.author"
|
:author="item.author"
|
||||||
:create-time="item.create_time"
|
:create-time="item.createTime"
|
||||||
:image="item.image || placeholder"
|
:image="item.image || placeholder"
|
||||||
:only-title="false"
|
:only-title="false"
|
||||||
:border="false"
|
:border="false"
|
||||||
|
|
@ -51,10 +49,8 @@
|
||||||
<InformationItems
|
<InformationItems
|
||||||
:id="item.id"
|
:id="item.id"
|
||||||
:title="item.title"
|
:title="item.title"
|
||||||
:desc="item.desc"
|
|
||||||
:click="item.click"
|
|
||||||
:author="item.author"
|
:author="item.author"
|
||||||
:create-time="item.create_time"
|
:create-time="item.createTime"
|
||||||
:image="item.image"
|
:image="item.image"
|
||||||
:only-title="true"
|
:only-title="true"
|
||||||
:show-time="false"
|
:show-time="false"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
v-for="item in data.lists"
|
v-for="item in data.lists"
|
||||||
:key="item.id"
|
: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">
|
<div class="border-b border-br py-4 flex items-center">
|
||||||
<ElImage
|
<ElImage
|
||||||
|
|
@ -23,15 +23,15 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-tx-regular line-clamp-2 mt-4">
|
<div class="text-tx-regular line-clamp-2 mt-4">
|
||||||
{{ item.desc }}
|
{{ item.intro }}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="mt-5 text-tx-secondary flex justify-between"
|
class="mt-5 text-tx-secondary flex justify-between"
|
||||||
>
|
>
|
||||||
<div>收藏于{{ item.collect_time }}</div>
|
<div>收藏于{{ item.createTime }}</div>
|
||||||
<ElButton
|
<ElButton
|
||||||
link
|
link
|
||||||
@click.stop="handelCollect(item.article_id)"
|
@click.stop="handelCollect(item.articleId)"
|
||||||
>
|
>
|
||||||
取消收藏
|
取消收藏
|
||||||
</ElButton>
|
</ElButton>
|
||||||
|
|
@ -41,9 +41,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="py-4 flex justify-end">
|
<div class="py-4 flex justify-end">
|
||||||
<el-pagination
|
<el-pagination
|
||||||
v-model:current-page="params.page_no"
|
v-model:current-page="params.pageNo"
|
||||||
:total="data.count"
|
:total="data.count"
|
||||||
:page-size="params.page_size"
|
:page-size="params.pageSize"
|
||||||
hide-on-single-page
|
hide-on-single-page
|
||||||
layout="total, prev, pager, next, jumper"
|
layout="total, prev, pager, next, jumper"
|
||||||
@current-change="refresh()"
|
@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 { ElImage, ElButton, ElPagination, ElEmpty } from 'element-plus'
|
||||||
import feedback from '~~/utils/feedback'
|
import feedback from '~~/utils/feedback'
|
||||||
const params = reactive({
|
const params = reactive({
|
||||||
page_no: 1,
|
pageNo: 1,
|
||||||
page_size: 15
|
pageSize: 15
|
||||||
})
|
})
|
||||||
const { data, refresh } = await useAsyncData(() => getCollect(params), {
|
const { data, refresh } = await useAsyncData(() => getCollect(params), {
|
||||||
initialCache: false
|
initialCache: false
|
||||||
})
|
})
|
||||||
const handelCollect = async (id) => {
|
const handelCollect = async (articleId) => {
|
||||||
await cancelCollect({ id })
|
await cancelCollect({ articleId })
|
||||||
feedback.msgSuccess('已取消收藏')
|
feedback.msgSuccess('已取消收藏')
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,18 +9,18 @@
|
||||||
<div class="avatar">
|
<div class="avatar">
|
||||||
<ElAvatar :size="60" :src="userInfo.avatar"></ElAvatar>
|
<ElAvatar :size="60" :src="userInfo.avatar"></ElAvatar>
|
||||||
<div class="change-btn">
|
<div class="change-btn">
|
||||||
<CropperUploaad
|
<CropperUpload
|
||||||
@change="setUserInfo($event, UserFieldEnum.AVATAR)"
|
@change="setUserInfo($event, UserFieldEnum.AVATAR)"
|
||||||
>
|
>
|
||||||
<span class="text-xs text-white">修改</span>
|
<span class="text-xs text-white">修改</span>
|
||||||
</CropperUploaad>
|
</CropperUpload>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="info-item leading-10">
|
<div class="info-item leading-10">
|
||||||
<div class="item-name">账号</div>
|
<div class="item-name">账号</div>
|
||||||
<div>
|
<div>
|
||||||
{{ userInfo.account }}
|
{{ userInfo.username }}
|
||||||
<ClientOnly>
|
<ClientOnly>
|
||||||
<PopoverInput
|
<PopoverInput
|
||||||
class="inline-block"
|
class="inline-block"
|
||||||
|
|
@ -104,25 +104,24 @@
|
||||||
<div class="info-item leading-10">
|
<div class="info-item leading-10">
|
||||||
<div class="item-name">注册时间</div>
|
<div class="item-name">注册时间</div>
|
||||||
<div>
|
<div>
|
||||||
{{ userInfo.create_time }}
|
{{ userInfo.createTime }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-[60px] flex justify-center">
|
<div class="mt-[60px] flex justify-center">
|
||||||
<ElButton type="primary" @click="handleLogut">退出登录</ElButton>
|
<ElButton type="primary" @click="handleLogout">退出登录</ElButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ElAvatar, ElButton } from 'element-plus'
|
import { ElAvatar, ElButton } from 'element-plus'
|
||||||
import { getUserInfo, userEdit } from '@/api/user'
|
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 PopoverInput from '@/components/popover-input/index.vue'
|
||||||
import {
|
import {
|
||||||
useAccount,
|
useAccount,
|
||||||
PopupTypeEnum
|
PopupTypeEnum
|
||||||
} from '@/layouts/components/account/useAccount'
|
} from '@/layouts/components/account/useAccount'
|
||||||
import { logout } from '~~/api/account'
|
|
||||||
import feedback from '~~/utils/feedback'
|
import feedback from '~~/utils/feedback'
|
||||||
import { useUserStore } from '~~/stores/user'
|
import { useUserStore } from '~~/stores/user'
|
||||||
const { setPopupType, toggleShowPopup, showPopup } = useAccount()
|
const { setPopupType, toggleShowPopup, showPopup } = useAccount()
|
||||||
|
|
@ -131,7 +130,7 @@ const userStore = useUserStore()
|
||||||
enum UserFieldEnum {
|
enum UserFieldEnum {
|
||||||
NONE = '',
|
NONE = '',
|
||||||
AVATAR = 'avatar',
|
AVATAR = 'avatar',
|
||||||
USERNAME = 'account',
|
USERNAME = 'username',
|
||||||
NICKNAME = 'nickname',
|
NICKNAME = 'nickname',
|
||||||
SEX = 'sex'
|
SEX = 'sex'
|
||||||
}
|
}
|
||||||
|
|
@ -147,6 +146,7 @@ const setUserInfo = async (
|
||||||
field: type,
|
field: type,
|
||||||
value: value
|
value: value
|
||||||
})
|
})
|
||||||
|
feedback.msgSuccess('操作成功')
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,9 +161,8 @@ watch(showPopup, (value) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleLogut = async () => {
|
const handleLogout = async () => {
|
||||||
await feedback.confirm('确定退出登录吗?')
|
await feedback.confirm('确定退出登录吗?')
|
||||||
await logout()
|
|
||||||
userStore.logout()
|
userStore.logout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ export function getLocalIconNames() {
|
||||||
|
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
for (const [iconName, component] of Object.entries(ElementPlusIcons)) {
|
for (const [iconName, component] of Object.entries(ElementPlusIcons)) {
|
||||||
const componenName = `${EL_ICON_PREFIX}${iconName}`
|
const componentName = `${EL_ICON_PREFIX}${iconName}`
|
||||||
elIconsName.push(componenName)
|
elIconsName.push(componentName)
|
||||||
nuxtApp.vueApp.component(componenName, component)
|
nuxtApp.vueApp.component(componentName, component)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue