#2 合并请求

Zusammengeführt
jiachengqian hat 4 Commits von cmy/dev-jcq nach cmy/master vor 3 Wochen zusammengeführt

+ 9 - 0
src/api/marketing/statistics.ts

@@ -0,0 +1,9 @@
+import request from '/@/utils/request';
+
+export function pageList(query: object) {
+    return request({
+        url: 'https://m1.apifoxmock.com/m1/6687089-6396408-default/marketing/statistics/page',
+        method: 'get',
+        data: query,
+    });
+}

+ 1 - 1
src/views/home/custom-panel.vue

@@ -2,7 +2,7 @@
   <el-card>
     <div class="panel-top">
       <div class="panel-name">{{prop.title}}</div>
-      <div style="cursor: pointer;">
+      <div class="cursor-pointer"  @click="$emit('reload')">
         <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
           <path d="M16.7167 6.66667C15.4895 4.19712 12.9411 2.5 9.99637 2.5C7.05158 2.5 4.56062 4.19712 3.33337 6.66667" stroke="#ADBFD7" stroke-linecap="round"/>
           <path d="M3.33337 3.33334V6.66667" stroke="#ADBFD7" stroke-linecap="round"/>

+ 134 - 0
src/views/home/echarts/keyword-frequency.vue

@@ -0,0 +1,134 @@
+<!-- 访客趋势图组件 -->
+<template>
+	<div class="visitor-trend">
+		<div ref="chartRef" style="width: 100%; height: 300px"></div>
+		<div style="position: absolute; top: 20px; right: 0">
+			<el-select v-model="value" style="width: 84px" @change="initChart">
+				<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
+			</el-select>
+		</div>
+	</div>
+</template>
+
+<script setup lang="ts" name="keywordFrequency">
+import { ref, onMounted, onUnmounted, watch } from 'vue';
+import * as echarts from 'echarts';
+
+const chartData = ref([
+	{ name: '下载', value: 30, color: '#ff6384' },
+	{ name: '宅六', value: 10, color: '#4bc0c0' },
+
+	{ name: '张三', value: 20, color: '#36a2eb' },
+	{ name: '里斯', value: 25, color: '#cc65fe' },
+	{ name: '王五', value: 15, color: '#ffce56' },
+]);
+
+const value = ref('7');
+const options = [
+	{
+		value: '7',
+		label: '7天',
+		selected: true,
+	},
+	{
+		value: '30',
+		label: '30天',
+	},
+];
+
+const chartRef = ref(null);
+let chartInstance: echarts.ECharts | null = null;
+console.log(chartInstance);
+
+// 初始化图表
+const initChart = () => {
+	if (!chartRef.value) return;
+
+	// 销毁旧实例(如果存在)
+	if (chartInstance) {
+		chartInstance.dispose();
+	}
+
+	// 创建新实例
+	chartInstance = echarts.init(chartRef.value);
+	console.log(chartInstance);
+
+	// 处理数据
+	const scatterData = chartData.value.map((item) => ({
+		value: [Math.random() * 100, Math.random() * 100, 30 + Math.random() * 20],
+		itemStyle: { color: item.color },
+		name: `${item.name}\n${item.value}`,
+	}));
+
+	// 配置项
+	const option = {
+		tooltip: {
+			trigger: 'item',
+			formatter: '{b}',
+		},
+		grid: {
+            top: '40%',
+		},
+		xAxis: { show: false },
+		yAxis: { show: false },
+		series: [
+			{
+				type: 'scatter',
+				data: scatterData,
+				symbolSize: (value: any) => {
+					return Math.sqrt(value[2]) * 10; // 根据值计算气泡大小
+				},
+				label: {
+					show: true,
+					position: 'inside',
+					color: '#fff',
+					fontSize: 14,
+					formatter: '{b}',
+				},
+				emphasis: {
+					label: { show: true },
+				},
+			},
+		],
+	};
+
+	// 设置配置项
+	chartInstance.setOption(option);
+
+	// 添加响应式
+	window.addEventListener('resize', handleResize);
+};
+
+// 响应窗口大小变化
+const handleResize = () => {
+	if (chartInstance) {
+		chartInstance.resize();
+	}
+};
+
+// 生命周期钩子
+onMounted(() => {
+	initChart();
+});
+
+onUnmounted(() => {
+	if (chartInstance) {
+		window.removeEventListener('resize', handleResize);
+		chartInstance.dispose();
+		chartInstance = null;
+	}
+});
+</script>
+
+<style scoped lang="scss">
+.bubble-chart-container {
+	width: 465px;
+	height: 330px;
+	min-height: 330px;
+}
+
+.chart {
+	width: 100%;
+	height: 100%;
+}
+</style>    

+ 17 - 1
src/views/home/index.vue

@@ -13,14 +13,30 @@
         <traffic-sources />
       </custom-panel>
     </el-col>
+    <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="9">
+      <custom-panel :title="'访客地图'">
+        <traffic-sources />
+      </custom-panel>
+    </el-col>
+    <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="9">
+      <custom-panel :title="'访客概览'">
+        <traffic-sources />
+      </custom-panel>
+    </el-col>
+    <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="9">
+      <custom-panel :title="'关键词频率'">
+        <keyword-frequency />
+      </custom-panel>
+    </el-col>
   </el-row>
 </template>
 
 <script setup lang="ts" name="home">
