Skip to content

Commit

Permalink
pref: enhance sign type tips
Browse files Browse the repository at this point in the history
  • Loading branch information
kuizuo committed Sep 8, 2023
1 parent c8c5922 commit 8686b47
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 29 deletions.
6 changes: 5 additions & 1 deletion app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { darkTheme, dateZhCN, lightTheme, zhCN } from 'naive-ui'
const colorMode = useColorMode()
const { title, keywords, description } = useAppConfig()
const theme = computed(() => {
return colorMode.value === 'system' ? (colorMode.value ? lightTheme : darkTheme) : colorMode.value === 'light' ? lightTheme : darkTheme
})
const themeColor = ref('#e70012')
const themeOverrides = computed(() => {
Expand Down Expand Up @@ -50,7 +54,7 @@ useHead({
<template>
<n-config-provider
:locale="zhCN" :date-locale="dateZhCN"
:theme="colorMode.preference === 'dark' ? darkTheme : lightTheme"
:theme="theme"
:theme-overrides="themeOverrides"
:inline-theme-disabled="true"
>
Expand Down
9 changes: 5 additions & 4 deletions components/AccountItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async function oneClickSign(uid: string) {
const QrCodeSignActivity = data.find(item => item.signType === SignTypeEnum.QRCode)?.activity
if (QrCodeSignActivity) {
doingActivity.value = QrCodeSignActivity
ms.warning(`检测到有二维码签到的课程[${QrCodeSignActivity.course?.name}],请扫码`, { duration: 20 * 1000, closable: true })
showQrCodeModal.value = true
return
Expand Down Expand Up @@ -124,7 +125,7 @@ async function handleUnMonitor() {
<n-ellipsis class="!max-w-[10ch]">
{{ info.siteName }}
</n-ellipsis>
<span>{{ info.realname }}</span>
<span cllass="text-sm">{{ info.realname }}</span>
<n-popover v-if="monitor" trigger="hover">
<template #trigger>
<n-popconfirm
Expand Down Expand Up @@ -211,8 +212,8 @@ async function handleUnMonitor() {
</n-tooltip>
</n-space>
</template>
<QrCodeSignModal v-model:show="showQrCodeModal" @success="handleQrCodeSignSuccess" />
<CodeOrGestureSignModal v-model:show="showCodeOrGestureModal" :loading="loading" @success="handleCodeOrGestureSignSuccess" />
<QrCodeSignModal v-model:show="showQrCodeModal" :title="doingActivity?.course.name" @success="handleQrCodeSignSuccess" />
<CodeOrGestureSignModal v-model:show="showCodeOrGestureModal" :activity="doingActivity!" :loading="loading" @success="handleCodeOrGestureSignSuccess" />
<SignHistory v-model:show="showSignHistory" :uid="uid" />
<SettingModal v-if="showSettingModal" v-model:show="showSettingModal" :uid="uid" :setting="setting" />
</n-card>
Expand All @@ -223,7 +224,7 @@ async function handleUnMonitor() {
</template>
<style lang="scss" scoped>
.icon{
.icon {
--at-apply: cursor-pointer transition hover:text-red-4
}
Expand Down
17 changes: 14 additions & 3 deletions components/CodeOrGestureSignModal.client.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
<script setup lang="ts">
import { signTypeMap } from '~/constants/cx'
const props = defineProps<{
activity: CX.ActivityItem
loading: boolean
}>()
const emit = defineEmits<{
(e: 'success', text: string): void
}>()
const ms = useMessage()
console.log('activity', props.activity)
const text = ref('')
const signPlaceholder = computed(() => {
return {
3: '请输入手势轨迹',
5: '请输入签到码',
}[props.activity?.otherId]
})
async function handleCodeSign(text: string) {
emit('success', text)
}
Expand All @@ -30,7 +41,7 @@ function handleClose() {
:mask-closable="false"
preset="card"
size="large"
title="签到码或手势签到"
:title="`${activity?.course?.name} | ${signTypeMap?.[activity?.otherId]}`"
:bordered="false"
:closable="true"
:style="{ 'max-width': '360px' }"
Expand All @@ -39,7 +50,7 @@ function handleClose() {
@after-leave="handleClose"
>
<n-input-group>
<n-input v-model:value="text" placeholder="请输入签到码或手势轨迹" clearable />
<n-input v-model:value="text" :placeholder="signPlaceholder" clearable />
<n-button type="primary" :loading="loading" @click="handleCodeSign(text)">
签到
</n-button>
Expand Down
17 changes: 7 additions & 10 deletions components/Operation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function handleSignAll() {
if (toAccounts.length === 0)
return logStore.log('请先选择账号', { type: 'warning' })
logStore.log(`共 ${toAccounts.length} 个账号正在签到`, { type: 'loading' })
logStore.log(`共 ${toAccounts.length} 个账号准备签到`, { type: 'loading' })
const data = await Promise.allSettled(
toAccounts.map((account) => {
Expand All @@ -52,16 +52,15 @@ async function handleSignAll() {
// // 如果一键签到中有二维码签到的课程,则弹出二维码扫码签到的弹窗
const QrCodeSignActivity = oneData.find(item => item.signType === SignTypeEnum.QRCode)?.activity
if (QrCodeSignActivity) {
doingActivity.value = QrCodeSignActivity
ms.warning(`检测到有二维码签到的课程[${QrCodeSignActivity.course?.name}],请扫码`, { duration: 20 * 1000, closable: true })
showQrCodeModal.value = true
return
}
// 检测到签到码签到
const CodeSignActivity = oneData.find(item => item.signType === SignTypeEnum.Code)?.activity
if (CodeSignActivity) {
doingActivity.value = CodeSignActivity
ms.warning(`检测到有签到码签到的课程[${CodeSignActivity.course?.name}],请输入签到码, 如 1234`, { duration: 20 * 1000, closable: true })
Expand All @@ -71,15 +70,13 @@ async function handleSignAll() {
// 检测到手势签到
const GestureSignActivity = oneData.find(item => item.signType === SignTypeEnum.Gesture)?.activity
if (GestureSignActivity) {
doingActivity.value = GestureSignActivity
ms.warning(`检测到有手势签到的课程[${GestureSignActivity.course?.name}],请输入手势轨迹, 如 123654789`, { duration: 20 * 1000, closable: true })
showCodeOrGestureModal.value = true
return
}
logStore.log(`共 ${toAccounts.length} 个账号签到完成`, { type: 'success' })
// logStore.log(`共 ${toAccounts.length} 个账号签到完成`, { type: 'success' })
}
async function openQrCodeSignModal() {
Expand All @@ -94,7 +91,7 @@ async function openQrCodeSignModal() {
async function handleSuccess(result: string) {
const toAccounts = unref(selectAccounts)
logStore.log(`共 ${toAccounts.length} 个账号正在签到`, { type: 'loading' })
logStore.log(`共 ${toAccounts.length} 个账号准备签到`, { type: 'loading' })
await Promise.allSettled(
toAccounts.map((account) => {
Expand Down Expand Up @@ -152,13 +149,13 @@ async function handleCodeOrGestureSignSuccess(result: string) {
全部二维码扫码签到
</n-tooltip>
</n-space>
<QrCodeSignModal v-model:show="showQrCodeModal" @success="handleSuccess" />
<CodeOrGestureSignModal v-model:show="showCodeOrGestureModal" :loading="loading" @success="handleCodeOrGestureSignSuccess" />
<QrCodeSignModal v-model:show="showQrCodeModal" :title="doingActivity?.course.name" @success="handleSuccess" />
<CodeOrGestureSignModal v-model:show="showCodeOrGestureModal" :activity="doingActivity!" :loading="loading" @success="handleCodeOrGestureSignSuccess" />
</n-card>
</template>
<style scoped>
.icon{
.icon {
--at-apply: cursor-pointer transition hover:text-red-4
}
</style>
14 changes: 8 additions & 6 deletions components/QrCodeSignModal.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ export interface BoundingBox {
left: number
}
interface Emit {
(e: 'success', text: string): void
}
const props = defineProps<{
title?: string
}>()
const emit = defineEmits<Emit>()
const emit = defineEmits<{
(e: 'success', text: string): void
}>()
const ms = useMessage()
const text = ref('')
Expand Down Expand Up @@ -92,7 +94,7 @@ async function onDetect(detectedCodes: DetectedBarcode[]) {
if (firstCode) {
const rawValue = firstCode.rawValue
ms.success('二维码识别成功,正在签到...')
ms.success('二维码识别成功,准备签到...')
text.value = rawValue
showScan.value = false
Expand Down Expand Up @@ -131,7 +133,7 @@ watch(text, () => {
:mask-closable="false"
preset="card"
size="large"
title="上传二维码图片"
:title="title ?? '二维码签到'"
:bordered="false"
:closable="true"
:style="{ 'max-width': '360px' }"
Expand Down
2 changes: 0 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ export default defineNuxtConfig({
],
colorMode: {
classSuffix: '',
preference: 'light',
fallback: 'light',
},
unocss: {
uno: true,
Expand Down
4 changes: 1 addition & 3 deletions types/account.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export interface Course extends CX.Course {
isLoadActivity?: boolean
}

export interface Activity extends CX.ActivityDetail {
result?: string
}
export interface Activity extends CX.ActivityItem & CX.Course {}

export interface History {
id: stringÏ
Expand Down

0 comments on commit 8686b47

Please sign in to comment.