接数据统计(部分)
This commit is contained in:
parent
d89f7f3d8c
commit
517999cc6a
|
@ -5,6 +5,7 @@ import startUseImg from '~/icons/welcome/startUse.png'
|
|||
import useBackgroundStore from '../background/useBackgroundStore'
|
||||
import useLayoutStore from '../useLayoutStore'
|
||||
import request from '@/utils/request'
|
||||
import useStatisticStore from '@/utils/useStatisticStore'
|
||||
export const DefaultPageSetting = [
|
||||
{
|
||||
name: '游戏',
|
||||
|
@ -44,6 +45,11 @@ export default defineComponent(() => {
|
|||
if (!visited) {
|
||||
// 如果没有记录,说明是第一次访问
|
||||
isFirst.value = true
|
||||
useStatisticStore().send({
|
||||
widget: 'WELCOME',
|
||||
action: 'OPEN',
|
||||
space: 'TAB',
|
||||
})
|
||||
}
|
||||
})
|
||||
return () =>
|
||||
|
@ -53,7 +59,7 @@ export default defineComponent(() => {
|
|||
{show.value && (
|
||||
<div
|
||||
class="w-full h-screen bg-black/60 "
|
||||
onClick={() => {}}
|
||||
onClick={() => { }}
|
||||
style={{
|
||||
backgroundImage: `url('${DefaultPageSetting[selectMode.value].backgroundUrl}')`,
|
||||
backgroundSize: '100% 100%',
|
||||
|
@ -61,7 +67,7 @@ export default defineComponent(() => {
|
|||
backgroundRepeat: 'no-repeat'
|
||||
}}
|
||||
>
|
||||
<div class="w-full h-screen bg-black/60 " onClick={() => {}}></div>
|
||||
<div class="w-full h-screen bg-black/60 " onClick={() => { }}></div>
|
||||
</div>
|
||||
)}
|
||||
</Transition>
|
||||
|
@ -88,11 +94,11 @@ export default defineComponent(() => {
|
|||
}
|
||||
onClick={() => {
|
||||
selectMode.value = idx
|
||||
|
||||
}}
|
||||
style={{
|
||||
transform: `translate(${idx === selectMode.value ? 80 : idx === (selectMode.value + 1) % 2 ? 219 : -52}px) scale(${
|
||||
idx === selectMode.value ? 1 : 0.85
|
||||
})`,
|
||||
transform: `translate(${idx === selectMode.value ? 80 : idx === (selectMode.value + 1) % 2 ? 219 : -52}px) scale(${idx === selectMode.value ? 1 : 0.85
|
||||
})`,
|
||||
backgroundImage: `url('${DivBgImg}')`,
|
||||
backgroundSize: '100% 100%',
|
||||
zIndex: selectMode.value === idx ? 10 : 0
|
||||
|
@ -130,6 +136,13 @@ export default defineComponent(() => {
|
|||
if (!res) return
|
||||
layout.state.dir = res.dir
|
||||
layout.state.content = res.content
|
||||
|
||||
})
|
||||
layout.state.current = selectMode.value as 0 | 1 | 2
|
||||
useStatisticStore().send({
|
||||
widget: selectMode.value === 0 ? "WELCOME_GAME" : selectMode.value === 1 ? "WELCOME_WORK" : "WELCOME_RELAX",
|
||||
action: 'CLICK',
|
||||
space: 'TAB',
|
||||
})
|
||||
}}
|
||||
style={{
|
||||
|
|
|
@ -4,6 +4,7 @@ import useSearchStore from './useSearchStore'
|
|||
import { OhVueIcon, addIcons } from 'oh-vue-icons'
|
||||
import { FaPlus } from 'oh-vue-icons/icons'
|
||||
import useRouterStore from '@/useRouterStore'
|
||||
import useStatisticStore from '@/utils/useStatisticStore'
|
||||
|
||||
addIcons(FaPlus)
|
||||
|
||||
|
@ -34,6 +35,13 @@ export default defineComponent({
|
|||
onClick={() => {
|
||||
searchConfig.current = { ...item }
|
||||
search.showSearchConfig = false
|
||||
|
||||
useStatisticStore().send({
|
||||
widget: 'search',
|
||||
action: 'search',
|
||||
key: `key=${item.name}`
|
||||
})
|
||||
|
||||
}}
|
||||
>
|
||||
<div
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { defineComponent } from 'vue'
|
||||
import { OhVueIcon, addIcons } from 'oh-vue-icons'
|
||||
import { MdHistory, MdRemove, RiCloseCircleLine } from 'oh-vue-icons/icons'
|
||||
import { MdHistory, RiCloseCircleLine } from 'oh-vue-icons/icons'
|
||||
import useSearchConfigStore from './useSearchConfigStore'
|
||||
import jump from '@/utils/jump'
|
||||
import useSettingsStore from '@/settings/useSettingsStore'
|
||||
import useStatisticStore from '@/utils/useStatisticStore'
|
||||
addIcons(MdHistory, RiCloseCircleLine)
|
||||
export default defineComponent(() => {
|
||||
const searchConfig = useSearchConfigStore()
|
||||
|
@ -17,6 +18,12 @@ export default defineComponent(() => {
|
|||
class="flex justify-between hover:pl-[20px] duration-300 items-center text-black/80 cursor-pointer hover:bg-white/40 py-1 px-2 rounded transition-all"
|
||||
onMousedown={() => {
|
||||
jump(searchConfig.current.url + item)
|
||||
|
||||
useStatisticStore().send({
|
||||
widget: 'search',
|
||||
action: 'search',
|
||||
key: `key=${item}&engine=${searchConfig.current.name}&type=直接搜索`
|
||||
})
|
||||
}}
|
||||
>
|
||||
<div class="flex items-center w-0 flex-grow">
|
||||
|
|
|
@ -41,50 +41,7 @@ const defaultCustomSearchList: SearchInfo[] = [
|
|||
|
||||
|
||||
]
|
||||
// const defaultCustomSearchList: SearchInfo[] = [
|
||||
// {
|
||||
// name: '知乎',
|
||||
// url: 'https://www.zhihu.com/search?type=content&q=',
|
||||
// icon: 'searchIcons/zhihu.svg',
|
||||
// show: true
|
||||
// },
|
||||
// {
|
||||
// name: 'GitHub',
|
||||
// url: 'https://github.com/search?q=',
|
||||
// icon: 'searchIcons/GitHub.svg',
|
||||
// show: true
|
||||
// },
|
||||
// {
|
||||
// name: 'F搜',
|
||||
// url: 'https://fsoufsou.com/search?q=',
|
||||
// icon: 'searchIcons/F.svg',
|
||||
// show: true
|
||||
// },
|
||||
// {
|
||||
// name: '豆瓣',
|
||||
// url: 'https://www.douban.com/search?q=',
|
||||
// icon: 'searchIcons/douban.svg',
|
||||
// show: true
|
||||
// },
|
||||
// {
|
||||
// name: 'Yandex',
|
||||
// url: 'https://yandex.com/search/?text=',
|
||||
// icon: 'searchIcons/yandex.svg',
|
||||
// show: true
|
||||
// },
|
||||
// {
|
||||
// name: '开发者',
|
||||
// url: 'https://kaifa.baidu.com/searchPage?wd=',
|
||||
// icon: 'searchIcons/kaifa.svg',
|
||||
// show: true
|
||||
// },
|
||||
// {
|
||||
// name: 'B站',
|
||||
// url: 'https://search.bilibili.com/all?keyword=',
|
||||
// icon: 'searchIcons/bilibili.svg',
|
||||
// show: true
|
||||
// }
|
||||
// ]
|
||||
|
||||
export default defineStore(
|
||||
'searchConfig',
|
||||
() => {
|
||||
|
|
|
@ -5,6 +5,7 @@ import jump from '@/utils/jump'
|
|||
import debounce from 'lodash/debounce'
|
||||
import { aIUrl, translateUrl } from '@/config'
|
||||
import request from '@/utils/request'
|
||||
import useStatisticStore from '@/utils/useStatisticStore'
|
||||
export type SearchAdType = {
|
||||
name: string
|
||||
icon: string
|
||||
|
@ -81,6 +82,12 @@ export default defineStore('search', () => {
|
|||
searchConfig.addHistory(str)
|
||||
searchStr.value = ''
|
||||
jump(searchConfig.current.url + str)
|
||||
|
||||
useStatisticStore().send({
|
||||
widget: 'search',
|
||||
action: 'search',
|
||||
key: `key=${str}&engine=${searchConfig.current.name}&type=直接搜索`
|
||||
})
|
||||
return
|
||||
}
|
||||
if (current.value <= 1) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import useLayoutStore from "@/layout/useLayoutStore";
|
||||
import request from "./request";
|
||||
/**
|
||||
* 生成随机数
|
||||
* @param min 最小值
|
||||
|
@ -33,7 +35,25 @@ export function formatSeconds(seconds: number): string {
|
|||
const minutes = Math.floor(seconds / 60);
|
||||
// 计算剩余的秒数
|
||||
const remainingSeconds = seconds % 60;
|
||||
|
||||
|
||||
// 返回格式化后的字符串,确保分钟和秒数都是两位数
|
||||
return `${String(minutes).padStart(2, '0')}:${String(remainingSeconds).padStart(2, '0')}`;
|
||||
}
|
||||
export function sendEvent(list: {
|
||||
widget: string;
|
||||
space?: string;
|
||||
action: string;
|
||||
key: string;
|
||||
}[]) {
|
||||
const store = useLayoutStore()
|
||||
request('POST', '/api/app/statistics', {
|
||||
data: list.map((item) => ({
|
||||
widget: item.widget,
|
||||
space: item.space || store.state.current === 0 ? 'TAB_GAME' : store.state.current === 1 ? 'TAB_WORK' : 'TAB_EAZY',
|
||||
action: item.action,
|
||||
key: item.key
|
||||
}))
|
||||
|
||||
})
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
import { debounce } from "lodash";
|
||||
import { defineStore } from "pinia"
|
||||
import { ref, watch, type Ref } from "vue"
|
||||
import request from "./request";
|
||||
import { message } from "ant-design-vue";
|
||||
import useLayoutStore from "@/layout/useLayoutStore";
|
||||
export type StatisticType = {
|
||||
widget: string;
|
||||
space?: string;
|
||||
action: string;
|
||||
key?: string;
|
||||
}
|
||||
export default defineStore('statistic', () => {
|
||||
const list = ref([] as StatisticType[])
|
||||
const store = useLayoutStore()
|
||||
const send = (item: StatisticType) => {
|
||||
list.value.push(item)
|
||||
}
|
||||
const debouncedHandler = debounce((newValue: StatisticType[]) => {
|
||||
console.log('数值改变并已防抖处理:', newValue)
|
||||
if (newValue.length === 0) return
|
||||
request("POST", `/api/app/statistics`, {
|
||||
data: newValue.map((item) => ({
|
||||
widget: item.widget,
|
||||
space: item.space || store.state.current === 0 ? 'TAB_GAME' : store.state.current === 1 ? 'TAB_WORK' : 'TAB_EAZY',
|
||||
action: item.action,
|
||||
key: item.key
|
||||
})),
|
||||
returnType: 'text'
|
||||
}).then(() => {
|
||||
|
||||
list.value = []
|
||||
message.success('发送统计成功')
|
||||
})
|
||||
}, 2500) //
|
||||
watch(list, (newValue) => {
|
||||
console.log(list);
|
||||
|
||||
debouncedHandler(newValue)
|
||||
}, {
|
||||
deep: true
|
||||
})
|
||||
return {
|
||||
list,
|
||||
send
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue