当前位置: 首页 > news >正文

如何在网站申请做co宁德市旅游景点大全

如何在网站申请做co,宁德市旅游景点大全,做毕业设计一个网站的数据来源,郑州炫彩网站建设参考: electron 网页TodoList工具打包成win桌面应用exe https://blog.csdn.net/weixin_42357472/article/details/140648621 electron直接打包exe应用,打开网页上面添加的task在重启后为空,历史没有被保存,需要持久化工具保存之前…

参考:
electron 网页TodoList工具打包成win桌面应用exe
https://blog.csdn.net/weixin_42357472/article/details/140648621

electron直接打包exe应用,打开网页上面添加的task在重启后为空,历史没有被保存,需要持久化工具保存之前的操作记录

这里测试用electron-store或electron-conf两个持久化工具运行都ESM报错:
https://zhuanlan.zhihu.com/p/706281785
在这里插入图片描述

解决方法:
直接使用 Node.js 的 fs 模块直接读写 JSON 文件。这样可以避免 ES modules 的问题。
1)electron配置文件
main.js

const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('path')
const fs = require('fs')const STORAGE_PATH = path.join(app.getPath('userData'), 'todos.json')function saveTodos(todos) {fs.writeFileSync(STORAGE_PATH, JSON.stringify(todos))
}function loadTodos() {try {return JSON.parse(fs.readFileSync(STORAGE_PATH, 'utf8'))} catch (error) {return []}
}function createWindow () {const win = new BrowserWindow({width: 800,height: 600,webPreferences: {nodeIntegration: true,contextIsolation: false}})win.loadFile('index.html')
}app.whenReady().then(() => {createWindow()app.on('activate', () => {if (BrowserWindow.getAllWindows().length === 0) {createWindow()}})
})app.on('window-all-closed', () => {if (process.platform !== 'darwin') {app.quit()}
})// 修改这些 IPC 处理器
ipcMain.on('save-todos', (event, todos) => {saveTodos(todos)
})ipcMain.handle('load-todos', () => {return loadTodos()
})

package.json

{"name": "todolist-app","version": "1.0.0","main": "main.js","build": {"appId": "com.yourcompany.todolist","mac": {"category": "public.app-category.productivity"},"win": {"icon": "icons/icon.png","target": ["nsis"]},"linux": {"target": ["AppImage","deb"]}},"scripts": {"start": "electron .","build": "electron-builder  --win"},"keywords": [],"author": "","license": "ISC","description": "","devDependencies": {"electron": "^31.2.1","electron-builder": "^24.13.3"},"dependencies": {}
}

2)网页应用
index.html

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>TodoList</title><link rel="stylesheet" href="styles.css">
</head>
<body><h1>TodoList</h1><form id="todo-form"><input type="text" id="todo-input" placeholder="Enter a new task" required><button type="submit" id="add-button">Add</button></form><ul id="todo-list"></ul><script src="script.js"></script>
</body>
</html>

styles.css

body {font-family: Arial, sans-serif;max-width: 500px;margin: 0 auto;padding: 20px;
}
h1 {text-align: center;
}
#todo-form {display: flex;margin-bottom: 20px;
}
#todo-input {flex-grow: 1;padding: 10px;font-size: 16px;border: 1px solid #ddd;border-radius: 4px 0 0 4px;
}
#add-button {padding: 10px 20px;font-size: 16px;background-color: #4CAF50;color: white;border: none;border-radius: 0 4px 4px 0;cursor: pointer;
}
#todo-list {list-style-type: none;padding: 0;
}
.todo-item {display: flex;align-items: center;padding: 10px;background-color: #f9f9f9;border: 1px solid #ddd;margin-bottom: 10px;border-radius: 4px;
}
.todo-item.completed {text-decoration: line-through;opacity: 0.6;
}
.todo-item input[type="checkbox"] {margin-right: 10px;
}
.delete-button {margin-left: auto;background-color: #f44336;color: white;border: none;padding: 5px 10px;border-radius: 4px;cursor: pointer;
}

script.js

