15 私有链接
文件数据库:
<?php
// 定义数据库文件的路径
$dbFile = 'database.db';
try {
// 创建或打开 SQLite3 数据库
$db = new SQLite3($dbFile);
// 创建一个表格,如果已经存在则跳过
$db->exec("CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT NOT NULL UNIQUE
)");
// 插入一些数据
$insertData = [
['name' => 'Alice', 'email' => 'alice@example.com'],
['name' => 'Bob', 'email' => 'bob@example.com'],
['name' => 'Charlie', 'email' => 'charlie@example.com'],
];
$stmt = $db->prepare("INSERT OR IGNORE INTO users (name, email) VALUES (:name, :email)");
foreach ($insertData as $data) {
$stmt->bindValue(':name', $data['name'], SQLITE3_TEXT);
$stmt->bindValue(':email', $data['email'], SQLITE3_TEXT);
$stmt->execute();
}
// 从数据库读取数据
$result = $db->query("SELECT * FROM users");
// 输出数据
echo "<h1>Users List</h1>";
echo "<table border='1'>";
echo "<tr><th>ID</th><th>Name</th><th>Email</th></tr>";
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
echo "<tr>";
echo "<td>" . htmlspecialchars($row['id']) . "</td>";
echo "<td>" . htmlspecialchars($row['name']) . "</td>";
echo "<td>" . htmlspecialchars($row['email']) . "</td>";
echo "</tr>";
}
echo "</table>";
// 关闭数据库连接
$db->close();
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>
内存数据库:
<?php
try {
// 创建一个 SQLite3 的内存数据库
$db = new SQLite3(':memory:');
// 创建一个表
$db->exec("CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT NOT NULL UNIQUE
)");
// 插入一些数据
$db->exec("INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com')");
$db->exec("INSERT INTO users (name, email) VALUES ('Bob', 'bob@example.com')");
$db->exec("INSERT INTO users (name, email) VALUES ('Charlie', 'charlie@example.com')");
// 从数据库读取数据
$result = $db->query("SELECT * FROM users");
// 输出数据
echo "<h1>Users List (Memory Database)</h1>";
echo "<table border='1'>";
echo "<tr><th>ID</th><th>Name</th><th>Email</th></tr>";
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
echo "<tr>";
echo "<td>" . htmlspecialchars($row['id']) . "</td>";
echo "<td>" . htmlspecialchars($row['name']) . "</td>";
echo "<td>" . htmlspecialchars($row['email']) . "</td>";
echo "</tr>";
}
echo "</table>";
// 关闭数据库连接
$db->close();
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
?>
欢迎来到极品下载论坛,这里不仅专注于高清无损音乐MV的搜集下载,更是教育教学的最佳学习分享之地。
基于豆包大模型,提供智能 AI IDE 和 AI 编程助手,带给你全新的编码体验。AI IDE 提供开箱即用的开发环境,AI 编程助手提供代码生成、代码解释、单测生成和问题修复等功能,支持上百种编程语言和主流开发环境。
基于豆包大模型,提供智能 AI IDE 和 AI 编程助手,带给你全新的编码体验。AI IDE 提供开箱即用的开发环境,AI 编程助手提供代码生成、代码解释、单测生成和问题修复等功能,支持上百种编程语言和主流开发环境。
// ./src/lib.rs
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.setup(|app| {
{
use tauri::Manager;
// 获取窗口对象
let window = app.get_webview_window("main").unwrap();
// 设置窗口始终在最上层
window.set_always_on_top(true).unwrap();
}
{
use tauri::{AppHandle, Manager};
#[cfg(desktop)]
use tauri_plugin_global_shortcut::{
Code, GlobalShortcutExt, Modifiers, Shortcut, ShortcutState,
}; // 引入窗口管理模块
let alt_x_shortcut = Shortcut::new(Some(Modifiers::ALT), Code::KeyX);
app.handle().plugin(
tauri_plugin_global_shortcut::Builder::new()
.with_handler(move |app_handle: &AppHandle, shortcut, event| {
if shortcut == &alt_x_shortcut {
let window = app_handle.get_webview_window("main").unwrap(); // 获取窗口对象
match event.state() {
ShortcutState::Pressed => {
if window.is_minimized().unwrap() {
window.unminimize().unwrap(); // 还原窗口
println!("窗口已还原!");
} else {
window.minimize().unwrap(); // 最小化窗口
println!("窗口已最小化!");
}
}
ShortcutState::Released => {
// 这里可以添加你想要在松开时执行的逻辑
}
}
}
})
.build(),
)?;
app.global_shortcut().register(alt_x_shortcut)?;
}
Ok(())
})
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Utilities for web, compare text online or compress/convert images to formats like JPEG, PNG, AVIF and WEBP
Collect the perfect IP addresses and domain names database for querying.
Clarity is a free user behavior analytics tool that helps you understand how users are interacting with your website through session replays and heatmaps.
The cross-platform app building toolkit
聚合图床是一个提供高速外链的免费图床,无限流量,无限外链,全球网络加速,提供API和客户端上传图片,专业的跨境电商图片上传和托管,适合亚马逊, wish, ebay, shopify, 速卖通等电商批量上传图片
GitHub 代理加速,github proxy国内加速,GitHub 文件,Releases,archive,gist,raw.githubusercontent.com 文件代理加速下载服务.
GitHub 文件 , Releases , archive , gist , raw.githubusercontent.com 文件代理加速下载服务.
使用MSVC工具链!
在全局 config.toml 中设置默认 release 配置,位于:
~/.cargo/config.toml
修改 Cargo.toml,添加以下配置:
[profile.release]
opt-level = "z" # 优化级别设为 "z",专注于大小优化
lto = true # 启用链接时优化
codegen-units = 1 # 减少代码生成单元,提高优化效果
panic = "abort" # 恐慌时直接中止,减少错误处理代码
strip = true # 剥离符号信息
cargo build --release
Github项目:
https://github.com/johnthagen/min-sized-rust/tree/main
Rust 语言真的好
静默安装msvc环境:
vs_BuildTools.exe --quiet --wait --norestart --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.Windows10SDK.19041 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --includeRecommended
能看到进度条的安装msvc环境:
vs_BuildTools.exe --passive --wait --norestart --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.Windows10SDK.19041 --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --includeRecommended
查看当前使用的 Rust 工具链
rustup show active-toolchain
查看所有安装的工具链
rustup toolchain list
要使用 MSVC 工具链,你需要先安装相应的工具链。
rustup toolchain install stable-x86_64-pc-windows-msvc
切换到 MSVC 工具链
rustup default stable-x86_64-pc-windows-msvc
rustup show active-toolchain
切换到 gnu 工具链
rustup default stable-x86_64-pc-windows-gnu
为工程添加工具链
rustup target add stable-x86_64-pc-windows-gnu
使用某个工具链build
cargo build --target=stable-x86_64-pc-windows-gnu --release
在工程中查看工具链
rustup show
Windows
rustup set profile minimal
中国科技大学:
setx RUSTUP_DIST_SERVER "https://mirrors.ustc.edu.cn/rust-static" /M
setx RUSTUP_UPDATE_ROOT "https://mirrors.ustc.edu.cn/rust-static/rustup" /M
RsProxy.cn
setx RUSTUP_DIST_SERVER "https://rsproxy.cn" /M
setx RUSTUP_UPDATE_ROOT "https://rsproxy.cn/rustup" /M
C:\Users\Administrator.cargo\config
中国科技大学:
[source.crates-io]
registry ="https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
RsProxy.cn
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true
CentOS7
在 CentOS 7 中配置 Rust 及 Rustup 使用国内镜像,可以按照以下步骤进行:
1. 安装 Rustup 并设置 Minimal Profile
首先修用下面的命令,将安装脚本导出
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust.sh
打开 rust.sh 脚本,将 RUSTUP_UPDATE_ROOT 修改为
RUSTUP_UPDATE_ROOT="https://mirrors.aliyun.com/rustup/rustup/"
这是用来下载 rustup-init 的, 修改后通过国内镜像下载
chmod +x ./rust.sh
最后执行修改后的rust.sh
rustup set profile minimal
2. 配置 Rustup 使用国内源
(1)中国科技大学镜像
echo 'export RUSTUP_DIST_SERVER="https://mirrors.ustc.edu.cn/rust-static"' >> ~/.bashrc
echo 'export RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup"' >> ~/.bashrc
source ~/.bashrc
(2)RsProxy.cn 镜像
echo 'export RUSTUP_DIST_SERVER="https://rsproxy.cn"' >> ~/.bashrc
echo 'export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"' >> ~/.bashrc
source ~/.bashrc
3. 配置 Cargo 使用国内源
编辑 ~/.cargo/config
文件:
(1)中国科技大学镜像
mkdir -p ~/.cargo
cat > ~/.cargo/config <<EOF
[source.crates-io]
registry ="https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
EOF
(2)RsProxy.cn 镜像
mkdir -p ~/.cargo
cat > ~/.cargo/config <<EOF
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true
EOF
4. 更新 Rust 并验证
rustup update
rustc --version
cargo --version
这套配置可以帮助你在 CentOS 7 上顺利使用国内源加速 Rust 及 Cargo 相关的操作。你可以选择 USTC 或 RsProxy 作为镜像源,二者选其一即可。