-import { defineAsyncComponent } from 'vue';
+import { defineAsyncComponent,ref } from 'vue';
 
 const customPanel = defineAsyncComponent(() => import('./custom-panel.vue'));
 const userInfo = defineAsyncComponent(() => import('./user-info.vue'));
 const visitorTrend = defineAsyncComponent(() => import('./visitor-trend.vue'));
 const trafficSources = defineAsyncComponent(() => import('./traffic-sources.vue'));
+const keywordFrequency = defineAsyncComponent(() => import('./echarts/keyword-frequency.vue'));
 </script>

+ 14 - 0
src/views/marketing/statistics/i18n/en.ts

@@ -0,0 +1,14 @@
+export default {
+	systoken: {
+		index: '#',
+		userId: 'userId',
+		username: 'username',
+		clientId: 'clientId',
+		accessToken: 'accessToken',
+		expiresAt: 'expiresAt',
+		inputUsernameTip: 'input Username',
+		offlineBtn: 'offline',
+		offlineConfirmText: 'offline confirm',
+		offlineSuccessText: 'offline success',
+	},
+};

+ 13 - 0
src/views/marketing/statistics/i18n/zh-cn.ts

@@ -0,0 +1,13 @@
+export default {
+	systoken: {
+		ip: 'IP',
+		domain: '域名',
+		content: '访问量',
+		active: '日活',
+		source: '来源',
+		inputIpTip: '请输入IP地址',
+		inputDomainTip: '请输入域名',
+		queryBtn: '查询',
+		resetBtn: '重置',
+	},
+};

+ 68 - 0
src/views/marketing/statistics/index.vue

@@ -0,0 +1,68 @@
+<template>
+	<div class="layout-padding">
+		<div class="layout-padding-auto layout-padding-view">
+			<el-row class="ml10" v-show="showSearch">
+				<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
+					<el-form-item :label="$t('systoken.ip')" prop="ip">
+						<el-input :placeholder="$t('systoken.inputIpTip')" v-model="state.queryForm.ip"></el-input>
+					</el-form-item>
+                    <el-form-item :label="$t('systoken.domain')" prop="domain">
+						<el-input :placeholder="$t('systoken.inputDomainTip')" v-model="state.queryForm.domain"></el-input>
+					</el-form-item>
+					<el-form-item>
+						<el-button @click="getDataList" icon="Search" type="primary">{{ $t('common.queryBtn') }} </el-button>
+						<el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }}</el-button>
+					</el-form-item>
+				</el-form>
+			</el-row>
+			<el-table
+				:data="state.dataList"
+				@sort-change="sortChangeHandle"
+				style="width: 100%"
+				v-loading="state.loading"
+				border
+				:cell-style="tableStyle.cellStyle"
+				:header-cell-style="tableStyle.headerCellStyle"
+			>
+				<!-- <el-table-column align="center" type="selection" width="40" /> -->
+				<el-table-column :label="$t('systoken.ip')" prop="ip" show-overflow-tooltip></el-table-column>
+				<el-table-column :label="$t('systoken.domain')" prop="domain" show-overflow-tooltip ></el-table-column>
+				<el-table-column :label="$t('systoken.content')" prop="content" show-overflow-tooltip></el-table-column>
+				<el-table-column :label="$t('systoken.active')" prop="active" show-overflow-tooltip></el-table-column>
+			</el-table>
+
+			<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle" v-bind="state.pagination"> </pagination>
+		</div>
+	</div>
+</template>
+
+<script lang="ts" setup>
+import { BasicTableProps, useTable } from '/@/hooks/table';
+import { pageList } from '/@/api/marketing/statistics';
+
+import { useI18n } from 'vue-i18n';
+import { useMessage, useMessageBox } from '/@/hooks/message';
+import { Session } from '/@/utils/storage';
+
+const { t } = useI18n();
+// 定义变量内容
+const queryRef = ref();
+const showSearch = ref(true);
+
+//  table hook
+const state: BasicTableProps = reactive<BasicTableProps>({
+	queryForm: {
+		ip: '',
+        domain:''
+	},
+	pageList: pageList,
+});
+const { getDataList, currentChangeHandle, sortChangeHandle, sizeChangeHandle, tableStyle } = useTable(state);
+
+// 清空搜索条件
+const resetQuery = () => {
+	queryRef.value?.resetFields();
+	getDataList();
+};
+
+</script>

+ 1 - 1
tsconfig.json

@@ -69,6 +69,6 @@
 		"skipLibCheck": true /* Skip type checking of declaration files. */,
 		"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
 	},
-	"include": ["src/**/*.ts", "src/**/*.vue", "src/**/*.tsx", "src/**/*.d.ts", "auto-imports.d.ts"], // **Represents any directory, and * represents any file. Indicates that all files in the src directory will be compiled
+	"include": ["src/**/*.ts", "src/**/*.vue", "src/**/*.tsx", "src/**/*.d.ts", "auto-imports.d.ts", "src/api/marketing/statistics.ts"], // **Represents any directory, and * represents any file. Indicates that all files in the src directory will be compiled
 	"exclude": ["node_modules", "dist"] // Indicates the file directory that does not need to be compiled
 }