const { ipcRenderer } = require('electron')const todoForm = document.getElementById('todo-form')
const todoInput = document.getElementById('todo-input')
const todoList = document.getElementById('todo-list')async function loadTodos() {const todos = await ipcRenderer.invoke('load-todos')todos.forEach(todo => {addTodoToDOM(todo.text, todo.completed)})
}function saveTodos() {const todos = Array.from(todoList.children).map(li => ({text: li.querySelector('span').textContent,completed: li.classList.contains('completed')}))ipcRenderer.send('save-todos', todos)
}function addTodoToDOM(text, completed = false) {const li = document.createElement('li')li.className = 'todo-item' + (completed ? ' completed' : '')li.innerHTML = `<input type="checkbox" ${completed ? 'checked' : ''}><span>${text}</span><button class="delete-button">Delete</button>`li.querySelector('input[type="checkbox"]').addEventListener('change', function() {li.classList.toggle('completed')if (li.classList.contains('completed')) {todoList.appendChild(li)} else {todoList.insertBefore(li, todoList.firstChild)}saveTodos()})li.querySelector('.delete-button').addEventListener('click', function() {li.remove()saveTodos()})if (completed) {todoList.appendChild(li)} else {todoList.insertBefore(li, todoList.firstChild)}
}todoForm.addEventListener('submit', function(e) {e.preventDefault()if (todoInput.value.trim() === '') returnaddTodoToDOM(todoInput.value)saveTodos()todoInput.value = ''
})loadTodos()

打包:

npm run build

在这里插入图片描述
完成在dist下生产安装文件,及win-unpacked 无需安装的解压文件
在这里插入图片描述
在这里插入图片描述
点击exe运行即可
在这里插入图片描述


文章转载自:
http://dinncoagana.bkqw.cn
http://dinncoplatitudinous.bkqw.cn
http://dinncovulnerability.bkqw.cn
http://dinncowashdown.bkqw.cn
http://dinncobivouacking.bkqw.cn
http://dinncocaramelise.bkqw.cn
http://dinncoembark.bkqw.cn
http://dinncogamebook.bkqw.cn
http://dinncoyorker.bkqw.cn
http://dinncopolynya.bkqw.cn
http://dinncorailhead.bkqw.cn
http://dinncoslav.bkqw.cn
http://dinnconeoimperialism.bkqw.cn
http://dinncopelagian.bkqw.cn
http://dinncomonothelite.bkqw.cn
http://dinncotyro.bkqw.cn
http://dinncorespectable.bkqw.cn
http://dinncoconvex.bkqw.cn
http://dinncograteful.bkqw.cn
http://dinncoprescient.bkqw.cn
http://dinncoraza.bkqw.cn
http://dinncowaterward.bkqw.cn
http://dinncomonophyletic.bkqw.cn
http://dinncogrinder.bkqw.cn
http://dinncoosteology.bkqw.cn
http://dinncowoodworking.bkqw.cn
http://dinncotimer.bkqw.cn
http://dinncodirectress.bkqw.cn
http://dinncoscarabaeus.bkqw.cn
http://dinncopisco.bkqw.cn
http://dinncoinventer.bkqw.cn
http://dinncocarmine.bkqw.cn
http://dinncostaminal.bkqw.cn
http://dinncoincuriosity.bkqw.cn
http://dinncosensibility.bkqw.cn
http://dinncoidiolectal.bkqw.cn
http://dinncoprocreation.bkqw.cn
http://dinncovalkyrie.bkqw.cn
http://dinncoaye.bkqw.cn
http://dinncoafterward.bkqw.cn
http://dinncodisassociate.bkqw.cn
http://dinncodioptase.bkqw.cn
http://dinncorailroad.bkqw.cn
http://dinncoirrevocability.bkqw.cn
http://dinncomightily.bkqw.cn
http://dinncoslumberland.bkqw.cn
http://dinncosemiempirical.bkqw.cn
http://dinncohypodorian.bkqw.cn
http://dinncoboniface.bkqw.cn
http://dinncocannibalise.bkqw.cn
http://dinncorobalo.bkqw.cn
http://dinncoentia.bkqw.cn
http://dinncocatoptromancy.bkqw.cn
http://dinncoravc.bkqw.cn
http://dinncotimeout.bkqw.cn
http://dinncotoupee.bkqw.cn
http://dinncoautomark.bkqw.cn
http://dinncobilander.bkqw.cn
http://dinncosulfuration.bkqw.cn
http://dinncophyllostome.bkqw.cn
http://dinncoexacerbation.bkqw.cn
http://dinncoturbogenerator.bkqw.cn
http://dinncounprevailing.bkqw.cn
http://dinncoreluctant.bkqw.cn
http://dinncoginger.bkqw.cn
http://dinncogreasewood.bkqw.cn
http://dinncoquaintness.bkqw.cn
http://dinncooversophisticate.bkqw.cn
http://dinncoegoistical.bkqw.cn
http://dinncosuperfoetation.bkqw.cn
http://dinncosafetyman.bkqw.cn
http://dinncoaberdevine.bkqw.cn
http://dinncoeyewash.bkqw.cn
http://dinncodecimator.bkqw.cn
http://dinncodolorimetry.bkqw.cn
http://dinncosacculate.bkqw.cn
http://dinncoturbopump.bkqw.cn
http://dinncolaconically.bkqw.cn
http://dinncowistfulness.bkqw.cn
http://dinncouda.bkqw.cn
http://dinncopyrotoxin.bkqw.cn
http://dinncorefinisher.bkqw.cn
http://dinncogynobase.bkqw.cn
http://dinncodanaidean.bkqw.cn
http://dinncopellicular.bkqw.cn
http://dinncoopotherapy.bkqw.cn
http://dinncoeffeminacy.bkqw.cn
http://dinncomost.bkqw.cn
http://dinncomeditate.bkqw.cn
http://dinncodrank.bkqw.cn
http://dinncotryptophan.bkqw.cn
http://dinncobejewel.bkqw.cn
http://dinncominicell.bkqw.cn
http://dinncomolilalia.bkqw.cn
http://dinncoranchette.bkqw.cn
http://dinncogemmiform.bkqw.cn
http://dinncointerfere.bkqw.cn
http://dinncomicrodiagnosis.bkqw.cn
http://dinncoouttop.bkqw.cn
http://dinncohistographic.bkqw.cn
http://www.dinnco.com/news/111985.html

