V0.2
This commit is contained in:
parent
5c7495fc71
commit
9b8c8841d2
Binary file not shown.
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 5.5 KiB |
@ -134,7 +134,7 @@ html, body {
|
||||
*/
|
||||
.tabbar-item-css{
|
||||
.van-tabbar-item{
|
||||
font-size: 20px;
|
||||
font-size: 35px;
|
||||
background-color: transparent;
|
||||
--van-tabbar-background-color: transparent;
|
||||
}
|
||||
|
||||
@ -40,16 +40,25 @@ export function Release(){
|
||||
wsManager.disconnect();
|
||||
}
|
||||
}
|
||||
function extractParenthesesContent(str) {
|
||||
const match = str.match(/\(([^)]+)\)/);
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
function setSetting(setting){
|
||||
if(!Config.DHCPMutex){
|
||||
Config.DHCP = setting.DHCPFlag === 1;
|
||||
}
|
||||
else{
|
||||
Config.DHCP = false;
|
||||
Config.DHCP = true;
|
||||
}
|
||||
Config.ServerName = setting.ServerName;
|
||||
Config.ServerVer = setting.Version1 + setting.Version2;
|
||||
Config.ServerVer2 = setting.Version2;
|
||||
try {
|
||||
Config.ServerVer2 = extractParenthesesContent(setting.Version2);
|
||||
}
|
||||
catch (e){
|
||||
Config.ServerVer2 = setting.Version2;
|
||||
}
|
||||
Config.ServerStatus = setting.ServerStatus;
|
||||
Config.ServerIP = setting.ServerIP;
|
||||
Config.IPList = setting.ServerAddress;
|
||||
@ -59,6 +68,9 @@ function setSetting(setting){
|
||||
Config.ServerGW = setting.IPGw;
|
||||
Config.ServerNM = setting.IPNm;
|
||||
}
|
||||
const formatFloat = function(value, n) {
|
||||
return Number(value).toFixed(n);
|
||||
}
|
||||
class WebSocketManager {
|
||||
constructor() {
|
||||
this.ws = null;
|
||||
@ -111,11 +123,11 @@ class WebSocketManager {
|
||||
else if(Code === 3){
|
||||
Config.UpDateIndex = 3;
|
||||
Config.DownValue = 100;
|
||||
ElNotification.success('开始解压升级包')
|
||||
ElNotification.success('开始安装升级包,即将重启')
|
||||
}
|
||||
else if(Code === 4){
|
||||
Config.UpDateIndex = 4;
|
||||
ElNotification.success('开始安装升级包,即将重启')
|
||||
ElNotification.success('即将重启')
|
||||
}
|
||||
}
|
||||
else if(json.Key === "exitSys"){
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<el-header height="30px" style="margin-left: 10px;margin-right: 10px;">
|
||||
<el-row style="" class="headerBox">
|
||||
<span @click.stop="toggleFullscreen">
|
||||
Ver: {{ Config.ServerVer }} [{{ formatTime(Date.now()) }}]
|
||||
Ver: {{ Config.ServerVer }} [{{ currentTime }}]
|
||||
</span>
|
||||
<span>
|
||||
System: {{ getSystemType() }}
|
||||
@ -21,7 +21,10 @@
|
||||
|
||||
<script setup>
|
||||
import { Config, toggleFullscreen } from "@renderer/JS/Config";
|
||||
import { onMounted, onUnmounted } from "vue";
|
||||
import { onMounted, onUnmounted, ref } from "vue";
|
||||
|
||||
const currentTime = ref('');
|
||||
let timer = null;
|
||||
|
||||
const formatTime = (timestamp) => {
|
||||
return new Date(timestamp).toLocaleString()
|
||||
@ -40,10 +43,17 @@ const getSystemType = () => {
|
||||
}
|
||||
|
||||
onMounted(()=>{
|
||||
// 立即设置初始时间
|
||||
currentTime.value = formatTime(Date.now());
|
||||
|
||||
// 每秒更新一次时间
|
||||
timer = setInterval(() => {
|
||||
currentTime.value = formatTime(Date.now());
|
||||
}, 1000);
|
||||
|
||||
});
|
||||
onUnmounted(()=>{
|
||||
|
||||
clearInterval(timer);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@ -21,7 +21,9 @@
|
||||
<el-form-item label="Web服务状态:" class="lBox">
|
||||
|
||||
<el-text type="success" v-if="Config.ServerStatus === 1" size="large">
|
||||
运行中...
|
||||
<span style="color: rgba(0,0,0,0.8);">
|
||||
运行中...
|
||||
</span>
|
||||
</el-text>
|
||||
<el-text type="warning" v-else-if="Config.ServerStatus === 2" size="large">
|
||||
加载中...
|
||||
@ -134,8 +136,48 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
<el-dialog
|
||||
v-model="Process1"
|
||||
title="密码验证"
|
||||
width="500"
|
||||
@opened="()=>{
|
||||
keyboardRef.inputBindKeyboard();
|
||||
}"
|
||||
@closed="()=>{
|
||||
showKeyboard = false;
|
||||
Config.showKeyboard = false;
|
||||
keyboardRef.manualHide();
|
||||
}"
|
||||
destroy-on-close
|
||||
draggable
|
||||
>
|
||||
<el-input
|
||||
v-model="Config.Password"
|
||||
placeholder="请输入密码"
|
||||
show-password
|
||||
ref="formBoxInput7"
|
||||
@focus="focusInput('formBoxInput7')"
|
||||
@keyup.enter="PasswordFun"
|
||||
size="large"
|
||||
keyboard="true"
|
||||
/>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click.stop="()=>{
|
||||
Process1 = false;
|
||||
}">
|
||||
取消
|
||||
</el-button>
|
||||
<el-button type="primary" @click.stop="PasswordFun">
|
||||
确认
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-main>
|
||||
<keyboard
|
||||
ref="keyboardRef"
|
||||
:transitionTime="'0.5s'"
|
||||
:maxQuantify="10"
|
||||
:showKeyboard="showKeyboard"
|
||||
@ -147,6 +189,7 @@
|
||||
@clickShow="showKeyboardClick"
|
||||
@clickHide="hideKeyboardClick"
|
||||
:blurHide="false"
|
||||
style="z-index: 9999;"
|
||||
></keyboard>
|
||||
</el-container>
|
||||
</template>
|
||||
@ -164,11 +207,14 @@ const formBoxInput3 = ref();
|
||||
const formBoxInput4 = ref();
|
||||
const formBoxInput5 = ref();
|
||||
const formBoxInput6 = ref();
|
||||
const formBoxInput7 = ref();
|
||||
const scrollContainer = ref()
|
||||
const keyboardRef = ref()
|
||||
const ClickIndex = ref(0);
|
||||
const manyDict = ref("@renderer/dict/chowder.json")
|
||||
const singleDict = ref("@renderer/dict/baseDict.json")
|
||||
const showKeyboard = ref(false);
|
||||
const Process1 = ref(false);
|
||||
const inputElement = ref();
|
||||
const targetH = ref(0);
|
||||
|
||||
@ -185,7 +231,6 @@ onUnmounted(()=>{
|
||||
const clickKey = (key) => {
|
||||
console.log("key-->>",key);
|
||||
}
|
||||
//点击键盘时数字的值
|
||||
const clickNumber = (key) => {
|
||||
console.log("key-->>",key);
|
||||
}
|
||||
@ -226,6 +271,14 @@ function focusInput(id){
|
||||
else if(id === "formBoxInput6"){
|
||||
element = formBoxInput6.value;
|
||||
}
|
||||
else if(id === "formBoxInput7"){
|
||||
element = formBoxInput7.value;
|
||||
if (!element) {
|
||||
console.log('dialog 尚未打开,元素不可用');
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 正确获取输入框元素
|
||||
if (element) {
|
||||
@ -237,72 +290,21 @@ function focusInput(id){
|
||||
console.log('inputElement', inputElement.value);
|
||||
console.log('tar', inputElement.value.getBoundingClientRect());
|
||||
targetH.value = inputElement.value.getBoundingClientRect().top;
|
||||
if (inputElement.value) {
|
||||
// keyboardRef.value.manualShow();
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log('inputElement not found for', id);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
function PasswordFun(Confirm = null,Cannel = null) {
|
||||
const passwordRef = ref('');
|
||||
|
||||
ElMessageBox({
|
||||
title: '请输入密码',
|
||||
message: () =>
|
||||
h('div', [
|
||||
h('input', {
|
||||
type: 'password',
|
||||
placeholder: '请输入密码',
|
||||
value: passwordRef.value,
|
||||
// 监听输入框点击事件
|
||||
onclick: (event) => {
|
||||
// console.log('密码输入框被点击');
|
||||
|
||||
// 在这里添加点击事件的处理逻辑
|
||||
},
|
||||
// 监听输入事件
|
||||
oninput: (event) => {
|
||||
passwordRef.value = event.target.value;
|
||||
},
|
||||
// 监听获得焦点事件
|
||||
onfocus: (event) => {
|
||||
console.log('密码输入框获得焦点');
|
||||
toggleScreenKeyboard(true);
|
||||
},
|
||||
// 监听失去焦点事件
|
||||
onblur: (event) => {
|
||||
console.log('密码输入框失去焦点');
|
||||
toggleScreenKeyboard(false);
|
||||
},
|
||||
style: {
|
||||
width: '380px',
|
||||
padding: '8px',
|
||||
border: '1px solid #dcdfe6',
|
||||
borderRadius: '4px'
|
||||
}
|
||||
})
|
||||
]),
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
}).then(() => {
|
||||
if(Confirm && passwordRef.value === Config.PasswordOrder){
|
||||
Confirm();
|
||||
}
|
||||
else{
|
||||
ElMessage.error('密码错误');
|
||||
}
|
||||
}).catch(() => {
|
||||
if(Cannel){
|
||||
Cannel();
|
||||
}
|
||||
toggleScreenKeyboard(false);
|
||||
})
|
||||
}
|
||||
function Save(){
|
||||
ClickIndex.value = 0;
|
||||
Config.Password = '';
|
||||
PasswordFun(()=>{
|
||||
function PasswordFun() {
|
||||
if(Config.Password !== Config.PasswordOrder){
|
||||
ElMessage.error('密码错误');
|
||||
return;
|
||||
}
|
||||
if(ClickIndex.value === 0){
|
||||
sendMessage(JSON.stringify({
|
||||
Key:'setSetting',
|
||||
DHCPFlag:Config.DHCP ? 1 : 0,
|
||||
@ -314,7 +316,20 @@ function Save(){
|
||||
ServerOrderPort:Config.ServerOrderPort,
|
||||
}));
|
||||
ElMessage.success('保存成功');
|
||||
});
|
||||
Process1.value = false;
|
||||
}
|
||||
else if(ClickIndex.value === 1){
|
||||
sendMessage(JSON.stringify({
|
||||
Key:"exitSys"
|
||||
}));
|
||||
Process1.value = false;
|
||||
window.electronAPI.winClose();
|
||||
}
|
||||
}
|
||||
function Save(){
|
||||
ClickIndex.value = 0;
|
||||
Config.Password = '';
|
||||
Process1.value = true;
|
||||
}
|
||||
function Reset(){
|
||||
ClickIndex.value = 1;
|
||||
@ -324,13 +339,9 @@ function Reset(){
|
||||
});
|
||||
}
|
||||
function Exit(){
|
||||
ClickIndex.value = 2;
|
||||
ClickIndex.value = 1;
|
||||
Config.Password = '';
|
||||
PasswordFun(()=>{
|
||||
sendMessage(JSON.stringify({
|
||||
Key:"exitSys"
|
||||
}));
|
||||
});
|
||||
Process1.value = true;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
</script>
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
v-model="Config.selectedVersion"
|
||||
placeholder="请选择版本"
|
||||
class="version-select"
|
||||
@change="handleVer"
|
||||
>
|
||||
<el-option
|
||||
v-for="version in Config.versionOptions"
|
||||
@ -31,7 +32,11 @@
|
||||
|
||||
<!-- 当前版本信息 -->
|
||||
<div class="current-version">
|
||||
当前版本:{{ Config.ServerVer2 }}
|
||||
当前版本:{{ `V${Config.ServerVer2}` }}
|
||||
</div>
|
||||
|
||||
<div class="current-version">
|
||||
编译日期:{{ DataDB.Date }}
|
||||
</div>
|
||||
|
||||
<!-- 升级特性列表 -->
|
||||
@ -57,15 +62,19 @@
|
||||
:striped-flow="Config.UpDateIndex === 3 || Config.UpDateIndex === 4"
|
||||
style="border-radius: 1px;"
|
||||
>
|
||||
<span v-if="Config.UpDateIndex === 1">
|
||||
下载进度: {{ Config.DownValue }} %
|
||||
</span>
|
||||
<span v-if="Config.UpDateIndex === 3">
|
||||
正在解压
|
||||
</span>
|
||||
<span v-if="Config.UpDateIndex === 4">
|
||||
正在安装升级包...
|
||||
</span>
|
||||
<el-row
|
||||
style="height: 25px;"
|
||||
>
|
||||
<span v-if="Config.UpDateIndex === 1">
|
||||
下载进度: {{ Config.DownValue }}%
|
||||
</span>
|
||||
<span v-if="Config.UpDateIndex === 3">
|
||||
正在安装升级包...
|
||||
</span>
|
||||
<span v-if="Config.UpDateIndex === 4">
|
||||
等待升级完成...
|
||||
</span>
|
||||
</el-row>
|
||||
</el-progress>
|
||||
</div>
|
||||
|
||||
@ -88,7 +97,7 @@
|
||||
<el-button
|
||||
@click="handleCancel"
|
||||
>
|
||||
更新列表
|
||||
检查更新
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@ -97,16 +106,21 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onBeforeMount, onMounted, ref } from "vue";
|
||||
import { onBeforeMount, onMounted, reactive } from "vue";
|
||||
import { Config, PostData, sendMessage } from "@renderer/JS/Config";
|
||||
import { Api, ApiUrl } from "@renderer/JS/Api";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { ElMessage, ElNotification } from "element-plus";
|
||||
|
||||
const DataDB = reactive({
|
||||
Date:'',
|
||||
});
|
||||
|
||||
onMounted(()=>{
|
||||
if(Config.UpgradeList.length === 0){
|
||||
getUpdateList();
|
||||
}
|
||||
getUpStatus();
|
||||
handleVer();
|
||||
});
|
||||
onBeforeMount(()=>{
|
||||
|
||||
@ -122,6 +136,14 @@ function handleUpgrade(){
|
||||
ID: Config.selectedVersion
|
||||
}));
|
||||
}
|
||||
function handleVer(){
|
||||
for (let i = 0; i < Config.versionOptions.length; i++){
|
||||
if(Config.versionOptions[i].ID === Config.selectedVersion){
|
||||
DataDB.Date = Config.versionOptions[i].Date;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
function handleStop(){
|
||||
sendMessage(JSON.stringify({
|
||||
Key:'stopUpgrade'
|
||||
@ -158,9 +180,21 @@ function InitList(){
|
||||
URL: item.URL,
|
||||
Date: item.Date_t
|
||||
});
|
||||
Config.versionOptions = Config.versionOptions.sort(
|
||||
(a, b) => b.Version.localeCompare(a.Version));
|
||||
}
|
||||
if(Config.versionOptions.length > 0){
|
||||
Config.selectedVersion = Config.versionOptions[0].ID;
|
||||
DataDB.Date = Config.versionOptions[0].Date;
|
||||
if(Config.versionOptions[0].Version > `V${Config.ServerVer2}`){
|
||||
ElNotification.success('发现新版本');
|
||||
}
|
||||
else{
|
||||
ElNotification.success('当前版本已是最新');
|
||||
}
|
||||
}
|
||||
else{
|
||||
ElMessage.warning('无更新可用');
|
||||
}
|
||||
}
|
||||
function getUpdateList() {
|
||||
@ -169,14 +203,13 @@ function getUpdateList() {
|
||||
if(data.Code === 1){
|
||||
Config.UpgradeList = data.List;
|
||||
InitList();
|
||||
ElMessage.success('获取升级列表成功');
|
||||
}
|
||||
},function(err){
|
||||
Config.UpgradeList = [];
|
||||
});
|
||||
}
|
||||
function getUpStatus(){
|
||||
PostData(ApiUrl + Api.getUpgradePackage,{},function(res){
|
||||
PostData(ApiUrl + Api.getUpStatus,{},function(res){
|
||||
const data = res.data;
|
||||
if(data.Code === 1){
|
||||
Config.UpDateIndex = data.Status;
|
||||
@ -194,7 +227,7 @@ function getUpStatus(){
|
||||
}
|
||||
/* 卡片整体样式 */
|
||||
.upgrade-card {
|
||||
width: 520px; /* 可根据设计调整宽度 */
|
||||
width: 580px; /* 可根据设计调整宽度 */
|
||||
margin: 60px auto; /* 页面居中 */
|
||||
background: linear-gradient(to right, #eaf5ff, #d9edff); /* 渐变背景(参考原型风格) */
|
||||
}
|
||||
@ -234,7 +267,7 @@ function getUpStatus(){
|
||||
|
||||
.UPGRADE-PROGRESS-BAR{
|
||||
margin-bottom: 24px;
|
||||
height: 20px;
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
/* 操作按钮区域 */
|
||||
|
||||
@ -538,6 +538,65 @@ const inputBindKeyboard = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const inputBindKeyboard2 = (targetRef = null) => {
|
||||
nextTick(() => {
|
||||
let inputElements = [];
|
||||
|
||||
if (targetRef) {
|
||||
// 如果传入了特定的 ref 元素
|
||||
if (Array.isArray(targetRef)) {
|
||||
// 处理多个 ref 元素
|
||||
inputElements = targetRef.map(ref => {
|
||||
if (ref && ref.$el) {
|
||||
// 对于 Element Plus 组件,获取内部 input 元素
|
||||
return ref.$el.querySelector('input') || ref.$el.querySelector('textarea') || ref.$el;
|
||||
} else if (ref && ref.querySelector) {
|
||||
return ref;
|
||||
} else {
|
||||
return ref;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 处理单个 ref 元素
|
||||
if (targetRef && targetRef.$el) {
|
||||
// 对于 Element Plus 组件,获取内部 input 元素
|
||||
const inputElement = targetRef.$el.querySelector('input') || targetRef.$el.querySelector('textarea') || targetRef.$el;
|
||||
inputElements = [inputElement];
|
||||
} else if (targetRef && targetRef.querySelector) {
|
||||
inputElements = [targetRef];
|
||||
} else {
|
||||
inputElements = [targetRef];
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤掉无效元素
|
||||
inputElements = inputElements.filter(element => element !== null && element !== undefined);
|
||||
} else {
|
||||
// 如果没有传入特定 ref,则使用原有的 DOM 查询方式
|
||||
inputElements = Array.from(document.querySelectorAll("[keyboard='true']:not([bindkeyboard])"));
|
||||
}
|
||||
|
||||
// 为找到的元素绑定事件
|
||||
inputElements.forEach((e) => {
|
||||
if (!e) return; // 跳过无效元素
|
||||
|
||||
// 检查元素是否已经绑定过键盘事件
|
||||
if (e.hasAttribute('bindkeyboard')) return;
|
||||
|
||||
e.setAttribute("bindkeyboard", "true");
|
||||
e.addEventListener("focus", showKeyBoardFn);
|
||||
e.addEventListener("click", () => {
|
||||
setTimeout(() => {}, 100);
|
||||
});
|
||||
if (props.blurHide) {
|
||||
e.addEventListener("blur", () => {
|
||||
show.value = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
let input = {};
|
||||
const showKeyBoardFn = (e) => {
|
||||
e.preventDefault();
|
||||
@ -1038,6 +1097,27 @@ watch(
|
||||
show.value = showValue;
|
||||
}
|
||||
);
|
||||
const manualShow = (targetElement, keyboardMode = 'cn') => {
|
||||
input = targetElement;
|
||||
show.value = true;
|
||||
mode.value = keyboardMode || 'cn';
|
||||
old_mode.value = '';
|
||||
};
|
||||
|
||||
const manualHide = () => {
|
||||
show.value = false;
|
||||
if (input) {
|
||||
input.blur();
|
||||
}
|
||||
emits('clickHide');
|
||||
};
|
||||
defineExpose({
|
||||
manualShow,
|
||||
manualHide,
|
||||
inputBindKeyboard,
|
||||
show: show,
|
||||
hide: () => HideKey()
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import './index.scss';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user