Commit 743b2a4c by linjinhong

feat:新增工厂域名以及清除缓存处理

parent b411806e
{
"apiApiHost": "https://factory.jomalls.com/api",
"fileApiUrl": "https://factory.jomalls.com/upload/factory",
"visionUrl": "https://console.jomalls.com"
}
{"apiApiHost":"https://factory.jomalls.com/api","fileApiUrl":"https://factory.jomalls.com/upload/factory","visionUrl":"https://console.jomalls.com","configPath":"D:\\work\\electron-printer\\config\\env.json"}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html>
<html>
<head>
<!-- 本地 Element UI CSS -->
<link
rel="stylesheet"
href="../dialogstatic/element/theme-chalk/index.css"
/>
<style>
.loading {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
color: #666;
}
#app {
display: none;
}
</style>
</head>
<body style="padding: 20px; margin: 0; overflow: hidden;">
<div class="loading">加载中...</div>
<div id="app">
<el-form label-width="100px">
<el-form-item label="清除缓存:">
<el-checkbox-group
style="display: flex;flex-direction: column"
v-model="checkList"
>
<el-checkbox
:label="item.value"
v-for="(item, i) in cacheList"
:key="i"
>{{ item.label }}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<div style="display: flex; gap: 10px; justify-content: flex-end;">
<el-button @click="cancel" type="default">取消</el-button>
<el-button @click="confirm" type="primary">确定</el-button>
</div>
</div>
<!-- 本地 Vue/Element UI JS -->
<script src="../dialogstatic/vue.min.js"></script>
<script src="../dialogstatic/element/element-ui.min.js"></script>
<script>
console.log(48, __dirname);
// 步骤1:从 URL 查询参数解析 promptId(核心:无需主进程注入)
function getQueryParam(name) {
const search = window.location.search.substring(1);
const params = new URLSearchParams(search);
return params.get(name);
}
const promptId = getQueryParam("promptId") || "";
// 步骤2:初始化 Vue(无需全局 vm 变量)
new Vue({
el: "#app",
data: {
// 直接设置默认值,无需主进程修改
checkList: [],
cacheList: [
{
label: "清除当前登录信息",
value: "token",
},
{
label: "登录记录",
value: "userList",
},
{
label: "打印预设",
value: "print-setting",
},
{
label: "系统设置",
value: "setting",
},
],
},
methods: {
cancel() {
window.close();
// 直接用解析到的 promptId 发送 IPC
if (promptId) {
require("electron").ipcRenderer.send(promptId, null);
}
},
confirm() {
if (promptId) {
require("electron").ipcRenderer.send(promptId, this.checkList);
}
window.close();
},
},
mounted() {
// 挂载完成后显示内容,隐藏加载占位
document.querySelector(".loading").style.display = "none";
document.getElementById("app").style.display = "block";
},
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<!-- 本地 Element UI CSS -->
<link
rel="stylesheet"
href="../dialogstatic/element/theme-chalk/index.css"
/>
<style>
.loading {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
color: #666;
}
#app {
display: none;
}
</style>
</head>
<body style="padding: 20px; margin: 0; overflow: hidden;">
<div class="loading">加载中...</div>
<div id="app">
<el-form label-width="100px" style="margin-bottom: 15px;">
<el-form-item label="工厂域名:">
<!-- 给 el-input 加 ref,方便直接操作 -->
<el-input
ref="domainInput"
v-model="domain"
type="url"
placeholder="请输入工厂域名"
></el-input>
</el-form-item>
</el-form>
<div style="display: flex; gap: 10px; justify-content: flex-end;">
<el-button @click="cancel" type="default">取消</el-button>
<el-button @click="confirm" type="primary">确定</el-button>
</div>
</div>
<!-- 本地 Vue/Element UI JS -->
<script src="../dialogstatic/vue.min.js"></script>
<script src="../dialogstatic/element/element-ui.min.js"></script>
<script>
console.log(48, __dirname);
// 步骤1:从 URL 查询参数解析 promptId(核心:无需主进程注入)
function getQueryParam(name) {
const search = window.location.search.substring(1);
const params = new URLSearchParams(search);
return params.get(name);
}
const promptId = getQueryParam("promptId") || "";
const defaultDomain =
getQueryParam("defaultDomain") || "factory.jomalls.com";
// 步骤2:初始化 Vue(无需全局 vm 变量)
new Vue({
el: "#app",
data: {
// 直接设置默认值,无需主进程修改
domain: defaultDomain,
},
methods: {
cancel() {
window.close();
// 直接用解析到的 promptId 发送 IPC
if (promptId) {
require("electron").ipcRenderer.send(promptId, null);
}
},
confirm() {
if (promptId) {
require("electron").ipcRenderer.send(promptId, this.domain);
}
window.close();
},
},
mounted() {
// 挂载完成后显示内容,隐藏加载占位
document.querySelector(".loading").style.display = "none";
document.getElementById("app").style.display = "block";
},
});
</script>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -23,8 +23,11 @@
"compressing": "^1.10.1",
"core-js": "^3.6.4",
"electron-builder": "^24.13.3",
"electron-dialogs": "^1.4.0",
"electron-icon-builder": "^2.0.1",
"electron-log": "^5.1.7",
"electron-modal": "^1.0.0",
"electron-prompt": "^1.7.0",
"electron-store": "^4.0.0",
"electron-updater": "^6.2.1",
"element-ui": "^2.13.0",
......@@ -37,7 +40,7 @@
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.2",
"multiparty": "^4.2.3",
"nodemon": "^3.1.4",
"nodemon": "^3.1.11",
"normalize.css": "^8.0.1",
"sharp": "0.28.0",
"vue": "^2.6.11",
......@@ -55,6 +58,7 @@
"@vue/cli-service": "^4.2.0",
"@vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.0.3",
"debug": "^4.4.3",
"electron": "^6.1.12",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.1",
......@@ -67,5 +71,6 @@
"pug-plain-loader": "^1.0.0",
"vue-cli-plugin-electron-builder": "^1.4.6",
"vue-template-compiler": "^2.6.11"
}
},
"__npminstall_done": false
}
......@@ -4,17 +4,57 @@
</div>
</template>
<script>
import { ipcRenderer } from "electron";
export default {
data() {
return {
update_info: null
update_info: null,
};
},
mounted() {
mounted() {},
methods: {
async clearCache() {
ipcRenderer.on("clear-checkList", (event, data) => {
console.log("clear-checkList", data);
console.log("clear-checkList", event);
if (data.length === 0) {
return this.$message.warning("请选择要清除的数据");
}
this.$confirm("是否确定清除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
// return;
for (let k of data) {
if (k === "print-setting" || k === "deviceId") {
let list = Object.keys(this.$dataStore.store).filter((el) =>
el.includes(k),
);
list.forEach((el) => {
this.$dataStore.delete(el);
});
} else if (k === "token") {
this.$dataStore.delete("token");
this.$dataStore.delete("user");
} else {
if (this.$dataStore.get(k)) {
this.$dataStore.delete(k);
}
}
}
window.location.reload();
})
.catch(() => {});
});
},
},
created() {
this.clearCache();
},
methods: {}
};
</script>
<style>
......
......@@ -402,6 +402,8 @@ export default {
},
login: async (req, res) => {
try {
env = getHostApi().apiApiHost;
console.log(`${env}/factory/login`);
let { data } = await axios.post(`${env}/factory/login`, req.body);
res.send(data);
......
......@@ -53,6 +53,7 @@ export default {
},
beforeDestroy() {
document.removeEventListener("keyup", this.keyUp);
console.log(333);
},
methods: {
keyUp(e) {
......
......@@ -120,6 +120,14 @@ module.exports = {
to: "../config",
},
{
from: "./dialogstatic/",
to: "../dialogstatic",
},
{
from: "./html/",
to: "../html",
},
{
from: "scripts", // 本地脚本目录
to: "scripts", // 输出到 resources/scripts
filter: ["**/*"], // 包含所有文件
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment