Skip to content

Commit

Permalink
revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
DUQIA authored Sep 29, 2024
1 parent b929517 commit 61ece1b
Show file tree
Hide file tree
Showing 11 changed files with 974 additions and 38 deletions.
255 changes: 255 additions & 0 deletions admin/ECharts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
// https://echarts.apache.org/examples/zh/editor.html?c=map-usa
import * as echarts from 'echarts';

var ROOT_PATH = 'https://echarts.apache.org/examples';

var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;

myChart.showLoading();
$.get(ROOT_PATH + '/data/asset/geo/world.json', function (geoJosn) {
echarts.registerMap('world', geoJosn);
myChart.hideLoading();

option = {
title: {
text: 'world',
left: 'center'
},
tooltip: {
trigger: 'item',
showDelay: 0,
transitionDuration: 0.2
},
visualMap: {
left: 'right',
min: 0,
max: 38000000,
inRange: {
color: ['#e0f3f8', '#abd9e9', '#74add1', '#4575b4', '#313695']
},
text: ['High', 'Low'],
calculable: true
},
series: [
{
name: 'world',
type: 'map',
map: 'world',
// roam: true,
emphasis: {
label: {
show: true
}
},
data: [
{ name: 'Canada', value: 4822023 },
{ name: 'China', value: 425111 },
{ name: 'Japan', value: 11055448 },
{ name: 'Russia', value: 38055448 },
{ name: 'Australia', value: 22589448 }
]
}
]
};
myChart.setOption(option);
});

option && myChart.setOption(option);

https://echarts.apache.org/examples/zh/editor.html?c=area-basic&version=5.5.1
import * as echarts from 'echarts';

var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;

option = {
title: {
text: '流量',
left: 10,
top: 10
},
tooltip: {
trigger: 'axis'
},
legend: {
icon: 'circle',
data: ['下载', '上传'],
emphasis: false,
top: 10
},
grid: {
top: 150,
left: 50,
right: 50,
bottom: 50
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['A', 'B', 'C', 'D', 'E']
},
yAxis: {},
series: [
{
name: '下载',
data: [10, 22, 28, 23, 19],
type: 'line',
symbolSize: 8,
showSymbol: false,
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(84, 112, 198, 0.5)' },
{ offset: 1, color: 'rgba(84, 112, 198, 0)' }
])
},
emphasis: {
disabled: true
}
},
{
name: '上传',
data: [25, 14, 23, 35, 10],
type: 'line',
symbolSize: 8,
showSymbol: false,
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(145, 204, 117, 0.5)' },
{ offset: 1, color: 'rgba(145, 204, 117, 0)' }
])
},
emphasis: {
disabled: true
}
}
]
};

option && myChart.setOption(option);




// 实时数据
import * as echarts from 'echarts';

var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;

const categories = (function () {
let now = new Date();
let res = [];
let len = 10;
while (len--) {
res.unshift(now.toLocaleTimeString().replace(/^\D*/, ''));
now = new Date(+now - 2000);
}
return res;
})();

const data = (function () {
let res = [];
let len = 10;
while (len--) {
res.push(Math.round(Math.random() * 1000));
}
return res;
})();

const data2 = (function () {
let res = [];
let len = 0;
while (len < 10) {
res.push(+(Math.random() * 10 + 5).toFixed(1));
len++;
}
return res;
})();

option = {
title: {
text: '流量',
left: 10,
top: 10
},
tooltip: {
trigger: 'axis'
},
legend: {
icon: 'circle',
data: ['下载', '上传'],
emphasis: false,
top: 10
},
xAxis: {
type: 'category',
boundaryGap: false,
data: categories
},
yAxis: {},
series: [
{
name: '下载',
data: data,
type: 'line',
symbolSize: 8,
showSymbol: false,
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(84, 112, 198, 0.5)' },
{ offset: 1, color: 'rgba(84, 112, 198, 0)' }
])
},
emphasis: {
disabled: true
}
},
{
name: '上传',
data: data2,
type: 'line',
symbolSize: 8,
showSymbol: false,
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(145, 204, 117, 0.5)' },
{ offset: 1, color: 'rgba(145, 204, 117, 0)' }
])
},
emphasis: {
disabled: true
}
}
]
};

setInterval(function () {
let axisData = new Date().toLocaleTimeString().replace(/^\D*/, '');
data.shift();
data.push(Math.round(Math.random() * 1000));
data2.shift();
data2.push(+(Math.random() * 10 + 5).toFixed(1));
categories.shift();
categories.push(axisData);
myChart.setOption({
xAxis: [
{
data: categories
}
],
series: [
{
data: data
},
{
data: data2
}
]
});
}, 1000);

option && myChart.setOption(option);
36 changes: 36 additions & 0 deletions admin/curl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
// 需要安装 cURL扩展
// try {
// // 初始化cURL
// $ch = curl_init();

// // 设置 cURL 选项
// curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/DUQIA/Phone-Sync/releases');
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 转换为字符串
// curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; PHP script)'); // 设置User-Agent头

// // 执行 cURL 请求
// $response = curl_exec($ch);
// } catch (Exception $e) {
// echo 'error: ' . $e->getMessage();
// }
// // 检查是否出错
// if (curl_errno($ch)) {
// echo 'cURL错误: ' . curl_error($ch);
// } else {
// // 将JSON字符串解码为PHP数组
// $data = json_decode($response, true);
// return $versions;
// // 获取更新
// if ($data[0]['name'] !== $versions) {
// // 更新
// $content = file_get_contents($data[0]['assets'][0]['browser_download_url']);
// // 下载
// file_put_contents('Akylor.zip', $content, LOCK_EX);
// // 移动
// rename('Akylor.zip', '../Akylor.zip');
// }
// }
// // 关闭 cURL 连接
// curl_close($ch);
?>
Loading

0 comments on commit 61ece1b

Please sign in to comment.