Skip to content

Commit

Permalink
Merge pull request #33 from besscroft/dev
Browse files Browse the repository at this point in the history
fix: 一些逻辑优化和 bug 修复
  • Loading branch information
besscroft authored Jan 21, 2024
2 parents 2a0fbdf + a65f02f commit c0dbf99
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
10 changes: 6 additions & 4 deletions components/Canvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const props = defineProps<{
}>()
const emit = defineEmits(['modalUpdate'])
const { share, isSupported } = useShare()
const source = ref('')
const { copy, isSupported } = useClipboard({ source })
const show = ref(false)
const toast = useToast()
const obj = ref({})
Expand All @@ -25,9 +25,9 @@ const items = [{
label: '更多',
}]
const share = (text, url) => {
const shareHandle = (text, url) => {
try {
navigator.share({
share({
title: appName || '旅行足迹',
text: text,
url: url,
Expand All @@ -38,6 +38,7 @@ const share = (text, url) => {
}
const copyHandle = (text) => {
const { copy, isSupported } = useClipboard({ source })
if (isSupported) {
source.value = text
copy(source.value)
Expand Down Expand Up @@ -88,11 +89,12 @@ onUnmounted(() => {
<template #panel>
<div p-2>
<div
v-if="isSupported"
flex flex-row items-center rounded-md
block px-5 py-2 focus-blue w-full
transition-colors duration-200 transform cursor-pointer
hover="bg-gray-100 dark:(bg-gray-700 text-white)"
@click="share(obj?.detail, obj?.url)"
@click="shareHandle(obj?.detail, obj?.url)"
>
<span i-carbon-crowd-report text-xl me-4 />分享
</div>
Expand Down
4 changes: 1 addition & 3 deletions components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ onBeforeUnmount(() => {
<nav relative bg-white dark:bg-custom-black>
<div flex container px-6 py-4 mx-auto md:flex md:justify-between md:items-center>
<div flex items-center justify-between w-full md:w-36>
<ClientOnly>
<img class="h-8 w-auto" src="/maskable-icon.png" cursor-pointer @click="router.push('/')" alt="logo">
</ClientOnly>
<img class="h-8 w-auto" src="/maskable-icon.png" cursor-pointer @click="router.push('/')" alt="logo">
</div>

<div v-if="mdAndLarger" flex items-center justify-center space-x-3>
Expand Down
30 changes: 24 additions & 6 deletions pages/admin/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ const tagTitleHandle = (type: string) => {
return photosList.find(item => type === item.url.replace('/', ''))?.title
}
const filterShow = (value: number, row: any) => {
return row.show === value
}
onBeforeMount(() => {
if (photosList) {
photosList?.forEach((photo: any) => {
Expand All @@ -196,7 +200,7 @@ definePageMeta({
<div>
<div p2 md:p8 pb-20>
<div flex items-center justify-center justify-between w-full mt-4>
<el-select v-model="type" m-2 max-w-80 placeholder="请选择类型" @change="dataHandle">
<el-select v-model="type" m-2 max-w-80 placeholder="类型(查询条件)" @change="dataHandle">
<el-option
v-for="item in imgTypeOptions"
:key="item.value"
Expand All @@ -212,7 +216,7 @@ definePageMeta({
stripe
height="calc(100vh - 16rem)"
>
<el-table-column label="id" prop="id" />
<el-table-column label="id" prop="id" sortable />
<el-table-column label="类型" prop="type">
<template #default="scope">
<el-tag v-if="scope.row.type === 'index'">首页精选</el-tag>
Expand All @@ -222,7 +226,12 @@ definePageMeta({
<el-tag v-else type="danger">错误类型</el-tag>
</template>
</el-table-column>
<el-table-column label="评分" prop="rating" :width="!lgAndLarger ? '127' : ''">
<el-table-column
label="评分"
prop="rating"
:width="!lgAndLarger ? '127' : ''"
sortable
>
<template #default="scope">
<el-rate
v-model="scope.row.rating"
Expand All @@ -231,7 +240,16 @@ definePageMeta({
/>
</template>
</el-table-column>
<el-table-column label="是否显示" prop="type">
<el-table-column
label="是否显示"
prop="show"
:filters="[
{ text: '', value: 0 },
{ text: '', value: 1 },
]"
:filter-method="filterShow"
filter-placement="bottom-end"
>
<template #default="scope">
<el-switch
v-model="scope.row.show"
Expand All @@ -245,15 +263,15 @@ definePageMeta({
/>
</template>
</el-table-column>
<el-table-column label="排序" prop="sort" />
<el-table-column label="排序" prop="sort" sortable />
<el-table-column label="描述" prop="detail">
<template #default="scope">
<el-text class="w-240px" truncated>
{{ scope.row.detail }}
</el-text>
</template>
</el-table-column>
<el-table-column align="right" fixed="right">
<el-table-column label="操作" align="right" fixed="right">
<template #default="scope">
<el-button size="small" @click="detail(scope.row)">查看</el-button>
<el-button size="small" @click="() => { objInfo.sort = scope.row.sort ;update(scope.row) }">维护</el-button>
Expand Down
13 changes: 7 additions & 6 deletions pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ async function handleSubmitClick(event: FormSubmitEvent<any>) {
router.push('/admin')
if (token) {
toast.add({ title: '登录成功!', timeout: 2000 })
} else {
toast.add({ title: 'token 获取异常,登录失败!', timeout: 2000, color: 'red' })
}
else {
} catch (e) {
if (e?.status === 500) {
toast.add({ title: '用户名或密码错误!', timeout: 2000, color: 'red' })
} else {
toast.add({ title: '登录失败!', timeout: 2000, color: 'red' })
}
}
catch (e) {
toast.add({ title: '登录失败!', timeout: 2000, color: 'red' })
}
finally {
} finally {
loading.value = false
}
}
Expand Down

1 comment on commit c0dbf99

@vercel
Copy link

@vercel vercel bot commented on c0dbf99 Jan 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.