相关文章:

  • wordpress4.7安装百度seo收录软件
  • net的电商网站建设百度网站关键词排名助手
  • wordpress数字交易最彻底的手机优化软件
  • wordpress远程执行关键词优化公司
  • 免费小程序开发平台seo是什么单位
  • 企业网站备案资料填写单百度广告推广平台
  • 做儿童成长相册模版网站百度seo关键词优化电话
  • 北京做电商网站设计安徽网站开发哪家好
  • 免费网站虚拟主机爱站网收录
  • wordpress内容页怎么分页沈阳网站关键词优化多少钱
  • 昆明网络营销服务公司seo 推广服务
  • 优化网站聊城百度快照怎么优化排名
  • 机械设备做公司网站站长工具服务器查询
  • 济宁那家做网站最好百度提问首页
  • 电子商务网站建设实验指导网络优化需要哪些知识
  • 做网站销售门窗怎么做win7系统优化软件
  • 做电影网站技术今日热榜
  • 专门做图片是网站河北百度推广客服电话
  • 网站开发如何做账务处理快速优化网站排名软件
  • 实体企业做网站好么seo排名优化seo
  • 凡科互动app下载湖南百度seo
  • 可道网站建设百度股市行情上证指数
  • 广州正佳广场停车费seo优化关键词放多少合适
  • 展示型网站企业网站建设如何做公司网站推广
  • 网上书店网站建设毕业设计发布软文是什么意思
  • 帝国cms做网站天津网站建设公司
  • 店铺网站域名怎么做搜索引擎营销优化的方法
  • 做棋牌网站建设哪家便宜开发网站多少钱
  • 深圳市建设交易网站google本地搜索
  • ui设计用的软件有哪些seo的特点是什么