<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>密码管理器</title>
<style>
body {
font-family: Arial, sans-serif;
}
#searchBar {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
}
#passwordTable {
width: 100%;
border-collapse: collapse;
}
#passwordTable th,
#passwordTable td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
#passwordTable tr:nth-child(even){background-color: #f2f2f2;}
#passwordTable tr:hover {background-color: #ddd;}
#passwordTable th {
padding-top: 12px;
padding-bottom: 12px;
text-align: center;
background-color: #4CAF50;
color: white;
}
/* 限制内容长度并换行 */
.max-length {
max-width: 150px;
word-wrap: break-word;
text-align: center;
}
</style>
</head>
<body>
<input type="text" id="searchBar" onkeyup="search()" placeholder="搜索网站/应用名称...">
<table id="passwordTable">
<tr>
<th>网站/应用名称</th>
<th>用户名</th>
<th>密码</th>
</tr>
<!-- 这里通过JavaScript动态添加数据 -->
</table>
<script src="script.js"></script>
</body>
</html>
// 示例数据,实际项目中可以通过Ajax从服务器获取
let passwords = [
// ...更多数据
{name: "Eplan", link: "https://login.epulse-eplan.cn/account/login", username: "崇山主人", password: "cszrtest"},
{name: "ChatAI", link: "http://chatyy.whwxk.cn/", username: "崇山主人", password: "cszrtest"}
];
// 初始化表格
function initTable() {
let table = document.getElementById('passwordTable');
passwords.forEach((item, index) => {
let row = table.insertRow(index + 1);
let nameCell = row.insertCell(0);
let userCell = row.insertCell(1);
let passCell = row.insertCell(2);
nameCell.innerHTML = `<a href="${item.link}" target="_blank">${item.name}</a>`;
userCell.innerHTML = `<span class="max-length">${item.username}</span><button onclick="copyText(this)" style="background-color: #6AD921;color: #FF0FFF">点击复制</button>`;
passCell.innerHTML = `<span class="max-length">${item.password}</span><button onclick="copyText(this)" style="background-color: #6AD921;color: #FF0FFF">点击复制</button>`;
});
}
// 复制文本到剪贴板
function copyText(button) {
let textToCopy = button.previousElementSibling.textContent;
navigator.clipboard.writeText(textToCopy).then(() => {
alert("复制成功");
}, () => {
alert("复制失败,请手动复制");
});
}
// 简单的搜索功能
function search() {
let input = document.getElementById("searchBar");
let filter = input.value.toUpperCase();
let table = document.getElementById("passwordTable");
let trs = table.getElementsByTagName("tr");
for (let i = 1; i < trs.length; i++) {
let td = trs[i].getElementsByTagName("td")[0];
if (td) {
let txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
trs[i].style.display = "";
} else {
trs[i].style.display = "none";
}
}
}
}
// 页面加载时初始化
window.onload = function() {
initTable();
};
"""
This is a Python module/script.
Author: 崇山主人
Email: 2276636532@qq.com
Version: 1.0.0
Date: 2024-05-24
Description:
PWI(password input),密码管理查阅小工具.
"""
import tkinter as tk
from tkinter import simpledialog, filedialog, messagebox
import pyperclip
import subprocess
import os
def get_inputs():
global number
number = simpledialog.askinteger("输入", "请输入密码的个数:", parent=root)
if number is None:
return # 如果点击了取消按钮,则返回,不执行后续代码
# 清空之前的结果
results.clear()
for _ in range(number):
link = simpledialog.askstring("输入", "请输入 link:", parent=root)
if link is None:
return # 如果点击了取消按钮,则返回,不执行后续代码
name = simpledialog.askstring("输入", "请输入 name:", parent=root)
if name is None:
return # 如果点击了取消按钮,则返回,不执行后续代码
username = simpledialog.askstring("输入", "请输入 username:", parent=root)
if username is None:
return # 如果点击了取消按钮,则返回,不执行后续代码
password = simpledialog.askstring("输入", "请输入 password:", parent=root)
if password is None:
return # 如果点击了取消按钮,则返回,不执行后续代码
results.append({"name": name, "link": link, "username": username, "password": password})
show_results()
def open_script():
if not check_vscode_path(): # 检查 VS Code 路径的有效性
return
filepath = filedialog.askopenfilename(title="选择 script.js 文件", filetypes=[("JavaScript files", "*.js")])
if filepath:
subprocess.Popen([vscode_cmd.get(), filepath])
def show_results():
output_text.delete(1.0, tk.END)
for data in results:
output_text.insert(tk.END, f'{{name: "{data["name"]}", link: "{data["link"]}", username: "{data["username"]}", password: "{data["password"]}"}},\n')
def copy_to_clipboard():
pyperclip.copy(output_text.get(1.0, tk.END))
def check_vscode_path():
vscode_path = vscode_cmd.get()
if not vscode_path:
messagebox.showerror("错误", "VS Code路径不能为空!")
return False
if not os.path.exists(vscode_path):
messagebox.showerror("错误", f"无效的VS Code路径:{vscode_path}")
return False
return True
root = tk.Tk()
root.title("密码管理器")
results = []
# 设置窗口大小不可调整
root.resizable(False, False)
frame_input = tk.Frame(root)
frame_input.pack(pady=10)
input_button = tk.Button(frame_input, text="开始输入密码", command=get_inputs)
input_button.pack(side=tk.LEFT, padx=20)
copy_button = tk.Button(frame_input, text="复制所有内容", command=copy_to_clipboard)
copy_button.pack(side=tk.LEFT, padx=20)
vscode_label = tk.Label(frame_input, text="VS Code 路径:")
vscode_label.pack(side=tk.LEFT, padx=20)
vscode_cmd = tk.StringVar()
vscode_cmd.set("D:\\OrginOthers\\Microsoft VS Code\\bin\\code.cmd")
vscode_path_entry = tk.Entry(frame_input, textvariable=vscode_cmd, width=40)
vscode_path_entry.pack(side=tk.LEFT, padx=5)
open_button = tk.Button(frame_input, text="打开 script.js", command=open_script)
open_button.pack(side=tk.LEFT, padx=20)
output_text = tk.Text(root, wrap=tk.WORD, width=85, height=35)
output_text.pack(padx=10, pady=10)
root.mainloop()
蓝奏云:https://cszr.lanzoue.com/iGT3C1zn3yxa
密码:cszr
最烦写字了,云盘有打包的exe和详细说明,喜欢就自己探索着玩