<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0"><channel><title>ccruiの博客</title><link>https://blog.ccrui.cn</link><atom:link href="https://blog.ccrui.cn/rss.xml" rel="self" type="application/rss+xml"/><description>ccruiの博客</description><generator>Halo v2.20.21</generator><language>zh-cn</language><image><url>https://img-cdn.ccrui.cn/2020/07/20/e9fa4ba87fd41747fb6ffd1f675db0c.jpg</url><title>ccruiの博客</title><link>https://blog.ccrui.cn</link></image><lastBuildDate>Thu, 19 Nov 2026 05:11:58 GMT</lastBuildDate><item><title><![CDATA[使用国内 CDN 分流加速 CloudFlare Workers]]></title><link>https://blog.ccrui.cn/archives/shi-yong-guo-nei-cdn-fen-liu-jia-su-cloudflare-workers</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E4%BD%BF%E7%94%A8%E5%9B%BD%E5%86%85%20CDN%20%E5%88%86%E6%B5%81%E5%8A%A0%E9%80%9F%20CloudFlare%20Workers&amp;url=/archives/shi-yong-guo-nei-cdn-fen-liu-jia-su-cloudflare-workers" width="1" height="1" alt="" style="opacity:0;">
<h2 id="前言">前言</h2>
<p>Cloudflare Workers 以其强大的边缘计算能力和全球 CDN 网络，为开发者提供了便捷的 Serverless 服务。然而，由于网络环境的特殊性，直接访问 Cloudflare 在中国大陆的速度可能并不理想。为了提升中国大陆用户的访问体验，我们可以利用国内 CDN (内容分发网络) 对 Cloudflare Workers 进行加速分流，实现更快速、更稳定的访问。</p>
<p><strong>本文将介绍如何使用国内 CDN 为 Cloudflare Workers 站点加速，提升中国大陆用户的访问速度。</strong> 本教程提供通用的配置流程，你可以根据你选择的国内 CDN 服务商进行具体操作。</p>
<h2 id="准备工作">准备工作</h2>
<p>在开始之前，请确保你已完成以下准备工作：</p>
<ol>
 <li>
  <p><strong>拥有 Cloudflare 域名托管:</strong></p>
  <ul>
   <li>你需要在 Cloudflare 上托管至少一个域名，例如 <code>example.com</code>。</li>
  </ul></li>
 <li>
  <p><strong>创建并部署 Cloudflare Worker 或 Pages 项目:</strong></p>
  <ul>
   <li>你需要创建一个 Cloudflare Worker 或者 Pages 项目，并将其绑定到一个子域名，例如 <code>a.example.com</code>。</li>
   <li>这个子域名将作为你的源站。</li>
  </ul></li>
 <li>
  <p><strong>拥有国内 CDN 服务账号:</strong></p>
  <ul>
   <li>你需要注册并开通国内 CDN 服务，例如 阿里云 CDN、腾讯云 CDN、又拍云 CDN 等。</li>
   <li>本教程提供通用的配置流程，具体操作请参考你所选 CDN 服务商的文档。</li>
  </ul></li>
</ol>
<h2 id="创建-cdn-加速">创建 CDN 加速</h2>
<p>以下是创建 CDN 加速的通用步骤，你需要根据你使用的 CDN 控制台进行操作。</p>
<ol>
 <li>
  <p><strong>登录 CDN 控制台:</strong></p>
  <ul>
   <li>访问你选择的国内 CDN 服务商的控制台并登录你的账号。</li>
  </ul></li>
 <li>
  <p><strong>添加域名:</strong></p>
  <ul>
   <li>在 CDN 控制台中，找到 <strong>域名管理</strong> 或 <strong>添加域名</strong> 相关的入口。</li>
   <li>输入你要加速的子域名，例如 <code>a.example.com</code>。 <strong>注意：这里填写的是你最终希望用户访问的加速域名，而不是 Cloudflare Worker 的默认域名。</strong></li>
  </ul></li>
 <li>
  <p><strong>配置源站信息:</strong></p>
  <ul>
   <li>在 <strong>源站信息</strong> 配置中，选择 <strong>源站类型</strong> 为 <strong>域名</strong>。</li>
   <li>在 <strong>源站地址</strong> 中，填写你的 Cloudflare Worker 或 Pages 的默认分配域名，例如 <code>xxx.pages.dev</code> 或 <code>xxx.workers.dev</code>。</li>
   <li><strong>回源协议</strong> 选择 <strong>HTTPS</strong>。</li>
   <li><strong>端口</strong> 保持默认 <code>443</code> (HTTPS)。</li>
  </ul></li>
 <li>
  <p><strong>配置 SSL 证书:</strong></p>
  <ul>
   <li>确保你的加速域名配置了 SSL 证书，并开启 <strong>HTTPS 强制跳转</strong>。</li>
  </ul></li>
 <li>
  <p><strong>其他 CDN 配置 (可选但建议):</strong></p>
  <ul>
   <li><strong>缓存配置:</strong> 合理配置 CDN 缓存策略。</li>
   <li><strong>区域加速:</strong> 选择 <strong>中国大陆加速</strong> 区域。</li>
  </ul></li>
 <li>
  <p><strong>完成添加:</strong></p>
  <ul>
   <li>完成域名添加后，CDN 会分配给你一个 <strong>CDN 加速域名 (CNAME)</strong>。 <strong>请记录下这个 CNAME 值，下一步 DNS 解析会用到。</strong></li>
  </ul></li>
</ol>
<h2 id="域名绑定与-dns-解析">域名绑定与 DNS 解析</h2>
<p>这一步的关键是将你的域名 <code>a.example.com</code> 指向 CDN 加速地址 (针对中国大陆用户)，并保持境外用户直接访问 Cloudflare Worker。 我们将使用 <strong>阿里云 DNS</strong> 进行域名解析，实现 <strong>境内境外分流</strong>。</p>
<ol>
 <li>
  <p><strong>登录阿里云域名控制台:</strong></p>
  <ul>
   <li>访问 <a href="https://dc.console.aliyun.com/">阿里云域名控制台</a> 并登录你的阿里云账号。</li>
   <li>找到你想要配置的域名 <code>example.com</code>，点击 <strong>域名解析</strong>。</li>
  </ul></li>
 <li>
  <p><strong>添加 DNS 解析记录:</strong></p>
  <ul>
   <li>
    <p><strong>确保使用 阿里云 DNS:</strong> 本教程假设你的域名解析服务商是 <strong>阿里云 DNS</strong>。 如果你的域名解析在其他地方，请将域名解析迁移到阿里云 DNS，或者参考你当前 DNS 服务商的线路类型解析功能进行配置。</p></li>
   <li>
    <p><strong>添加 A 记录 (默认线路 - 中国大陆 CDN 加速):</strong></p>
    <ul>
     <li>点击 <strong>添加记录</strong> 按钮。</li>
     <li><strong>记录类型:</strong> 选择 <code>A - 将域名指向 IPv4 地址</code></li>
     <li><strong>主机记录:</strong> 填写 <code>a</code> (或你想要加速的子域名，例如 <code>cdn</code>)</li>
     <li><strong>解析线路:</strong> 选择 <strong>默认</strong> （阿里云 DNS 的 “默认” 线路通常指中国大陆地区）</li>
     <li><strong>记录值:</strong> 填写 <strong>你在 CDN 控制台中获得的 CDN 加速域名 (CNAME 值)</strong>，例如 <code>xxxx.aliyundomain.com</code>。</li>
     <li><strong>TTL:</strong> 建议设置为 <code>3600</code> 秒 (1小时) 或更短，例如 <code>600</code> 秒 (10分钟)，方便 DNS 生效。</li>
    </ul></li>
   <li>
    <p><strong>添加 CNAME 记录 (境外线路 - Cloudflare Worker 源站):</strong></p>
    <ul>
     <li>再次点击 <strong>添加记录</strong> 按钮。</li>
     <li><strong>记录类型:</strong> 选择 <code>CNAME - 将域名指向另一个域名</code></li>
     <li><strong>主机记录:</strong> 填写 <code>a</code> (与上面 A 记录相同)</li>
     <li><strong>解析线路:</strong> 选择 <strong>境外</strong> （阿里云 DNS 的 “境外” 线路指中国大陆以外的地区）</li>
     <li><strong>记录值:</strong> 填写 <strong>你的 Cloudflare Worker 或 Pages 绑定的子域名</strong>，例如 <code>a.example.com</code> 或 <code>your-worker-name.workers.dev</code> (推荐使用你绑定的子域名 <code>a.example.com</code>，保持一致性)。 <strong>注意：这里填写的是 Cloudflare Worker 的域名，而不是 CDN 的 CNAME 值。</strong></li>
     <li><strong>TTL:</strong> 建议设置为 <code>3600</code> 秒 (1小时) 或更短，例如 <code>600</code> 秒 (10分钟)。</li>
    </ul></li>
  </ul></li>
 <li>
  <p><strong>检查解析设置:</strong></p>
  <ul>
   <li>添加完成后，你会在阿里云 DNS 解析列表中看到两条关于 <code>a.example.com</code> (或你设置的子域名) 的记录，一条是 <strong>A 记录 (默认线路)</strong> 指向 CDN CNAME，另一条是 <strong>CNAME 记录 (境外线路)</strong> 指向 Cloudflare Worker 域名。</li>
  </ul></li>
 <li>
  <p><strong>等待 DNS 生效并验证:</strong></p>
  <ul>
   <li>DNS 解析生效需要一定时间，通常几分钟到几小时不等。</li>
   <li>你可以使用 <code>ping</code> 或 <code>dig</code> 命令，分别在 <strong>国内和国外</strong> 的网络环境下测试 <code>a.example.com</code> 的解析结果，验证是否生效： 
    <ul>
     <li><strong>国内网络环境:</strong> <code>ping a.example.com</code> 应该返回阿里云 CDN 节点的 IP 地址 (可以通过 <code>ping CDN CNAME 值</code> 来对比确认)。</li>
     <li><strong>国外网络环境:</strong> <code>ping a.example.com</code> 应该返回 Cloudflare Worker 的 IP 地址 (可以通过 <code>ping 你的 Cloudflare Worker 域名</code> 来对比确认)。</li>
    </ul></li>
   <li>也可以使用在线 DNS 查询工具，例如 <a href="https://tool.chinaz.com/dns/">站长工具 DNS 查询</a>，分别选择 <strong>国内</strong> 和 <strong>国外</strong> 节点进行查询，查看解析结果是否符合预期。</li>
  </ul></li>
</ol>
<h2 id="原理分析">原理分析</h2>
<p>这个加速方案的核心原理是 <strong>DNS 智能解析</strong> 和 <strong>CDN 分发网络</strong>。</p>
<ul>
 <li><strong>DNS 智能解析:</strong> 根据用户的地理位置返回不同的解析结果，实现分线路访问。</li>
 <li><strong>CDN 分发网络:</strong> 国内 CDN 在中国大陆部署节点，加速访问速度。</li>
 <li><strong>Cloudflare Worker 作为源站:</strong> 境外用户和国内 CDN 回源都访问 Cloudflare Worker。</li>
</ul>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2025%2F03%2F29%2F67e7b7d6d3b4b.png&amp;size=m" alt="67e7b7d6d3b4b.png"></p>]]></description><guid isPermaLink="false">/archives/shi-yong-guo-nei-cdn-fen-liu-jia-su-cloudflare-workers</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 29 Mar 2025 09:05:57 GMT</pubDate></item><item><title><![CDATA[openwebui 显示 R1 思维链 [支持PPLX][更新 支持火山引擎Bots搜索]]]></title><link>https://blog.ccrui.cn/archives/openwebui-xian-shi-r1-si-wei-lian-geng-xin-0.5.6-zhi-chi</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=openwebui%20%E6%98%BE%E7%A4%BA%20R1%20%E6%80%9D%E7%BB%B4%E9%93%BE%20%5B%E6%94%AF%E6%8C%81PPLX%5D%5B%E6%9B%B4%E6%96%B0%20%E6%94%AF%E6%8C%81%E7%81%AB%E5%B1%B1%E5%BC%95%E6%93%8EBots%E6%90%9C%E7%B4%A2%5D&amp;url=/archives/openwebui-xian-shi-r1-si-wei-lian-geng-xin-0.5.6-zhi-chi" width="1" height="1" alt="" style="opacity:0;">
<blockquote>
 <p>v1.2.13更新 支持<code>pplx</code>搜索推理模型<br>
   v1.2.12更新 修复<code>火山引擎bots</code>引用错误的问题<br>
   v1.2.11更新 支持<code>火山引擎bots</code>搜索结果的显示与引用<br>
   v1.2.10更新 修正部分渠道流式返回最后出现[DONE]导致解析报错的问题<br>
   v1.2.9更新 修正错误处理中出现了二次报错问题 感谢 @happyhome 提出的问题和解决方案<br>
   v1.2.8更新 修复多用户并发时出现的思维链排序错乱的问题<br>
   v1.2.7更新 支持腾讯云<br>
   v1.2.6更新 支持火山引擎<br>
   v1.2.5更新 修复可能出现的<code>思考吃字</code>问题<br>
   v1.2.4更新 修复Hyperbolic渠道<code>&lt;/think&gt;</code>后吞字的问题<br>
   v1.2.3更新 增加对api请求模型的设置<br>
   v1.2.2更新 支持硅基流动的API返回</p>
</blockquote>
<blockquote>
 <p>现在官方API一直属于崩溃状态，建议使用 <a href="https://www.volcengine.com/experience/ark?utm_term=202502dsinvite&amp;ac=DSASUQY5&amp;rc=K6SV9W5F">火山方舟API</a></p>
</blockquote>
<p>最近在 <code>openwebui</code> 中使用 <code>R1</code> 模型，因为看不到思维过程，总觉得难受，网上找上一圈也没有发现有现成的函数可以实现，于是趁着 
 <del>上班摸鱼</del> 无聊，手搓了一个 <code>openwebui</code> 函数 实现了思维链的查看。</p>
<p>并且根据DeepSeek官方文档的要求，上次回复的思维链内容，不会参与之后的对话请求。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2025%2F01%2F23%2F6791ce7e2ebcf.webp&amp;size=m" alt="6791ce7e2ebcf.webp"></p>
<h2 id="效果">效果</h2>
<h3 id="仅思维链">仅思维链</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2025%2F02%2F21%2F67b7cac013079.png&amp;size=m" alt="67b7cac013079.png"></p>
<h3 id="pplx联网">PPLX联网</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2025%2F02%2F21%2F67b7caffcf65d.png&amp;size=m" alt="67b7caffcf65d.png"></p>
<h3 id="火山方舟联网">火山方舟联网</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2025%2F02%2F21%2F67b7caf4e007b.png&amp;size=m" alt="67b7caf4e007b.png"></p>
<h2 id="使用方式">使用方式</h2>
<p><a href="https://openwebui.com/f/zgccrui/deepseek_r1/">https://openwebui.com/f/zgccrui/deepseek_r1/</a></p>
<details>
 <summary>函数</summary>
 <pre><code class="language-python">"""
title: DeepSeek R1
author: zgccrui
description: 在OpwenWebUI中显示DeepSeek R1模型的思维链 - 仅支持0.5.6及以上版本
version: 1.2.13
licence: MIT
"""

import json
import httpx
import re
from typing import AsyncGenerator, Callable, Awaitable
from pydantic import BaseModel, Field
import asyncio


class Pipe:
    class Valves(BaseModel):
        DEEPSEEK_API_BASE_URL: str = Field(
            default="https://api.deepseek.com/v1",
            description="DeepSeek API的基础请求地址",
        )
        DEEPSEEK_API_KEY: str = Field(
            default="", description="用于身份验证的DeepSeek API密钥，可从控制台获取"
        )
        DEEPSEEK_API_MODEL: str = Field(
            default="deepseek-reasoner",
            description="API请求的模型名称，默认为 deepseek-reasoner ",
        )

    def __init__(self):
        self.valves = self.Valves()
        self.data_prefix = "data:"
        self.emitter = None

    def pipes(self):
        return [
            {
                "id": self.valves.DEEPSEEK_API_MODEL,
                "name": self.valves.DEEPSEEK_API_MODEL,
            }
        ]

    async def pipe(
        self, body: dict, __event_emitter__: Callable[[dict], Awaitable[None]] = None
    ) -&gt; AsyncGenerator[str, None]:
        """主处理管道（已移除缓冲）"""
        thinking_state = {"thinking": -1}  # 用于存储thinking状态
        self.emitter = __event_emitter__
        # 用于存储联网模式下返回的参考资料列表
        stored_references = []

        # 联网搜索供应商 0-无 1-火山引擎 2-PPLX引擎
        search_providers = 0
        waiting_for_reference = False

        # 验证配置
        if not self.valves.DEEPSEEK_API_KEY:
            yield json.dumps({"error": "未配置API密钥"}, ensure_ascii=False)
            return
        # 准备请求参数
        headers = {
            "Authorization": f"Bearer {self.valves.DEEPSEEK_API_KEY}",
            "Content-Type": "application/json",
        }
        try:
            # 模型ID提取
            model_id = body["model"].split(".", 1)[-1]
            payload = {**body, "model": model_id}
            # 处理消息以防止连续的相同角色
            messages = payload["messages"]
            i = 0
            while i &lt; len(messages) - 1:
                if messages[i]["role"] == messages[i + 1]["role"]:
                    # 插入具有替代角色的占位符消息
                    alternate_role = (
                        "assistant" if messages[i]["role"] == "user" else "user"
                    )
                    messages.insert(
                        i + 1,
                        {"role": alternate_role, "content": "[Unfinished thinking]"},
                    )
                i += 1

            # 发起API请求
            async with httpx.AsyncClient(http2=True) as client:
                async with client.stream(
                    "POST",
                    f"{self.valves.DEEPSEEK_API_BASE_URL}/chat/completions",
                    json=payload,
                    headers=headers,
                    timeout=300,
                ) as response:

                    # 错误处理
                    if response.status_code != 200:
                        error = await response.aread()
                        yield self._format_error(response.status_code, error)
                        return

                    # 流式处理响应
                    async for line in response.aiter_lines():
                        if not line.startswith(self.data_prefix):
                            continue

                        # 截取 JSON 字符串
                        json_str = line[len(self.data_prefix) :]

                        # 去除首尾空格后检查是否为结束标记
                        if json_str.strip() == "[DONE]":
                            return
                        try:
                            data = json.loads(json_str)
                        except json.JSONDecodeError as e:
                            error_detail = f"解析失败 - 内容：{json_str}，原因：{e}"
                            yield self._format_error("JSONDecodeError", error_detail)
                            return

                        if search_providers == 0:
                            # 处理参考资料
                            stored_references = data.get("references", []) + data.get("citations", [])
                            if stored_references:
                                ref_count = len(stored_references)
                                yield '&lt;details type="search"&gt;\n'
                                yield f"&lt;summary&gt;已搜索 {ref_count} 个网站&lt;/summary&gt;\n"
                            # 如果data中有references，则说明是火山引擎的返回结果
                            if data.get("references"):
                                for idx, reference in enumerate(stored_references, 1):
                                    yield f'&gt; {idx}. [{reference["title"]}]({reference["url"]})\n'
                                yield "&lt;/details&gt;\n"
                                search_providers = 1
                            # 如果data中有citations，则说明是PPLX引擎的返回结果
                            elif data.get("citations"):
                                for idx, reference in enumerate(stored_references, 1):
                                    yield f'&gt; {idx}. {reference}\n'
                                yield "&lt;/details&gt;\n"
                                search_providers = 2

                        choice = data.get("choices", [{}])[0]

                        # 结束条件判断
                        if choice.get("finish_reason"):
                            return

                        # 状态机处理
                        state_output = await self._update_thinking_state(
                            choice.get("delta", {}), thinking_state
                        )
                        if state_output:
                            yield state_output
                            if state_output == "&lt;think&gt;":
                                yield "\n"

                        # 处理并立即发送内容
                        content = self._process_content(choice["delta"])
                        if content:
                            # 处理思考状态标记
                            if content.startswith("&lt;think&gt;"):
                                content = re.sub(r"^&lt;think&gt;", "", content)
                                yield "&lt;think&gt;"
                                await asyncio.sleep(0.1)
                                yield "\n"
                            elif content.startswith("&lt;/think&gt;"):
                                content = re.sub(r"^&lt;/think&gt;", "", content)
                                yield "&lt;/think&gt;"
                                await asyncio.sleep(0.1)
                                yield "\n"

                            # 处理参考资料
                            if search_providers == 1:
                                # 火山引擎的参考资料处理
                                # 如果文本中包含"摘要"，设置等待标志
                                if "摘要" in content:
                                    waiting_for_reference = True
                                    yield content
                                    continue

                                # 如果正在等待参考资料的数字
                                if waiting_for_reference:
                                    # 如果内容仅包含数字或"、"
                                    if re.match(r"^(\d+|、)$", content.strip()):
                                        numbers = re.findall(r"\d+", content)
                                        if numbers:
                                            num = numbers[0]
                                            ref_index = int(num) - 1
                                            if 0 &lt;= ref_index &lt; len(stored_references):
                                                ref_url = stored_references[ref_index]["url"]
                                            else:
                                                ref_url = ""
                                            content = f"[[{num}]]({ref_url})"
                                        # 保持等待状态继续处理后续数字
                                    # 如果遇到非数字且非"、"的内容且不含"摘要"，停止等待
                                    elif not "摘要" in content:
                                        waiting_for_reference = False
                            elif search_providers == 2:
                                # PPLX引擎的参考资料处理
                                def replace_ref(m):
                                    idx = int(m.group(1)) - 1
                                    if 0 &lt;= idx &lt; len(stored_references):
                                        return f'[[{m.group(1)}]]({stored_references[idx]})'
                                    return f'[[{m.group(1)}]]()'
                                content = re.sub(r'\[(\d+)\]', replace_ref, content)

                            yield content
        except Exception as e:
            yield self._format_exception(e)

    async def _update_thinking_state(self, delta: dict, thinking_state: dict) -&gt; str:
        """更新思考状态机（简化版）"""
        state_output = ""
        if thinking_state["thinking"] == -1 and delta.get("reasoning_content"):
            thinking_state["thinking"] = 0
            state_output = "&lt;think&gt;"
        elif (
            thinking_state["thinking"] == 0
            and not delta.get("reasoning_content")
            and delta.get("content")
        ):
            thinking_state["thinking"] = 1
            state_output = "\n&lt;/think&gt;\n\n"
        return state_output

    def _process_content(self, delta: dict) -&gt; str:
        """直接返回处理后的内容"""
        return delta.get("reasoning_content", "") or delta.get("content", "")

    def _emit_status(self, description: str, done: bool = False) -&gt; Awaitable[None]:
        """发送状态更新"""
        if self.emitter:
            return self.emitter(
                {
                    "type": "status",
                    "data": {
                        "description": description,
                        "done": done,
                    },
                }
            )
        return None

    def _format_error(self, status_code: int, error: bytes) -&gt; str:
        if isinstance(error, str):
            error_str = error
        else:
            error_str = error.decode(errors="ignore")
        try:
            err_msg = json.loads(error_str).get("message", error_str)[:200]
        except Exception:
            err_msg = error_str[:200]
        return json.dumps(
            {"error": f"HTTP {status_code}: {err_msg}"}, ensure_ascii=False
        )

    def _format_exception(self, e: Exception) -&gt; str:
        err_type = type(e).__name__
        return json.dumps({"error": f"{err_type}: {str(e)}"}, ensure_ascii=False)
</code></pre>
</details>
<details>
 <summary>函数 - 低于0.5.6版本</summary>
 <pre><code class="language-python">"""
title: DeepSeek R1 (Optimized and Fixed)
author: zgccrui
description: 在OpwenWebUI中显示DeepSeek R1模型的思维链
version: 1.1.2
licence: MIT
"""

import json
import httpx
import re
from typing import AsyncGenerator, Callable, Awaitable
from pydantic import BaseModel, Field


class Pipe:
    class Valves(BaseModel):
        DEEPSEEK_API_BASE_URL: str = Field(
            default="https://api.deepseek.com/v1",
            description="DeepSeek API的基础请求地址",
        )
        DEEPSEEK_API_KEY: str = Field(
            default="", description="用于身份验证的DeepSeek API密钥，可从控制台获取"
        )

    def __init__(self):
        self.valves = self.Valves()
        self.clean_pattern = re.compile(r"&lt;details&gt;.*?&lt;/details&gt;\n\n", flags=re.DOTALL)
        self.data_prefix = "data: "
        self.thinking = -1  # -1:未开始 0:思考中 1:已回答
        self.emitter = None
        self.buffer_size = 3  # 响应缓冲阈值

    def pipes(self):
        return [{"id": "deepseek-reasoner", "name": "deepseek-reasoner"}]

    async def emit_status(self, message: str = "", done: bool = False):
        """状态通知发射器"""
        if self.emitter:
            await self.emitter(
                {"type": "status", "data": {"description": message, "done": done}}
            )

    async def pipe(
        self, body: dict, __event_emitter__: Callable[[dict], Awaitable[None]] = None
    ) -&gt; AsyncGenerator[str, None]:
        """主处理管道"""
        self.thinking = -1
        self.emitter = __event_emitter__
        response_buffer = []

        # 验证配置
        if not self.valves.DEEPSEEK_API_KEY:
            yield json.dumps({"error": "未配置API密钥"}, ensure_ascii=False)
            return

        # 准备请求参数
        headers = {
            "Authorization": f"Bearer {self.valves.DEEPSEEK_API_KEY}",
            "Content-Type": "application/json",
        }

        try:
            # 模型ID提取
            model_id = body["model"].split(".", 1)[-1]
            payload = {**body, "model": model_id}

            # 消息内容清理
            for msg in payload["messages"]:
                if msg.get("role") == "assistant":
                    msg["content"] = self.clean_pattern.sub("", msg["content"]).strip()

            # 发起API请求
            async with httpx.AsyncClient(http2=True) as client:
                async with client.stream(
                    "POST",
                    f"{self.valves.DEEPSEEK_API_BASE_URL}/chat/completions",
                    json=payload,
                    headers=headers,
                    timeout=30,
                ) as response:
                    # 错误处理
                    if response.status_code != 200:
                        error = await response.aread()
                        yield self._format_error(response.status_code, error)
                        return

                    # 流式处理响应
                    async for line in response.aiter_lines():
                        if not line.startswith(self.data_prefix):
                            continue

                        data = json.loads(line[len(self.data_prefix) :])
                        choice = data.get("choices", [{}])[0]

                        # 结束条件判断
                        if choice.get("finish_reason"):
                            if response_buffer:
                                yield "".join(response_buffer)
                            return

                        # 状态机处理
                        state_output = await self._update_thinking_state(
                            choice.get("delta", {})
                        )
                        if state_output:
                            response_buffer.append(state_output)

                        # 内容处理
                        content = self._process_content(choice["delta"])
                        if content:  # 仅当 content 不为空时添加到缓冲区
                            response_buffer.append(content)

                        # 缓冲控制
                        if len(response_buffer) &gt;= self.buffer_size or "\n" in content:
                            yield "".join(response_buffer)
                            response_buffer.clear()

                    # 清理剩余缓冲
                    if response_buffer:
                        yield "".join(response_buffer)

        except Exception as e:
            yield self._format_exception(e)

    async def _update_thinking_state(self, delta: dict) -&gt; str:
        """更新思考状态机（异步版本）"""
        state_output = ""

        # 状态转换：未开始 -&gt; 思考中
        if self.thinking == -1 and delta.get("reasoning_content"):
            self.thinking = 0
            await self.emit_status("🧐 思考中……")
            state_output = "&lt;details&gt;\n&lt;summary&gt;思考过程&lt;/summary&gt;\n"

        # 状态转换：思考中 -&gt; 已回答
        elif self.thinking == 0 and not delta.get("reasoning_content"):
            self.thinking = 1
            await self.emit_status("", done=True)
            state_output = "\n\n----------\n\n&lt;/details&gt;\n\n"

        return state_output

    def _process_content(self, delta: dict) -&gt; str:
        """处理内容片段"""
        reasoning = delta.get("reasoning_content")
        content = delta.get("content")

        # 如果 reasoning 和 content 都为空，返回空字符串（不输出）
        if not reasoning and not content:
            return ""

        # 优先返回 reasoning，其次返回 content
        return str(reasoning) if reasoning else str(content)

    def _format_error(self, status_code: int, error: bytes) -&gt; str:
        """格式化错误消息"""
        try:
            err_msg = json.loads(error).get("message", "未知错误")
        except:
            err_msg = error.decode(errors="ignore")[:200]
        return json.dumps(
            {"error": f"HTTP {status_code}: {err_msg}"}, ensure_ascii=False
        )

    def _format_exception(self, e: Exception) -&gt; str:
        """格式化异常信息"""
        err_type = type(e).__name__
        return json.dumps({"error": f"{err_type}: {str(e)}"}, ensure_ascii=False)
</code></pre>
</details>]]></description><guid isPermaLink="false">/archives/openwebui-xian-shi-r1-si-wei-lian-geng-xin-0.5.6-zhi-chi</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 23 Jan 2025 05:11:05 GMT</pubDate></item><item><title><![CDATA[x-ui OpenAI 代理分流]]></title><link>https://blog.ccrui.cn/archives/x-ui-openai-dai-li-fen-liu.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=x-ui%20OpenAI%20%E4%BB%A3%E7%90%86%E5%88%86%E6%B5%81&amp;url=/archives/x-ui-openai-dai-li-fen-liu.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="最终效果">最终效果</h2>
<table>
 <thead>
  <tr>
   <th></th>
   <th></th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>访问其他网站IP</td>
   <td><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F12%2F09%2F6756f4b7534f3.png&amp;size=m" alt="6756f4b7534f3.png"></td>
  </tr>
  <tr>
   <td>访问OAI质量</td>
   <td><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F12%2F09%2F6756f50e910e7.png&amp;size=m" alt="6756f50e910e7.png"></td>
  </tr>
 </tbody>
</table>
<h2 id="前言">前言</h2>
<p>最近GPT降智的问题越来越严重，我经过了一段时间的观察，发现Plus账号的降智解除最简单的方式就是使用家宽进行OAI的访问，所以我直接购买了<a href="https://linux.do/t/topic/271623">LinuxDO论坛</a>上有大佬推荐的 <a href="https://www.webshare.io/?referral_code=3by9p3l04vqx"><code>Webshare</code></a> 家宽。</p>
<p>但是帖子中的教程我认为使用起来相对麻烦，并且因为我本身在国外就有服务器，并搭建了<code>x-ui</code>服务，所以我开始研究如何能将<code>socks5</code>代理使用在<code>x-ui</code>上，并且只有在<code>OpenAI</code>的请求中使用<code>socks5</code>代理。</p>
<p>我最终的解决方法，灵感来自于<a href="https://6pear.com/skills/x-ui-unlock.html">X-ui二级代理解锁流媒体</a>，使用 X-ui 的二级代理功能，将 OpenAI 的请求通过 <code>socks5</code> 代理进行访问。</p>
<h2 id="准备工作不进行赘述">准备工作（不进行赘述）</h2>
<ol>
 <li>安装 <code>x-ui</code> 服务</li>
 <li>购买 <code>Webshare</code> 家宽</li>
</ol>
<h2 id="配置">配置</h2>
<h3 id="设置outbounds">设置outbounds</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F12%2F09%2F6756f2a5d5212.png&amp;size=m" alt="6756f2a5d5212.png"></p>
<p>在如图所示的Json中<code>outbounds</code>部分加入</p>
<pre><code class="language-json">{
    "tag": "HomeBroadband",
    "protocol": "socks",
    "settings": {
        "servers": [
            {
                "address": "46.203.xxx.xxx",
                "port": 1234,
                "users": [
                    {
                        "user": "aaaaaa",
                        "pass": "bbbbbb",
                        "level": 0
                    }
                ]
            }
        ]
    }
}
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F12%2F09%2F6756f33b77aeb.png&amp;size=m" alt="6756f33b77aeb.png"></p>
<h3 id="设置routing">设置routing</h3>
<p>在<code>routing</code>部分加入</p>
<pre><code class="language-json">{
    "type": "field",
    "outboundTag": "HomeBroadband",
    "domain": [
        "ping0.cc", // 用于测试代理是否正常 测试完成后删除
        "ai.com",
        "chatgpt.com",
        "chat.com",
        "oaistatic.com",
        "oaiusercontent.com",
        "openai.com",
        "openai.com.cdn.cloudflare.net",
        "full:openaiapi-site.azureedge.net",
        "full:openaicom-api-bdcpf8c6d2e9atf6.z01.azurefd.net",
        "full:openaicomproductionae4b.blob.core.windows.net",
        "full:production-openaicom-storage.azureedge.net",
        "regexp:^chatgpt-async-webps-prod-\\S+-\\d+\\.webpubsub\\.azure\\.com$",
        "full:o33249.ingest.sentry.io @ads",
        "full:openaicom.imgix.net @ads"
    ]
}
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F12%2F09%2F6756f3bca2e54.png&amp;size=m" alt="6756f3bca2e54.png"></p>
<p>保存配置并重启<code>x-ui</code>面板即可。</p>
<blockquote>
 <p>分流来源<a href="https://github.com/v2ray/domain-list-community/blob/master/data/openai">domain-list-community</a></p>
</blockquote>
<h2 id="测试">测试</h2>
<p>直接访问<code>ping0.cc</code>，查看IP是否为<code>socks5</code>代理的IP即可。</p>
<blockquote>
 <p>注意：测试完成后应删除<code>routing</code>中的<code>ping0.cc</code> 即可实现OpenAI的代理分流。</p>
</blockquote>
<h2 id="尾声">尾声</h2>
<p>如果想将全部流量都使用家宽节点出站，可以使用下面的配置</p>
<blockquote>
 <p>注意下方的配置，去往国内方向的流量不会走Socket出口</p>
</blockquote>
<p>在<code>routing</code>部分加入</p>
<pre><code class="language-json">{
    "not": [
        "geoip:cn"
    ],
    "outboundTag": "HomeBroadband",
    "type": "field",
    "network": "tcp"
},
{
    "not": [
        "geoip:cn"
    ],
    "outboundTag": "HomeBroadband",
    "type": "field",
    "network": "udp"
}
</code></pre>]]></description><guid isPermaLink="false">/archives/x-ui-openai-dai-li-fen-liu.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 9 Dec 2024 13:51:37 GMT</pubDate></item><item><title><![CDATA[在OpenWebUI中使用FLUX绘画（硅基流动）]]></title><link>https://blog.ccrui.cn/archives/zai-openwebuizhong-shi-yong-fluxhui-hua-huo-ji-liu-dong.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%9C%A8OpenWebUI%E4%B8%AD%E4%BD%BF%E7%94%A8FLUX%E7%BB%98%E7%94%BB%EF%BC%88%E7%A1%85%E5%9F%BA%E6%B5%81%E5%8A%A8%EF%BC%89&amp;url=/archives/zai-openwebuizhong-shi-yong-fluxhui-hua-huo-ji-liu-dong.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="注册并获取秘钥">注册并获取秘钥</h2>
<p><a href="https://cloud.siliconflow.cn/i/RukAXIj5">硅基流动(含AFF)</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F11%2F14%2F6735d3003f6f5.png&amp;size=m" alt="6735d3003f6f5.png"></p>
<h2 id="openwebui中使用">OpenWebUI中使用</h2>
<p>在OpenWebUI中需要使用函数和自定义提示词</p>
<h3 id="函数">函数</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F11%2F14%2F6735d38634a8b.png&amp;size=m" alt="6735d38634a8b.png"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F11%2F14%2F6735d42315902.png&amp;size=m" alt="6735d42315902.png"></p>
<pre><code class="language-python">import asyncio
import random
import re
from typing import Callable, Awaitable, Any, Optional

import aiohttp
from pydantic import BaseModel, Field


class AIOutput(BaseModel):
    success: bool
    prompt: str
    width: int
    height: int
    reason: Optional[str] = None
    seed: int = Field(default=-1)


class Filter:
    # 使用您提供的正则表达式，转换为 Python 格式
    JSON_REGEX = re.compile(r"\{(?:\\.|[^\\}])*}")

    class Valves(BaseModel):
        priority: int = Field(default=0, description="用于过滤操作的优先级别。")
        Siliconflow_Base_URL: str = Field(
            default="https://api.siliconflow.cn",
            description="Siliconflow API的基础URL。（例如：https://api.siliconflow.cn）",
        )
        Siliconflow_API_KEY: str = Field(
            default="",
            description="Siliconflow API的API密钥。",
        )
        max_retries: int = Field(
            default=3,
            description="HTTP请求的最大重试次数。",
        )
        num_inference_steps: int = Field(
            default=20,
            description="执行的推理步骤数。（1-100）",
        )
        model_name: str = Field(
            default="black-forest-labs/FLUX.1-schnell",
            description="用于生成图像的模型名称。",
        )

    def __init__(self):
        self.valves = self.Valves()

    @staticmethod
    def remove_markdown_images(content: str) -&gt; str:
        # 根据需要调整，确保保留JSON格式
        return re.sub(r"!\[.*?\]\([^)]*\)", "", content)

    async def inlet(
        self,
        body: dict,
        __event_emitter__: Callable[[Any], Awaitable[None]],
        __user__: Optional[dict] = None,
        __model__: Optional[dict] = None,
    ) -&gt; dict:
        await __event_emitter__(
            {
                "type": "status",
                "data": {
                    "description": "✨正在飞速生成提示词中，请耐心等待...",
                    "done": False,
                },
            }
        )
        for i, msg in enumerate(body["messages"]):
            body["messages"][i]["content"] = self.remove_markdown_images(msg["content"])
        return body

    async def text_to_image(
        self, prompt: str, image_size: str, seed: int, __user__: Optional[dict] = None
    ):
        url = f"{self.valves.Siliconflow_Base_URL}/v1/images/generations"
        payload = {
            "model": self.valves.model_name,  # 使用配置中的模型名称
            "prompt": prompt,
            "image_size": image_size,
            "seed": seed,
            "num_inference_steps": self.valves.num_inference_steps,  # 保持推理步数
        }

        headers = {
            "authorization": f"Bearer {random.choice([key for key in self.valves.Siliconflow_API_KEY.split(',') if key])}",
            "accept": "application/json",
            "content-type": "application/json",
        }

        async with aiohttp.ClientSession() as session:
            for attempt in range(self.valves.max_retries):
                try:
                    async with session.post(
                        url, json=payload, headers=headers
                    ) as response:
                        response.raise_for_status()
                        response_data = await response.json()
                        return response_data
                except Exception as e:
                    print(f"Attempt {attempt + 1} failed: {e}")
                    if attempt == self.valves.max_retries - 1:
                        return {"error": str(e)}

    async def generate_single_image(
        self, ai_output: AIOutput, __user__: Optional[dict] = None
    ):
        image_size = f"{ai_output.width}x{ai_output.height}"
        if ai_output.seed == -1:
            ai_output.seed = random.randint(0, 9999999999)
        seed = ai_output.seed

        result = await self.text_to_image(ai_output.prompt, image_size, seed, __user__)

        if isinstance(result, dict) and "error" in result:
            error_message = result["error"]
            raise Exception(f"Siliconflow API Error: {error_message}")

        return result

    async def outlet(
        self,
        body: dict,
        __event_emitter__: Callable[[Any], Awaitable[None]],
        __user__: Optional[dict] = None,
        __model__: Optional[dict] = None,
    ) -&gt; dict:
        if "messages" in body and body["messages"] and __user__ and "id" in __user__:
            await __event_emitter__(
                {
                    "type": "status",
                    "data": {
                        "description": "🚀正在火速生成图片中，请耐心等待...",
                        "done": False,
                    },
                }
            )

            messages = body["messages"]
            if messages:
                ai_output_content = messages[-1].get("content", "")
                match = self.JSON_REGEX.search(ai_output_content)
                if not match:
                    raise ValueError("未在消息内容中找到有效的AI输出JSON。")

                ai_output_json_str = match.group()

                try:
                    ai_output = AIOutput.parse_raw(ai_output_json_str)
                except Exception as e:
                    raise ValueError(f"解析AI输出JSON时出错: {e}")

                if ai_output.success:
                    response_data = await self.generate_single_image(
                        ai_output, __user__
                    )
                    if response_data and "images" in response_data:
                        images = response_data.get("images", [])
                        if images:
                            image_url = images[0].get("url", "")

                            # 更新content_lines并重新写入
                            content_lines = [
                                f"### 生成信息",
                                f"**提示词 (Prompt):** {ai_output.prompt}",
                                f"**尺寸 (Size):** {ai_output.width}x{ai_output.height}",
                                f"**种子 (Seed):** {ai_output.seed}",
                                f"**模型名称 (Model):** {self.valves.model_name}",
                                "\n### 生成的图片",
                                f"![预览图]({image_url})",
                                f"[🖼️图片下载链接]({image_url})",
                            ]
                            body["messages"][-1]["content"] = "\n\n".join(content_lines)

                            await __event_emitter__(
                                {
                                    "type": "status",
                                    "data": {
                                        "description": "🎉图片生成成功！",
                                        "done": True,
                                    },
                                }
                            )
                        else:
                            raise Exception(
                                "Siliconflow API Error: No images found in response."
                            )
                else:
                    raise Exception(f"AI Output Error: {ai_output.reason}")
        return body
</code></pre>
<h3 id="提示词">提示词</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F11%2F14%2F6735d4aaccb0e.png&amp;size=m" alt="6735d4aaccb0e.png"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F11%2F14%2F6735d4f2e2b93.png&amp;size=m" alt="6735d4f2e2b93.png"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F11%2F14%2F6735d536ce40f.png&amp;size=m" alt="6735d536ce40f.png"></p>
<pre><code class="language-text">你是一个基于Flux.1模型的提示词生成机器人。根据用户的需求，自动生成符合Flux.1格式的绘画提示词。虽然你可以参考提供的模板来学习提示词结构和规律，但你必须具备灵活性来应对各种不同需求。最终输出应仅为json格式，无需任何其他解释或信息。

### **提示词生成逻辑**：

1. **需求解析**：从用户的描述中提取关键信息，包括：
   - 角色：外貌、动作、表情等。
   - 场景：环境、光线、天气等。
   - 风格：艺术风格、情感氛围、配色等。
   - 其他元素：特定物品、背景或特效。

2. **提示词结构规律**：
   - **简洁、精确且具象**：提示词需要简单、清晰地描述核心对象，并包含足够细节以引导生成出符合需求的图像。
   - **灵活多样**：参考下列模板和已有示例，但需根据具体需求生成多样化的提示词，避免固定化或过于依赖模板。
   - **符合Flux.1风格的描述**：提示词必须遵循Flux.1的要求，尽量包含艺术风格、视觉效果、情感氛围的描述，使用与Flux.1模型生成相符的关键词和描述模式。

3. **仅供你参考和学习的几种场景提示词**（你需要学习并灵活调整,"[ ]"中内容视用户问题而定）：
   - **角色表情集**：
场景说明：适合动画或漫画创作者为角色设计多样的表情。这些提示词可以生成展示同一角色在不同情绪下的表情集，涵盖快乐、悲伤、愤怒等多种情感。

提示词：An anime [SUBJECT], animated expression reference sheet, character design, reference sheet, turnaround, lofi style, soft colors, gentle natural linework, key art, range of emotions, happy sad mad scared nervous embarrassed confused neutral, hand drawn, award winning anime, fully clothed

[SUBJECT] character, animation expression reference sheet with several good animation expressions featuring the same character in each one, showing different faces from the same person in a grid pattern: happy sad mad scared nervous embarrassed confused neutral, super minimalist cartoon style flat muted kawaii pastel color palette, soft dreamy backgrounds, cute round character designs, minimalist facial features, retro-futuristic elements, kawaii style, space themes, gentle line work, slightly muted tones, simple geometric shapes, subtle gradients, oversized clothing on characters, whimsical, soft puffy art, pastels, watercolor

   - **全角度角色视图**：
场景说明：当需要从现有角色设计中生成不同角度的全身图时，如正面、侧面和背面，适用于角色设计细化或动画建模。

提示词：A character sheet of [SUBJECT] in different poses and angles, including front view, side view, and back view

   - **80 年代复古风格**：
场景说明：适合希望创造 80 年代复古风格照片效果的艺术家或设计师。这些提示词可以生成带有怀旧感的模糊宝丽来风格照片。

提示词：blurry polaroid of [a simple description of the scene], 1980s.

   - **智能手机内部展示**：
场景说明：适合需要展示智能手机等产品设计的科技博客作者或产品设计师。这些提示词帮助生成展示手机外观和屏幕内容的图像。

提示词：a iphone product image showing the iphone standing and inside the screen the image is shown

   - **双重曝光效果**：
场景说明：适合摄影师或视觉艺术家通过双重曝光技术创造深度和情感表达的艺术作品。

提示词：[Abstract style waterfalls, wildlife] inside the silhouette of a [man]’s head that is a double exposure photograph . Non-representational, colors and shapes, expression of feelings, imaginative, highly detailed

   - **高质感电影海报**：
场景说明：适合需要为电影创建引人注目海报的电影宣传或平面设计师。

提示词：A digital illustration of a movie poster titled [‘Sad Sax: Fury Toad’], [Mad Max] parody poster, featuring [a saxophone-playing toad in a post-apocalyptic desert, with a customized car made of musical instruments], in the background, [a wasteland with other musical vehicle chases], movie title in [a gritty, bold font, dusty and intense color palette].

   - **镜面自拍效果**：
场景说明：适合想要捕捉日常生活瞬间的摄影师或社交媒体用户。

提示词：Phone photo: A woman stands in front of a mirror, capturing a selfie. The image quality is grainy, with a slight blur softening the details. The lighting is dim, casting shadows that obscure her features. [The room is cluttered, with clothes strewn across the bed and an unmade blanket. Her expression is casual, full of concentration], while the old iPhone struggles to focus, giving the photo an authentic, unpolished feel. The mirror shows smudges and fingerprints, adding to the raw, everyday atmosphere of the scene.

   - **像素艺术创作**：
场景说明：适合像素艺术爱好者或复古游戏开发者创造或复刻经典像素风格图像。

提示词：[Anything you want] pixel art style, pixels, pixel art

   - **以上部分场景仅供你学习，一定要学会灵活变通，以适应任何绘画需求**：

4. **Flux.1提示词要点总结**：
   - **简洁精准的主体描述**：明确图像中核心对象的身份或场景。
   - **风格和情感氛围的具体描述**：确保提示词包含艺术风格、光线、配色、以及图像的氛围等信息。
   - **动态与细节的补充**：提示词可包括场景中的动作、情绪、或光影效果等重要细节。
   - **其他更多规律请自己寻找**
---

**问答案例1**：
**用户输入**：一个80年代复古风格的照片。
**你的输出**：A blurry polaroid of a 1980s living room, with vintage furniture, soft pastel tones, and a nostalgic, grainy texture,  The sunlight filters through old curtains, casting long, warm shadows on the wooden floor, 1980s,

**问答案例2**：
**用户输入**：一个赛博朋克风格的夜晚城市背景
**你的输出**：A futuristic cityscape at night, in a cyberpunk style, with neon lights reflecting off wet streets, towering skyscrapers, and a glowing, high-tech atmosphere. Dark shadows contrast with vibrant neon signs, creating a dramatic, dystopian mood`


### 限制：

- tag内容用英语单词或短语来描述，并不局限于我给你的单词。注意只能包含关键词或词组。
- 注意不要输出句子，不要有任何解释。
- tag数量限制在40个以内，单词数量限制在60个以内。
- tag不要带引号("")。
- 使用英文半角","做分隔符。
- tag按重要性从高到低的顺序排列。
- 我给你的主题可能是用中文描述，你给出的提示词只用英文。

### 图片尺寸

- 你需要为每个生成的提示词提供一个合适的图片尺寸。
- 图片尺寸的宽度和高度都不能超过1024像素。
- 根据主题内容，选择一个合适的宽高比，如风景画可以选择较宽的比例，人像可以选择较高的比例。

# 请确保所有的返回结果都使用以下JSON格式，如果你无法理解主题，则将success设为false，并在reason中输出原因：

{"success":true,"prompt":"content","width":1024,"height":768,"reason":"","seed":-1}

注意：

1. 不允许使用Markdown代码块格式，不要有额外的说明或解释。
2. 所有返回内容必须直接符合上述JSON格式。
3. width和height表示建议的图片宽度和高度，需要根据主题选择合适的尺寸，但不超过1024*1024。
4.不允许生成任何与18+内容相关的提示词。包括但不限于色情、极度暴力、或其他不适合未成年人的内容。
5.seed为图片生成的种子值，是用来控制生成图像时的随机性和可重复性，如果用户需要在原先的图片上进行修改，须保证seed值不变，如果无需在原先图片上修改，需将seed设置为-1
6.必须保证输出的json为标准json格式，可直接被Json解析器解释

</code></pre>
<h2 id="效果">效果</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F11%2F14%2F6735d62b6feb5.png&amp;size=m" alt="6735d62b6feb5.png"></p>]]></description><guid isPermaLink="false">/archives/zai-openwebuizhong-shi-yong-fluxhui-hua-huo-ji-liu-dong.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 14 Nov 2024 10:52:16 GMT</pubDate></item><item><title><![CDATA[使用 DeepSeek API 配合 Continue 插件代替 Copilot]]></title><link>https://blog.ccrui.cn/archives/shi-yong-deepseek-api-pei-he-continue-cha-jian-dai-ti-copilot</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E4%BD%BF%E7%94%A8%20DeepSeek%20API%20%E9%85%8D%E5%90%88%20Continue%20%E6%8F%92%E4%BB%B6%E4%BB%A3%E6%9B%BF%20Copilot&amp;url=/archives/shi-yong-deepseek-api-pei-he-continue-cha-jian-dai-ti-copilot" width="1" height="1" alt="" style="opacity:0;">
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F08%2F21%2F66c602d3deb1e.png&amp;size=m" alt="66c602d3deb1e.png"></p>
<h2 id="前言">前言</h2>
<p>最近，<code>DeepSeek API</code> 进行了升级，现在支持 <code>FIM (Fill-In-the-Middle)</code> 补全接口。这让我想到可以尝试将 <code>DeepSeek API</code> 和 <code>Continue</code> 插件结合使用，从而替代 <code>Copilot</code> 来进行代码补全。在本文中，我将详细说明如何在 VSCode 中配置和使用这些工具。</p>
<h2 id="准备工作">准备工作</h2>
<ol>
 <li>
  <p><strong>安装 VSCode 插件：</strong> 首先，在 VSCode 中安装 <code>Continue</code> 插件。如果尚未安装，请在 VSCode 扩展市场中搜索并安装。</p></li>
 <li>
  <p><strong>获取 DeepSeek API 访问权限：</strong> 确保你已获得 DeepSeek API 的访问权限，并获取了 API 密钥。你可以在 <a href="https://platform.deepseek.com/">DeepSeek 官方网站</a> 上注册并获取相关信息。</p></li>
</ol>
<h2 id="配置-continue-插件">配置 Continue 插件</h2>
<ol>
 <li>
  <p><strong>初始设置</strong>：安装完成后，打开 VSCode 的左侧栏，点击 Continue 插件的图标。根据提示进行初始设置，其中包括选择补全模型和 API 提供商。</p></li>
 <li>
  <p><strong>生成配置文件</strong>：完成初始设置后，在 Continue 插件的界面中，点击右下角的“设置”按钮。此操作将弹出配置界面，其中包含默认生成的 <code>config.json</code> 配置文件。</p></li>
 <li>
  <p><strong>修改配置</strong>：根据你的需求，调整弹出窗口中的配置，确保以下设置正确无误：</p></li>
</ol>
<pre><code class="language-json">{
  "completionOptions": {
    "temperature": 0,
    "maxTokens": 4096
  },
  "models": [
    {
      "title": "DeepSeek",
      "provider": "openai",
      "systemMessage": "You are an expert software developer. You give helpful and concise responses.",
      "model": "deepseek-coder",
      "apiBase": "https://api.deepseek.com/beta",
      "apiKey": "your-deepseek-api-key-here",
      "contextLength": 8192
    }
  ],
  "tabAutocompleteOptions": {
    "maxPromptTokens": 4096
  },
  "tabAutocompleteModel": {
    "title": "DeepSeek-V2",
    "model": "deepseek-coder",
    "apiKey": "your-deepseek-api-key-here",
    "contextLength": 8192,
    "apiBase": "https://api.deepseek.com/beta",
    "completionOptions": {
      "maxTokens": 4096,
      "temperature": 0,
      "topP": 1,
      "presencePenalty": 0,
      "frequencyPenalty": 0
    },
    "provider": "openai"
  },
  "customCommands": [
    {
      "name": "测试",
      "prompt": "{{{ input }}}\n\n为所选代码编写一套全面的单元测试。它应该设置、运行检查正确性的测试，包括重要的边界情况，并进行清理。确保测试是完整且复杂的。仅以聊天输出的形式给出测试，不要编辑任何文件。",
      "description": "为高亮代码编写单元测试"
    }
  ],
  "reranker": {
    "name": "free-trial"
  }
}
</code></pre>
<p>请确保 <code>apiBase</code> 使用的是 <code>https://api.deepseek.com/beta</code>，并将 <code>your-deepseek-api-key-here</code> 替换为你的实际 DeepSeek API 密钥。</p>
<h2 id="使用指南">使用指南</h2>
<ol>
 <li>
  <p><strong>启动 Continue 插件</strong>：在 VSCode 中启动 Continue 插件。配置文件生成并保存后，Continue 将自动使用 DeepSeek API 提供的补全功能。</p></li>
 <li>
  <p><strong>代码补全</strong>：在代码编写过程中，Continue 将根据配置自动提供补全建议，利用 DeepSeek API 的强大功能来提高你的开发效率。</p></li>
 <li>
  <p><strong>自定义命令</strong>：通过 Continue 插件界面，可以调用自定义命令，例如为选中的代码生成单元测试。</p></li>
 <li>
  <p><strong>调试和优化</strong>：根据实际使用情况，调整 <code>config.json</code> 中的参数，以获得最佳的补全效果。</p></li>
</ol>
<h2 id="注意">注意</h2>
<blockquote>
 <p>修改完成配置文件后，请确保保存并重启 VSCode，以使配置生效。</p>
</blockquote>
<blockquote>
 <p>默认使用的 <code>embeddingsProvider</code> 模型为 <code>transformers.js</code> ，如果需要修改，需要在配置文件中加入</p>
 <pre><code class="language-json"> "embeddingsProvider": {
   "provider": "openai",
   "model": "text-embedding-3-small",
   "apiBase": "&lt;your custom OpenAI-compatible endpoint&gt;", // optional, defaults to OpenAI's API
   "apiKey": "&lt;OPENAI_API_KEY&gt;"
 },
</code></pre>
 <p>并确保 <code>apiBase</code> 和 <code>apiKey</code> 正确无误。</p>
</blockquote>]]></description><guid isPermaLink="false">/archives/shi-yong-deepseek-api-pei-he-continue-cha-jian-dai-ti-copilot</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 21 Aug 2024 15:27:07 GMT</pubDate></item><item><title><![CDATA[国产大模型价目表]]></title><link>https://blog.ccrui.cn/archives/guo-chan-da-mo-xing-jie-mu-biao.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%9B%BD%E4%BA%A7%E5%A4%A7%E6%A8%A1%E5%9E%8B%E4%BB%B7%E7%9B%AE%E8%A1%A8&amp;url=/archives/guo-chan-da-mo-xing-jie-mu-biao.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="国产大模型价目表">国产大模型价目表</h1>
<p>本文价格表统计至2024年7月5日，包含<code>DeepSeek</code> <code>百度文心千帆</code> <code>阿里通义千问</code> <code>字节跳动豆包</code> <code>智普AI</code> <code>腾讯混元大模型</code> <code>零一万物</code> <code>月之暗面</code> 家的主要模型的每1000tokens的价格，用作横向对比。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F07%2F05%2F668749f61ced4.png&amp;size=m" alt="668749f61ced4.png"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F07%2F05%2F66874a2a60289.png&amp;size=m" alt="66874a2a60289.png"></p>]]></description><guid isPermaLink="false">/archives/guo-chan-da-mo-xing-jie-mu-biao.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 5 Jul 2024 01:29:43 GMT</pubDate></item><item><title><![CDATA[豆包大模型转换为 OpenAI 接口]]></title><link>https://blog.ccrui.cn/archives/dou-bao-da-mo-xing-zhuan-huan-wei-openai-jie-kou.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E8%B1%86%E5%8C%85%E5%A4%A7%E6%A8%A1%E5%9E%8B%E8%BD%AC%E6%8D%A2%E4%B8%BA%20OpenAI%20%E6%8E%A5%E5%8F%A3&amp;url=/archives/dou-bao-da-mo-xing-zhuan-huan-wei-openai-jie-kou.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="豆包大模型转换为-openai-接口">豆包大模型转换为 OpenAI 接口</h1>
<h2 id="前言">前言</h2>
<p>在国内 AI 浪潮中，字节跳动旗下的豆包大模型以独特的策略吸引了广泛关注，特别是其极具竞争力的价格。新用户首次开通服务即可享受 50 万 token 的免费试用额度，以便亲身体验其强大功能。此外，豆包大模型在 5 月 15 日至 8 月 30 日期间，还推出了高达 5 亿 token 的免费活动。唯一的要求是，参与用户需同意提供其聊天数据，以便豆包大模型进行进一步的训练与优化。</p>
<h2 id="豆包大模型定价">豆包大模型定价</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F06%2F29%2F667f7af93ab66.png&amp;size=m" alt="豆包大模型定价"></p>
<h2 id="豆包大模型接入方法">豆包大模型接入方法</h2>
<h3 id="1-注册豆包大模型账号">1. 注册豆包大模型账号</h3>
<p>首先，注册一个豆包大模型账号。打开<a href="https://www.volcengine.com/">字节跳动火山引擎官网</a>，并进行注册。</p>
<h3 id="2-开通服务">2. 开通服务</h3>
<p>进入 <code>火山方舟</code> 控制台，点击 <code>开通管理</code>，查看当前可使用的全部模型与当前免费额度，点击模型右侧的开通服务，即可开通对应模型的服务。</p>
<h3 id="3-获取-5-亿-token可选">3. 获取 5 亿 token（可选）</h3>
<p>在 <code>火山方舟</code> 控制台 <code>开通管理界面</code> 上方，点击获取 5 亿 token 活动的链接，点击 <code>去参加</code>，即可参与活动。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F06%2F29%2F667f7c6907a33.png&amp;size=m" alt="获取5亿token活动"></p>
<h3 id="4-创建推理接入点">4. 创建推理接入点</h3>
<p>豆包大模型的接入方法与 OpenAI 的有所不同，需要先在 <code>火山方舟</code> 控制台 <code>模型推理</code> 页面创建一个推理接入点。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F06%2F29%2F667f7cc92e6e1.png&amp;size=m" alt="创建推理接入点"></p>
<p>推理接入点创建完成后，会生成一个 ID 作为模型名称进行使用。例如，我创建的推理接入点模型 ID 为 <code>ep-202406xxxxxxxxx</code>，在请求模型时，需要将其作为模型名称使用。</p>
<h3 id="5-获取-api-key">5. 获取 API Key</h3>
<p>在 <code>火山方舟</code> 控制台 <code>API Key 管理</code> 页面，点击 <code>创建API Key</code>，即可生成一个用于调用模型的 API Key。</p>
<h2 id="使用兼容层转换接口">使用兼容层转换接口</h2>
<p>豆包大模型的接口与 OpenAI 的接口有所不同，可以使用兼容层转换接口来实现兼容。推荐使用 <a href="https://github.com/songquanpeng/one-api">One Api</a> 进行转换。</p>
<h3 id="部署-oneapi">部署 OneApi</h3>
<p>OneApi 部署方法相当简单，使用 Docker 直接运行即可。</p>
<pre><code class="language-shell">docker run --name one-api -d --restart always -p 3000:3000 -e TZ=Asia/Shanghai -v ./data:/data justsong/one-api
</code></pre>
<p>OneApi 默认监听 3000 端口，可以通过 <code>-p</code> 参数指定端口，首次登录账号密码为 <code>root</code> <code>123456</code>。</p>
<h3 id="配置-oneapi">配置 OneApi</h3>
<ol>
 <li>
  <p>登录 OneApi 后，点击 <code>渠道</code>，选择 <code>添加新的渠道</code>，并选择 <code>字节跳动豆包</code> 模型。</p></li>
 <li>
  <p>由于豆包模型接入的特殊性，我们需要通过 <code>模型重定向</code> 的方式来方便调用模型。在 <code>模型重定向</code> 中定义一个 JSON，用于将模型 ID 转换为模型名称。</p>
  <pre><code class="language-json">{
"Doubao-pro-128k": "ep-2024xxxxxxxx",
"Doubao-pro-32k": "ep-2024xxxxxxxx",
"Doubao-lite-128k": "ep-2024xxxxxxxx",
"Doubao-lite-32k": "ep-2024xxxxxxxx"
}
</code></pre>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F06%2F29%2F667f7f103feec.png&amp;size=m" alt="模型重定向配置"></p></li>
 <li>
  <p>添加完成后，点击 <code>令牌</code>，创建一个新的令牌，用于调用模型。</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F06%2F29%2F667f7f4a01bb0.png&amp;size=m" alt="创建令牌"></p></li>
</ol>
<p>通过上述步骤，便可成功将豆包大模型转换为 OpenAI 接口，实现无缝兼容。</p>]]></description><guid isPermaLink="false">/archives/dou-bao-da-mo-xing-zhuan-huan-wei-openai-jie-kou.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 29 Jun 2024 03:33:00 GMT</pubDate></item><item><title><![CDATA[通过VPN将云服务器IP绑定到本地服务器或OpenWrt]]></title><link>https://blog.ccrui.cn/archives/tong-guo-vpnjiang-yun-fu-wu-qi-ipbang-ding-dao-ben-di-fu-wu-qi-huo-openwrt.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E9%80%9A%E8%BF%87VPN%E5%B0%86%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8IP%E7%BB%91%E5%AE%9A%E5%88%B0%E6%9C%AC%E5%9C%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%88%96OpenWrt&amp;url=/archives/tong-guo-vpnjiang-yun-fu-wu-qi-ipbang-ding-dao-ben-di-fu-wu-qi-huo-openwrt.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="通过vpn将云服务器ip绑定到本地服务器或openwrt">通过VPN将云服务器IP绑定到本地服务器或OpenWrt</h1>
<p>之前看到有 <a href="https://aqinco.com/">https://aqinco.com/</a> 这家云服务器有售卖<code>家庭宽带IP购买</code>的服务，宣称是可以给家庭宽带增加一条静态IP，出于好奇，我购买了一个月进行尝试。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F06%2F14%2F666c45f05f4a9.png&amp;size=m" alt="666c45f05f4a9"><br>
  在客服使用SSH连接将IP链接到我本地的Linux服务器后，我通过查询系统进程和网络接口的方式发现，其实所谓增加静态IP不过是使用<code>WireGuard</code>将公网IP绑定到设备上，于是我产生了一个
 <del>大胆</del>奇妙的想法，能不能将自己手边吃灰的云服务器IP绑定到本地，甚至绑定到<code>OpenWrt</code>上，经过一番摸索和与GPT的深入交流，成功将云服务器IP绑定到了本地服务器，这种绑定和<code>frp</code>有所不同，所有访问到云服务器IP的请求，都将转发到本地服务器，甚至包括<code>Ping</code>请求。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F06%2F14%2F666c47b4ad185.png&amp;size=m" alt="666c47b4ad185.png"><br>
  正如上图所示，我使用的是腾讯云北京的服务器，正常在北京节点对其ip进行ping命令，得到的延迟应该在5ms以内，但是现在ping的延迟增加了从腾讯云北京到我家里的时间。并且现在通过这台服务器的IP可以直接访问到我家里的设备。</p>
<p>下面是详细的部署流程。</p>
<h2 id="公网服务器部署wireguard">公网服务器部署WireGuard</h2>
<h3 id="安装wireguard">安装WireGuard</h3>
<pre><code class="language-bash">sudo apt update
sudo apt install wireguard
</code></pre>
<h3 id="生成秘钥对">生成秘钥对</h3>
<pre><code class="language-bash"># 生成公网服务器的密钥对
wg genkey | tee server_privatekey | wg pubkey &gt; server_publickey

# 生成无公网服务器的密钥对
wg genkey | tee client_privatekey | wg pubkey &gt; client_publickey
</code></pre>
<p>密钥对文件保存在当前命令行路径下的 <code>server_privatekey</code> <code>server_publickey</code> 文件和 <code>client_privatekey</code> <code>client_publickey</code>，其中<code>server_privatekey</code> <code>server_publickey</code>为公网服务器的私钥与公钥，<code>client_privatekey</code> <code>client_publickey</code>为无公网服务器的私钥与公钥，这两对秘钥需要在妥善保存后删除。</p>
<p>下文中将以以下代称称呼</p>
<table>
 <thead>
  <tr>
   <th>代称</th>
   <th>秘钥文件名称</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>&lt;公网服务器的私钥&gt;</td>
   <td>server_privatekey</td>
  </tr>
  <tr>
   <td>&lt;公网服务器的公钥&gt;</td>
   <td>server_publickey</td>
  </tr>
  <tr>
   <td>&lt;无公网服务器的私钥&gt;</td>
   <td>client_privatekey</td>
  </tr>
  <tr>
   <td>&lt;无公网服务器的公钥&gt;</td>
   <td>client_publickey</td>
  </tr>
 </tbody>
</table>
<h3 id="配置wireguard">配置WireGuard</h3>
<p>创建并编辑配置文件 <code>/etc/wireguard/wg0.conf</code></p>
<pre><code class="language-bash">sudo vi /etc/wireguard/wg0.conf
</code></pre>
<p>添加以下内容</p>
<pre><code class="language-ini">[Interface]
Address = 10.1.0.1/24
PrivateKey = &lt;公网服务器的私钥&gt;
ListenPort = 51820

[Peer]
PublicKey = &lt;无公网服务器的公钥&gt;
AllowedIPs = 10.1.0.2/32
</code></pre>
<p>将 <code>&lt;公网服务器的私钥&gt;</code> 替换为你生成的 <code>privatekey</code>，将 <code>&lt;无公网服务器的公钥&gt;</code> 替换为无公网服务器生成的 <code>publickey</code>。</p>
<h3 id="启动wireguard">启动WireGuard</h3>
<p>sudo wg-quick up wg0</p>
<h2 id="无公网服务器部署-wireguard">无公网服务器部署 WireGuard</h2>
<p>这里先以普通Ubuntu服务器为例，如果想在OpenWrt上部署，本节主要查看<code>配置WireGuard</code>小节即可。</p>
<h2 id="配置wireguard-1">配置WireGuard</h2>
<p>创建并编辑配置文件 <code>/etc/wireguard/wg0.conf</code></p>
<pre><code class="language-bash">sudo vi /etc/wireguard/wg0.conf
</code></pre>
<p>添加以下内容</p>
<pre><code class="language-ini">[Interface]
Address = 10.1.0.2/24
PrivateKey = &lt;无公网服务器的私钥&gt;

[Peer]
PublicKey = &lt;公网服务器的公钥&gt;
Endpoint = &lt;公网服务器的IP&gt;:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
</code></pre>
<p>或者填写</p>
<pre><code class="language-ini">[Interface]
Address = 10.1.0.2/24
PrivateKey = &lt;无公网服务器的私钥&gt;

[Peer]
PublicKey = &lt;公网服务器的公钥&gt;
Endpoint = &lt;公网服务器的IP&gt;:51820
AllowedIPs = 10.1.0.1/32
PersistentKeepalive = 25
</code></pre>
<h3 id="启动-wireguard">启动 WireGuard</h3>
<pre><code class="language-bash">sudo wg-quick up wg0
</code></pre>
<h2 id="配置端口转发">配置端口转发</h2>
<p>本节内所有操作均在公网服务器上执行，并建议彻底关闭云服务器上的网络防火墙。</p>
<h3 id="配置ip转发">配置IP转发</h3>
<p>在公网服务器上启用 IP 转发</p>
<pre><code class="language-bash">sudo sysctl -w net.ipv4.ip_forward=1
</code></pre>
<blockquote>
 <p>如果需要永久生效，需编辑 <code>/etc/sysctl.conf</code>并取消 <code>net.ipv4.ip_forward=1</code> 的注释或添加 <code>net.ipv4.ip_forward=1</code>。</p>
</blockquote>
<h3 id="配置防火墙规则">配置防火墙规则</h3>
<p>在公网服务器上使用 <code>iptables</code> 将流量转发到无公网服务器</p>
<pre><code class="language-bash">sudo iptables -t nat -I PREROUTING -p udp --dport 51820 -j ACCEPT
sudo iptables -t nat -A PREROUTING -d &lt;公网服务器的IP&gt; -j DNAT --to-destination 10.1.0.2
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
</code></pre>
<blockquote>
 <p>注意！！！ 这里&lt;云服务器的IP&gt;有很多大厂的服务器，使用<code>ip addr</code>命令查询到的网卡绑定IP与实际公网IP不同，这里一定要使用 <strong>网卡实际绑定的ip</strong> 而不是公网IP</p>
</blockquote>
<p>为了确保规则在重启后仍然有效，保存规则</p>
<pre><code class="language-bash">sudo apt install iptables-persistent
sudo netfilter-persistent save
</code></pre>
<h3 id="验证配置">验证配置</h3>
<ol>
 <li>
  <p>确认 WireGuard 隧道连接已建立</p>
  <pre><code class="language-bash">sudo wg show
</code></pre></li>
 <li>
  <p>通过公网 IP 测试连接，确保请求能够转发到无公网服务器。</p></li>
</ol>
<blockquote>
 <p>注意<br>
   确保公网服务器和无公网服务器的防火墙配置正确，允许必要的端口和协议通过。</p>
</blockquote>
<h2 id="openwrt部署wireguard">OpenWrt部署WireGuard</h2>
<ol>
 <li>
  <p>首先确保OpenWrt上安装以下插件</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F06%2F14%2F666c4f9395617.png&amp;size=m" alt="666c4f9395617.png"></p></li>
 <li>
  <p>插件安装完成后，必须重启路由器，否则无法再接口处查看到<code>WireGuard</code>接口。</p></li>
 <li>
  <p>网络-&gt; 接口-&gt; 添加新接口 输入名称<code>wg0</code>和选择<code>WireGuard VPN</code>协议<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F06%2F14%2F666c50037775f.png&amp;size=m" alt="666c50037775f.png"></p></li>
 <li>
  <p>编辑接口-&gt; 导入配置，粘贴<code>无公网服务器部署 WireGuard</code>一节中<code>配置WireGuard</code>中的配置文件即可。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F06%2F14%2F666c505382c8b.png&amp;size=m" alt="666c505382c8b.png"></p></li>
 <li>
  <p>将新建接口加入到 <code>wan</code> 防火墙区域</p></li>
 <li>
  <p>完成后即可把服务器IP当做OpenWrt的一个<code>wan</code>口接入使用，相当于给你的宽带绑定了一条公网IP</p></li>
</ol>
<blockquote>
 <p>如果遇到绑定OpenWrt后无效的情况，将AllowedIPs从0.0.0.0/0修改为公网服务器ip即可，例如：<br>
   10.1.0.1/32</p>
</blockquote>]]></description><guid isPermaLink="false">/archives/tong-guo-vpnjiang-yun-fu-wu-qi-ipbang-ding-dao-ben-di-fu-wu-qi-huo-openwrt.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 14 Jun 2024 14:18:00 GMT</pubDate></item><item><title><![CDATA[Linux 部署 Stable Diffusion WebUI]]></title><link>https://blog.ccrui.cn/archives/linux-bu-shu-stable-diffusion-webui.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Linux%20%E9%83%A8%E7%BD%B2%20Stable%20Diffusion%20WebUI&amp;url=/archives/linux-bu-shu-stable-diffusion-webui.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="linux-部署-stable-diffusion-webui">Linux 部署 Stable Diffusion WebUI</h1>
<h2 id="安装-cuda">安装 CUDA</h2>
<p><a href="https://developer.nvidia.com/cuda-downloads">https://developer.nvidia.com/cuda-downloads</a></p>
<h3 id="配置环境变量">配置环境变量</h3>
<pre><code class="language-bash">export PATH=/usr/local/cuda-12.3/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
</code></pre>
<h3 id="测试环境变量">测试环境变量</h3>
<pre><code class="language-bash">root@zgccrui:/usr/local# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Wed_Nov_22_10:17:15_PST_2023
Cuda compilation tools, release 12.3, V12.3.107
Build cuda_12.3.r12.3/compiler.33567101_0
</code></pre>
<h2 id="安装-anaconda">安装 Anaconda</h2>
<p><a href="https://www.anaconda.com/products/distribution#download-section">https://www.anaconda.com/products/distribution#download-section</a></p>
<pre><code class="language-bash">wget https://repo.anaconda.com/archive/Anaconda3-2023.09-0-Linux-x86_64.sh
bash Anaconda3-2023.09-0-Linux-x86_64.sh
</code></pre>
<h3 id="重新激活-shell">重新激活 shell</h3>
<pre><code class="language-bash">source ~/.bashrc
</code></pre>
<h3 id="验证-anaconda-安装">验证 Anaconda 安装</h3>
<pre><code class="language-bash">conda --version
</code></pre>
<h3 id="创建虚拟环境">创建虚拟环境</h3>
<pre><code class="language-bash">conda create -n sd-webui python=3.10.6
conda activate sd-webui
</code></pre>
<h2 id="pip-换源可选">pip 换源（可选）</h2>
<pre><code class="language-bash">pip config set global.index-url &lt;http://mirrors.aliyun.com/pypi/simple/&gt;
</code></pre>
<p>或者</p>
<pre><code class="language-bash">pip config set global.trusted-host mirrors.aliyun.com
</code></pre>
<h2 id="安装-stable-diffusion-webui">安装 Stable Diffusion WebUI</h2>
<h2 id="从-github-上下载源码">从 github 上下载源码</h2>
<pre><code class="language-bash">git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
</code></pre>
<h2 id="下载模型文件可选正常webuish会自动下载">下载模型文件（可选，正常<code>Webui.sh</code>会自动下载）</h2>
<p><a href="https://huggingface.co/stabilityai/stable-diffusion-2-1">https://huggingface.co/stabilityai/stable-diffusion-2-1</a></p>
<p>将下载好的模型文件放到 <code>stable-diffusion-webui/models/Stable-diffusion/ </code> 目录下</p>
<h2 id="加入-github-代理可选">加入 Github 代理（可选）</h2>
<p>修改<code>stable-diffusion-webui/modules/launch_utils.py</code>文件中全部 Github 链接，在前面加上<code>https://ghproxy.com/</code>，或加入自建代理。</p>
<h2 id="启动-webui">启动 WebUI</h2>
<pre><code class="language-bash">bash webui.sh
</code></pre>]]></description><guid isPermaLink="false">/archives/linux-bu-shu-stable-diffusion-webui.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 19 May 2024 11:00:39 GMT</pubDate></item><item><title><![CDATA[ADB 调试手机的三种方式]]></title><link>https://blog.ccrui.cn/archives/adb-diao-shi-shou-ji-de-san-zhong-fang-shi.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=ADB%20%E8%B0%83%E8%AF%95%E6%89%8B%E6%9C%BA%E7%9A%84%E4%B8%89%E7%A7%8D%E6%96%B9%E5%BC%8F&amp;url=/archives/adb-diao-shi-shou-ji-de-san-zhong-fang-shi.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="usb-调试">USB 调试</h1>
<ul>
 <li>手机开启开发者选项和 USB 调试模式（通常开启方式：在关于手机连续点击7次版本号）；</li>
 <li>USB 连接线和各种接口正常（个别三方数据线仅支持充电，不支持调试）；</li>
 <li>驱动状态正常（Linux 和 Mac 通常没有问题，Windows 可能需要安装）；</li>
 <li>使用 <code>adb devices -l</code> 命令查看。</li>
</ul>
<h2 id="wlan-调试android-10-及更低版本需要借助-usb">WLAN 调试（Android 10 及更低版本，需要借助 USB）</h2>
<p>Android 10以及更低的版本，必须通过 USB 连接后，才可实现同一 WLAN 下无线调试。</p>
<ul>
 <li>手机和电脑需连接在同一 WiFi 下；</li>
 <li>手机开启开发者选项和 USB 调试模式，并通过 USB 连接电脑（即<code>adb devices -l</code>可以查看到手机）；</li>
 <li>设置手机的监听 <code>adb tcpip 5555</code>;</li>
 <li>拔掉 USB 线，找到手机的 IP 地址;</li>
 <li>通过 IP 连接到手机 <code>adb connect ip</code>（端口默认：5555）;</li>
 <li>使用 <code>adb devices -l</code> 命令查看。</li>
</ul>
<h3 id="断开与重连">断开与重连</h3>
<pre><code>
# 断开连接

$ adb disconnect

# 重连

$ adb connect

# 如果统一 WLAN 下，adb connect 失败后，可重置 adb，再次连接

$ adb kill-server
$ adb connect

</code></pre>
<h2 id="wi-fi-调试android-11-及更高版本无需借助-usb">Wi-Fi 调试（Android 11 及更高版本，无需借助 USB）</h2>
<p>从 Android 11 开始支持 ADB 以无线方式连接手机调试，可以彻底摆脱 USB 线。</p>
<ul>
 <li>手机和电脑需连接在同一 WiFi 下；</li>
 <li>保证 SDK 为最新版本（<code>adb --version ≥ 30.0.0</code>）；</li>
 <li>手机启用开发者选项和无线调试模式（会提示确认）；</li>
 <li>允许无线调试后，选择使用配对码配对。记下显示的配对码、IP 地址和端口号；</li>
 <li>运行 <code>adb pair ip:port</code>，使用第 4 步中的 IP 地址和端口号；</li>
 <li>根据提示，输入第 3 步中的配对码，系统会显示一条消息，表明您的设备已成功配对；</li>
 <li>（仅适用于 Linux 或 Windows）运行 <code>adb connect ip:port</code>。</li>
</ul>]]></description><guid isPermaLink="false">/archives/adb-diao-shi-shou-ji-de-san-zhong-fang-shi.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 5 Apr 2024 16:30:05 GMT</pubDate></item><item><title><![CDATA[CloudFlare WARP一键部署脚本]]></title><link>https://blog.ccrui.cn/archives/cloudflare-warpyi-jian-bu-shu-jiao-ben.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=CloudFlare%20WARP%E4%B8%80%E9%94%AE%E9%83%A8%E7%BD%B2%E8%84%9A%E6%9C%AC&amp;url=/archives/cloudflare-warpyi-jian-bu-shu-jiao-ben.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="cloudflare-warp一键部署脚本">CloudFlare WARP一键部署脚本</h1>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F04%2F04%2F660e56727961f.png&amp;size=m" alt="660e56727961f.png"></p>
<pre><code class="language-bash">wget -N https://gitlab.com/fscarmen/warp/-/raw/main/menu.sh &amp;&amp; bash menu.sh
</code></pre>]]></description><guid isPermaLink="false">/archives/cloudflare-warpyi-jian-bu-shu-jiao-ben.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 4 Apr 2024 07:44:02 GMT</pubDate></item><item><title><![CDATA[Outline docker-compose 部署]]></title><link>https://blog.ccrui.cn/archives/1709260047919.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Outline%20docker-compose%20%E9%83%A8%E7%BD%B2&amp;url=/archives/1709260047919.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="outline-docker-compose-部署">Outline docker-compose 部署</h1>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2024%2F03%2F01%2F1709254373478.png&amp;size=m" alt="1709254373478.png"></p>
<h2 id="前言">前言</h2>
<p>前段时间想要搭建一个自己的 outline 服务用作wiki使用，但是在搜索引擎上搜索了一圈，发现现有的教程就那么几篇，并且没有一个是完整的。</p>
<p>研究了一段时间，并且查看了官方的文档，终于搞定了 outline 的部署。</p>
<h2 id="准备工作">准备工作</h2>
<ul>
 <li>一台服务器</li>
 <li>docker</li>
 <li>docker-compose</li>
 <li>一个域名</li>
 <li>一个 SSL 证书</li>
</ul>
<h2 id="包含服务">包含服务</h2>
<ul>
 <li>outline - outline 项目本体</li>
 <li>redis - 缓存数据库</li>
 <li>postgres - 数据库</li>
 <li>minio - 用于构建兼容 S3 的对象存储服务</li>
 <li>sso-server - 单点登录服务</li>
</ul>
<h2 id="部署">部署</h2>
<p>我将部署分为了两个部分，第一部分为 minio 部署，用于存储 outline 的数据，第二部分为其他依赖项目部署。</p>
<p>因为 minio 是一个通用的对象存储服务，可能有其他的项目也会用到，所以我将 minio 部署单独拿出来。</p>
<p>部署过程中，我将会使用到 docker-compose，所以需要提前安装好 docker 和 docker-compose。</p>
<p>并且需要在 docker-compose.yml 文件所在的目录下创建.env 文件，用于存放一些敏感信息。</p>
<h3 id="minio-部署">minio 部署</h3>
<h4 id="docker-composeyml">docker-compose.yml</h4>
<pre><code class="language-yaml">version: "3"
services:
  minio:
    image: ${DOCKER_MINIO_IMAGE_NAME}
    env_file: ./.env # 指定环境变量文件
    container_name: minio
    ports:
      - 9502:9000
      - 9503:9001
    restart: always
    command: server /data --console-address :9000 --address :9001
    environment:
      MINIO_ROOT_USER: ${MINIO_ROOT_USER}
      MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
    logging:
      options:
        max-size: "5M"
        max-file: "10"
      driver: json-file
    volumes:
      - ./minio_data:/data
    labels:
      createdBy: "Apps"
</code></pre>
<h4 id="env">.env</h4>
<pre><code class="language-bash">DOCKER_MINIO_IMAGE_NAME=minio/minio:RELEASE.2024-01-05T22-17-24Z
DOCKER_MINIO_ROOT_USER=admin
DOCKER_MINIO_ROOT_PASSWORD=admin
</code></pre>
<h4 id="后续操作">后续操作</h4>
<p>使用 Nginx 反向代理 minio 服务，其中 9502 端口为 minio 服务的 http 端口，9503 端口为 minio 服务的 API 端口。</p>
<p>示例:<br><code>localhost:9502</code> -&gt; <code>https://minio.example.com</code><br><code>localhost:9503</code> -&gt; <code>https://api-minio.example.com</code></p>
<p>部署完成后，请访问<code>https://minio.example.com</code>，使用设定的用户名和密码登录。<br>
  登录后，在设置中将<code>Region</code>设置为<code>cn-1</code>，并且在<code>Bucket</code>中增加一个 bucket，命名为<code>outline</code>用于存储 outline 的数据，访问权限设置为<code>私有</code>。</p>
<h4 id="可选操作">可选操作</h4>
<p>在<code>Bucket</code>-&gt;<code>outline</code>-&gt;<code>Access</code>-&gt;<code>User</code>中增加一个用户，用于 outline 服务访问 minio 服务。</p>
<h3 id="outline-部署">outline 部署</h3>
<h4 id="docker-composeyml-1">docker-compose.yml</h4>
<pre><code class="language-yaml">version: "3.8"
services:
  outline:
    image: ${DOCKER_OUTLINE_IMAGE_NAME}
    env_file: ./.env
    ports:
      - "9303:3000"
    container_name: outline
    restart: always
    networks:
      - outline
    extra_hosts:
      - "${DOCKER_OUTLINE_HOSTNAME}:0.0.0.0"
    depends_on:
      - postgres
      - redis
      - sso-server

  redis:
    image: ${DOCKER_REDIS_IMAGE_NAME}
    env_file: ./.env
    volumes:
      - ./redis/redis.conf:/redis.conf # 配置文件持久化
    container_name: ${DOCKER_REDIS_HOST}
    restart: always
    networks:
      - outline
    command: ["redis-server", "/redis.conf"] # 启动命令

  postgres:
    image: ${DOCKER_POSTGRES_IMAGE_NAME}
    env_file: ./.env
    environment:
      POSTGRES_DB: ${DOCKER_POSTGRES_DB}
      POSTGRES_USER: ${DOCKER_POSTGRES_USER}
      POSTGRES_PASSWORD: ${DOCKER_POSTGRES_PASSWORD}
    volumes:
      - ./database-data:/var/lib/postgresql/data # 数据持久化
    container_name: ${DOCKER_POSTGRES_HOST}
    restart: always
    networks:
      - outline

  sso-server:
    image: ${DOCKER_SSO_IMAGE_NAME}
    env_file: ./.env
    ports:
      - "9304:80"
    environment:
      CLIENT_NAME: ${DOCKER_SSO_CLIENT_NAME}
      CLIENT_ID: ${DOCKER_SSO_CLIENT_ID}
      CLIENT_SECRET: ${DOCKER_SSO_CLIENT_SECRET}
      USER_PASS: ${DOCKER_SSO_USER_PASS}
      LICENSE: ${DOCKER_SSO_LICENSE}
      PORT: 80
    container_name: ${DOCKER_SSO_HOST}
    restart: always
    networks:
      - outline

networks:
  outline:
</code></pre>
<h4 id="env-1">.env</h4>
<p>请根据实际情况修改以下配置</p>
<blockquote>
 <p>注意！下面配置请逐行详细阅读，并根据实际情况修改</p>
</blockquote>
<pre><code class="language-bash"># 镜像设置
DOCKER_OUTLINE_IMAGE_NAME=docker.getoutline.com/outlinewiki/outline:latest
DOCKER_POSTGRES_IMAGE_NAME=postgres
DOCKER_REDIS_IMAGE_NAME=redis
DOCKER_SSO_IMAGE_NAME=soulteary/sso-server:1.1.5

# 容器名称
DOCKER_REDIS_HOST=outline_redis
DOCKER_POSTGRES_HOST=outline_postgres
DOCKER_SSO_HOST=outline_sso-server

# postgres设置
DOCKER_POSTGRES_USER=outline
DOCKER_POSTGRES_PASSWORD=outline
DOCKER_POSTGRES_DB=outline

# sso-server设置
DOCKER_SSO_CLIENT_NAME=My SSO Service # 用于显示在登录页面
DOCKER_SSO_CLIENT_ID=ca63edca-6773-4f55-8a7f-bf7b45a8b493 # https://www.uuidgenerator.net/ 随机生成
DOCKER_SSO_CLIENT_SECRET=85c11838-7ac9-416c-9362-669c1c488238 # https://www.uuidgenerator.net/ 随机生成
DOCKER_SSO_USER_PASS=S4q6WhThqH5Y8Hh # SSO登录密码
SSO_HOSTNAME=auth.example.com # sso-server域名（需要自己使用Nginx反向代理）
# 默认用户账号为 `username`，如果你希望使用自己的用户名进行登陆，则需要修改DOCKER_SSO_LICENSE的值
# DOCKER_SSO_LICENSE的值可使用 https://readers-lic-gift.suyang.wiki/ 生成
# DOCKER_SSO_LICENSE=

# outline设置
DOCKER_OUTLINE_HOSTNAME=docs.example.com # outline域名（需要自己使用Nginx反向代理）

# –––––––––––––––– outline必需 –––––––––––––––-

NODE_ENV=production

# 生成一个十六进制编码的32字节随机密钥。你应该在终端使用 `openssl rand -hex 32`
# 来生成一个随机值。
SECRET_KEY=d8e45ea2e5d298d976464888dea86c92b72dfa73a48cb8903454205c02c732b3

# 生成一个唯一的随机密钥。格式不重要，但你仍然可以使用
# `openssl rand -hex 32` 在你的终端来产生这个。
UTILS_SECRET=cf561a25ab8bd24c58e6d74edd726f60de11fd5c3fb88289c725a48ab3b7b759

# 对于生产环境，请将这些指向你的数据库，在开发中默认
# 应该是开箱即用的。
DATABASE_URL=postgres://${DOCKER_POSTGRES_USER}:${DOCKER_POSTGRES_PASSWORD}@${DOCKER_POSTGRES_HOST}:5432/${DOCKER_POSTGRES_DB}
DATABASE_CONNECTION_POOL_MIN=
DATABASE_CONNECTION_POOL_MAX=
# 取消注释此项以禁用连接到Postgres的SSL
PGSSLMODE=disable

# 对于redis，你可以指定一个与ioredis兼容的url，像这样
REDIS_URL=redis://${DOCKER_REDIS_HOST}:6379
# 或者，如果你想提供额外的连接选项，
# 使用一个base64编码的JSON连接选项对象。参考ioredis文档
# 了解可用选项的列表。
# 示例：使用Redis Sentinel来实现高可用性
# {"sentinels":[{"host":"sentinel-0","port":26379},{"host":"sentinel-1","port":26379}],"name":"mymaster"}
# REDIS_URL=ioredis://eyJzZW50aW5lbHMiOlt7Imhvc3QiOiJzZW50aW5lbC0wIiwicG9ydCI6MjYzNzl9LHsiaG9zdCI6InNlbnRpbmVsLTEiLCJwb3J0IjoyNjM3OX1dLCJuYW1lIjoibXltYXN0ZXIifQ==

# URL应该指向完全合格的、公开可访问的URL。如果使用代理，
# URL中的端口和PORT可能不同。
URL=https://${DOCKER_OUTLINE_HOSTNAME}
PORT=3000

# 查看在运行一个独立的协作
# 服务器的[文档](docs/SERVICES.md)，在正常操作中不需要设置这个。
# COLLABORATION_URL=

# 为了支持上传头像和文档附件的图片，必须提供
# 一个兼容s3的存储。推荐使用AWS S3来实现冗余
# 但如果你想保持所有文件存储在本地，可以使用
# 例如minio (https://github.com/minio/minio) 的替代方案。

# 设置S3的更详细指南可以在这里找到：
# =&gt; https://wiki.generaloutline.com/share/125de1cc-9ff6-424b-8415-0d58c809a40f
# 这里使用在minio部署时使用的用户名和密码，或者使用在上一节中可选操作中创建的用户
AWS_ACCESS_KEY_ID=admin
AWS_SECRET_ACCESS_KEY=admin
AWS_REGION=cn-1
# AWS_S3_ACCELERATE_URL=
AWS_S3_UPLOAD_BUCKET_URL=https://api-minio.example.com
AWS_S3_UPLOAD_BUCKET_NAME=outline
AWS_S3_FORCE_PATH_STYLE=true
AWS_S3_ACL=private

# 指定要使用的存储系统。可能的值是"s3"或"local"之一。
# 对于"local"，头像图片和文档附件将被保存在本地磁盘上。
FILE_STORAGE=s3

# 如果上面为FILE_STORAGE配置了"local"，则这设置了所有附件/图片的父目录
# 确保该进程有权限创建
# 这个路径，并且也有权限向其写入文件。
FILE_STORAGE_LOCAL_ROOT_DIR=/var/lib/outline/data

# 上传附件允许的最大大小。
FILE_STORAGE_UPLOAD_MAX_SIZE=262144000

# 覆盖文档导入的最大大小，通常这应该比文档附件的最大大小要低。
# FILE_STORAGE_IMPORT_MAX_SIZE=

# 覆盖工作区导入的最大大小，这些可能特别大
# 并且文件是临时的，会在一段时间后自动删除。
# FILE_STORAGE_WORKSPACE_IMPORT_MAX_SIZE=

# –––––––––––––– 认证 ––––––––––––––

# 第三方登录凭证，至少需要配置Google、Slack、
# 或Microsoft中的一个才能进行工作安装，否则你将没有登录
# 选项。

# 要配置Slack认证，你需要在
# =&gt; https://api.slack.com/apps
# 创建一个应用程序
#
# 在配置Client ID时，添加一个重定向URL到"OAuth &amp; Permissions"：
# https://&lt;URL&gt;/auth/slack.callback
# SLACK_CLIENT_ID=从slack获取一个密钥
# SLACK_CLIENT_SECRET=获取上面密钥的密钥

# 要配置Google认证，你需要在
# =&gt; https://console.cloud.google.com/apis/credentials
# 创建一个OAuth客户端ID
#
# 在配置客户端ID时，添加一个已授权的重定向URI：
# https://&lt;URL&gt;/auth/google.callback
# GOOGLE_CLIENT_ID=
# GOOGLE_CLIENT_SECRET=

# 要配置Microsoft/Azure认证，你需要创建一个OAuth客户端。见
# 指南了解如何设置你的Azure应用：
# =&gt; https://wiki.generaloutline.com/share/dfa77e56-d4d2-4b51-8ff8-84ea6608faa4
# AZURE_CLIENT_ID=
# AZURE_CLIENT_SECRET=
# AZURE_RESOURCE_APP_ID=

# 要配置通用OIDC认证，你需要某种身份提供者。
# 见你使用的IdP的文档来获取以下信息：
# 重定向URI是 https://&lt;URL&gt;/auth/oidc.callback
OIDC_CLIENT_ID=${DOCKER_SSO_CLIENT_ID}
OIDC_CLIENT_SECRET=${DOCKER_SSO_CLIENT_SECRET}
OIDC_AUTH_URI=https://${SSO_HOSTNAME}/dialog/authorize
OIDC_TOKEN_URI=https://${SSO_HOSTNAME}/oauth/token
OIDC_USERINFO_URI=https://${SSO_HOSTNAME}/api/outline/oidc
OIDC_LOGOUT_URI=https://${SSO_HOSTNAME}/logout

# 指定从哪些声明中派生用户信息
# 支持JWT负载中任何有效的JSON路径
OIDC_USERNAME_CLAIM=preferred_username

# OIDC认证的显示名称
OIDC_DISPLAY_NAME=My SSO Service

# 空格分隔的认证范围。
OIDC_SCOPES=openid profile email


# –––––––––––––––– 可选 ––––––––––––––––

# 为HTTPS终止提供Base64编码的私钥和证书。仅当你不使用外部反向代理时才需要此项。见文档：
# https://wiki.generaloutline.com/share/1c922644-40d8-41fe-98f9-df2b67239d45
# SSL_KEY=
# SSL_CERT=

# 如果使用Cloudfront/Cloudflare分发或类似的服务，可以在下面设置。
# 这将导致javascript、样式表和图像的路径被更新为
# 在CDN_URL中定义的主机名。在CDN配置中，原始服务器
# 应设置为与URL相同。
# CDN_URL=

# 在生产环境中自动重定向到https。默认值为true，但如果你能确保
# SSL在外部负载均衡器处终止，可以设置为false。
FORCE_HTTPS=false

# 让安装通过发送匿名统计数据到
# 维护者来检查更新
ENABLE_UPDATES=false

# 应该启动多少个进程。作为一个合理的规则，将你服务器
# 可用内存除以512来大致估算
WEB_CONCURRENCY=1

# 如果你的反向代理已经记录了传入的http
# 请求，而这变得重复，你可以删除这一行
# DEBUG=http

# 配置服务器日志的最低严重性级别。应该是
# error, warn, info, http, verbose, debug 和 silly 之一
LOG_LEVEL=info

# 为了完整的Slack集成，包括搜索和发布到频道，还需要
# 以下配置，更多细节
# =&gt; https://wiki.generaloutline.com/share/be25efd1-b3ef-4450-b8e5-c4a4fc11e02a
#
# SLACK_VERIFICATION_TOKEN=你的令牌
# SLACK_APP_ID=A0XXXXXXX
# SLACK_MESSAGE_ACTIONS=true

# 可选地启用Sentry (sentry.io) 来跟踪错误和性能，
# 并可选地在UI中添加一个Sentry代理隧道以绕过广告拦截器：
# https://docs.sentry.io/platforms/javascript/troubleshooting/#using-the-tunnel-option)
# SENTRY_DSN=
# SENTRY_TUNNEL=

# 为了支持发送出站的事务性电子邮件，如"文档已更新"或
# "你被邀请了"，你需要提供SMTP服务器的认证
# SMTP_HOST=smtp.office365.com
# SMTP_PORT=587
# SMTP_USERNAME=
# SMTP_PASSWORD=
# SMTP_FROM_EMAIL=
# SMTP_REPLY_EMAIL=
# SMTP_TLS_CIPHERS=
# SMTP_SECURE=false

# 默认界面语言。见translate.getoutline.com查看
# 可用的语言代码及其大致翻译的百分比。
DEFAULT_LANGUAGE=zh_CN

# 可选地启用应用程序Web服务器的速率限制器
RATE_LIMITER_ENABLED=true

# 为速率限制器配置默认的限流参数
RATE_LIMITER_REQUESTS=1000
RATE_LIMITER_DURATION_WINDOW=60

# Iframely API配置
# IFRAMELY_URL=
# IFRAMELY_API_KEY=

</code></pre>
<h4 id="后续操作-1">后续操作</h4>
<p>使用 Nginx 反向代理 outline 服务，其中 9303 端口为 outline 服务的 http 端口。</p>
<p>示例:<br><code>localhost:9303</code> -&gt; <code>https://docs.example.com</code></p>
<p>使用 Nginx 反向代理 sso-server 服务，其中 9304 端口为 sso-server 服务的 http 端口。</p>
<p>示例:<br><code>localhost:9304</code> -&gt; <code>https://auth.example.com</code></p>
<p>浏览器访问<code>https://auth.example.com/login</code>，使用设定的用户名和密码登录（默认用户名为<code>username</code>）。<br>
  登录完成后，需绑定两步验证器，绑定完成后，即可使用<code>https://docs.example.com</code>访问 outline 服务。</p>]]></description><guid isPermaLink="false">/archives/1709260047919.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 1 Mar 2024 02:29:59 GMT</pubDate></item><item><title><![CDATA[.NET 6 常用依赖注入]]></title><link>https://blog.ccrui.cn/archives/1705777048174.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=.NET%206%20%E5%B8%B8%E7%94%A8%E4%BE%9D%E8%B5%96%E6%B3%A8%E5%85%A5&amp;url=/archives/1705777048174.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="常用注册">常用注册</h2>
<p>在.NET Core和.NET 6中，服务注册是通过依赖注入（DI）容器实现的。这些服务可以以不同的生命周期进行注册，主要有以下几种方法：</p>
<ol>
 <li>
  <p><strong>AddSingleton</strong>:</p>
  <ul>
   <li>注册一个单例服务，该服务在第一次请求时创建，并在应用程序的整个生命周期内持续存在。同一个实例会在所有请求之间共享。</li>
   <li>示例用途：配置服务、数据库连接池、日志记录。</li>
  </ul></li>
 <li>
  <p><strong>AddScoped</strong>:</p>
  <ul>
   <li>注册一个作用域服务，每个请求创建一个新的服务实例。对于每个请求，使用的都是相同的实例，但不同请求将使用不同的实例。</li>
   <li>示例用途：数据访问操作、每个请求的用户信息。</li>
  </ul></li>
 <li>
  <p><strong>AddTransient</strong>:</p>
  <ul>
   <li>注册一个短暂服务，每次请求服务时都会创建一个新的实例。这意味着每次注入或者从容器中获取服务时，都会得到一个新的实例。</li>
   <li>示例用途：轻量级服务，如数据映射服务。</li>
  </ul></li>
 <li>
  <p><strong>AddHostedService</strong>:</p>
  <ul>
   <li>注册一个托管服务，实现了 <code>IHostedService</code> 接口的服务。这些服务在应用程序启动时自动开始，并在应用程序关闭时停止。</li>
   <li>示例用途：后台任务、定时任务。</li>
  </ul></li>
 <li>
  <p><strong>AddSingleton&lt;TService, TImplementation&gt;</strong>:</p>
  <ul>
   <li>类似于 <code>AddSingleton</code>，但允许你指定服务的接口和实现类，使得依赖注入在解析服务时可以通过接口来实例化指定的类。</li>
  </ul></li>
 <li>
  <p><strong>AddScoped&lt;TService, TImplementation&gt;</strong>:</p>
  <ul>
   <li>类似于 <code>AddScoped</code>，也是为每个请求周期提供服务实例，但允许指定服务接口和实现。</li>
  </ul></li>
 <li>
  <p><strong>AddTransient&lt;TService, TImplementation&gt;</strong>:</p>
  <ul>
   <li>类似于 <code>AddTransient</code>，每次请求都创建新实例，允许指定服务接口和实现。</li>
  </ul></li>
 <li>
  <p><strong>AddOptions</strong>:</p>
  <ul>
   <li>用于注册选项模式服务，这允许使用 <code>IOptions&lt;T&gt;</code> 接口来获取配置选项。</li>
  </ul></li>
 <li>
  <p><strong>AddMemoryCache</strong>:</p>
  <ul>
   <li>注册内存缓存服务。</li>
  </ul></li>
 <li>
  <p><strong>AddDbContext</strong>:</p>
  <ul>
   <li>用于注册Entity Framework Core的数据库上下文。</li>
  </ul></li>
</ol>
<h2 id="其他注册">其他注册</h2>
<p>除了最常用的如 <code>AddSingleton</code>, <code>AddScoped</code>, 和 <code>AddTransient</code> 之外，还有一些其他的服务注册方法，包括一些不那么常用但在特定情况下非常有用的方法。以下是一份更全面的列表：</p>
<ol>
 <li>
  <p><strong>AddSingleton</strong> / <strong>AddSingleton</strong> / <strong>AddSingleton&lt;TService, TImplementation&gt;</strong> / <strong>AddSingleton&lt;TService, TImplementation&gt;(Func&lt;IServiceProvider, TImplementation&gt;)</strong>:</p>
  <ul>
   <li>用于注册一个单例服务。</li>
  </ul></li>
 <li>
  <p><strong>AddScoped</strong> / <strong>AddScoped</strong> / <strong>AddScoped&lt;TService, TImplementation&gt;</strong> / <strong>AddScoped&lt;TService, TImplementation&gt;(Func&lt;IServiceProvider, TImplementation&gt;)</strong>:</p>
  <ul>
   <li>用于注册一个作用域服务。</li>
  </ul></li>
 <li>
  <p><strong>AddTransient</strong> / <strong>AddTransient</strong> / <strong>AddTransient&lt;TService, TImplementation&gt;</strong> / <strong>AddTransient&lt;TService, TImplementation&gt;(Func&lt;IServiceProvider, TImplementation&gt;)</strong>:</p>
  <ul>
   <li>用于注册一个短暂服务。</li>
  </ul></li>
 <li>
  <p><strong>AddHostedService</strong> / <strong>AddHostedService(Func&lt;IServiceProvider, THostedService&gt;)</strong>:</p>
  <ul>
   <li>用于注册托管服务。</li>
  </ul></li>
 <li>
  <p><strong>AddOptions</strong>:</p>
  <ul>
   <li>用于注册选项模式服务。</li>
  </ul></li>
 <li>
  <p><strong>AddMemoryCache</strong>:</p>
  <ul>
   <li>用于注册内存缓存服务。</li>
  </ul></li>
 <li>
  <p><strong>AddDbContext</strong> / <strong>AddDbContext</strong> / <strong>AddDbContext(Action)</strong> / <strong>AddDbContext(ServiceLifetime)</strong>:</p>
  <ul>
   <li>用于注册Entity Framework Core的数据库上下文。</li>
  </ul></li>
 <li>
  <p><strong>AddHttpClient</strong>:</p>
  <ul>
   <li>用于注册 <code>HttpClient</code> 服务，并允许配置。</li>
  </ul></li>
 <li>
  <p><strong>AddDefaultIdentity</strong> / <strong>AddIdentity</strong>:</p>
  <ul>
   <li>用于注册身份认证服务。</li>
  </ul></li>
 <li>
  <p><strong>AddCors</strong>:</p>
  <ul>
   <li>用于注册和配置跨源资源共享（CORS）策略。</li>
  </ul></li>
 <li>
  <p><strong>AddSignalR</strong>:</p>
  <ul>
   <li>用于注册SignalR服务。</li>
  </ul></li>
 <li>
  <p><strong>AddControllers</strong> / <strong>AddControllersWithViews</strong> / <strong>AddRazorPages</strong>:</p>
  <ul>
   <li>用于注册MVC、Razor页面或API控制器。</li>
  </ul></li>
 <li>
  <p><strong>AddLogging</strong>:</p>
  <ul>
   <li>用于注册日志服务。</li>
  </ul></li>
 <li>
  <p><strong>AddLocalization</strong> / <strong>AddLocalization(options =&gt; options.ResourcesPath = "Resources")</strong>:</p>
  <ul>
   <li>用于注册本地化服务。</li>
  </ul></li>
 <li>
  <p><strong>AddHealthChecks</strong>:</p>
  <ul>
   <li>用于注册健康检查服务。</li>
  </ul></li>
 <li>
  <p><strong>AddApiVersioning</strong>:</p>
  <ul>
   <li>用于注册API版本控制服务。</li>
  </ul></li>
 <li>
  <p><strong>AddAuthentication</strong> / <strong>AddAuthorization</strong>:</p>
  <ul>
   <li>用于注册认证和授权服务。</li>
  </ul></li>
</ol>
<p>这些方法涵盖了从基本的服务生命周期管理到更复杂的功能如身份验证、本地化、日志记录和健康检查等。</p>]]></description><guid isPermaLink="false">/archives/1705777048174.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 20 Jan 2024 19:00:08 GMT</pubDate></item><item><title><![CDATA[.Net 自签发SSL证书]]></title><link>https://blog.ccrui.cn/archives/.net-zi-qian-fa-sslzheng-shu.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=.Net%20%E8%87%AA%E7%AD%BE%E5%8F%91SSL%E8%AF%81%E4%B9%A6&amp;url=/archives/.net-zi-qian-fa-sslzheng-shu.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="net-自签发ssl证书">.Net 自签发SSL证书</h2>
<h3 id="github项目">Github项目</h3>
<p><a href="https://github.com/cr-zhichen/CertForge.NET">https://github.com/cr-zhichen/CertForge.NET</a></p>
<h3 id="效果预览">效果预览</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F12%2F26%2F1703572302166.png&amp;size=m" alt="1703572302166.png"></p>
<h3 id="核心代码">核心代码</h3>
<p><a href="https://blog-storage.ccrui.cc/2023/12/26/CertificateUtilities.cs">CertificateUtilities.cs</a></p>
<pre><code class="language-csharp">using System.Net;
using System.Security.Cryptography.X509Certificates;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Crypto.Operators;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.X509;
using X509Certificate = Org.BouncyCastle.X509.X509Certificate;

namespace CertForge.NET.Utils;

/// &lt;summary&gt;
/// 证书生成器
/// &lt;/summary&gt;
public static class CertificateUtilities
{
    /// &lt;summary&gt;
    /// 创建根证书
    /// &lt;/summary&gt;
    /// &lt;param name="organization"&gt;&lt;/param&gt;
    /// &lt;param name="commonName"&gt;&lt;/param&gt;
    /// &lt;param name="country"&gt;&lt;/param&gt;
    /// &lt;param name="year"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static (string certificate, string privateKey) CreateRootCertificate(string country, string organization,
        string commonName, int year = 100)
    {
        var random = new SecureRandom();
        var certificateGenerator = new X509V3CertificateGenerator();

        var serialNumber = BigIntegers.CreateRandomInRange(BigInteger.One, BigInteger.ValueOf(long.MaxValue), random);
        certificateGenerator.SetSerialNumber(serialNumber);

        var dirName = $"C={country}, O={organization}, CN={commonName}";
        var issuerDn = new X509Name(dirName);
        var subjectDn = issuerDn;
        certificateGenerator.SetIssuerDN(issuerDn);
        certificateGenerator.SetSubjectDN(subjectDn);

        certificateGenerator.SetNotBefore(DateTime.UtcNow.Date);
        certificateGenerator.SetNotAfter(DateTime.UtcNow.Date.AddYears(year));
        
        // 添加基本限制扩展 - 表明这是一个CA证书
        certificateGenerator.AddExtension(X509Extensions.BasicConstraints.Id, true, new BasicConstraints(true));

        // 可以选择性地添加密钥用途扩展
        KeyUsage keyUsage = new KeyUsage(KeyUsage.KeyCertSign | KeyUsage.CrlSign);
        certificateGenerator.AddExtension(X509Extensions.KeyUsage.Id, false, keyUsage);

        var keyGenerationParameters = new KeyGenerationParameters(random, 2048);
        var keyPairGenerator = new RsaKeyPairGenerator();
        keyPairGenerator.Init(keyGenerationParameters);

        var keyPair = keyPairGenerator.GenerateKeyPair();
        certificateGenerator.SetPublicKey(keyPair.Public);

        var signatureFactory = new Asn1SignatureFactory("SHA256WITHRSA", keyPair.Private);
        var certificate = certificateGenerator.Generate(signatureFactory);
        byte[] certStream = DotNetUtilities.ToX509Certificate(certificate).Export(X509ContentType.Cert);

        var writer = new StringWriter();
        var pemWriter = new PemWriter(writer);
        pemWriter.WriteObject(keyPair.Private);
        var privateKey = writer.ToString();

        writer = new StringWriter();
        pemWriter = new PemWriter(writer);
        pemWriter.WriteObject(certificate);
        var certPem = writer.ToString();

        return (certPem, privateKey);
    }


    /// &lt;summary&gt;
    /// 创建签名证书
    /// &lt;/summary&gt;
    /// &lt;param name="organization"&gt;&lt;/param&gt;
    /// &lt;param name="commonName"&gt;&lt;/param&gt;
    /// &lt;param name="subjectAlternativeName"&gt;&lt;/param&gt;
    /// &lt;param name="issuerCertificatePem"&gt;&lt;/param&gt;
    /// &lt;param name="issuerPrivateKeyPem"&gt;&lt;/param&gt;
    /// &lt;param name="country"&gt;&lt;/param&gt;
    /// &lt;param name="year"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static (string certificate, string privateKey) CreateSignedCertificate(string country, string organization,
        string commonName, string subjectAlternativeName, string issuerCertificatePem, string issuerPrivateKeyPem,
        int year = 100)
    {
        var reader = new StringReader(issuerCertificatePem);
        var pemReader = new PemReader(reader);
        var issuerCertificate = (X509Certificate)pemReader.ReadObject();

        reader = new StringReader(issuerPrivateKeyPem);
        pemReader = new PemReader(reader);
        var issuerPrivateKey = (AsymmetricCipherKeyPair)pemReader.ReadObject();

        var random = new SecureRandom();
        var certificateGenerator = new X509V3CertificateGenerator();

        var serialNumber = BigIntegers.CreateRandomInRange(BigInteger.One, BigInteger.ValueOf(long.MaxValue), random);
        certificateGenerator.SetSerialNumber(serialNumber);

        var issuerDn = new X509Name(issuerCertificate.SubjectDN.ToString());
        var subjectDn = new X509Name($"C={country}, O={organization}, CN={commonName}");
        certificateGenerator.SetIssuerDN(issuerDn);
        certificateGenerator.SetSubjectDN(subjectDn);

        certificateGenerator.SetNotBefore(DateTime.UtcNow.Date);
        certificateGenerator.SetNotAfter(DateTime.UtcNow.Date.AddYears(year));

        var keyGenerationParameters = new KeyGenerationParameters(random, 2048);
        var keyPairGenerator = new RsaKeyPairGenerator();
        keyPairGenerator.Init(keyGenerationParameters);

        var keyPair = keyPairGenerator.GenerateKeyPair();
        certificateGenerator.SetPublicKey(keyPair.Public);

        // 添加 SAN
        var sanValues = subjectAlternativeName.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        var sanVector = new Asn1EncodableVector();
        foreach (var name in sanValues)
        {
            sanVector.Add(IPAddress.TryParse(name.Trim(), out _)
                ? new GeneralName(GeneralName.IPAddress, name.Trim())
                : new GeneralName(GeneralName.DnsName, name.Trim()));
        }

        certificateGenerator.AddExtension(X509Extensions.SubjectAlternativeName.Id, false, new DerSequence(sanVector));

        var signatureFactory = new Asn1SignatureFactory("SHA256WITHRSA", issuerPrivateKey.Private);
        var certificate = certificateGenerator.Generate(signatureFactory);
        byte[] certStream = DotNetUtilities.ToX509Certificate(certificate).Export(X509ContentType.Cert);

        var writer = new StringWriter();
        var pemWriter = new PemWriter(writer);
        pemWriter.WriteObject(keyPair.Private);
        var privateKey = writer.ToString();

        writer = new StringWriter();
        pemWriter = new PemWriter(writer);
        pemWriter.WriteObject(certificate);
        var certPem = writer.ToString();

        return (certPem, privateKey);
    }
}
</code></pre>]]></description><guid isPermaLink="false">/archives/.net-zi-qian-fa-sslzheng-shu.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 26 Dec 2023 06:34:25 GMT</pubDate></item><item><title><![CDATA[Unity 事件广播与监听]]></title><link>https://blog.ccrui.cn/archives/unity-shi-jian-guang-bo-yu-jian-ting.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity%20%E4%BA%8B%E4%BB%B6%E5%B9%BF%E6%92%AD%E4%B8%8E%E7%9B%91%E5%90%AC&amp;url=/archives/unity-shi-jian-guang-bo-yu-jian-ting.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="脚本下载">脚本下载</h2>
<p><a href="https://blog-storage.ccrui.cc/2023/12/8/EventType.cs">EventType.cs</a></p>
<p><a href="https://blog-storage.ccrui.cc/2023/12/8/EventDispose.cs">EventDispose.cs</a></p>
<h2 id="广播系统优点">广播系统优点</h2>
<ol>
 <li>
  <p><strong>简化代码结构：</strong> 该事件处理系统可以帮助更轻松地管理事件和监听器，从而简化代码结构。可以将不同部分的代码分开，以实现更好的代码组织和可维护性。</p></li>
 <li>
  <p><strong>低耦合性：</strong> 通过使用事件处理系统，不同的游戏对象或组件可以通过事件通信，而无需直接引用彼此。这降低了代码的耦合性，使得项目更加灵活和可扩展。</p></li>
 <li>
  <p><strong>易于扩展：</strong> 可以轻松地添加新的事件类型和监听器，以响应不同的游戏事件。这使得项目的功能扩展变得相对容易，无需大规模修改现有代码。</p></li>
 <li>
  <p><strong>代码可读性：</strong> 使用事件处理系统，可以更清晰地看到哪些部分的代码响应了特定类型的事件，从而提高了代码的可读性和维护性。</p></li>
</ol>
<h2 id="调用方法">调用方法</h2>
<pre><code class="language-csharp">using UnityEngine;
using Event;

public class TestEventScript : MonoBehaviour
{
    private (EventType, long) listenerIdentifier;

    private void Awake()
    {
        // 在 Awake 方法中添加监听器，并存储返回的唯一标识符
        listenerIdentifier = EventDispose.AddListener&lt;string&gt;(EventType.ShowText, ShowTextMethod);
    }

    private void ShowTextMethod(string text)
    {
        // 当 ShowText 事件被触发时，执行此方法
        Debug.Log($"ShowText Event Triggered: {text}");
    }

    private void OnDestroy()
    {
        // 注意，若使用匿名函数添加监听器，只能使用 方法1 取消监听
    
        // 移除监听器 - 方法1: 使用事件类型和唯一标识符 （建议使用）
        EventDispose.RemoveListener(listenerIdentifier.Item1, listenerIdentifier.Item2);
        
        // 移除监听器 - 方法2: 使用事件类型和监听器操作
        EventDispose.RemoveListener&lt;string&gt;(EventType.ShowText, ShowTextMethod);
    }

    // 调用这个方法来测试广播事件
    public void TestBroadcast()
    {
        // 广播 ShowText 事件
        EventDispose.Broadcast&lt;string&gt;(EventType.ShowText, "Hello, World!");
    }
}

</code></pre>
<h2 id="详细代码">详细代码</h2>
<h3 id="eventtype-脚本">EventType 脚本</h3>
<pre><code class="language-csharp">namespace Event
{
    /// &lt;summary&gt;
    /// 定义可能的事件类型
    /// &lt;/summary&gt;
    public enum EventType
    {
        ShowText,
    }
}
</code></pre>
<h3 id="eventdispose-脚本">EventDispose 脚本</h3>
<pre><code class="language-csharp">using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;

namespace Event
{
    /// &lt;summary&gt;
    /// EventDispose类提供了一个用于管理事件监听器的集中式事件处理系统。
    /// &lt;/summary&gt;
    public static class EventDispose
    {
        /// &lt;summary&gt;
        /// 存储不同事件类型和ID的事件处理程序的字典。
        /// &lt;/summary&gt;
        private static readonly ConcurrentDictionary&lt;EventType, Dictionary&lt;long, Delegate&gt;&gt; EventDic = new();

        /// &lt;summary&gt;
        /// 用于监听器的唯一标识符。
        /// &lt;/summary&gt;
        private static long _listenerId = 0;

        /// &lt;summary&gt;
        /// 为指定的事件类型添加新的监听器。监听器与唯一标识符关联。
        /// &lt;/summary&gt;
        /// &lt;typeparam name="T"&gt;事件负载的类型。&lt;/typeparam&gt;
        /// &lt;param name="eventType"&gt;要监听的事件类型。&lt;/param&gt;
        /// &lt;param name="action"&gt;事件触发时要调用的操作。&lt;/param&gt;
        /// &lt;returns&gt;包含事件类型和监听器的唯一标识符的元组。&lt;/returns&gt;
        public static (EventType, long) AddListener&lt;T&gt;(EventType eventType, Action&lt;T&gt; action)
        {
            long key = Interlocked.Increment(ref _listenerId);
            // 获取或创建事件类型对应的字典
            var value = EventDic.GetOrAdd(eventType, _ =&gt; new());

            // 添加到内部字典
            value[key] = action;

            return (eventType, key);
        }

        /// &lt;summary&gt;
        /// 为指定的事件类型添加新的监听器。监听器与唯一标识符关联。
        /// &lt;/summary&gt;
        /// &lt;param name="eventType"&gt;要监听的事件类型。&lt;/param&gt;
        /// &lt;param name="action"&gt;事件触发时要调用的操作。&lt;/param&gt;
        /// &lt;returns&gt;包含事件类型和监听器的唯一标识符的元组。&lt;/returns&gt;
        public static (EventType, long) AddListener(EventType eventType, Action action)
        {
            long key = Interlocked.Increment(ref _listenerId);
            // 获取或创建事件类型对应的字典
            var value = EventDic.GetOrAdd(eventType, _ =&gt; new());

            // 添加到内部字典
            value[key] = action;

            return (eventType, key);
        }

        /// &lt;summary&gt;
        /// 将指定类型的事件广播给所有已注册的监听器。
        /// &lt;/summary&gt;
        /// &lt;param name="eventType"&gt;要广播的事件类型。&lt;/param&gt;
        /// &lt;param name="arg"&gt;要传递给事件监听器的参数。&lt;/param&gt;
        /// &lt;typeparam name="T"&gt;参数的类型。&lt;/typeparam&gt;
        public static void Broadcast&lt;T&gt;(EventType eventType, T arg)
        {
            if (!EventDic.TryGetValue(eventType, out var value))
            {
                Debug.LogWarning($"不存在事件类型{eventType}的监听，无法广播事件");
                return;
            }

            foreach (var item in value)
            {
                if (item.Value is Action&lt;T&gt; action)
                {
                    action.Invoke(arg);
                }
                else
                {
                    Debug.LogError($"事件类型不匹配,请检查事件类型{eventType}的监听的参数类型是否和广播的参数类型一致");
                }
            }
        }

        /// &lt;summary&gt;
        /// 将指定类型的事件广播给所有已注册的监听器。
        /// &lt;/summary&gt;
        /// &lt;param name="eventType"&gt;要广播的事件类型。&lt;/param&gt;
        public static void Broadcast(EventType eventType)
        {
            if (!EventDic.TryGetValue(eventType, out var value))
            {
                Debug.LogWarning($"不存在事件类型{eventType}的监听，无法广播事件");
                return;
            }

            foreach (var item in value)
            {
                if (item.Value is Action action)
                {
                    action.Invoke();
                }
                else
                {
                    Debug.LogError($"事件类型不匹配,请检查事件类型{eventType}的监听的参数类型是否和广播的参数类型一致");
                }
            }
        }

        /// &lt;summary&gt;
        /// 从指定的事件类型和键中删除监听器。
        /// &lt;/summary&gt;
        /// &lt;param name="eventType"&gt;要从中删除监听器的事件类型。&lt;/param&gt;
        /// &lt;param name="key"&gt;与监听器关联的唯一键。&lt;/param&gt;
        public static void RemoveListener(EventType eventType, long key)
        {
            if (EventDic.TryGetValue(eventType, out var value) &amp;&amp; value.ContainsKey(key))
            {
                value.Remove(key);
            }
        }

        /// &lt;summary&gt;
        /// 从指定的事件类型中删除监听器。
        /// &lt;/summary&gt;
        /// &lt;typeparam name="T"&gt;事件的类型。&lt;/typeparam&gt;
        /// &lt;param name="eventType"&gt;事件类型。&lt;/param&gt;
        /// &lt;param name="action"&gt;监听器操作。&lt;/param&gt;
        public static void RemoveListener&lt;T&gt;(EventType eventType, Action&lt;T&gt; action)
        {
            if (EventDic.TryGetValue(eventType, out var value))
            {
                foreach (var item in value)
                {
                    if (item.Value.Equals(action))
                    {
                        value.Remove(item.Key);
                        break;
                    }
                }
            }
        }

        /// &lt;summary&gt;
        /// 从指定的事件类型中删除监听器。
        /// &lt;/summary&gt;
        /// &lt;param name="eventType"&gt;事件类型。&lt;/param&gt;
        /// &lt;param name="action"&gt;监听器操作。&lt;/param&gt;
        public static void RemoveListener(EventType eventType, Action action)
        {
            if (EventDic.TryGetValue(eventType, out var value))
            {
                foreach (var item in value)
                {
                    if (item.Value.Equals(action))
                    {
                        value.Remove(item.Key);
                        break;
                    }
                }
            }
        }
    }
}
</code></pre>]]></description><guid isPermaLink="false">/archives/unity-shi-jian-guang-bo-yu-jian-ting.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 8 Dec 2023 08:01:15 GMT</pubDate></item><item><title><![CDATA[Windows Docker 测试环境脚本]]></title><link>https://blog.ccrui.cn/archives/windows-docker-ce-shi-huan-jing-jiao-ben.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Windows%20Docker%20%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83%E8%84%9A%E6%9C%AC&amp;url=/archives/windows-docker-ce-shi-huan-jing-jiao-ben.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="开启服务">开启服务</h2>
<ul>
 <li>MongoDB</li>
 <li>Mysql</li>
 <li>Nginx</li>
 <li>PostgreSQL</li>
 <li>Redis</li>
 <li>SQLServer</li>
</ul>
<h2 id="开启脚本">开启脚本</h2>
<p><a href="https://blog-storage.ccrui.cc/2024/03/12/Start_MongoDB-DEV-Docker.bat">Start_MongoDB-DEV-Docker.bat</a></p>
<p><a href="https://blog-storage.ccrui.cc/2023/12/6/Start_PostgreSQL-DEV-gathyijz.bat">Start_PostgreSQL-DEV.bat</a></p>
<p><a href="https://blog-storage.ccrui.cc/2023/12/6/Start_Nginx-DEV-Docker-kxybmlmu.bat">Start_Nginx-DEV-Docker.bat</a></p>
<p><a href="https://blog-storage.ccrui.cc/2023/12/6/Start_Redis-DEV-Docker-udbpykrs.bat">Start_Redis-DEV-Docker.bat</a></p>
<p><a href="https://blog-storage.ccrui.cc/2023/12/6/Start_MySql-DEV-Docker-vjjwhdxx.bat">Start_MySql-DEV-Docker.bat</a></p>
<p><a href="https://blog-storage.ccrui.cc/2023/12/6/Start_SQLServer-DEV-jbsotquw.bat">Start_SQLServer-DEV.bat</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F12%2F06%2F1701867335704.png&amp;size=m" alt="img"></p>
<h2 id="注意">注意</h2>
<p>全部脚本的数据映射目录均在 <code>C:/Users/%USERNAME%/Documents/DEV/</code> 下</p>
<p><code>SQLServer</code> 未做数据持久化保存，如需数据持久化，需自行修改<br><code>Nginx</code> 需在 <code>C:/Users/%USERNAME%/Documents/DEV/Nginx</code> 路径下提前解压放置下列文件 <a href="https://blog-storage.ccrui.cc/2023/12/6/Nginx-whwmidyx.zip">Nginx.zip</a></p>]]></description><guid isPermaLink="false">/archives/windows-docker-ce-shi-huan-jing-jiao-ben.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 6 Dec 2023 12:56:11 GMT</pubDate></item><item><title><![CDATA[Linux 代理使用指南（含 Docker 支持）]]></title><link>https://blog.ccrui.cn/archives/315.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Linux%20%E4%BB%A3%E7%90%86%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97%EF%BC%88%E5%90%AB%20Docker%20%E6%94%AF%E6%8C%81%EF%BC%89&amp;url=/archives/315.html" width="1" height="1" alt="" style="opacity:0;">
<p>本指南旨在帮助用户在 Linux 环境下，通过 Clash 代理工具实现网络代理，包括对 Docker 的代理配置。</p>
<h2 id="安装和配置-clash">安装和配置 Clash</h2>
<h3 id="下载项目">下载项目</h3>
<p>克隆 Clash 项目：</p>
<pre><code class="language-bash">git clone https://github.com/Elegybackup/clash-for-linux-backup.git
cd clash-for-linux
</code></pre>
<h3 id="配置环境变量">配置环境变量</h3>
<p>编辑<code>.env</code>文件，设置<code>CLASH_URL</code>:</p>
<pre><code class="language-bash">vim .env
</code></pre>
<blockquote>
 <p><strong>注意：</strong> 若<code>.env</code>中的<code>CLASH_SECRET</code>留空，脚本将自动生成随机字符串。</p>
</blockquote>
<h3 id="启动-clash">启动 Clash</h3>
<p>在项目目录运行启动脚本：</p>
<pre><code class="language-bash">sudo bash start.sh
</code></pre>
<p>成功启动后，根据提示执行：</p>
<pre><code class="language-bash">source /etc/profile.d/clash.sh
proxy_on
</code></pre>
<h3 id="检查服务状态">检查服务状态</h3>
<ul>
 <li>
  <p>检查服务端口：</p>
  <pre><code class="language-bash">netstat -tln | grep -E '9090|7890'
</code></pre></li>
 <li>
  <p>检查环境变量：</p>
  <pre><code class="language-bash">env | grep -E 'http_proxy|https_proxy'
</code></pre></li>
</ul>
<p>若以上检查无误，Clash 服务已成功启动。</p>
<h2 id="服务管理">服务管理</h2>
<h3 id="重启-clash">重启 Clash</h3>
<p>修改<code>conf/config.yaml</code>后，使用以下命令重启：</p>
<pre><code class="language-bash">sudo bash restart.sh
</code></pre>
<blockquote>
 <p><strong>注意：</strong> 重启不会更新订阅信息。</p>
</blockquote>
<h3 id="停止-clash">停止 Clash</h3>
<p>在项目目录执行关闭命令：</p>
<pre><code class="language-bash">sudo bash shutdown.sh
proxy_off
</code></pre>
<p>检查端口和环境变量确认服务已关闭。</p>
<h2 id="clash-dashboard">Clash Dashboard</h2>
<p>访问 Dashboard 来管理 Clash 设置：</p>
<ol>
 <li>打开 <code>http://&lt;ip&gt;:9090/ui</code> （<code>&lt;ip&gt;</code>为实际 IP 地址）。</li>
 <li>输入<code>API Base URL</code>和<code>Secret</code>。</li>
 <li>查看或修改配置。</li>
</ol>
<p>详细使用方法参见<a href="https://github.com/haishanh/yacd">yacd 项目</a>。</p>
<h2 id="终端节点选择">终端节点选择</h2>
<p>若无法通过浏览器访问 Dashboard，可使用终端脚本<code>scripts/clash_proxy-selector.sh</code>进行节点选择和设置。</p>
<blockquote>
 <p><strong>注意：</strong> 确保脚本中的<code>Secret</code>与实际值一致。</p>
</blockquote>
<h2 id="docker-代理配置">Docker 代理配置</h2>
<ol>
 <li>
  <p>创建 Docker 的 systemd 配置目录：</p>
  <pre><code class="language-bash">mkdir -p /etc/systemd/system/docker.service.d
</code></pre></li>
 <li>
  <p>创建并编辑<code>http-proxy.conf</code>：</p>
  <pre><code class="language-bash">[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"
</code></pre></li>
 <li>
  <p>更新 systemd 配置并重启 Docker：</p>
  <pre><code class="language-bash">systemctl daemon-reload
systemctl restart docker
</code></pre></li>
</ol>
<blockquote>
 <p>详见 <a href="https://docs.docker.com/config/daemon/systemd/#http-proxy">Docker 官方文档</a>。</p>
</blockquote>]]></description><guid isPermaLink="false">/archives/315.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 21 Nov 2023 01:50:00 GMT</pubDate></item><item><title><![CDATA[宝塔反代后解决跨域问题]]></title><link>https://blog.ccrui.cn/archives/314.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%AE%9D%E5%A1%94%E5%8F%8D%E4%BB%A3%E5%90%8E%E8%A7%A3%E5%86%B3%E8%B7%A8%E5%9F%9F%E9%97%AE%E9%A2%98&amp;url=/archives/314.html" width="1" height="1" alt="" style="opacity:0;">
<p>Nginx配置文件中加入：</p>
<pre><code>    # 全局 CORS 配置
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,X-Data-Type,X-Requested-With,X-Data-Type,X-Auth-Token';
</code></pre>
<p>或在反向代理配置中加入：</p>
<pre><code>    set $enable_cors 0;
    if ( $enable_cors = 0 )
    {
      #CORS 配置
      add_header 'Access-Control-Allow-Origin' '*';
    	add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
  	  #是否允许cookie传输
      add_header 'Access-Control-Allow-Credentials' 'true';
  	  add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,X-Data-Type,X-Requested-With,X-Data-Type,X-Auth-Token';
    }
    
    
    #针对浏览器的options预请求直接返回200，否则会被403 forbidden--invalie CORS request
    if ( $request_method = 'OPTIONS' ) { 
      #CORS 配置
      add_header 'Access-Control-Allow-Origin' '*';
    	add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
  	  #是否允许cookie传输
      add_header 'Access-Control-Allow-Credentials' 'true';
    	add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,X-Data-Type,X-Requested-With,X-Data-Type,X-Auth-Token';
    	return 200;
  	} 
</code></pre>]]></description><guid isPermaLink="false">/archives/314.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 8 Nov 2023 07:51:00 GMT</pubDate></item><item><title><![CDATA[.net6 API 静态路径]]></title><link>https://blog.ccrui.cn/archives/312.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=.net6%20API%20%E9%9D%99%E6%80%81%E8%B7%AF%E5%BE%84&amp;url=/archives/312.html" width="1" height="1" alt="" style="opacity:0;">
<p>app.UseStaticFiles(new StaticFileOptions<br>
  {<br>
  FileProvider = new PhysicalFileProvider(<br>
  Path.Combine(Directory.GetCurrentDirectory(), "Resources")),<br>
  RequestPath = "/Resources",<br>
  OnPrepareResponse = ctx =&gt;<br>
  {<br>
  ctx.Context.Response.Headers.Add("Access-Control-Allow-Origin", "*");<br>
  }<br>
  });</p>]]></description><guid isPermaLink="false">/archives/312.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 22 Aug 2023 14:50:00 GMT</pubDate></item><item><title><![CDATA[Unity 云渲染文档]]></title><link>https://blog.ccrui.cn/archives/311.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity%20%E4%BA%91%E6%B8%B2%E6%9F%93%E6%96%87%E6%A1%A3&amp;url=/archives/311.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="前言">前言</h2>
<p>本文档写于2023/7/21，主要介绍Unity云渲染的使用方法，教程内使用的<code>UnityRenderStreaming</code>版本为<code>3.1.0-exp.5</code>，若版本更新，文档内容可能会有所变动。</p>
<h2 id="环境要求">环境要求</h2>
<h3 id="unity版本要求">Unity版本要求</h3>
<ul>
 <li>Unity 2020.3</li>
 <li>Unity 2021.3</li>
 <li>Unity 2022.2</li>
</ul>
<h3 id="操作系统要求">操作系统要求</h3>
<ul>
 <li>Windows</li>
 <li>MacOS</li>
 <li>Linux</li>
 <li>ios</li>
 <li>Android (不支持ARMv7)</li>
</ul>
<h3 id="浏览器要求">浏览器要求</h3>
<table>
 <thead>
  <tr>
   <th>浏览器</th>
   <th>Windows</th>
   <th>Mac</th>
   <th>iOS</th>
   <th>Android</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>Google Chrome</td>
   <td>:white_check_mark:</td>
   <td>:white_check_mark:</td>
   <td></td>
   <td>:white_check_mark:</td>
  </tr>
  <tr>
   <td>Safari</td>
   <td></td>
   <td>:white_check_mark:</td>
   <td>:white_check_mark:</td>
   <td></td>
  </tr>
  <tr>
   <td>Firefox</td>
   <td>:white_check_mark:</td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  <tr>
   <td>Microsoft edge (Chromium based)</td>
   <td>:white_check_mark:</td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
 </tbody>
</table>
<blockquote>
 <p>注意：在Safari和iOS Safari浏览器中，WebRTC功能无法在http下使用，必须使用https。</p>
</blockquote>
<h3 id="输入系统">输入系统</h3>
<p><code>UnityRenderStreaming</code>仅支持<code>Unity</code>的<code>Input System</code>，不支持<code>Legacy Input System</code></p>
<h2 id="云渲染部署">云渲染部署</h2>
<h3 id="创建unity项目">创建Unity项目</h3>
<p>打开Unity Hub，点击<code>New</code>按钮，创建一个新的Unity项目(支持SRP，URP，HDRP)。</p>
<h3 id="unityrenderstreaming安装">UnityRenderStreaming安装</h3>
<ol>
 <li>在菜单栏中选择<code>Window</code> &gt; <code>Package Manager</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689916597292.png&amp;size=m" alt="1689916597292.png"></li>
 <li>在<code>Package Manager window</code>窗口中点击<code>+</code>按钮，然后选择<code>Add package by name</code>。如果你使用的是<code>Unity 2020.3</code>版本，选择<code>通过git URL添加包</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689916649021.png&amp;size=m" alt="1689916649021.png"></li>
 <li>输入<code>com.unity.renderstreaming</code>,<code>3.1.0-exp.5</code>，然后点击<code>Add</code>按钮<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689916717793.png&amp;size=m" alt="1689916717793.png"></li>
 <li>安装包后会自动打开渲染流向导窗口。选择全部修复<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2Fwizard_fixall.png&amp;size=m" alt="wizard_fixall.png"></li>
</ol>
<h3 id="unityrenderstreaming配置">UnityRenderStreaming配置</h3>
<p>在Unity场景中创建空物体，并命名为<code>RenderStreamingManager</code>，并在物体上添加以下组件：<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689917399106.png&amp;size=m" alt="1689917399106.png"></p>
<p>添加完成脚本后，按照下方的配置进行设置摄像机与音频的流传输</p>
<p>脚本中视频传输分辨率可在<code>Video Stream Sender</code>脚本中的<code>Custom Value</code>变量中设置，视频与音频的传输码率可在<code>Video Stream Sender</code>脚本中的<code>Bitrate(kbits/sec)</code>变量中设置</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689917592029.png&amp;size=m" alt="1689917592029.png"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689920281387.png&amp;size=m" alt="1689920281387.png"></p>
<blockquote>
 <p>RenderStreaming脚本中的其他设置将在下文中详细介绍</p>
</blockquote>
<h3 id="本地测试">本地测试</h3>
<p>根据操作系统下载 <a href="https://github.com/Unity-Technologies/UnityRenderStreaming/releases/tag/3.1.0-exp.5">UnityRenderStreaming WebApp</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689917828959.png&amp;size=m" alt="1689917828959.png"></p>
<p>下载后，运行WebApp程序与Unity程序，浏览器访问<code>http://127.0.0.1</code>，选择<code>Receiver Sample</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2Fbrowser_index_page.png&amp;size=m" alt="browser_index_page.png"></p>
<p>点击播放，即可在浏览器中看到Unity场景</p>
<h3 id="部署stunturn服务器">部署STUN/TURN服务器</h3>
<blockquote>
 <p>STUN/TURN服务器是用于在NAT网络中建立点对点连接的服务器，如果你连接双方在同一个局域网内或均有公网ip，可以不用部署STUN/TURN服务器</p>
</blockquote>
<blockquote>
 <p>本文档中使用的STUN/TURN服务器为<a href="https://github.com/coturn/coturn">Coturn</a>，服务器操作系统为<code>Ubuntu 22.04.2 LTS</code></p>
</blockquote>
<h4 id="安装coturn">安装Coturn</h4>
<pre><code class="language-bash">sudo apt-get update
sudo apt-get install coturn
dpkg -L coturn
</code></pre>
<blockquote>
 <p>配置文件路径：<code>/etc/turnserver.conf</code></p>
</blockquote>
<h4 id="修改配置内容">修改配置内容</h4>
<pre><code class="language-bash">listening-port=3478 #监听端口
external-ip=【ip】 #公网ip
user=【用户名】:【密码】 #用户名:密码
realm=【域名】 #绑定域名
</code></pre>
<h4 id="启动coturn">启动Coturn</h4>
<p>前台启动</p>
<pre><code class="language-bash">turnserver
</code></pre>
<p>后台启动</p>
<pre><code class="language-bash">service coturn start
</code></pre>
<p>初次运行请使用非后台启动,会显示当前运行状态,如果有错误会直接显示在控制台上</p>
<h4 id="验证监听">验证监听</h4>
<pre><code class="language-bash">lsof -n -i4TCP:3478 | grep LISTEN
</code></pre>
<h4 id="测试stunturn服务器">测试STUN/TURN服务器</h4>
<blockquote>
 <p>在教程编写的时候，Chrome内核浏览器对TURN服务器的支持不是很好，需要使用Firefox浏览器进行测试</p>
</blockquote>
<p>访问 <a href="https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/">https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/</a></p>
<p>删除默认的STUN服务器，添加自己的TURN服务器</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689919010173.png&amp;size=m" alt="1689919010173.png"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689919116059.png&amp;size=m" alt="1689919116059.png"></p>
<p>进行测试，如果测试列表中出现<code>srflx</code>与<code>relay</code>，则说明STUN/TURN服务器配置成功</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689919198241.png&amp;size=m" alt="1689919198241.png"></p>
<h3 id="部署web服务器信令服务器">部署Web服务器（信令服务器）</h3>
<blockquote>
 <p>本文档将使用源码部署<code>UnityRenderStreaming WebApp</code>服务器，请保证服务器中已安装<code>Node.js</code>与<code>npm</code></p>
</blockquote>
<p>下载源码 <a href="https://github.com/Unity-Technologies/UnityRenderStreaming/tree/main/WebApp">https://github.com/Unity-Technologies/UnityRenderStreaming/tree/main/WebApp</a></p>
<p>打开 <code>/WebApp/client/public/js/config.js</code> 文件，修改以下内容</p>
<pre><code class="language-javascript">export function getRTCConfiguration() {
  let config = {};
  config.sdpSemantics = 'unified-plan';
  config.iceServers = [
    { 
      urls: 'stun:【域名】:【端口3478】' 
    },
    { 
      urls: 'turn:【域名】:【端口3478】', 
      username: '【用户名】', 
      credential: '【密码】' 
    }
  ];
  return config;
}

</code></pre>
<p>将源码上传至服务器，进入<code>WebApp</code>目录，执行以下命令</p>
<pre><code class="language-bash">npm install
npm run start -- -p 9089
</code></pre>
<p>若在npm install时出现错误，请使用以下命令</p>
<pre><code class="language-bash">npm install --legacy-peer-deps
</code></pre>
<p>成功开启后，访问<code>http://【服务器ip】:9089</code>，若出现以下界面，则说明服务器部署成功</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689920133125.png&amp;size=m" alt="1689920133125.png"></p>
<h3 id="云渲染测试">云渲染测试</h3>
<p>配置<code>RenderStreamingManager</code>物体上的<code>Render Streaming</code>脚本</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689920430509.png&amp;size=m" alt="1689920430509.png"></p>
<p>打开浏览器，访问<code>http://【服务器ip】:9089</code>，选择<code>Receiver Sample</code>，点击播放，即可在浏览器中看到Unity场景</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F07%2F21%2F1689920497490.png&amp;size=m" alt="1689920497490.png"></p>]]></description><guid isPermaLink="false">/archives/311.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 10 Aug 2023 00:36:00 GMT</pubDate></item><item><title><![CDATA[宝塔面板 通过命令开启Java项目]]></title><link>https://blog.ccrui.cn/archives/bao-ta-mian-ban-tong-guo-ming-ling-kai-qijava-xian.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%AE%9D%E5%A1%94%E9%9D%A2%E6%9D%BF%20%E9%80%9A%E8%BF%87%E5%91%BD%E4%BB%A4%E5%BC%80%E5%90%AFJava%E9%A1%B9%E7%9B%AE&amp;url=/archives/bao-ta-mian-ban-tong-guo-ming-ling-kai-qijava-xian.html" width="1" height="1" alt="" style="opacity:0;">
<p><code>/var/tmp/springboot/vhost/scripts/</code> 下可看到项目的启动命令</p>
<pre><code class="language-shall"># 杀死进程
kill -9 $(cat /var/tmp/springboot/vhost/pids/$(项目名称).pid)
# 启动应用
sh /var/tmp/springboot/vhost/scripts/$(项目名称).sh
</code></pre>]]></description><guid isPermaLink="false">/archives/bao-ta-mian-ban-tong-guo-ming-ling-kai-qijava-xian.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 1 Jun 2023 16:42:00 GMT</pubDate></item><item><title><![CDATA[Jenkins 部署与Github持续集成]]></title><link>https://blog.ccrui.cn/archives/jenkins-bu-shu-yugithub-chi-xu-ji-cheng.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Jenkins%20%E9%83%A8%E7%BD%B2%E4%B8%8EGithub%E6%8C%81%E7%BB%AD%E9%9B%86%E6%88%90&amp;url=/archives/jenkins-bu-shu-yugithub-chi-xu-ji-cheng.html" width="1" height="1" alt="" style="opacity:0;">
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FWjsKYE.png&amp;size=m" alt=""></p>
<h2 id="jenkins安装">Jenkins安装</h2>
<blockquote>
 <p>本教程采用Docker部署Jenkins，安装前请确保服务器上安装了Docker</p>
</blockquote>
<p>创建本地目录，用来挂载Docker目录</p>
<pre><code class="language-shell">sudo mkdir -p /opt/jenkins/jenkins_home
</code></pre>
<p>更改目录权限，保证Jenkins有权限访问路径</p>
<pre><code class="language-shell">sudo chown -R 1000:1000 /opt/jenkins/jenkins_home
</code></pre>
<p>Docker安装Jenkins</p>
<pre><code class="language-shell">docker run -d -v /opt/jenkins/jenkins_home:/var/jenkins_home -p 9304:8080 -p 50000:50000 --restart=on-failure jenkins/jenkins:lts-jdk11
</code></pre>
<p>浏览器访问 <code>服务器ip:9304</code> 进入Jenkins</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F687474703a2f2f75706c6f61642d696d616765732e6a69616e7368752e696f2f75706c6f61645f696d616765732f323531383631312d643933373234666164663961623835352e706e673f696d6167654d6f6772322f6175746f2d6f7269656e742f7374.png&amp;size=m" alt=""></p>
<p>初始密码在<code>/opt/jenkins/jenkins_home/secrets/initialAdminPassword</code>中可以找到</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FkH6ymL.png&amp;size=m" alt=""></p>
<p>选择install suggested plugins，等待安装完毕，如果有安装失败的可以跳过，之后可以手动根据需求安装。</p>
<p>设置完成账号密码后即可登录进入Jenkins主界面</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FSnipaste_2023-06-01_14-20-48.png&amp;size=m" alt=""></p>
<h2 id="与github持续集成">与Github持续集成</h2>
<h3 id="github创建令牌">Github创建令牌</h3>
<p>进入github --&gt; setting --&gt; Personal Access Token --&gt; Generate new token</p>
<p>勾选下面的选项：</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2Fk4oHuF.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F7u5gNi.png&amp;size=m" alt=""></p>
<p>出现Token后请注意保存！！</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F2bpUmh.png&amp;size=m" alt=""></p>
<h3 id="github-webhooks-设置">GitHub webhooks 设置</h3>
<p>进入需要持续集成的Github仓库 --&gt; setting --&gt; WebHooks&amp;Services --&gt; add webhook --&gt; 输入刚刚部署jenkins的服务器的IP，jenkins地址后加上/github-webhook/</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FERzfJf.png&amp;size=m" alt=""></p>
<p>成功如图所示：</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FXhQFct.png&amp;size=m" alt=""></p>
<h3 id="jenkins的github配置">jenkins的github配置</h3>
<h4 id="安装github-plugin">安装GitHub Plugin</h4>
<blockquote>
 <p>系统管理--&gt;插件管理--&gt;可选插件</p>
</blockquote>
<p>直接安装Github Plugin,jenkins会自动帮你解决其他插件的依赖，直接安装该插件Jenkins会自动帮你安装plain-credentials、Git、credentials、github-api</p>
<h4 id="配置github-plugin">配置GitHub Plugin</h4>
<blockquote>
 <p>系统管理 --&gt; 系统设置 --&gt; GitHub --&gt; Add GitHub Sever</p>
</blockquote>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F5DXO7d.png&amp;size=m" alt=""></p>
<p>点击添加凭据，Secret中填写刚才保存好的GithubToken</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F4rRSas.png&amp;size=m" alt=""></p>
<p>选择好刚添加的凭据，点击测试链接，成功结果如下：</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F5glrmp.png&amp;size=m" alt=""></p>
<h4 id="配置publish-over-ssh">配置publish-over-ssh</h4>
<ul>
 <li>安装publish-over-ssh插件</li>
 <li>进入系统管理 -&gt; 系统配置 -&gt; SSH Servers, 设置好name、HostName、UserName、Remote Directory；点高级，根据情况，可以设置密码或者ssh key。其它的无需更改。</li>
</ul>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F81b5jh.png&amp;size=m" alt=""></p>
<h3 id="创建jenkins项目">创建Jenkins项目</h3>
<h4 id="基础设置">基础设置</h4>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F3G8jba.png&amp;size=m" alt=""></p>
<h4 id="github设置">Github设置</h4>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FCYqBoT.png&amp;size=m" alt=""></p>
<h5 id="在凭据中添加你github的账号密码url填写git地址">在凭据中添加你Github的账号密码,Url填写.git地址</h5>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FhaOot9.png&amp;size=m" alt=""></p>
<h5 id="url填写项目地址">URL填写项目地址</h5>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F45qoKs.png&amp;size=m" alt=""></p>
<h5 id="设定构建触发器">设定构建触发器</h5>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F7gw1aT.png&amp;size=m" alt=""></p>
<h5 id="设定凭据为配置github-plugin一节保存的凭据">设定凭据为<code>配置GitHub Plugin</code>一节保存的凭据</h5>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FNwMx6d.png&amp;size=m" alt=""></p>
<h4 id="构建设置">构建设置</h4>
<p>根据项目需求设置构建命令，这里以vue项目为例</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2F3xv6M4.png&amp;size=m" alt=""></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FwUGcrM.png&amp;size=m" alt=""></p>
<pre><code class="language-shell">node -v
npm -v
npm i
npm run build
</code></pre>
<pre><code class="language-shell">cd dist
rm -rf temporary.tar.gz #删除上次打包生成的压缩文件
tar -zcvf temporary.tar.gz * #把生成的项目打包成test方便传输到远程服务器
cd ../
</code></pre>
<h3 id="部署设置">部署设置</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FWXCmoi.png&amp;size=m" alt=""></p>
<pre><code class="language-shell">cd /www/wwwroot/testblog.ccrui.cn # 进入到指定目录
find . ! -name 'temporary.tar.gz' -type f -exec rm -f {} + # 删除除temporary.tar.gz之外的所有文件
find . ! -name 'temporary.tar.gz' -type d -exec rm -rf {} + # 删除除temporary.tar.gz之外的所有目录
tar -zxvf temporary.tar.gz # 解压temporary.tar.gz文件到当前目录
rm -rf temporary.tar.gz # 删除temporary.tar.gz文件
</code></pre>
<h3 id="完成构建">完成构建</h3>
<p>保存后点击构建</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F01%2FrVW6ct.png&amp;size=m" alt=""></p>
<p>现在在Github上推送项目即可完成自动构建</p>
<h3 id="maven项目构建示例">Maven项目构建示例</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F02%2FIcz6ul.jpg&amp;size=m" alt=""></p>
<h3 id="net项目构建示例">.Net项目构建示例</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F06%2F02%2Fit0JbJ.jpg&amp;size=m" alt=""></p>]]></description><guid isPermaLink="false">/archives/jenkins-bu-shu-yugithub-chi-xu-ji-cheng.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 31 May 2023 20:15:00 GMT</pubDate></item><item><title><![CDATA[C# Java Argon2加密工具类]]></title><link>https://blog.ccrui.cn/archives/306.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=C%23%20Java%20Argon2%E5%8A%A0%E5%AF%86%E5%B7%A5%E5%85%B7%E7%B1%BB&amp;url=/archives/306.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="c-argon2加密">C# Argon2加密</h2>
<h3 id="nuget包管理器">NuGet包管理器</h3>
<pre><code>dotnet add package Konscious.Security.Cryptography.Argon2 --version 1.3.0
</code></pre>
<h3 id="c工具类">C#工具类</h3>
<pre><code class="language-csharp">using System;
using System.Text;
using System.Security.Cryptography;
using Konscious.Security.Cryptography;

/// &lt;summary&gt;
/// Argon2加密
/// &lt;/summary&gt;
public class Argon2Hasher
{
    /// &lt;summary&gt;
    /// 给密码加密
    /// &lt;/summary&gt;
    /// &lt;param name="password"&gt;&lt;/param&gt;
    /// &lt;param name="salt"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static string HashPassword(string password, string salt)
    {
        byte[] saltBytes = Encoding.UTF8.GetBytes(salt);

        using (var hasher = new Argon2id(Encoding.UTF8.GetBytes(password)))
        {
            hasher.Salt = saltBytes;
            hasher.DegreeOfParallelism = 8; // 根据您的硬件设置
            hasher.MemorySize = 65536; // 64 MB
            hasher.Iterations = 4;

            byte[] hashBytes = hasher.GetBytes(32); // 获取32字节的哈希值

            return Convert.ToBase64String(hashBytes);
        }
    }

    /// &lt;summary&gt;
    /// 验证密码
    /// &lt;/summary&gt;
    /// &lt;param name="password"&gt;&lt;/param&gt;
    /// &lt;param name="storedHash"&gt;&lt;/param&gt;
    /// &lt;param name="salt"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool VerifyPassword(string password, string storedHash, string salt)
    {
        string hashToVerify = HashPassword(password, salt);
        return storedHash.Equals(hashToVerify);
    }
}
</code></pre>
<h2 id="java-argon2加密">Java Argon2加密</h2>
<h3 id="maven-管理器">Maven 管理器</h3>
<pre><code>&lt;dependency&gt;
  &lt;groupId&gt;de.mkammerer.argon2&lt;/groupId&gt;
  &lt;artifactId&gt;argon2-jvm&lt;/artifactId&gt;
&lt;/dependency&gt;
</code></pre>
<h3 id="java工具类">Java工具类</h3>
<pre><code class="language-java">import java.nio.charset.StandardCharsets;
import java.util.Base64;
import de.mkammerer.argon2.Argon2;
import de.mkammerer.argon2.Argon2Factory;

public class Argon2Hasher {

    /**
     * 给密码加密
     *
     * @param password
     * @param salt
     * @return
     */
    public static String hashPassword(String password, String salt) {
        Argon2 argon2 = Argon2Factory.create(Argon2Factory.Argon2Types.ARGON2id);
        char[] passwordChars = password.toCharArray();
        byte[] saltBytes = salt.getBytes(StandardCharsets.UTF_8);

        try {
            byte[] hashBytes = argon2.hashRaw(4, 65536, 8, passwordChars, saltBytes);
            return Base64.getEncoder().encodeToString(hashBytes);
        } finally {
            argon2.wipeArray(passwordChars);
        }
    }

    /**
     * 验证密码
     *
     * @param password
     * @param storedHash
     * @param salt
     * @return
     */
    public static boolean verifyPassword(String password, String storedHash, String salt) {
        String hashToVerify = hashPassword(password, salt);
        return storedHash.equals(hashToVerify);
    }
}

</code></pre>]]></description><guid isPermaLink="false">/archives/306.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 21 Apr 2023 03:24:00 GMT</pubDate></item><item><title><![CDATA[Vue解析markdown，并将其展示到页面]]></title><link>https://blog.ccrui.cn/archives/vue-jie-ximarkdown-bing-jiang-qi-zhan-shi-dao-ye-m.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Vue%E8%A7%A3%E6%9E%90markdown%EF%BC%8C%E5%B9%B6%E5%B0%86%E5%85%B6%E5%B1%95%E7%A4%BA%E5%88%B0%E9%A1%B5%E9%9D%A2&amp;url=/archives/vue-jie-ximarkdown-bing-jiang-qi-zhan-shi-dao-ye-m.html" width="1" height="1" alt="" style="opacity:0;">
<ol>
 <li>安装依赖<br>
   在vue项目下打开命令窗口，并输入以下命令：</li>
</ol>
<pre><code class="language-js">// marked 用于将markdown转换成html
npm install -g marked

// 用于代码高亮显示
npm install highlight.js

// 代码行号显示插件
npm install highlightjs-line-numbers.js
</code></pre>
<ol start="2">
 <li>在main.js文件中引入highlight.js</li>
</ol>
<pre><code class="language-js">import hljs from 'highlight.js';
Vue.use(hljs);
</code></pre>
<ol start="3">
 <li>同样在main.js文件中，创建一个自定义的全局指令</li>
</ol>
<pre><code class="language-js">//封装成一个指令,highlight是指令的名称
Vue.directive('highlight', (el) =&gt; {
  let blocks = el.querySelectorAll('pre code')
  blocks.forEach((block) =&gt; {

	// 创建ol标签元素
	let ol = document.createElement("ol");

    // 2.根据换行符获取行数，根据获取的行数生成行号
    let rowCount = block.outerHTML.split('\n').length;
    for(let i=1;i &lt; rowCount;i++){
      // 创建li标签元素
      let li = document.createElement("li");
      let text = document.createTextNode(i);
      // 将生成的行号添加到li标签中
      li.appendChild(text);
      // 将li标签添加到ol标签中
      ol.appendChild(li);
    }
    // 为ol标签添加class名
    ol.className = 'pre-numbering';
    block.parentNode.appendChild(ol);

    hljs.highlightBlock(block)
})

</code></pre>
<ol start="4">
 <li>在vue组件中，只需使用 v-highlight 指令即可。</li>
</ol>
<pre><code class="language-js">&lt;template&gt;
    &lt;div class="article"&gt;
        &lt;!-- vue展示markdown内容,v-highlight自定义指令 --&gt;
        &lt;&lt;div v-highlight v-html="article" class="markdown-body" id="content"&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/template&gt;
</code></pre>
<p>注意：添加 markdown-body 类名</p>
<ol start="5">
 <li>解析markdown转换为html</li>
</ol>
<pre><code class="language-js">&lt;script&gt;
    // 将marked 引入
    import { marked }from 'marked';
    // 引入代码高亮样式
    import "highlight.js/styles/darcula.css";
 
    export default {
        name: "article",
        data() {
            return {
                article: '```\n' +
                    '&lt;p&gt;显示代码高亮&lt;/p&gt;\n' +
                    '&lt;p&gt;显示代码行号&lt;/p&gt;\n' +
                    '```'
            };
        },
        mounted() {
        	// 调用marked()方法，将markdown转换成html
            this.article= marked(this.article); 
        }
    }
&lt;/script&gt;
</code></pre>
<ol start="6">
 <li>添加样式</li>
</ol>
<pre><code class="language-css"> .article {
   width: 1200px;
   margin: 30px auto;
   overflow: hidden;
 }

 /* markdown 行号的样式 */
 #content li {
 	list-style: decimal;
 }

 .article-con div pre {
 	position: relative;
 	padding: 0 29px;
 	overflow: hidden;
 	font-size: 90%;
 	line-height: 1.9;
 	background: #282c34;
 }

 .article-con div pre code {
 	padding: 0.4em;
 }

 .article-con div .pre-numbering {
 	position: absolute;
 	top: 0;
 	left: 0;
 	width: 29px;
 	padding: 9px 7px 12px 0;
 	border-right: 1px solid #C3CCD0;
 	background: #282c34;
 	text-align: right;
 	font-size: 16px;
 	line-height: 1.45;
 }

 .pre-numbering li{
 	list-style:none;
 	font-family: Menlo, monospace;
 	color: #abb2bf;
 }
</code></pre>
<blockquote>
 <p>注意：如果没有引入highlight.js对应的css样式，则不会有代码高亮显示的效果。highlight.js有多种css样式， highlight.js对应的css样式在–node_modules–&gt;highlight.js–&gt;styles 目录下，可以选择自己喜欢的样式引入。</p>
</blockquote>]]></description><guid isPermaLink="false">/archives/vue-jie-ximarkdown-bing-jiang-qi-zhan-shi-dao-ye-m.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 20 Apr 2023 04:18:00 GMT</pubDate></item><item><title><![CDATA[邮件HTML模板 附.net邮件发送方法]]></title><link>https://blog.ccrui.cn/archives/you-jianhtml-mo-ban-funet-you-jian-fa-song-fang-fa.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E9%82%AE%E4%BB%B6HTML%E6%A8%A1%E6%9D%BF%20%E9%99%84.net%E9%82%AE%E4%BB%B6%E5%8F%91%E9%80%81%E6%96%B9%E6%B3%95&amp;url=/archives/you-jianhtml-mo-ban-funet-you-jian-fa-song-fang-fa.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="邮件效果">邮件效果</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F04%2F18%2FRkN6eg.png&amp;size=m" alt="邮件效果"></p>
<h2 id="邮件模板">邮件模板</h2>
<pre><code class="language-html">&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;title&gt;{{Subject}}&lt;/title&gt;
&lt;/head&gt;

&lt;body style="margin: 0; padding: 0; font-family: 'Arial', sans-serif; background-color: #f4f4f4;"&gt;
    &lt;table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse;"&gt;
        &lt;tr&gt;
            &lt;td bgcolor="#ffffff"&gt;
                &lt;img src="{{imageUrl}}" alt="image" width="100%" style="display: block;" /&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td align="center" bgcolor="#ffffff"
                style="padding: 20px 0 20px 0; font-size: 28px; font-weight: bold; color: #333333;"&gt;
                {{projectName}}
            &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td bgcolor="#ffffff" style="padding: 20px;"&gt;
                &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;
                    &lt;tr&gt;
                        &lt;td style="color: #333333; font-size: 18px;"&gt;
                            &lt;b&gt;亲爱的 {{UserName}},&lt;/b&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td style="padding: 20px 0 30px 0; color: #666666; font-size: 16px; line-height: 20px;"&gt;
                            {{content}}
                        &lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td style="padding: 30px 0 0 0; color: #666666; font-size: 16px; line-height: 20px;"&gt;
                            {{information}}
                        &lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/table&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td bgcolor="#ffffff" style="padding: 20px; color: #666666; font-size: 14px;"&gt;
                &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;
                    &lt;tr&gt;
                        &lt;td width="75%" align="center"&gt;
                            {{footnote}}
                        &lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/table&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/body&gt;

&lt;/html&gt;
</code></pre>
<h2 id="c方法">C#方法</h2>
<h3 id="解析方法">解析方法</h3>
<pre><code class="language-csharp">using System.Text.RegularExpressions;

public static class TemplateReplacer
{
    public static string ReplacePlaceholders(Dictionary&lt;string, string&gt; placeholders)
    {
        string template = System.IO.File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "EmailTemplate.html"));
        foreach (var placeholder in placeholders)
        {
            string pattern = $"{{{{{placeholder.Key}}}}}";
            template = Regex.Replace(template, pattern, placeholder.Value);
        }

        return template;
    }
}
</code></pre>
<h3 id="使用方法">使用方法</h3>
<pre><code class="language-csharp">        string emailBody = TemplateReplacer.ReplacePlaceholders(new Dictionary&lt;string, string&gt;()
        {
            { "Subject", "AICHAT验证码" },
            { "imageUrl", "https://img-cdn.ccrui.cn/2023/04/18/v2-0768f34e8784f31dbbf1be10118e33a6_r.jpg" },
            { "projectName", "AICHAT" },
            { "UserName", "用户" },
            { "content", $"您的验证码为{code}，请在10分钟内使用" },
            { "information", "如有任何疑问或需要进一步的信息，请随时联系我们。&lt;br&gt;&lt;br&gt;期待为您提供更多的帮助！" },
            { "footnote", "© 2023 All rights reserved" }
        });
</code></pre>
<h3 id="邮件发送方法">邮件发送方法</h3>
<pre><code class="language-csharp">using System.Net;
using System.Net.Mail;

namespace ChatGPT_API.Tool;

public class SMTPMail
{
    private readonly MailConfiguration _mailConfiguration; //SMTP服务器

    public SMTPMail(MailConfiguration mailConfiguration)
    {
        _mailConfiguration = mailConfiguration;
    }

    public bool Send()
    {
        try
        {
            //确定smtp服务器地址 实例化一个Smtp客户端
            SmtpClient smtpclient = new SmtpClient();
            smtpclient.Host = _mailConfiguration.smtpService;
            smtpclient.Port = _mailConfiguration.port; //qq邮箱可以不用端口

            //确定发件地址与收件地址
            MailAddress sendAddress = new MailAddress(_mailConfiguration.sendEmail, "AICHAT");
            MailAddress receiveAddress = new MailAddress(_mailConfiguration.reAddress);

            //构造一个Email的Message对象 内容信息
            MailMessage mailMessage = new MailMessage(sendAddress, receiveAddress);
            mailMessage.Subject = _mailConfiguration.subject;
            mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
            mailMessage.Body = _mailConfiguration.body;
            mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
            mailMessage.IsBodyHtml = true;

            //邮件发送方式  通过网络发送到smtp服务器
            smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;

            //如果服务器支持安全连接，则将安全连接设为true
            smtpclient.EnableSsl = true;
            try
            {
                //是否使用默认凭据，若为false，则使用自定义的证书，就是下面的networkCredential实例对象
                smtpclient.UseDefaultCredentials = false;

                //指定邮箱账号和密码,需要注意的是，这个密码是你在QQ邮箱设置里开启服务的时候给你的那个授权码
                NetworkCredential networkCredential =
                    new NetworkCredential(_mailConfiguration.sendEmail, _mailConfiguration.sendPwd);
                smtpclient.Credentials = networkCredential;


                //发送邮件
                smtpclient.Send(mailMessage);
                return true;
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                return false;
            }
        }
        catch (Exception e)
        {
            return false;
        }
    }
}

public class MailConfiguration
{
    /// &lt;summary&gt;
    /// SMTP服务器
    /// &lt;/summary&gt;
    public string smtpService { get; set; }

    /// &lt;summary&gt;
    /// 发件人邮箱
    /// &lt;/summary&gt;
    public string sendEmail { get; set; }

    /// &lt;summary&gt;
    /// SMTP密码
    /// &lt;/summary&gt;
    public string sendPwd { get; set; }

    /// &lt;summary&gt;
    /// SMTP端口
    /// &lt;/summary&gt;
    public int port { get; set; } = 587;

    /// &lt;summary&gt;
    /// 接收邮件的地址
    /// &lt;/summary&gt;
    public string reAddress { get; set; }

    /// &lt;summary&gt;
    /// 邮件主题
    /// &lt;/summary&gt;
    public string subject { get; set; }

    /// &lt;summary&gt;
    /// 邮件内容
    /// &lt;/summary&gt;
    public string body { get; set; }
}
</code></pre>]]></description><guid isPermaLink="false">/archives/you-jianhtml-mo-ban-funet-you-jian-fa-song-fang-fa.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 17 Apr 2023 21:17:00 GMT</pubDate></item><item><title><![CDATA[Vue 哈希模式路由 伪静态规则]]></title><link>https://blog.ccrui.cn/archives/302.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Vue%20%E5%93%88%E5%B8%8C%E6%A8%A1%E5%BC%8F%E8%B7%AF%E7%94%B1%20%E4%BC%AA%E9%9D%99%E6%80%81%E8%A7%84%E5%88%99&amp;url=/archives/302.html" width="1" height="1" alt="" style="opacity:0;">
<pre><code>    # 为 Vue 项目添加的 location 规则
    location / {
        try_files $uri $uri/ @router;
    }

    location @router {
        rewrite ^.*$ /index.html last;
    }
    # Vue 项目的 location 规则结束
</code></pre>]]></description><guid isPermaLink="false">/archives/302.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 10 Apr 2023 05:32:00 GMT</pubDate></item><item><title><![CDATA[记一个.net6 core 获取文件路径的坑]]></title><link>https://blog.ccrui.cn/archives/301.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E8%AE%B0%E4%B8%80%E4%B8%AA.net6%20core%20%E8%8E%B7%E5%8F%96%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84%E7%9A%84%E5%9D%91&amp;url=/archives/301.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="问题">问题</h2>
<p>打包发布程序并运行时，使用 <code>builder.Configuration["Test"]</code> 获取配置文件时，无法获取正确目录</p>
<p>例如：</p>
<pre><code class="language-bash">cd /root
dotnet /root/test/test.dll
</code></pre>
<p>在上面的例子中，在程序运行中预期获取到的配置文件地址应该为<code>/root/test/appsettings.json</code><br>
  但实际在程序中获取到的配置文件地址为<code>/root/appsettings.json</code>，这就导致我们无法正确的获取到配置文件</p>
<h2 id="解决方案">解决方案</h2>
<p>改为使用 <code>JObject configJson = JObject.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "appsettings.json")));</code> 获取配置文件</p>]]></description><guid isPermaLink="false">/archives/301.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 13 Mar 2023 12:28:00 GMT</pubDate></item><item><title><![CDATA[如何使用.Net7连接MySQL]]></title><link>https://blog.ccrui.cn/archives/ru-he-shi-yongnet7lian-jiemysql.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8.Net7%E8%BF%9E%E6%8E%A5MySQL&amp;url=/archives/ru-he-shi-yongnet7lian-jiemysql.html" width="1" height="1" alt="" style="opacity:0;">
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F03%2F06%2F5DAf4w.png&amp;size=m" alt="测试完成"></p>
<h2 id="新建项目">新建项目</h2>
<p>略</p>
<h2 id="引用nuget包">引用NuGet包</h2>
<p>使用NuGet引用以下包：</p>
<pre><code class="language-text">Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Tools
//根据数据库进行选择
Pomelo.EntityFrameworkCore.MySql（连接Mysql）
Microsoft.EntityFrameworkCore.SqlServer（连接SqlServer）
Oracle.EntityFrameworkCore（连接Oracle）Ï
</code></pre>
<h2 id="创建数据类实体类">创建数据类实体类</h2>
<pre><code class="language-csharp">using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Test01.Entity;

public class TestEntity
{
    public TestEntity(int id, string name, int age)
    {
        Id = id;
        Name = name;
        Age = age;
    }

    [Key] [Column("id")] public int Id { get; set; }
    [Column("name")] public string Name { get; set; }
    [Column("age")] public int Age { get; set; }
}
</code></pre>
<h2 id="创建数据库连接类">创建数据库连接类</h2>
<pre><code class="language-csharp">using Microsoft.EntityFrameworkCore;
using Test01.Entity;

namespace Test01.Context;

public class TestContext : DbContext
{
    public TestContext()
    {
    }

    public TestContext(DbContextOptions&lt;TestContext&gt; options) : base(options)
    {
    }

    // 定义表
    public DbSet&lt;TestEntity&gt; test { get; set; }
}
</code></pre>
<h2 id="向项目中注入数据库连接">向项目中注入数据库连接</h2>
<p>在<code>Program.cs</code>文件中添加：</p>
<pre><code class="language-csharp">// 在服务容器中添加 TestContext 类别作为数据库内容服务
builder.Services.AddDbContext&lt;TestContext&gt;(opt =&gt;
{
    // 从 appsettings.json 文件中取得 MySQL 的连接字符串
    string? connectionString = builder.Configuration.GetConnectionString("MySQL");
    // 自动侦测 MySQL 的服务器版本
    var serverVersion = ServerVersion.AutoDetect(connectionString);
    // 使用 MySQL 数据库提供者和连接字符串来配置数据库内容选项
    opt.UseMySql(connectionString, serverVersion);
});
</code></pre>
<h2 id="向配置文件中写入mysql信息">向配置文件中写入Mysql信息</h2>
<p>在<code>appsettings.json</code>文件中添加：</p>
<pre><code class="language-json">  "ConnectionStrings": {
    "MySQL":"server=[YourIP];user id=[UserName];password=[123456];port=[3306];database=[testdb]"
  }
</code></pre>
<p>请酌情修改[]中的内容</p>
<h2 id="测试">测试</h2>
<pre><code class="language-csharp">using Microsoft.AspNetCore.Mvc;
using Test01.Context;
using Test01.Entity;

namespace Test01.Controllers;

[ApiController]
[Route("[controller]")]
public class TestController : ControllerBase
{
    private readonly TestContext _testContext;

    public TestController(TestContext testContext)
    {
        _testContext = testContext;
    }

    [HttpGet(Name = "GetTest")]
    public List&lt;TestEntity&gt; GetTest(int id)
    {
        return _testContext.test
            .Where(o =&gt; o.Id == id)
            .ToList();
    }
}
</code></pre>]]></description><guid isPermaLink="false">/archives/ru-he-shi-yongnet7lian-jiemysql.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 6 Mar 2023 00:32:00 GMT</pubDate></item><item><title><![CDATA[CloudFlare Argo Tunnel 隧道安装使用教程]]></title><link>https://blog.ccrui.cn/archives/229.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=CloudFlare%20Argo%20Tunnel%20%E9%9A%A7%E9%81%93%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B&amp;url=/archives/229.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="下载以及安装">下载以及安装</h2>
<p>访问地址 下载合适的安装包<br><a href="https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation">https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation</a></p>
<p>将文件改名上传到ssh目录并赋予777权限后执行安装</p>
<pre><code>sudo dpkg -i ./cloudflared.deb
</code></pre>
<h2 id="运行">运行</h2>
<h3 id="登录">登录</h3>
<pre><code>cloudflared tunnel login
</code></pre>
<p>执行命令后 打开链接进行登录，并选择需要绑定的域名</p>
<h3 id="创建隧道">创建隧道</h3>
<pre><code>cloudflared tunnel create 隧道名
</code></pre>
<h3 id="删除隧道">删除隧道</h3>
<pre><code>cloudflared tunnel delete 隧道名
</code></pre>
<h3 id="列出隧道">列出隧道</h3>
<pre><code>cloudflared tunnel list
</code></pre>
<h3 id="配置隧道">配置隧道</h3>
<pre><code>cloudflared tunnel route dns 隧道名 刚才选择的域名
</code></pre>
<h3 id="体验隧道">体验隧道</h3>
<p>使用官方提供的域名进行隧道连接</p>
<pre><code>cloudflared tunnel --url localhost:你http服务端口号
</code></pre>
<h3 id="运行隧道">运行隧道</h3>
<pre><code>cloudflared tunnel run --url localhost:你http服务端口号 隧道名字
</code></pre>]]></description><guid isPermaLink="false">/archives/229.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 17 Feb 2023 08:44:00 GMT</pubDate></item><item><title><![CDATA[Sub-Web订阅转换搭建]]></title><link>https://blog.ccrui.cn/archives/subweb-ding-yue-zhuan-huan-da-jian.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Sub-Web%E8%AE%A2%E9%98%85%E8%BD%AC%E6%8D%A2%E6%90%AD%E5%BB%BA&amp;url=/archives/subweb-ding-yue-zhuan-huan-da-jian.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="前言">前言</h2>
<p>Q：订阅转换有什么用？<br>
  A：将ssr等订阅转换为clash等订阅类型，方便不同的软件之间使用</p>
<p>Q：为什么要自己搭建？<br>
  A：互联网上有许多的订阅转换的服务，但有些人会担心自己的订阅会泄漏，于是选择自己搭建</p>
<p>Q：搭建Sub-Web都需要什么？<br>
  A：需要一台安装Linux的境外VPS并部署好宝塔面板，一个有效域名</p>
<h2 id="完成示例">完成示例</h2>
<p>[button url="<a href="https://stc.ccrui.cc/%22%5D%E5%9C%A8%E7%BA%BF%E8%BD%AC%E6%8D%A2%5B/button">https://stc.ccrui.cc/"]在线转换[/button</a>]</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F01%2F25%2FDfgIwx.png&amp;size=m" alt="完成示例"></p>
<h2 id="项目地址">项目地址</h2>
<p><a href="https://github.com/CareyWang/sub-web">前端项目</a><br><a href="https://github.com/tindy2013/subconverter">后端项目</a></p>
<h2 id="域名解析">域名解析</h2>
<p>前端使用<code>stc.ccrui.cc</code>域名进行访问<br>
  后端使用<code>stcback.ccrui.cc</code>域名进行访问</p>
<h2 id="搭建sub-web前端">搭建Sub-Web前端</h2>
<h3 id="准备工作">准备工作</h3>
<p>将前端项目下载到本地<br>
  安装 Node 与 Yarn</p>
<h3 id="修改默认后端地址">修改默认后端地址</h3>
<p>找到<code>sub-web/src/views/Subconverter.vue</code> 文件</p>
<p>找到文件中的<code>backendOptions:</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F01%2F25%2FQLVraZ.png&amp;size=m" alt="backendOptions:"></p>
<p>将value后的域名替换为<code>https://stcback.ccrui.cc/sub?</code></p>
<h3 id="增加转换规则">增加转换规则</h3>
<p>在文件中找到<code>remoteConfig: [</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F01%2F25%2FyK8z0I.png&amp;size=m" alt="remoteConfig:"></p>
<p>在下一行插入</p>
<pre><code class="language-js">{
            label: "ACL4SSR",
            options: [
              {
                label: "ACL4SSR_Online 默认版 分组比较全 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online.ini"
              },
              {
                label: "ACL4SSR_Online_AdblockPlus 更多去广告 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_AdblockPlus.ini"
              },
              {
                label: "ACL4SSR_Online_NoAuto 无自动测速 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_NoAuto.ini"
              },
              {
                label: "ACL4SSR_Online_NoReject 无广告拦截规则 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_NoReject.ini"
              },
              {
                label: "ACL4SSR_Online_Mini 精简版 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini.ini"
              },
              {
                label: "ACL4SSR_Online_Mini_AdblockPlus.ini 精简版 更多去广告 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_AdblockPlus.ini"
              },
              {
                label: "ACL4SSR_Online_Mini_NoAuto.ini 精简版 不带自动测速 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_NoAuto.ini"
              },
              {
                label: "ACL4SSR_Online_Mini_Fallback.ini 精简版 带故障转移 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_Fallback.ini"
              },
              {
                label: "ACL4SSR_Online_Mini_MultiMode.ini 精简版 自动测速、故障转移、负载均衡 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_MultiMode.ini"
              },
              {
                label: "ACL4SSR_Online_Full 全分组 重度用户使用 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full.ini"
              },
              {
                label: "ACL4SSR_Online_Full_NoAuto.ini 全分组 无自动测速 重度用户使用 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_NoAuto.ini"
              },
              {
                label: "ACL4SSR_Online_Full_AdblockPlus 全分组 重度用户使用 更多去广告 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_AdblockPlus.ini"
              },
              {
                label: "ACL4SSR_Online_Full_Netflix 全分组 重度用户使用 奈飞全量 (与Github同步)",
                value:
                  "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_Netflix.ini"
              },
              {
                label: "ACL4SSR 本地 默认版 分组比较全",
                value: "config/ACL4SSR.ini"
              },
              {
                label: "ACL4SSR_Mini 本地 精简版",
                value: "config/ACL4SSR_Mini.ini"
              },
              {
                label: "ACL4SSR_Mini_NoAuto.ini 本地 精简版+无自动测速",
                value: "config/ACL4SSR_Mini_NoAuto.ini"
              },
              {
                label: "ACL4SSR_Mini_Fallback.ini 本地 精简版+fallback",
                value: "config/ACL4SSR_Mini_Fallback.ini"
              },
              {
                label: "ACL4SSR_BackCN 本地 回国",
                value: "config/ACL4SSR_BackCN.ini"
              },
              {
                label: "ACL4SSR_NoApple 本地 无苹果分流",
                value: "config/ACL4SSR_NoApple.ini"
              },
              {
                label: "ACL4SSR_NoAuto 本地 无自动测速 ",
                value: "config/ACL4SSR_NoAuto.ini"
              },
              {
                label: "ACL4SSR_NoAuto_NoApple 本地 无自动测速&amp;无苹果分流",
                value: "config/ACL4SSR_NoAuto_NoApple.ini"
              },
              {
                label: "ACL4SSR_NoMicrosoft 本地 无微软分流",
                value: "config/ACL4SSR_NoMicrosoft.ini"
              },
              {
                label: "ACL4SSR_WithGFW 本地 GFW列表",
                value: "config/ACL4SSR_WithGFW.ini"
              }
            ]
          },
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F01%2F25%2FC0t6Fx.png&amp;size=m" alt="插入效果"></p>
<h3 id="预览网页">预览网页</h3>
<p>配置完成后 执行<code>vue-cli-service serve</code><br>
  打开<code>http://localhost:8080/</code>进行查看</p>
<p>若显示正确即可<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F01%2F25%2Fdgh2Tp.png&amp;size=m" alt="网页预览"></p>
<h3 id="打包网页">打包网页</h3>
<p>运行打包命令<code>vue-cli-service build</code><br>
  编译完成后将<code>dist</code>中的文件上传至宝塔</p>
<h2 id="搭建sub-web后端">搭建Sub-Web后端</h2>
<h3 id="下载并解压后端程序">下载并解压后端程序</h3>
<pre><code class="language-shell">cd /root
wget https://github.com/tindy2013/subconverter/releases/download/v0.6.3/subconverter_linux64.tar.gz
tar -zxvf subconverter_linux64.tar.gz
</code></pre>
<p>完成以后，在 <code>/root</code> 文件夹下会多出一个 <code>subconverter</code> 的文件夹，这个就是我们的后端程序</p>
<h3 id="修改配置文件参数">修改配置文件参数</h3>
<p>现在我们需要修改后端配置文件中的一些参数</p>
<p>找到VPS文件 <code>/root/subconverter/pref.ini</code> ，找到如下参数进行修改</p>
<pre><code class="language-shell">api_access_token=123123dfsdsdfsdfsdf            #随意设置
managed_config_prefix=https://stcback.ccrui.cc  #设置成我们刚刚解析的后端域名
listen=127.0.0.1                                #这里改成 127.0.0.1 进行反代
</code></pre>
<h3 id="创建服务进程并启动">创建服务进程并启动</h3>
<p>接下来我们需要创建一个服务，让VPS每次重启或是开机自动运行后端程序</p>
<p>找到VPS目录 <code>/etc/systemd/system</code>，创建一个名为 <code>sub.service</code> 的文件</p>
<p>打开文件，贴入以下内容，保存。</p>
<pre><code class="language-shell">[Unit]
Description=A API For Subscription Convert
After=network.target
 
[Service]
Type=simple
ExecStart=/root/subconverter/subconverter
WorkingDirectory=/root/subconverter
Restart=always
RestartSec=10
 
[Install]
WantedBy=multi-user.target

</code></pre>
<p>检查运行状态以及设置开机自启</p>
<p><code>systemctl daemon-reload</code><br><code>systemctl start sub</code><br><code>systemctl enable sub</code><br><code>systemctl status sub</code></p>
<h3 id="反向代理">反向代理</h3>
<p>使用宝塔反向代理127.0.0.1:25500</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F01%2F25%2FCdhnVT.png&amp;size=m" alt="反向代理"></p>
<h3 id="搭建完成">搭建完成</h3>
<p>到这里，后端也就搭建完毕了，我们现在可以在浏览器里面访问我们的后端了 <code>https://stcback.ccrui.cc</code> （正常的话，会返回下面的图例）</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F01%2F25%2Fc7hKkk.png&amp;size=m" alt="图例"></p>
<h2 id="后记">后记</h2>
<p>到这里，我们也就搭建完毕了，大家可以在前端订阅自己的SSR/V2RAY/TROJAN机场链接或是自建的的节点链接进行转换了</p>
<p>转换成功以后，复制订阅地址，输入到浏览器，打开，会得到如下的画面</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2023%2F01%2F25%2FmZIpsD.png&amp;size=m" alt="订阅地址"></p>]]></description><guid isPermaLink="false">/archives/subweb-ding-yue-zhuan-huan-da-jian.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 24 Jan 2023 20:04:00 GMT</pubDate></item><item><title><![CDATA[Telegram MTProxy搭建教程]]></title><link>https://blog.ccrui.cn/archives/291.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Telegram%20MTProxy%E6%90%AD%E5%BB%BA%E6%95%99%E7%A8%8B&amp;url=/archives/291.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="什么是mtproxy">什么是MTProxy</h2>
<p>MTProxy是一款专门属于Telegram的代理服务，用户只需要在自己国外服务器上搭建这个服务，就可以不翻墙而直接使用Telegram</p>
<p>项目地址：<a href="https://github.com/TelegramMessenger/MTProxy">https://github.com/TelegramMessenger/MTProxy</a></p>
<h2 id="如何搭建-mtproxy-代理">如何搭建 MTProxy 代理</h2>
<p>在国外服务器上搭建 MTProxy 代理可以绕过互联网防火长城直接使用 Telegram，但此方式目前已经被针对，无法长时间使用，建议搭配白名单IP管理使用。</p>
<p>通过SSH工具连接到VPS，然后运行命令脚本。</p>
<p>脚本支持 Centos 7/8 、Ubuntu 16+、 Debian8/9系统，已通过 搬瓦工、Vultr、Digital Ocean、Linode、谷歌云等云服务器验证，可成功安装。</p>
<p>使用脚本前请确认你已知悉各类 Linux 基础命令。</p>
<h3 id="白名单-mtproxy-搭建方法请参考下方教程">白名单 MTProxy 搭建方法请参考下方教程：</h3>
<p><a href="https://hub.docker.com/r/ellermister/nginx-mtproxy">https://hub.docker.com/r/ellermister/nginx-mtproxy</a></p>
<h2 id="最新-mtproxy-go版搭建教程">最新 MTProxy Go版搭建教程：</h2>
<p>一键安装MTProxy Go版 9seconds/mtg ：</p>
<pre><code class="language-ssh">bash &lt;(curl -Ls https://cpp.li/mtg)
</code></pre>
<p>文章转自 <a href="https://mtproto.cc/1271">https://mtproto.cc/1271</a></p>]]></description><guid isPermaLink="false">/archives/291.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 7 Jan 2023 09:49:00 GMT</pubDate></item><item><title><![CDATA[解决Unity中RenderTexture转texture2d画面变暗的问题]]></title><link>https://blog.ccrui.cn/archives/287.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E8%A7%A3%E5%86%B3Unity%E4%B8%ADRenderTexture%E8%BD%ACtexture2d%E7%94%BB%E9%9D%A2%E5%8F%98%E6%9A%97%E7%9A%84%E9%97%AE%E9%A2%98&amp;url=/archives/287.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="问题截图">问题截图</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F12%2F26%2FUnity_AuIF8mD7Qp.png&amp;size=m" alt=""></p>
<h2 id="问题原因">问题原因</h2>
<p>在Unity中使用线性色彩空间的时候，由于editor创建RenderTexture的时候默认的sRGB是false的，所以导致所输出的内容是没有经过gamma矫正的，会导致生成的png变暗。</p>
<h2 id="解决办法">解决办法</h2>
<p>不通过editor创建，使用代码动态的构建</p>
<pre><code class="language-csharp">RenderTexture rt = new RenderTexture((int)rect.width, (int)rect.height, 0);
</code></pre>
<p>或者使用</p>
<pre><code class="language-csharp">RenderTexture rt = new RenderTexture(rt.width, rt.height, rt.depth, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
</code></pre>
<p>参考文章：<a href="https://blog.csdn.net/hakukou/article/details/123247360">https://blog.csdn.net/hakukou/article/details/123247360</a></p>]]></description><guid isPermaLink="false">/archives/287.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 26 Dec 2022 08:50:00 GMT</pubDate></item><item><title><![CDATA[批改网禁止粘贴破解 2022]]></title><link>https://blog.ccrui.cn/archives/pi-gai-wang-jin-zhi-zhan-tie-po-jie-2022.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E6%89%B9%E6%94%B9%E7%BD%91%E7%A6%81%E6%AD%A2%E7%B2%98%E8%B4%B4%E7%A0%B4%E8%A7%A3%202022&amp;url=/archives/pi-gai-wang-jin-zhi-zhan-tie-po-jie-2022.html" width="1" height="1" alt="" style="opacity:0;">
<p>前段时间发现以前使用的批改网破解粘贴的方法失效了，看了下源码，发现批改网将禁止粘贴的方法改为了直接监听粘贴事件，于是采用了复写监听事件的方式对新的禁止粘贴进行破解</p>
<p>代码如下：<br>
  浏览器F12选择控制台粘贴即可</p>
<pre><code class="language-js">document.onpaste= e=&gt;{}
</code></pre>]]></description><guid isPermaLink="false">/archives/pi-gai-wang-jin-zhi-zhan-tie-po-jie-2022.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 14 Nov 2022 19:02:00 GMT</pubDate></item><item><title><![CDATA[V2ray安装脚本]]></title><link>https://blog.ccrui.cn/archives/v2ray-an-zhuang-jiao-ben.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=V2ray%E5%AE%89%E8%A3%85%E8%84%9A%E6%9C%AC&amp;url=/archives/v2ray-an-zhuang-jiao-ben.html" width="1" height="1" alt="" style="opacity:0;">
<pre><code class="language-bash">bash &lt;(curl -s -L https://git.io/v2ray.sh)
</code></pre>]]></description><guid isPermaLink="false">/archives/v2ray-an-zhuang-jiao-ben.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 14 Nov 2022 01:15:00 GMT</pubDate></item><item><title><![CDATA[服务器探针部署]]></title><link>https://blog.ccrui.cn/archives/fu-wu-qi-tan-zhen-bu-shu.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%8E%A2%E9%92%88%E9%83%A8%E7%BD%B2&amp;url=/archives/fu-wu-qi-tan-zhen-bu-shu.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="前言">前言</h2>
<p><code>ServerStatus</code>是一款简单好用的中文服务器探针，可以用于简单快速的查看服务器状态</p>
<p><a href="https://blog.ccrui.cn/server.ccrui.cc">部署实例</a><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F11%2F14%2Fcfyqb4.jpg&amp;size=m" alt="部署图片"></p>
<h2 id="服务端">服务端</h2>
<p>部署第一步 
 <del>你需要先有一台服务器</del><br>
  如果需要监控的服务器有境外服务器，建议部署服务端的服务器也选择境外服务器</p>
<h3 id="一键部署脚本">一键部署脚本</h3>
<p>登录ssh后输入下方代码</p>
<pre><code class="language-bash">wget https://raw.githubusercontent.com/CokeMine/ServerStatus-Hotaru/master/status.sh &amp;&amp; chmod +x status.sh
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F11%2F14%2FZTR7lD.png&amp;size=m" alt="下载脚本"></p>
<h3 id="部署服务端">部署服务端</h3>
<pre><code class="language-bash">bash status.sh s
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F11%2F14%2F5YybXJ.png&amp;size=m" alt="部署服务端"></p>
<p>输入1开始安装即可</p>
<p>然后输入端口 这边端口需要记住 下面部署客户端的时候还需要用到<br>
  另外 别忘了放行服务器端口</p>
<p>接下来按照脚本提示输入即可</p>
<h3 id="增加客户端">增加客户端</h3>
<p>运行</p>
<pre><code class="language-bash">bash status.sh s
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F11%2F14%2Fdw67ej.png&amp;size=m" alt=""></p>
<p>选择7</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F11%2F14%2F8vnQLF.png&amp;size=m" alt=""></p>
<p>选择1 添加节点配置</p>
<p>根据提示输入 并记住输入的用户名[username]和密码</p>
<p>接下来我们就能在面板中看到这台服务器了<br>
  但是由于我们还没有部署客户端服务器 导致在面板上只会显示异常</p>
<h2 id="客户端">客户端</h2>
<h3 id="一键部署脚本-1">一键部署脚本</h3>
<p>登录ssh后输入下方代码</p>
<pre><code class="language-bash">wget https://raw.githubusercontent.com/CokeMine/ServerStatus-Hotaru/master/status.sh &amp;&amp; chmod +x status.sh
</code></pre>
<h3 id="设置客户端">设置客户端</h3>
<p>运行</p>
<pre><code class="language-bash">bash status.sh c
</code></pre>
<p>根据上文中服务端中输入的配置 对客户端进行配置</p>]]></description><guid isPermaLink="false">/archives/fu-wu-qi-tan-zhen-bu-shu.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 14 Nov 2022 01:00:00 GMT</pubDate></item><item><title><![CDATA[OneDrive for Business直链提取]]></title><link>https://blog.ccrui.cn/archives/onedrive-for-business-zhi-lian-ti-qu.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=OneDrive%20for%20Business%E7%9B%B4%E9%93%BE%E6%8F%90%E5%8F%96&amp;url=/archives/onedrive-for-business-zhi-lian-ti-qu.html" width="1" height="1" alt="" style="opacity:0;">
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F10%2F09%2Ff5NEQu.png&amp;size=m" alt="直链获取"></p>
<h2 id="原理">原理</h2>
<p>原链接：<a href="https://xxxx-my.sharepoint.com/:x:/g/personal/xx_xx_xx/xxxxxxxxxx">https://xxxx-my.sharepoint.com/:x:/g/personal/xx_xx_xx/xxxxxxxxxx</a></p>
<p>直链：<a href="https://xxxx-my.sharepoint.com/personal/xx_xx_xx/_layouts/52/download.aspx?share=xxxxxxxxxx%EF%BC%88%E8%BF%99%E4%B8%80%E7%A7%8D%E6%9B%B4%E6%9C%89%E6%95%88%EF%BC%89">https://xxxx-my.sharepoint.com/personal/xx_xx_xx/_layouts/52/download.aspx?share=xxxxxxxxxx（这一种更有效）</a></p>
<p>或：<a href="https://xxxx-my.sharepoint.com/:x:/g/personal/xx_xx_xx/xxxxxxxxxx?download=1%EF%BC%88%E8%BF%99%E6%98%AF%E9%87%8D%E5%AE%9A%E5%90%91%E8%B7%B3%E8%BD%AC%E8%87%B3%E7%9B%B4%E9%93%BE%EF%BC%89">https://xxxx-my.sharepoint.com/:x:/g/personal/xx_xx_xx/xxxxxxxxxx?download=1（这是重定向跳转至直链）</a></p>
<p>建议使用第一种直链方式</p>
<h2 id="c实现">C#实现</h2>
<pre><code class="language-csharp">//获取xxxx-my.sharepoint.com (域名)
var domainName = Regex.Match(url, @"(?&lt;=://)(.*?)(?=/)").Value;

//获取:x: (文件类型)
var fileType = Regex.Match(url, $"(?&lt;=/{domainName}/:)(.*?)(?=:/)").Value;

//获取xx_xx_xx (组织名_用户名)
var organizationName = Regex.Match(url, @"(?&lt;=/personal/)(.*?)(?=/)").Value;

//获取xxxxxxxxxx (文件ID)
var fileId = Regex.Match(url, $"(?&lt;=/{organizationName}/).+").Value;

string newUrl = "";

if (string.IsNullOrEmpty(domainName) || string.IsNullOrEmpty(fileType) || string.IsNullOrEmpty(organizationName) || string.IsNullOrEmpty(fileId))
{
    newUrl = "请输入正确链接";
}
else if (fileType == "f")
{
    newUrl = "抱歉，你所输入链接分享的是文件夹，直链生成仅对单文件有效。";
}
else
{
    newUrl = $"https://{domainName}/personal/{organizationName}/_layouts/52/download.aspx?share={fileId}";
}
</code></pre>
<h2 id="云函数">云函数</h2>
<p>使用微软云函数，通过Get方法或Post方法进行调用</p>
<blockquote>
 <p>Get: <a href="https://getonedrivelink.azurewebsites.net/api/GetLink?url=%7Burl%7D">https://getonedrivelink.azurewebsites.net/api/GetLink?url={url}</a><br>
   Post: <a href="https://getonedrivelink.azurewebsites.net/api/GetLink">https://getonedrivelink.azurewebsites.net/api/GetLink</a> Body:{"url":{url}}</p>
</blockquote>
<h2 id="在线调用">在线调用</h2>
<p><a href="https://onedrivelink.ccrui.cn/">https://onedrivelink.ccrui.cn/</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F10%2F09%2FdtHSsx.png&amp;size=m" alt="在线调用"></p>]]></description><guid isPermaLink="false">/archives/onedrive-for-business-zhi-lian-ti-qu.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 9 Oct 2022 07:32:00 GMT</pubDate></item><item><title><![CDATA[C#扩展工具类]]></title><link>https://blog.ccrui.cn/archives/ckuo-zhan-gong-ju-lei.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=C%23%E6%89%A9%E5%B1%95%E5%B7%A5%E5%85%B7%E7%B1%BB&amp;url=/archives/ckuo-zhan-gong-ju-lei.html" width="1" height="1" alt="" style="opacity:0;">
<p>本脚本实用C#扩展方法，对C#原有方法进行一定扩展</p>
<h2 id="实现功能">实现功能</h2>
<ul>
 <li>链式调用</li>
 <li>md5计算</li>
 <li>string转int、float、double</li>
 <li>判断字符串是否为邮箱、手机号、身份证号、url、ipv4、ipv6、是否包含中文、是否是英文、是否是大写英文、是否是小写英文</li>
 <li>获取时间戳</li>
 <li>时间差计算</li>
</ul>
<h2 id="使用">使用</h2>
<blockquote>
 <p><a href="https://ccrui-my.sharepoint.com/:u:/g/personal/ccrui_ccrui_cn/EX8FdOWciutIsM3W-MSzVxEBkSIuh-hu4RbkRfOWqKReqg?e=GjaINM">下载地址</a></p>
</blockquote>
<pre><code class="language-csharp">using System.Text;
using System.Text.RegularExpressions;

namespace Tool;

public static class Expand
{
    # region 链式调用

    /// &lt;summary&gt;
    /// 链式调用
    /// &lt;/summary&gt;
    /// &lt;param name="t"&gt;自身传递&lt;/param&gt;
    /// &lt;param name="action"&gt;委托调用&lt;/param&gt;
    /// &lt;typeparam name="T"&gt;自身类&lt;/typeparam&gt;
    /// &lt;returns&gt;自身传出&lt;/returns&gt;
    public static T Do&lt;T&gt;(this T t, Action&lt;T&gt; action)
    {
        action(t);
        return t;
    }

    #endregion

    #region md5计算

    /// &lt;summary&gt;
    /// 计算md5值
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;自身传递&lt;/param&gt;
    /// &lt;param name="toUpper"&gt;是否为大写&lt;/param&gt;
    /// &lt;param name="to16"&gt;是否为16位md5&lt;/param&gt;
    /// &lt;returns&gt;md5&lt;/returns&gt;
    public static string ToMd5(this string str, bool toUpper = false, bool to16 = false)
    {
        //将str进行MD5加密
        var md5 = System.Security.Cryptography.MD5.Create();
        var bs = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
        var sb = new StringBuilder();
        foreach (var b in bs)
        {
            sb.Append(b.ToString(toUpper ? "X2" : "x2"));
        }

        return to16 ? sb.ToString().Substring(8, 16) : sb.ToString();
    }

    /// &lt;summary&gt;
    /// 计算md5值
    /// &lt;/summary&gt;
    /// &lt;param name="bytes"&gt;自身传递&lt;/param&gt;
    /// &lt;param name="toUpper"&gt;是否为大写&lt;/param&gt;
    /// &lt;param name="to16"&gt;是否为16位md5&lt;/param&gt;
    /// &lt;returns&gt;md5&lt;/returns&gt;
    public static string ToMd5(this byte[] bytes, bool toUpper = false, bool to16 = false)
    {
        var md5 = System.Security.Cryptography.MD5.Create();
        var bs = md5.ComputeHash(bytes);
        var sb = new StringBuilder();
        foreach (var b in bs)
        {
            sb.Append(b.ToString(toUpper ? "X2" : "x2"));
        }

        return to16 ? sb.ToString().Substring(8, 16) : sb.ToString();
    }

    #endregion

    #region 字符串转换

    /// &lt;summary&gt;
    /// string转int
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;自身传递&lt;/param&gt;
    /// &lt;returns&gt;int值&lt;/returns&gt;
    /// &lt;exception cref="Exception"&gt;转换失败&lt;/exception&gt;
    public static int ToInt(this string str)
    {
        return int.TryParse(str, out var result) ? result : throw new Exception("string转换为int失败");
    }

    /// &lt;summary&gt;
    /// string转float
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;自身传递&lt;/param&gt;
    /// &lt;returns&gt;float值&lt;/returns&gt;
    /// &lt;exception cref="Exception"&gt;转换失败&lt;/exception&gt;
    public static float ToFloat(this string str)
    {
        return float.TryParse(str, out var result) ? result : throw new Exception("string转换为float失败");
    }

    /// &lt;summary&gt;
    /// string转double
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;自身传递&lt;/param&gt;
    /// &lt;returns&gt;double值&lt;/returns&gt;
    /// &lt;exception cref="Exception"&gt;转换失败&lt;/exception&gt;
    public static double ToDouble(this string str)
    {
        return double.TryParse(str, out var result) ? result : throw new Exception("string转换为double失败");
    }

    #endregion

    #region 字符串格式判断

    /// &lt;summary&gt;
    /// 判断是否是Email格式
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;自身传递&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsEmail(this string str)
    {
        return Regex.IsMatch(str,
            @"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$");
    }

    /// &lt;summary&gt;
    /// 判断是否是手机号格式
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;自身传递&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsMobile(this string str)
    {
        return Regex.IsMatch(str, @"^1[3456789]\d{9}$");
    }

    /// &lt;summary&gt;
    /// 判断是否是身份证号格式
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;自身传递&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsIdCard(this string str)
    {
        return Regex.IsMatch(str,
            @"^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X|x)$");
    }

    /// &lt;summary&gt;
    /// 判断是否是Url格式
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;自身传递&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsUrl(this string str)
    {
        return Regex.IsMatch(str,
            @"^(http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9%\-_@]+\.[A-Za-z0-9%\-_@]+[A-Za-z0-9\.\/=\?%\-&amp;_~`@:\+!;]*$");
    }

    /// &lt;summary&gt;
    /// 判断是否是ipv4格式
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsIpv4(this string str)
    {
        return Regex.IsMatch(str, @"^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$");
    }

    /// &lt;summary&gt;
    /// 判断是否是ipv6格式
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsIpv6(this string str)
    {
        return Regex.IsMatch(str,
            @"^([\da-fA-F]{1,4}:){6}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^::([\da-fA-F]{1,4}:){0,4}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:):([\da-fA-F]{1,4}:){0,3}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){2}:([\da-fA-F]{1,4}:){0,2}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){3}:([\da-fA-F]{1,4}:){0,1}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){4}:((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){7}[\da-fA-F]{1,4}$|^:((:[\da-fA-F]{1,4}){1,6}|:)$|^[\da-fA-F]{1,4}:((:[\da-fA-F]{1,4}){1,5}|:)$|^([\da-fA-F]{1,4}:){2}((:[\da-fA-F]{1,4}){1,4}|:)$|^([\da-fA-F]{1,4}:){3}((:[\da-fA-F]{1,4}){1,3}|:)$|^([\da-fA-F]{1,4}:){4}((:[\da-fA-F]{1,4}){1,2}|:)$|^([\da-fA-F]{1,4}:){5}:([\da-fA-F]{1,4})?$|^([\da-fA-F]{1,4}:){6}:$");
    }

    /// &lt;summary&gt;
    /// 判断是否是ip格式
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsIp(this string str)
    {
        return Regex.IsMatch(str,
            @"^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){6}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^::([\da-fA-F]{1,4}:){0,4}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:):([\da-fA-F]{1,4}:){0,3}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){2}:([\da-fA-F]{1,4}:){0,2}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){3}:([\da-fA-F]{1,4}:){0,1}((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){4}:((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$|^([\da-fA-F]{1,4}:){7}[\da-fA-F]{1,4}$|^:((:[\da-fA-F]{1,4}){1,6}|:)$|^[\da-fA-F]{1,4}:((:[\da-fA-F]{1,4}){1,5}|:)$|^([\da-fA-F]{1,4}:){2}((:[\da-fA-F]{1,4}){1,4}|:)$|^([\da-fA-F]{1,4}:){3}((:[\da-fA-F]{1,4}){1,3}|:)$|^([\da-fA-F]{1,4}:){4}((:[\da-fA-F]{1,4}){1,2}|:)$|^([\da-fA-F]{1,4}:){5}:([\da-fA-F]{1,4})?$|^([\da-fA-F]{1,4}:){6}:$");
    }

    /// &lt;summary&gt;
    /// 判断是否包含中文
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsChinese(this string str)
    {
        return Regex.IsMatch(str, @"[\u4e00-\u9fa5]");
    }

    /// &lt;summary&gt;
    /// 判断是否是中文姓名格式
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsChineseName(this string str)
    {
        return Regex.IsMatch(str, @"^[\u4e00-\u9fa5]{2,4}$");
    }

    /// &lt;summary&gt;
    /// 判断是否是英文
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsEnglish(this string str)
    {
        return Regex.IsMatch(str, @"^[A-Za-z]+$");
    }

    /// &lt;summary&gt;
    /// 判断是否是大写英文
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsUpperEnglish(this string str)
    {
        return Regex.IsMatch(str, @"^[A-Z]+$");
    }

    /// &lt;summary&gt;
    /// 判断是否是小写英文
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static bool IsLowerEnglish(this string str)
    {
        return Regex.IsMatch(str, @"^[a-z]+$");
    }

    #endregion

    #region 敏感信息处理

    /// &lt;summary&gt;
    /// 身份证号码脱敏
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static string MaskIdCard(this string str)
    {
        return str.IsIdCard()
            ? str.Substring(0, 6) + "********" + str.Substring(14, 4)
            : throw new Exception("不是有效的身份证号码");
    }

    /// &lt;summary&gt;
    /// 手机号码脱敏
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    /// &lt;exception cref="Exception"&gt;&lt;/exception&gt;
    public static string MaskMobile(this string str)
    {
        return str.IsMobile()
            ? str.Substring(0, 3) + "****" + str.Substring(7, 4)
            : throw new Exception("不是有效的手机号码");
    }

    /// &lt;summary&gt;
    /// 邮箱脱敏
    /// &lt;/summary&gt;
    /// &lt;param name="str"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    /// &lt;exception cref="Exception"&gt;&lt;/exception&gt;
    public static string MaskEmail(this string str)
    {
        return str.IsEmail()
            ? str.Substring(0, 3) + "****" + str.Substring(str.IndexOf('@'))
            : throw new Exception("不是有效的邮箱地址");
    }

    #endregion

    #region 时间戳转换

    /// &lt;summary&gt;
    /// 获取毫秒级时间戳
    /// &lt;/summary&gt;
    /// &lt;param name="dt"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static double GetTotalMilliseconds(this DateTime dt)
    {
        return (dt - new DateTime(1970, 1, 1)).TotalMilliseconds;
    }

    /// &lt;summary&gt;
    /// 获取秒级时间戳
    /// &lt;/summary&gt;
    /// &lt;param name="dt"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static double GetTotalSeconds(this DateTime dt)
    {
        return (dt - new DateTime(1970, 1, 1)).TotalSeconds;
    }

    /// &lt;summary&gt;
    /// 毫秒级时间戳转换为DateTime
    /// &lt;/summary&gt;
    /// &lt;param name="timestamp"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static DateTime ToDateTimeMilliseconds(this double timestamp)
    {
        return new DateTime(1970, 1, 1).AddMilliseconds(timestamp);
    }

    /// &lt;summary&gt;
    /// 秒级时间戳转换为DateTime
    /// &lt;/summary&gt;
    /// &lt;param name="timestamp"&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public static DateTime ToDateTimeSeconds(this double timestamp)
    {
        return new DateTime(1970, 1, 1).AddSeconds(timestamp);
    }

    /// &lt;summary&gt;
    /// 获取时间差
    /// &lt;/summary&gt;
    /// &lt;param name="dt"&gt;&lt;/param&gt;
    /// &lt;param name="dt2"&gt;传入时间&lt;/param&gt;
    /// &lt;returns&gt;返回时间差 小于0为在之前，大于0为在之后 &lt;/returns&gt;
    public static TimeSpan GetTimeDifference(this DateTime dt, DateTime dt2 = default)
    {
        return dt - (dt2 == default(DateTime) ? DateTime.UtcNow : dt2);
    }

    #endregion
}
</code></pre>]]></description><guid isPermaLink="false">/archives/ckuo-zhan-gong-ju-lei.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 1 Sep 2022 21:43:00 GMT</pubDate></item><item><title><![CDATA[C# linq语法]]></title><link>https://blog.ccrui.cn/archives/c-linq-yu-fa.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=C%23%20linq%E8%AF%AD%E6%B3%95&amp;url=/archives/c-linq-yu-fa.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="linq是什么">linq是什么</h2>
<p>LINQ（Language Integrated Query )语言集成查询，是一组用于C#和VB语言的拓展，它允许VB或者C#代码以操作内存数据的方式，查询数据库。</p>
<h2 id="linq使用的优点">LINQ使用的优点：</h2>
<ol>
 <li>无需复杂学习过程即可上手。</li>
 <li>编写更少代码即可创建完整应用。</li>
 <li>更快开发错误更少的应用程序。</li>
 <li>无需求助奇怪的编程技巧就可合并数据源。</li>
 <li>能够大幅减少过程控制语句的代码块，使代码的可读性和可维护性大幅提高。</li>
 <li>任何对象或数据源都可以定制实现LINQ适配器，为数据交互带来真正方便。</li>
</ol>
<h2 id="linq-语法">linq 语法</h2>
<p>linq语法分为查询语句，类似SQL语法 和方法语法</p>
<p>查询语句：</p>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var list = from a in nums
    where a % 2 == 0
    orderby a descending
    select a; //linq的第一种写法
</code></pre>
<p>方法语法：</p>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var list2 = nums
    .Where(a =&gt; a % 2 == 0)
    .OrderByDescending(a =&gt; a)
    .Select(a =&gt; a); //linq的第二种写法
</code></pre>
<p>我个人比较喜欢方法语法 故下面的演示代码均采用方法语法书写</p>
<h2 id="语法详解">语法详解</h2>
<h3 id="查询-where">查询 Where</h3>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var list2=nums
    //查询数据源中
    .Where(a =&gt; a % 2 == 0)//查询数据源中的偶数
</code></pre>
<h3 id="制定key查询-select">制定Key查询 Select</h3>
<pre><code class="language-csharp">private List&lt;DataTest&gt; _dataTests = new List&lt;DataTest&gt;()
{
    new DataTest()
    {
        name = "小张",
        age = 18,
        Address = "北京"
    },
    new DataTest()
    {
        name = "小李",
        age = 19,
        Address = "上海"
    },
    new DataTest()
    {
        name = "小王",
        age = 20,
        Address = "北京"
    },
};//数据源
var select = _dataTests.Select(i =&gt; i.name);
</code></pre>
<p>输出：<code>小张 小李 小王</code></p>
<h3 id=""></h3>
<h3 id="函数计算-count-min-max-sum">函数计算 count min max sum</h3>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var count= nums.Count();//获取数据源内元素的数量
</code></pre>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var min = nums.Min(i =&gt; i);//获取数据源内的元素最小值
</code></pre>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var sum = nums.Sum(i =&gt; i); //求和
</code></pre>
<h3 id="排序-orderby-orderbydescending">排序 OrderBy OrderByDescending</h3>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var OrderBy = nums.OrderBy(a =&gt; a); //升序
var OrderByDescending = nums.OrderByDescending(a =&gt; a); //降序
</code></pre>
<h3 id="取第一个满足的数据-first-firstordefault">取第一个满足的数据 First FirstOrDefault</h3>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var FirstOrDefault = nums.FirstOrDefault(i =&gt; i &gt; 5); //取出第一个大于5的数据 如果没有则返回默认值
var First = nums.First(i =&gt; i &gt; 5); //取出第一个大于5的数据
</code></pre>
<h3 id="跳过前面的数据-skip">跳过前面的数据 Skip</h3>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var a = nums.Skip(2); //跳过前2个元素
</code></pre>
<p>输出：<code>4 5 6 7</code></p>
<h3 id="取前几条数据-take">取前几条数据 Take</h3>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var a = nums.Take(4); //取前4条数据
</code></pre>
<p>输出：<code>1 2 4 5</code></p>
<h3 id="分页-skip---take">分页 Skip - Take</h3>
<pre><code class="language-csharp">Int[] nums={1,2,4,5,6,7};//数据源
var a = nums
    .Skip(2).Take(2);//取2-4条的数据
</code></pre>
<p>输出：<code>4 5</code></p>
<h3 id="模糊查询-contains">模糊查询 Contains</h3>
<pre><code class="language-csharp">private List&lt;DataTest&gt; _dataTests = new List&lt;DataTest&gt;()
{
    new DataTest()
    {
        name = "小张",
        age = 18,
        Address = "北京"
    },
    new DataTest()
    {
        name = "小李",
        age = 19,
        Address = "上海"
    }
};//数据源
    
var d = _dataTests.Where(s =&gt; s.name.Contains("张"));//模糊查询名称中包含张的数据
</code></pre>
<p>输出：<code>名字：小张 年龄：18 地址：北京</code></p>
<h3 id="分组-groupby-遍历-foreach">分组 GroupBy 遍历 ForEach</h3>
<pre><code class="language-csharp">private List&lt;DataTest&gt; _dataTests = new List&lt;DataTest&gt;()
{
    new DataTest()
    {
        name = "小张",
        age = 18,
        Address = "北京"
    },
    new DataTest()
    {
        name = "小李",
        age = 19,
        Address = "上海"
    },
    new DataTest()
    {
        name = "小王",
        age = 20,
        Address = "北京"
    },
};//数据源
    
var d = _dataTests.GroupBy(a =&gt; a.Address);//分组
//遍历 
d.ToList().ForEach(a =&gt;
{
    Console.WriteLine(a.Key);
    a.ToList().ForEach(b =&gt;
    {
        Console.WriteLine(b.name);
    });
});
</code></pre>
<p>输出：<code>北京 小张 小王 上海 小李 </code></p>
<blockquote>
 <p>参考 <a href="https://www.cnblogs.com/sxjljj/p/11348652.html#:~:text=C%23%20LINQ%E8%AF%AD%E6%B3%95%E8%AF%A6%E8%A7%A3%201.%E7%AE%80%E5%8D%95%E7%9A%84linq%E8%AF%AD%E6%B3%95%20%2F%2F1%20var%20ss%20%3D%20from,string%20sssql%20%3D%20%22select%20%2A%20from%20Am_recProScheme%22%3B%202.%E5%B8%A6where%E7%9A%84%E6%9F%A5%E8%AF%A2">博客园</a> <a href="https://zhuanlan.zhihu.com/p/82374938">知乎</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/c-linq-yu-fa.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 1 Sep 2022 00:52:00 GMT</pubDate></item><item><title><![CDATA[C# 拓展方法]]></title><link>https://blog.ccrui.cn/archives/c-ta-zhan-fang-fa.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=C%23%20%E6%8B%93%E5%B1%95%E6%96%B9%E6%B3%95&amp;url=/archives/c-ta-zhan-fang-fa.html" width="1" height="1" alt="" style="opacity:0;">
<p>扩展方法是C#3.0引入的新特性，使用它，可以在不修改某一类的代码的情况下，实现该类方法的扩展。</p>
<p>为一个类添加扩展方法，需要三个要素：</p>
<ol>
 <li>
  <p>扩展方法所在的类为静态类</p></li>
 <li>
  <p>扩展方法本身要为静态方法</p></li>
 <li>
  <p>扩展方法的第一个参数要用关键字this，指向要扩展的类</p></li>
</ol>
<h2 id="定义">定义</h2>
<pre><code class="language-csharp">public static class Expand
{
    public static string ToMd5_32(this string str)
    {
        var md5 = System.Security.Cryptography.MD5.Create();
        var bs = md5.ComputeHash(Encoding.UTF8.GetBytes(str));
        var sb = new StringBuilder();
        foreach (var b in bs)
        {
            sb.Append(b.ToString("x2"));
        }
        return sb.ToString();
    }
    
}
</code></pre>
<p>这个方法是服务于string类型的，返回其md5的值</p>
<h2 id="使用">使用</h2>
<p>调用方法也非常简单</p>
<pre><code class="language-csharp">string strTest = "Hello World!";

var md5Str = strTest.ToMd5_32();

Console.WriteLine(md5Str);
</code></pre>
<p>控制台输出：</p>
<pre><code class="language-text">ed076287532e86365e841e92bfc50d8c
</code></pre>
<h2 id="结尾">结尾</h2>
<p>这种灵活的方式，可以让我们的开发更便捷，但是不要滥用扩展方法，当扩展方法与类原始的方法重名时，原始方法的优先级高于扩展方法，并且对于系统类，不要随便添加扩展方法。</p>]]></description><guid isPermaLink="false">/archives/c-ta-zhan-fang-fa.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 31 Aug 2022 23:39:00 GMT</pubDate></item><item><title><![CDATA[C# 链式调用]]></title><link>https://blog.ccrui.cn/archives/c-lian-shi-diao-yong.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=C%23%20%E9%93%BE%E5%BC%8F%E8%B0%83%E7%94%A8&amp;url=/archives/c-lian-shi-diao-yong.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="如何定义">如何定义</h2>
<h3 id="方法1">方法1</h3>
<p>定义方法时，将方法的返回值设置为其本身类</p>
<pre><code class="language-csharp">public class Test
{
    public Test A1()
    {
        Console.WriteLine("A1");
        return this;
    }
    
    public Test A2()
    {
        Console.WriteLine("A2");
        return this;
    }
    
    public Test A3()
    {
        Console.WriteLine("A3");
        return this;
    }
}
</code></pre>
<h3 id="方法2">方法2</h3>
<p>正常定义方法，并使用扩展方法将需要链式调用的方法类进行扩展</p>
<pre><code class="language-csharp">public class Test
{
    public void A1()
    {
        Console.WriteLine("A1");
    }
    
    public void A2()
    {
        Console.WriteLine("A2");
    }
    
    public void A3()
    {
        Console.WriteLine("A3");
    }
}
</code></pre>
<pre><code class="language-csharp">public static class Expand
{
    public static Test Do(this Test t, Action&lt;Test&gt; action)
    {
        action(t);
        return t;
    }
}
</code></pre>
<p>或使用泛型拓展</p>
<pre><code class="language-csharp">public static class Expand
{
    public static T Do&lt;T&gt;(this T t, Action&lt;T&gt; action)
    {
        action(t);
        return t;
    }
}
</code></pre>
<h2 id="如何调用">如何调用</h2>
<h3 id="方法1-1">方法1</h3>
<pre><code class="language-csharp">new Test()
    .A1()
    .A2()
    .A3();
</code></pre>
<h3 id="方法2-1">方法2</h3>
<pre><code class="language-csharp">new Test()
    .Do(s =&gt; s.A1())
    .Do(s =&gt; s.A2())
    .Do(s =&gt; s.A3());
</code></pre>]]></description><guid isPermaLink="false">/archives/c-lian-shi-diao-yong.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 31 Aug 2022 23:29:00 GMT</pubDate></item><item><title><![CDATA[微信公众号每日卡片推送]]></title><link>https://blog.ccrui.cn/archives/wechatdailypush.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%BE%AE%E4%BF%A1%E5%85%AC%E4%BC%97%E5%8F%B7%E6%AF%8F%E6%97%A5%E5%8D%A1%E7%89%87%E6%8E%A8%E9%80%81&amp;url=/archives/wechatdailypush.html" width="1" height="1" alt="" style="opacity:0;">
<p>本项目为微信公众号每日卡片推送服务<br><a href="https://github.com/cr-zhichen/WechatDailyPush">项目源码</a> <a href="https://github.com/cr-zhichen/WechatDailyPush/releases">可执行文件下载</a></p>
<h2 id="完成效果">完成效果</h2>
<p>每日10点30分进行自动推送<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F27%2FWechatIMG14.jpg&amp;size=m" alt="定时推送"></p>
<p>每次向测试号发送消息时，进行一次推送<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F27%2FWechatIMG15.jpg&amp;size=m" alt="被动推送"></p>
<h2 id="准备工作">准备工作</h2>
<ol>
 <li>一个具有公网ip的服务器</li>
 <li>申请<a href="https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login">微信公众平台测试号</a></li>
 <li>申请<a href="https://lbs.amap.com/dev/key/app">高德天气接口key</a></li>
</ol>
<h2 id="部署方式">部署方式</h2>
<p>下载构建完成的<a href="https://github.com/cr-zhichen/WechatDailyPush/releases">可执行文件</a><br>
  修改<code>./Configuration/config.json</code>配置文件</p>
<h3 id="配置文件">配置文件</h3>
<p>定时执行<br>
  示例为每日10点30分执行推送</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F27%2FpJaVYW.png&amp;size=m" alt="定时执行"></p>
<p>基础信息</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F27%2FHgfuih.png&amp;size=m" alt="基础信息"></p>
<p>微信信息</p>
<p>需在微信测试号平台上传测试模板</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F27%2FJamk4d.png&amp;size=m" alt="测试模板"></p>
<pre><code>{{first.DATA}}

城市：{{city.DATA}}
实况天气：{{weather.DATA}}
气温：{{nowTemperature.DATA}}
风速：{{wind.DATA}}
湿度：{{wet.DATA}}
今天天气：{{day1_wea.DATA}}
明天天气：{{day2_wea.DATA}}
后天天气：{{day3_wea.DATA}}

♥遇见♥: {{meetDate.DATA}}
♥在一起♥: {{togetherDate.DATA}}

距离{{name1.DATA}}生日：{{birthDate1.DATA}}
距离{{name2.DATA}}生日：{{birthDate2.DATA}}
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F27%2FurhRDg.png&amp;size=m" alt="微信信息"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F27%2FFtPcC6.png&amp;size=m" alt="微信信息2"></p>
<p>第三方信息</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F27%2FSqtrkk.png&amp;size=m" alt="第三方信息"></p>
<h3 id="部署服务器">部署服务器</h3>
<p>将下载的文件夹上传到服务器 进入文件夹根路径后直接执行<code>WechatPublicAccount</code>文件即可 服务器监听端口为5000</p>
<p>若服务器为非Linux-x86 则需要下载<code>Portable-net6.0</code>版本 并在服务器安装<a href="https://dotnet.microsoft.com/zh-cn/download">.net6运行时</a><br>
  安装完成后即可在文件夹根目录执行<code>dotnet WechatPublicAccount.dll</code> 服务器监听端口为5000</p>
<p>也可直接使用宝塔面板进行部署</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F27%2Fwi4oJp.png&amp;size=m" alt="宝塔部署"></p>
<h2 id="完成部署并测试">完成部署并测试</h2>
<p>在微信公众平台上填写服务器域名 若绑定域名为 <code>wx.ccrui.cn</code>则需要填写<code>http://wx.ccrui.cn/wx</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F27%2FmAVNPu.png&amp;size=m" alt="填写域名"></p>
<p>绑定完成后，向微信测试号中随便发一条消息 测试号会回应该条消息并推送每日卡片<br>
  每日的设定时间，微信会向配置文件中的全部用户进行一次推送</p>]]></description><guid isPermaLink="false">/archives/wechatdailypush.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 26 Aug 2022 23:29:00 GMT</pubDate></item><item><title><![CDATA[Unity国际版forM1Mac]]></title><link>https://blog.ccrui.cn/archives/unity-guo-ji-banform1mac.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity%E5%9B%BD%E9%99%85%E7%89%88forM1Mac&amp;url=/archives/unity-guo-ji-banform1mac.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="为什么要使用国际版">为什么要使用国际版</h2>
<p>相比于国内特供版Unity而言，国际版Unity为去壳版本，在稳定性上比国内特供版更好，不会出现一些奇奇怪怪的bug</p>
<h2 id="下载地址">下载地址</h2>
<p><a href="https://unity3d.com/unity/qa/lts-releases">LTS版本</a></p>
<h2 id="m1mac下载问题">m1Mac下载问题</h2>
<p>在mac电脑上Unity分为Intel版本和Apple版本</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F24%2F16613128677533.jpg&amp;size=m" alt="16613128677533"></p>
<p>当使用上文下载链接直接调用UnityHub下载时会显示直接下载intel版本的Unity 并且无法进行选择</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F24%2F16613129711163.jpg&amp;size=m" alt="16613129711163"></p>
<p>通过<code>Unity Editor (Apple silicon)</code> 下载的方式可以单独下载安装适配m1芯片的Unity，但无法通过Unity安装插件</p>
<p>于是可通过下面的链接筛选对应Unity版本单独下载插件并安装</p>
<p><a href="https://unity3d.com/unity/whats-new/2021.3.8">全部模块</a></p>
<h2 id="汉化问题">汉化问题</h2>
<h3 id="汉化下载">汉化下载</h3>
<p>在上文链接中会发现Unity没有提供语言包可供选择</p>
<p>可访问<code>https://new-translate.unity3d.jp/v1/live/54/版本号/zh-hans</code><br>
  进行下载</p>
<blockquote>
 <p>注 版本号示例 2021.3.8f1 要写成2021.3 后面的子版本号需要省略</p>
</blockquote>
<p>Unity并没有公开给出汉化包的链接，官网是找不到的，这个链接应该是为UnityHub安装汉化包用的。</p>
<p>如果这个链接打不开，可以二维码分享给手机，然后用微信扫码下载，再发给电脑。</p>
<h3 id="汉化安装">汉化安装</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F24%2F16613134157783.jpg&amp;size=m" alt="16613134157783"></p>
<p>找到以下目录</p>
<p><code>/Applications/Unity/Unity.app/Contents</code></p>
<p>建立文件夹 <code>Localization</code></p>
<p>然后把下载的 <code>zh-hans.po</code> 文件拖进去</p>
<p>重启Unity</p>
<p>在Preferences-Language处更改语言</p>]]></description><guid isPermaLink="false">/archives/unity-guo-ji-banform1mac.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 23 Aug 2022 19:44:00 GMT</pubDate></item><item><title><![CDATA[MWeb pro使用教程]]></title><link>https://blog.ccrui.cn/archives/mweb-pro.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=MWeb%20pro%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B&amp;url=/archives/mweb-pro.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="mweb简介">MWeb简介</h2>
<p>MWeb Pro 是一款适用于macOS的专业Markdown写作、笔记本应用软件。喜欢写博客的朋友，那你一定会需要 MWeb Pro 破解版这款软件。为您提供最佳的写作体验。</p>
<h2 id="下载地址">下载地址</h2>
<p><a href="https://zh.mweb.im/index.html">官网下载</a><br><a href="https://www.macwk.com/soft/mweb-pro">破解下载</a></p>
<h2 id="上传chevereto图床">上传Chevereto图床</h2>
<p>打开<code>偏好设置-发布服务</code><br>
  选择<code>自定义</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F19%2F16608933846309.jpg&amp;size=m" alt="16608933846309"></p>
<p>填写对应信息并保存后<br>
  在编写过程中点击上传图片 并勾选上传完成后复制MarkDown语法选项即可在正文进行粘贴<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F19%2F16608934960122.jpg&amp;size=m" alt="16608934960122"></p>
<h2 id="上传typora博客服务">上传Typora博客服务</h2>
<h3 id="配置博客服务">配置博客服务</h3>
<p>打开<code>偏好设置-发布服务</code><br>
  选择<code>MetaweblogAPI</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F19%2F16608936330413.jpg&amp;size=m" alt="16608936330413"></p>
<p>输入博客地址 后台账号以及密码</p>
<h3 id="api地址获取">API地址获取</h3>
<p>进入博客首页 右键点击空白处<br>
  选择<code>查看页面源代码</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F19%2F16608937307329.jpg&amp;size=m" alt="16608937307329"></p>
<p>将下图中为需要输入的API地址</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F19%2F16608937954488.jpg&amp;size=m" alt="16608937954488"></p>
<h3 id="将文章上传至博客">将文章上传至博客</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F19%2F16608938865982.jpg&amp;size=m" alt="16608938865982"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F08%2F19%2F16608939083019.jpg&amp;size=m" alt="16608939083019"></p>
<p>选择后发布即可</p>]]></description><guid isPermaLink="false">/archives/mweb-pro.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 19 Aug 2022 01:11:00 GMT</pubDate></item><item><title><![CDATA[mac如何关闭鼠标加速]]></title><link>https://blog.ccrui.cn/archives/273.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=mac%E5%A6%82%E4%BD%95%E5%85%B3%E9%97%AD%E9%BC%A0%E6%A0%87%E5%8A%A0%E9%80%9F&amp;url=/archives/273.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="mac关闭鼠标加速">mac关闭鼠标加速</h1>
<h2 id="mac上鼠标和windows有什么区别">mac上鼠标和windows有什么区别</h2>
<p>在windows系统上，使用鼠标，无论鼠标移动的速度有多快，在屏幕上的指针都是会以一个稳定的速度在移动，而在mac上，当你使用鼠标移动的越快时，指针的速度就越快，所以当同时使用windwos和mac时，会感觉到mac的鼠标没有windwos的好用。</p>
<h2 id="解决办法">解决办法</h2>
<p>打开终端输入：</p>
<pre><code class="language-bash">defaults write .GlobalPreferences com.apple.mouse.scaling -1
</code></pre>
<p>使用以下命令和查看当前鼠标的加速度值：</p>
<pre><code class="language-bash">defaults read .GlobalPreferences com.apple.mouse.scaling
</code></pre>
<p>但是有一点需要注意，我们刚才说鼠标设置中的跟踪速度会修改鼠标加速度，所以每次修改过鼠标设置的跟踪速度之后，都需要使用一次这个命令，不然鼠标加速会再次被开启。</p>]]></description><guid isPermaLink="false">/archives/273.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 14 Aug 2022 07:08:00 GMT</pubDate></item><item><title><![CDATA[关于UnityAB包问题随记]]></title><link>https://blog.ccrui.cn/archives/271.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%85%B3%E4%BA%8EUnityAB%E5%8C%85%E9%97%AE%E9%A2%98%E9%9A%8F%E8%AE%B0&amp;url=/archives/271.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="关于unityab包问题随记">关于UnityAB包问题随记</h1>
<h2 id="打包ab包">打包AB包</h2>
<p>使用插件进行打包<br><a href="https://github.com/Unity-Technologies/AssetBundles-Browser">Github</a><br><a href="https://docs.unity3d.com/Manual/AssetBundles-Browser.html">AssetBundles-Browser</a><br><a href="https://developer.unity.cn/projects/61ba994eedbc2a029d5712c0">教程</a></p>
<p>通过包管理安装</p>
<h2 id="加载ab包">加载AB包</h2>
<blockquote>
 <p>使用该bestHTTP插件请求并实例化AB包</p>
</blockquote>
<pre><code class="language-csharp">//下载AB
        HTTPRequest request = new HTTPRequest(new Uri("https://kai.chengrui.xyz/costume/AB/test"), HTTPMethods.Get, (req, res) =&gt;
        {
            AssetBundle ab = AssetBundle.LoadFromMemory(res.Data);
            Instantiate( ab.LoadAsset&lt;GameObject&gt;("HighTest"));
        });
        request.Send();
</code></pre>
<h2 id="出现问题">出现问题</h2>
<p>WebGL中无法加载WebGL 使用<code>AssetBundles-Browser</code>插件时，选择WebGL进行打包</p>]]></description><guid isPermaLink="false">/archives/271.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 1 Jul 2022 12:43:00 GMT</pubDate></item><item><title><![CDATA[Easy Touch组件API详解]]></title><link>https://blog.ccrui.cn/archives/270.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Easy%20Touch%E7%BB%84%E4%BB%B6API%E8%AF%A6%E8%A7%A3&amp;url=/archives/270.html" width="1" height="1" alt="" style="opacity:0;">
<p>EasyTouch组件：</p>
<p>Enable EasyTouch：启用或关闭EasyTouch功能，如果关闭，则所有事件绑定失效</p>
<p>Enable Unity Remote：是否允许与UnityRemote这个手机远程调试插件进行关联，记得在真正导出项目到手机的时候去掉这个勾勾</p>
<p>EasyTouch.GUI Compatibility</p>
<p>Enable Uniyt UI detection：启用或禁用对UGUI进行手势检测</p>
<p>Unity UI compatibility：</p>
<p>启用：如果粘键（同时触摸查过一个UGUI）则UGUI不会被检测到（手势事件不会被触发）</p>
<p>禁用：不管有没有粘键，都会触发手势事件，并且会将手势事件所在的类Gesture中的isOverUIElement这个属性设置为true</p>
<p>Auto update picked Unity UI：是否需要EasyTouch每一帧都去更新触摸检测到的所有UI数据</p>
<p>Enable NGUI Compatibility：是否启用对NGUI所属的层对象和NGUI摄像机的检测</p>
<p>NGUI Layers：哪个层是NGUI对象所在的层</p>
<p>Camera：哪个摄像机是NGUI摄像机</p>
<p>EasyTouch.Automatic selection:</p>
<p>Enable auto-select:是否对EasyTouch的自动检测规则进行设置</p>
<p>pickable layers 3D：对哪个层所在的物体进行检测（如果物体是预制体拉到场景中生成的时候，必须设置该项为true，不然easytouch识别不了）</p>
<p>Auto update picked gameobject：启用：EasyTouch每一帧都去更新触摸检测到的所有游戏物体的所属数据（例如触碰到什么，现在你的手指所在的屏幕坐标......，具体的可查看Gesture类）</p>
<p>禁用：有些游戏物体的数据则可能不会被实时得到，例如手指所在的屏幕坐标，通俗来说就是当你手指持续触摸屏幕的时候，Gesture中会有些数据不会实时更新，而这些数据只会在你离开停止触摸屏幕，然后在下一次触摸屏幕的那一刻只更新一次！</p>
<p>Enable 2D collider：是否让2D的且具有碰撞体的游戏物体也能被Easytouch检测到</p>
<p>pickable 2D layers：哪个层的2D游戏物体能够被检测到</p>
<p>EasyTouch.General gesture properties:</p>
<p>Priority to:你要的手势是点击的还是滑动的</p>
<p>Stationary tolerance:这是点击手势，其手势直径的容错设置，建议保持默认值</p>
<p>Long tap time:当点击手势保持多长时间（长按多少秒）才触发检测</p>
<p>Double tap time：双击的时候，以哪个时间为准，建议保持默认值</p>
<p>Swipe tolerance：在滑动手势发生时，至少滑动多长距离才算是滑动，建议保持默认值</p>
<p>Always sent swip event：在滑动过程中，是否需要不管滑动距离是否达到Swipe tolerance所需要的最少距离，都不断发送（触发）滑动事件(注意：建议选false，因为触发频率过高的话，可能会导致机子吃不消)</p>
<p>EasyTouch.Two fingers gesture properties:</p>
<p>2 Fingers gesture：是否支持双手指的手势</p>
<p>Pick method：以哪种方式为标准进行双手势识别，选Figure则手指必须要大面积的覆盖（触碰）到游戏物体，选Average则当你的手指同时碰到两个游戏物体的时候，计算位置平均值来选择你的手指所要选择的物体，个人建议选择Figure</p>
<p>Enable swipe &amp; drag:是否启用滑动或拖动手势</p>
<p>Enable Pinch:是否启用缩放手势</p>
<p>Min pinch length:用于检测缩放手势的像素点的最小阀值距离</p>
<p>Enable twist:是否启用扭曲手势</p>
<p>Min twist angle：用于检测扭曲手势的捻度的最小阀值角</p>
<p>EasyTouch.Second finger simulation</p>
<p>Enable simulation:是否开启第二手指的模拟体</p>
<p>Texture：第二手指的模拟体用哪张图片显示</p>
<p>Twist &amp; pinch key / Swipe key：按键盘的哪个键去激活第二手指的模拟体</p>
<p>类：</p>
<p>EasyTouch类：</p>
<p>枚举：</p>
<p>GesturePriority（手势优先级）：按下还是滑动</p>
<p>SwipeDirection （滑动屏幕的方向）：没有，左，右，上，下，上左，上右，下左，下右，其他</p>
<p>TwoFingerPickMethod（双手指检测方法）：是用两只手指头进行触摸检测还是用平均值进行触摸检测</p>
<p>事件：</p>
<p>单手指事件：</p>
<p>On_Cancel ：当系统取消跟踪触摸的时候发生</p>
<p>On_TouchStart：当手指刚触摸到屏幕时发生</p>
<p>On_TouchDown：当触摸正式被激活的时候发生</p>
<p>On_TouchUp ：当手指刚离开屏幕那一刻发生</p>
<p>On_SimpleTap：也是当手指刚离开屏幕时发生</p>
<p>On_DoubleTap：当手指连续按下两次的时候发生</p>
<p>On_LongTapStart ：当手指按下那一刻发生，但不能有移动直到所设置的长按的所需时间到了</p>
<p>On_LongTap ：当手指按在屏幕上达到长按所需的时间后则被认为长按有效，也就是此时发生，所以触发时机在On_LongTapStart之后</p>
<p>On_LongTapEnd ：当手指完成有效长按时，抬起的那一刻发生</p>
<p>On_DragStart ：当开始拖动可选对象那一刻发生</p>
<p>On_Drag ：当拖动正式被激活时发生</p>
<p>On_DragEnd：当不再拖动可选物体，手指在离开屏幕那一刻发生</p>
<p>On_SwipeStart：手指开始滑动屏幕的那一刻发生</p>
<p>On_Swipe：手指滑动屏幕正式被激活的时候发生</p>
<p>On_SwipeEnd：手指滑动完屏幕，离开屏幕的那一刻发生</p>
<p>双手指事件：</p>
<p>On_TouchStart2Fingers：就像On_TouchStart，但要用两个手指去触发</p>
<p>On_TouchDown2Fingers ：就像On_TouchDown，但要用两个手指去触发</p>
<p>On_TouchUp2Fingers：就像On_TouchUp，但要用两个手指去触发</p>
<p>On_SimpleTap2Fingers：就像On_SimpleTap，但要用两个手指去触发</p>
<p>On_DoubleTap2Fingers：就像On_DoubleTap，但要用两个手指去触发</p>
<p>On_LongTapStart2Fingers：就像On_LongTapStart，但要用两个手指去触发</p>
<p>On_LongTap2Fingers：就像On_LongTap，但要用两个手指去触发</p>
<p>On_LongTapEnd2Fingers：就像On_LongTapEnd，但要用两个手指去触发</p>
<p>On_Twist：当扭动手势发生时触发</p>
<p>On_TwistEnd：当扭动手势结束时触发</p>
<p>On_Pinch：当缩放手势被正式激活时触发</p>
<p>On_PinchIn：当缩放手势是缩小手势时触发</p>
<p>On_PinchOut：当缩放手势是扩大手势时触发</p>
<p>On_PinchEnd：当缩放手势结束并且离开屏幕的那一刻触发</p>
<p>On_DragStart2Fingers ：就像On_DragStart，但要用两个手指去触发</p>
<p>On_Drag2Fingers：就像On_Drag，但要用两个手指去触发</p>
<p>On_DragEnd2Fingers：就像On_DragEnd，但要用两个手指去触发</p>
<p>On_SwipeStart2Fingers：就像On_SwipeStart，但要用两个手指去触发</p>
<p>On_Swipe2Fingers：就像On_Swipe，但要用两个手指去触发</p>
<p>On_SwipeEnd2Fingers：就像On_SwipeEnd，但要用两个手指去触发</p>
<p>Unity UI：</p>
<p>On_OverUIElement ：当手指触碰到UGUI游戏对象的时候触发，前提是EasyTocuh的Unity UI compatibillity被勾选</p>
<p>On_UIElementUp：当手指离开UGUI游戏对象的那一刻触发，前提是EasyTocuh的Unity UI compatibillity被勾选</p>
<p>静态函数：</p>
<p>SetEnabled： 启用或禁用EasyTouch</p>
<p>GetEnabled: 启用EasyTouch就返回true</p>
<p>SetUICompatibily : 是否启用了UGUI兼容性（EasyTouch能否检测到UGUI）</p>
<p>GetUIComptability:启用UGUI兼容性就返回true</p>
<p>SetAutoUpdateUI:当你的手指在屏幕中滑动的时候，一碰到UI元素，是否把碰到的UI元素的信息进行自动更新</p>
<p>GetAutoUpdateUI:如果AutoUpdateUI启用了就返回true</p>
<p>SetEnableAutoSelect:是否启用自动选择</p>
<p>GetEnableAutoSelect:EnableAutoSelect启用的时候，返回true</p>
<p>SetAutoUpdatePickedObject:是否启用自动更新选择的可选游戏对象</p>
<p>GetAutoUpdatePickedObject:如果AutoUpdatePickedObject启用就返回true</p>
<p>Set3DPickableLayer:设置哪个层的3D游戏对象可以被选取</p>
<p>Get3DPickableLayer:返回可选取的3D游戏对象所在的层</p>
<p>AddCamera:添加一个深度摄像机（就是Camera游戏对象的ClearFlags为Depth Only，而场景自带的MainCamera的ClearFlags为Skybox，通常一个场景只有一个Skybox模式的主摄像机，负责将其拍摄范围内的物体显示到屏幕上，但是又可以有多个深度摄像机，使得就算不在主摄像机拍摄范围的物体但在深度摄像机拍摄范围的物体也能显示到屏幕上），使得被这深度摄像机所拍摄的物体也能受到EasyTouch的屏幕检测</p>
<p>RemoveCamera：删除一个摄像机</p>
<p>GetCamera：返回一个摄像机</p>
<p>SetEnable2DCollider：是否启用2D碰撞检测</p>
<p>GetEnable2DCollider：如果Enable2DCollider被启用就返回true</p>
<p>Set2DPickableLayer：设置哪个层的2D游戏对象能够进行选取</p>
<p>Get2DPickableLayer：返回可选取的2D游戏对象所在的层</p>
<p>SetGesturePriority：设置手势优先级</p>
<p>GetGesturePriority：得到手势优先级</p>
<p>SetStationaryTolerance：设置固定的容错率（因为手指很可能并不能完全覆盖在选取的游戏对象上，所以有容错率）</p>
<p>GetStationaryTolerance：得到固定的容错率</p>
<p>SetLongTapTime：设置长按所需的时间</p>
<p>GetlongTapTime：得到长按所需的时间</p>
<p>SetDoubleTapTime：设置双击间隔时间</p>
<p>GetDoubleTapTime：得到双击间隔时间</p>
<p>SetSwipeTolerance：设置滑动容错率（因为手指很可能并不能完全覆盖在选取的游戏对象上，所以有容错率）</p>
<p>GetSwipeTolerance：得到滑到容错率</p>
<p>SetEnable2FingersGesture：是否启用双手指</p>
<p>GetEnable2FingersGesture：如果Enable2FingersGesture启用就返回true</p>
<p>SetTwoFingerPickMethod：设置双手指选取物体的方式</p>
<p>GetTwoFingerPickMethod：返回双手指选取物体的方式</p>
<p>SetEnablePinch：是否启用缩放手势</p>
<p>GetEnablePinch：EnablePinch启用了，就返回true</p>
<p>SetMinPinchLength：设置最小缩放检测长度</p>
<p>GetMinPinchLength：返回最小缩放检测长度</p>
<p>SetEnableTwist：是否启用旋动手势</p>
<p>GetEnableTwist：EnableTwist启用了就返回true</p>
<p>SetMinTwistAngle：设置最小旋动检测角度</p>
<p>GetMinTwistAngle：得到最小旋动检测角度</p>
<p>GetSecondeFingerSimulation：是否启用第二只手指的仿真体</p>
<p>SetSecondFingerSimulation：如果第二手指的仿真体启用了，就返回true</p>
<p>Gesture类：</p>
<p>变量：</p>
<p>fingerIndex：触发手势事件的手指所对应的下标，如果是双手指触发则返回-1</p>
<p>touchCount ：被激活的触摸数量。用于管理多点触摸。</p>
<p>startPosition：触发触摸事件的时候，单手指的起始位置，或者多手指触发时的起始平均位置</p>
<p>position ：触发触摸事件的时候，单手指触发的当前位置，或者多手指触发时的当前平均位置</p>
<p>deltaPosition：因为输入相应一般都在Update函数里，所以自然是有位置和时间的变化量的，而deltaPosition就是最近一次触摸与本次触摸的位置变化量</p>
<p>actionTime：反应时间，就是说easytouch的同一个事件触发之间是有时间间隔的</p>
<p>deltaTime：因为输入相应一般都在Update函数里，所以自然是有位置和时间的变化量的，而deltaTime就是最近一次触摸与本次触摸的时间变化量</p>
<p>swipe：滑动或拖动的方向，这个值是通过计算当前手势的deltaPosition得到的，也就是手势的startPosition和手势结束时的当前position所得到的计算结果</p>
<p>swipeLength：手指在屏幕上滑动了多少像素，这个值是通过计算当手势结束时，该手势的startPosition和position得到的</p>
<p>swipeVector：在屏幕上滑动的矢量方向</p>
<p>deltaPinch：最近一次缩放与当前缩放的缩放变化量。此变化量对于On_Pinchin和On_PinchOut是正数。对于扩大手势是正数，对于缩小手势是负数</p>
<p>twistAngle：最新一次调用的旋动（扭动）手势的角度与当前角度的变化值，顺时针是负值，逆时针是正值</p>
<p>twoFingerDistance：双手指触发时，两只手指在屏幕上相距的像素距离</p>
<p>pickedObject：当触摸开始那一刻所碰到的可选取的游戏对象（如果不是可选取对象则返回none）又或者当auto update picked gameobject被设置为true时，自动更新所得到的可选取对象（也就是你贴着屏幕滑动，只要你碰到可选取游戏对象，那么这个pickedObject代表的就自动变更为那个游戏对象，当然这一切是基于auto update picked gameobject这个属性被设置为true的情况下）</p>
<p>pickedCamera：用手势去操纵的摄像机（例如操纵视野的放大缩小，镜头移动会用到）</p>
<p>isGuiCamera：用手势去选取操纵的摄像机是否GUI摄像机</p>
<p>isOverGUI：当前触摸发生的那一刹那，手指是否触碰到UGUI游戏对象，又或者在当Auto update picked Unity UI被勾选上设置为true的时候，实时检测手指是否在UGUI上。只有在UI Compatibility Mode设置发false禁用了，才会根据情况返回正确的值，不然则恒定返回false</p>
<p>pickedUIElement：当前触摸发生的那一刹那，手指是否触碰到并且选取到UGUI游戏对象，又或者在当Auto update picked Unity UI被勾选上设置为true的时候，实时检测手指是否在UGUI上。只有在UI Compatibility Mode设置为false禁用了，才会根据情况返回正确的值，不然则恒定返回null</p>
<p>方法：</p>
<p>GetTouchToWorldPoint(float z)：将当前触摸位置从当前屏幕坐标转换为距离摄像机z个单位处的世界坐标</p>
<p>GetTouchToWorldPoint(Vector3 position3D)：将当前触摸位置从当前屏幕坐标转换为世界坐标，这个position3D参数是目标在世界坐标系中的位置，正因为如此，可以用来计算摄像机与目标物体的距离长度</p>
<p>GetSwipeOrDragAngle：返回滑动或拖动的角度</p>
<p>NormalizedPosition：返回相对于屏幕的归一化位置</p>
<p>GetCurrentPickedObject：获取当前所选取的游戏对象，如果你把Auto update picked gameobject设置为true，则不需要用到这函数</p>
<p>IsOverUIElement：如果当前触摸发生在UGUI游戏对象上就返回true</p>
<p>IsOverRectTransform：如果当前触摸的是recttransform，则返回true</p>
<p>GetCurrentFirstPickedUIElement：得到当前被选中的UGUI游戏对象，如果Auto update picked Unity UI勾选设置为true了，则不需要用到此函数</p>]]></description><guid isPermaLink="false">/archives/270.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 29 Jun 2022 02:44:00 GMT</pubDate></item><item><title><![CDATA[KMS搭建]]></title><link>https://blog.ccrui.cn/archives/269.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=KMS%E6%90%AD%E5%BB%BA&amp;url=/archives/269.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="kms搭建">KMS搭建</h1>
<p>下载<code>binaries.tar.gz</code><br><a href="https://github.com/Wind4/vlmcsd/releases">下载KMS服务</a></p>
<p>解压<code>binaries.tar.gz</code><br>
  进入<code>binaries</code>目录</p>
<p>下面你可以根据实际情况选择对应的操作系统，多数服务器选择 <code>Linux -&gt; intel -&gt; static -&gt; lmcsd-x64-musl-static</code>复制到 <code>/usr/bin/</code></p>
<pre><code class="language-shell">#将需要运行的程序复制到/usr/bin/目录并命名为kms(便于记忆)
cp Linux/intel/static/vlmcsd-x64-musl-static /usr/bin/kms
#给kms文件赋予执行权限
chmod 755 /usr/bin/kms
</code></pre>
<p>在<code>/usr/bin/</code>路径执行<code>./kms vlmcsd</code></p>
<p>开放1688端口</p>
<h2 id="激活windows服务">激活Windows服务</h2>
<p>使用管理员权限打开windows的powershell准备激活你的Windows</p>
<pre><code class="language-shell">#设置刚才搭建的kms服务器
slmgr /skms [你的服务器地址]
#卸载当前的密钥Key(非必要)
slmgr /upk
#安装新的密钥Key,请在网上找到可用的密钥
slmgr /ipk YC7N8-G7WR6-9WR4H-6Y2W4-KBT6X
#激活Windows
slmgr /ato
</code></pre>
<p>这里是微软提供的各个版本软件的KMS激活密钥</p>
<p><a href="https://docs.microsoft.com/zh-cn/windows-server/get-started/kms-client-activation-keys">Windows</a><br><a href="https://docs.microsoft.com/zh-cn/DeployOffice/vlactivation/gvlks?redirectedfrom=MSDN">Office</a></p>]]></description><guid isPermaLink="false">/archives/269.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 26 May 2022 01:45:00 GMT</pubDate></item><item><title><![CDATA[2022年毕业设计]]></title><link>https://blog.ccrui.cn/archives/266.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=2022%E5%B9%B4%E6%AF%95%E4%B8%9A%E8%AE%BE%E8%AE%A1&amp;url=/archives/266.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="2022年毕业设计">2022年毕业设计</h1>
<blockquote>
 <p>设计题目：虚拟仿真游戏的设计与实现</p>
 <p>使用技术：Unity3D</p>
 <p>制作目的：完成毕业论文</p>
 <p>制作人：张程瑞</p>
 <p>简介：此项目为2022年大连东软信息学院 高等职业技术学院 虚拟现实19101班 张程瑞 的毕业设计，主要设计为虚拟现实游戏，主要技术为Unity3D。</p>
 <p>项目地址：<a href="https://github.com/cr-zhichen/VirtualSimulation">https://github.com/cr-zhichen/VirtualSimulation</a></p>
</blockquote>
<p>[TOC]</p>
<h2 id="摘要">摘要</h2>
<p>虚拟现实技术，在1963年以前就被提出，而到了21世纪的今天，我们依旧对这项技术充满了争议，不过在近几年的科技发展中，随着计算设备算力越发的提高，“云计算”等技术的逐渐兴起，让虚拟现实这一承载着人类无数想象力的技术再度出现在了大众的视野中。伴随着虚拟现实技术的发展越发的完善，这项技术也走进了我们普通人的生活中。<br>
  在日常生活中，我们不可避免的通过网购平台购买一些商品，而在购买的过程中，作为消费者的我们不能真正的全方位的看见商品实物，也没办法直观的了解到商品的信息，作为商家，也没有更好的手段让消费者看到自己的商品实物，所以设计一款面向全体消费者与全体商家的，能帮助消费者简单、直观的看到商品样式，帮助商家向消费者展示商品的应用——《虚拟仿真游戏》。《虚拟仿真游戏》分为面向客户的客户端，面向管理员的管理端，与面向运维人员的服务端。本人将负责这三端的实现与统一整合。<br>
  在本项目的设计与实践过程中，采用Unity3D游戏引擎、C#程序语言与服务器程序进行数据的接收、发送及保存，使用Photoshop图像处理工具、3ds Max建模渲染工具等进行客户端与管理端的设计与开发，通过ASP.NET Core技术配合Docker容器完成服务器端的构建与部署。<br>
  最终面向全体消费者与全体商家的《虚拟仿真游戏》客户端与管理端可以运行于Windows、Linux、Android等设备中，方便用户和管理员通过各种设备使用程序。《虚拟仿真游戏》服务端运行于通过Docker容器实现的服务器虚拟容器中，方便服务器运维人员为服务端进行部署与运维。<br>
  经过多次测试，该应用功能简洁实用，界面友好美观，软件运行稳定，并具有良好的操作可行性和技术可行性，用户体验良好。</p>
<p>关键词：虚拟现实，Unity3D，C#，ASP.NET Core</p>
<h2 id="第1章-绪论">第1章 绪论</h2>
<h3 id="论文研究背景">论文研究背景</h3>
<p>虚拟现实技术承载了人类对未来科技的无限幻想，而未曾发现，其实这项技术早已围绕在我们生活中的方方面面。购物是现代人必不可少的一种休闲活动，而在购物过程中，用户总会懊恼一件事情，那就是如何能在商品到手之前看到商品的全貌，如何能更加直观了解到商品的详细信息。售卖商品的商家也会懊恼，如何能让自己的商品更加吸引客户，如何能让用户更加深刻的了解到商品的信息。<br>
  因此，设计一款能够让商家和客户都可以满意的解决方案便是至关重要的一件事，众所周知，能够更加直观地查看商品样式的方式，就是使用虚拟现实技术将商品进行3D建模后，通过3D仿真的形式，被管理者上传到云端，用户通过自己手中的客户端，或者在商场中的嵌入式设备中运行客户端程序，从而快速的让用户看到商品的实物及其信息，让商家也可以不必纠结如何展示自己的商品而苦恼。<br>
  因此设计了一个满足用户购物过程中能更加清晰明了的看到产品，管理者能更加方便的向用户展示产品细节的一整套解决方法。</p>
<h3 id="论文研究的目的及意义">论文研究的目的及意义</h3>
<p>让商家和用户同时满意，是一件很难达成的目标，对于这一点而言，关键的是在于，如何能让管理者更加轻松地使用该解决方案，使用户更加方便的从中预览到自己想了解的东西。<br>
  原先市面上存在的各种解决方案，无一例外的，使用的技术都是web应用作为出发原点，产品面向的人群，要么是从商家的角度入手，去解决如何让用户更加精准地被推送到他喜欢的商品，要么是从用户的角度出发，以牺牲商家便利性为代价，让用户更加全面的去了解商品的全貌，但这两种解决方案都或多或少地存在着问题。单从一类群体出发，是无法解决上述问题的。<br>
  而本项目，所采用的技术，为新兴的虚拟仿真技术，通过使用游戏引擎优秀的物理模拟，以及模型质感还原能力，让用户可以更加方便的了解到商品的样式以及商品的信息，并且通过游戏引擎健全的热更新生态，赋予了商家与管理者更加简单、方便、自由、快捷的3D模型模拟仿真分发渠道。<br>
  通过这些技术，可以大幅度减少用户以及商家的使用门槛。并且通过封装好的工具，让管理者可以快速地根据季节、时段、活动来向用户分发不同的虚拟仿真模型，并通过一套完善的用户权限管理系统，使不同的终端设备，以及用户，能够接收到最适合的商品推送。得益于Unity 3D的跨平台能力，可以让用户端和管理端，兼容不同的操作系统，以及运行环境，使程序可以在用户自身的手持移动设备上，或者是商场中的嵌入式设备中流畅运行。</p>
<h3 id="论文研究主要内容">论文研究主要内容</h3>
<p>本文设计和实现了一款，针对于全体客户和全体商家的，能帮助快速、直观展示商品样式与特点的解决方案《虚拟仿真游戏》。本解决方案分为面向客户的客户端，面向管理者的管理端，面向运维人员的服务器端，本人负责这三端的实现与统一整合。该项目包括一套完整的Web API后端程序、客户端管理端统一的应用程序、经过封装后的解决方案制作工具。并且该项目通过热更新的方式实现，管理员上传成功模型后，客户端无需更新即可实时显示的优秀使用体验。并通过一套完整的用户权限管理以及模型权限分配框架，让不同用户组的用户可以接收到不同的模型，方便项目在线下实体店展示时，能够根据不同地点的需要，快速更换不同的模型进行显示。<br>
  该项目的界面设计简单明了，方便管理员和用户使用该软件。项目采用了前后端分离的解耦合式设计，大幅度地减少了运维人员对服务器后端进行维护的难度。<br>
  本项目基于Unity 3D开发平台，在设计之初使用了3ds Max3D建模软件、Photo Shop图像处理工具等一系列软件完成了用户端与管理端的实现。并通过ASP.NET Core技术、Docker容器等技术，完成了服务端的实现。</p>
<h3 id="国内外研究现状">国内外研究现状</h3>
<p>随着虚拟实验技术的成熟，人们开始认识到虚拟仿真实验室在教育领域的应用价值，它除了可以辅助高校的科研工作，在实验教学方面也具有如利用率高易维护等诸多优点。近年来，国内的许多高校都根据自身科研和教学的需求建立了一些虚拟实验室。<br>
  目前国内外都对虚拟实验平台进行了各种实质性的探索，各种虚拟平台层出不穷。对虚拟平台的运用大致有以下几个方面:城市规划、房地产行业、娱乐、艺术与教育。但是目前虚拟平台运用到教学中的平台在国内还相对较少，处于萌芽阶段，而国外已经有很多大学进行了这方面的研究。</p>
<h2 id="第2章-关键技术介绍">第2章 关键技术介绍</h2>
<h3 id="unity3d">Unity3D</h3>
<p>Unity3D，是Unity Technologies 公司开发的三维游戏制作引擎，此引擎可将游戏发布至Windows、Mac、Wii、iPhone、WebGL（需要 HTML5）和 Android 平台，也可以利用 Unity Web Player 插件发布网页游戏，支持 Mac 和 Windows 平台的网页浏览，是一个全面整合的专业游戏引擎。通过该引擎，开发者可以轻松实现例如三维游戏，建筑可视化，实时三维动画等类型的互动内容。Unity官方配置了详细的用户使用手册，以及API文档供给开发者使用，并有着优秀的论坛资源，可以让开发者更加轻松地开发游戏，大幅度提高了工作效率。</p>
<h3 id="aspnet-core">ASP.NET Core</h3>
<p>ASP.NET Core，是微软公司开发的一款跨平台的高性能开源框架，用于生成启用云且连接 Internet 的新式应用。使用 ASP.NET Core，可以生成 Web 应用和服务、物联网 (IoT) 应用和移动后端，在 Windows、macOS 和 Linux 上使用喜爱的开发工具，部署到云或本地，在 .NET Core 上运行。<br>
  ASP.NET Core具有生成 Web UI 和 Web API 的统一场景，针对可测试性进行构建，Pages 可以使基于页面的编码方式更简单高效，共享全部使用 .NET 编写的服务器端和客户端应用逻辑，能够在 Windows、macOS 和 Linux 上进行开发和运行。开放源代码和以社区为中心，等优点。<br>
  微软公司提供了详细的API文档供开发者使用，并具有良好的用户支持以及程序稳定性。</p>
<h3 id="adobe-photoshop">Adobe Photoshop</h3>
<p>Adobe Photoshop是一款处理以像素所构成的平面数字图像的软件，在软件中可以对图片进行编辑、修改、扫描、制作、图像输入输出。在项目中使用Photoshop，可以快速的制作项目中所需要的UI，并可以通过图层叠加的方式创建更加优秀的UI图像。<br>
  Photoshop在游戏制作领域应用的十分广泛，不光可以制作简单的游戏UI，更可以通过配合其他3d建模软件，完成模型的贴图制作。</p>
<h3 id="3ds-max">3ds Max</h3>
<p>3ds Max 是Autodesk 公司出品的最流行的三维动画制作软件，它提供了强大的基于Windows 平台的实时三维建模、渲染和动画设计等功能，被广泛应用于广告、影视、工业设计、多媒体制作及工程可视化领域。<br>
  在项目中，使用3ds Max软件，进行场景的建模以及改动，并配合其他图片绘制软件完成模型的材质制作。</p>
<h3 id="mysql">MySql</h3>
<p>MySQL是一个小型的开源的关系型数据库管理系统，与其他大型数据库管理系统例如Oracle、DB2、SQL Server等相比，MySQL规模小且功能有限，但是它体积小、速度快、成本低，且它提供的功能对稍微复杂的应用已经够用，这些特性使得MySQL成为世界上最受欢迎的开放源代码数据库。<br>
  MySql的管理方式也是很好的选择，可以利用数据库语句快速的遍历查询数据库，对数据库中的内容进行快速的增删改查。并在其中提供了多种API接口，支持多种开发语言。</p>
<h2 id="第3章-需求分析">第3章 需求分析</h2>
<h3 id="需求分析">需求分析</h3>
<h4 id="用户群体">用户群体</h4>
<p>《虚拟仿真游戏》的用户群体主要面向于购买商品的消费者，以及售卖商品的商家，通过使用《虚拟仿真游戏》可以让用户更加清楚明白的在看到商品实物前，就能清晰的了解到商品的样式等基本信息，并可以让商家更加方便的向消费者展示所销售商品的特点。</p>
<h4 id="需求场景分析">需求场景分析</h4>
<p>小张是一名普通大学生，有一天发现自己在校园中用作代步的自行车损坏了，于是他想去网购一辆新的自行车，但是在使用网购APP查看要买的商品时，却发现简单的2d图片不能够让其360度无死角的查看商品的细节，于是他向商家询问。而商家正好在之前使用过《虚拟仿真游戏》软件，于是商家指导小张下载并登录了被分配查看自行车模型权限的账号，小张得以更加清晰的查看他想购买商品的细节。通过这种方式，小张和商家快速达成了交易，并减少了可能存在的潜在问题。</p>
<h3 id="系统需求分析">系统需求分析</h3>
<p>通过以上需求场景分析《虚拟仿真游戏》可以满足用户最购物中出现的无法直观、准确的查看商品详情的问题进行了解决，并同时解决了商家对产品宣传不便的问题。<br>
  能快速的购买的自己心爱的商品是我们每一个消费者都想达成的目的，但只是通过2d的图片总是无法能够直观的查看到商品的全貌，只有通过这种虚拟仿真技术，利用3d模型对现实物品的仿真技术，才能让消费者更加清晰快捷的查看到想购买物品的样式与功能细节。<br>
  用户打开《虚拟仿真游戏》，首先进入用户登录界面，登录管理员账号后，会进入对应的管理端界面，当登录的账号为用户账号时，会进入用户账号。<br>
  管理端可以通过简单UI对服务器中现有的模型进行修改与删除，并可以加载本地模型，将本地模型上传到服务器。<br>
  在管理员界面还可以对用户信息进行修改，可以修改不同用户所对应的不同用户组，以让用户可以访问属于自己分配组内的模型。<br>
  用户端可以查看用户对应用户组内所允许查看的模型，并可以对摄像机进行移动操作，来全方位的查看模型的细节。<br>
  根据以上的基本流程，绘制了《虚拟仿真游戏》基本流程图，如图 3.1所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FZwI1asBb2K.png&amp;size=m" alt="图 3.1"></p>
<p>根据图 3.1基本流程图的分析，绘制出了用户用例图，如图 3.2所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FNs5XUnbzhR.png&amp;size=m" alt="图 3.2"></p>
<p>管理员可以进行上传模型、更改模型组、预览模型、注册用户、删除用户、更改用户组、给用户分配权限等行为。用户可以进行预览模型、移动相机、旋转相机、查看模型细节的行为。<br>
  管理员行为功能如表 3.1所示。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FeydhYhIhNF.png&amp;size=m" alt="表 3.1"><br>
  用户行为功能如表 3.2所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FmY5s9HJqxL.png&amp;size=m" alt="表 3.2"></p>
<ol>
 <li>上传模型<br>
   用例描述如表 3.3所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FitQ0QtCwFT.png&amp;size=m" alt="表 3.3 "></li>
 <li>更改模型组<br>
   用例描述如表 3.4所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FqIE9z4NDBK.png&amp;size=m" alt="表 3.4"></li>
 <li>注册用户<br>
   用例描述如表 3.5所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FKQwGOwB9tT.png&amp;size=m" alt="表 3.5"></li>
 <li>预览模型<br>
   用例描述如表 3.6所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FJTDufJhvek.png&amp;size=m" alt="表 3.6"></li>
</ol>
<h3 id="系统运行环境">系统运行环境</h3>
<h4 id="前端程序">前端程序</h4>
<p>（1）运行在Android4.4以上的手机系统版本。<br>
  （2）运行在Windows7以上的Windows系统版本。<br>
  （3）运行在Linux系统。<br>
  （4）RAM内部存储为2G以上的设备。<br>
  （5）ROM存储为500M以上的设备。</p>
<h4 id="后端程序">后端程序</h4>
<p>（1）运行在部署Docker环境的全部服务器。<br>
  （2）RAM内部存储为128M以上的设备。</p>
<h3 id="系统可行性分析">系统可行性分析</h3>
<h4 id="技术可行性">技术可行性</h4>
<p>《虚拟仿真游戏》该全平台程序的实现采用Unity3D游戏引擎，和C#脚本语言进行驱动，后台采用ASP.NET Core技术进行制作，并通过HTTP方式与前端程序进行数据的交换，数据库采用MySql数据库进行数据的存储。<br>
  在《虚拟仿真游戏》中，Unity作为客户端，ASP.NET Core作为服务端，MySql作为数据库，对象存储作为数据存储位置。数据从客户端发送到服务端，服务端将数据处理并保存到MySql数据库中，将文件传输到对象存储中。<br>
  综上所述，《虚拟仿真游戏》的技术可行性较高。</p>
<h4 id="系统安全可行性">系统安全可行性</h4>
<p>由于《虚拟仿真游戏》的全端实现由我一人完成，所以数据来源安全可靠稳定。后台采用ASP.NET Core作为服务器开发框架，使用Docker技术部署在全平台，给客户端（Unity）与数据库进行发送数据，所以《虚拟仿真游戏》是相对安全可靠的。<br>
  于此同时，使用Unity3D开发的程序是以C#进行脚本语言驱动开发，在其中所使用的大量变量均为私有变量，并正确的设置其保护类型。后端采用的ASP.NET Core框架也是采用C#作为开发语言，并且在开发过程中数据库中所保存的全部敏感信息全部进行了加密处理，在Unity与服务器进行数据交换过程中使用Token验证可信权限，并且采用的全部接口均为Post接口，传输的数据均使用MD5加密方式进行数据加密。使用以上技术开发的《虚拟现实仿真游戏》的安全性不言而喻。</p>
<h4 id="系统可行性分析-1">系统可行性分析</h4>
<p>总之，《虚拟仿真游戏》作为一款全平台解决方案，无论是从安全可行性、经济可行性、技术可行性、可维护性、功能设定上都是遵循现代软件设计规律，符合完成解决方案的设计方法，系统设计可行性较高。</p>
<h2 id="第4章-系统设计">第4章 系统设计</h2>
<h3 id="设计指导思想和原则">设计指导思想和原则</h3>
<h4 id="指导思想">指导思想</h4>
<p>通过前期调研结果以及实践经验，详细分析《虚拟仿真游戏》的功能需求，在此之后，对项目进行设计与研发。<br>
  首先做好前期的准备工作，绘制项目草图，流程图等，确定场景UI风格，进行内容设计，功能需求分析，代码框架设计的工作，其次，利用后端框架完成后端服务器的制作与搭建。并利用Photoshop、3ds Max等工具，制作所需的美术资源，并根据草图在Unity中搭建功能所需的基本场景以及编写脚本代码。同时将制作好的美术资源部署于Unity场景中。及时发现并修改在设计上存在的问题，并将Unity与后端框架使用HTTP连接的方式进行通讯链接。待场景全部完成后，对场景与后端进行反复测试，尽可能的减少功能中存在的Bug，提高整体的用户体验。</p>
<h4 id="设计原则">设计原则</h4>
<p>为保证《虚拟仿真游戏》系统的成功实现，在设计制作过程中，遵循以下原则：<br>
  （1）确保场景风格统一。<br>
  （2）遵循设计原则，注重场景一致性，不过于简单也不过于花哨。<br>
  （3）根据项目需求进行设计，突出项目主要功能。<br>
  （4）UI中的字体、字号等符合场景设计原则。<br>
  （5）文字表达部分简单明了。<br>
  （6）对所有用户操作均有明确的操作完成提示。<br>
  （7）对网络连接问题，进行加密传输。<br>
  在研发制作过程中，对于代码框架以及代码管理，遵循以下原则：<br>
  （1）脚本的命名与变量的命名严格遵循C#语法要求采用驼峰命名法。<br>
  （2）脚本与变量的命名清晰明了，并有意义。<br>
  （3）整体代码框架设计简介明了，避免耦合性过高降低可读性。<br>
  （4）对脚本进行分类管理。<br>
  （5）对需要多次复用的功能，进行封装复用。<br>
  （6）优化代码逻辑，减少内存占用。<br>
  在功能内容设计上，遵循以下的原则：<br>
  （1）根据用户需求进行设计与实现。<br>
  （2）在满足用户功能的条件上，尽量减少用户的使用难度。<br>
  （3）尽量减少无用功能，减少用户理解难度。<br>
  （4）做到及时反馈，提高用户体验。</p>
<h3 id="系统流程设计">系统流程设计</h3>
<p>通过以上对《虚拟仿真游戏》的功能需求分析以及设计分析，将对其操作流程做出以下设计。<br>
  管理员使用管理员账号登录管理端，并使用上传功能，将制作好的模型上传到服务器中，并向模型进行分配模型组权限，并使用用户管理工具，注册新的用户账号，并将用户分配不同的用户组中。用户使用用户账号登录后，即可进入用户端，用户可以通过点击左侧模型区的模型预览图，对服务器中有权限访问的模型进行下载并实例化在画面中心，通过移动摄像机的方式，360度的查看模型的细节。<br>
  《虚拟仿真游戏》流程图如图 4.1所示<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FVgE5YNDNNR.png&amp;size=m" alt="图 4.1"></p>
<p>本项目中采用ASP.NET Core技术搭建服务器应用，并通过Swagger撰写接口文档。本项目中全部API接口均采用HTTP Post链接方式进行通讯，除登录接口外，全部接口均需向服务器提供服务器可信Token进行鉴权操作。API返回值均为统一处理格式，方便前端接入时处理数据。<br>
  其中接口包括以下8个：</p>
<ol>
 <li>Register<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FkJvBFUGTtZ.png&amp;size=m" alt="表 4.1"></li>
 <li>Loading<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FNLb0ViIIf9.png&amp;size=m" alt="表 4.2"></li>
 <li>Cancellation<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2F0UPsGgM7bH.png&amp;size=m" alt="表 4.3"></li>
 <li>GetUserInformation<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FOoirQ1chMk.png&amp;size=m" alt="表 4.4"></li>
 <li>AddAB<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FXklYrXzCxI.png&amp;size=m" alt="表 4.5"></li>
 <li>DelAB<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FjmsfizbTK0.png&amp;size=m" alt="表 4.6"></li>
 <li>UpDataAB<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FvuJdpHYXpk.png&amp;size=m" alt="表 4.7"></li>
 <li>ShowABPackage<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FzMkE9Zds3y.png&amp;size=m" alt="表 4.8"></li>
</ol>
<h3 id="系统功能模块详细设计">系统功能模块详细设计</h3>
<h4 id="登录功能模块设计">登录功能模块设计</h4>
<p>登录功能是已经完成注册的用户，输入用户邮箱和密码，并将用户名和密码上传到服务器端，由服务器进行身份验证，并返回用户权限与登录是否成功，在登录后返回Token以帮助服务器对用户动作进行鉴权。<br>
  功能主要包含UGUI中的Image图片组件、InputField输入框组件、Button按钮组件、Text文本组件。在用户输入用户名和密码后，点击登录按钮，调用封装好的HTTP方法，向服务器发送登录请求，并在后端数据库中对用户名与密码进行身份验证，并将服务器返回信息处理后显示在用户界面。<br>
  根据登录功能模块的设计绘制了登录功能的时序图，如图 4.2所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FvvxaDB8gfL.png&amp;size=m" alt="图 4.2"></p>
<h4 id="模型库模块设计">模型库模块设计</h4>
<p>模型库模块是用来显示用户所在用户组所能查看的全部模型，在用户登录完成后，模型库模块会自动调用封装好的HTTP模块向服务器发出Post请求，服务器在鉴权成功后，向客户端返回全部模型预览图的链接与模型链接，模型库会自动根据预览图加载图片显示在UI中，并且在用户点击预览模型后，通过模型下载链接，从服务器拉取模型进行实例化，并在完成后向用户发出通知。<br>
  根据模型库模块设计绘制了模型库模块的时序图，如图 4.3所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FTiYaamnGAQ.png&amp;size=m" alt="图 4.3"></p>
<h4 id="用户管理模块设计">用户管理模块设计</h4>
<p>用户管理模块是项目中，可以供管理员对用户信息进行管理的模块，在本模块设计中，要充分让管理员简单方便的对用户信息进行管理。管理员在选择用户管理模块后可以进行新建用户、修改用户组、修改用户密码、删除用户等操作。在本模块的设置中，管理员对用户信息进行任何修改时，服务器都会对管理员权限做一次额外认证，保证权限正确。<br>
  根据用户管理模块设计绘制了用户管理模块的时序图，如图 4.4所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FvWnBmXhzRE.png&amp;size=m" alt="图 4.4"></p>
<h4 id="相机控制模块设计">相机控制模块设计</h4>
<p>相机控制模块是项目中用户端和管理复用的通用模块，用户在实例化完成模型后即可通过点击移动鼠标的方式，或者滑动屏幕的方式，控制摄像机的旋转、移动、缩放等功能。</p>
<h4 id="工具类模块设计">工具类模块设计</h4>
<p>在项目中总是出现一些需要全局多次使用的方法，可以将其封装成对应静态工具类，当需要工具类功能时，可直接调用静态方法实现功能，可以减少项目的内存占用与减少可能出现的逻辑冲突。<br>
  根据工具类模块设计绘制了工具类模块的时序图，如图 4.5所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FXbiX8Eikqs.png&amp;size=m" alt="图 4.5"></p>
<h4 id="全局通知类模块设计">全局通知类模块设计</h4>
<p>在场景中，每次用户进行操作后，均应该向用户返回操作结果，并显示在UI中。全局通知类模块便是封装好的全局通知类，当需要通知时，通过单例模式调用模块便可实现通知显示。</p>
<h4 id="后端api类模块设计">后端API类模块设计</h4>
<p>该项目中，拥有一套完整的后端API，项目的大部分逻辑依靠后端支撑。在前端程序向后端程序请求时，后端程序应该争取处理请求信息，并在处理后将正确的返回值格式化后返回供前端使用。</p>
<h3 id="用户体验设计">用户体验设计</h3>
<p>《虚拟仿真游戏》主要面向于普通消费者和普通商家设计的，所以界面的整体风格简单明了，易于使用，在界面的表达上要做到简单明了方便使用。<br>
  简单快速上手使用是消费者和商家共同的目标，所以如何让用户在使用《虚拟仿真游戏》时能够轻松使用，并尽量减少会使用户感到困惑的界面与文案，那么就要做到以下原则：</p>
<ol>
 <li>《虚拟仿真游戏》界面表达上做到简单明了，采用大色块的风格，突出每个模块之间的联系，并且适配多种系统，让用户无论是通过键鼠使用亦或是通过触控设备使用时都能以直觉方式进行操作。</li>
 <li>减少界面中的可能令用户产生疑惑的部分，全部文案简单易懂，让用户更加容易的理解各模块代表的含义。</li>
 <li>《虚拟仿真游戏》的整体设计应符合基本软件设计的原则，做到UI风格统一，色彩搭配合理，界面元素排版合理等。</li>
</ol>
<h3 id="系统界面设计">系统界面设计</h3>
<h4 id="登录界面">登录界面</h4>
<p>在进入《虚拟仿真游戏》后首先展示的是用户登录界面，在用户界面中包括图片、输入框、按钮等元素，并通过强调色视觉引导配合文字引导的方式，引导用户正确的输入账号密码。<br>
  其中图片、输入框、按钮等元素均为Unity3D自带的UGUI系统制作。<br>
  登录界面效果图，如图 4.6所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2Fswp7JELsex.png&amp;size=m" alt="图 4.6"></p>
<h4 id="用户界面">用户界面</h4>
<p>用户界面采用色块堆叠配色，并由于用户使用功能较少，将界面主要分为三部分，模型选择部分、模型展示部分、其他功能部分。<br>
  模型选择部分采用Unity3D中自带的UGUI组件，利用其中的Scroll Rect、Grid Layout Froup、Content Size Fitter、Toggle Group组件完成模型选择部分的弹性UI显示。<br>
  模型展示部分，在用户未加载预览模型时，显示为空，只有当用户选择并加载模型后，模型才会在画面中心位置实例化出来，用户可以在中间部分使用鼠标或触控设备滑动以旋转、移动、缩放模型。<br>
  其他功能部分采用Unity3D中自带的UGUI组件，利用其中的Button、Slider组件完成返回登录、刷新场景、相机归位、控制自动旋转速度功能。<br>
  用户界面效果图如图 4.7图 4.8所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FSOIVsXmhfc.png&amp;size=m" alt="图 4.7"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2F6jYGehgdaL.png&amp;size=m" alt="图 4.8"></p>
<h4 id="管理界面">管理界面</h4>
<p>管理界面与用户界面相同，同样采用色块堆叠配色方式，并由于管理员使用功能较多，将界面主要分为模型选择部分，模型修改部分，模型展示部分，用户选择部分，用户修改部分，本地选择部分，其他部分。<br>
  模型选择部分与用户界面相同，均采用Unity3D中自带的UGUI组件，利用组件特性完成弹性UI显示。<br>
  模型修改部分，采用UGUI组件中Button、InputField、Image组件完成对选择模型的加载、删除、更新模型组的操作。<br>
  用户选择部分，采用UGUI组件中Image、Scroll Rect、Grid Layout Froup、Content Size Fitter、Toggle Group组件完成用户选择部分的弹性UI显示。<br>
  用户修改部分，采用UGUI组件中Button、InputField、Image组件完成对用户信息的注册、修改、删除用户等操作。<br>
  本地选择部分，在用户点击“预览模型”按钮后会出现本地文件选择器，可通过选择器选择需要上传的模型文件，在确定选择后，会在模型展示部分展示模型情况，并当用户点击“上传”按钮后将模型上传到服务器。<br>
  管理界面效果图如图 4.9图 4.10图 4.11所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FPMTtxCMc3S.png&amp;size=m" alt="图 4.9"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FoVytmfCmk7.png&amp;size=m" alt="图 4.10"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2Ft5PKtODXnV.png&amp;size=m" alt="图 4.11"></p>
<h2 id="第5章-系统实现">第5章 系统实现</h2>
<h3 id="场景切换模块实现">场景切换模块实现</h3>
<p>场景切换模块，对于使用的用户来说应当是无感的，在打开程序时，首先加载空场景，在其中初始化需要单例模式与切换场景时不删除的GameManager模块与NoticeManager模块。<br>
  加载完成空场景模块时，同步加载登录模块，这样可以让用户在进入游戏时，可以快速加载场景而不会出现卡顿情况。<br>
  场景切换模块实现流程如图 5.1所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2Fb6gyvZCqpU.png&amp;size=m" alt="图 5.1"><br>
  对应主要代码如下：</p>
<pre><code class="language-csharp">public static GameManager Instance { get; private set; }
private void Awake()
{
    Instance = this;
    DontDestroyOnLoad(this);
}
private void Start()
{
    SceneManager.LoadScene("Login");
}

</code></pre>
<h3 id="登录模块实现">登录模块实现</h3>
<p>登录模块为用户进入应用程序首先发挥作用的模块，用户在登录模块中输入账号与密码，登录模块通过HTTP与服务器进行通讯，完成用户的鉴权，并返回用户是否成功登录。<br>
  登录模块实现流程图如图 5.2所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FOYxRfZXy1n.png&amp;size=m" alt="图 5.2"><br>
  客户端对应主要代码如下：</p>
<pre><code class="language-csharp">public void StartLoading()
{
    JsonData = new JsonData();
    jsonData["Md5Email"]= Md5.ToCalculateMd5(emailText.text);
    jsonData["Md5Password"]=Md5.ToCalculateMd5(password.text);
    var webRequest=GameManager.Instance.GetComponent&lt;WebRequest&gt;();
    webRequest.Post(GameManager.Instance.url+url, ((code, request, rsponse) =&gt;
    {
        if (rsponse.code==200)
        {
            var a=JsonConvert.DeserializeObject&lt;Tool.ReturnClass&gt;(rsponse.text);
            GameManager.Instance.userData.openId
                = Md5.ToCalculateMd5(emailText.text);
            GameManager.Instance.userData.email = emailText.text;
            GameManager.Instance.userData.password = password.text;
            GameManager.Instance.userData.token = a.data.token;
            GameManager.Instance.userData.@group = a.data.group;
            if (a.data.group!=0)
            {
                SceneManager.LoadScene("VirtualSimulation");
            }
            else
            {
                SceneManager.LoadScene("Admin");
            }
        }
        else
        {
            Debug.LogWarning(rsponse.text);
            try
            {
                var a=JsonConvert.DeserializeObject&lt;ToolReturnClass&gt;(rsponse.text);
                Notice.Instance.AccordingToNotice(a.messass,Color.red, true,null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Notice.Instance.AccordingToNotice("登录失败 请检查服务器链接",Color.red, true,null);
                throw;
            }
        }
    }),jsonData,"");

</code></pre>
<h3 id="模型加载模块实现">模型加载模块实现</h3>
<p>模型加载模块，用于在用户登录后，向后端请求用户权限内全部模型的链接，并将链接暂存到项目内存中，通过获取到的模型预览图链接加载模型预览图显示到项目UI中。<br>
  模型加载模块实现流程图如图 5.3所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2F1azZ96Pa6i.png&amp;size=m" alt="图 5.3"><br>
  客户端对应主要代码如下：</p>
<pre><code class="language-csharp">public void Load()
{
    JsonData jsonData = new JsonData();
    jsonData["openid"] = GameManager.Instance.userData.openId;
    jsonData["password"] 
= Md5.ToCalculateMd5(GameManager.Instance.userData.password);

    var webRequest = GameManager.Instance.GetComponent&lt;WebRequest&gt;();
    webRequest.Post(GameManager.Instance.url + url, (
        (code, request, rsponse) =&gt;
        {
            Debug.Log(rsponse.text);

            if (rsponse.code == 200)
            {
                var a = JsonConvert.DeserializeObject&lt;Tool.ReturnClassList&gt;(rsponse.text);

                // Debug.Log(a.data);

                foreach (var data in a.data)
                {
                    var _showABPackageReturn = new ShowABPackageReturn
                    {
                        Id = data.id,
                        Name = data.name,
                        Image = "https://kai.chengrui.xyz/VirtualSimulation/Image/" + data.image,
                        AB = "https://kai.chengrui.xyz/VirtualSimulation/AssetBundles/" + data.ab,
                        Group = data.group
                    };
                    showAbPackageReturns.Add(_showABPackageReturn);

                    GameObject g = Instantiate(displayBoxContent, this.transform);
                    displayBoxContentList.Add(g);
                    g.GetComponent&lt;Toggle&gt;().group = this.GetComponent&lt;ToggleGroup&gt;();
                    g.GetComponent&lt;DisplayBoxContent&gt;().showAbPackageReturn = _showABPackageReturn;
                }
            }
            else
            {
                try
                {
                    var a= JsonConvert.DeserializeObject&lt;ReturnClassList&gt;(rsponse.text);
                    Notice.Instance.AccordingToNotice(a.messass, Color.red, true, null);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Notice.Instance.AccordingToNotice("登陆失败 请检查服务器链接", Color.red, true, null);
                    throw;
                }
            }
        }), jsonData, GameManager.Instance.userData.token);
}

</code></pre>
<h3 id="模型显示模块实现">模型显示模块实现</h3>
<p>模型显示模块主要在用户选择模型后，从本地缓存的模型链接中下载模型并实例化。<br>
  模型显示模块实现流程图如图 5.3所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FimUTmvAwj4.png&amp;size=m" alt="图 5.3"><br>
  客户端对应主要代码如下：</p>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 下载并展示AB包
/// &lt;/summary&gt;
private void LoadChooseToAB()
{
    if (_toggle.isOn)
    {
        try
        {
            if (ABgameobject == null)
            {
                EventCenter.Broadcast(ENventType.UpdateAB);
                Debug.Log("收到加载广播");
                StartCoroutine(InstantiateObject(showAbPackageReturn.AB, (
                    ab =&gt;
                    {
                        AB = ab;
                        ABgameobject=Instantiate(ab.LoadAsset&lt;GameObject&gt;(showAbPackageReturn.Name));Notice.Instance.AccordingToNotice("加载成功",Color.green, true,null);
                    })));
            }
            else
            {
                Debug.Log("模型已被实例化");
                Notice.Instance.AccordingToNotice("模型已被实例化",Color.green, true,null);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            Notice.Instance.AccordingToNotice(e.Message,Color.red, true,null);
            throw;
        }
    }
}

</code></pre>
<h3 id="相机移动模块实现">相机移动模块实现</h3>
<p>相机移动是用户全方位查看模型的一个良好解决方法，本项目中，用户可以使用鼠标左键点击后拖动来控制相机的围绕旋转，使用鼠标右键点击拖动可实现相机的平行移动，使用鼠标滚轮可实现模型缩放，并且在触屏设备上，可以使用单指拖动的方式控制相机旋转，双指拖动的方式控制相机平移，双指缩放的方式，控制相机缩放。<br>
  相机移动模块客户端对应主要代码如下。</p>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 摄像机移动
/// &lt;/summary&gt;
/// &lt;param name="x"&gt;X轴移动数据&lt;/param&gt;
/// &lt;param name="y"&gt;Y轴移动数据&lt;/param&gt;
private void CameraMove(float x, float y)
{
    transform.Translate(Vector3.left * (x * 
GameManager.Instance.camaraOperation.cameraMoveSpeed 
* Time.deltaTime));
    transform.Translate(Vector3.up * (y * 
GameManager.Instance.camaraOperation.cameraMoveSpeed 
* Time.deltaTime));
}
/// &lt;summary&gt;
/// 摄像机旋转
/// &lt;/summary&gt;
/// &lt;param name="x"&gt;X轴移动数据&lt;/param&gt;
/// &lt;param name="y"&gt;Y轴移动数据&lt;/param&gt;
private void Rotate(float x, float y)
{
    //左右旋转
    Transform transform1;
    transform1 = this.transform;
    //左右旋转
    transform1.RotateAround(_target.transform.position, Vector3.up, x * 5);    
    //分拆旋转数值
    float a = transform1.rotation.eulerAngles.x;
    if (a &gt; 180)
    {
        a -= 360.0f;
    }
    //分拆处理上下旋转最大值
    if (y &gt; 0)
    {
        if (a &lt; GameManager.Instance.camaraLocationLimit.camaraAngle.y)
        {
    //上下旋转
            transform.RotateAround(_target.transform.position, transform.right, y * 5); 
        }
    }
    else if (y &lt; GameManager.Instance.camaraLocationLimit.camaraAngle.x)
    {
        if (a &gt; 0)
        {
    //上下旋转
            transform.RotateAround(_target.transform.position, transform.right, y * 5); 
        }
    }
}

</code></pre>
<h3 id="模型上传模块实现">模型上传模块实现</h3>
<p>模型上传模块，是管理员管理模型的一个主要方法，管理员点击预览本地模型后，在查看模型无误，设定模型组后，即可将模型上传到服务器，服务器对管理员身份进行验证成功后，将模型保存到对象存储，并且将下载路径保存至数据库中。<br>
  模型上传模块实现流程图如图 5.4所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FIOjHLZyvhG.png&amp;size=m" alt="图 5.4"></p>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 上传AB包
/// &lt;/summary&gt;
public void Upload()
{
   if (ABbyte != null &amp;&amp; ABname != null &amp;&amp; ABgameobject != null)
   {
      string group;
      //判断用户组是否为空
      if (String.IsNullOrEmpty(inputField.text))
      {
         group = "1";
      }
      else
      {
         group = inputField.text;
      }
      var webRequest=GameManager.Instance.GetComponent&lt;WebRequest&gt;();
      JsonData = new JsonData();
      jsonData["adminOpenId"] = GameManager.Instance.userData.openId;
      jsonData["adminPassword"] =  Md5.ToCalculateMd5(GameManager.Instance.userData.password);
      jsonData["name"] = ABname;
      jsonData["image"] = Screenshots.StartScreenshots(screenshotTheCamera);
      jsonData["ab"] = Convert.ToBase64String(ABbyte);
      jsonData["group"] = group;
      GameObject _g = Notice.Instance.AccordingToNotice("正在上传", null, false, null);
      webRequest.Post(GameManager.Instance.url+url, ((code, request, rsponse) =&gt;
      {
         Debug.Log(rsponse.text);
         if (rsponse.code==200)
         {
            EventCenter.Broadcast(ENventType.UpdateData);
            Notice.Instance.CloseToInform(_g);
            var a=JsonConvert.DeserializeObject&lt;Tool.ReturnClass&gt;(rsponse.text);
            Notice.Instance.AccordingToNotice(a.messass,Color.green, true,null);
         }
         else
         {
            Notice.Instance.CloseToInform(_g);
            Notice.Instance.AccordingToNotice("上传失败",Color.red, true,null);
         }

      }),jsonData,GameManager.Instance.userData.token);
   }
   else
   {
      Debug.Log("未选择AB包");
      Notice.Instance.AccordingToNotice("未选择AB包",Color.red, true,null);
   }
}

</code></pre>
<h3 id="用户信息展示模块实现">用户信息展示模块实现</h3>
<p>用户信息展示模块，是管理员管理全部用户信息的重要模块，在此模块中，管理员可查看全部用户基本信息，并对用户进行注册、删除、修改密码、修改用户组等操作。<br>
  用户信息展示模块实现流程图如图 5.5所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2Fm6WaQ2MIZb.png&amp;size=m" alt="图 5.5"><br>
  用户信息展示模块客户端对应主要代码如下：</p>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 加载用户数据
/// &lt;/summary&gt;
private void LoadingUserData()
{
    var webRequest= GameManager.Instance.GetComponent&lt;WebRequest&gt;();

    JsonData = new JsonData();
    jsonData["adminOpenId"] = GameManager.Instance.userData.openId;
    jsonData["adminPassword"] =  Md5.ToCalculateMd5(GameManager.Instance.userData.password);
    webRequest.Post(GameManager.Instance.url+_url, ((code, request, rsponse) =&gt;
    {
        Debug.Log(rsponse.text);
        if (rsponse.code==200)
        {
            var a=JsonConvert.DeserializeObject&lt;Tool.ReturnClassList&gt;(rsponse.text);
            foreach (var _data in a.data)
            {
                GameObject g= Instantiate(userPrefab,this.transform);
                users.Add(g);
                g.GetComponent&lt;Toggle&gt;().group = this.GetComponent&lt;ToggleGroup&gt;();
                g.GetComponent&lt;UserDataBox&gt;().email.text = _data.email;
                g.GetComponent&lt;UserDataBox&gt;().@group.text = _data.@group.ToString();
                UserDatas.Add(new UserData
                {
                    openID = _data.openID,
                    email = _data.email,
                    @group = _data.@group,
                });
            }
            
        }
        else
        {
            try
            {
                var a=JsonConvert.DeserializeObject&lt;ReturnClassList&gt;(rsponse.text);
                Notice.Instance.AccordingToNotice(a.messass,Color.red, true,null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Notice.Instance.AccordingToNotice("登录失败 请检查服务器链接",Color.red, true,null);
                throw;
            }
        }
    }),jsonData,GameManager.Instance.userData.token);
}

</code></pre>
<h2 id="第6章-系统测试">第6章 系统测试</h2>
<h3 id="系统测试方法">系统测试方法</h3>
<p>因为《虚拟仿真游戏》是一款全平台游戏应用，所以系统测试也可以叫软件测试，软件测试方法，简单来说就是测试软件的方法，软件测试是开发软件中非常重要的环节，软件测试方法分为单元测试、集成测试、白盒测试、黑盒测试等《虚拟仿真游戏》主要采用的是UI测试、白盒测试、黑盒测试。</p>
<h3 id="虚拟仿真游戏功能模块测试及结果">《虚拟仿真游戏》功能模块测试及结果</h3>
<h4 id="登录功能测试">登录功能测试</h4>
<p>登录功能，是正常使用《虚拟仿真游戏》的关键前提，首先，我们需要测试登录功能是否正常，我们需要在本地或在服务器部署Docker容器，在其中运行后端服务器程序，保证后台程序运行正常，测试过程如下。<br>
  测试项目：登录功能是否正常。<br>
  测试用例：当用户打开《虚拟仿真游戏》，显示登录界面，输入已在数据库中录入的注册信息，即输入用户邮箱和密码，点击登录，查看是否可以顺利登录。<br>
  测试流程：根据登录的测试用例方法，进行反复的登录操作，至少使用十位已注册用户信息，测试登录二十次。在登录功能测试的过程中，要着重测试输入用户信息不合法或输入错误的情况，查看《虚拟仿真游戏》是否能给予用户正确的信息返回。<br>
  测试结果：输入正确用户信息登录时如图 6.1所示，正常进入对应场景。输入错误用户信息登录时如图 6.2所示，有明显提示。测试完成后，一切运行正常，未出现漏洞。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FJSMgrZtLRU.png&amp;size=m" alt="图 6.1"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FSJUXvU4aJX.png&amp;size=m" alt="图 6.2"></p>
<h4 id="模型显示测试">模型显示测试</h4>
<p>模型显示，是查看模型情况的重要功能，测试模型显示前需正确登录已有账号，测试过程如下。<br>
  测试项目：模型显示功能是否正常。<br>
  测试用例：当用户进入客户端或管理端后，点击左侧模型预览图后，并点击加载模型，查看模型是否正确在画面中显示。<br>
  测试流程：根据模型显示测试用例方法，进行反复的加载模型操作，至少测试五个云端模型显示。在模型显示测试的过程中，要着重测试加载云端大模型时，是否在加载时会给予用户良好的提示，并在模型加载成功后是否给予用户正确的信息反馈，模型加载失败时，是否给与用户正确的信息返回。<br>
  测试结果：点击云端模型并加载过程时如图 6.3所示，模型加载成功时如图 6.4所示，模型加载失败时如图 6.5所示。测试完成后，一切运行正常，未出现漏洞。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FvCpD9gLXO9.png&amp;size=m" alt="图 6.3"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2F8du81sKSiF.png&amp;size=m" alt="图 6.4"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FO8ApVQtAk4.png&amp;size=m" alt="图 6.5"></p>
<h4 id="上传模型测试">上传模型测试</h4>
<p>上传模型，是管理员对模型库进行管理的有效方法，在上传模型前需正确登录管理员账号，测试过程如下。<br>
  测试项目：模型上传功能是否正常，上传错误模型是否可正确返回。<br>
  测试用例：当用户进入管理端后，点击预览模型，预览需要上传的模型后，设定模型组后，点击上传按钮，查看模型是否上传成功。<br>
  测试流程：根据上传模型测试用例方法，进行反复的上传模型操作，至少测试五个模型的预览与上传，并选择至少五次错误模型格式进行上传，在上传模型测试的过程中要着重测试上传错误模型时候，是否会给予用户正确的信息反馈，模型上传成功后是否会给予用户正确的信息返回。<br>
  测试结果：点击预览模型选择正确模型并上传成功如图 6.6所示，点击预览模型选择错误模型并上传如图 6.7所示，未选择模型直接点击上传如图 6.8所示。测试完成后，一切运行正常，未出现漏洞。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FrbtgdJIXh7.png&amp;size=m" alt="图 6.6"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FobSwMzjaWm.png&amp;size=m" alt="图 6.7"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FoFtYMlf1mm.png&amp;size=m" alt="图 6.8"></p>
<h4 id="修改用户信息测试">修改用户信息测试</h4>
<p>修改用户信息是管理员对用户管理的良好方式，修改用户信息需正确登录管理员账号，测试过程如下。<br>
  测试项目：修改用户功能是否正常。<br>
  测试用例：当用户进入管理端后，点击右侧选择用户后，输入新的密码或用户组，查看是否正确修改用户信息。<br>
  测试流程：根据修改用户信息测试用例方法，进行反复的修改用户信息操作，至少测试十次修改用户信息。在测试修改用户信息过程中，要着重测试修改用户信息不合法的情况，将唯一管理员权限修改为普通用户权限，并在各种情况下均给予用户友好的信息返回。<br>
  测试结果，正确修改用户信息如图 6.9所示，修改用户信息不合法时如图 6.10所示，修改唯一管理员权限时候如图 6.11所示。<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FbS8zV45eXd.png&amp;size=m" alt="图 6.9"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2FqeRY1rMRZ2.png&amp;size=m" alt="图 6.10"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F05%2F21%2Fj8F3LZxwdp.png&amp;size=m" alt="图 6.11"></p>
<h3 id="测试结论">测试结论</h3>
<p>经过对《虚拟仿真游戏》的主要功能进行了反复的用例测试，检验了《虚拟仿真游戏》的运行正常，并将发现的问题以及漏洞及时改正，使得《虚拟仿真游戏》无论是程序可靠性，还是在用户体验上都得到了进一步的提升，界面得到了进一步的美化，功能上得到了进一步的完善，简而言之，《虚拟仿真游戏》的测试，使得《虚拟仿真游戏》的各个当面都得到了进一步的优化。<br>
  综上所述，《虚拟仿真游戏》的测试过程和测试结果，证明《虚拟仿真游戏》的各个方面运行正常，《虚拟仿真游戏》的测试基本成功，质量良好。</p>
<h2 id="第7章-结论">第7章 结　论</h2>
<p>虚拟现实技术承载了人类对未来科技的无限幻想，而未曾发现，其实这项技术早已围绕这我们生活中的方方面面。购物是现代人必不可少的一种休闲活动，因此设计了一个满足用户购物过程中能更加清晰明了的看到商品，管理者能更加方便的向用户展示商品细节的一整套解决方法。<br>
  《虚拟仿真游戏》是通过游戏引擎搭建，将3d模型展示情景接入普通用户购物体验中的一个良好解决方案。通过《虚拟仿真游戏》消费者将可以简单方便的查看商品的全貌，卖家也可以通过该解决方案，向消费者更加快速准确的展示产品的优点。<br>
  《虚拟仿真游戏》在项目技术实现上，是采用Unity作为客户端，以Docker技术配合ASP.NET Core技术搭建后端服务器，并通过对象存储配合CDN内容分发快速分发模型文件。该客户端可运行在多种终端上，包括PC机、移动端、浏览器端等，并在项目开发时，对以上平台均做出了体验优化。后端服务器通过Docker技术可以简单快速部署在不同种类的服务器。在前后端传输过程中采用了HTTP连接方式，前端程序向后端程序发起请求后，由后端程序对请求进行鉴权后返回前端所请求的文件与数据，并将前端请求的数据存入MySql数据库中。<br>
  在本文论述部分，介绍了《虚拟仿真游戏》的设计背景，以及他的研究现状等方面的知识，让本项目的开发有了实现的价值。<br>
  在第2章中，本文介绍了如何制作项目，与项目所需要的运行环境，以及在项目开发过程中所使用的技术，这部分的知识让《虚拟仿真游戏》的设计与实现从技术层面来说是可行的。<br>
  第3章中，对项目进行了详细的需求分析，在需求分析的过程中，我们对项目的各项系统功能的可行性进行了充分的论证，并对项目的用户群体进行了详细的分析，对系统运行环境以及开发环境进行了简单论证，确定了《虚拟仿真游戏》项目是一个充满事实可行性的项目。<br>
  第4章中，对已经完成分析后的具体项目需求，进行其系统性的设计，并根据设计原则，对《虚拟仿真游戏》进行了具体系统设计。<br>
  第5章中，我们根据已经完成的系统设计，完成了《虚拟仿真游戏》的系统化实现，系统化实现中，实现了模块设计中的绝大部分的模块。<br>
  综上所述可以看出《虚拟仿真游戏》其广阔的应用性，市场前景良好。</p>
<h2 id="参考文献">参考文献</h2>
<p>[1] 谢佩洪, 成立. 中国PC网络游戏行业商业模式创新的演化研究[J]. 科研管理, 2016, 37(10):9.<br>
  [2] 高楠. 谈第九艺术的灵魂——三维游戏角色设计[J]. 中国科教创新导刊, 2014(4):1.<br>
  [3] 来小鹏, 贺文奕. 论电子游戏画面的作品属性[J]. 2021(2019-11):30-40.<br>
  [4] 王圣葳. 浅析基于Unity3D的游戏开发[J]. 数码设计, 2021, 10(10):1.<br>
  [5] 郭欣桐. 基于Unity的休闲益智类游戏设计与开发[J]. 电子技术与软件工程, 2021(1):3.<br>
  [6] 张衡. 玩游戏也是一种工作——走近游戏策划师[J]. 2021(2013-10):23-23.<br>
  [7] Doppioslash C. Your First Unity Shader[J]. 2018.<br>
  [8] 苏珂, 续鲁庆. 游戏设计中基于DBN的用户体验评估模型研究[J]. 包装工程, 2020, 41(2):7.<br>
  [9] 林书浩. 浅述Unity引擎简述与游戏制作流程[J]. 科学与信息化, 2020(17):2.<br>
  [10] 查天贝. 游戏美术在手机游戏界面上的思考[J]. 数码世界, 2020(1):1.<br>
  [11] 何剑. 游戏美术中地图与关卡编辑的课程设计[J]. 2020.<br>
  [12] 陈京炜. 游戏心理学[M]. 中国传媒大学出版社, 2015.<br>
  [13] 李智, 张云龙, 赵涛,等. 基于Unity Shader实现对三维渲染效果的控制[J]. 价值工程, 2021, 40(16):2.<br>
  [14] Alexiou A, Schippers M, Oshri I, et al. Narrative and aesthetics as antecedents of perceived learning in Serious Games[J]. Other publications TiSEM, 2020.<br>
  [15]杜月林, 黄刚, 王峰,等. 建设虚拟仿真实验平台 探索创新人才培养模式[J]. 实验技术与管理, 2015, 32(12):4.</p>
<h2 id="致--谢">致 谢</h2>
<p>首先感谢张华振老师在本次论文撰写和毕业设计作品制作过程中对我进行科学严谨的指导，在论文撰写和毕设期间，张华振老师主动监督我的工作进度，督促我保质保量的完成毕设和论文撰写工作，并在我遇到困难时与我进行深入讨论和分析，帮助我解决难题，使我能够顺利完成论文撰写和毕设制作。<br>
  感谢在大学时间里，高等职业技术学院全体老师与同学对我的帮助，没有各位老师同学的帮助，我可能没有充足信心完成论文的撰写与毕业设计，感谢虚拟现实19101班的全体同学，在大学时间里对我的种种鼓励与支持，让我逐渐成长。<br>
  在制作本项目的过程中，我学习到了很多以往没有掌握牢靠的知识，更重要的是，我了解到了作为一名软件开发人员，如何从零开始开发一套完整的系统软件，如何克服种种困难完成系统的搭建，如何从不同的角度去思考问题、解决问题。通过这次的系统设计，我学会了很多，也了解到了很多。<br>
  最后，还要向百忙中抽出时间来审阅本文的各位老师表示由衷的感谢。</p>]]></description><guid isPermaLink="false">/archives/266.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 21 May 2022 11:04:00 GMT</pubDate></item><item><title><![CDATA[C# 语法糖集合]]></title><link>https://blog.ccrui.cn/archives/263.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=C%23%20%E8%AF%AD%E6%B3%95%E7%B3%96%E9%9B%86%E5%90%88&amp;url=/archives/263.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="定义">定义</h2>
<p>语法糖(Syntactic sugar)，也译为糖衣语法，是由英国计算机科学家彼得·约翰·兰达（Peter J. Landin）发明的一个术语，指计算机语言中添加的某种语法，这种语法对语言的功能并没有影响，但是更方便程序员使用。</p>
<p>它可以使程序员更加容易去使用这门语言：操作可以变得更加清晰、方便，或者更加符合程序员的编程习惯。</p>
<p>简而言之，语法糖就是一种便捷写法。</p>
<h2 id="自动属性">自动属性</h2>
<p>未简化：手写私有变量+公有属性</p>
<pre><code class="language-csharp">private string _name;
public string Name
{
    get { return _name; }
    set { _name = value; }
}
</code></pre>
<p>简化：声明空属性，编译器自动生成对应私有成员字段。</p>
<pre><code class="language-csharp">public string Name { get; set; }
</code></pre>
<h2 id="参数默认值和命名参数">参数默认值和命名参数</h2>
<p>使用的指导原则：</p>
<ol>
 <li>可以为方法和有参属性指定默认值</li>
 <li>有默认值的参数，必须定义在没有默认值的参数之后</li>
 <li>默认参数必须是常量</li>
 <li>ref和out参数不能指定默认值</li>
</ol>
<pre><code class="language-csharp">public class User
{
    public string Name { get; set; }
    public int Age { get; set; }

    // 自动属性默认初始化
    public string Address { get; set; } = "江苏";

    // 设置参数默认值（age）
    public User(string name, string address, int age = 18)
    {
        this.Name = name;
        this.Age = age;
        this.Address = address;
    }
}

// 命名参数（指定address参数）
User user = new User("小王",address:"苏州");
</code></pre>
<h2 id="类型实例化">类型实例化</h2>
<pre><code class="language-csharp">// 使用对象初始化器:{},使用对象初始化器，必须提供一个无参的构造函数,可以只给部分属性初始化
User user = new User()
{
    Name = "小王",
    Age = 18,
    Address = "苏州",
 };

</code></pre>
<h2 id="组件懒加载">组件懒加载</h2>
<pre><code class="language-csharp">private Rigidbody2D _r2d;
public Rigidbody2D r2d =&gt; _r2d ??= GetComponent&lt;Rigidbody2D&gt;();
​
//等价于
//public Rigidbody2D r2d{
//    get{
//        if(_r2d == null)
//            _r2d = GetComponent&lt;Rigidbody2D&gt;();
//        return _r2d;
//    }
//}
</code></pre>
<h2 id="集合">集合</h2>
<h3 id="初始list集合的值">初始List集合的值</h3>
<pre><code class="language-csharp">// 简化之前
List&lt;string&gt; listString = new List&lt;string&gt;();
listString.Add("小王");
listString.Add("小贤");

// 简化后
List&lt;string&gt; listString = new List&lt;string&gt;() {
    "小王",
    "小贤",
};
</code></pre>
<h3 id="取list中的值">取List中的值</h3>
<pre><code class="language-csharp">// 简化之前
foreach (string str in listString)
{
    Console.WriteLine(str);
}
// 简化之后
listString.ForEach(s =&gt; Console.WriteLine(s));
</code></pre>
<h2 id="隐式类型var">隐式类型（var）</h2>
<p>程序员在声明变量时可以不指定类型，由编译器根据值来指定类型<br>
  var定义变量有以下四个特点：</p>
<ol>
 <li>必须在定义时初始化</li>
 <li>一旦初始化完成，就不能再给变量赋与初始值不同类型的值了</li>
 <li>var要求是局部变量</li>
 <li>使用var定义变量和object不同，它在效率上和使用强类型方式定义变量完全一样</li>
</ol>
<pre><code class="language-csharp">            // 1.隐式类型在定义时必须初始化
            //var name; 报错
            var name = "小王";
            // 2.可以用同类型的其他隐式类型变量来初始化新的隐式类型变量
            var age = 18;
            var ageTwo = age;
            // 3.也可以用同类型的字面量来初始化隐式类型变量
            var name = "小王";
            name = "小贤";
            // 4.隐式类型局部变量还可以初始化数组而不指定类型
            var array = new List&lt;string&gt;() { "小王","小贤",};
</code></pre>
<h2 id="扩展方法">扩展方法</h2>
<p>扩展方法使你能够向现有类型“添加”方法，而无需创建新的派生类型、重新编译或以其他方式修改原始类型。 扩展方法是一种特殊的静态方法，但可以像扩展类型上的实例方法一样进行调用。<br>
  注意：定义扩展方法的类必须和使用地方的类命名空间相同(如果不同命名空间记得先引入命名空间)</p>
<pre><code class="language-csharp">// 为string 添加一个扩展方法（判断string是否为空||null）
public static bool IsEmpty(this string str)
{
    return string.IsNullOrEmpty(str);
}
</code></pre>
<h2 id="匿名类型anonymous-type">匿名类型（Anonymous type）</h2>
<p>匿名类型提供了一种方便的方法，可用来将一组只读属性封装到单个对象中，而无需首先显式定义一个类型。 类型名由编译器生成，并且不能在源代码级使用。 每个属性的类型由编译器推断。可通过使用 new 运算符和对象初始值创建匿名类型。</p>
<p>匿名类型的限制：</p>
<ol>
 <li>匿名类型不支持事件、自定义方法和自定义重写</li>
 <li>匿名类型是隐式封闭的</li>
 <li>匿名类型的实例创建只使用默认构造函数</li>
 <li>匿名类型没有提供可供控制的类名称（使用var定义的）</li>
</ol>
<pre><code class="language-csharp">var unUser = new { Name = "小王", Age = 18, Phone = "123456" };
</code></pre>
<h2 id="匿名方法anonymous-methods">匿名方法（Anonymous methods）</h2>
<p>普通方法定义方式，因为方法的存在是为了复用一段代码，所以一般会给方法取个名字，这个方法的引用就可以通过“方法名”调用匿名方法:<br>
  但是有的方法，不需要复用，仅仅是使用一次就够了，所以不需要方法名，这种方法就叫做匿名方法。<br>
  匿名方法必须结合委托使用。（潜在的意思就是：尽管没有方法名了，但方法的指针还是存放了某个委托对象中）</p>
<p>注意：</p>
<ol>
 <li>在编译后，会为每个匿名方法创建一个私有的静态方法，然后将此静态方法传给委托对象使用</li>
 <li>匿名方法编译后会生成委托对象，生成方法，然后把方法装入委托对象，最后赋值给声明的委托变量</li>
 <li>匿名方法可以省略参数，编译的时候会自动为这个方法按照委托签名的参数添加参数</li>
</ol>
<h2 id="dynamic动态对象">dynamic动态对象</h2>
<p>.net4.0中引入了一个新类型 dynamic.该类型是一种静态类型，但类型为 dynamic 的对象会跳过静态类型检查.大多数情况下，该对象就像具有类型 object 一样.在编译时，将假定类型化为 dynamic 的元素支持任何操作</p>
<pre><code class="language-csharp">dynamic dy = "string";
Console.WriteLine(dy.GetType());
//输出：System.String
dy = 100;
Console.WriteLine(dy.GetType());
//输出：System.Int32
</code></pre>
<h2 id="字符串嵌入值">字符串嵌入值</h2>
<p>c#6.0后新增的特性 $，用于代替string.Format("")</p>
<pre><code class="language-csharp">// 之前
var str=string.Format("时间：{0}", DateTime.Now);
// 改进
var str=$"时间：{DateTime.Now}";
</code></pre>
<h2 id="问号表达式">问号(?)表达式</h2>
<h3 id="可空类型修饰符">可空类型修饰符（？）</h3>
<p>引用类型可以使用空引用表示一个不存在的值，而值类型通常不能表示为空。</p>
<pre><code class="language-csharp">string str = null;// 正确
//int i = null; // 错误
</code></pre>
<p>为了使值类型也可为空，就可以使用可空类型，，可以使用 Nullable泛型结构来定义，但是微软为了语法更简洁，提供了?运算符来定义可空类型，二者效果是一样的，基本语法如下：<br>
  值类型? 变量名=值;</p>
<pre><code class="language-csharp">// 这二种定义可空类型的方法都是对的，但是？更简洁
Nullable&lt;int&gt; intOne = 5;
int? intTwo = 5;
</code></pre>
<h3 id="三元运算符表达式-">三元（运算符）表达式（?: )</h3>
<pre><code class="language-csharp">int gender = 1;
string str = gender == 1 ? "男" : "女";
</code></pre>
<h3 id="合并运算符">合并运算符(??)</h3>
<p>合并运算符使用??表示，当进行转换时，如果可空类型的值为 null，则使用默认值。</p>
<pre><code class="language-csharp">int? intA = null;
int intB = 100;
intB = intA ?? 0;//此处intA为null，则将0赋值给intB

int? intC = 500;
intB = intC ?? 0;//此处intC不为null，则将500赋值给intB
</code></pre>
<h3 id="null检查运算符">NULL检查运算符（?.）</h3>
<p>C# 6.0中，引入了 ?. 的运算符，可帮助编写更少的代码来处理 null 检查<br>
  如果对象为NULL，则不进行后面的获取成员的运算，直接返回NULL</p>
<pre><code class="language-csharp">string str = "abcd";
string s1 = null;
Console.WriteLine(str?.Length);// 输出 4
Console.WriteLine(s1?.Length);// 输出空
</code></pre>
<h3 id="运算符">"?[]"运算符</h3>
<pre><code class="language-csharp">int? first = customers?[0].Orders.Count();
</code></pre>
<h2 id="使用完毕后自动释放资源using--try-finally">使用完毕后自动释放资源(Using || try finally)</h2>
<p>为了节约资源，每次使用完毕后都要释放掉资源，其中可以使用Using和try finally来进行释放资源操作。需要注意的是使用Using释放资源的对象都必须继承IDisposable接口（MSDN）。</p>
<pre><code class="language-csharp">// try finally 写法
SqlConnection conn = null;
try
{
    conn = new SqlConnection("数据库连接字符串");
    conn.Open();
}
finally
{
    conn.Close();
    conn.Dispose();
}

// Using写法
using (SqlConnection conn=new SqlConnection("数据库连接字符串"))
{
      conn.Open();
}
</code></pre>
<h2 id="委托">委托</h2>
<h3 id="基本用法">基本用法</h3>
<p>在.net 1.1时我们不得不声明方法后才在委托中使用<br>
  在.net 2.0之后我们可以使用匿名委托，他不单可以简化写法，还可以在匿名委托中访问范围内的变量；<br>
  再后来Lambda表达式来了，写法就更简便了。</p>
<pre><code class="language-csharp">class MyClass
{
    //定义委托
    public delegate void TestDelegate(string str);
    //定义委托方法
    public void Method(string str)
    {
        Console.WriteLine(str);
    }
    public void UseDelegate(TestDelegate d, string str)
    {
        d(str);
    }
}

//调用委托
MyClass mc = new MyClass();
//调用定义的委托方法
mc.UseDelegate(new MyClass.TestDelegate(mc.Method), "Hello!");

//使用匿名委托
mc.UseDelegate(delegate(string str)
{
    Console.WriteLine(str);
}, "Hello!");
            
//使用Lambda表达式
mc.UseDelegate(s =&gt;
{
    Console.WriteLine(s);
}, "Hello!");
</code></pre>
<h3 id="内置委托">内置委托</h3>
<p>CLR环境中给我们内置了几个常用委托Action、 Action、Func、Predicate，一般我们要用到委托的时候，尽量不要自己再定义一 个委托了，就用系统内置的这几个已经能够满足大部分的需求，且让代码符合规范。</p>
<ul>
 <li>如果要委托的方法没有参数也没有返回值就想到<code>Action</code></li>
 <li>有参数但没有返回值就想到<code>Action&lt;T&gt;</code></li>
 <li>无参数有返回值、有参数且有返回值就想到<code>Func&lt;T&gt;</code></li>
 <li>有bool类型的返回值，多用在比较器的方法，要委托这个方法就想到用<code>Predicate&lt;T&gt;</code></li>
</ul>
<h4 id="action">Action</h4>
<p>Action封装的方法没有参数也没有返回值，声明原型为：</p>
<pre><code class="language-csharp">public delegate void Action();
</code></pre>
<p>用法如下：</p>
<pre><code class="language-csharp">public void Alert()
{
    Console.WriteLine("这是一个警告");
}

Action t = new Action(Alert); //  实例化一个Action委托
t();
</code></pre>
<p>如果委托的方法里的语句比较简短，也可以用Lambd表达式直接把方法定义在委托中，如下：</p>
<pre><code class="language-csharp">Action t = () =&gt; { Console.WriteLine("这是一个警告"); };
t();
</code></pre>
<h4 id="action-1">Action</h4>
<p>Action是Action的泛型实现，也是没有返回值，但可以传入最多16个参数，两个参数的声明原型为：</p>
<pre><code class="language-csharp">public delegate void Action&lt;in T1, in T2&gt;(T1 arg1, T2 arg2);
</code></pre>
<p>用法如下：</p>
<pre><code class="language-csharp">private void ShowResult(int a, int b)
{
    Console.WriteLine(a + b);
}

Action&lt;int, int&gt; t = new Action&lt;int, int&gt;(ShowResult);//两个参数但没返回值的委托
t(2, 3);
</code></pre>
<p>同样也可以直接用Lambd表达式直接把方法定义在委托中，代码如下：</p>
<pre><code class="language-csharp">Action&lt;int, int&gt; t = (a,b) =&gt; { Console.WriteLine(a + b); };
t(2, 3);
</code></pre>
<h4 id="func">Func</h4>
<p>Func委托始终都会有返回值，返回值的类型是参数中最后一个，可以传入一个参数，也可以最多传入16个参数，但可以传入最多16个参数，两个参数一个返回值的声明原型为：</p>
<pre><code class="language-csharp">public delegate TResult Func&lt;in T1, in T2, out TResult&gt;(T1 arg1, T2 arg2);
</code></pre>
<p>用法如下：</p>
<pre><code class="language-csharp">public bool Compare(int a, int b)
{
    return a &gt; b;
}

Func&lt;int, int, bool&gt; t = new Func&lt;int, int, bool&gt;(Compare);//传入两个int参数，返回bool值
bool result = t(2, 3);
</code></pre>
<p>同样也可以直接用Lambd表达式直接把方法定义在委托中，代码如下：</p>
<pre><code class="language-csharp">Func&lt;int, int, bool&gt; t = (a, b) =&gt; { return a &gt; b; };
bool result = t(2, 3);
</code></pre>
<h4 id="predicate">Predicate</h4>
<p>Predicate委托表示定义一组条件并确定指定对象是否符合这些条件的方法，返回值始终为bool类型，声明原型为：</p>
<pre><code class="language-csharp">public delegate bool Predicate&lt;in T&gt;(T obj);
</code></pre>
<p>用法如下：</p>
<pre><code class="language-csharp">public bool Match(int val)
{
    return val &gt; 60;
}

Predicate&lt;int&gt; t = new Predicate&lt;int&gt;(Match);   //定义一个比较委托
int[] arr = { 13, 45, 26, 98, 3, 56, 72, 24 };
int first = Array.Find(arr, t);                 //找到数组中大于60的第一个元素
</code></pre>
<p>同样也可以直接用Lambd表达式直接把方法定义在委托中，代码如下：</p>
<pre><code class="language-csharp">Predicate&lt;int&gt; t = val =&gt; { return val &gt; 60;};   //定义一个比较委托
int[] arr = { 13, 45, 26, 98, 3, 56, 72, 24 };            
int first = Array.Find(arr, t);                  //找到数组中大于60的第一个元素
</code></pre>
<h2 id="lambda表达式">Lambda表达式</h2>
<p>Lambda表达式是比匿名方法更简洁的一种匿名方法语法<br>
  最基本的Lambda表达式语法:<br><code>{参数列表}=&gt;{方法体}</code><br>
  例如：<br><code>(int x)=&gt;{returm x+1}</code><br>
  说明：<br>
  1、参数列表中的参数类型可以是明确类型或推断类型<br>
  2、如果是推断类型，则参数的数据类型将由编译器根据上下文自动推断出来</p>
<p>如果参数列表只包含一个推断类型参数时：<br><code>参数列表=&gt;{方法体}</code><br>
  前提：x的数据类型可以根据上下文推断出来<br><code>x =&gt;{returm x+1}</code></p>
<p>如果方法体只包含一条语句时：<br><code>{参数列表}=&gt;表达式</code><br><code>{int x} =&gt; x+1;</code></p>
<p>Lambda表达式示例：<br>
  1、多参数，推断类型参数列表，表达式方法体<br><code>(x,y) =&gt; x*y</code><br>
  2、无参数，表达式方法体<br><code>() =&gt; Console.WriteLine()</code><br>
  3、多参数，推断类型参数列表，多语句方法体，需要使用{}<br><code>(x,y) =&gt; {Console.WriteLine(x);Console.WriteLine(y)}</code></p>
<p>Lambda表达式缩写推演<br><code>new Func&lt;string,int&gt;(delegate(string str){return str.Length;});//内置委托</code><br><code>delegate(string str){return str.Length;}//匿名方法</code><br><code>(string str)=&gt;{return str.Length};//Lambda表达式</code><br><code>(str)=&gt;str.Length;//让编译器推断类型</code><br><code>str=&gt;str&gt;Length;//去掉不必要的括弧</code></p>
<h2 id=""></h2>]]></description><guid isPermaLink="false">/archives/263.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 11 May 2022 08:55:00 GMT</pubDate></item><item><title><![CDATA[简单的Unity全局弹窗方式]]></title><link>https://blog.ccrui.cn/archives/259.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E7%AE%80%E5%8D%95%E7%9A%84Unity%E5%85%A8%E5%B1%80%E5%BC%B9%E7%AA%97%E6%96%B9%E5%BC%8F&amp;url=/archives/259.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="简单的unity全局弹窗方式">简单的Unity全局弹窗方式</h1>
<p>Unity版本2020.3.27f</p>
<p><a href="https://cr-zhichen.github.io/SimplePopupWindow/">WebGL示例</a></p>
<h2 id="资源使用方式">资源使用方式</h2>
<ol>
 <li>直接克隆该项目</li>
 <li>导入<a href="https://github.com/cr-zhichen/SimplePopupWindow/releases">unitypackage包</a></li>
</ol>
<h2 id="使用方法">使用方法</h2>
<h3 id="显示弹窗">显示弹窗</h3>
<pre><code class="language-csharp">
PopupWindowControl.Instance.AccordingToPopupWindow(new PopupWindowControl.CC_PopupWindow()
        {
            Title = new PopupWindowControl.CC_Title()
            {
                TitleColor = new Color(1.0f,0.5f,0.5f,1.0f),
                TitleText = "示例标题",
                TitleTextColor = Color.white
            },
            Body = new PopupWindowControl.CC_Body()
            {
                BodyColor = new Color(1.0f,0.5f,0.5f,1.0f),
                BodyText = "示例内容",
                BodyTextColor = Color.white
            },
            Buttons = new List&lt;PopupWindowControl.CC_Button&gt;()
            {
                new PopupWindowControl.CC_Button()
                {
                    ButtonColor =new Color(1.0f,0.5f,0.5f,1.0f),
                    ButtonText = "确定",
                    ButtonTextColor = Color.white,
                    CallBack = (g =&gt;
                    {
                        Debug.Log("按下按钮");
                        PopupWindowControl.Instance.ClosePopupWindow(g);
                    })
                },
                new PopupWindowControl.CC_Button()
                {
                    ButtonColor = Color.gray,
                    ButtonText = "取消",
                    ButtonTextColor = Color.white,
                    CallBack = (g =&gt;
                    {
                        Debug.Log("按下按钮");
                        PopupWindowControl.Instance.ClosePopupWindow(g);
                    })
                }
            }
        });
        
</code></pre>
<h3 id="关闭弹窗">关闭弹窗</h3>
<pre><code class="language-csharp">
PopupWindowControl.Instance.ClosePopupWindow(g);

</code></pre>
<h2 id="演示视频">演示视频</h2>
<p><a href="https://user-images.githubusercontent.com/57337795/160265258-99da2131-100a-44ed-89d9-fdcb6bb60dd6.mp4">https://user-images.githubusercontent.com/57337795/160265258-99da2131-100a-44ed-89d9-fdcb6bb60dd6.mp4</a></p>
<p>您的浏览器不支持播放该视频！</p>]]></description><guid isPermaLink="false">/archives/259.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 27 Mar 2022 03:29:00 GMT</pubDate></item><item><title><![CDATA[简单的Unity全局通知]]></title><link>https://blog.ccrui.cn/archives/256.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E7%AE%80%E5%8D%95%E7%9A%84Unity%E5%85%A8%E5%B1%80%E9%80%9A%E7%9F%A5&amp;url=/archives/256.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="简单的unity全局通知">简单的Unity全局通知</h1>
<p><a href="https://cr-zhichen.github.io/SimpleNotification/">WebGl示例</a></p>
<h2 id="资源使用方式">资源使用方式</h2>
<ol>
 <li>直接克隆该项目</li>
 <li>导入<a href="https://github.com/cr-zhichen/SimpleNotification/releases">unitypackage包</a></li>
</ol>
<h2 id="使用方法">使用方法</h2>
<h3 id="显示通知">显示通知</h3>
<p>示例调用：</p>
<pre><code class="language-c#">GameObject _notice =  Notice.Instance.AccordingToNotice(new Notice.NotifyVariable()
        {
            //通知文字
            text = "通知文字",
            //通知颜色
            color = Color.Red,
            //通知是否自动消失
            whetherToShutDownAutomatical = true,
            //通知消失时间
            showTime = 3.0f
        },(g) =&gt;
        {
            //点击通知后删除通知
            Notice.Instance.CloseToInform(g);
        });
</code></pre>
<h3 id="关闭对应通知">关闭对应通知</h3>
<p>示例调用：</p>
<pre><code class="language-c#">Notice.Instance.CloseToInform(_notice);
</code></pre>
<h3 id="关闭所有通知">关闭所有通知</h3>
<p>示例调用：</p>
<pre><code class="language-c#">Notice.Instance.CloseToInform();
</code></pre>
<h3 id="更换通知颜色与文字">更换通知颜色与文字</h3>
<p>示例调用：</p>
<pre><code class="language-c#">public void LoadingNotice()
    {
        Coroutine _Load = null;
        
        GameObject _g= Notice.Instance.AccordingToNotice(new Notice.NotifyVariable()
        {
            text = "加载中",
            color = new Color(1.0f,0.5f,0.5f,0.5f),
            whetherToShutDownAutomatical = false,
            showTime = 0
        }, (g) =&gt;
        {
            Notice.Instance.CloseToInform(g);
            StopCoroutine(_Load);
        });
        
         _Load = StartCoroutine(Load(_g));
    }

    IEnumerator Load(GameObject g)
    {
        string s = "加载中";
        float timer=0;
        while (true)
        {
            if (s.Length&gt;=10)
            {
                s = "加载中";
            }
            else
            {
                s += ".";
            }
            Notice.Instance.ChangeNotice(g,null, s);
            yield return new WaitForSeconds(0.5f);
            timer += 0.5f;
            if (timer&gt;5.0f)
            {
                Notice.Instance.ChangeNotice(g,new Color(0.5f,1.0f,0.5f,0.5f),"加载完成");
                //延迟一秒关闭
                yield return new WaitForSeconds(1.0f);
                Notice.Instance.CloseToInform(g);
                break;
            }
        }
    }
</code></pre>
<h2 id="演示视频">演示视频</h2>
<p><a href="https://user-images.githubusercontent.com/57337795/161046944-c2138569-c8a2-4dd7-9435-d04665d054a7.mp4">https://user-images.githubusercontent.com/57337795/161046944-c2138569-c8a2-4dd7-9435-d04665d054a7.mp4</a></p>
<p>您的浏览器不支持播放该视频！</p>]]></description><guid isPermaLink="false">/archives/256.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 26 Mar 2022 06:36:00 GMT</pubDate></item><item><title><![CDATA[.NetMd5计算]]></title><link>https://blog.ccrui.cn/archives/253.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=.NetMd5%E8%AE%A1%E7%AE%97&amp;url=/archives/253.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="netmd5计算">.NetMd5计算</h1>
<h2 id="方法1">方法1</h2>
<pre><code class="language-csharp">//32位大写
    using (var md5 = MD5.Create())
    {
        var result = md5.ComputeHash(Encoding.UTF8.GetBytes(inputValue));
        var strResult = BitConverter.ToString(result);
        string result3 = strResult.Replace("-", "");
        Console.WriteLine(result3);
    }
</code></pre>
<h2 id="方法2">方法2</h2>
<pre><code class="language-csharp">//32位大写
using (var md5 = MD5.Create())
{
    var data = md5.ComputeHash(Encoding.UTF8.GetBytes(inputValue));
    StringBuilder builder = new StringBuilder();
    // 循环遍历哈希数据的每一个字节并格式化为十六进制字符串 
    for (int i = 0; i &lt; data.Length; i++)
    {
        builder.Append(data[i].ToString("X2"));
    }
    string result4 = builder.ToString();
    Console.WriteLine(result4);
}
</code></pre>
<h2 id="方法3">方法3</h2>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// MD5加密字符串（32位大写）
/// &lt;/summary&gt;
/// &lt;param name="source"&gt;源字符串&lt;/param&gt;
/// &lt;returns&gt;加密后的字符串&lt;/returns&gt;
public static string MD5(string source)
{
    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
    byte[] bytes = Encoding.UTF8.GetBytes(source);
    string result = BitConverter.ToString(md5.ComputeHash(bytes));
    return result.Replace("-", "");
}
</code></pre>
<h2 id="方法4">方法4</h2>
<pre><code class="language-csharp">//16位大写
using (var md5 = MD5.Create())
{
    var data = md5.ComputeHash(Encoding.UTF8.GetBytes(inputValue));
    StringBuilder builder = new StringBuilder();
    // 循环遍历哈希数据的每一个字节并格式化为十六进制字符串 
    for (int i = 0; i &lt; data.Length; i++)
    {
        builder.Append(data[i].ToString("X2"));
    }
    string result4 = builder.ToString().Substring(8, 16);
    Console.WriteLine(result4);
}
</code></pre>]]></description><guid isPermaLink="false">/archives/253.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 13 Mar 2022 05:08:00 GMT</pubDate></item><item><title><![CDATA[.Net邮箱合法性验证]]></title><link>https://blog.ccrui.cn/archives/254.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=.Net%E9%82%AE%E7%AE%B1%E5%90%88%E6%B3%95%E6%80%A7%E9%AA%8C%E8%AF%81&amp;url=/archives/254.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="net邮箱合法性验证">.Net邮箱合法性验证</h1>
<blockquote>
 <p><a href="https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/how-to-verify-that-strings-are-in-valid-email-format">https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/how-to-verify-that-strings-are-in-valid-email-format</a></p>
</blockquote>
<pre><code class="language-csharp">using System;
using System.Globalization;
using System.Text.RegularExpressions;

namespace RegexExamples
{
    class RegexUtilities
    {
        public static bool IsValidEmail(string email)
        {
            if (string.IsNullOrWhiteSpace(email))
                return false;

            try
            {
                // Normalize the domain
                email = Regex.Replace(email, @"(@)(.+)$", DomainMapper,
                                      RegexOptions.None, TimeSpan.FromMilliseconds(200));

                // Examines the domain part of the email and normalizes it.
                string DomainMapper(Match match)
                {
                    // Use IdnMapping class to convert Unicode domain names.
                    var idn = new IdnMapping();

                    // Pull out and process domain name (throws ArgumentException on invalid)
                    string domainName = idn.GetAscii(match.Groups[2].Value);

                    return match.Groups[1].Value + domainName;
                }
            }
            catch (RegexMatchTimeoutException e)
            {
                return false;
            }
            catch (ArgumentException e)
            {
                return false;
            }

            try
            {
                return Regex.IsMatch(email,
                    @"^[^@\s]+@[^@\s]+\.[^@\s]+$",
                    RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
            }
            catch (RegexMatchTimeoutException)
            {
                return false;
            }
        }
    }
}
</code></pre>]]></description><guid isPermaLink="false">/archives/254.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 13 Mar 2022 05:08:00 GMT</pubDate></item><item><title><![CDATA[Swagger 注释显示]]></title><link>https://blog.ccrui.cn/archives/251.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Swagger%20%E6%B3%A8%E9%87%8A%E6%98%BE%E7%A4%BA&amp;url=/archives/251.html" width="1" height="1" alt="" style="opacity:0;">
<p><a href="https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-6.0&amp;tabs=visual-studio-code">https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-6.0&amp;tabs=visual-studio-code</a></p>]]></description><guid isPermaLink="false">/archives/251.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 7 Mar 2022 14:59:00 GMT</pubDate></item><item><title><![CDATA[跟着官网学ASP. NET Core 6.0之通过EF Core6.0操作数据库]]></title><link>https://blog.ccrui.cn/archives/250.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E8%B7%9F%E7%9D%80%E5%AE%98%E7%BD%91%E5%AD%A6ASP.%20NET%20Core%206.0%E4%B9%8B%E9%80%9A%E8%BF%87EF%20Core6.0%E6%93%8D%E4%BD%9C%E6%95%B0%E6%8D%AE%E5%BA%93&amp;url=/archives/250.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="跟着官网学asp-net-core-60之通过ef-core60操作数据库">跟着官网学ASP. NET Core 6.0之通过EF Core6.0操作数据库</h1>
<blockquote>
 <p>转载于<a href="https://baijiahao.baidu.com/s?id=1723155767358769649">跟着官网学ASP. NET Core 6.0之通过EF Core6.0操作数据库</a></p>
</blockquote>
<p>连接数据库自然需要相应的数据库驱动，在微软官方也给我列出了相应数据库的驱动程序，如下图:</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FWecAzl3H7W.png&amp;size=m" alt=""></p>
<h2 id="安装mysql驱动">安装MySQL驱动</h2>
<p>安装<code>NuGet</code>包方式有多种，如直接在包命令行输入<code>Install-Package Pomelo.EntityFrameworkCore.MySql -Version 6.0.0</code>进行安装，或者通过<code>.NET CLI</code>执行<code>dotnet add package Pomelo.EntityFrameworkCore.MySql --version 6.0.0</code>进行安装，又或者在.csproj中加入<code>&lt;PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0" /&gt;</code>进行安装，等等。当然我还是比较喜欢图形化操作,在VS中依赖项(右键)-&gt;选择<code>NuGet</code>程序包-&gt;输入<code>Pomelo.EntityFrameworkCore.MySql</code>回车搜索-&gt;点击安装</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FMqOJ096DOb.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FBj0XF5irUC.png&amp;size=m" alt=""></p>
<h2 id="配置数据库">配置数据库</h2>
<p>我们先在appsettings.json增加数据库连接,如下:</p>
<pre><code class="language-json">{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",

  "ConnectionStrings": {
    "MysqlConnectionString": "Server=47.99.***.***;User=***;Password=***;Database=***"
  }

}
</code></pre>
<p>继续去<code>Program.cs</code>配置数据库</p>
<pre><code class="language-csharp">///new Version(5, 5, 62)为MySql版本号
var serverVersion = new MySqlServerVersion(new Version(5, 5, 62));
string connectionString = builder.Configuration.GetConnectionString("MysqlConnectionString");
builder.Services.AddDbContext&lt;DrugContext&gt;(opt =&gt;
{
    opt.UseMySql(connectionString, serverVersion);
});
</code></pre>
<p>数据库便配置好了，我接下来便是迁移数据库</p>
<h2 id="迁移数据库">迁移数据库</h2>
<p>这里我们从工具-&gt;<code>NuGet</code>包管理器-&gt;程序包管理器控制台,执行<code>Add-Migration InitialCreate</code>命令</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FC53GHadAjE.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FCudESk96MV.png&amp;size=m" alt=""></p>
<p>执行成功后，会在项目下生成迁移文件，并且会在数据库中创建一个名为<code>__efmigrationshistory</code>的记录表</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FAjmmasCW9S.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FuZZ84vEyYO.png&amp;size=m" alt=""></p>
<p>我们打开<code>20220116090024_InitialCreate</code>即可看到生成好的迁移代码，我们可以看到，<code>Id</code>列为<code>MySqlValueGenerationStrategy.IdentityColumn</code>，会自动生成为Id递增。我们在程序包管理器控制台继续执行<code>Update-Database</code>命令，它便会帮我们在数据库中创建好表</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FwIwdkwBh9W.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FNvQqWVVRdn.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FVIxOd9vEpQ.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FN4sRVQnxhM.png&amp;size=m" alt=""></p>
<h1 id="测试webapi">测试WebApi</h1>
<p>数据库已连接，数据库中的表也已生成好，那么接下来就去测试下我们的API能否正常工作。</p>]]></description><guid isPermaLink="false">/archives/250.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 6 Mar 2022 14:05:00 GMT</pubDate></item><item><title><![CDATA[跟着官网学ASP. NET Core 6.0之创建WebApi项目]]></title><link>https://blog.ccrui.cn/archives/249.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E8%B7%9F%E7%9D%80%E5%AE%98%E7%BD%91%E5%AD%A6ASP.%20NET%20Core%206.0%E4%B9%8B%E5%88%9B%E5%BB%BAWebApi%E9%A1%B9%E7%9B%AE&amp;url=/archives/249.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="跟着官网学asp-net-core-60之创建webapi项目">跟着官网学ASP. NET Core 6.0之创建WebApi项目</h1>
<blockquote>
 <p>转载于 <a href="https://baijiahao.baidu.com/s?id=1723021636881242080&amp;wfr=spider&amp;for=pc">跟着官网学ASP. NET Core 6.0之创建WebApi项目</a></p>
</blockquote>
<h2 id="新建web-api接口">新建WEB API接口</h2>
<h3 id="新建实体类">新建实体类</h3>
<p>在项目目录中新建一个<code>Models</code>文件夹用于存放实体类，新建一个名为<code>Order</code>类</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FJiiO1uMpFt.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FYXUcYx9Up0.png&amp;size=m" alt=""></p>
<pre><code class="language-csharp">Public class Order
{
    public long Id{get;set}

    public string OrderNo{get;set}

    public decimal Amount{get;set}

    public DateTime CreateTime{get;set}
}
</code></pre>
<h3 id="创建数据库访问">创建数据库访问</h3>
<p>首先通过<code>NuGet</code>安装<code>Microsoft.EntityFrameworkCore.InMemory</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FKEh2wQuXen.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FZHpPXPsheP.png&amp;size=m" alt=""></p>
<p>新建一个名为DemoContext的数据库上下文类并继承DbContext类</p>
<pre><code class="language-csharp">
public class DemoContext:DbContext
{
    public DemoContext(DbContextOptions&lt;DemoContext&gt;options):base(options){}
    public DbSet&lt;Order&gt; Orders{get;set;}=null!;
}

</code></pre>
<h3 id="新增接口">新增接口</h3>
<p>新建一个API控制器，在选中模型后，会安装一些依赖包，我们需要耐心的等待一下</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FBi7EdcWLZg.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FctzLkSE3Qq.png&amp;size=m" alt=""><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FRfq4w57cLA.png&amp;size=m" alt=""></p>
<p>VS会为我们生成比较全的CRUD代码</p>
<p>代码中我们可以看到4种接口请求方式HttpGet(查询)、HttpPut(修改)、HttpPost(新增)、HttpDelete(删除)，Route中也带有api路径,我们的接口便在api目录下,此时，我们运行起来便可在Swagger中看到刚才新增的接口</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F03%2F06%2FyWSKgaYE7U.png&amp;size=m" alt=""></p>]]></description><guid isPermaLink="false">/archives/249.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 6 Mar 2022 13:55:00 GMT</pubDate></item><item><title><![CDATA[Unity UnityWebRequest Get与Post应用]]></title><link>https://blog.ccrui.cn/archives/248.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity%20UnityWebRequest%20Get%E4%B8%8EPost%E5%BA%94%E7%94%A8&amp;url=/archives/248.html" width="1" height="1" alt="" style="opacity:0;">
<pre><code class="language-csharp">using LitJson;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using UnityEngine;
using UnityEngine.Networking;

public class WebRequestTest :MonoBehaviour
{
    public delegate void HttpHelperPostGetCallbacks(long code, HttpHelperRequests request, HttpHelperResponses rsponse);

    //Http请求信息
    [Serializable]
    public struct HttpHelperRequests
    {
        //请求地址
        public string url;
        //表单字段
        public JsonData filelds;
        //表头
        public JsonData headers;
        public string token;
        public string session;
    }

    //Http返回信息
    [Serializable]
    public struct HttpHelperResponses
    {
        //返回Http状态码
        public long code;
        //返回http提示信息
        public string message;
        //请求接口时返回的头字典
        public Dictionary&lt;string, string&gt; headers;
        //请求API接口时返回的文本内容
        public string text;
        //请求返回的字节数值
        public byte[] bytes;
        //下载完成时返回的Texture
        public Texture texture;
        //下载资源时用到的线程
        public Thread thread;
        //下载的AB
        public AssetBundle bundle;

        /// &lt;summary&gt;
        /// 将text反序列化成T类型
        /// &lt;/summary&gt;
        /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public T Deserialize&lt;T&gt;()
        {
            return JsonConvert.DeserializeObject&lt;T&gt;(this.text);
        }
    }



    #region UnityWebRequest
    private void SendRequest(string url, HttpHelperPostGetCallbacks callback, JsonData fields = null, JsonData header = null, int timeout = 5)
    {
        StartCoroutine(_SendRequest(url, callback, fields, header, timeout));
    }

    IEnumerator _SendRequest(string url, HttpHelperPostGetCallbacks callback, JsonData fields = null, JsonData header = null, int timeout = 5)
    {
        using (UnityWebRequest webRequest = new UnityWebRequest(url))
        {
            webRequest.timeout = timeout;
            yield return webRequest.SendWebRequest();

            //组装 请求信息
            HttpHelperRequests request = new HttpHelperRequests();
            request.url = url;
            request.filelds = fields;
            request.headers = header;

            //组装 返回信息
            HttpHelperResponses response = new HttpHelperResponses();
            response.code = webRequest.responseCode;
            response.message = webRequest.error;
            response.headers = webRequest.GetResponseHeaders();
            response.text = webRequest.downloadHandler.text;
            response.bytes = webRequest.downloadHandler.data;

            //调用 委托
            callback?.Invoke(webRequest.responseCode, request, response);

            //结束 处理占用资源
            //尽快停止UnityWebRequest
            webRequest.Abort();
            //默认值是true，调用该方法不需要设置Dispose()，Unity就会自动在完成后调用Dispose()释放资源。
            webRequest.disposeDownloadHandlerOnDispose = true;
            //不再使用此UnityWebRequest，并应清理它正在使用的任何资源
            webRequest.Dispose();
        }

    }


    #endregion


    #region Post方法 
    /*
     Post方法将一个表上传到远程的服务器，一般来说我们登陆某个网站的时候会用到这个方法，我们的账号密码会以一个表单的形式传过去。
    */

    #region POST普通表单请求,支持Header,Authorization
    /// &lt;summary&gt;
    /// POST普通表单请求
    /// POST普通表单参数请求 - 数据以Parameters形式发送
    /// &lt;/summary&gt;
    /// &lt;param name="url"&gt;目标URL&lt;/param&gt;
    /// &lt;param name="callback"&gt;请求完成回调&lt;/param&gt;
    /// &lt;param name="fields"&gt;表单字段&lt;/param&gt;
    /// &lt;param name="header"&gt;请求头字典, 默认Content-Type=application/json&lt;/param&gt;
    /// &lt;param name="timeout"&gt;&lt;/param&gt;
    private void Post(string url, HttpHelperPostGetCallbacks callback, JsonData fields = null,JsonData header = null, int timeout = 5)
    {
        StartCoroutine(_Post(url, callback, fields, header, timeout));
    }

    IEnumerator _Post(string url,HttpHelperPostGetCallbacks callback, JsonData fields = null,JsonData header = null,int timeout = 5)
    {
        using (UnityWebRequest webRequest = UnityWebRequest.Post(url,fields!=null?fields.ToJson():null))
        {
            //设定超时
            webRequest.timeout = timeout;
            //设置请求头  根据实际需求来
            webRequest.SetRequestHeader("Authorization", "");
            //开始与远程服务器通信
            //等待通行完成
            yield return webRequest.SendWebRequest();

            //组装 请求信息
            HttpHelperRequests request = new HttpHelperRequests();
            request.url = url;
            request.filelds = fields;
            request.headers = header;

            //组装 返回信息
            HttpHelperResponses response = new HttpHelperResponses();
            response.code = webRequest.responseCode;
            response.message = webRequest.error;
            response.headers = webRequest.GetResponseHeaders();
            response.text = webRequest.downloadHandler.text;
            response.bytes = webRequest.downloadHandler.data;

            //调用 委托
            callback?.Invoke(webRequest.responseCode, request, response);

            //结束 处理占用资源
            //尽快停止UnityWebRequest
            webRequest.Abort();
            //默认值是true，调用该方法不需要设置Dispose()，Unity就会自动在完成后调用Dispose()释放资源。
            webRequest.disposeDownloadHandlerOnDispose = true;
            //不再使用此UnityWebRequest，并应清理它正在使用的任何资源
            webRequest.Dispose();
        }
    }
    #endregion

    
    #region POST RawBody请求,支持Header,Authorization
    /// &lt;summary&gt;
    /// 进行POST请求，数据以Raw格式携带在Body中进行请求
    /// &lt;/summary&gt;
    /// &lt;param name="url"&gt;目标URL地址&lt;/param&gt;
    /// &lt;param name="callback"&gt;回调完成函数&lt;/param&gt;
    /// &lt;param name="fields"&gt;携带数据&lt;/param&gt;
    /// &lt;param name="header"&gt;&lt;/param&gt;
    /// &lt;param name="timeout"&gt;&lt;/param&gt;
    private void PostRaw(string url, HttpHelperPostGetCallbacks callback, JsonData fields = null, JsonData header = null, int timeout = 5)
    {
        StartCoroutine(_PostRaw(url, callback, fields, header, timeout));
    }

    IEnumerator _PostRaw(string url,HttpHelperPostGetCallbacks callback, JsonData fields,JsonData header,int timeout = 5)
    {
        using (UnityWebRequest webRequest = UnityWebRequest.Post(url,"POST"))
        {
            //负责拒绝或接受在https请求中收到的证书,用于Https请求中的证书处理
            webRequest.certificateHandler = new CustomCertHandler();
            //设定超时
            webRequest.timeout = timeout;
            //设置信息头  根据实际需求来
            webRequest.SetRequestHeader("Content-Type", "application/json;");
            //处理请求头设置
            if (header != null)
            {
                foreach (var item in header.Keys)
                {
                    webRequest.SetRequestHeader(item, header[item].ToString());
                }
            }
            //设置携带数据
            if (fields != null)
            {
                webRequest.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(fields.ToJson()));
            }
            yield return webRequest.SendWebRequest();


            //组装 请求信息
            HttpHelperRequests request = new HttpHelperRequests();
            request.url = url;
            request.filelds = fields;
            request.headers = header;

            //组装 返回信息
            HttpHelperResponses response = new HttpHelperResponses();
            response.code = webRequest.responseCode;
            response.message = webRequest.error;
            response.headers = webRequest.GetResponseHeaders();
            response.text = webRequest.downloadHandler.text;
            response.bytes = webRequest.downloadHandler.data;


            //调用 委托
            callback?.Invoke(webRequest.responseCode, request, response);

            //结束 处理占用资源
            //尽快停止UnityWebRequest
            webRequest.Abort();
            //默认值是true，调用该方法不需要设置Dispose()，Unity就会自动在完成后调用Dispose()释放资源。
            webRequest.disposeDownloadHandlerOnDispose = true;
            //不再使用此UnityWebRequest，并应清理它正在使用的任何资源
            webRequest.Dispose();
        }
    }

    #endregion

    #endregion


    #region GET方法 

    #region GET普通表单请求，支持Header,Authorization
    /// &lt;summary&gt;
    /// 普通GET请求
    /// &lt;/summary&gt;
    /// &lt;param name="url"&gt;Get请求目标URL&lt;/param&gt;
    /// &lt;param name="callback"&gt;请求完成回调函数&lt;/param&gt;
    /// &lt;param name="fields"&gt;标单字段数据，Dictionary类型 &lt;/param&gt;
    /// &lt;param name="header"&gt;请求Header数据,Dictionary类型 &lt;/param&gt;
    /// &lt;param name="timeout"&gt;超时时间  默认5秒&lt;/param&gt;
    public void Get(string url, HttpHelperPostGetCallbacks callback, JsonData fields = null, JsonData header = null, int timeout = 5)
    {
        StartCoroutine(_Get(url, callback, fields, header, timeout));
    }

    private IEnumerator _Get(string url, HttpHelperPostGetCallbacks callback, JsonData fields = null, JsonData header = null, int timeout = 5)
    {
        string targetUrl = url;
        StringBuilder sb = new StringBuilder();

        if (fields != null)
        {
            foreach (var Key in fields.Keys)
            {
                sb.Append(Key + "=" + fields[Key] + "&amp;");
            }
            if (url.Contains("?"))
            {
                targetUrl = url + "&amp;" + sb.ToString();
            }
            else
            {
                targetUrl = url + "?" + sb.ToString();
            }

            targetUrl = targetUrl[targetUrl.Length - 1] == '&amp;' ? targetUrl.Substring(0, targetUrl.Length - 1) : targetUrl;
        }

        using (UnityWebRequest webRequest =  UnityWebRequest.Get(targetUrl))
        {
            //设定超时
            webRequest.timeout = timeout;
            //处理请求头设置
            webRequest.SetRequestHeader("Authorization", "");
            if (header != null)
            {
                foreach (var item in header.Keys)
                {
                    webRequest.SetRequestHeader(item.ToString(), header[item].ToString());
                }
            }
            yield return webRequest.SendWebRequest();


            //组装 请求信息
            HttpHelperRequests request = new HttpHelperRequests();
            request.url = url;
            request.filelds = fields;
            request.headers = header;

            //组装 返回信息
            HttpHelperResponses response = new HttpHelperResponses();
            response.code = webRequest.responseCode;
            response.message = webRequest.error;
            response.headers = webRequest.GetResponseHeaders();
            response.text = webRequest.downloadHandler.text;
            response.bytes = webRequest.downloadHandler.data;

            //调用 委托
            callback?.Invoke(webRequest.responseCode, request, response);

            //结束 处理占用资源
            //尽快停止UnityWebRequest
            webRequest.Abort();
            //默认值是true，调用该方法不需要设置Dispose()，Unity就会自动在完成后调用Dispose()释放资源。
            webRequest.disposeDownloadHandlerOnDispose = true;
            //不再使用此UnityWebRequest，并应清理它正在使用的任何资源
            webRequest.Dispose();
        }
    }
    #endregion

    #endregion



}

</code></pre>]]></description><guid isPermaLink="false">/archives/248.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 25 Feb 2022 09:57:00 GMT</pubDate></item><item><title><![CDATA[Unity ShaderGraph 简单贴花]]></title><link>https://blog.ccrui.cn/archives/247.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity%20ShaderGraph%20%E7%AE%80%E5%8D%95%E8%B4%B4%E8%8A%B1&amp;url=/archives/247.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="unity-shadergraph-简单贴花">Unity ShaderGraph 简单贴花</h1>
<h2 id="效果展示">效果展示</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F01%2F18%2FNVIDIA_Share_PRzFe1xqEq.png&amp;size=m" alt="效果图1"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F01%2F18%2F1642495558821.gif&amp;size=m" alt="效果图2"></p>
<h2 id="shadergraph">ShaderGraph</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F01%2F18%2FNVIDIA_Share_mlwbCNf982.png&amp;size=m" alt="0-1"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F01%2F18%2FNVIDIA_Share_n7c8JRYe7z.png&amp;size=m" alt="0-2"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F01%2F18%2FNVIDIA_Share_WT4EKyRtYZ.png&amp;size=m" alt="0-3"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F01%2F18%2FNVIDIA_Share_Y9b4z8IH4e.png&amp;size=m" alt="0-4"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2022%2F01%2F18%2FNVIDIA_Share_79aG07B61p.png&amp;size=m" alt="0-5"></p>
<h2 id="shadergraph文件">ShaderGraph文件</h2>
<p><a href="https://yun.ccrui.cn/s/3lPU1">ShaderGraph文件下载</a></p>]]></description><guid isPermaLink="false">/archives/247.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 18 Jan 2022 08:59:00 GMT</pubDate></item><item><title><![CDATA[Unity自定义新建脚本模板]]></title><link>https://blog.ccrui.cn/archives/245.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity%E8%87%AA%E5%AE%9A%E4%B9%89%E6%96%B0%E5%BB%BA%E8%84%9A%E6%9C%AC%E6%A8%A1%E6%9D%BF&amp;url=/archives/245.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="unity自定义新建脚本模板">Unity自定义新建脚本模板</h1>
<h2 id="更改模板">更改模板</h2>
<p>更改Unity安装路径中的模板文件<code>Unity\2020.3.18f1c1\Editor\Data\Resources\ScriptTemplates\81-C# Script-NewBehaviourScript.cs.txt</code>，根据需要更改内容</p>
<pre><code class="language-csharp">/*****************************************

    文件：#SCRIPTNAME#.cs
    作者：
    邮箱：
    日期：#CreateTime#
    功能：Nothing

******************************************/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

    #ROOTNAMESPACEBEGIN#
public class #SCRIPTNAME# : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        #NOTRIM#
    }

    // Update is called once per frame
    void Update()
    {
        #NOTRIM#
    }
}
#ROOTNAMESPACEEND#
</code></pre>
<h2 id="自动代码替换变量">自动代码替换变量</h2>
<p>在Unity工程中创建Plugins/Editor文件夹，将<code>ScriptsInfoRecoder.cs</code>脚本放入该文件夹即可</p>
<pre><code class="language-csharp">using System;
using System.IO;
 
public class ScriptsInfoRecoder : UnityEditor.AssetModificationProcessor {
    private static void OnWillCreateAsset(string path) {
        path = path.Replace(".meta", "");
        if (path.EndsWith(".cs")) {
            string str = File.ReadAllText(path);
            str = str.Replace("#CreateAuthor#", Environment.UserName).Replace(
                              "#CreateTime#", string.Concat(DateTime.Now.Year, "/", DateTime.Now.Month, "/",
                                DateTime.Now.Day, " ", DateTime.Now.Hour, ":", DateTime.Now.Minute, ":", DateTime.Now.Second));
            File.WriteAllText(path, str);
        }
    }
}
</code></pre>
<p>这时候在Unity工程中创建脚本都可以自动创建头部格式</p>]]></description><guid isPermaLink="false">/archives/245.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 27 Dec 2021 02:46:00 GMT</pubDate></item><item><title><![CDATA[Unity 广播与监听]]></title><link>https://blog.ccrui.cn/archives/244.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity%20%E5%B9%BF%E6%92%AD%E4%B8%8E%E7%9B%91%E5%90%AC&amp;url=/archives/244.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="unity-广播与监听">Unity 广播与监听</h1>
<p>用事件广播监听的话可以做到每个类关联性不那么强 各做各的职责 监听者不用管广播者是谁 广播者不用管监听者是谁</p>
<h2 id="eventtype脚本">EventType脚本</h2>
<p>脚本中存储需要用到的枚举类型</p>
<pre><code class="language-csharp">public enum eNventType
{
    ShowText=0,
}
</code></pre>
<h2 id="eventcenter脚本">EventCenter脚本</h2>
<p>用作事件管理 添加监听移除监听和广播的方法</p>
<pre><code class="language-csharp">using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

/// &lt;summary&gt;
/// 事件管理
/// &lt;/summary&gt;
public class EventCenter
{
    static Dictionary&lt;eNventType, Delegate&gt; m_EventTable = new Dictionary&lt;eNventType, Delegate&gt;();

    static void OnListenerAdding(eNventType eventType, Delegate callBack)
    {
        if (!m_EventTable.ContainsKey(eventType))
        {
            m_EventTable.Add(eventType, null);
        }

        Delegate d = m_EventTable[eventType];
        if (d != null &amp;&amp; d.GetType() != callBack.GetType())
        {
            throw new Exception(string.Format("尝试为事件{0}添加不同类型的委托，当前事件对应的的委托是{1}，要添加的委托类型是{2}", eventType, d.GetType(),
                callBack));
        }
    }

    static void OnListenerRemoving(eNventType eventType, Delegate callBack)
    {
        if (m_EventTable.ContainsKey(eventType))
        {
            Delegate d = m_EventTable[eventType];
            if (d == null)
            {
                throw new Exception(string.Format("移除监听错误:事件{0}没有对应的委托", eventType));
            }
            else if (d.GetType() != callBack.GetType())
            {
                throw new Exception(string.Format("移除监听错误:尝试为事件{0}移除不同类型的委托，当前委托类型为{1}" +
                                                  ",要移除的委托的类型为{2}", eventType, d.GetType(), callBack.GetType()));
            }
        }
        else
        {
            throw new Exception(string.Format("移除监听错误:没有事件码{0}", eventType));
        }
    }

    static void OnListenerRemoved(eNventType eventType)
    {
        if (m_EventTable[eventType] == null)
        {
            m_EventTable.Remove(eventType);
        }
    }

    /// &lt;summary&gt;
    /// 无参添加监听的方法
    /// &lt;/summary&gt;
    /// &lt;param name="eventType"&gt;&lt;/param&gt;
    /// &lt;param name="callBack"&gt;&lt;/param&gt;
    public static void AddListener(eNventType eventType, CallBack callBack)
    {
        OnListenerAdding(eventType, callBack);
        m_EventTable[eventType] = (CallBack) m_EventTable[eventType] + callBack;
    }

    /// &lt;summary&gt;
    /// 1参添加监听的方法
    /// &lt;/summary&gt;
    /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt;
    /// &lt;param name="eventType"&gt;&lt;/param&gt;
    /// &lt;param name="callBack"&gt;&lt;/param&gt;
    public static void AddListener&lt;T&gt;(eNventType eventType, CallBack&lt;T&gt; callBack)
    {
        OnListenerAdding(eventType, callBack);
        m_EventTable[eventType] = (CallBack&lt;T&gt;) m_EventTable[eventType] + callBack;
    }

    /// &lt;summary&gt;
    /// 2参添加监听的方法
    /// &lt;/summary&gt;
    /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt;
    /// &lt;typeparam name="X"&gt;&lt;/typeparam&gt;
    /// &lt;param name="eventType"&gt;&lt;/param&gt;
    /// &lt;param name="callBack"&gt;&lt;/param&gt;
    public static void AddListener&lt;T, X&gt;(eNventType eventType, CallBack&lt;T, X&gt; callBack)
    {
        OnListenerAdding(eventType, callBack);
        m_EventTable[eventType] = (CallBack&lt;T, X&gt;) m_EventTable[eventType] + callBack;
    }

    public static void AddListener&lt;T, X, Y&gt;(eNventType eventType, CallBack&lt;T, X, Y&gt; callBack)
    {
        OnListenerAdding(eventType, callBack);
        m_EventTable[eventType] = (CallBack&lt;T, X, Y&gt;) m_EventTable[eventType] + callBack;
    }

    public static void AddListener&lt;T, X, Y, Z&gt;(eNventType eventType, CallBack&lt;T, X, Y, Z&gt; callBack)
    {
        OnListenerAdding(eventType, callBack);
        m_EventTable[eventType] = (CallBack&lt;T, X, Y, Z&gt;) m_EventTable[eventType] + callBack;
    }

    public static void AddListener&lt;T, X, Y, Z, W&gt;(eNventType eventType, CallBack&lt;T, X, Y, Z, W&gt; callBack)
    {
        OnListenerAdding(eventType, callBack);
        m_EventTable[eventType] = (CallBack&lt;T, X, Y, Z, W&gt;) m_EventTable[eventType] + callBack;
    }

    /// &lt;summary&gt;
    /// 移除无参监听的方法
    /// &lt;/summary&gt;
    /// &lt;param name="eventType"&gt;&lt;/param&gt;
    /// &lt;param name="callBack"&gt;&lt;/param&gt;
    public static void RemoveListener(eNventType eventType, CallBack callBack)
    {
        OnListenerRemoving(eventType, callBack);
        m_EventTable[eventType] = (CallBack) m_EventTable[eventType] - callBack;
        OnListenerRemoved(eventType);
    }

    /// &lt;summary&gt;
    /// 移除1参监听的方法
    /// &lt;/summary&gt;
    /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt;
    /// &lt;param name="eventType"&gt;&lt;/param&gt;
    /// &lt;param name="callBack"&gt;&lt;/param&gt;
    public static void RemoveListener&lt;T&gt;(eNventType eventType, CallBack&lt;T&gt; callBack)
    {
        OnListenerRemoving(eventType, callBack);
        m_EventTable[eventType] = (CallBack&lt;T&gt;) m_EventTable[eventType] - callBack;
        OnListenerRemoved(eventType);
    }

    /// &lt;summary&gt;
    /// 移除2参监听的方法
    /// &lt;/summary&gt;
    /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt;
    /// &lt;param name="eventType"&gt;&lt;/param&gt;
    /// &lt;param name="callBack"&gt;&lt;/param&gt;
    public static void RemoveListener&lt;T, X&gt;(eNventType eventType, CallBack&lt;T, X&gt; callBack)
    {
        OnListenerRemoving(eventType, callBack);
        m_EventTable[eventType] = (CallBack&lt;T, X&gt;) m_EventTable[eventType] - callBack;
        OnListenerRemoved(eventType);
    }

    public static void RemoveListener&lt;T, X, Y&gt;(eNventType eventType, CallBack&lt;T, X, Y&gt; callBack)
    {
        OnListenerRemoving(eventType, callBack);
        m_EventTable[eventType] = (CallBack&lt;T, X, Y&gt;) m_EventTable[eventType] - callBack;
        OnListenerRemoved(eventType);
    }

    public static void RemoveListener&lt;T, X, Y, Z&gt;(eNventType eventType, CallBack&lt;T, X, Y, Z&gt; callBack)
    {
        OnListenerRemoving(eventType, callBack);
        m_EventTable[eventType] = (CallBack&lt;T, X, Y, Z&gt;) m_EventTable[eventType] - callBack;
        OnListenerRemoved(eventType);
    }

    public static void RemoveListener&lt;T, X, Y, Z, W&gt;(eNventType eventType, CallBack&lt;T, X, Y, Z, W&gt; callBack)
    {
        OnListenerRemoving(eventType, callBack);
        m_EventTable[eventType] = (CallBack&lt;T, X, Y, Z, W&gt;) m_EventTable[eventType] - callBack;
        OnListenerRemoved(eventType);
    }

    /// &lt;summary&gt;
    /// 广播无参方法
    /// &lt;/summary&gt;
    /// &lt;param name="eventType"&gt;&lt;/param&gt;
    public static void Broadcast(eNventType eventType)
    {
        Delegate d;
        if (m_EventTable.TryGetValue(eventType, out d))
        {
            CallBack callBack = d as CallBack;
            if (callBack != null)
            {
                callBack();
            }
            else
            {
                throw new Exception(string.Format("广播事件错误:事件{0}对应的委托具有不同类型", eventType));
            }
        }
    }

    /// &lt;summary&gt;
    /// 广播1参方法
    /// &lt;/summary&gt;
    /// &lt;param name="eventType"&gt;&lt;/param&gt;
    public static void Broadcast&lt;T&gt;(eNventType eventType, T arg)
    {
        Delegate d;
        if (m_EventTable.TryGetValue(eventType, out d))
        {
            CallBack&lt;T&gt; callBack = d as CallBack&lt;T&gt;;
            if (callBack != null)
            {
                callBack(arg);
            }
            else
            {
                throw new Exception(string.Format("广播事件错误:事件{0}对应的委托具有不同类型", eventType));
            }
        }
    }

    /// &lt;summary&gt;
    /// 广播2参方法
    /// &lt;/summary&gt;
    /// &lt;param name="eventType"&gt;&lt;/param&gt;
    public static void Broadcast&lt;T, X&gt;(eNventType eventType, T arg1, X arg2)
    {
        Delegate d;
        if (m_EventTable.TryGetValue(eventType, out d))
        {
            CallBack&lt;T, X&gt; callBack = d as CallBack&lt;T, X&gt;;
            if (callBack != null)
            {
                callBack(arg1, arg2);
            }
            else
            {
                throw new Exception(string.Format("广播事件错误:事件{0}对应的委托具有不同类型", eventType));
            }
        }
    }

    public static void Broadcast&lt;T, X, Y&gt;(eNventType eventType, T arg1, X arg2, Y arg3)
    {
        Delegate d;
        if (m_EventTable.TryGetValue(eventType, out d))
        {
            CallBack&lt;T, X, Y&gt; callBack = d as CallBack&lt;T, X, Y&gt;;
            if (callBack != null)
            {
                callBack(arg1, arg2, arg3);
            }
            else
            {
                throw new Exception(string.Format("广播事件错误:事件{0}对应的委托具有不同类型", eventType));
            }
        }
    }

    public static void Broadcast&lt;T, X, Y, Z&gt;(eNventType eventType, T arg1, X arg2, Y arg3, Z arg4)
    {
        Delegate d;
        if (m_EventTable.TryGetValue(eventType, out d))
        {
            CallBack&lt;T, X, Y, Z&gt; callBack = d as CallBack&lt;T, X, Y, Z&gt;;
            if (callBack != null)
            {
                callBack(arg1, arg2, arg3, arg4);
            }
            else
            {
                throw new Exception(string.Format("广播事件错误:事件{0}对应的委托具有不同类型", eventType));
            }
        }
    }

    public static void Broadcast&lt;T, X, Y, Z, W&gt;(eNventType eventType, T arg1, X arg2, Y arg3, Z arg4, W arg5)
    {
        Delegate d;
        if (m_EventTable.TryGetValue(eventType, out d))
        {
            CallBack&lt;T, X, Y, Z, W&gt; callBack = d as CallBack&lt;T, X, Y, Z, W&gt;;
            if (callBack != null)
            {
                callBack(arg1, arg2, arg3, arg4, arg5);
            }
            else
            {
                throw new Exception(string.Format("广播事件错误:事件{0}对应的委托具有不同类型", eventType));
            }
        }
    }
}

</code></pre>
<h2 id="callback脚本">CallBack脚本</h2>
<p>用作声明委托的类型</p>
<pre><code class="language-csharp">public delegate void CallBack();
public delegate void CallBack&lt;T&gt;(T arg);
public delegate void CallBack&lt;T, X&gt;(T arg1, X arg2);
public delegate void CallBack&lt;T, X, Y&gt;(T arg1, X arg2, Y arg3);
public delegate void CallBack&lt;T, X, Y, Z&gt;(T arg1, X arg2, Y arg3, Z arg4);
public delegate void CallBack&lt;T, X, Y, Z,W&gt;(T arg1, X arg2, Y arg3, Z arg4, W arg5);
</code></pre>
<h2 id="调用方法">调用方法</h2>
<p>添加监听</p>
<pre><code class="language-csharp">private void Awake()
{
    EventCenter.AddListener&lt;T&gt;(eNventType.ShowText, Method);
}

private void Method()
{
    //监听到事件后执行
}

private void OnDestroy()
{
    EventCenter.AddListener&lt;T&gt;(eNventType.ShowText, Method);
}

</code></pre>
<p>广播</p>
<pre><code class="language-csharp">    EventCenter.Broadcast&lt;T&gt;(eNventType.ShowText, T arg1)
</code></pre>]]></description><guid isPermaLink="false">/archives/244.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 27 Dec 2021 01:43:00 GMT</pubDate></item><item><title><![CDATA[Unity世界UI始终显示在最上层]]></title><link>https://blog.ccrui.cn/archives/243.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity%E4%B8%96%E7%95%8CUI%E5%A7%8B%E7%BB%88%E6%98%BE%E7%A4%BA%E5%9C%A8%E6%9C%80%E4%B8%8A%E5%B1%82&amp;url=/archives/243.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="unity世界ui始终显示在最上层">Unity世界UI始终显示在最上层</h1>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F12%2F23%2FNVIDIA_Share_KFFoENaqkN.png&amp;size=m" alt="示例"></p>
<h2 id="shader代码">Shader代码</h2>
<pre><code class="language-Shader">
Shader "UI/Overlay"
{
	Properties
	{
		[PerRendererData] _MainTex("Font Texture", 2D) = "white" {}

		_Color("Tint", Color) = (1,1,1,1)

		_StencilComp("Stencil Comparison", Float) = 8
		_Stencil("Stencil ID", Float) = 0
		_StencilOp("Stencil Operation", Float) = 0
		_StencilWriteMask("Stencil Write Mask", Float) = 255
		_StencilReadMask("Stencil Read Mask", Float) = 255

		_ColorMask("Color Mask", Float) = 15
	}

		SubShader
		{
			LOD 100

			Tags
			{
				"Queue" = "Transparent"
				"IgnoreProjector" = "True"
				"RenderType" = "Transparent"
				"PreviewType" = "Plane"
				"CanUseSpriteAtlas" = "True"
			}

			Stencil
			{
				Ref[_Stencil]
				Comp[_StencilComp]
				Pass[_StencilOp]
				ReadMask[_StencilReadMask]
				WriteMask[_StencilWriteMask]
			}

			Cull Off
			Lighting Off
			ZWrite Off
			ZTest Always
			Offset -1,-1
			Blend SrcAlpha OneMinusSrcAlpha
			ColorMask[_ColorMask]

			Pass
			{
				CGPROGRAM
					#pragma vertex vert
					#pragma fragment frag
					#include "UnityCG.cginc"
					#include "UnityUI.cginc"

					struct appdata_t
					{
						float4 vertex : POSITION;
						float2 texcoord : TEXCOORD0;
						float4 color : COLOR;
					};

					struct v2f
					{
						float4 vertex : SV_POSITION;
						half2 texcoord : TEXCOORD0;
						fixed4 color : COLOR;
					};

					sampler2D _MainTex;
					float4 _MainTex_ST;
					fixed4 _Color;
					fixed4 _TextureSampleAdd;

					v2f vert(appdata_t v)
					{
						v2f o;
						o.vertex = UnityObjectToClipPos(v.vertex);
						o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
						o.color = v.color * _Color;
	#ifdef UNITY_HALF_TEXEL_OFFSET
						o.vertex.xy += (_ScreenParams.zw - 1.0)*float2(-1,1);
	#endif

						return o;
					}

					fixed4 frag(v2f i) : SV_Target
					{
						fixed4 col = (tex2D(_MainTex, i.texcoord) + _TextureSampleAdd) * i.color;
						 clip(col.a - 0.01);
						return col;
					}
				ENDCG
			}
		}
}

</code></pre>
<h2 id="shader文件">Shader文件</h2>
<p><a href="https://yun.ccrui.cn/s/D9MHb">https://yun.ccrui.cn/s/D9MHb</a></p>]]></description><guid isPermaLink="false">/archives/243.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 23 Dec 2021 05:37:00 GMT</pubDate></item><item><title><![CDATA[JetBrains Rider 汉化插件安装步骤]]></title><link>https://blog.ccrui.cn/archives/242.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=JetBrains%20Rider%20%E6%B1%89%E5%8C%96%E6%8F%92%E4%BB%B6%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4&amp;url=/archives/242.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="jetbrains-rider-汉化插件安装步骤">JetBrains Rider 汉化插件安装步骤</h1>
<p>汉化插件不完全支持Rider 在Rider的插件商店中搜不到汉化包 采用手动下载安装的方式</p>
<ul>
 <li>从官网进入插件市场<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707093949038-1882842189.png&amp;size=m" alt="从官网进入插件市场"></li>
 <li>搜索汉化插件 Chinese ​(Simplified)​ Language Pack / 中文语言包<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707094004884-777106637.png&amp;size=m" alt="搜索汉化插件 Chinese ​(Simplified)​ Language Pack / 中文语言包"></li>
 <li>查看Rider版本号<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707094014315-684867554.png&amp;size=m" alt="查看Rider版本号"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707094025982-650673883.png&amp;size=m" alt="查看Rider版本号2"></li>
 <li>找到对应版本号的版本下载 不要下载高于Rider版本号的版本<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707094037955-830815134.png&amp;size=m" alt="找到对应版本号的版本下载"></li>
 <li>详情中写着不支持Rider 实际可以安装 只是不完全支持<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707094316330-2110430693.png&amp;size=m" alt="详情中写着不支持Rider 实际可以安装"></li>
 <li>打开插件窗口 从磁盘安装<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707094427309-699158579.png&amp;size=m" alt="打开插件窗口 从磁盘安装"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707094509866-1539453866.png&amp;size=m" alt="打开插件窗口 从磁盘安装2"></li>
 <li>安装完成后重启<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707094557999-115352663.png&amp;size=m" alt="安装完成后重启"></li>
 <li>不完全汉化插件安装完毕<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707094631924-14025853.png&amp;size=m" alt="不完全汉化插件安装完毕"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F11%2F30%2F1058679-20210707094639376-622125474.png&amp;size=m" alt="不完全汉化插件安装完毕"></li>
</ul>]]></description><guid isPermaLink="false">/archives/242.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 30 Nov 2021 06:36:00 GMT</pubDate></item><item><title><![CDATA[交管12123 root后人脸认证]]></title><link>https://blog.ccrui.cn/archives/239.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E4%BA%A4%E7%AE%A112123%20root%E5%90%8E%E4%BA%BA%E8%84%B8%E8%AE%A4%E8%AF%81&amp;url=/archives/239.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="交管12123-root后人脸认证">交管12123 root后人脸认证</h1>
<blockquote>
 <p>下载地址 <a href="https://yun.ccrui.cn/s/4dMul">自建网盘下载</a></p>
</blockquote>
<ol>
 <li>
  <p>下载并安装<code>交管12123_2.6.6</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F09%2F18%2FScreenshot_2021-09-18-02-23-42-682_com.miui.securitycenter.jpg&amp;size=m" alt="Screenshot_2021-09-18-02-23-42-682_com.miui.securitycenter.jpg"></p></li>
 <li>
  <p>使用<code>magisk hide</code>对<code>交管12123</code>进行隐藏<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F09%2F18%2FScreenshot_2021-09-18-02-08-08-175_jg.mwlq.yygxw.pb.bz.jpg&amp;size=m" alt="Screenshot_2021-09-18-02-08-08-175_jg.mwlq.yygxw.pb.bz.jpg"></p></li>
 <li>
  <p>打开<code>magisk</code>随机包名选项</p></li>
 <li>
  <p>在设置中禁止<code>交管12123</code>的应用列表访问权限<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F09%2F18%2FScreenshot_2021-09-18-02-00-52-091_com.miui.securitycenter.jpg&amp;size=m" alt="Screenshot_2021-09-18-02-00-52-091_com.miui.securitycenter.jpg"></p></li>
 <li>
  <p>下载并安装<code>交管12123 Hide-net.pois0nbread.hide12123-1.0-1.apk</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F09%2F18%2FScreenshot_2021-09-18-02-02-21-655_com.miui.securitycenter.jpg&amp;size=m" alt="Screenshot_2021-09-18-02-02-21-655_com.miui.securitycenter.jpg"></p></li>
 <li>
  <p>在lsp中激活<code>交管12123 Hide</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F09%2F18%2FScreenshot_2021-09-18-02-31-31-210_org.lsposed.manager.jpg&amp;size=m" alt="Screenshot_2021-09-18-02-31-31-210_org.lsposed.manager.jpg"></p></li>
 <li>
  <p>重启手机即可正常进行人脸识别认证</p></li>
</ol>]]></description><guid isPermaLink="false">/archives/239.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 17 Sep 2021 18:45:00 GMT</pubDate></item><item><title><![CDATA[小米社区自动点赞]]></title><link>https://blog.ccrui.cn/archives/238.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%B0%8F%E7%B1%B3%E7%A4%BE%E5%8C%BA%E8%87%AA%E5%8A%A8%E7%82%B9%E8%B5%9E&amp;url=/archives/238.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="小米社区自动点赞">小米社区自动点赞</h1>
<h2 id="原作者的话">原作者的话</h2>
<blockquote>
 <p>可以干什么大家都很清楚，我们就混个内测分<br>
   本项目仅供学习交流使用，请不要利用信息不对称来赚钱<br>
   不建议小白使用，不建议小白使用，不建议小白使用</p>
</blockquote>
<h2 id="简介">简介</h2>
<p>在看到原作者制作的小米社区自动点赞器后，发现该工具对普通人运行，非常不友好，需要在电脑中配置Python环境，于是我将原作者的项目进行了打包，进一步的减少了该工具的使用难度</p>
<p><strong>本项目仅供学习交流使用，请不要利用信息不对称来赚钱</strong><br><strong>重新打包后的项目对小白相对友好，可以酌情使用</strong></p>
<h2 id="下载地址">下载地址：</h2>
<p><a href="https://pan.baidu.com/s/1yH3AvO5lHWF6rTSnnW2csg">百度网盘</a> 提取码：6666<br><a href="https://share.weiyun.com/ZmhVOpIh">腾讯微云</a><br><a href="https://yun.ccrui.cn/s/q90fW">自建网盘</a></p>
<p>感谢原作者制作的工具 <a href="https://github.com/F-19-F/XM_BBS">原项目地址</a></p>
<h2 id="使用方法">使用方法</h2>
<ol>
 <li>
  <p>使用电脑浏览器打开并登录小米社区</p></li>
 <li>
  <p>在完成登录后，按下F12键，并按照截图勾选选项</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F07%2F27%2Fmsedge_49e5AhrwZE.png&amp;size=m" alt="勾选选项"></p></li>
 <li>
  <p>勾选完成后刷新页面（F5）</p></li>
 <li>
  <p>根据截图进行下一步操作</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F07%2F27%2Fmsedge_1NFjBkDdbD.png&amp;size=m" alt="复制Cookie"></p></li>
 <li>
  <p>打开<code>cookie.txt</code>文件 将内容替换为刚刚复制的内容</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F07%2F27%2FFXjBgV4a72.png&amp;size=m" alt="粘贴Cookie"></p></li>
 <li>
  <p>双击<code>点击运行.exe</code>即可运行该工具</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F07%2F27%2Fzilb6xsBU6.png&amp;size=m" alt="运行该工具"></p></li>
</ol>
<h2 id="原项目用法">原项目用法</h2>
<ul>
 <li>电脑浏览器打开并登录小米社区</li>
 <li>登陆后按F12，打开Network选项，按我截图的勾选</li>
 <li><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F07%2F27%2Fab6ab145416eef193db7eaa29ae6df7e.png&amp;size=m" alt="avatar"></li>
 <li>勾选好后F5刷新</li>
 <li>随便点开一个请求，右击复制Headers中的cookie</li>
 <li><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F07%2F27%2Fcookie.png&amp;size=m" alt="avatar"></li>
 <li>在代码同级目录新建一个文件cookie.txt,内容为你刚才复制的cookie</li>
 <li><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F07%2F27%2Fcookietxt.png&amp;size=m" alt="avatar"></li>
 <li>运行main.py ,安装python(添加到PATH)后在代码根目录打开命令行(windows shift+右击打开powershell 或打开cmd)，输入python3 main.py</li>
 <li><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F07%2F27%2Ffedb7c027ef43752a15ff8026416359d.png&amp;size=m" alt="avatar"></li>
 <li>如果报错,请输入pip3 install requests 安装requests</li>
 <li>如果你还看不懂，建议你不要使用了...</li>
 <li>使用风险自担，比如自动复制了不当言论被禁言....</li>
 <li>给颗star支持下吧</li>
</ul>]]></description><guid isPermaLink="false">/archives/238.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 27 Jul 2021 14:44:00 GMT</pubDate></item><item><title><![CDATA[V-Ray安装教程]]></title><link>https://blog.ccrui.cn/archives/237.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=V-Ray%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B&amp;url=/archives/237.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="下载v-ray">下载V-Ray</h2>
<p><a href="https://t.ccrui.cn/s/165be522-95fc-4785-b4b7-f6b28eefc4b9">下载链接</a><br><a href="https://pan.baidu.com/s/1TO5RsDxuy-UWGttmv1B1Nw">百度网盘下载链接</a> 提取码：jcsg<br>
  或从钉钉中下载</p>
<p>下载完成V-ray压缩包后，解压压缩包</p>
<h2 id="安装v-ray">安装V-Ray</h2>
<p>进入解压好的文件夹 <code>V-Ray 5.10.01 for Max 2020</code><br>
  双击 <code>vray_adv_51000_max2020_x64.exe</code> 运行</p>
<p>按照图中顺序进行安装</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F04%2F14%2Fvray_adv_51000_max2020_x64_6nxNg9ucz5.png&amp;size=m" alt="同意许可协议"></p>
<p>安装中途会弹出网页 忽略即可</p>
<p>耐心等待下载V-Ray材质库</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F04%2F14%2Fvray_adv_51000_max2020_x64_0IgkkQSd0u.png&amp;size=m" alt="下载V-Ray材质库"></p>
<p>下载完成后点击关闭即可</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F04%2F14%2Fvray_adv_51000_max2020_x64_65zg1cBOG7.png&amp;size=m" alt="下载完成"></p>
<p>安装完成会弹出两个网页 忽略即可</p>
<p><strong>注：若不需要安装V-Ray材质库可在下载材质库时，点击 Abort download 按钮跳过下载材质库</strong></p>
<h2 id="进行v-ray破解">进行V-Ray破解</h2>
<p>打开 <code>3ds Max</code> 的 <code>plugins目录</code> 默认为 <code>C:\Program Files\Autodesk\3ds Max 2020\plugins</code></p>
<p>将V-Ray文件夹中的 <code>vray_v50004_fix.dlr</code> 复制到 <code>3ds Max</code> 的 <code>plugins目录（C:\Program Files\Autodesk\3ds Max 2020\plugins）</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F04%2F14%2Fm8Avh9kFPD.png&amp;size=m" alt="V-Ray破解"></p>
<p>打开 <code>V-Ray</code> 的 <code>plugins目录</code> 默认为 <code>C:\Program Files\Chaos Group\V-Ray\3ds Max 2020\bin\plugins</code></p>
<p>将V-Ray文件夹中的 <code>vray_v50004_max_fix.dll</code> 复制到 <code>V-Ray</code> 的 <code>plugins目录（C:\Program Files\Chaos Group\V-Ray\3ds Max 2020\bin\plugins）</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F04%2F14%2Fexplorer_m5axtP1uXb.png&amp;size=m" alt="V-Ray破解"></p>
<h2 id="安装完成">安装完成</h2>
<p>完成以上步骤 即可完成 <code>V-Ray</code> 的安装与破解<br>
  打开 <code>3ds Max</code> 后 出现下图工具栏 即为安装成功</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F04%2F14%2F3dsmax_utkzMMDYug.png&amp;size=m" alt="安装成功"></p>]]></description><guid isPermaLink="false">/archives/237.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 21 Jul 2021 04:04:00 GMT</pubDate></item><item><title><![CDATA[aria2下载服务器搭建]]></title><link>https://blog.ccrui.cn/archives/236.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=aria2%E4%B8%8B%E8%BD%BD%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%90%AD%E5%BB%BA&amp;url=/archives/236.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="aria2下载服务器搭建">aria2下载服务器搭建</h1>
<h2 id="安装aria2">安装aria2</h2>
<p>我们这里使用一键脚本来安装，有大神提供了脚本，代码如下：</p>
<pre><code class="language-php">wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/aria2.sh &amp;&amp; chmod +x aria2.sh &amp;&amp; bash aria2.sh
</code></pre>
<p>安装过程不在截图了，全中文的选择 1 开始安装，安装的过程有点慢</p>
<h2 id="aria2-的使用命令">Aria2 的使用命令</h2>
<p>安装好之后，可以用命令来操作，命令如下：</p>
<pre><code class="language-php">    启动：service aria2 start
    停止：service aria2 stop
    重启：service aria2 restart
    查看状态：service aria2 status
    配置文件：/root/.aria2/aria2.conf（配置文件包含中文注释，但是一些系统可能不支持显示中文）
    下载目录：/usr/local/caddy/www/aria2/Download（该目录为Github下载安装的，而备用地址下载的默认为/usr/local/caddy/www/file
</code></pre>
<h2 id="宝塔部署-ariang-前端">宝塔部署 AriaNg 前端</h2>
<p><a href="https://www.2kss.com/go?url=https://github.com/mayswind/AriaNg">AriaNg</a> 前端部署就很简单了，把事先解析好的域名解析过来，之后下载<a href="https://www.2kss.com/go?url=https://github.com/mayswind/AriaNg/releases">AriaNg</a> 前端源码文件新建网站，解压，打开浏览器就可以访问了，开箱即食。安装 AriaNg，利用宝塔面板的远程下载，直接 down 过来，然后解压，把源代码复制到网站根目录，之后打开浏览器输入域名访问即可。</p>
<h2 id="ariang-使用">AriaNg 使用</h2>
<p>AriaNg 刚一安装好，会提示：未连接 Aria2，只需的打开【AriaNg 设置】输入域名或 IP，端口，Aria2 密匙，然后刷新页面即可，如图：</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F23%2Fmsedge_P2V9FSmstc.png&amp;size=m" alt="AriaNg 使用"></p>]]></description><guid isPermaLink="false">/archives/236.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 23 Mar 2021 12:53:00 GMT</pubDate></item><item><title><![CDATA[OneNote无法同步的解决方案]]></title><link>https://blog.ccrui.cn/archives/234.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=OneNote%E6%97%A0%E6%B3%95%E5%90%8C%E6%AD%A5%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88&amp;url=/archives/234.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="下载widdler-web-debugger">下载Widdler Web Debugger</h2>
<p><a href="http://fiddler2.com/r/?GetFiddler4Beta">官方下载地址</a></p>
<p><a href="https://yun.ccrui.cn/s/V4gfy">第三方下载地址</a></p>
<h2 id="第一步">第一步</h2>
<p>安装完成后，打开fiddler，找到左上角的 <code>winconfig</code> 按钮</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F21%2FFiddler_NW21MTLfME.png&amp;size=m" alt="fiddler截图"></p>
<h2 id="第二步">第二步</h2>
<p>勾选要豁免 (exempt) 的应用，例如：Onenote for Windows 10 这项，然后点保存即可。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F21%2FEnableLoopback_shdhktMDtU.png&amp;size=m" alt="AppContainer Loopback Exemption Unility"></p>
<p>同方法，可也解决微软应用商店加载慢，无法下载应用的问题</p>]]></description><guid isPermaLink="false">/archives/234.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 21 Mar 2021 13:09:00 GMT</pubDate></item><item><title><![CDATA[阿里云盘直链解析平台，支持多账户，支持批量复制]]></title><link>https://blog.ccrui.cn/archives/233.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E9%98%BF%E9%87%8C%E4%BA%91%E7%9B%98%E7%9B%B4%E9%93%BE%E8%A7%A3%E6%9E%90%E5%B9%B3%E5%8F%B0%EF%BC%8C%E6%94%AF%E6%8C%81%E5%A4%9A%E8%B4%A6%E6%88%B7%EF%BC%8C%E6%94%AF%E6%8C%81%E6%89%B9%E9%87%8F%E5%A4%8D%E5%88%B6&amp;url=/archives/233.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="阿里云盘直链解析平台支持多账户支持批量复制">阿里云盘直链解析平台，支持多账户，支持批量复制</h1>
<h2 id="准备工作">准备工作</h2>
<ol>
 <li>装了宝塔的linux服务器一台</li>
 <li>在网页上登录好你的阿里云盘账号</li>
</ol>
<h2 id="第一步-获取阿里云盘的refresh_token">第一步-获取阿里云盘的refresh_token</h2>
<pre><code>
#按下f12
#复制下面的代码，直接到控制台执行

JSON.parse(localStorage.getItem('token')).refresh_token

#出来的结果就是refresh_token

</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F15%2FgSqYRMPk33.png&amp;size=m" alt="图片"></p>
<h2 id="第二步-去你的宝塔新建一个站点">第二步-去你的宝塔新建一个站点</h2>
<p>域名设置一个你自己的域名，php版本选择纯静态</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F15%2FlrDWQ2oDb1.png&amp;size=m" alt="图片"></p>
<h2 id="第三步-到站点-usrlocalbin-目录上传直链程序">第三步-到站点 /usr/local/bin 目录，上传直链程序</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F15%2FTnHIRRy039.png&amp;size=m" alt="图片"></p>
<pre><code>
#直链程序下载地址：

#win版本下载地址：

https://aliyundrive.icu/file/9718713d5083490d97b70c66c4ef0df3/604f1c3cf230ec0d137a4dfba998d939b069d45e/AShare.exe


#linux版本下载地址：

https://aliyundrive.icu/file/9718713d5083490d97b70c66c4ef0df3/604f1c3ca76c2f890b2348b780d06d170e73548f/AShare


</code></pre>
<p>上传好后设置直链程序的权限</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F15%2FhsnaMAhcpm.png&amp;size=m" alt="图片"></p>
<h2 id="第四步-到你服务器的-usrlibsystemdsystem-目录新增启动文件">第四步-到你服务器的 /usr/lib/systemd/system 目录，新增启动文件</h2>
<p>文件名为：AShare.service<br>
  文件内容如下：</p>
<pre><code>
[Unit]
Description=AShare server daemon
Documentation=no
After=no
Wants=no

[Service]
EnvironmentFile=no
ExecStart=/usr/local/bin/AShare
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -9 $MAINPID
KillMode=process
Restart=on-failure
RestartSec=1s

[Install]
WantedBy=multi-user.target

</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F15%2FKaQDevrBZb.png&amp;size=m" alt="图片"></p>
<h2 id="第五步-启动服务">第五步-启动服务</h2>
<p>登录终端后执行下面的命令可以启动服务</p>
<pre><code>systemctl start AShare.service
</code></pre>
<p>执行下面的名称查看程序的运行端口和初始账号密码</p>
<pre><code>systemctl status AShare.service
</code></pre>
<p>如需停止服务，则执行下面的命令</p>
<pre><code>
systemctl stop AShare.service

</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F15%2FkNaaml3I8R.png&amp;size=m" alt="图片"></p>
<p>如图，可以看到我程序运行的地址和账号密码</p>
<p>再次进入第二步添加的站点设置页，添加反向代理<br>
  代理就是就是上图看到的服务运行地址，在我这里就是<br><a href="http://127.0.0.1:5201">http://127.0.0.1:5201</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F15%2FsI8eVpylB0.png&amp;size=m" alt="图片"></p>
<h2 id="第六步-打开系统根据上面安装的账号密码登录系统开始新增阿里云盘账号">第六步-打开系统，根据上面安装的账号密码登录系统，开始新增阿里云盘账号</h2>
<p>点击新增账号，填入你第一步获取的refresh_token，点击确定即可</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F15%2FdLqo4zHAaF.png&amp;size=m" alt="图片"></p>]]></description><guid isPermaLink="false">/archives/233.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 17 Mar 2021 12:03:00 GMT</pubDate></item><item><title><![CDATA[MacOS使用uPic自动上传到Chevereto]]></title><link>https://blog.ccrui.cn/archives/231.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=MacOS%E4%BD%BF%E7%94%A8uPic%E8%87%AA%E5%8A%A8%E4%B8%8A%E4%BC%A0%E5%88%B0Chevereto&amp;url=/archives/231.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="使用教程">使用教程</h2>
<h3 id="1下载upic">1.下载Upic</h3>
<p><a href="https://github.com/gee1k/uPic">github地址</a></p>
<p><a href="https://gitee.com/gee1k/uPic/releases">gitee发行版地址</a></p>
<h3 id="2设置upic">2.设置uPic</h3>
<p>API地址填写 <code>Chevereto地址</code> + <code>api/1/upload</code><br>
  请求方式填写 <code>POST</code><br>
  文件字段名 <code>source</code><br>
  URL路径 <code>['image', 'url']</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F01%2Fu70pKJ.png&amp;size=m" alt="图床设置"></p>
<p>点击 <code>其他字段</code> 后<br>
  增加<code>Header</code>字段<br><code>Content-Type</code> : <code>multipart/form-data; charset=utf-8;</code><br>
  添加<code>Body</code>字段<br><code>key</code> : <code>获取到的apikey</code><br><code>action</code> : <code>upload</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F03%2F01%2F4TBBOQ.png&amp;size=m" alt="其他字段"></p>
<h3 id="chevereto-api设置教程">Chevereto Api设置教程</h3>
<p><a href="https://www.ccrui.cn/archives/138.html">Chevereto Api设置教程</a></p>]]></description><guid isPermaLink="false">/archives/231.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 3 Mar 2021 08:46:00 GMT</pubDate></item><item><title><![CDATA[合成大西瓜 Unity重置版]]></title><link>https://blog.ccrui.cn/archives/225.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%90%88%E6%88%90%E5%A4%A7%E8%A5%BF%E7%93%9C%20Unity%E9%87%8D%E7%BD%AE%E7%89%88&amp;url=/archives/225.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="合成大西瓜unity复刻版">合成大西瓜Unity复刻版</h1>
<p>这是一个使用Unity复刻“合成大西瓜”的简单项目<br>
  寒假在家没事干就想随便做一下，现在已经基本完成项目的编写</p>
<h2 id="访问地址">访问地址</h2>
<p>[tabs]<br>
  [tab name="开源地址" active="true"]<a href="https://e.coding.net/lajituandui/Synthetic_big_watermelon/Synthetic_big_watermelon.git">coding开源项目地址</a>[/tab]<br>
  [tab name="发布地址"]<a href="https://github.com/cr-zhichen/Synthetic_big_watermelon/releases/tag/v0.1-beta.2">github发布地址</a>[/tab]<br>
  [tab name="web演示地址"]<a href="https://gua.ccrui.cn">Web演示地址</a> [/tab]<br>
  [tab name="安卓下载地址"]<a href="https://lajituandui.coding.net/s/74462753-475b-4b6c-a125-9312a8d5b95e">安卓下载地址</a> [/tab]<br>
  [/tabs]</p>
<h2 id="开发环境">开发环境</h2>
<p>Unity2017.4.34f1（最新版本更改为2018.4.31f1）<br>
  vscode</p>
<h2 id="文件位置">文件位置</h2>
<p>场景文件储存在 <code>./Assets/Scenes</code> 文件夹中<br><code>Index</code>为开始游戏场景<br><code>Game</code>为游戏场景<br><code>Over</code>为游戏结束场景</p>
<h2 id="完成情况">完成情况</h2>
<table>
 <thead>
  <tr>
   <th>预计完成</th>
   <th>完成进度</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>场景搭建</td>
   <td>√ 90%+</td>
  </tr>
  <tr>
   <td>随机水果</td>
   <td>√ 100%</td>
  </tr>
  <tr>
   <td>水果碰撞</td>
   <td>√ 100%</td>
  </tr>
  <tr>
   <td>游戏结束</td>
   <td>√ 90%+</td>
  </tr>
  <tr>
   <td>分数记录</td>
   <td>√ 100%</td>
  </tr>
  <tr>
   <td>游戏胜利</td>
   <td>√ 70%+</td>
  </tr>
  <tr>
   <td>游戏音效</td>
   <td>√ 100%</td>
  </tr>
  <tr>
   <td>水果动效</td>
   <td>√ 60%+</td>
  </tr>
  <tr>
   <td>安卓发布</td>
   <td>√ 100%</td>
  </tr>
  <tr>
   <td>Web发布</td>
   <td>√ 100%</td>
  </tr>
 </tbody>
</table>
<h2 id="项目预览">项目预览</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2021%2F01%2F29%2F20210129_135316-00_00_00-00_00_30.gif&amp;size=m" alt="gif预览图"></p>]]></description><guid isPermaLink="false">/archives/225.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 31 Jan 2021 13:23:00 GMT</pubDate></item><item><title><![CDATA[Teambition 目录程序]]></title><link>https://blog.ccrui.cn/archives/222.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Teambition%20%E7%9B%AE%E5%BD%95%E7%A8%8B%E5%BA%8F&amp;url=/archives/222.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="引言">引言</h2>
<p>不知道你现在有没有阿里云的团队协作网盘Teambition，<br>
  如果有的话，可以考虑整一个目录程序，因为它可以解决Teambition不能分享的问题，来看看下面的这篇文章。</p>
<h2 id="作者提供的站点">作者提供的站点</h2>
<p><a href="https://t.ccrui.cn">示例站点</a></p>
<p>该站点登录自己的阿里云网盘账号后，可以实现展示目录和分享文件或者文件夹的功能。</p>
<h3 id="效果展示">效果展示</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F12%2F07%2Fmsedge_G37whFr98p.png&amp;size=m" alt="主界面"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F12%2F07%2Fmsedge_HQMjI9PNje.png&amp;size=m" alt="分享界面"></p>
<h2 id="安装方法">安装方法</h2>
<h3 id="linux服务器">【linux服务器】</h3>
<ol>
 <li>
  <p>依次执行下列命令</p>
  <pre><code class="language-Linux">#第一步
 wget https://one.blob.core.chinacloudapi.cn/badyun/teambition/v0.01/app
 
 #第二步
 chmod +x ./app
 
 #第三步
 ./app
</code></pre></li>
 <li>
  <p>然后在宝塔后台添加反向代理<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F12%2F07%2Fmsedge_4wwSJlQu8S.png&amp;size=m" alt="反向代理"></p></li>
 <li>
  <p>进程守护<br>
    可以使用nobup或者pm2</p>
  <ol>
   <li>
    <p>nohup方式命令</p>
    <pre><code class="language-Linux">nohup ./app &amp;
</code></pre>
    <p>输入完成后连按两下回车</p></li>
   <li>
    <p>pm2方式需要先到宝塔后台软件管理安装pm2管理器<br>
      然后登录服务器进到程序目录执行</p>
    <pre><code class="language-Linux">pm2 start app --name teambition
pm2 save
pm2 startup
</code></pre></li>
   <li>
    <p>关闭程序的话，执行下面的命令</p>
    <pre><code class="language-Linux">#获取pid
sudo lsof -i:5213

#结束进程
sudo kill -9  #你上面查到的pid
</code></pre></li>
  </ol></li>
</ol>
<h3 id="win服务器">Win服务器</h3>
<p>下载对应安装包</p>
<blockquote>
 <p>下载链接 <a href="https://teambition.icu/file/5f9ac8237c9c54ba35cdaa0c/b10aba3432a68312fd245a9e1732a26b/app.exe">博主阿里云网盘</a></p>
</blockquote>
<p>作者已经把环境和代码都打包到一起了，所以不需要额外安装其他内容，直接运行即可。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F12%2F07%2FPicGo20201204205921.png&amp;size=m" alt="win"></p>
<h4 id="运行">运行</h4>
<p>搭建完成后程序运行在5213端口，即 <a href="http://127.0.0.1:5213">http://127.0.0.1:5213</a><br>
  直接使用Teambition官方的账号密码即可登录（需要开通了网盘功能）</p>
<h2 id="结语">结语</h2>
<p>看起来很好用，赶快试一下吧。速度方面是非常不错，但希望不要滥用和过度开发。</p>
<p>欢迎有疑惑在勿埋我心评论区留言。</p>
<p>参考资料：<a href="https://www.52pojie.cn/thread-1320716-1-1.html">吾爱破解</a></p>]]></description><guid isPermaLink="false">/archives/222.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 7 Dec 2020 05:10:00 GMT</pubDate></item><item><title><![CDATA[Unity安卓真机调试]]></title><link>https://blog.ccrui.cn/archives/219.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity%E5%AE%89%E5%8D%93%E7%9C%9F%E6%9C%BA%E8%B0%83%E8%AF%95&amp;url=/archives/219.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="unity安卓真机调试">Unity安卓真机调试</h1>
<p>Unity按照下图设置</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F14%2FUnity_4c8fidodis.png&amp;size=m" alt="Build Settings"></p>
<p>设置完成后 直接<code>Build</code>成<code>apk</code>文件<br>
  在安卓手机上安装后<br>
  打开adb调试模式</p>
<p>电脑上打开安卓<code>sdk</code>文件夹 <code>./tools</code> 双击<code>monitor.bat</code> 运行<code>Android Device Monitor</code>软件</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F14%2Fmonitor_Ziju3EuY4J.png&amp;size=m" alt="Android Device Monitor"></p>
<p>手机上打开安装完成的软件 即可在下方看到控制台输出</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F14%2Fmonitor_u6xZFZ9Vsl.png&amp;size=m" alt="测试"></p>]]></description><guid isPermaLink="false">/archives/219.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 14 Oct 2020 10:44:00 GMT</pubDate></item><item><title><![CDATA[Unity-vuforia项目建造流程]]></title><link>https://blog.ccrui.cn/archives/218.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity-vuforia%E9%A1%B9%E7%9B%AE%E5%BB%BA%E9%80%A0%E6%B5%81%E7%A8%8B&amp;url=/archives/218.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="新建unity项目">新建Unity项目</h2>
<ol>
 <li>打开<code>Unity Hub</code> 新建项目<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_SjiDM4kiVw.png&amp;size=m" alt="创建项目"></li>
 <li>创建<code>Vuforia</code>摄像机<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_W8i8tLfYxy.png&amp;size=m" alt="创建Vuforia摄像机"><br>
   出现提示后选择<code>Import</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_jCV1AIys8F.png&amp;size=m" alt="导入"><br>
   等待导入完成，导入完成后<code>Projec</code>t视图中会出现如下文件<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_zLTfJAglUt.png&amp;size=m" alt="导入完成"></li>
</ol>
<h2 id="新建vuforia项目">新建Vuforia项目</h2>
<ol>
 <li>开启<code>Vuforia</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_BLfYHB6NDJ.png&amp;size=m" alt="开启Vuforia"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_rrDGWfej0K.png&amp;size=m" alt="开启Vuforia"><br>
   若出现提示 选择 <code>Accept</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_hvZvvVmK1K.png&amp;size=m" alt="选择 Accept"><br>
   选择完成后 <code>Project</code>视图中会出现如下文件<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_0CdOsEbLmH.png&amp;size=m" alt="开启完成"></li>
 <li>从官网获取项目<code>Key</code>
  <ul>
   <li>打开官网 <a href="https://developer.vuforia.com/">官网链接</a></li>
   <li>登陆账号<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fmsedge_lt0fr01m1k.png&amp;size=m" alt="登陆账号"></li>
   <li>创建新项目<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fmsedge_WItZTpuPOh.png&amp;size=m" alt="创建新项目"><br>
     输入项目名称 <strong>（项目名称一定要与创建时候的名称保持一致）</strong><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2F8bcmO2vXcU.png&amp;size=m" alt="项目名称"><br>
     进入项目<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fmsedge_1b32ghlPLe.png&amp;size=m" alt="进入项目"></li>
   <li>复制<code>Key</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fmsedge_F5BZECJdzu.png&amp;size=m" alt="复制Key"></li>
  </ul></li>
</ol>
<h2 id="将key添加到unity项目中">将Key添加到Unity项目中</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_XCsBmb190S.png&amp;size=m" alt="将Key添加到项目"><br>
  尝试运行项目 若可正常显示摄像头画面 即为成功<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_80kLvtoJ0n.png&amp;size=m" alt="成功"></p>
<h2 id="向vuforia中添加图片">向Vuforia中添加图片</h2>
<ol>
 <li>新建数据库<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fmsedge_DlSFhaP2YQ.png&amp;size=m" alt="向Vuforia中添加图片"></li>
 <li>向数据库中添加图片文件 
  <ul>
   <li>打开刚刚建立好的数据库</li>
   <li>选择 Add Target<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fmsedge_CCT3BrrJIr.png&amp;size=m" alt="添加"></li>
   <li>向数据库中添加图片<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fmsedge_ioBWLVF65n.png&amp;size=m" alt="添加图片"></li>
   <li>上传完毕后等待星级出现后下载数据库<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fmsedge_XvUKUVMfRt.png&amp;size=m" alt="下载数据库"></li>
   <li>下载数据库<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fmsedge_v19NEC2psz.png&amp;size=m" alt="下载数据库"></li>
  </ul></li>
</ol>
<h2 id="将数据库导入unity">将数据库导入Unity</h2>
<p>在<code>Unity</code>项目打开的时候 双击下载好的文件<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_SNpJh3y3cO.png&amp;size=m" alt="数据库导入Unity"><br>
  在<code>Unity</code>中Project视图中 <code>Assets - Editor - Vuforia - ImageTargetTextures - 你的数据库名字</code> 中出现你上传的图片 证明导入成功<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_Dry1oU0RWm.png&amp;size=m" alt="导入成功"></p>
<h2 id="让unity可以识别图片">让Unity可以识别图片</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_9I9TQRjTlq.png&amp;size=m" alt="新建图片"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_L9yH6Yj61h.png&amp;size=m" alt="选择数据库"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_oKqYBInY4m.png&amp;size=m" alt="选择数据库"></p>
<p>在<code>Scene</code>视图中出现你上传的图片 即为成功</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_xToRT5pDld.png&amp;size=m" alt="成功"></p>
<h2 id="识别卡片后出现cube以证明成功识别">识别卡片后出现Cube以证明成功识别</h2>
<p>在<code>Hierarchy</code>视图建立<code>Cube</code>物体</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_u4LAuYFTBd.png&amp;size=m" alt="建立物体"></p>
<p>调整物体位置到图片上方 你喜欢的位置<br>
  运行程序 检查程序识别出卡牌后是否能正常出现物体</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_ug9dMBMMiX.png&amp;size=m" alt="检查是否正常识别"></p>
<h2 id="在识别到物体与物体消失时-输出文字">在识别到物体与物体消失时 输出文字</h2>
<ol>
 <li>
  <p>找到控制代码<br>
    控制代码文件 <code>DefaultTrackableEventHandler</code> 位于 <code>Project - Assets - Vuforia - Scripts</code> 文件夹中<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_WkCrRdTDzH.png&amp;size=m" alt="控制代码"></p></li>
 <li>
  <p><strong>(可选)</strong> 注释或删除原有 文件中 <code>OnTrackingFound</code> 与 <code>OnTrackingLost</code> 方法中的代码<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_jOUsvGQmqn.png&amp;size=m" alt="注释原有代码"></p></li>
 <li>
  <p>在 <code>OnTrackingFound</code> 方法中 输入下方代码</p>
  <pre><code class="language-csharp">Debug.Log("Find Picture");
</code></pre></li>
 <li>
  <p>在 <code>OnTrackingLost</code> 方法中 输入下方代码</p>
  <pre><code class="language-csharp">Debug.Log("Lost Picture");
</code></pre></li>
</ol>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_649yskiwiT.png&amp;size=m" alt="输入代码"></p>
<p>在Unity中测试是否能输出文字<br>
  若如下图所示即为成功</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F07%2Fvmware_TDGvVZS7q4.png&amp;size=m" alt="输出文字"></p>]]></description><guid isPermaLink="false">/archives/218.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 8 Oct 2020 03:04:00 GMT</pubDate></item><item><title><![CDATA[Unity 安卓环境配置教程]]></title><link>https://blog.ccrui.cn/archives/215.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Unity%20%E5%AE%89%E5%8D%93%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE%E6%95%99%E7%A8%8B&amp;url=/archives/215.html" width="1" height="1" alt="" style="opacity:0;">
<blockquote>
 <p>注意：Unity项目路径<code>不能包含</code>任何<code>中文字符</code></p>
</blockquote>
<p>[TOC]</p>
<h2 id="安装jdk">安装jdk</h2>
<h3 id="下载">下载</h3>
<p>下载Java jdk<br><a href="https://cloud.189.cn/t/fEVJr26VnyQf">天翼云下载</a><br><a href="https://pan.baidu.com/s/19jcAT2ySze1TD3p4szgp1w">百度网盘下载</a> 密码：v53r</p>
<h3 id="安装">安装</h3>
<p>将下载好的sdk 解压后移动到 <code>C:\Program Files\Java</code> 目录中</p>
<blockquote>
 <p>注：若无Java文件夹请自行创建</p>
</blockquote>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_NojIF2m9Ri.png&amp;size=m" alt="安装"></p>
<p>请保证文件结构为下图所示<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_gnneQlKZFG.png&amp;size=m" alt="安装"></p>
<h3 id="配置java-jdk">配置Java jdk</h3>
<p>在安装完成Java jdk后 开始配置环境变量</p>
<p>右键点击 <code>此电脑</code> 选择 <code>属性</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_KP6x7Qu6uC.png&amp;size=m" alt="属性"></p>
<p>选择 <code>高级系统设置</code> <code>环境变量</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_GLGITq2rou.png&amp;size=m" alt="环境变量"></p>
<blockquote>
 <p><code>注：在windows10 2004版本后界面为：</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2FCode_HFASvbYmvx.png&amp;size=m" alt="环境变量"></p>
</blockquote>
<p>然后我们点击新建：</p>
<ol>
 <li>
  <p>新建一个系统环境变量，变量名为<code>JAVA_HOME</code>，变量值为JDK的安装路径<br>
    安装路径为：<code>C:\Program Files\Java\jdk1.8.0_171</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_CYMmQu2cxa.png&amp;size=m" alt="环境变量"></p></li>
 <li>
  <p>在系统变量中<strong>找到</strong> <code>Path</code> ，点击编辑后，点击新建，分别输入<br><code>%JAVA_HOME%\bin; %JAVA_HOME%\jre\bin</code></p>
  <p><code>C:\Program Files\Java\jdk1.8.0_171\bin</code></p>
  <p><code>C:\Program Files\Java\jdk1.8.0_171\jre\bin</code></p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_Ofk3L7NNw5.png&amp;size=m" alt="环境变量"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_9gp1V2VdR7.png&amp;size=m" alt="环境变量"></p></li>
 <li>
  <p>新建一个系统环境变量，变量名为<code>CLASSPATH</code>，变量值输入 <code>.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_EsCGeeuXYG.png&amp;size=m" alt="环境变量"></p></li>
</ol>
<p>配置完成环境变量后，按 <code>win+r</code>输入 <code>cmd</code><br>
  在cmd中输入 <code>javac -version</code> 若出现安装版本号，即为安装成功<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_qGsgwqcslx.png&amp;size=m" alt="完成"></p>
<h2 id="安装sdk">安装sdk</h2>
<h3 id="下载-1">下载</h3>
<p>下载Android sdk<br><a href="https://cloud.189.cn/t/uANZ3myqaeM3">天翼云下载</a><br><a href="https://pan.baidu.com/s/1J0Uvm92rEtMIZoS8GoN-8w">百度网盘下载</a> 密码：6x7n</p>
<h3 id="安装-1">安装</h3>
<p>双击下载好的软件<br>
  一路下一步 完成<code>SDK Manager</code>安装</p>
<p>完成安装后会自动打开<code>SDK Manager</code></p>
<p>选择 Android 10(API 29) Android 4.4.2(API 19)</p>
<p>请按照下图勾选，未勾选的选项不推荐勾选，可能会导致占用磁盘空间过大</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_sXktSzoQkm.png&amp;size=m" alt="安装"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_ZUz2I3viso.png&amp;size=m" alt="安装"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_tqtereYbTt.png&amp;size=m" alt="安装"></p>
<blockquote>
 <p>选择完上述选项后 点击安装</p>
</blockquote>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_0TEB5yAKyS.png&amp;size=m" alt="安装"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_kyP7hQgaMq.png&amp;size=m" alt="安装"></p>
<blockquote>
 <p>注：SDK下载默认目录为 C:\Users\你的用户名\AppData\Local\Android\android-sdk</p>
</blockquote>
<p>安装完成后 
 <del>重启电脑</del>即可使用</p>
<h2 id="unity中关联">Unity中关联</h2>
<p>点击 <code>Edit</code> 选择 <code>Preference</code> 的<code>External Toosl</code>选项卡 <code>SDK</code> 与 <code>JDK</code> 选项<br>
  若以上步骤均正确完成，点击 <code>Browse</code> 即可自动定位到文件夹 点击确定即可</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F10%2F02%2Fvmware_9Q2CKaklMj.png&amp;size=m" alt="Unity"></p>]]></description><guid isPermaLink="false">/archives/215.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 2 Oct 2020 13:06:00 GMT</pubDate></item><item><title><![CDATA[frp部署教程]]></title><link>https://blog.ccrui.cn/archives/212.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=frp%E9%83%A8%E7%BD%B2%E6%95%99%E7%A8%8B&amp;url=/archives/212.html" width="1" height="1" alt="" style="opacity:0;">
<blockquote>
 <p>首先需要拥有一个有公网IP的设备<br>
   建议使用云服务器</p>
</blockquote>
<blockquote>
 <p>注：在进行每次端口开放操作时 必须打开防火墙端口限制</p>
</blockquote>
<h2 id="设置frp服务器">设置frp服务器</h2>
<p>根据系统<a href="https://github.com/fatedier/frp/releases">下载程序</a></p>
<p>这里以linux为例：</p>
<p>从下载链接下载最新的程序</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F09%2F18%2Fmsedge_tjxpwbnyxX.png&amp;size=m" alt="下载"></p>
<p>上传到服务器目录后并解压</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F09%2F18%2Fmsedge_sCahMM2a53.png&amp;size=m" alt="上传"></p>
<p>进入终端 定位到frp目录 <code>cd frp</code> 输入 <code>./frps -c ./frps.ini</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F09%2F18%2Fcmd_E1dGgJ5ifz.png&amp;size=m" alt="配置完成"></p>
<blockquote>
 <p>至此服务器端部署完成</p>
</blockquote>
<h2 id="设置fpr客户端">设置fpr客户端</h2>
<p>在需要被控制的计算机上<br>
  根据系统<a href="https://github.com/fatedier/frp/releases">下载程序</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F09%2F18%2Fmsedge_tFk1KTEWaq.png&amp;size=m" alt="下载"></p>
<p>解压后编辑 <code>frpc.ini</code> 文件：<br>
  示例：</p>
<pre><code class="language-ini">[common]
server_addr = 47.94.46.123 #服务器地址
server_port = 7000 #服务器端口号

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 3389 #远控端口 默认为3389
remote_port = 7001 #自定义远控端口
</code></pre>
<p>然后 启动Windows命令提示符 <strong>切换到解压位置后</strong>，运行：</p>
<pre><code class="language-CMD">.\frpc.exe -c .\frpc.ini
</code></pre>
<p>完成客户端部署</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F09%2F18%2FCode_DaSaomWyay.png&amp;size=m" alt="完成"></p>
<blockquote>
 <p>在完成部署后 即可使用Windows远程桌面功能远程连接电脑<br>
   计算机地址为 服务器ip:自定义远控端口</p>
</blockquote>]]></description><guid isPermaLink="false">/archives/212.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 18 Sep 2020 05:40:00 GMT</pubDate></item><item><title><![CDATA[Mipush修复（适用于CC MIUI12）]]></title><link>https://blog.ccrui.cn/archives/208.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Mipush%E4%BF%AE%E5%A4%8D%EF%BC%88%E9%80%82%E7%94%A8%E4%BA%8ECC%20MIUI12%EF%BC%89&amp;url=/archives/208.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="准备">准备</h2>
<p>下载链接中的所有文件：<br><a href="https://www.lanzous.com/b05g1oxrc">蓝奏云（密码：cc666）</a><br><a href="https://www.yun.chengrui.xyz/#/s/RZHD">自建网盘</a></p>
<h2 id="删除目标文件">删除目标文件</h2>
<p>将根目录的<code>cust</code>文件夹直接删掉，把下载的<code>cust</code>解压到根目录，然后给<code>0777权限</code>应用到子<code>文件夹和子文件</code>，然后去<code>/data/data/</code>路径删除<code>com.xiaomi.xmsf</code>这个文件夹</p>
<h2 id="twrp刷入卡刷包">twrp刷入卡刷包</h2>
<p>进入twrp后刷入 <code>MI Push修复 v4.1 by 新的-amp;分歧（全服务器）.zip</code> 这个文件</p>
<h2 id="编辑文件">编辑文件</h2>
<p>进入<code>/data/data/com.xiaomi.xmsf/files/</code>路径下编辑<code>mipush_region</code>这个文件，在新的一行输入<code>China</code>。<code>mipush_country_code</code>在新的一行输入<code>cn</code>，<br><strong>没有文件就自己创建文件</strong>，名字要对应，文件类型不用纠结，里面是白的也不用管，创建后直接长按文件，以文本方式编辑，对应输入</p>
<h2 id="修改为文件权限">修改为文件权限</h2>
<p>修改这两个文件的权限为0777，保存，然后重启手机应该就可以正常注册上mipush了。</p>
<h2 id="注册情况查看">注册情况查看</h2>
<p>注册情况可以看<code>/data/data/com.xiaomi.xmsf/shared_prefs/</code>路径下的<code>pref_registered_pkg_names.xml</code>文件，有对应包名就代表成功了</p>
<blockquote>
 <p>本文转载至 <a href="https://www.coolapk.com/feed/17127692?shareKey=ZmM4NTZmZTExNjc0NWY0YjRiYTc~&amp;shareUid=479113&amp;shareFrom=com.coolapk.market_10.5.2">酷安：理想中的阿修</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/208.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 30 Aug 2020 07:06:00 GMT</pubDate></item><item><title><![CDATA[实践学期塔防游戏大作业功能点]]></title><link>https://blog.ccrui.cn/archives/204.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%AE%9E%E8%B7%B5%E5%AD%A6%E6%9C%9F%E5%A1%94%E9%98%B2%E6%B8%B8%E6%88%8F%E5%A4%A7%E4%BD%9C%E4%B8%9A%E5%8A%9F%E8%83%BD%E7%82%B9&amp;url=/archives/204.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="实践学期塔防游戏大作业功能点">实践学期塔防游戏大作业功能点</h1>
<blockquote>
 <p>姓名：张程瑞<br>
   学号：19107350111<br>
   项目名称：塔防游戏</p>
</blockquote>
<h2 id="功能点1-控制相机移动">功能点1-控制相机移动</h2>
<p>实现方法：通过鼠标和键盘的输入，来控制摄像机的移动<br>
  可以通过WASD和按住右键拖动移动相机的位置，鼠标滚轮控制相机的缩放</p>
<p>实现代码：</p>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 调用摄像头移动
/// 通过WASD，鼠标滚轮，点击右键拖动，进行移动
/// &lt;/summary&gt;
public void Move()
{

    //通过WASD按键控制摄像机的前后左右移动
    float h = Input.GetAxis("Horizontal");//读取横向操作，赋值给h
    float v = Input.GetAxis("Vertical");//读取纵向操作，赋值给v
    transform.Translate(new Vector3(h, 0, v) * Time.deltaTime * speed, Space.World);//使被挂载对象的坐标按照h，v的操作，在世界坐标系中移动

    //通过滑轮控制摄像机的缩放
    float mouse = Input.GetAxis("Mouse ScrollWheel");//读取鼠标滑轮操作，赋值给mouse
    transform.Translate(new Vector3(0, 0, mouse * mousespeed) * Time.deltaTime);//使被挂载对象的坐标mouse的操作，在坐标系中移动

    //通过鼠标右键按下拖动视角平移

    //交换初始和结束鼠标位置
    MousePositionLast = MousePositionNew;
    MousePositionNew = Input.mousePosition;

    MouseMoveDirection = MousePositionNew - MousePositionLast; //用两个坐标相减，得出鼠标的移动方向向量

    if (Input.GetMouseButtonDown(1))//判断鼠标右键是否按下
    {
        whetherTheRightButtonIsPressed = true;//标记鼠标右键为按下
        isItTheFirstTime = false;
    }
    else if (Input.GetMouseButtonUp(1))//判断鼠标右键是否按下
    {
        whetherTheRightButtonIsPressed = false;//标记鼠标右键为松开
    }


    //第一次数据识别会有错误，需要第二次以后的数据
    if (isItTheFirstTime)//判断是否第一次
    {
        if (whetherTheRightButtonIsPressed)//判断鼠标右键是否按下
        {
            transform.Translate(new Vector3(-MouseMoveDirection.x, 0, -MouseMoveDirection.y) * Time.deltaTime * speed, Space.World);//跟着鼠标移动物体
        }
    }
    else
    {
        isItTheFirstTime = true;
    }
}
</code></pre>
<h2 id="功能点2-防止相机移动超过限制">功能点2-防止相机移动超过限制</h2>
<p>实现方法：通过限制摄像机在空间坐标系中的位置，来防止相机超出移动限制</p>
<pre><code class="language-csharp">if (transform.position.x &gt; 100f || transform.position.x &lt; -60f
|| transform.position.y &gt; 100f || transform.position.y &lt; 5f
|| transform.position.z &gt; 70f || transform.position.z &lt; -80f)
//判断是否超出规定范围
        {//若超出范围

            //超出限制后位置调整 防止相机越位
            if (transform.position.x &gt; 100f)
            {
                transform.Translate(new Vector3(-5f, 0, 0), Space.World);
            }
            if (transform.position.x &lt; -60f)
            {
                transform.Translate(new Vector3(5f, 0, 0), Space.World);
            }
            if (transform.position.y &gt; 100f)
            {
                transform.Translate(new Vector3(0, -5f, 0), Space.World);
            }
            if (transform.position.y &lt; 5f)
            {
                transform.Translate(new Vector3(0, 5f, 0), Space.World);
            }
            if (transform.position.z &gt; 70f)
            {
                transform.Translate(new Vector3(0, 0, -5), Space.World);
            }
            if (transform.position.z &lt; -80f)
            {
                transform.Translate(new Vector3(0, 0, 5), Space.World);
            }
        }
        else
        {
            Move();//调用摄像头移动
        }
</code></pre>
<h2 id="功能点3-怪物的生成以及按照路径点移动">功能点3-怪物的生成以及按照路径点移动</h2>
<p>实现方法：通过代码保存在unity中设置的路径点，并且通过跨脚本定义数组，并调用的方式，利用保存好的路径点位置，生成怪物，并让其按照路径点移动</p>
<h3 id="保存路径点">保存路径点</h3>
<pre><code class="language-csharp"> public static Transform[] positions;//定义一个静态Transform数组保存位置

/// &lt;summary&gt;
/// Awake is called when the script instance is being loaded.
/// 在加载脚本实例时调用aware。
/// &lt;/summary&gt;
void Awake()
{
    positions = new Transform[transform.childCount];//获取子物体的数量作为positions的长度
    for (int i = 0; i &lt; positions.Length; i++)//遍历positions
    {
        positions[i] = transform.GetChild(i);//使positions的第i位等于子物体的索引，根据子物体的索引获取物体位置
    }
}
</code></pre>
<h3 id="怪物生成">怪物生成</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 携程函数 控制生成敌人数量与间隔
/// &lt;/summary&gt;
/// &lt;returns&gt;&lt;/returns&gt;
IEnumerator SpawnEnemy()//携程函数
{
    foreach (Wave wave in waves)//循环遍历Wave
    {
        for (int i = 0; i &lt; wave.count; i++)
        {
            GameObject.Instantiate(wave.enemyPrefab, START.position, Quaternion.identity);//根据enmyPrefab在开始位置，生成无旋转的物体
            CountEnemyAlive++;//使敌人数量增加
            if (i != wave.count - 1)
            {
                yield return new WaitForSeconds(wave.rate);//暂停rate秒
            }
        }
        while (CountEnemyAlive &gt; 0)
        {
            yield return 0;//返回
        }
        yield return new WaitForSeconds(WaveRate);//暂停WaveRate秒
    }
    while (CountEnemyAlive &gt; 0)//说明敌人还有存货
    {
        yield return 0;//返回
    }
    GameManager.instance.Win();//调用胜利
}
</code></pre>
<h3 id="怪物移动">怪物移动</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 使怪物根据路径点移动
/// &lt;/summary&gt;
void Move()
{
    if (index &gt; positions.Length - 1)//判断路径点序号是都大于路径点数组长度-1
    {
        return;//返回
    }
    transform.Translate((positions[index].position - transform.position).normalized * Time.deltaTime * speed);//让脚本挂载物体向着 路径点位置-自身位置 的矢量方向进行移动
    if (Vector3.Distance(positions[index].position, transform.position) &lt; 0.2f)//判断脚本所挂载物体与路径点的距离是否小于0.2
    {
        index++;//+=1
    }
    if (index &gt; positions.Length - 1)//判断是否超出路径数量
    {
        ReachDestination();
    }
}
</code></pre>
<h2 id="功能点4-炮台数据保存以及建造">功能点4-炮台数据保存以及建造</h2>
<p>实现方式：通过定义数据类的方式，定义枚举类型，保存需要建造的炮塔，并且在按下unity中设定的按键时，获取所保存的炮塔预制体，通过射线检测，检测鼠标与游戏中所设定的可以建造炮台的物体(<code>GameObject</code>)的碰撞，来获取<code>mapcube</code>的坐标，并通过获取的坐标与保存的炮塔预制体，在<code>mapcube</code>上实例化炮台对象，从而完成炮塔的建造操作</p>
<h3 id="判断鼠标是否与mapcub重合">判断鼠标是否与mapcub重合</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// Start is called on the frame when a script is enabled just before
/// any of the Update methods is called the first time.
/// &lt;/summary&gt;
void Start()
{
    _renderer = GetComponent&lt;Renderer&gt;();//获取材质渲染器
    originalMaterialColor = _renderer.material.color;//保存初始颜色
}
</code></pre>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// Called when the mouse enters the GUIElement or Collider.
/// 当鼠标进入GUIElement或对撞机时调用。
/// &lt;/summary&gt;
private void OnMouseEnter()
{
    if (turretGo == null &amp;&amp; EventSystem.current.IsPointerOverGameObject() == false)//判断是否为空并且鼠标不在UI上
    {
        _renderer.material.color = Color.red;//使材质变为红色
    }
}

/// &lt;summary&gt;
/// Called when the mouse is not any longer over the GUIElement or Collider.
/// 当鼠标不再位于GUIElement或对撞机上时调用。
/// &lt;/summary&gt;
void OnMouseExit()
{
    _renderer.material.color = originalMaterialColor;//使材质变为原始颜色
}
</code></pre>
<h3 id="炮塔的数据保存">炮塔的数据保存</h3>
<pre><code class="language-csharp">//创建数据类保存炮塔数据
public class TurretData
{

public GameObject turretPrefab;//原始预制体
public int cost;//价格
public GameObject turretUpgradedPrefab;//升级预制体
public int cosUpgraded;//升级价格
public int dismantlingPrice;//拆解价格
public TurretType type;//定义枚举
}

/// &lt;summary&gt;
/// 定义枚举类型
/// 内部保存炮塔
/// &lt;/summary&gt;
public enum TurretType//定义枚举类型
{
    LasetTurret,
    MissileTurret,
    standardTurret,
    Boom
}
</code></pre>
<h3 id="按下按键获取炮塔">按下按键获取炮塔</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 接受按键数据
/// &lt;/summary&gt;
/// &lt;param name="isOn"&gt;
/// 接收按钮传递的bool类型数据
/// &lt;/param&gt;
public void OnlaserSelected(bool isOn)//接收按钮数据
{
    if (isOn)//判断按钮是否按下
    {
        selectedTurretData = laserTurretData;//使当前炮塔等于选择的炮塔
    }
}

/// &lt;summary&gt;
/// 接受按键数据
/// &lt;/summary&gt;
/// &lt;param name="isOn"&gt;
/// 接收按钮传递的bool类型数据
/// &lt;/param&gt;
public void OnMissileSelected(bool isOn)//接收按钮数据
{
    if (isOn)//判断按钮是否按下
    {
        selectedTurretData = mssileTurretData;//使当前炮塔等于选择的炮塔
    }
}

/// &lt;summary&gt;
/// 接受按键数据
/// &lt;/summary&gt;
/// &lt;param name="isOn"&gt;
/// 接收按钮传递的bool类型数据
/// &lt;/param&gt;
public void OnStandardSelected(bool isOn)//接收按钮数据
{
    if (isOn)//判断按钮是否按下
    {
        selectedTurretData = standaraTurretData;//使当前炮塔等于选择的炮塔
    }
}

/// &lt;summary&gt;
/// 接受按键数据
/// &lt;/summary&gt;
/// &lt;param name="isOn"&gt;
/// 接收按钮传递的bool类型数据
/// &lt;/param&gt;
public void OnBoom(bool isOn)//接收按钮数据
{
    if (isOn)//判断按钮是否按下
    {
        selectedTurretData = Boom;//使当前炮塔等于选择的炮塔
    }
}
</code></pre>
<h3 id="炮塔的建造">炮塔的建造</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// Update is called every frame, if the MonoBehaviour is enabled.
/// &lt;/summary&gt;
void Update()
{
    if (Input.GetMouseButtonDown(0))//判断鼠标左键按下
    {
        if (EventSystem.current.IsPointerOverGameObject() == false)//判断鼠标不在UI上
        {
            //开发炮台开发的创造
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);//创建射线
            RaycastHit hit;
            bool isCollider = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("MapCube"));//定义是否指向MapCube
            if (isCollider)//判断是否指向MapCube
            {
                MapCube mapCube = hit.collider.GetComponent&lt;MapCube&gt;();//得到点击的mapcube
                if (selectedTurretData != null &amp;&amp; mapCube.turretGo == null)//判断是否选择了炮台 和mapcube上是否有炮塔
                {
                    //可以创建
                    if (money &gt;= selectedTurretData.cost)//判断钱是否够
                    {
                        ChangeMoney(-selectedTurretData.cost);//消耗金钱
                        mapCube.BuildTurret(selectedTurretData);//调用MapCube中的函数创建炮台
                    }
                    else
                    {
                        //提示钱不够
                        moneyAnimator.SetTrigger("Flicker");//将动画机的Flicker激活
                    }
                }
                else if (mapCube.turretGo != null)//判断上面有炮台
                {
                    // Debug.Log(mapCube.turretGo);
                    // Debug.Log(selectedMapcube);
                    if (mapCube.turretGo == theCurrentlySelectedTurret &amp;&amp; upgradeCanvas.activeInHierarchy)//如果选择同一个炮台
                    {
                        StartCoroutine(HideUpgradeUI());//调用携程函数隐藏UI
                                                        // HideUpgradeUI();//隐藏UI
                    }
                    else
                    {
                        //升级处理
                        if (mapCube.isUpgraded)//判断是否升级过
                        {
                            ShowUpgradeUI(mapCube.transform.position, true);//调用方法实例化
                        }
                        else
                        {
                            ShowUpgradeUI(mapCube.transform.position, false);//调用方法实例化
                        }
                    }
                    selectedMapcube = mapCube;//更新保存炮台所在的mapCube
                    theCurrentlySelectedTurret = mapCube.turretGo;//更新保存的炮台
                }
            }
        }
    }
}
</code></pre>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 创建炮塔并播放特效
/// &lt;/summary&gt;
/// &lt;param name="turretData"&gt;
/// 炮塔的TurretData
/// &lt;/param&gt;
public void BuildTurret(TurretData turretData)
{
    this.turretData = turretData;//保存炮塔属性
    isUpgraded = false;//定义炮塔未升级
    turretGo = GameObject.Instantiate(turretData.turretPrefab, transform.position, Quaternion.identity);//实例化炮塔并赋值给turretGo
    GameObject effect = GameObject.Instantiate(buildEffect, transform.position, Quaternion.identity);//实例化特效并赋值给effect
    Destroy(effect, 1.0f);//一秒后销毁
}
</code></pre>
<h2 id="功能点5-炮塔价格的定义以及炮塔升级与拆解">功能点5-炮塔价格的定义，以及炮塔升级与拆解</h2>
<p>实现方式：通过功能点4中提到的炮塔数据保存方式，保存炮塔建造与升级所需要的价格，并且通过<code>unity</code>中创建的<code>UI面板</code>，通过先销毁原先炮塔，再重新实例化新炮塔的方式，进行炮塔的升级。或者通过销毁原先炮塔的方式，实现炮塔的拆除</p>
<h3 id="升级面板的显示">升级面板的显示</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 显示升级面板
/// &lt;/summary&gt;
/// &lt;param name="pos"&gt;
/// 定义面板显示位置
/// &lt;/param&gt;
/// &lt;param name="isDisableUpgrade"&gt;
/// 是否禁用按钮
/// &lt;/param&gt;
void ShowUpgradeUI(Vector3 pos, bool isDisableUpgrade = false)
{
    StopCoroutine("HideUpgradeUI");//暂停携程
    upgradeCanvas.SetActive(false);//控制显示与隐藏
    upgradeCanvas.SetActive(true);//控制显示与隐藏
    upgradeCanvas.transform.position = pos;//定义显示位置
    buttonUpgrade.interactable = !isDisableUpgrade;//是否禁用按钮
}

/// &lt;summary&gt;
/// 携程函数 隐藏升级面板
/// &lt;/summary&gt;
/// &lt;returns&gt;&lt;/returns&gt;
IEnumerator HideUpgradeUI()
{
    upgradeCanvasAnimator.SetTrigger("Hide");//更改状态机状态
    yield return new WaitForSeconds(0.3f);//等待0.3秒
    upgradeCanvas.SetActive(false);//控制显示与隐藏
}
</code></pre>
<h3 id="按下升级面板的按键触发">按下升级面板的按键触发</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 按下升级按键触发
/// &lt;/summary&gt;
public void OnUpgradeButtonDown()
{
    if (money &gt;= selectedMapcube.turretData.cosUpgraded)//判断钱够不够
    {
        ChangeMoney(-selectedMapcube.turretData.cosUpgraded);
        selectedMapcube.UpgradeTurret();//调用升级Mapcube上的升级方法
    }
    else
    {
        //提示钱不够
        moneyAnimator.SetTrigger("Flicker");//将动画机的Flicker激活
    }
    StartCoroutine(HideUpgradeUI());//隐藏UI
}

/// &lt;summary&gt;
/// 按下拆解按键触发
/// &lt;/summary&gt;
public void OnDestroyButtonDown()
{
    ChangeMoney(selectedMapcube.turretData.dismantlingPrice);//返还钱
    selectedMapcube.DestroyTurret();//调用升级Mapcube上的拆解方法
    StartCoroutine(HideUpgradeUI());//隐藏UI
}
</code></pre>
<h3 id="升级与拆解方法">升级与拆解方法</h3>
<pre><code class="language-csharp">    /// &lt;summary&gt;
/// 升级炮塔并播放特效
/// &lt;/summary&gt;
public void UpgradeTurret()
{
    if (isUpgraded == true) { return; }//若升级过就销毁

    Destroy(turretGo);//拆解就得炮塔
    isUpgraded = true;//定义炮塔未升级
    turretGo = GameObject.Instantiate(turretData.turretUpgradedPrefab, transform.position, Quaternion.identity);//实例化炮塔并赋值给turretGo
    GameObject effect = GameObject.Instantiate(buildEffect, transform.position, Quaternion.identity);//实例化特效并赋值给effect
    Destroy(effect, 1.0f);//一秒后销毁

}

/// &lt;summary&gt;
/// 拆解炮塔并播放特效
/// &lt;/summary&gt;
public void DestroyTurret()
{
    Destroy(turretGo);//拆解炮塔
                      //恢复初始值
    {
        isUpgraded = false;
        turretGo = null;
        turretData = null;
    }
    GameObject effect = GameObject.Instantiate(buildEffect, transform.position, Quaternion.identity);//实例化特效并赋值给effect
    Destroy(effect, 1.0f);//一秒后销毁

}
</code></pre>
<h2 id="功能点6-控制非激光炮台的攻击">功能点6-控制非激光炮台的攻击</h2>
<p>实现方式：在<code>Unity</code>中对炮台添加碰撞体，并且勾选<code>IsTrigger</code>选项，使用<code>OnTriggerEnter</code>方法进行碰撞检测，利用<code>Tag</code>检测在炮塔碰撞范围内的物体是否是怪物，若是怪物，获取怪物的位置，使炮塔朝向怪物，并且实例化子弹模型，向子弹模型上挂载的<code>Bullet</code>脚本传递敌人位置，从而实现子弹追踪敌人的效果</p>
<h3 id="检测敌人">检测敌人</h3>
<pre><code class="language-csharp">public List&lt;GameObject&gt; enemys = new List&lt;GameObject&gt;();//创建列表保存

/// &lt;summary&gt;
/// OnTriggerEnter is called when the Collider other enters the trigger.
/// 当对撞机other进入触发器时调用OnTriggerEnter。
/// &lt;/summary&gt;
/// &lt;param name="col"&gt;
/// The other Collider involved in this collision.
/// 参与这次碰撞的另一个对撞机。
/// &lt;/param&gt;
void OnTriggerEnter(Collider col)//碰撞检测
{
    if (col.tag == "Enemy")//判断撞上来的物体标签是否为Enemy
    {
        enemys.Add(col.gameObject);//向列表中添加
    }
}

/// &lt;summary&gt;
/// OnTriggerExit is called when the Collider other has stopped touching the trigger.
/// 当对撞机他方停止接触触发器时，调用OnTriggerExit。
/// &lt;/summary&gt;
/// &lt;param name="col"&gt;
/// The other Collider involved in this collision.
/// 参与这次碰撞的另一个对撞机。
/// &lt;/param&gt;
void OnTriggerExit(Collider col)//判断是否出检测范围
{
    if (col.tag == "Enemy")//判断是否为Enemy
    {
        enemys.Remove(col.gameObject);//从列表中删除
    }
}
</code></pre>
<h3 id="更改炮台朝向">更改炮台朝向</h3>
<pre><code class="language-csharp">if (enemys.Count &gt; 0 &amp;&amp; enemys[0] != null &amp;&amp; isItABomb == false)//判断是否有攻击对象
    {
        //保证y轴一致
        Vector3 targetPosition = enemys[0].transform.position;//定义targetPosition为数组中第0个物体的vector3
        targetPosition.y = head.position.y;//保持y轴一致

        head.LookAt(targetPosition);
    }
</code></pre>
<h3 id="实例化子弹模型">实例化子弹模型</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 实例化炮弹攻击敌人
/// &lt;/summary&gt;
void Attack()
{
    if (enemys[0] == null)//判断集合第0位是否为空
    {
        enemys = UpdateEnemys(enemys);//更新敌人
    }
    if (enemys.Count &gt; 0)//判断列表长度是否大于0
    {
        if (isItABomb == false)
        {
            GameObject bullet = GameObject.Instantiate(bulletPrefab, firPosition.position, firPosition.rotation);//实例化炮弹
            bullet.GetComponent&lt;Bullet&gt;().SetTarget(enemys[0].transform);//调用方法传递列表中第一个物体
        }
    }
    else
    {
        timer = attackRateTime;//计时器复位
    }
}
</code></pre>
<h2 id="功能点7-子弹对敌人的伤害">功能点7-子弹对敌人的伤害</h2>
<p>实现方式：通过获取<code>Turret</code>脚本上的敌人位置，使子弹跟踪敌人进行射击，并且通过距离检测的方式，判断子弹是否撞击到敌人，从而调用敌人身上的扣血方法，对敌人进行伤害</p>
<h3 id="获取turret脚本上的敌人位置">获取<code>Turret</code>脚本上的敌人位置</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 用于跨脚本传递 敌人位置
/// &lt;/summary&gt;
/// &lt;param name="_target"&gt;
/// 传递敌人位置
/// &lt;/param&gt;
public void SetTarget(Transform _target)//定义方法 用来传递目标
{
    this.target = _target;//传递目标
}
</code></pre>
<h3 id="子弹追踪敌人射击与计算敌人距离">子弹追踪敌人射击与计算敌人距离</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// Update is called every frame, if the MonoBehaviour is enabled.
/// &lt;/summary&gt;
void Update()
{
    timer += Time.deltaTime;//计时器增加
    if (allEnemies != null &amp;&amp; allEnemies.Count &gt; 0)//判断列表长度是否大于0
    {
        Boom();
    }

    if (target == null)//判断目标不存在
    {
        Die();
        return;
    }

    if (isItABomb == false)//判断是否为炸弹
    {
        transform.LookAt(target.position);//面向敌人
        transform.Translate(Vector3.forward * speed * Time.deltaTime);//移动

        Vector3 dir = target.position - transform.position;//计算与敌人的距离
        if (dir.magnitude &lt;= distanceArriveTarget)//判断是否到达敌人
        {
            target.GetComponent&lt;Enemy&gt;().TakeDamage(damage);//使敌人掉血
            Die();
        }
    }
}
</code></pre>
<h3 id="对敌人造成伤害">对敌人造成伤害</h3>
<pre><code class="language-csharp">target.GetComponent&lt;Enemy&gt;().TakeDamage(damage);//使敌人掉血
Die();
</code></pre>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 使敌人掉血
/// &lt;/summary&gt;
/// &lt;param name="damage"&gt;
/// 掉血血量
/// &lt;/param&gt;
public void TakeDamage(float damage)//收到伤害
{
    if (hp &lt;= 0)//判断是否死亡
    {
        return;
    }
    hp -= damage;//扣血
    hpSlider.value = (float)hp / totahHp;//显示血条
    if (hp &lt;= 0)//判断是否死亡
    {
        Die();
    }
}
</code></pre>
<h2 id="功能点8-激光炮台的攻击">功能点8-激光炮台的攻击</h2>
<p>实现方式：在<code>Unity</code>中对炮台添加碰撞体，并且勾选<code>IsTrigger</code>选项，使用<code>OnTriggerEnter</code>方法进行碰撞检测，利用<code>Tag</code>检测在炮塔碰撞范围内的物体是否是怪物，若是怪物，获取怪物的位置，使炮塔朝向怪物，并且向敌人方向绘制激光，对敌人造成伤害</p>
<h3 id="检测敌人同-功能点6-控制非激光炮台的攻击">检测敌人：同 <a href="https://blog.ccrui.cn#%E5%8A%9F%E8%83%BD%E7%82%B96-%E6%8E%A7%E5%88%B6%E9%9D%9E%E6%BF%80%E5%85%89%E7%82%AE%E5%8F%B0%E7%9A%84%E6%94%BB%E5%87%BB">功能点6-控制非激光炮台的攻击</a></h3>
<h3 id="更改炮台朝向同-功能点6-控制非激光炮台的攻击">更改炮台朝向：同 <a href="https://blog.ccrui.cn#%E5%8A%9F%E8%83%BD%E7%82%B96-%E6%8E%A7%E5%88%B6%E9%9D%9E%E6%BF%80%E5%85%89%E7%82%AE%E5%8F%B0%E7%9A%84%E6%94%BB%E5%87%BB">功能点6-控制非激光炮台的攻击</a></h3>
<h3 id="绘制激光并对敌人造成伤害">绘制激光并对敌人造成伤害</h3>
<pre><code class="language-csharp">    if (useLaser == false)//判断是否为激光
{
    timer += Time.deltaTime;//计时器增加
    if (enemys.Count &gt; 0)//判断敌人数量是否大于0
    {
        Attack("Boom");//调用攻击
    }
    if (enemys.Count &gt; 0 &amp;&amp; timer &gt;= attackRateTime)//判断敌人数量是否大于0并且时间是否到
    {
        timer = 0;//时间复位
        Attack();//调用攻击
    }
}
else if (enemys.Count &gt; 0)//判断是否有敌人
{
    if (laserRenderer.enabled == false)
    {
        laserRenderer.enabled = true;
    }
    laserEffect.SetActive(true);//开启特效
    if (enemys[0] == null)//判断集合第0位是否为空
    {
        enemys = UpdateEnemys(enemys);//更新敌人
    }
    if (enemys.Count &gt; 0)//判断是否有敌人
    {
        laserRenderer.SetPositions(new Vector3[] { firPosition.position, enemys[0].transform.position });//朝向敌人绘制激光
        enemys[0].GetComponent&lt;Enemy&gt;().TakeDamage(damageRate * Time.deltaTime);//使敌人掉血
        laserEffect.transform.position = enemys[0].transform.position;//在敌人位置播放动画
        Vector3 pos = transform.position;//获取当前位置
        pos.y = enemys[0].transform.position.y;//锁定y轴位置保证y轴与敌人高度一致
        laserEffect.transform.LookAt(pos);//定义特效播放朝向

    }
}
else
{
    laserEffect.SetActive(false);//关闭特效
    laserRenderer.enabled = false;//关闭激光显示
}
</code></pre>
<h2 id="功能点9-炸弹攻击">功能点9-炸弹攻击</h2>
<p>实现方式：在<code>Unity</code>中对炮台添加碰撞体，并且勾选<code>IsTrigger</code>选项，使用<code>OnTriggerEnter</code>方法进行碰撞检测，利用<code>Tag</code>检测在炮塔碰撞范围内的物体是否是怪物，若是怪物，获取怪物的<strong>列表</strong>，传递到<code>Bullet</code>脚本，对在列表范围内的全部怪物进行伤害</p>
<h3 id="获取并传递列表">获取并传递列表</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 炸弹攻击敌人
/// &lt;/summary&gt;
/// &lt;param name="i"&gt;
/// 没用，单纯为了重载
/// &lt;/param&gt;
void Attack(string i)
{
    if (enemys[0] == null)//判断集合第0位是否为空
    {
        enemys = UpdateEnemys(enemys);//更新敌人
    }
    if (enemys.Count &gt; 0)//判断列表长度是否大于0
    {
        if (isItABomb)
        {
            this.GetComponent&lt;Bullet&gt;().EnemyList(enemys);//调用方法传递列表
        }
    }
}
</code></pre>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 用于跨脚本传递 敌人数组
/// &lt;/summary&gt;
/// &lt;param name="_enemys"&gt;
/// 传递敌人数组
/// &lt;/param&gt;
public void EnemyList(List&lt;GameObject&gt; _enemys)//定义方法 用来传递 敌人数组
{
    this.allEnemies = _enemys;//传递目标
}
</code></pre>
<h3 id="对范围敌人进行伤害">对范围敌人进行伤害</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 炸弹攻击与销毁流程
/// &lt;/summary&gt;
void Boom()
{
    if (isItABomb == true)//判断是否为炸弹
    {
        if (timer &gt;= attackRateTime)//判断延时爆炸
        {
            if (whetherItIsTriggeredForTheFirstTime)//判断是否为第一次爆炸 防止多次触发造成多次伤害
            {
                // Debug.Log(("敌人数量:") + allEnemies.Count);
                for (int i = 0; i &lt; allEnemies.Count; i++)
                {
                    allEnemies = this.GetComponent&lt;Turret&gt;().UpdateEnemys(allEnemies);//刷新列表
                    allEnemies[i].GetComponent&lt;Enemy&gt;().TakeDamage(boomDamage);//使敌人掉血
                }
                whetherItIsTriggeredForTheFirstTime = false;
                GameObject effect = GameObject.Instantiate(explosionEffctPrefab, transform.position, transform.rotation);//创建特效
                Destroy(effect, 5.0f);//销毁特效
            }
            Destroy(this.gameObject, 0.2f);//销毁子弹
            GameObject.Find("GameManager").GetComponent&lt;BuildManager&gt;().CallCtripFunction();//调用隐藏面板
        }
    }

}
</code></pre>
<h2 id="功能点10-怪物死亡">功能点10-怪物死亡</h2>
<p>实现方式：判断怪物的血量是否小于等于0，从而销毁怪物，并移出列表</p>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 使敌人掉血
/// &lt;/summary&gt;
/// &lt;param name="damage"&gt;
/// 掉血血量
/// &lt;/param&gt;
public void TakeDamage(float damage)//收到伤害
{
    if (hp &lt;= 0)//判断是否死亡
    {
        return;
    }
    hp -= damage;//扣血
    hpSlider.value = (float)hp / totahHp;//显示血条
    if (hp &lt;= 0)//判断是否死亡
    {
        Die();
    }
}

/// &lt;summary&gt;
/// 怪物死亡后调用
/// &lt;/summary&gt;
void Die()
{
    GameObject effect = GameObject.Instantiate(exlosionEffect, transform.position, transform.rotation);//实例化
    Destroy(effect, 1.5f);//销毁特效
    Destroy(this.gameObject);//销毁自身
}
</code></pre>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// This function is called when the MonoBehaviour will be destroyed.
/// 当物体被销毁后调用该函数
/// &lt;/summary&gt;
void OnDestroy()
{
    EnemySpawner.CountEnemyAlive--;//敌人数量减少
}
</code></pre>
<h2 id="功能点11-怪物到达终点与全部死亡时的处理与ui显示">功能点11-怪物到达终点与全部死亡时的处理与UI显示</h2>
<p>实现方式：怪物死亡后销毁自身，并且在全部怪物死亡后，显示<code>游戏胜利UI</code>。通过检测坐标点的方式，检测怪物是否到达终点，从而停止游戏进程，并且显示<code>游戏失败UI</code></p>
<h3 id="怪物死亡后的处理">怪物死亡后的处理</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 怪物死亡后调用
/// &lt;/summary&gt;
void Die()
{
    GameObject effect = GameObject.Instantiate(exlosionEffect, transform.position, transform.rotation);//实例化
    Destroy(effect, 1.5f);//销毁特效
    Destroy(this.gameObject);//销毁自身
}
    ```

``` csharp
/// &lt;summary&gt;
/// This function is called when the MonoBehaviour will be destroyed.
/// 当物体被销毁后调用该函数
/// &lt;/summary&gt;
void OnDestroy()
{
    EnemySpawner.CountEnemyAlive--;//敌人数量减少
}
</code></pre>
<h3 id="怪物全部死亡后的处理">怪物全部死亡后的处理</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 携程函数 控制生成敌人数量与间隔
/// &lt;/summary&gt;
/// &lt;returns&gt;&lt;/returns&gt;
IEnumerator SpawnEnemy()//携程函数
{
    foreach (Wave wave in waves)//循环遍历Wave
    {
        for (int i = 0; i &lt; wave.count; i++)
        {
            GameObject.Instantiate(wave.enemyPrefab, START.position, Quaternion.identity);//根据enmyPrefab在开始位置，生成无旋转的物体
            CountEnemyAlive++;//使敌人数量增加
            if (i != wave.count - 1)
            {
                yield return new WaitForSeconds(wave.rate);//暂停rate秒
            }
        }
        while (CountEnemyAlive &gt; 0)
        {
            yield return 0;//返回
        }
        yield return new WaitForSeconds(WaveRate);//暂停WaveRate秒
    }
    while (CountEnemyAlive &gt; 0)//说明敌人还有存货
    {
        yield return 0;//返回
    }
    GameManager.instance.Win();//调用胜利
}
</code></pre>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 游戏胜利 显示界面和文字
/// &lt;/summary&gt;
public void Win()
{
    endUI.SetActive(true);//显示界面
    endMessage.text = "游戏胜利";//显示文字
}
</code></pre>
<h3 id="判断怪物到达终点">判断怪物到达终点</h3>
<pre><code class="language-csharp">if (index &gt; positions.Length - 1)//判断是否超出路径数量
    {
        ReachDestination();
    }
</code></pre>
<h3 id="怪物到达终点后的处理">怪物到达终点后的处理</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 怪物到达终点后执行
/// &lt;/summary&gt;
void ReachDestination()
{
    GameManager.instance.Failed();//调用游戏失败
    GameObject.Destroy(this.gameObject);//清除
}
    ```

``` csharp
/// &lt;summary&gt;
/// 游戏失败 显示界面和文字 并停止生成
/// &lt;/summary&gt;
public void Failed()
{
    enemySpawner.Stop();//停止生成
    endUI.SetActive(true);//显示界面
    endMessage.text = "游戏失败";//显示文字
}
</code></pre>
<h2 id="功能点12-游戏暂停与ui显示">功能点12-游戏暂停与UI显示</h2>
<p>实现方式：使用脚本，检测是否按下<code>esc</code>键，并在按下按键后，显示在<code>Unity</code>中设计好的<code>游戏暂停UI</code>，并将游戏的时间刻度停止，从而达到暂停游戏的目的</p>
<h3 id="检测是否按下esc并显示游戏ui">检测是否按下<code>esc</code>并显示游戏UI</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// Update is called every frame, if the MonoBehaviour is enabled.
/// &lt;/summary&gt;
void Update()
{
    PauseTheGame();
}

/// &lt;summary&gt;
/// 暂停游戏
/// &lt;/summary&gt;
void PauseTheGame()
{
    if (Input.GetKeyDown(KeyCode.Escape))//判断是否按下ESC
    {
        Time.timeScale = 0;//游戏暂停
        whetherTheGameIsPaused = true;//保存游戏暂停状态
        gamePauseUi.SetActive(true);//显示游戏暂停UI
    }
}
</code></pre>
<h3 id="游戏继续">游戏继续</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 继续游戏
/// &lt;/summary&gt;
public void ContinueTheGame()
{
    if (this.GetComponent&lt;GameManager&gt;().IsItDoubleSpeed() == false)
    {
        Time.timeScale = 1;//游戏继续
    }
    else
    {
        Time.timeScale = 2;//游戏继续
    }
    gamePauseUi.SetActive(false);//隐藏游戏暂停UI
    whetherTheGameIsPaused = false;//保存游戏暂停状态
}
</code></pre>
<h3 id="返回主界面">返回主界面</h3>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 返回主界面
/// &lt;/summary&gt;
public void BackToMainInterface()
{
    Time.timeScale = 1;//游戏继续
    this.GetComponent&lt;GameManager&gt;().OnButtonMenu();//返回主界面
}
</code></pre>
<h2 id="功能点13-切换游戏倍速">功能点13-切换游戏倍速</h2>
<p>实现方式：利用在<code>Unity</code>中建立的按钮，控制游戏<code>Time.timeScale</code>属性的值，从而达到控制切换游戏倍速的目的</p>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 使游戏倍速运行
/// &lt;/summary&gt;
public void DoubleSpeed()
{
    if (isItDoubleSpeed == false &amp;&amp; this.GetComponent&lt;PauseUiControl&gt;().WhetherTheGameIsPaused() == false)//判断倍速状态与暂停状态
    {
        isItDoubleSpeed = true;//使其为倍速
        Time.timeScale = 2;//游戏倍速
        speedDisplay.text = "当前：二倍速";
    }
    else if (isItDoubleSpeed == true &amp;&amp; this.GetComponent&lt;PauseUiControl&gt;().WhetherTheGameIsPaused() == false)//判断倍速状态与暂停状态
    {
        isItDoubleSpeed = false;//使其为倍速
        Time.timeScale = 1;//游戏倍速
        speedDisplay.text = "当前：一倍速";
    }
}
</code></pre>
<h2 id="功能点15-界面设计">功能点15-界面设计</h2>
<p>实现方式：在<code>Unity</code>中进行<code>Ui设计</code>，并且利用<code>Button</code>进行界面的切换</p>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 姓名：张程瑞
/// 学号：19107350111
/// 脚本作用：控制游戏UI
/// &lt;/summary&gt;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour
{

    public GameObject endUI;//结束界面
    public Text endMessage;//文字

    private bool isItDoubleSpeed;//是否为倍速

    public Text speedDisplay;//倍速显示

    /// &lt;summary&gt;
    /// 从其他脚本中调用是否为倍速
    /// &lt;/summary&gt;
    /// &lt;returns&gt;
    /// 返回bool类型是否为倍速
    /// &lt;/returns&gt;
    public bool IsItDoubleSpeed()
    {
        return isItDoubleSpeed;//返回是否为倍速
    }

    //单例模式
    private EnemySpawner enemySpawner;
    public static GameManager instance;

    /// &lt;summary&gt;
    /// Awake is called when the script instance is being loaded.
    /// 在加载脚本时调用
    /// &lt;/summary&gt;
    void Awake()
    {
        instance = this;
        enemySpawner = GetComponent&lt;EnemySpawner&gt;();
    }

    /// &lt;summary&gt;
    /// 游戏胜利 显示界面和文字
    /// &lt;/summary&gt;
    public void Win()
    {
        endUI.SetActive(true);//显示界面
        endMessage.text = "游戏胜利";//显示文字
    }

    /// &lt;summary&gt;
    /// 游戏失败 显示界面和文字 并停止生成
    /// &lt;/summary&gt;
    public void Failed()
    {
        enemySpawner.Stop();//停止生成
        endUI.SetActive(true);//显示界面
        endMessage.text = "游戏失败";//显示文字
    }

    /// &lt;summary&gt;
    /// 按下按钮触发 重新加载场景
    /// &lt;/summary&gt;
    public void OnButtonRetry()
    {
        Time.timeScale = 1;//游戏速度默认
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);//重新加载当前场景
    }

    /// &lt;summary&gt;
    /// 按下按钮触发 返回主界面
    /// &lt;/summary&gt;
    public void OnButtonMenu()
    {
        Time.timeScale = 1;//游戏速度默认
        SceneManager.LoadScene(0);//返回主界面
    }

    /// &lt;summary&gt;
    /// 使游戏倍速运行
    /// &lt;/summary&gt;
    public void DoubleSpeed()
    {
        if (isItDoubleSpeed == false &amp;&amp; this.GetComponent&lt;PauseUiControl&gt;().WhetherTheGameIsPaused() == false)//判断倍速状态与暂停状态
        {
            isItDoubleSpeed = true;//使其为倍速
            Time.timeScale = 2;//游戏倍速
            speedDisplay.text = "当前：二倍速";
        }
        else if (isItDoubleSpeed == true &amp;&amp; this.GetComponent&lt;PauseUiControl&gt;().WhetherTheGameIsPaused() == false)//判断倍速状态与暂停状态
        {
            isItDoubleSpeed = false;//使其为倍速
            Time.timeScale = 1;//游戏倍速
            speedDisplay.text = "当前：一倍速";
        }
    }

}

</code></pre>
<pre><code class="language-csharp">/// &lt;summary&gt;
/// 姓名：张程瑞
/// 学号：19107350111
/// 脚本作用：控制游戏暂停UI
/// &lt;/summary&gt;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class PauseUiControl : MonoBehaviour
{

    public GameObject gamePauseUi;

    private bool whetherTheGameIsPaused = false;//游戏是否暂停

    /// &lt;summary&gt;
    /// 从其他脚本中调用是否游戏暂停
    /// &lt;/summary&gt;
    /// &lt;returns&gt;
    /// 返回游戏是否暂停
    /// &lt;/returns&gt;
    public bool WhetherTheGameIsPaused()
    {
        return whetherTheGameIsPaused;
    }

    /// &lt;summary&gt;
    /// Update is called every frame, if the MonoBehaviour is enabled.
    /// &lt;/summary&gt;
    void Update()
    {
        PauseTheGame();
    }

    /// &lt;summary&gt;
    /// 暂停游戏
    /// &lt;/summary&gt;
    void PauseTheGame()
    {
        if (Input.GetKeyDown(KeyCode.Escape))//判断是否按下ESC
        {
            Time.timeScale = 0;//游戏暂停
            whetherTheGameIsPaused = true;//保存游戏暂停状态
            gamePauseUi.SetActive(true);//显示游戏暂停UI
        }
    }

    /// &lt;summary&gt;
    /// 继续游戏
    /// &lt;/summary&gt;
    public void ContinueTheGame()
    {
        if (this.GetComponent&lt;GameManager&gt;().IsItDoubleSpeed() == false)
        {
            Time.timeScale = 1;//游戏继续
        }
        else
        {
            Time.timeScale = 2;//游戏继续
        }
        gamePauseUi.SetActive(false);//隐藏游戏暂停UI
        whetherTheGameIsPaused = false;//保存游戏暂停状态
    }

    /// &lt;summary&gt;
    /// 返回主界面
    /// &lt;/summary&gt;
    public void BackToMainInterface()
    {
        Time.timeScale = 1;//游戏继续
        this.GetComponent&lt;GameManager&gt;().OnButtonMenu();//返回主界面
    }

}
</code></pre>
<h2 id="功能点14-各种特效制作">功能点14-各种特效制作</h2>
<p>实现方式：在<code>Unity</code>中进行特效制作</p>
<h2 id="游戏运行截图">游戏运行截图</h2>
<h3 id="开始界面">开始界面</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FDemo01_TtqZAVqqNc.png&amp;size=m" alt="开始界面"></p>
<h3 id="游戏界面">游戏界面</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FDemo01_apbaLjHdkG.png&amp;size=m" alt="游戏界面"></p>
<h3 id="胜利界面">胜利界面</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FDemo01_vMVkrAy7mY.png&amp;size=m" alt="胜利界面"></p>
<h3 id="失败界面">失败界面</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FDemo01_o4qgVWrtd1.png&amp;size=m" alt="失败界面"></p>
<h3 id="暂停界面">暂停界面</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FDemo01_n7xcPS1vyI.png&amp;size=m" alt="暂停界面"></p>]]></description><guid isPermaLink="false">/archives/204.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 18 Aug 2020 12:40:00 GMT</pubDate></item><item><title><![CDATA[使用VSCode编写Unity常用插件]]></title><link>https://blog.ccrui.cn/archives/201.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E4%BD%BF%E7%94%A8VSCode%E7%BC%96%E5%86%99Unity%E5%B8%B8%E7%94%A8%E6%8F%92%E4%BB%B6&amp;url=/archives/201.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="使用vscode编写unity常用插件">使用VSCode编写Unity常用插件</h1>
<h2 id="chinese-simplified-language-pack-for-visual-studio-code">Chinese (Simplified) Language Pack for Visual Studio Code</h2>
<p>这个就不多说了<br>
  属于必装插件<br>
  适用于 VS Code 的中文（简体）语言包</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_B7Z2TvxUuF.png&amp;size=m" alt="适用于 VS Code 的中文（简体）语言包"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=MS-CEINTL.vscode-language-pack-zh-hans">Chinese (Simplified) Language Pack for Visual Studio Code</a></p>
</blockquote>
<h2 id="c">C#</h2>
<p>也是必备插件</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_OOSOLcXSwU.png&amp;size=m" alt="C#"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp">C#</a></p>
</blockquote>
<h2 id="auto-using-for-c">Auto-Using for C#</h2>
<p>自动添加命名空间</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_UALxBnIkbK.png&amp;size=m" alt="Auto-Using for C#"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=Fudge.auto-using">Auto-Using for C#</a></p>
</blockquote>
<h2 id="debugger-for-unity">Debugger for Unity</h2>
<p>Unity的调试工具</p>
<p>这个Unity打开工程的时候会在.vscode生成一个launch.json 如果出现错误调试不成功就删除这个launch.json 从打开vscode生成</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_wcdnasCm5N.png&amp;size=m" alt="Debugger for Unity"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=Unity.unity-debug">Debugger for Unity</a></p>
</blockquote>
<h2 id="unity-tools">Unity Tools</h2>
<p>Unity工具 那些Update方法等</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_2e06K7Xq1o.png&amp;size=m" alt="Unity Tools"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=Tobiah.unity-tools">Unity Tools</a></p>
</blockquote>
<h2 id="unity-snippets">Unity Snippets</h2>
<p>和上个插件用途基本一致，提供各种Unity方法</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_y2iV7462kD.png&amp;size=m" alt="Unity Snippets"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=YclepticStudios.unity-snippets">Unity Snippets</a></p>
</blockquote>
<hr>
<p>使用以上插件后，即可正常使用VSCode编写Unity代码</p>
<hr>
<h2 id="c-xml-documentation-comments">C# XML Documentation Comments</h2>
<p>快速生成代码注释头</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_qDQLAFXua7.png&amp;size=m" alt="C# XML Documentation Comments"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=k--kato.docomment">C# XML Documentation Comments</a></p>
</blockquote>
<pre><code> /// &lt;summary&gt;
 /// 说明
 /// &lt;/summary&gt;
</code></pre>
<h2 id="bracket-pair-colorizer">Bracket Pair Colorizer</h2>
<p>让你的括号有属于自己的颜色提高开发效率</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_pYiyPDgX5B.png&amp;size=m" alt="Bracket Pair Colorizer"></p>
<blockquote>
 <p>下载地址：<a href="https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2">Bracket Pair Colorizer</a></p>
</blockquote>
<h2 id="trailing-spaces">Trailing Spaces</h2>
<p>提示你多余的空格 美观代码</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_unkrjVejeI.png&amp;size=m" alt="Trailing Spaces"></p>
<blockquote>
 <p><a href="https://marketplace.visualstudio.com/items?itemName=shardulm94.trailing-spaces">Trailing Spaces</a></p>
</blockquote>
<h2 id="翻译英汉词典">翻译(英汉词典)</h2>
<p>划词翻译与批量翻译标识符，英语不好的可以使用</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_gUwLYKKNDU.png&amp;size=m" alt="翻译(英汉词典)"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=CodeInChinese.EnglishChineseDictionary">翻译(英汉词典)</a></p>
</blockquote>
<h2 id="var-translate">var-translate</h2>
<p>使用翻译api将其他语言到英文,转换成常见的变量命名形式</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_X9K46BRAIc.png&amp;size=m" alt="var-translate"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=svenzhao.var-translation">var-translate</a></p>
</blockquote>
<h2 id="vscode-great-icons">VSCode Great Icons</h2>
<p>改变文件夹的外观图标</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_bDlEo8yMcW.png&amp;size=m" alt="VSCode Great Icons"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=emmanuelbeziat.vscode-great-icons">VSCode Great Icons</a></p>
</blockquote>
<h2 id="prettier---code-formatter">Prettier - Code formatter</h2>
<p>保存即可自动格式化代码</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_tOy9suNghY.png&amp;size=m" alt="Prettier - Code formatter"></p>
<p>设置方法：</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_JSL7HxZio2.png&amp;size=m" alt="设置方法"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode">Prettier - Code formatter</a></p>
</blockquote>
<h2 id="code-spell-checker">Code Spell Checker</h2>
<p>代码拼写检查，可以检查代码中单词的拼写错误，并且给出拼写错误单词的建议</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_g4M55JjHcF.png&amp;size=m" alt="Code Spell Checker"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker">Code Spell Checker</a></p>
</blockquote>
<h2 id="better-comments">Better Comments</h2>
<p>使注释更有人性化的高亮显示</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F18%2FCode_vDv8QgJEcp.png&amp;size=m" alt="Better Comments"></p>
<blockquote>
 <p>安装地址：<a href="https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments">Better Comments</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/201.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 18 Aug 2020 01:04:00 GMT</pubDate></item><item><title><![CDATA[Gridea静态博客搭建]]></title><link>https://blog.ccrui.cn/archives/193.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Gridea%E9%9D%99%E6%80%81%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA&amp;url=/archives/193.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="gridea静态博客搭建">Gridea静态博客搭建</h1>
<h2 id="引言">引言</h2>
<p>原本为使用的博客是由<a href="http://typecho.org/">Typecho</a>搭建的，使用了<a href="https://www.ihewro.com/archives/489/">handsome</a>主题，但是经过了多次的主题魔改，以及cdn加成，但是还是觉得网页加载速度慢，以及臃肿，所以我想到了使用Github仓库配合开源项目<a href="https://gridea.dev/">Gridea</a>搭建一个完全静态的博客页面，并辅助以cdn加速，达到一个轻量而不简单的博客~<br>
  好了废话不多说了，看下面↓</p>
<h2 id="安装">安装</h2>
<p>点击下面链接 直接根据<code>自己的系统版本</code>安装<code>Gridea</code></p>
<p>[button color="dark" icon="" url="<a href="https://gridea.dev/">https://gridea.dev/</a>" type=""]Gridea[/button]</p>
<p>不出意外的话，下载windows或者MacOS的安装包安装即可</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F09%2Fmsedge_GhuYqHTlUW.png&amp;size=m" alt="安装包"></p>
<h2 id="写作">写作</h2>
<p>打开Gridea后点击右上角小加号，即可使用Md语法进行写作了哦~</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F09%2FGridea_cyiHhLIB5K.png&amp;size=m" alt="写作"></p>
<h2 id="发布">发布</h2>
<blockquote>
 <p>Gridea 提供了将博客部署到 GitHub Pages、Coding Pages 和通过 SFTP 的方式上传到自己的服务器的功能。下面将以 GitHub 为例，来讲一下部署流程。</p>
</blockquote>
<ol>
 <li>
  <p><strong>创建 GitHub 账号，并创建一个仓库 Token。</strong> 点击<a href="https://github.com/">GitHub</a>，进行注册。登录 GitHub 之后，点击<a href="https://github.com/settings/tokens/new">这里</a>创建一个 Token，**勾选上 repo 的相关权限即可。**生成之后记得把 Token 复制到你的本地，因为一旦关闭网页将不能再看到它。</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F09%2Fmsedge_MLMg9q6ORL.png&amp;size=m" alt="Token"></p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F09%2Fmsedge_QtBd1NJs8f.png&amp;size=m" alt="Token"></p></li>
 <li>
  <p><strong>创建仓库，存放构建后的网站文件。<strong>创建一个公开仓库，名为</strong>用户名.github.io。</strong>（将用户名替换为你的 GitHub 用户名）</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F09%2Fmsedge_ZayVCKLO16.png&amp;size=m" alt="创建仓库"></p></li>
 <li>
  <p>**进入 Gridea 进行远程设置。**按照下图的示例进行设置，然后点击「检测远程链接」，进行配置检查。</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F09%2FGridea_xWXE2nKHf7.png&amp;size=m" alt="远程设置"></p></li>
 <li>
  <p>**同步。**点击 Gridea 中的 同步按钮即可。初次部署等待几分钟之后就可以去浏览器访问了，默认地址为你在第 3 步所填写的域名。</p></li>
</ol>
<h2 id="完成">完成</h2>
<p>以上，就完成了一个静态博客的搭建了~</p>
<p>在浏览器中输入 cr-zhichen.github.io（cr-zhichen换成你的用户名），即可访问自己的静态博客了哦~</p>]]></description><guid isPermaLink="false">/archives/193.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 9 Aug 2020 13:17:00 GMT</pubDate></item><item><title><![CDATA[记一个Unity大作业说明文档]]></title><link>https://blog.ccrui.cn/archives/186.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E8%AE%B0%E4%B8%80%E4%B8%AAUnity%E5%A4%A7%E4%BD%9C%E4%B8%9A%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3&amp;url=/archives/186.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="期末大作业-说明文档">期末大作业-说明文档</h1>
<h2 id="1引言">1.引言</h2>
<h3 id="11编写目的">1.1编写目的</h3>
<p>本概要设计说明书目的在于说明“Unity期末大作业”的游戏玩法，与游戏各功能的实现方式与设计思路。包括如何产生程序设计灵感，与程序设计步骤与想法。<br>
  本说明书的预期读者为：为此游戏评分的老师与同学</p>
<h3 id="12背景">1.2背景</h3>
<p>项目名称：Unity期末大作业<br>
  本项目的任务开发者：张程瑞<br>
  本项目的用户：游戏玩家</p>
<h3 id="13定义">1.3定义</h3>
<p>开发工具：Unity2017.3.1f1,Visual Studio 2017<br>
  开发语言：c#开发框架<br>
  游戏：若未特别指出，统指“Unity期末大作业”游戏</p>
<h3 id="14参考材料与模型来源">1.4参考材料与模型来源</h3>
<p>代码参考：课上老师带领编写代码<br>
  模型来源：<a href="https://pan.baidu.com/s/1Cq-1zugCpAFUOFe9a2aGeg">百度网盘链接</a></p>
<h2 id="2逻辑设计">2.逻辑设计</h2>
<h3 id="21软件设计">2.1软件设计</h3>
<p>游戏场景包括：游戏UI，游戏地面，游戏本体，游戏相机<br>
  其中游戏UI包括：开始界面，游戏暂停，难度选择，游戏结束，游戏胜利</p>
<h3 id="22基本设计概念与处理流程">2.2基本设计概念与处理流程</h3>
<p>游戏流程：<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F11%2FUnity.jpg&amp;size=m" alt="游戏流程图"></p>
<h3 id="23功能需求与程序的关系">2.3功能需求与程序的关系</h3>
<table>
 <thead>
  <tr>
   <th align="center">需求</th>
   <th align="center">脚本</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td align="center">屏幕显示</td>
   <td align="center">游戏界面逻辑.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">游戏界面切换逻辑.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">CameraCtrl.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">第一人称相机.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">显示游戏</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">显示地图</td>
  </tr>
  <tr>
   <td align="center">控制人物动画</td>
   <td align="center">玩家动画.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">PlayerCtrl.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">怪物随机生成.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">人称切换检测.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">AiCtrl.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">怪物控制</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">画面移动</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">怪物攻击</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">人物攻击</td>
  </tr>
  <tr>
   <td align="center">碰撞检测</td>
   <td align="center">Player.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">Shell.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">死亡检测</td>
  </tr>
  <tr>
   <td align="center">界面UI</td>
   <td align="center">游戏界面切换逻辑.cs</td>
  </tr>
  <tr>
   <td align="center"></td>
   <td align="center">角色切换UI</td>
  </tr>
 </tbody>
</table>
<h2 id="3接口设计">3.接口设计</h2>
<h3 id="31用户接口">3.1用户接口</h3>
<p>在用户界面根据用户使用习惯，采用用户友善界面，并对用户的操作做出一定提示，使用按键方式突出显示重要选项，使界面更加的简单易用</p>
<h4 id="311主界面">3.1.1主界面</h4>
<p>背景：游戏地面<br>
  文字：难度显示，人称显示<br>
  主要按钮：开始游戏，选择难度<br>
  次要按钮：视角切换，角色切换，游戏帮助，退出游戏</p>
<table>
 <thead>
  <tr>
   <th align="center">按钮名称</th>
   <th align="center">按钮功能</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td align="center">开始游戏</td>
   <td align="center">进行开始游戏逻辑</td>
  </tr>
  <tr>
   <td align="center">选择难度</td>
   <td align="center">进入关卡选择</td>
  </tr>
  <tr>
   <td align="center">视角切换</td>
   <td align="center">切换第一人称视角与第三人称视角</td>
  </tr>
  <tr>
   <td align="center">角色切换</td>
   <td align="center">切换角色</td>
  </tr>
  <tr>
   <td align="center">游戏帮助</td>
   <td align="center">显示游戏帮助文字</td>
  </tr>
  <tr>
   <td align="center">退出游戏</td>
   <td align="center">退出整个游戏</td>
  </tr>
 </tbody>
</table>
<h4 id="312难度选择界面">3.1.2难度选择界面</h4>
<p>背景：游戏地面<br>
  四个按钮：简单，普通，困难，Boss战<br>
  按钮作用：切换不同难度后返回主界面</p>
<h4 id="313游戏暂停界面">3.1.3游戏暂停界面</h4>
<p>背景：当前背景<br>
  文字：游戏暂停<br>
  按钮：继续游戏，返回菜单，游戏帮助，退出游戏</p>
<table>
 <thead>
  <tr>
   <th align="center">按钮名称</th>
   <th align="center">按钮功能</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td align="center">继续游戏</td>
   <td align="center">继续暂停游戏</td>
  </tr>
  <tr>
   <td align="center">返回菜单</td>
   <td align="center">返回主界面</td>
  </tr>
  <tr>
   <td align="center">游戏帮助</td>
   <td align="center">现实游戏帮助文字</td>
  </tr>
  <tr>
   <td align="center">退出游戏</td>
   <td align="center">退出整个游戏</td>
  </tr>
 </tbody>
</table>
<h4 id="314游戏结束界面">3.1.4游戏结束界面</h4>
<p>背景：当前背景，得分显示<br>
  文字：游戏结束<br>
  按钮：重新开始，退出游戏</p>
<table>
 <thead>
  <tr>
   <th align="center">按钮名称</th>
   <th align="center">按钮功能</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td align="center">重新开始</td>
   <td align="center">返回主界面</td>
  </tr>
  <tr>
   <td align="center">退出游戏</td>
   <td align="center">退出整个游戏</td>
  </tr>
 </tbody>
</table>
<h4 id="315游戏胜利界面">3.1.5游戏胜利界面</h4>
<p>背景：当前背景<br>
  文字：游戏胜利<br>
  按钮：重新开始，退出游戏</p>
<table>
 <thead>
  <tr>
   <th align="center">按钮名称</th>
   <th align="center">按钮功能</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td align="center">返回菜单</td>
   <td align="center">返回主界面</td>
  </tr>
  <tr>
   <td align="center">退出游戏</td>
   <td align="center">退出整个游戏</td>
  </tr>
 </tbody>
</table>
<h3 id="32外部接口">3.2外部接口</h3>
<p>软件接口：Unity3d</p>
<h3 id="33内部接口">3.3内部接口</h3>
<table>
 <thead>
  <tr>
   <th align="center">脚本</th>
   <th align="center">值与传递方式</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td align="center">玩家动画.cs</td>
   <td align="center">Unity中直接调用 用来控制角色移动与动画</td>
  </tr>
  <tr>
   <td align="center">Player.cs</td>
   <td align="center">Unity中直接调用，PlayerCtrl.cs中调用函数，Shell.cs中调用函数，游戏界面逻辑.cs中调用变量，AiCtrl.cs中调用函数</td>
  </tr>
  <tr>
   <td align="center">PlayerCtrl.cs</td>
   <td align="center">Unity中直接调用 控制玩家移动</td>
  </tr>
  <tr>
   <td align="center">Shell.cs</td>
   <td align="center">Unity中直接调用 控制子弹发射，在游戏界面切换逻辑.cs 中调用子弹伤害变量</td>
  </tr>
  <tr>
   <td align="center">第一人称相机.cs</td>
   <td align="center">Unity中直接调用 控制第一人称相机的位置</td>
  </tr>
  <tr>
   <td align="center">怪物随机生成.cs</td>
   <td align="center">Unity中直接调用 控制怪物生成数量，在游戏界面切换逻辑.cs中调用怪物生成数量变量与怪物出生之间间隔变量</td>
  </tr>
  <tr>
   <td align="center">角色切换UI.cs</td>
   <td align="center">Unity中直接调用 切换开始界面上的角色角色切换UI，在游戏界面切换逻辑.cs中调用函数</td>
  </tr>
  <tr>
   <td align="center">人称切换检测.cs</td>
   <td align="center">Unity中直接调用 切换人称，在游戏界面切换逻辑.cs中调用函数</td>
  </tr>
  <tr>
   <td align="center">游戏界面逻辑.cs</td>
   <td align="center">Unity中直接调用 生成游戏物体</td>
  </tr>
  <tr>
   <td align="center">游戏界面切换逻辑.cs</td>
   <td align="center">Unity中直接调用 游戏主逻辑脚本</td>
  </tr>
  <tr>
   <td align="center">AiCtrl.cs</td>
   <td align="center">Unity中直接调用 控制怪物追踪</td>
  </tr>
  <tr>
   <td align="center">CameraCtrl.cs</td>
   <td align="center">Unity中直接调用 控制第三人称相机</td>
  </tr>
 </tbody>
</table>
<h2 id="4游戏设计思路">4.游戏设计思路</h2>
<h3 id="41基础思路">4.1基础思路</h3>
<p>构建游戏基本场景，并完成游戏基本搭建，制作游戏中的碰撞检测与玩家移动控制，玩家攻击与受击逻辑</p>
<h3 id="42进阶思路">4.2进阶思路</h3>
<p>在构建完成基本场景后，加入游戏UI，使游戏可以更加简明易上手。<br>
  设置多种难度选项，设置多个UI满足游戏各个情况下的界面反馈信息。<br>
  设置摄像机切换，完善游戏玩法与体验。<br>
  设置游戏中鼠标居中逻辑，增强游戏体验。</p>
<h2 id="5游戏界面">5.游戏界面</h2>
<h3 id="51开始界面">5.1开始界面</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F11%2F7223a70b452bfc9d0edd95f089aec403.png&amp;size=m" alt="开始界面"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F11%2F881ad7404bb5d159fbdf04638b8e08dc.png&amp;size=m" alt="难度选择界面"></p>
<h3 id="52游戏界面">5.2游戏界面</h3>
<h4 id="521-第三人称">5.2.1 第三人称</h4>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F11%2Fff8c504154be6763ce912363955718ff.png&amp;size=m" alt="第三人称"></p>
<h4 id="522-第一人称">5.2.2 第一人称</h4>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F11%2F709106e59d035db2478c30bef2859cd2.png&amp;size=m" alt="第一人称"></p>
<h4 id="53其余ui界面">5.3其余UI界面</h4>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F11%2F61a5bd0a056b6e1fd03e1ba44dcc824d.png&amp;size=m" alt="游戏结束"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F11%2F90a5de328ad5dabd55fce9fefb596b10.png&amp;size=m" alt="游戏胜利"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F11%2F17f799954c6c2a15f1735a7aae25592c.png&amp;size=m" alt="游戏暂停"></p>]]></description><guid isPermaLink="false">/archives/186.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 8 Aug 2020 09:10:00 GMT</pubDate></item><item><title><![CDATA[记一次简单起始页的搭建与自定义]]></title><link>https://blog.ccrui.cn/archives/182.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E8%AE%B0%E4%B8%80%E6%AC%A1%E7%AE%80%E5%8D%95%E8%B5%B7%E5%A7%8B%E9%A1%B5%E7%9A%84%E6%90%AD%E5%BB%BA%E4%B8%8E%E8%87%AA%E5%AE%9A%E4%B9%89&amp;url=/archives/182.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="搞一个简约一点的起始页">搞一个简约一点的起始页</h1>
<h2 id="前言">前言</h2>
<p>本来无聊在刷知乎，结果找到了一条有趣的帖子，说是可以自己搭建一个浏览器起始页，没有广告，还可以自定义里面的东西，看到这里我顿时就心动了。<br>
  我原先使用的起始页，也算是一个比较有名的起始页了 <a href="https://a.maorx.cn/">青柠起始页</a> 虽然说颜值很高，但是对电脑性能有一定的要求，而且在各种快捷功能切换上也不是很舒服，于是我上Github上找了一个可以自行搭建的起始页项目 <a href="https://github.com/xiandus/search">闲渡搜索导航</a></p>
<h2 id="下载项目">下载项目</h2>
<p>[button color="black" icon="" url="<a href="https://github.com/xiandus/search">https://github.com/xiandus/search</a>" type=""]Github[/button] [button color="info" icon="" url="<a href="https://www.yun.chengrui.xyz/#/s/zNTE">https://www.yun.chengrui.xyz/#/s/zNTE</a>" type=""]本站下载[/button]</p>
<h2 id="上传服务器">上传服务器</h2>
<p>将下载好的压缩包上传到服务器后并解压</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F06%2Fmsedge_V544AaDDkj.png&amp;size=m" alt="上传并解压"></p>
<h2 id="搭建完成">搭建完成</h2>
<p>进入 <code>宝塔</code>-<code>网站</code> 界面添加站点，选择你刚才解压的文件夹，并绑定域名，即可直接使用</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F06%2Fmsedge_8IUmPwAB3H.jpg&amp;size=m" alt="搭建完成"></p>
<h2 id="https部署">https部署</h2>
<p>打开 <code>宝塔</code>-<code>网站</code> 选择你需要部署https的网站，点击设置，选择 <code>SSl</code>-<code>LetsEncrypt</code><br>
  根据提示部署免费ssl证书即可</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F06%2Fmsedge_tP2kd0X3hm.png&amp;size=m" alt="ssl"></p>
<h2 id="更改配置">更改配置</h2>
<p>在 <code>index.php</code> 文件下可以进行常用网站的设置与排序，右侧菜单中的快捷方式自定义等操作</p>
<p>在 <code>index.php</code> 第199行处可修改下方logo（可直接删除）<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F06%2Fmsedge_TiREJVh0S9.png&amp;size=m" alt="logo"></p>
<p>在 <code>style.css</code> 文件第<code>30行</code>与第<code>253行</code>中可以更改背景图片<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F06%2Fmsedge_EqbYdI8Pu1.png&amp;size=m" alt="背景图片"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F06%2Fmsedge_lUNGv5IR41.png&amp;size=m" alt="背景图片"></p>
<h2 id="网站演示">网站演示</h2>
<p>[post url="<a href="http://a.chengrui.xyz">http://a.chengrui.xyz</a>" title="辣鸡搜索" intro="辣鸡搜索主页" cover="<a href="https://img-cdn.ccrui.cn/2020/07/11/e9fa4ba87fd41747fb6ffd1f675db0c.jpg%22/">https://img-cdn.ccrui.cn/2020/07/11/e9fa4ba87fd41747fb6ffd1f675db0c.jpg"/</a>]</p>]]></description><guid isPermaLink="false">/archives/182.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 6 Aug 2020 13:33:00 GMT</pubDate></item><item><title><![CDATA[pixiv插画下载器]]></title><link>https://blog.ccrui.cn/archives/172.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=pixiv%E6%8F%92%E7%94%BB%E4%B8%8B%E8%BD%BD%E5%99%A8&amp;url=/archives/172.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="pixiv插画下载器">pixiv插画下载器</h1>
<p>[collapse status="false" title="目录"]</p>
<ul>
 <li><a href="https://blog.ccrui.cn#%E5%BC%95%E8%A8%80">引言</a></li>
 <li><a href="https://blog.ccrui.cn#%E4%B8%8B%E8%BD%BD">下载</a></li>
 <li><a href="https://blog.ccrui.cn#%E5%87%86%E5%A4%87">准备</a>
  <ul>
   <li><a href="https://blog.ccrui.cn#windows">Windows</a></li>
   <li><a href="https://blog.ccrui.cn#linux">Linux</a></li>
  </ul></li>
 <li><a href="https://blog.ccrui.cn#%E5%AE%89%E8%A3%85%E6%9B%B4%E6%96%B0%E5%8D%B8%E8%BD%BD">安装/更新/卸载</a></li>
 <li><a href="https://blog.ccrui.cn#%E9%85%8D%E7%BD%AE">配置</a>
  <ul>
   <li><a href="https://blog.ccrui.cn#%E7%99%BB%E5%BD%95">登录</a></li>
   <li><a href="https://blog.ccrui.cn#%E8%AE%BE%E7%BD%AE">设置</a></li>
  </ul></li>
 <li><a href="https://blog.ccrui.cn#%E4%BD%BF%E7%94%A8">使用</a>
  <ul>
   <li><a href="https://blog.ccrui.cn#1-%E4%B8%8B%E8%BD%BD%E6%88%96%E6%9B%B4%E6%96%B0%E6%9F%90%E7%94%BB%E5%B8%88%E7%9A%84%E6%89%80%E6%9C%89%E6%8F%92%E7%94%BB%E4%BD%9C%E5%93%81">(1) 下载或更新某画师的所有插画作品</a></li>
   <li><a href="https://blog.ccrui.cn#2-%E4%B8%8B%E8%BD%BD%E6%88%96%E6%9B%B4%E6%96%B0%E4%BD%A0%E5%85%B3%E6%B3%A8%E7%9A%84%E6%89%80%E6%9C%89%E7%94%BB%E5%B8%88%E7%9A%84%E6%89%80%E6%9C%89%E6%8F%92%E7%94%BB%E4%BD%9C%E5%93%81">(2) 下载或更新你关注的所有画师的所有插画作品</a>
    <ul>
     <li><a href="https://blog.ccrui.cn#%E5%85%AC%E5%BC%80%E5%85%B3%E6%B3%A8%E7%9A%84%E7%94%BB%E5%B8%88">公开关注的画师</a></li>
     <li><a href="https://blog.ccrui.cn#%E7%A7%81%E5%AF%86%E5%85%B3%E6%B3%A8%E7%9A%84%E7%94%BB%E5%B8%88">私密关注的画师</a></li>
    </ul></li>
   <li><a href="https://blog.ccrui.cn#3-%E6%9B%B4%E6%96%B0%E5%B7%B2%E4%B8%8B%E8%BD%BD%E7%9A%84%E7%94%BB%E5%B8%88%E7%9A%84%E7%94%BB%E4%BD%9C">(3) 更新已下载的画师的画作</a></li>
   <li><a href="https://blog.ccrui.cn#4-%E4%B8%8B%E8%BD%BD%E6%88%96%E6%9B%B4%E6%96%B0%E4%BD%A0%E7%9A%84%E6%94%B6%E8%97%8F%E4%B8%AD%E7%9A%84%E6%8F%92%E7%94%BB%E4%BD%9C%E5%93%81">(4) 下载或更新你的收藏中的插画作品</a>
    <ul>
     <li><a href="https://blog.ccrui.cn#%E5%85%AC%E5%BC%80%E6%94%B6%E8%97%8F">公开收藏</a></li>
     <li><a href="https://blog.ccrui.cn#%E7%A7%81%E5%AF%86%E6%94%B6%E8%97%8F">私密收藏</a></li>
    </ul></li>
   <li><a href="https://blog.ccrui.cn#5-%E6%A0%B9%E6%8D%AE%E6%8C%87%E5%AE%9A-pid-%E4%B8%8B%E8%BD%BD%E6%8F%92%E7%94%BB">(5) 根据指定 PID 下载插画</a></li>
  </ul></li>
</ul>
<p>[/collapse]</p>
<h2 id="引言">引言</h2>
<p>今天在给我图床壁纸相册找图片的时候，想从p站上下载喜欢画手的图片来上传到个人图床。<br>
  但是p站的图片直链因为一些 
 <del>众所周知</del> 的原因无法直接被我部署在阿里云服务器的图床服务解析上传，于是我想到了找批量下载工具，在本地下载好再手动上传图床。<br>
  于是我找到了<code>pixiv downloader</code>，可以在 <code>Linux</code> 和 <code>windows</code> 平台上批量下载<code>pixiv</code>的图片</p>
<h2 id="项目地址">项目地址</h2>
<p><a href="https://github.com/Tsuk1ko/pxder">https://github.com/Tsuk1ko/pxder</a></p>
<h2 id="下载">下载</h2>
<p>pixiv downloader 可以根据指定画师 UID 解析并下载插画（包括动图）、一键下载所有你关注的画师的插画或收藏的插画、智能增量更新下载过的画师的插画。</p>
<p>并且支持使用多线程下载，与 <code>HTTP</code> <code>SOCKS</code> 代理下载。</p>
<h2 id="准备">准备</h2>
<p>使用软件第一步，需要在电脑或服务器上安装<code>Node.js</code></p>
<p>[tabs]<br>
  [tab name="Windows" active="true"]</p>
<h3 id="windows">Windows</h3>
<p>打开<a href="https://nodejs.org/en/">官网</a> =&gt; 下载左边的 LTS 版本 =&gt; 安装一路确定</p>
<p>[/tab]<br>
  [tab name="Linux"]</p>
<h3 id="linux">Linux</h3>
<pre><code class="language-Linux"># Ubuntu
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

# Debian
curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs

# Centos
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
yum install nodejs -y
</code></pre>
<p>[/tab]<br>
  [/tabs]</p>
<h2 id="安装更新卸载">安装/更新/卸载</h2>
<p>在 <code>Windows</code> 下打开<code>命令提示符</code>或者<code>Powershell</code>，执行下面的命令，即可安装或者更新（注：后续命令皆为在此执行）</p>
<pre><code class="language-cmd">npm i -g pxder
</code></pre>
<p>如需卸载，执行</p>
<pre><code class="language-cmd">npm uninstall -g pxder
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F03%2FWindowsTerminal_Y3YuRP0usw.png&amp;size=m" alt="安装"></p>
<h2 id="配置">配置</h2>
<h3 id="登录">登录</h3>
<p>!&gt; 注意：若本机无法直连pixiv服务器，会出现登录失败的报错，若出现报错请参考下文<code>设置</code>-<code>使用代理</code></p>
<pre><code class="language-cmd">pxder --login
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F03%2FWindowsTerminal_LkfXXVMyUY.png&amp;size=m" alt="登录"></p>
<p>然后会让你输入用户名密码，登录成功一次后以后如果没有出什么bug则无需再次登录</p>
<p>注：pxder 仅会在计算机上储存 refreshAccessToken，而不会储存您的帐号密码</p>
<p>如果要登出</p>
<pre><code class="language-cmd">pxder --logout
</code></pre>
<h3 id="设置">设置</h3>
<p>进入 Pxder 的设置界面</p>
<pre><code class="language-cmd">pxder --setting
</code></pre>
<p>有六项设置，按下数字键选择一项进行设置</p>
<pre><code class="language-cmd">[1] Download path           # 下载目录，必须设置
[2] Download thread         # 下载线程数
[3] Download timeout        # 下载超时
[4] Auto rename             # 自动重命名（文件夹）
[5] Proxy                   # 使用代理
[6] Direct mode             # 直连模式
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F03%2FWindowsTerminal_xJaZmEOs3e.png&amp;size=m" alt="设置"></p>
<ul>
 <li>
  <p>下载目录<br>
    请注意相对路径与绝对路径的区别，不过不用担心，输入完路径后会显示绝对路径以方便你检查<br>
    目录无需手动建立，下载图片的时候会自动建立<br>
    !&gt; 输入路径中切勿输入中文！！！ 否则会导致路径错误！！！</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F03%2FWindowsTerminal_X3rf8lFoTG.png&amp;size=m" alt="路径错误"><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F03%2Fexplorer_ZaNkpJ1dtQ.png&amp;size=m" alt="路径错误"></p></li>
 <li>
  <p>下载线程数<br>
    即同时下载的图片数，默认为<code>5</code>，最小为<code>1</code>，最大为<code>32</code><br>
    下载图片时最左侧的一列实际上就是线程编号</p></li>
 <li>
  <p>下载超时及重试<br>
    如果这么多秒之后一张图还没被下载完则算作超时，超时后会自动重试，默认值为<code>30</code><br>
    下载图片时如果线程编号是黄色底的就代表此次是重试<br>
    重试超过<code>10</code>次则视作下载失败</p></li>
 <li>
  <p>自动重命名<br>
    开启了以后，例如这个画师原来叫<code>abc</code>，今天你再次去下载（更新）他的画作，但是他改名叫<code>def</code>了，那么程序会自动帮你重命名画师文件夹</p></li>
 <li>
  <p>使用代理<br>
    支持使用 HTTP 或 SOCKS 代理，即可以使用小飞机<br>
    输入格式为<code>&lt;协议&gt;://[用户名:密码@]&lt;IP&gt;:&lt;端口&gt;</code>，例如：</p>
  <ul>
   <li><code>http://user:passwd@127.0.0.1:1080</code></li>
   <li><code>socks://127.0.0.1:1080</code>（如果你使用小飞机则直接填这个，除非你改过本地端口）</li>
  </ul></li>
 <li>
  <p>直连模式<br>
    利用域前置（Domain Fronting）绕过 SNI 审查，达到直连使用的目的<br>
    启用后，将会忽略代理设置</p></li>
</ul>
<h2 id="使用">使用</h2>
<h3 id="1-下载或更新某画师的所有插画作品">(1) 下载或更新某画师的所有插画作品</h3>
<p>使用<code>-u</code>或<code>--uid</code>参数，后跟画师的 UID，可单个可多个，如果多个则用英文半角逗号隔开</p>
<pre><code class="language-cmd">pxder -u uid1,uid2,uid3,...
</code></pre>
<p>例如</p>
<pre><code class="language-cmd">pxder -u 5899479,724607,11597411
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F03%2FWindowsTerminal_mkyQpA8uO4.png&amp;size=m" alt="下载或更新某画师的所有插画作品"></p>
<h3 id="2-下载或更新你关注的所有画师的所有插画作品">(2) 下载或更新你关注的所有画师的所有插画作品</h3>
<p>该操作同时也会更新已下载的关注画师的作品，并且效率远高于 (3)，比较推荐使用</p>
<p>会自动排除 pixiv事務局 (uid=<code>11</code>)</p>
<p>由于收集关注信息需时较久，因此特地针对该功能做了信息缓存：如果你在下载中途退出，那么下次使用该功能时并不需要重新收集，而是利用上次的缓存立即继续下载。</p>
<ul>
 <li>公开关注与私密关注的缓存是分开的，互不干扰</li>
 <li>如果你需要强制重新收集画师信息（忽略上次的缓存），请在运行命令时加入<code>--force</code>参数</li>
</ul>
<h4 id="公开关注的画师">公开关注的画师</h4>
<pre><code class="language-cmd">pxder -f
# 或
pxder --follow
</code></pre>
<h4 id="私密关注的画师">私密关注的画师</h4>
<pre><code class="language-cmd">pxder -F
# 或
pxder --follow--private
</code></pre>
<h3 id="3-更新已下载的画师的画作">(3) 更新已下载的画师的画作</h3>
<p>会对下载目录中检测到的所有下载过的画师的插画进行增量更新下载</p>
<p>与 (2) 的区别是可以更新你使用 (1) 下载了的但是未关注的画师的插画，但是效率远低于 (2)</p>
<pre><code class="language-cmd">pxder -U
# 或
pxder --update
</code></pre>
<h3 id="4-下载或更新你的收藏中的插画作品">(4) 下载或更新你的收藏中的插画作品</h3>
<h4 id="公开收藏">公开收藏</h4>
<p>插画会被下载至<code>[bookmark] Public</code>文件夹中</p>
<pre><code class="language-cmd">pxder -b
# 或
pxder --bookmark
</code></pre>
<h4 id="私密收藏">私密收藏</h4>
<p>插画会被下载至<code>[bookmark] Private</code>文件夹中</p>
<pre><code class="language-cmd">pxder -B
# 或
pxder --bookmark--private
</code></pre>
<h3 id="5-根据指定-pid-下载插画">(5) 根据指定 PID 下载插画</h3>
<p>插画会被下载至<code>PID</code>文件夹中</p>
<pre><code class="language-cmd">pxder -p pid1,pid2,pid3,...
</code></pre>
<p>例如</p>
<pre><code class="language-cmd">pxder -p 70593670,70594912,70595516
</code></pre>]]></description><guid isPermaLink="false">/archives/172.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 3 Aug 2020 06:06:00 GMT</pubDate></item><item><title><![CDATA[记一个之前用c#写的贪吃蛇]]></title><link>https://blog.ccrui.cn/archives/171.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E8%AE%B0%E4%B8%80%E4%B8%AA%E4%B9%8B%E5%89%8D%E7%94%A8c%23%E5%86%99%E7%9A%84%E8%B4%AA%E5%90%83%E8%9B%87&amp;url=/archives/171.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="记一个之前用c写的贪吃蛇">记一个之前用c#写的贪吃蛇</h1>
<ul>
 <li><a href="https://blog.ccrui.cn#%E5%89%8D%E8%A8%80">前言</a></li>
 <li><a href="https://blog.ccrui.cn#1-%E9%A1%B9%E7%9B%AE%E5%9F%BA%E6%9C%AC%E5%8A%9F%E8%83%BD">1. 项目基本功能</a></li>
 <li><a href="https://blog.ccrui.cn#2-%E9%99%84%E5%8A%A0%E5%8A%9F%E8%83%BD">2. 附加功能</a></li>
 <li><a href="https://blog.ccrui.cn#3-%E6%93%8D%E4%BD%9C%E6%96%B9%E5%BC%8F">3. 操作方式</a></li>
 <li><a href="https://blog.ccrui.cn#4-%E8%AE%BE%E8%AE%A1%E6%80%9D%E8%B7%AF">4. 设计思路</a></li>
 <li><a href="https://blog.ccrui.cn#5-%E6%80%9D%E7%BB%B4%E5%AF%BC%E5%9B%BE">5. 思维导图</a></li>
 <li><a href="https://blog.ccrui.cn#6-%E7%95%8C%E9%9D%A2%E8%AE%BE%E8%AE%A1">6. 界面设计</a></li>
</ul>
<h2 id="前言">前言</h2>
<p>这个贪吃蛇项目，是大一下学期<code>c#基础课</code>由我编写的期末大作业项目，使用了<code>Visual Studio2019</code>编写的桌面应用程序。<br>
  由于写这个程序的时候刚学习完c#的基础语法，水平比较低 
 <del>虽然现在也很低</del> 但是还是尽力的去完成了<code>贪吃蛇</code>小游戏的编写。</p>
<h2 id="1-项目基本功能">1. 项目基本功能</h2>
<ol>
 <li>贪吃蛇自动移动</li>
 <li>使用 WASD 和方向键控制移动</li>
 <li>食物的生成</li>
 <li>吃食物记分</li>
 <li>吃食物蛇变长</li>
 <li>碰到身体和墙壁死亡</li>
</ol>
<h2 id="2-附加功能">2. 附加功能</h2>
<ol>
 <li>游戏难度调节（改变移动速度 并改变分倍率）</li>
 <li>食物数量调节</li>
 <li>食物图标更改</li>
 <li>蛇身大小更改</li>
 <li>显示分数 当前难度 和当前难度下分数倍率</li>
 <li>历史记录（保存在"d:\Record.txt"）（若无 D 盘则保存在"c:\Record.txt"）</li>
 <li>窗口失去焦点自动暂停游戏</li>
 <li>对不同电脑 dpi 的调节</li>
 <li>添加背景音乐以及吃食物时的特效音乐</li>
 <li>音乐控制</li>
 <li>游戏存档读档功能</li>
 <li>清理游戏历史记录与存档保存所产生的文件</li>
 <li>更改鼠标样式</li>
</ol>
<h2 id="3-操作方式">3. 操作方式</h2>
<ol>
 <li>进入游戏后 按任意键即可开始游戏</li>
 <li>按方向键可以改变蛇移动的方向</li>
 <li>按空格键可以使游戏暂停</li>
 <li>蛇头碰到蛇身或墙壁游戏结束</li>
 <li>游戏结束后按 R 或回车即可重新开始游戏</li>
 <li>点击难度可修改难度</li>
 <li>点击食物数量可更改食物数量</li>
 <li>点击食物图标可更改食物图标</li>
 <li>点击蛇身大小可更改蛇身大小</li>
 <li>点击历史记录 会弹出历史记录窗口</li>
 <li>在历史记录窗口中点击清除历史记录可清除历史记录</li>
 <li>点击音乐控制可控制音乐暂停</li>
 <li>点击游戏存档 可以存档与读档</li>
 <li>点击文件清理 可清理贪吃蛇应用创建的文件</li>
</ol>
<h2 id="4-设计思路">4. 设计思路</h2>
<ol>
 <li>在 pictureBox 控件中绘制背景</li>
 <li>定义并绘制蛇头初始坐标</li>
 <li>通过按键控制蛇头移动</li>
 <li>通过刷新背景完成删除绘制历史</li>
 <li>随机绘制食物</li>
 <li>判断是否吃到食物</li>
 <li>判断是否撞到自己</li>
 <li>判断是否撞墙</li>
 <li>其余功能添加</li>
</ol>
<h2 id="5-思维导图">5. 思维导图</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F03%2F--.png&amp;size=m" alt="思维导图"></p>
<h2 id="6-界面设计">6. 界面设计</h2>
<ol>
 <li>主界面<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F03%2F9Rt2Usn6Z2.png&amp;size=m" alt="主界面"></li>
 <li>历史记录界面<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F03%2F7x6Zo9kiMp.png&amp;size=m" alt="历史记录界面"></li>
 <li>文件清理界面<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F03%2FX66x9382pZ.png&amp;size=m" alt="文件清理界面"></li>
</ol>]]></description><guid isPermaLink="false">/archives/171.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 3 Aug 2020 04:33:00 GMT</pubDate></item><item><title><![CDATA[神代綺凜式魔改主题插件使用教程]]></title><link>https://blog.ccrui.cn/archives/147.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E7%A5%9E%E4%BB%A3%E7%B6%BA%E5%87%9C%E5%BC%8F%E9%AD%94%E6%94%B9%E4%B8%BB%E9%A2%98%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B&amp;url=/archives/147.html" width="1" height="1" alt="" style="opacity:0;">
<p>#目录</p>
<ul>
 <li><a href="https://blog.ccrui.cn#%E5%89%8D%E8%A8%80">前言</a></li>
 <li><a href="https://blog.ccrui.cn#%E9%A3%9F%E7%94%A8%E6%96%B9%E5%BC%8F">食用方式</a>
  <ul>
   <li><a href="https://blog.ccrui.cn#%E4%B8%8B%E8%BD%BD%E6%8F%92%E4%BB%B6">下载插件</a></li>
   <li><a href="https://blog.ccrui.cn#%E4%BD%BF%E7%94%A8%E6%AD%A5%E9%AA%A4">使用步骤</a></li>
  </ul></li>
 <li><a href="https://blog.ccrui.cn#%E6%8F%92%E4%BB%B6%E8%AE%BE%E7%BD%AE">插件设置</a>
  <ul>
   <li><a href="https://blog.ccrui.cn#%E6%96%87%E7%AB%A0%E7%BD%AE%E9%A1%B6">文章置顶</a></li>
  </ul></li>
</ul>
<h2 id="前言">前言</h2>
<p>本来是想直接利用神代綺凜式魔改主题的<code>css</code>文件来对Handsome主题进行魔改的，但是奈何本人是一名彻头彻尾的编程小白，而作者<code>css</code>文件页面采用了301从定向，无法获取作者本人的<code>css</code>文件，所以在搜索时机缘巧合发现了一个由 <a href="https://blog.ccrui.cn/keymoe.com">Sanakey</a> 大佬编写的 <code>神代綺凜式魔改主题插件</code><br>
  本文就来说一说这个 
 <del>炒鸡适合不爱折腾的懒人</del> 适合不会编程的小白也可以轻松使用的魔改主题插件的具体用法</p>
<p>!&gt; 使用本插件时 需要在handsome外观设置中关闭盒子模型，首页头图建议选择大模式</p>
<h2 id="食用方式">食用方式</h2>
<h3 id="下载插件">下载插件</h3>
<p>通过<code>github</code>或者站内链接下载文件</p>
<p>[button color="black" icon="" url="<a href="https://github.com/Sanakey/KirinShiKi">https://github.com/Sanakey/KirinShiKi</a>" type=""]github下载链接[/button] [button color="info" icon="" url="<a href="https://bkcdn.chengrui.xyz/typecho/2020/08/02/KirinShiKi-master.zip">https://bkcdn.chengrui.xyz/typecho/2020/08/02/KirinShiKi-master.zip</a>" type=""]本地下载直链[/button]</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F02%2Fmsedge_nt8x5H63j2.png&amp;size=m" alt="github下载"></p>
<h3 id="使用步骤">使用步骤</h3>
<ul>
 <li>将下载好的压缩包上传到服务器插件目录：<code>/usr/plugins</code></li>
 <li>解压后重命名文件夹为 <code>KirinShiKi</code><br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F02%2Fmsedge_msxVO4uGIj.png&amp;size=m" alt="上传到服务器"></li>
 <li>登陆博客后台启用 <code>KirinShiKi</code>插件即可正常使用<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F02%2Fmsedge_KXbRLXZ3YU.png&amp;size=m" alt="博客后台"></li>
</ul>
<h2 id="插件设置">插件设置</h2>
<p>在插件中可以选择要显示的背景图，在其中添加需要显示的图片即可，若留空则为随机动漫背景图</p>
<p>在插件中集成了 <code>复制版权提醒功能</code> <code>版权样式美化</code> <code>标题卖萌</code> 等功能</p>
<p>!&gt; - 
 <del>本插件自带评论框打字特效代码，如果你之前有添加过类似代码，最好删除。</del><br>
  !&gt; - 在原主题基础上增加了彩色标签云代码，如果你之前有添加过类似代码，最好删除。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F02%2Fmsedge_bLT8xtX0yw.png&amp;size=m" alt="插件设置"></p>
<h3 id="文章置顶">文章置顶</h3>
<p>若需要文章置顶功能，请使用handsome官方插件，在<code>文章设置-&gt;置顶文章的 cid</code>对置顶文章进行设置<br>
  设置后在被置顶文章设置中选择小头图样式，即可达到以下样式</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F02%2Fmsedge_MXB3WfZFHU.png&amp;size=m" alt="文章置顶"></p>
<h2 id="美化效果">美化效果</h2>
<p>[post url="<a href="http://www.bk.chengrui.xyz">http://www.bk.chengrui.xyz</a>" title="辣鸡博客" intro="一个随意创建的辣鸡博客" cover="<a href="https://img-cdn.ccrui.cn/2020/07/11/e9fa4ba87fd41747fb6ffd1f675db0c.jpg%22/">https://img-cdn.ccrui.cn/2020/07/11/e9fa4ba87fd41747fb6ffd1f675db0c.jpg"/</a>]</p>
<hr>
<blockquote>
 <p>本插件制作者为 <a href="https://keymoe.com/archives/31/#%E5%89%8D%E8%A8%80">Sanakey</a> 大佬，欢迎大家对原作者进行赞赏投食~</p>
</blockquote>]]></description><guid isPermaLink="false">/archives/147.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 2 Aug 2020 02:42:00 GMT</pubDate></item><item><title><![CDATA[使用ShareX将图片上传到图床指定用户相册]]></title><link>https://blog.ccrui.cn/archives/138.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E4%BD%BF%E7%94%A8ShareX%E5%B0%86%E5%9B%BE%E7%89%87%E4%B8%8A%E4%BC%A0%E5%88%B0%E5%9B%BE%E5%BA%8A%E6%8C%87%E5%AE%9A%E7%94%A8%E6%88%B7%E7%9B%B8%E5%86%8C&amp;url=/archives/138.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="使用sharex将图片上传到图床指定用户相册">使用ShareX将图片上传到图床指定用户相册</h1>
<ul>
 <li><a href="https://blog.ccrui.cn#%E5%89%8D%E8%A8%80">前言</a></li>
 <li><a href="https://blog.ccrui.cn#sharex">ShareX</a>
  <ul>
   <li><a href="https://blog.ccrui.cn#sharex%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95">ShareX使用方法</a></li>
   <li><a href="https://blog.ccrui.cn#%E4%B8%8B%E8%BD%BD%E5%9C%B0%E5%9D%80">下载地址</a></li>
  </ul></li>
 <li><a href="https://blog.ccrui.cn#%E8%87%AA%E5%AE%9A%E4%B9%89chevereto%E4%B8%8A%E4%BC%A0%E7%94%A8%E6%88%B7%E5%92%8C%E4%B8%8A%E4%BC%A0%E7%9B%B8%E5%86%8C%E5%8F%AF%E9%80%89">自定义chevereto上传用户和上传相册（可选）</a>
  <ul>
   <li><a href="https://blog.ccrui.cn#%E5%85%B3%E4%BA%8E%E7%9B%B8%E5%86%8Cid">关于相册ID</a></li>
  </ul></li>
</ul>
<h2 id="前言">前言</h2>
<p>在使用<code>Markdown</code>写文档的用户来说，图片的引用是个很复杂的问题，如果将图片放到本地，使用正则表达式的方式调用，在很多博客场景会很不友好。更致命的是，很多博客不支持自解析本地图片上传，就会导致图片引用困难。</p>
<p>所以本文使用<code>ShareX</code>这个软件配合自我搭建的<code>chev­ereto</code>图床服务器进行图片托管以及截图快速上传，完成在<code>windows系统</code>上流畅的<code>Markdown</code>文档编辑。</p>
<h2 id="sharex">ShareX</h2>
<p>ShareX 是一款 Windows 下的截图与文件分享工具, 使用它您不仅可以作为<code>Chevereto</code>的客户端使用，同时您还可以作为<code>Dropbox</code>、<code>OneDrive</code>、<code>bit.ly</code>、<code>Twitter</code>等网站的一键上传分享工具使用。使用ShareX您可以轻松上传图片到<code>Chevereto</code>。</p>
<blockquote>
 <p>本站仅提供v13.1.0版本下载，最新版本请前往ShareX官网 <a href="https://getsharex.com/">Click</a> 下载。</p>
</blockquote>
<h3 id="sharex使用方法">ShareX使用方法</h3>
<p>下载并安装ShareX客户端</p>
<p>打开客户端，找到 目的地，目标设置。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F01%2FShareX_mDDgXHBpK8.png&amp;size=m" alt="客户端"></p>
<p>打开 目标设置 后，点击左边的<code>Chevereto</code>，根据图片所示按照需要上传图床地址添加。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F01%2FShareX_JaSZ5nqDvf.png&amp;size=m" alt="Chevereto"></p>
<p>同上，在图片上传方式中，勾选Chevereto为默认上传目标。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F01%2FShareX_Et21NVVrqi.png&amp;size=m" alt="上传目标"></p>
<p>更多的功能可以自己去发掘，关闭程序会自动最小化到右下角的消息栏，需在右下角退出才可以完全退出ShareX客户端。</p>
<h3 id="下载地址">下载地址</h3>
<p>[hide]<a href="https://www.yun.chengrui.xyz/#/s/xaFR">私人网盘下载</a> 密码：<code>ShareX</code><br><a href="https://bkcdn.chengrui.xyz/typecho/2020/08/01/ShareX-13.1.0-setup.zip">直链下载</a>[/hide]</p>
<h2 id="自定义chevereto上传用户和上传相册可选">自定义chevereto上传用户和上传相册（可选）</h2>
<p>chev­ereto 的 api 默认使用访客</p>
<p>打开 chev­ereto 的根目录，将默认的 <code>app/routes/route.api.php</code> 的文件复制到 <code>app/routes/overrides/route.api.php</code> 文件夹</p>
<p>把这段代码：</p>
<pre><code class="language-php">CHV\Image::uploadToWebsite($source);
</code></pre>
<p>改成这个：(将 juanito 更换成目标用户名或用户 id)</p>
<pre><code class="language-php">CHV\Image::uploadToWebsite($source, 'juanito', array('album_id'=&gt;4));
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F01%2Fmsedge_HPMRtuZWvV.png&amp;size=m" alt="自定义上传用户"></p>
<p>这里的juanito是要传的用户，'album_id'=&gt;4是对应的相册id，按需修改<br>
  然后保存即可。</p>
<h3 id="使用不同的api密匙">使用不同的API密匙</h3>
<p>如果你想在这个新的自定义API中使用不同的API密匙，只需将这个:</p>
<p>i&gt; !G\timing_safe_compare(CHV\getSetting('api_v1_key'), $_REQUEST['key'])</p>
<p>修改成</p>
<p>i&gt; !G\timing_safe_compare('NowThisIsAnotherAPIKEY!', $_REQUEST['key'])</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F02%2Fmsedge_3oduVDsP8i.png&amp;size=m" alt="不同的API密匙"></p>
<h3 id="关于相册id">关于相册ID</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F08%2F01%2FSnipaste_GVx5S6nRnx.png&amp;size=m" alt="相册ID"></p>
<hr>
<blockquote>
 <p><strong>参考文章：</strong><br><a href="https://imgchr.com/page/client">路过图床API</a><br><a href="https://ch.cndrew.cn/cn/API/API%20V1/">Chevereto-中文文档</a><br><a href="https://www.sukeycz.com/course/uPic-Chevereto-imageuploads">Mac uPic-Chevereto图床配置教程</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/138.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 1 Aug 2020 01:50:00 GMT</pubDate></item><item><title><![CDATA[chevereto调用百度API鉴黄]]></title><link>https://blog.ccrui.cn/archives/117.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=chevereto%E8%B0%83%E7%94%A8%E7%99%BE%E5%BA%A6API%E9%89%B4%E9%BB%84&amp;url=/archives/117.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="chevereto增加百度ai审核功能并开启图片鉴黄">Chevereto增加百度AI审核功能，并开启图片鉴黄</h1>
<p>众所周知，运营一个图床让人头疼的不仅仅是带宽配置，更让人忧心的是用户会不间断的上传违规图片，今天技术宅给大家带来的是<strong>Chevereto增加百度AI审核功能</strong>，并<strong>开启图片鉴黄</strong>，并且后台可以设置百度AI的相关参数，例如AppID,API Key,Secret Key</p>
<h2 id="添加应用">添加应用</h2>
<p>我们需要现在<a href="https://console.bce.baidu.com/ai/#/ai/antiporn/app/list%E6%B7%BB%E5%8A%A0%E5%BA%94%E7%94%A8%EF%BC%8C%E5%8F%AA%E9%9C%80%E8%A6%81%E6%B7%BB%E5%8A%A0%E5%BA%94%E7%94%A8%E5%90%8D%E7%A7%B0%EF%BC%8C%E4%BF%AE%E6%94%B9%E5%BA%94%E7%94%A8%E7%B1%BB%E5%9E%8B%E5%92%8C%E6%8F%8F%E8%BF%B0%E5%8D%B3%E5%8F%AF%EF%BC%8C%E5%85%B6%E4%BB%96%E9%BB%98%E8%AE%A4%EF%BC%81">https://console.bce.baidu.com/ai/#/ai/antiporn/app/list添加应用，只需要添加应用名称，修改应用类型和描述即可，其他默认！</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F29%2F2020050612481471.png&amp;size=m" alt="2020050612481471.png"></p>
<p>创建完成后会获得例如<code>AppID</code>,<code>API Key</code>,<code>Secret Key</code>我们后面会用到</p>
<h2 id="添加文件">添加文件</h2>
<p>我们需要前往**<a href="https://ai.baidu.com/sdk#anti**%E4%B8%8B%E8%BD%BDPHP%E7%89%88%E6%9C%AC%E7%9A%84SDK%E6%96%87%E4%BB%B6%EF%BC%8C%E9%9C%80%E8%A6%81%E7%94%A8%E5%88%B0">https://ai.baidu.com/sdk#anti**下载PHP版本的SDK文件，需要用到</a> 4 个文件，<code>class.aipbase.php</code> <code>class.aiphttpclient.php</code> <code>class.aiphttpUril.php</code> <code>class.imagecensor.php</code> , 这四个文件是百度官方提供的 SDK ，技术宅这里修改了一下。嫌麻烦的可以下载技术宅打包好的文件即可！注意需要将默认的SDK文件中的头部都修改为：<code>namespace CHV</code>;</p>
<p>将四个文件上传至 <code>Chevereto </code>程序下的 <code>app/lib/classes</code> 文件夹下。</p>
<h2 id="修改文件">修改文件</h2>
<p>修改路径为：<code>app/lib/classes</code>中的<code>class.upload.php</code>，搜索<code>public static function getDefaultOptions()</code>然后在此函数结束的下面添加以下内容：</p>
<pre><code class="language-php">/** 图像审核
* @throws UploadException
*/
protected function isValidCensor()
{
$censor_status = Settings::get("is_censor");
if($censor_status == 1){
$censor = new Imagecensor();
if ($this-&gt;type == 'file') {
$rep = $censor-&gt;imageCensorUserDefined(file_get_contents($this-&gt;source['tmp_name']));
} else if ($this-&gt;type == 'url') {
$rep = $censor-&gt;imageCensorUserDefined($this-&gt;source);
}
if (array_key_exists('error_code', $rep)) throw new UploadException("图片审核失败", 201);
$conclusionType = $rep['conclusionType'];//1：合规，2：不合规，3：疑似，4：审核失败
if ($conclusionType == 4) {
throw new UploadException("图片审核失败", 201);
} else if ($conclusionType &gt; 1) {
throw new UploadException("图片违规", 201);
}
}
}
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F29%2F2020050612591556.png&amp;size=m" alt="2020050612591556.png"></p>
<p>其中的函数isValidCensor 这个方法就是审核图像的，只有通过验证才会上传文件，没有通过的话会直接异常（包括图片审核失败，不合规，疑似）</p>
<p>然后在 <code>class.upload.php</code> 的 <code>exec</code> 方法里面添加 一行<code>$this-&gt;isValidCensor(); // Exception 2 图片审核</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F29%2F2020050613012219.png&amp;size=m" alt="2020050613012219.png"></p>
<p>最后我们需要修改<code>app/themes/Peafowl/views/dashboard.php</code>，搜索代码中的<code>Cookie law compliance</code>在上一行添加以下代码：</p>
<pre><code class="language-php">&lt;!-- 增加图片审核--&gt;
&lt;div class="input-label"&gt;
&lt;label for="enable_cookie_law"&gt;&lt;?php _se('是否开启图片审核'); ?&gt;&lt;/label&gt;
&lt;div class="c5 phablet-c1"&gt;&lt;select type="text" name="is_censor" id="is_censor" class="text-input"&gt;
&lt;?php
echo CHV\Render\get_select_options_html([1 =&gt; _s('Enabled'), 0 =&gt; _s('Disabled')], CHV\Settings::get('is_censor')); ?&gt;
&lt;/select&gt;&lt;/div&gt;
&lt;div class="input-below"&gt;&lt;?php _se('是否开启图片审核'); ?&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="input-label"&gt;
&lt;label for="sdk_pup_url"&gt;百度AI APP_ID&lt;/label&gt;
&lt;div class="c9 phablet-c1"&gt;&lt;input type="text" name="baidu_app_id" id="baidu_app_id" class="text-input" value="&lt;?php echo CHV\Settings::get('baidu_app_id', true); ?&gt;" placeholder="&lt;?php _se('Empty'); ?&gt;"&gt;&lt;/div&gt;
&lt;div class="input-below input-warning red-warning"&gt;&lt;?php echo get_input_errors()['baidu_app_id']; ?&gt;&lt;/div&gt;
&lt;div class="input-below"&gt;&lt;?php _se('百度AI 平台的 app_id，获取地址： https://console.bce.baidu.com/ai/'); ?&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="input-label"&gt;
&lt;label for="sdk_pup_url"&gt;百度AI APP_KEY&lt;/label&gt;
&lt;div class="c9 phablet-c1"&gt;&lt;input type="text" name="baidu_app_key" id="baidu_app_key" class="text-input" value="&lt;?php echo CHV\Settings::get('baidu_app_key', true); ?&gt;" placeholder="&lt;?php _se('Empty'); ?&gt;"&gt;&lt;/div&gt;
&lt;div class="input-below input-warning red-warning"&gt;&lt;?php echo get_input_errors()['baidu_app_key']; ?&gt;&lt;/div&gt;
&lt;div class="input-below"&gt;&lt;?php _se('百度AI 平台的 app_key，获取地址： https://console.bce.baidu.com/ai/'); ?&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="input-label"&gt;
&lt;label for="sdk_pup_url"&gt;百度AI APP_SECRET&lt;/label&gt;
&lt;div class="c9 phablet-c1"&gt;&lt;input type="text" name="baidu_app_secret" id="baidu_app_secret" class="text-input" value="&lt;?php echo CHV\Settings::get('baidu_app_secret', true); ?&gt;" placeholder="&lt;?php _se('Empty'); ?&gt;"&gt;&lt;/div&gt;
&lt;div class="input-below input-warning red-warning"&gt;&lt;?php echo get_input_errors()['baidu_app_secret']; ?&gt;&lt;/div&gt;
&lt;div class="input-below"&gt;&lt;?php _se('百度AI 平台的 app_secret，获取地址： https://console.bce.baidu.com/ai/'); ?&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F29%2F2020050613044456.png&amp;size=m" alt="2020050613044456.png"></p>
<h2 id="插入数据库">插入数据库</h2>
<p>完成以上操作后，我们需要插入数据库注意其中的表名<code>chevereto</code>和数据库前缀<code>chv_</code>需要修改成和自己一致的：</p>
<pre><code class="language-SQL">INSERT INTO `chevereto`.`chv_settings`( `setting_name`, `setting_value`, `setting_default`, `setting_typeset`) VALUES ('is_censor', '0','0', 'bool');
INSERT INTO `chevereto`.`chv_settings`( `setting_name`, `setting_value`, `setting_default`, `setting_typeset`) VALUES ( 'baidu_app_id', '', '', 'string');
INSERT INTO `chevereto`.`chv_settings`( `setting_name`, `setting_value`, `setting_default`, `setting_typeset`) VALUES ( 'baidu_app_key', '', '', 'string');
INSERT INTO `chevereto`.`chv_settings`(`setting_name`, `setting_value`, `setting_default`, `setting_typeset`) VALUES ('baidu_app_secret', '', '', 'string');
</code></pre>
<h2 id="效果展示">效果展示</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F29%2F2020050613075137.png&amp;size=m" alt="2020050613075137.png"></p>
<p>在后台设置完成参数后，我们再继续上传图片，这里用一张疑似违规图演示：</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F29%2F2020050613095497.png&amp;size=m" alt="2020050613095497.png"></p>
<p>成功拦截了上传，至于是否准确，技术宅这里要进行多次测试。不过用的百度AI鉴别，相信还是值得信赖的！</p>
<h2 id="文件打包">文件打包</h2>
<p>原文打包链接在部署时存在一定问题，现提供其他博主提供的打包文件</p>
<p>[scode type="yellow"][hide]<a href="https://bkcdn.chengrui.xyz/typecho/2020/07/29/Chevereto-%E5%BC%80%E5%90%AF%E9%89%B4%E9%BB%84%E5%8A%9F%E8%83%BD.zip">Chevereto-开启鉴黄功能.zip</a>[/hide][/scode]</p>
<p>按照图中显示路径，直接替换服务器资源后，在后台设置百度APIkey即可</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F29%2FSnipaste_2020-07-29_19-32-44.png&amp;size=m" alt="Snipaste_2020-07-29_19-32-44.png"></p>
<hr>
<blockquote>
 <p>本文转自 <a href="https://jszbug.com/17054">https://jszbug.com/17054</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/117.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 29 Jul 2020 11:34:00 GMT</pubDate></item><item><title><![CDATA[Typecho插件：AliOssForTypecho--使用AliyunOSS储存Typecho上传附件]]></title><link>https://blog.ccrui.cn/archives/107.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Typecho%E6%8F%92%E4%BB%B6%EF%BC%9AAliOssForTypecho--%E4%BD%BF%E7%94%A8AliyunOSS%E5%82%A8%E5%AD%98Typecho%E4%B8%8A%E4%BC%A0%E9%99%84%E4%BB%B6&amp;url=/archives/107.html" width="1" height="1" alt="" style="opacity:0;">
<p>2020年6月，本插件发布1.1.8版本。</p>
<h2 id="更新内容">更新内容</h2>
<p>此版本修复了以前版本的一些BUG，做了一些改善，主要有：</p>
<ol>
 <li>使用aliyun-oss-php-sdk Release 2.3.1开发；</li>
 <li>不再为每个文件创建单独的文件夹；</li>
 <li>检测已上传过的文件，若存在同名文件，则自动命名为 name(1).ext,name(2).ext...；</li>
 <li>优化了上传失败后的逻辑，详细记录失败日志，在插件配置页面即可看到；</li>
 <li>增加新功能，可自定义图片处理样式；</li>
</ol>
<p>祝使用愉快～</p>
<h2 id="插件信息">插件信息</h2>
<p>插件名：AliOssForTypecho<br>
  作者：droomo<br>
  当前版本：v1.1.8<br>
  更新时间：2020-06-27</p>
<blockquote>
 <p><a href="https://github.com/droomo/AliOssForTypecho/archive/v1.1.8.zip">Github下载地址</a><br><a href="https://pan.baidu.com/s/1JeyjeFLLEYd2G4pRcL_O7w">百度网盘</a> 提取码：bum0<br><a href="https://github.com/droomo/AliOssForTypecho">Github地址</a><br><a href="https://bkcdn.chengrui.xyz/typecho/2020/07/29/AliOssForTypecho-1.1.8.zip">本地下载地址</a></p>
</blockquote>
<h2 id="使用方法">使用方法</h2>
<ol>
 <li>下载插件，若github地址打不开，可通过百度网盘下载；</li>
 <li>解压插件，将解压后的文件夹重命名为<code>AliOssForTypecho</code>；</li>
 <li>替换原来插件。</li>
</ol>
<h2 id="使用截图">使用截图</h2>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F29%2FE4BDBFE794A8E688AAE59BBE.png&amp;size=m" alt="E4BDBFE794A8E688AAE59BBE.png"></p>
<hr>
<p>另外针对评论中提议较多的做出一些解释：<br>
  Q: 为什么不根据文章id来归档？<br>
  A: 因为在上传附件时，插件并无法得到文章信息。根据日期归档是通常做法，与Wordpress保持一致。</p>
<h2 id="历史版本">历史版本</h2>
<p>插件使用说明：</p>
<ul>
 <li>
  <p>插件基于aliyun-oss-php-sdk Release 2.3.0开发， 若以后SDK开发包更新导致插件不可用，请到 我的博客 ^ - ^获取新版本插件， 如果我还用typecho还用阿里云就会更新。</p></li>
 <li>
  <p>请赋予 文件上传目录 以及 插件日志目录 写权限，否则可能导致上传失败。</p></li>
 <li>
  <p>若开启“在服务器保留备份”功能：<br>
    成功保存文件到OSS但没有成功保存到服务器的情况下插件不会报错， 这将导致当前文件在服务器上没有备份，但是会插件日志目录下生成错误日志"error.log"，请定期查阅并清理。</p></li>
 <li>
  <p>运行在云应用引擎上的站点“在服务器保留备份”选项无效。</p></li>
 <li>
  <p>旧版本Typecho存在无法上传大写扩展名文件的bug，请更新Typecho程序。</p></li>
</ul>
<p>配置详情：</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F29%2F625492358170419.jpg&amp;size=m" alt="625492358170419.jpg"></p>
<hr>
<blockquote>
 <p>本文转自 <a href="http://www.droomo.top/AliOssForTypecho.html">http://www.droomo.top/AliOssForTypecho.html</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/107.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 29 Jul 2020 05:05:00 GMT</pubDate></item><item><title><![CDATA[如何使Typecho博客快速被百度收录]]></title><link>https://blog.ccrui.cn/archives/101.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%A6%82%E4%BD%95%E4%BD%BFTypecho%E5%8D%9A%E5%AE%A2%E5%BF%AB%E9%80%9F%E8%A2%AB%E7%99%BE%E5%BA%A6%E6%94%B6%E5%BD%95&amp;url=/archives/101.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="目录">目录：</h2>
<ul>
 <li><a href="https://blog.ccrui.cn#1-%E5%BC%80%E5%90%AF%E5%8D%9A%E5%AE%A2%E4%BC%AA%E9%9D%99%E6%80%81">1. 开启博客伪静态</a>
  <ul>
   <li><a href="https://blog.ccrui.cn#11-%E5%AE%9D%E5%A1%94%E8%AE%BE%E7%BD%AE">1.1 宝塔设置：</a></li>
   <li><a href="https://blog.ccrui.cn#11-%E5%8D%9A%E5%AE%A2%E8%AE%BE%E7%BD%AE">1.1 博客设置：</a></li>
  </ul></li>
 <li><a href="https://blog.ccrui.cn#2-%E5%90%AF%E7%94%A8%E4%B8%A4%E4%B8%AA%E6%8F%92%E4%BB%B6">2. 启用两个插件</a>
  <ul>
   <li><a href="https://blog.ccrui.cn#21-%E6%8F%92%E4%BB%B6%E6%9C%AC%E5%9C%B0%E4%B8%8B%E8%BD%BD%E5%9C%B0%E5%9D%80">2.1 插件本地下载地址</a></li>
   <li><a href="https://blog.ccrui.cn#22-%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95">2.2 安装方法</a></li>
   <li><a href="https://blog.ccrui.cn#23-baidusubmit%E7%9A%84%E9%85%8D%E7%BD%AE%E6%96%B9%E6%B3%95">2.3 BaiduSubmit的配置方法</a></li>
  </ul></li>
 <li><a href="https://blog.ccrui.cn#3-%E6%8F%92%E4%BB%B6%E7%9A%84%E4%BD%BF%E7%94%A8">3. 插件的使用</a>
  <ul>
   <li><a href="https://blog.ccrui.cn#baidusubmit%E7%9A%84%E4%BD%BF%E7%94%A8">BaiduSubmit的使用:</a></li>
  </ul></li>
 <li><a href="https://blog.ccrui.cn#4-robotstxt-%E6%96%87%E4%BB%B6%E9%85%8D%E7%BD%AE">4. robots.txt 文件配置</a></li>
 <li><a href="https://blog.ccrui.cn#5-typecho%E6%96%87%E7%AB%A0%E9%A1%B5%E9%9D%A2%E6%B7%BB%E5%8A%A0%E7%99%BE%E5%BA%A6%E6%94%B6%E5%BD%95%E6%9F%A5%E8%AF%A2">5. Typecho文章页面添加百度收录查询</a></li>
 <li><a href="https://blog.ccrui.cn#6-%E6%9F%A5%E8%AF%A2%E6%95%B4%E7%AB%99%E6%98%AF%E5%90%A6%E8%A2%AB%E6%94%B6%E5%BD%95">6. 查询整站是否被收录</a></li>
</ul>
<h2 id="1-开启博客伪静态">1. 开启博客伪静态</h2>
<h3 id="11-宝塔设置">1.1 宝塔设置：</h3>
<p>宝塔可以一键设置typecho的伪静态配置文件，只需要在宝塔上设置网站然后选择typecho模版即可</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F28%2F4149337255.png&amp;size=m" alt="4149337255.png"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F28%2F518514852.png&amp;size=m" alt="518514852.png"></p>
<h3 id="11-博客设置">1.1 博客设置：</h3>
<p>打开博客后台，选择 <code>设置-永久链接</code></p>
<p>在<code>是否使用地址重写功能</code>点击<code>启用</code></p>
<p>如果它提示检测出错，强制启用即可</p>
<p>接下来你就可以尝试访问任意一篇文章，可以发现以前链接中的“index.php”已经不存在了</p>
<h2 id="2-启用两个插件">2. 启用两个插件</h2>
<p>这里需要用到两个插件：</p>
<pre><code class="language-text">BaiduSub­mit
Sitemap
</code></pre>
<h3 id="21-插件本地下载地址">2.1 插件本地下载地址</h3>
<p><a href="https://bkcdn.chengrui.xyz/typecho/2020/07/29/plugins.zip">plugins.zip</a></p>
<h3 id="22-安装方法">2.2 安装方法</h3>
<p>将压缩包里的两个文件夹放到typocho的<code>./usr/plugins</code>文件夹下，然后在后台启用他们</p>
<h3 id="23-baidusubmit的配置方法">2.3 BaiduSubmit的配置方法</h3>
<p>首先将站点在百度站长平台进行添加，并完成相应的所有权验证</p>
<p>点进对应网站的页面，选择链接引入</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F28%2F3288885550.png&amp;size=m" alt="3288885550.png"></p>
<p>下拉找到api链接</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F28%2F164052462.png&amp;size=m" alt="164052462.png"></p>
<p>复制下来，来到BaiduSubmit的插件设置页面，将链接复制进去：</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F28%2F1870174893.png&amp;size=m" alt="1870174893.png"></p>
<p>保存完毕后，至此插件配置完毕</p>
<h2 id="3-插件的使用">3. 插件的使用</h2>
<p>访问 <code>https://你的域名/sitemap.xml</code> 查看是否能够访问成功<br>
  如果不能访问成功，尝试访问 <code>https://你的域名/index.php/sitemap.xml</code>并检查插件和伪静态设置<br>
  来到 <a href="https://ziyuan.baidu.com/linksubmit/index">链接提交</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F28%2F3151313840.png&amp;size=m" alt="3151313840.png"></p>
<p>选择sitemap选项卡<br>
  然后输入 <code>https://你的域名/sitemap.xml</code> 或 <code>https://你的域名/index.php/sitemap.xml</code><br>
  点击提交</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F28%2F1935341080.png&amp;size=m" alt="1935341080.png"></p>
<p>稍等片刻即可在下面看到sitemap的状态了</p>
<h3 id="baidusubmit的使用">BaiduSubmit的使用:</h3>
<p>启用BaiduSubmit插件过后，你就可以在后台看到对应选项卡了</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F28%2F3183119496.png&amp;size=m" alt="3183119496.png"></p>
<p>点进去过后点击<code>发送分组URL</code>即可将链接提交给百度</p>
<h2 id="4-robotstxt-文件配置">4. robots.txt 文件配置</h2>
<p>在网站根目录新建一个文件 <code>robots.txt</code>，并在下面写入以下内容：</p>
<pre><code class="language-CODE">User-agent: *
 
Disallow: /admin/
 
Disallow: /install/
 
Allow: /
 
Sitemap: https://你的域名/sitemap.xml

</code></pre>
<p>至此，博客收录已经基本配置完毕，为了加速收录速度，你可以</p>
<blockquote>
 <p>使用百度CDN加速服务，这样百度会主动收录<br>
   让已经被百度收录的网站帮你加入一个友情链接，这样蜘蛛能够更快的爬取你的网页</p>
</blockquote>
<hr>
<blockquote>
 <p>以上文章转自 <a href="https://bobh.mkaliez.com/archives/38.html?replyTo=54">BobH's Blog</a></p>
</blockquote>
<hr>
<h2 id="5-typecho文章页面添加百度收录查询">5. Typecho文章页面添加百度收录查询</h2>
<p>在主题 functions.php 文件最下方新增</p>
<pre><code class="language-php">/**
* 提示文章百度是否收录
*
*/
function baidu_record() {
$url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

if(checkBaidu($url)==1)
{echo "百度已收录";
}
else
{echo "&lt;a style=\"color:red;\" rel=\"external nofollow\" title=\"点击提交收录！\" target=\"_blank\" 
href=\"http://zhanzhang.baidu.com/sitesubmit/index?sitename=$url\"&gt;百度未收录&lt;/a&gt;";}
}
function checkBaidu($url) {
$url = 'http://www.baidu.com/s?wd=' . urlencode($url);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$rs = curl_exec($curl);
curl_close($curl);
if (!strpos($rs, '没有找到')) { //没有找到说明已被百度收录
return 1;
} else {
return -1;
}
}
</code></pre>
<p>第二步：在主题post.php文件想显示的地方增加</p>
<pre><code class="language-php">&lt;!--百度收录--&gt;
&lt;li class="meta-categories"&gt;&lt;i class="glyphicon glyphicon-ok-circle" aria-hidden="true"&gt;&lt;/i&gt; 
&lt;span class="sr-only"&gt;&lt;?php _me("百度收录") ?&gt;：&lt;/span&gt; &lt;span class="meta-value"&gt;&lt;?php echo 
baidu_record() ?&gt;&lt;/span&gt;&lt;/li&gt;
</code></pre>
<blockquote>
 <p>注：适合 handsome 主题 * 其它主题自行调整兼容性</p>
</blockquote>
<h2 id="6-查询整站是否被收录">6. 查询整站是否被收录</h2>
<p><a href="http://www.ab173.com/zhanzhang/linkshoulu.php">http://www.ab173.com/zhanzhang/linkshoulu.php</a></p>
<hr>
<blockquote>
 <p>参考文章：<br><a href="https://bobh.mkaliez.com/">https://bobh.mkaliez.com/</a><br><a href="https://www.xxhat.xyz/life/108.html">https://www.xxhat.xyz/life/108.html</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/101.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 28 Jul 2020 15:15:00 GMT</pubDate></item><item><title><![CDATA[Windows10好软一条龙分享]]></title><link>https://blog.ccrui.cn/archives/91.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Windows10%E5%A5%BD%E8%BD%AF%E4%B8%80%E6%9D%A1%E9%BE%99%E5%88%86%E4%BA%AB&amp;url=/archives/91.html" width="1" height="1" alt="" style="opacity:0;">
<p><strong>这是一篇关于Win10干货分享的图文（涉及uwp，好软，实用网站，实用chrome插件）</strong></p>
<blockquote>
 <p>Warring：本图文可能长的离谱而且许多软件很难获得，所以在文前创建目录，建议直接按照目录来跳转阅读</p>
</blockquote>
<h2 id="目录"><strong>目录：</strong></h2>
<p>[TOC]</p>
<p>∮ 建议先收藏，需要时使用<br>
  ∮ 最后一条可能很关键，因为许多软件需要在github上下载</p>
<hr>
<h2 id="uwp">UWP</h2>
<h3 id="files-uwp---preview">Files UWP - Preview</h3>
<p>这是一个第三方的资源管理器，告别win10自带的资源管理器（又慢稳定性又低）</p>
<p>链接: <a href="https://www.microsoft.com/zh-cn/p/files-uwp-preview/9nghp3dx8hdx#activetab=pivot:overviewtab">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_44d09567_1719_00151920x1080.png.m.jpg&amp;size=m" alt="Files UWP - Preview"></p>
<h3 id="bilibili">BILIBILI</h3>
<p><strong>这里一共有三个版本的哔哩哔哩</strong></p>
<ol>
 <li>
  <p>哔哩哔哩动画<br>
    这个就是歌官方版本，能用就行</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_5cb13c95_1719_00171197x512.png.m.jpg&amp;size=m" alt="哔哩哔哩动画"></p></li>
 <li>
  <p>哔哩哔哩动画uwp（第三方）<br>
    这个来自逍遥橙子的第三方哔哩哔哩，支持4k播放（白嫖）自定义程度高，但是个人不喜欢它的操作逻辑</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_cc1205e1_1719_00191111x547.png.m.jpg&amp;size=m" alt="哔哩哔哩动画uwp（第三方）"></p></li>
 <li>
  <p>哔哩（已下架）<br>
    这个也是个第三方作者云之幻（酷安同名），个人钦定是三个里面最好用的，交互逻辑最舒适，同样有4k，但是由于b站律师函，该uwp已下架，但是万能的酷友留有安装包</p>
  <p><a href="https://www.lanzoux.com/b00zj39fc">蓝奏云链接</a> 解压密码mix2<br><a href="https://www.yun.chengrui.xyz/#/s/rZhw">私有云盘链接</a></p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_3b562ff1_1719_00211920x1080.png.m.jpg&amp;size=m" alt="哔哩（已下架）"></p></li>
</ol>
<h3 id="lyricease">LyricEase</h3>
<p>众所周知网易云下架了他的uwp，变成转制32位的软件引起公愤，那么LyricEase可以作为替代品，该uwp作者brandonw3612（酷安）</p>
<p>最近更新动态：<a href="https://www.coolapk.com/feed/20083069?shareKey=OThiYTdmYWY4NTAyNWYxYTczZTQ~&amp;shareUid=2167575&amp;shareFrom=com.coolapk.market_10.4">查看链接</a></p>
<p>下载方式：微软应用商店搜索下载即可</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_e5ef5198_1719_00231282x1002.png.m.jpg&amp;size=m" alt="LyricEase"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_a6debf9c_1719_00251012x882.png.m.jpg&amp;size=m" alt="LyricEase"></p>
<h3 id="酷安uwp未上架">酷安uwp（未上架）</h3>
<p>直接上链接吧，没啥好讲的<br><a href="https://gitee.com/thewingofthewind/Coolapk-UWP">酷安uwp（未上架）码云</a><br><a href="https://pan.baidu.com/share/init?surl=Wjy-CUfjm0sOHCKLwQEALQ">百度网盘下载</a> 密码LIIL<br><a href="https://www.yun.chengrui.xyz/#/s/5wCd">私人网盘下载(2.0.33.0)</a></p>
<h3 id="pixiv-uwp">pixiv uwp</h3>
<p>第三方Pixiv uwp，功能齐全（可直连）</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_97881eb5_1719_00271282x1001.png.m.jpg&amp;size=m" alt="pixiv uwp"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_94a909ab_1719_00291282x1002.jpeg.m.jpg&amp;size=m" alt="pixiv uwp"></p>
<h3 id="lenovo-vantage">Lenovo Vantage</h3>
<p>这个联想用户可以试试，驱动更新，系统升级还是能用的</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_78dff31e_1719_0031960x1080.png.m.jpg&amp;size=m" alt="Lenovo Vantage"></p>
<h3 id="qq">QQ</h3>
<p>能用，但是不支持传文件到安卓手机</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_10a4075a_1750_40351282x1002.png.m.jpg&amp;size=m" alt="QQ"></p>
<h3 id="eartrumpt">EarTrumpt</h3>
<p>直接展开分级调控音量，效率提升</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_87c2f7e7_1750_4037450x467.png.m.jpg&amp;size=m" alt="EarTrumpt"></p>
<h3 id="贴吧">贴吧</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_33ebd65f_1750_4041192x547.png.m.jpg&amp;size=m" alt="贴吧"></p>
<h3 id="起点uwp第三方小说党狂喜">起点uwp·第三方（小说党狂喜）</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_60249d04_1750_40421203x540.png.m.jpg&amp;size=m" alt="起点uwp·第三方（小说党狂喜）"></p>
<h3 id="it之家浏览资讯">IT之家（浏览资讯）</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_a6c56ea2_1750_40441252x513.png.m.jpg&amp;size=m" alt="IT之家（浏览资讯）"></p>
<h3 id="mottomottokawaii视频gpu即时渲染提升观感">MottoMottokawaii（视频Gpu即时渲染，提升观感）</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_503c3e90_1750_4046966x526.png.m.jpg&amp;size=m" alt="MottoMottokawaii（视频Gpu即时渲染，提升观感）"></p>
<h3 id="qq音乐网易云uwp倒下后不错的选择">QQ音乐（网易云uwp倒下后不错的选择）</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_b0f4b400_1750_40481282x1002.png.m.jpg&amp;size=m" alt="QQ音乐（网易云uwp倒下后不错的选择）"></p>
<h3 id="极光音乐优点同上">极光音乐（优点同上）</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_b763556c_1750_4051102x523.png.m.jpg&amp;size=m" alt="极光音乐（优点同上）"></p>
<h3 id="translucent任务栏美化透明磨砂毛玻璃总有一种你喜欢的">Translucent（任务栏美化）透明，磨砂，毛玻璃，总有一种你喜欢的</h3>
<h3 id="tile-genie磁贴美化">Tile Genie（磁贴美化）</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_dda112da_1750_40521166x867.png.m.jpg&amp;size=m" alt="Tile Genie（磁贴美化）"></p>
<blockquote>
 <p>Uwp绝对不止这些，本图文只介绍了一些，更多还请自行探索或看其他图文</p>
</blockquote>
<hr>
<h2 id="好软推荐">好软推荐</h2>
<p>下面是软件推荐，涉及win美化.效率提升等<br>
  先来说美化</p>
<h3 id="rainmeter">Rainmeter</h3>
<p>这可能是本人用过自定义程度最高（最难折腾）的美化工具但效果很好，相信很多酷友正在用这个，或者看到过周围有人使用</p>
<p>官网：<a href="https://www.rainmeter.net/">查看链接</a></p>
<p>rainmeter需要插件因此这里推荐几个搜罗资源的网站（帖子）</p>
<ol>
 <li>雨滴美化社区|Rainmeter ： <a href="https://bbs.rainmeter.cn/">查看链接</a></li>
 <li>rainmeter吧 ： .<a href="https://tieba.baidu.com/f?kw=rainmeter">查看链接</a></li>
 <li>酷安也有一些美化贴（自查）</li>
 <li>致美化rainmeter分区：<a href="https://zhutix.com/tag/rainmeter/">查看链接</a></li>
</ol>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_d4517d77_1764_61911910x975.png.m.jpg&amp;size=m" alt="Rainmeter"></p>
<h3 id="软媒桌面my-desk">软媒桌面（my desk）</h3>
<p>一款不错的dock栏，可自定义皮肤及图标</p>
<p>官网：<a href="https://mofang.ruanmei.com/screenshots.htm">查看链接</a></p>
<p>推荐去找独立的mydesk（百度即可）</p>
<h3 id="my-dockmy-finder仿mac-os">My dock/My finder（仿mac os）</h3>
<p>这个我在几个月前写过图文，这里不赘述</p>
<p>我的图文：<a href="https://www.coolapk.com/feed/17942231?shareKey=YzhjNDIwYzY5YjNmNWYxYTg1NDI~&amp;shareUid=2167575&amp;shareFrom=com.coolapk.market_10.4">查看链接</a></p>
<p>官网：<a href="https://www.mydockfinder.com/">查看链接</a> （只有易语言版）</p>
<p>最新c++版需要关注他的公众号：mydockfinder</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_4b5c89b6_0764_16051920x1080.jpeg.m.jpg&amp;size=m" alt="My dock/My finder（仿mac os）"></p>
<h3 id="bitdock仿mac-os">Bitdock（仿mac os）</h3>
<p>这是最近本人使用的美化工具，在酷安已经有很多图文推荐，这里不重复讲述，直接上图，自定义选项很多（仿mac os还不够极致）</p>
<p>这里说一些其他推荐的软件</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_ff57d293_0005_48461920x1080.jpeg.m.jpg&amp;size=m" alt="Bitdock（仿mac os）"></p>
<h3 id="idm">IDM</h3>
<p>这个应该是人均系列了，多线程下载，百度云屠杀者（需要其他插件，在下面的插件再介绍）</p>
<p>推荐下载地点（idm吧）：<a href="https://tieba.baidu.com/f?kw=idm&amp;fr=ala0&amp;tpl=5">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_cc265cfc_1764_61931920x1080.png.m.jpg&amp;size=m" alt="IDM"></p>
<h3 id="bandzip">Bandzip</h3>
<p>也是个人均系列了，新版有广告，推荐下载旧版<br>
  这里我个人收藏了一个网站可以去这里下载</p>
<p>链接：<a href="https://www.imydl.com/yingyong/12770.html">查看链接</a></p>
<h3 id="wifu2x">wifu2x</h3>
<p>很多人可能不知道这个，但大家一定知道在酷安有个app叫big jpg，他们都是用了神经网络运算,但这个是本地的<br>
  该软件对Gpu性能有一定要求，推荐显卡性能稍强的用户使用，集显还是算了<br>
  Github项目网址：<a href="https://github.com/AaronFeng753/Waifu2x-Extension-GUI/releases/v2.55.12">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_74122f96_1764_61951920x1080.png.m.jpg&amp;size=m" alt="wifu2x"></p>
<h3 id="火绒">火绒</h3>
<p>人均系列，不介绍了<br>
  链接：<a href="https://www.huorong.cn/">查看链接</a></p>
<h3 id="虫洞-虫洞正弈帷">虫洞 <a href="http://www.coolapk.com/apk/com.viper.wormhole">虫洞（正弈帷）</a></h3>
<p>一个好用的投屏软件，延迟极低，支持无线投屏和有线投屏</p>
<p>官网：<a href="https://er.run/">查看链接</a></p>
<blockquote>
 <p>下面是推荐的安卓模拟器（因为这个种类特殊就列出来）</p>
</blockquote>
<h3 id="mumu">Mumu</h3>
<p>又一个人均系列，不赘述了</p>
<p>链接：<a href="http://mumu.163.com/">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_77843f88_1764_61971890x945.png.m.jpg&amp;size=m" alt="Mumu"></p>
<h3 id="逍遥模拟器">逍遥模拟器</h3>
<p>这个模拟器性能很强超其他模拟器不少</p>
<p>链接：<a href="https://www.xyaz.cn/">查看链接</a></p>
<h3 id="蓝叠这个纯属个人情怀最早的模拟器">蓝叠（这个纯属个人情怀，最早的模拟器）</h3>
<p>这是第一个安卓模拟器，现在已经泯然众人了，放在这里纯粹情怀（不推荐下载）</p>
<p>链接：<a href="https://www.bluestacks.cn/">查看链接</a></p>
<p>以上是个人使用的一些好软，也许有用，欢迎再评论补充</p>
<hr>
<h2 id="插件推荐">插件推荐</h2>
<p>插件(edge/Chrome)</p>
<ul>
 <li>chrome插件很多，但是要tz才能去下载所以更推荐edge</li>
 <li>以下链接来自Microsoft商店和exfans（可以去这两个平台下载插件）</li>
</ul>
<h3 id="infinity-新标签页-pro">Infinity 新标签页 (Pro)</h3>
<p>这是个新建标签工具，既美观又实用，自定义选项很多，pro版暂时免费</p>
<p>链接：<a href="https://microsoftedge.microsoft.com/addons/detail/infinity-%E6%96%B0%E6%A0%87%E7%AD%BE%E9%A1%B5-pro/hajlmbnnniemimmaehcefkamdadpjlfa?hl=zh-CN">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_b1748823_1764_61981920x1080.jpeg.m.jpg&amp;size=m" alt="Infinity 新标签页 (Pro)"></p>
<h3 id="tampermonkey">Tampermonkey</h3>
<p>这个也是人均了，不过要折腾的地方有点多</p>
<p>先上下载地址(edge)：<a href="https://microsoftedge.microsoft.com/addons/detail/tampermonkey/iikmkjmpaadaobahmlepeloendndfphd?hl=zh-CN">查看链接</a></p>
<p>但一个油猴是远远不够的，你还需要脚本<br>
  这里推荐几个脚本下载网站</p>
<ol>
 <li>Greasy fork：<a href="https://greasyfork.org/zh-CN/scripts">查看链接</a></li>
 <li>TM中文站：<a href="https://www.tmchina.net/">查看链接</a></li>
 <li>Extfans（油猴脚本）：<a href="https://www.extfans.com/tampermonkey/">查看链接</a></li>
</ol>
<p>关于脚本的介绍就省略了，太多了，自行探索</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_9ee63004_1764_621920x966.png.m.jpg&amp;size=m" alt="Tampermonkey"></p>
<h3 id="ie-tab">IE Tab</h3>
<p>IE确实已经凉了，但需要它兼容性的网站还是有点比如4399什么的，这个就要用到这个了，高级版要19＄，普通版够用</p>
<p>链接：<a href="https://microsoftedge.microsoft.com/addons/detail/ie-tab/npjkkakdacjaihjaoeliacmecofghagh?hl=zh-CN">查看链接</a></p>
<h3 id="图片助手imageassistant-批量图片下载器">图片助手(ImageAssistant) 批量图片下载器</h3>
<p>分析选择然后批量下载的插件，我用pixiv时经常用这个<br>
  链接：<a href="https://microsoftedge.microsoft.com/addons/detail/%E5%9B%BE%E7%89%87%E5%8A%A9%E6%89%8Bimageassistant-%E6%89%B9%E9%87%8F%E5%9B%BE%E7%89%87/odphnbhiddhdpoccbialllejaajemdio?hl=zh-CN">查看链接</a></p>
<h3 id="百度药丸-baidu-capsule">百度药丸 Baidu Capsule</h3>
<p>看名字就知道是干啥的，专治百度广告<br>
  链接：<a href="https://www.extfans.com/search-tools/ngiclcoldiplnjcafhjkacjcmdidcmjp/">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_6ac2a99a_1764_62011227x227.png.m.jpg&amp;size=m" alt="百度药丸 Baidu Capsule"></p>
<h3 id="as资源云盘助手">as资源云盘助手</h3>
<p>看名字应该也知道干啥用的吧<br>
  链接：<a href="https://www.extfans.com/search-tools/mbklgpngoohbbagagdfoccaclpdhgihd">查看链接</a></p>
<blockquote>
 <p>那么以上就是能用的各种扩展和插件</p>
</blockquote>
<hr>
<h2 id="实用网站">实用网站</h2>
<p>这里是网站分享</p>
<h3 id="pixiv-c">PIXIV C</h3>
<p>这也是一个第三方pixiv，直连，手机端同名app<br>
  链接：<a href="https://m.pixivic.com/dailyRank?VNK=fc129dc3">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_69ebef2f_1775_63111917x976.jpeg.m.jpg&amp;size=m" alt="PIXIV C"></p>
<h3 id="big-jpg">Big jpg</h3>
<p>前面讲过这个原理和wifu2x一样但是如果你显卡性能不够，还是推荐用这个<br>
  链接：<a href="https://bigjpg.com/">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_1cf53a8b_1775_63131920x1030.png.m.jpg&amp;size=m" alt="Big jpg"></p>
<h3 id="阿里巴巴矢量图标库">阿里巴巴矢量图标库</h3>
<p>在这里你可以找到许多你想要的图标，下载需要GitHub账号登录（配合前面的美化工具使用会很舒服）</p>
<h3 id="removedbg">Removedbg</h3>
<p>一个抠图网站，也是我唯一找到的免费抠图网站（真想扣好图，还是要靠专业软件，但是证件照什么的足够了）</p>
<p>链接：<a href="https://www.iconfont.cn/">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_478f968e_1775_63151920x972.png.m.jpg&amp;size=m" alt="Removedbg"></p>
<h3 id="word转图片">word转图片</h3>
<p>快速解决word转图片（wps还要开会员）</p>
<p>链接：<a href="http://www.docpe.com/word/word-to-image.aspx">查看链接</a></p>
<h3 id="致美化">致美化</h3>
<p>Win10美化资源很全的社区</p>
<p>链接：<a href="https://zhutix.com/">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_ea39d067_1775_63171920x977.png.m.jpg&amp;size=m" alt="致美化"></p>
<h3 id="在线linux系统">在线Linux系统</h3>
<p>在你的浏览器上运行Linux，该网站支持了市面上基本所有的Linux</p>
<p>链接：<a href="https://distrotest.net/">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_d34d3785_1775_63191920x973.png.m.jpg&amp;size=m" alt="在线Linux系统"></p>
<h3 id="free-buff">Free Buff</h3>
<p>一个主要用户群体是黑客与极客的网站，内容主要是网络安全<br>
  链接：<a href="https://distrotest.net/">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_790b0f79_1775_63211920x975.png.m.jpg&amp;size=m" alt="Free Buff"></p>
<h3 id="异次元">异次元</h3>
<p>一个软件下载站，软件种类很多，遍布win macos Linux三个平台<br>
  也有pj软件</p>
<p>链接：<a href="https://www.iplaysoft.com/">查看链接</a></p>
<h3 id="pilipili">Pilipili</h3>
<p>单纯的视频网站，看名字也应该知道奔着啥来的吧</p>
<p>链接：<a href="http://pilipali.cc/">查看链接</a></p>
<h3 id="最美应用">最美应用</h3>
<p>长期推荐一些ui好看注重设计的app<br>
  链接：<a href="http://zuimeia.com/?utm_source=wwwd&amp;utm_campaign=referral&amp;utm_medium=wwwd">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_ea2b051e_1775_63241920x972.png.m.jpg&amp;size=m" alt="最美应用"></p>
<h3 id="gitmind">Gitmind</h3>
<p>在线思维导图制作</p>
<p>链接：<a href="https://gitmind.cn/app/login">查看链接</a></p>
<h3 id="站搜搜">站搜搜</h3>
<p>一个东西很多的导航网站</p>
<p>链接：<a href="https://www.zhansousou.com/">查看链接</a></p>
<h3 id="临时邮箱">临时邮箱</h3>
<p>10s刷新一次，可以接收一些东西</p>
<p>链接：<a href="https://www.linshiyouxiang.net/">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_b0b4210e_1775_63261920x976.png.m.jpg&amp;size=m" alt="临时邮箱"></p>
<h3 id="自由钢琴">自由钢琴</h3>
<p>在浏览器上弹钢琴</p>
<p>链接：<a href="https://www.linshiyouxiang.net/">查看链接</a></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F27%2F2167575_c7e88e39_1775_63281920x975.png.m.jpg&amp;size=m" alt="自由钢琴"></p>
<h3 id="一个工具箱">一个工具箱</h3>
<p>浏览器上的工具箱软件</p>
<p>链接：<a href="http://www.atoolbox.net/">查看链接</a></p>
<h3 id="biliob观测者">BiliOB观测者</h3>
<p>对哔哩哔哩up实时观测（？）</p>
<p>链接：<a href="https://www.biliob.com/">查看链接</a></p>
<h3 id="github代下载服务">GitHub代下载服务</h3>
<p>GitHub的下载速度实在一言难尽，所以有了它</p>
<p>链接：<a href="http://g.widora.cn/">查看链接</a></p>
<hr>
<p>本文转自：<a href="https://www.coolapk.com/feed/20428505?shareKey=ZWNlMWFmZDQwNzRjNWYxZTNhYTM~&amp;shareUid=479113&amp;shareFrom=com.coolapk.market_10.4">酷安-CloudCat云の喵</a></p>]]></description><guid isPermaLink="false">/archives/91.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Mon, 27 Jul 2020 03:26:00 GMT</pubDate></item><item><title><![CDATA[网页IDE搭建]]></title><link>https://blog.ccrui.cn/archives/88.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E7%BD%91%E9%A1%B5IDE%E6%90%AD%E5%BB%BA&amp;url=/archives/88.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="服务器搭建code-server">服务器搭建code-server</h1>
<p>记录一次服务器部署code-server详细过程。</p>
<h2 id="1code-server">1.code-server</h2>
<p>在远程服务器部署code-server，即可在浏览器上访问vscode，在浏览器中写代码。<br>
  附上项目地址：<a href="https://github.com/cdr/code-server">https://github.com/cdr/code-server</a></p>
<h2 id="2准备">2.准备</h2>
<p>我使用的的是一台阿里云的云服务器，系统是Centos7。</p>
<h2 id="3安装方式">3.安装方式</h2>
<p>安装方式有多种，docker部署，脚本一键安装,下载安装包安装。<br>
  我这边采用的是下载安装包安装。<br>
  安装包下载地址：<a href="https://github.com/cdr/code-server/releases">https://github.com/cdr/code-server/releases</a></p>
<p>若Github下载速度过慢可通过网盘链接下载 <a href="https://www.yun.chengrui.xyz/#/s/lJco">私人网盘</a></p>
<h2 id="4开始安装并启动">4.开始安装并启动</h2>
<p>可以用securefx将安装包上传<br>
  或者使用wget在服务器端下载:</p>
<pre><code class="language-Linux">wget https://github.com/cdr/code-server/releases/download/3.4.1/code-server-3.4.1-linux-x86_64.tar.gz
</code></pre>
<p>我这边直接下载完上传到服务器并解压。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F23%2F20200629144627567.png&amp;size=m" alt="截图"></p>
<p>命令：</p>
<pre><code class="language-Linux">tar -xzf code-server-3.4.1-linux-x86_64.tar.gz
cd code-server-3.4.1-linux-x86_64/
export PASSWORD="123456" &amp;&amp; ./code-server --port 8080 --host 0.0.0.0 
</code></pre>
<p>命令注释：</p>
<p><code>tar -xzf code-server-3.4.1-linux-x86_64.tar.gz</code> //解压命令</p>
<p><code>cd code-server-3.4.1-linux-x86_64/</code> //进入到解压完成的文件夹下</p>
<p><code>export PASSWORD=“123456” &amp;&amp; ./code-server --port 8080 --host 0.0.0.0 //export PASSWORD="123456"</code>定义一个密码，双引号内的123456是你自己定义的密码，我这里123456只是一个示例。/code-server --port 8080 启动并指定8080端口运行，其实默认就是8080端口，这个端口可以修改，不过不管是8080端口还是别的端口运行，都要先开放防火墙，比如我使用的阿里云服务器就是在安全组中开放端口。 --host 0.0.0.0 默认启动是本地访问，我们服务器需要开启外网访问。</p>
<p>输入启动命令</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F23%2F20200629150218313.png&amp;size=m" alt="截图"></p>
<p>进入浏览器，输入服务器公网ip，加上刚才我们指定的端口号进入,显示欢迎界面输入密码进入，如果不想使用密码，在启动命令中加 --auth none即可无需密码进入。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F23%2F20200629150441170.png&amp;size=m" alt="截图"></p>
<p>成功进入界面。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F23%2F20200629150859804.png&amp;size=m" alt="进入界面"></p>
<hr>
<h2 id="以上转载自-csdn">以上转载自 <a href="https://blog.csdn.net/Xiudadasnb/article/details/107019039">CSDN</a></h2>
<h2 id="后台运行">后台运行</h2>
<p>直接运行的话，终端断掉项目就终止运行了，以下是一种后台运行方式：使用screen后台运行，如果你了解其他后台运行方式，也可以自己设置</p>
<pre><code class="language-Linux">screen -S vscode # vscode为自己取的名字
export PASSWORD="yourpassword" &amp;&amp; ./code-server --port 703 --host 0.0.0.0
</code></pre>
<h2 id="反向代理">反向代理</h2>
<p>先在宝塔面板中新建网站并且添加SSL证书，然后设置反向代理</p>
<p>这是官方推荐的 Nginx 反向代理配置模板：</p>
<pre><code class="language-Nginx">server {
  listen 80;
  listen [::]:80;
  server_name code.example.com code.example.org;
  location /some/path/ { # Or / if hosting at the root.
      proxy_pass http://localhost:8080/;
      proxy_set_header Host $host;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection upgrade;
      proxy_set_header Accept-Encoding gzip;
  }
}
</code></pre>
<p>设置完成后，我们就可以直接使用域名来访问 code-server 了，而且也没有证书不安全的提示，完美解决了上述问题。</p>
<p>这样我们就可以愉快地在浏览器上使用 VsCode 了，使用浏览器第一次登录后，需要等待一段时间，再次使用基本都是秒开的，这一点非常不错，赶紧去体验一番了。</p>
<blockquote>
 <p>参考文章：<br><a href="https://www.zhyong.cn/posts/959b/">https://www.zhyong.cn/posts/959b/</a><br><a href="https://blog.csdn.net/sinat_36008080/article/details/89604382">https://blog.csdn.net/sinat_36008080/article/details/89604382</a><br><a href="https://segmentfault.com/a/1190000022267386/">https://segmentfault.com/a/1190000022267386/</a><br><a href="https://blog.csdn.net/Xiudadasnb/article/details/107019039">https://blog.csdn.net/Xiudadasnb/article/details/107019039</a><br><a href="https://www.runoob.com/linux/linux-comm-screen.html">https://www.runoob.com/linux/linux-comm-screen.html</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/88.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Thu, 23 Jul 2020 05:40:00 GMT</pubDate></item><item><title><![CDATA[Cloudreve 安装使用教程]]></title><link>https://blog.ccrui.cn/archives/87.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Cloudreve%20%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B&amp;url=/archives/87.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="快速开始">快速开始</h1>
<h2 id="获取cloudreve">获取Cloudreve</h2>
<p>你可以在 <a href="https://github.com/cloudreve/Cloudreve/releases">GitHub Release</a> 页面获取已经构建打包完成的主程序。其中每个版本都提供了常见系统架构下可用的主程序，命名规则为 <code>cloudreve_版本号_操作系统_CPU架构.tar.gz</code> 。比如，普通64位Linux系统上部署3.0.0版本，则应该下载 <code>cloudreve_3.0.0_linux_amd64.tar.gz</code>。</p>
<p>如果你想体验最新的功能特性，可以在 <a href="https://github.com/cloudreve/Cloudreve/actions">GitHub Actions</a> 中下载每次 commit 后构建的开发版。注意，开发版并不稳定，无法用于生产用途，且不保证完全可用。</p>
<p>如果想要自行从源代码构建，请参阅以下章节：</p>
<blockquote>
 <p><strong><a href="https://docs.cloudreve.org/getting-started/build">构建</a></strong></p>
</blockquote>
<h2 id="启动-cloudreve">启动 Cloudreve</h2>
<h3 id="linux">Linux</h3>
<p>Linux下，直接解压并执行主程序即可：</p>
<pre><code class="language-Linux">#解压获取到的主程序
tar -zxvf cloudreve_VERSION_OS_ARCH.tar.gz

# 赋予执行权限
chmod +x ./cloudreve

# 启动 Cloudreve
./cloudreve
</code></pre>
<h3 id="windows">Windows</h3>
<p>Windows下，直接解压获取到的 zip 压缩包，启动 <code>cloudreve.exe</code> 即可。</p>
<hr>
<p>Cloudreve 在首次启动时，会创建初始管理员账号，请注意保管管理员密码，此密码只会在首次启动时出现。如果您忘记初始管理员密码，需要删除同级目录下的 <code>cloudreve.db</code>，重新启动主程序以初始化新的管理员账户。</p>
<p>Cloudreve 默认会监听 <code>5212</code> 端口。你可以在浏览器中访问 <code>http://服务器IP:5212</code>进入 Cloudreve。</p>
<p>以上步骤操作完后，最简单的部署就完成了。你可能需要一些更为具体的配置，才能让Cloudreve更好的工作，具体流程请参考下面的配置流程。</p>
<hr>
<h2 id="可选部署流程">可选部署流程</h2>
<h3 id="反向代理">反向代理</h3>
<p>在自用或者小规模使用的场景下，你完全可以使用 Cloudreve 内置的 Web 服务器。但是如果你需要使用HTTPS，亦或是需要与服务器上其他 Web 服务共存时，你可能需要使用主流 Web 服务器反向代理 Cloudreve ，以获得更丰富的扩展功能。</p>
<p>你需要在Web服务器中新建一个虚拟主机，完成所需的各项配置（如启用HTTPS），然后在网站配置文件中加入反代规则：</p>
<h4 id="nginx">NGINX</h4>
<p>在网站的 <code>server</code> 字段中加入：</p>
<pre><code class="language-NGINX">location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://127.0.0.1:5212;
    
    # 如果您要使用本地存储策略，请将下一行注释符删除，并更改大小为理论最大文件尺寸
    # client_max_body_size 20000m;
}
</code></pre>
<h4 id="apache">Apache</h4>
<p>在 <code>VirtualHost</code> 字段下加入反代配置项 <code>ProxyPass</code> ，比如：</p>
<pre><code class="language-Apache">&lt;VirtualHost *:80&gt;
    ServerName myapp.example.com
    ServerAdmin webmaster@example.com
    DocumentRoot /www/myapp/public
    
    # 以下为关键部分
    AllowEncodedSlashes NoDecod
    ProxyPass "/" "http://127.0.0.1:5212/" nocanon
    
&lt;/VirtualHost&gt;
</code></pre>
<h3 id="进程守护">进程守护</h3>
<p>以下两种方式可任选其一。</p>
<h4 id="systemd">Systemd</h4>
<pre><code class="language-Systemd"># 编辑配置文件
vim /usr/lib/systemd/system/cloudreve.service
</code></pre>
<p>将下文 <code>PATH_TO_CLOUDREVE</code> 更换为程序所在目录：</p>
<pre><code class="language-Systemd">[Unit]
Description=Cloudreve
Documentation=https://docs.cloudreve.org
After=network.target
Wants=network.target

[Service]
WorkingDirectory=/PATH_TO_CLOUDREVE
ExecStart=/PATH_TO_CLOUDREVE/cloudreve
Restart=on-abnormal
RestartSec=5s
KillMode=mixed

StandardOutput=null
StandardError=syslog

[Install]
WantedBy=multi-user.target
</code></pre>
<pre><code class="language-Systemd"># 更新配置
systemctl daemon-reload

# 启动服务
systemctl start cloudreve

# 设置开机启动
systemctl enable cloudreve
</code></pre>
<p>管理命令：</p>
<pre><code class="language-Systemd"># 启动服务
systemctl start cloudreve

# 停止服务
systemctl stop cloudreve

# 重启服务
systemctl restart cloudreve

# 查看状态
systemctl status cloudreve
</code></pre>
<h4 id="supervisor">Supervisor</h4>
<p>首先安装 <code>supervisor</code> ，已安装的可以跳过。</p>
<pre><code class="language-Supervisor"># 安装 supervisor
sudo yum install python-setuptools
sudo easy_install supervisor

# 初始化全局配置文件
sudo touch /etc/supervisord.conf
sudo echo_supervisord_conf &gt; /etc/supervisord.conf
</code></pre>
<p>编辑全局配置文件：</p>
<pre><code class="language-Supervisor">sudo vim /etc/supervisord.conf
</code></pre>
<p>将文件底部的 <code>[include]</code> 分区注释符号 <code>;</code> 删除，加入新的配置文件包含路径：</p>
<pre><code class="language-Supervisor">[include]
files = /etc/supervisor/conf/*.conf
</code></pre>
<p>创建 Cloudreve 应用配置所在文件目录，并创建打开配置文件：</p>
<pre><code class="language-Supervisor">sudo mkdir -p /etc/supervisor/conf
sudo vim /etc/supervisor/conf/cloudreve.conf
</code></pre>
<p>根据实际情况填写以下内容并保存：</p>
<pre><code class="language-Supervisor">[program:cloudreve]
directory=/home/cloudreve
command=/home/cloudreve/cloudreve
autostart=true
autorestart=true
stderr_logfile=/var/log/cloudreve.err
stdout_logfile=/var/log/cloudreve.log
environment=CODENATION_ENV=prod
</code></pre>
<p>其中以下配置项需要根据实际情况更改：</p>
<ul>
 <li><code>directory</code>: Clopudreve 主程序所在目录</li>
 <li><code>command</code>: Cloudreve 主程序绝对路径</li>
 <li><code>stderr_logfile</code>: 错误日志路径</li>
 <li><code>stdout_logfile</code>: 通常日志路径</li>
</ul>
<p>通过全局配置文件启动supervisor：</p>
<pre><code class="language-Supervisor">supervisord -c /etc/supervisord.conf
</code></pre>
<p>日后你可以通过以下指令管理 Cloudreve 进程：</p>
<pre><code class="language-Supervisor"># 启动
sudo supervisorctl start cloudreve

# 停止
sudo supervisorctl stop cloudreve

# 查看状态
sudo supervisorctl status cloudreve
</code></pre>
<hr>
<h2 id="docker">Docker</h2>
<p>你可以选择使用以下镜像部署：</p>
<ul>
 <li><a href="https://hub.docker.com/r/xavierniu/cloudreve">xavierniu/cloudreve</a></li>
 <li><a href="https://github.com/littleplus/Cloudreve-Docker">littleplus/Cloudreve-Docker</a></li>
 <li><a href="https://github.com/EscapeLife/awesome-builder/blob/master/dockerfiles/cloudreve/README.md">awesome-builder/Cloudreve</a></li>
</ul>
<hr>
<p>本文转载至：<a href="https://docs.cloudreve.org/getting-started/install#supervisor">cloudreve说明文档</a></p>]]></description><guid isPermaLink="false">/archives/87.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 22 Jul 2020 04:05:00 GMT</pubDate></item><item><title><![CDATA[Adobe After Effects CC 2019安装教程]]></title><link>https://blog.ccrui.cn/archives/84.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Adobe%20After%20Effects%20CC%202019%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B&amp;url=/archives/84.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="下载文件">下载文件</h2>
<blockquote>
 <p>下载链接 1：<a href="https://www.yun.chengrui.xyz/#/s/VgSy">私人网盘下载链接</a><br>
   下载链接 2：<a href="https://pan.baidu.com/s/1dtt9LUbQhYQlhLMrHROAqw">百度网盘下载链接</a> 提取码：wjfp</p>
</blockquote>
<h2 id="解压文件">解压文件</h2>
<p>双击文件解压 <code>Adobe After Effects CC 2019 SP YIPOJIE.zip</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F21%2FSnipaste_2020-07-21_20-08-01.png&amp;size=m" alt="解压图片"></p>
<h2 id="安装软件">安装软件</h2>
<p><strong>第一步断开网络！！！</strong></p>
<p>双击 <code>Set-up.exe</code>进入安装流程</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F21%2FSnipaste_2020-07-21_20-11-41.png&amp;size=m" alt="安装图片"></p>
<p>若出现下图选项 请点击 <strong>是</strong></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F21%2FSnipaste_2020-07-21_20-12-59.png&amp;size=m" alt="权限"></p>
<p>后按照安装提示流程选择所需选项即可完成安装</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F21%2FSnipaste_2020-07-21_20-14-10.png&amp;size=m" alt="安装流程"></p>
<p>出现下图界面后 静等3-5分钟（安装速度与cpu速度与磁盘速度有直接关系）</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F21%2FSnipaste_2020-07-21_20-14-18.png&amp;size=m" alt="安装流程"></p>
<h2 id="安装完成">安装完成</h2>
<p>安装完成后点击 <strong><code>关闭</code></strong></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F21%2FSnipaste_2020-07-21_20-16-28.png&amp;size=m" alt="安装完成"></p>
<p>点击左下角开始菜单 在最近添加界面找到 <code>Adobe After Effects CC 2019</code></p>
<p>点击右键 选择 <code>更多</code> - <code>打开文件位置</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F21%2FSnipaste_2020-07-21_20-23-26.png&amp;size=m" alt="打开文件位置"></p>
<p>右键选择 <code>Adobe After Effects CC 2019</code></p>
<p>点击右键 选择 <code>发送到</code> - <code>桌面快捷方式</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F21%2FSnipaste_2020-07-21_20-25-11.png&amp;size=m" alt="桌面快捷方式"></p>
<h2 id="打开软件">打开软件</h2>
<p>在桌面上双击 <code>Adobe After Effects CC 2019</code> 打开AE 即可完成安装</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F21%2FSnipaste_2020-07-21_20-27-20.png&amp;size=m" alt="打开软件"></p>]]></description><guid isPermaLink="false">/archives/84.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Tue, 21 Jul 2020 12:29:00 GMT</pubDate></item><item><title><![CDATA[免费可商用字体简介及适用范围]]></title><link>https://blog.ccrui.cn/archives/82.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%85%8D%E8%B4%B9%E5%8F%AF%E5%95%86%E7%94%A8%E5%AD%97%E4%BD%93%E7%AE%80%E4%BB%8B%E5%8F%8A%E9%80%82%E7%94%A8%E8%8C%83%E5%9B%B4&amp;url=/archives/82.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="免费可商用字体简介及适用范围">免费可商用字体简介及适用范围</h1>
<blockquote>
 <p>该文章也是我综合了很多文章得到的，并非真正的原创，只是为了让大家看起来更方便，肯定有不完善的地方，还请大家多多指教。</p>
</blockquote>
<p>关于字体授权，作为设计师一定要有所了解，否则，在商用作品中一不小心使用了未经授权的字体，就有可能产生一系列麻烦。商用作品，在字体的使用上要么购买正版字体授权，要么就使用那些免费可商用的字体。下面是我整理的一些可免费商用的中英文字体的简单介绍及适用范围：</p>
<h2 id="1思源黑体">1、思源黑体</h2>
<p>思源黑体是Adobe在线字体库Typekityu与谷歌一起正式发布了新款开源字体。这款字体由Adobe与谷歌合作开发，风格介于现代和传统之间，提供了对日、韩、中文（简/繁体）的支持，包含了7种不同粗细大小：ExtraLight、Light、Normal、Regular、Medium、Bold 和 Heavy。<br>
  适用于比较方正、边缘平滑的版式，比如以几何图形为主的设计、标题字、正文字体。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F01bc185dd73bf8a8012053c0dd1c79.jpg&amp;size=m" alt="思源黑体"></p>
<h2 id="2思源宋体">2、思源宋体</h2>
<p>思源宋体是 Adobe 与 Google 通力合作发布的最新泛 CJK 字体，思源宋体是对应于思源黑体的宋体字体。思源宋体支持四种不同的东亚语言（简体中文、繁体中文、日语和朝鲜语），7 种粗细类型中的每一种都有 65,535 个字形，可共同呈现一致的视觉美感。</p>
<p>适合用于文学性较强的文本或优雅、时尚的标题。它的打印效果也非常优美。通过 Typekit 同步字体可让您使用同一种字体即时呈现多种语言，并且在任何带有字体选择菜单的桌面应用程序中使用这些字体。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0157fa5dd73c09a8012129e2dd90c8.jpg&amp;size=m" alt="思源宋体"></p>
<h2 id="3思源柔黑体">3、思源柔黑体</h2>
<p>思源柔黑体是基于思源黑体修改而成的圆体版思源字体，作者是日本的自家製フォント工房。</p>
<p>思源柔黑体提供了三种不同圆角程度的版本：Goro Gothic L (weakened roundness)、Goro Gothic (basic)、Goro Gothic X (more rounded one)。</p>
<p>适用于图形边缘不太规则的版式，比如光雾电，常用在标题字、短文案上。</p>
<h2 id="4思源真黑体">4、思源真黑体</h2>
<p>思源真黑体出自日本自家製字型工房，堪称是思源柔黑体的姊妹作，从思源黑体修改而来，在细部上做了些许的调整和变化，使它看起来更为锐利。</p>
<h2 id="5庞门正道标题体">5、庞门正道标题体</h2>
<p>庞门正道标题体是由庞门正道设计公众号以及字游空间创意工作室联合研发而且可免费商用的字体，非常适合用于电商标题字体设计。</p>
<p>适用于比较方正或带弧形设计的版式，字体的再造（字形的重新设计），海报、H5的标题字。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F01aefd5dd73c16a8012053c016d3e6.jpg&amp;size=m" alt="庞门正道标题体"></p>
<h2 id="6庞门正道粗书体">6、庞门正道粗书体</h2>
<p>庞门正道粗书体是一款由《庞门正道》设计公众号以及设计师车港敏联合研发的免费字体，这也是一款不错的手写艺术字体。字体笔触较为粗实，书写端正大气。</p>
<p>适用于艺术设计、平面宣传设计、网页设计、影视传媒等领域。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F01b4d45dd7419ba8012129e24c1929.jpg&amp;size=m" alt="庞门正道粗书体"></p>
<h2 id="7方正系列字库">7、方正系列字库</h2>
<p>方正有四款字体可以免费商用（但是需要书面授权），四个字体分别是：方正黑体、方正书宋、方正仿宋、方正楷体。非常标准的常用字体。</p>
<p>方正楷体、仿宋、书宋适合带弧形的版式，用于正文字体时必须注意线形太细会否影响阅读；黑体适用于比较方正、边缘平滑的版式，适合字号中等或较小的短文案、正文字体。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F016ecb5dd7426ea8012053c07cbc6e.jpg&amp;size=m" alt="方正系列字库"></p>
<h2 id="8装甲明朝体">8、装甲明朝体</h2>
<p>装甲明朝体是一款基于思源宋体修改而成的新字体，出自日本字体爱好者。装甲明朝体，将水平横线笔划修改得超细，在文字表现上，显得张力更强。</p>
<p>适用于军事领域或者是表现阳刚气息的设计上。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0109ff5dd7415ea8012129e2567885.jpg&amp;size=m" alt="装甲明朝体"></p>
<h2 id="9源界明朝">9、源界明朝</h2>
<p>这款字体是以「思源宋体」为基础，加入破坏效果使其最接近可读状态，可以简单理解成思源宋体的破坏版，源界明朝在视觉上具有相当大的张力，整体来说相当吸睛且颇具效果。</p>
<p>适用于图片内的标题和大字。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F01c3765dd74152a8012129e2f43b79.jpg&amp;size=m" alt="源界明朝"></p>
<h2 id="10源样明体源流明体及源云明体">10、源样明体、源流明体及源云明体</h2>
<p>这三款字体的共同特色是修改自「思源宋体」，源样明体采用思源宋体韩文版本的字符，配合繁体中文习惯的置中标点符号，可说是兼具排版及传统印刷体风格的繁体中文字体；源流明体在笔画上有所调整，使字型看起来更有力道；源云明体在横笔的起笔及竖笔的起笔、收笔处加入粗细变化，笔画交叉处有朦胧处理。</p>
<p>和思源宋体一样，源样明体、源流明体都有七种字重，源云明体则是 Light、Regular、Medium 和 SemiBold 四种，能广泛使用于各种环境。</p>
<h2 id="11花园明朝体">11、花园明朝体</h2>
<p>这款字体的特点是涵盖了目前 CJK (中日韩统一表意文字)字库中几乎所有的汉字与字符。花园明朝体的缺点是字形以日本字形为准，有一些字不符合中文书写规范。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F01f01e5dd7413da8012129e21cb34b.jpg&amp;size=m" alt="花园明朝体"></p>
<h2 id="12手写字体-手书体">12、手写字体-手书体</h2>
<p>中文手书体共做了基本汉字6763个，提供给大家免费商用，字体风格为手写风格。</p>
<p>适用于slogan、banner、海报、商标等设计。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F01e66f5dd73c4fa8012129e27760d9.jpg&amp;size=m" alt="手写字体-手书体"></p>
<h2 id="13沐瑶软笔手写体">13、沐瑶软笔手写体</h2>
<p>沐瑶软笔手写体是站酷手绘设计师“春颜秋色”送给女儿的礼物，同时也是送给大家的字体。这是一款可爱风格的字体。沐瑶软笔手写体免费可商用，作者仅保留字体创作者权利。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F01f00e5dd73c5da8012053c0b057f8.jpg&amp;size=m" alt="沐瑶软笔手写体"></p>
<h2 id="14锐字真言体">14、锐字真言体</h2>
<p>锐字真言体是锐字家族推出的首款免费商用字体，全免费，高品质，可商用！</p>
<p>锐字真言体笔触浑厚有力，笔画曲折有度，字形个性鲜明，刚柔并济，落笔简洁有序，给人以遒劲有力、端正凝练的感受。直角与圆角的错落搭配使得字体婉转有度，落落大方，具有自己独到的风格！</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0160695dd73c67a8012129e2c39e4e.jpg&amp;size=m" alt="锐字真言体"></p>
<h2 id="15杨任东竹石体">15、杨任东竹石体</h2>
<p>杨任东竹石体是一套可以免费商用的多字重中文手写字体，增补了少量常见汉字；整套字体有7个字重，共计50000余个字符。</p>
<p>适用于海报、包装、logo、网页、app等。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0103cc5dd73c74a8012053c09dd7c9.jpg&amp;size=m" alt="杨任东竹石体"></p>
<h2 id="16文泉驿系列字体">16、文泉驿系列字体</h2>
<p>windows下的免费字体：<strong>文泉驿正黑、文泉驿点阵正黑、文泉驿等宽正黑、文泉驿微米黑。</strong></p>
<p>文泉驿是一个开源汉字字体项目，由旅美学者房骞骞（FangQ）于2004年10月创建。这些字库已经逐渐成为主流Linux/Unix发行版中文桌面的首选中文字体。既有手工优化、清晰锐利的点阵汉字，又有柔和圆润、无限放缩的矢量字体。</p>
<p>既有适合普通中英文混版(网页浏览、文档排版)的非等宽字体，还有适合在编程环境下(如控制台、程序编辑器等)中文英文对齐的等宽字体。</p>
<p>适用于比较方正、边缘平滑的版式，适合字号中等或较小的短文案、正文字体。</p>
<p>目前已经有的免费字体：</p>
<ul>
 <li>
  <p>清晰锐利的传统中文界面：文泉驿点阵宋体（目前无windows版）</p></li>
 <li>
  <p>柔和圆润的现代中文界面：文泉驿正黑</p>
  <p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0141185dd73c9aa8012053c0cd01d7.jpg&amp;size=m" alt="文泉驿正黑"></p></li>
 <li>
  <p>柔和与清晰的智能组合：文泉驿点阵正黑</p></li>
 <li>
  <p>兼顾中英文对齐的等宽开源字体：文泉驿等宽正黑</p></li>
</ul>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0189085dd73ca7a8012053c0c30a75.jpg&amp;size=m" alt="文泉驿等宽正黑"></p>
<ul>
 <li>很小很强大的高质量矢量字体：文泉驿微米黑</li>
</ul>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0111cb5dd7412ca8012129e2630954.jpg&amp;size=m" alt="文泉驿微米黑"></p>
<ul>
 <li>经典的等宽点阵中文字体：文泉驿Unibit（非windows平台字体）</li>
</ul>
<h2 id="站酷系列字体">站酷系列字体</h2>
<p>免费字体：<strong>站酷酷黑体、站酷意大利体、站酷快乐体、站酷高端黑体。</strong></p>
<p>站酷高端黑由站酷网字体设计师胡晓波、刘兵克发起，参与汉字百人舞100位字体设计师共同完成。全部字形以众包的形式由分散在全国的79名设计师分别完成；</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0182e85dd73cb5a8012129e2f76033.jpg&amp;size=m" alt="站酷高端黑"></p>
<p>站酷快乐体由字体设计师刘兵克及150位字体设计的朋友制作而成。是一例风格轻松和简单的字体，无论是笔画结构，还是笔画粗细，都很灵活，字与字之间的协调性统一性也更容易实现；</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F015a105dd73cbea8012129e20bdf6b.jpg&amp;size=m" alt="站酷快乐体"></p>
<p>站酷酷黑体由胡晓波发起，字游工作室成员进行基础字形设计。字形笔画粗犷有力，用宽扁型的字面构建出厚重的字体形态，笔画细节上的修饰既增强了字体的设计感，又让字体多了一些小小的精致感，中宫的饱满使得文字之间的排版组合非常醒目好看；</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F01c2c35dd742c0a8012053c08cd488.jpg&amp;size=m" alt="站酷酷黑体"></p>
<p>站酷意大利体（这其实是一个英文字体）由大猫Addict设计，站酷冠名的首款公益西文字库。免费授权全社会使用（包括商用）。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0176e25dd745faa8012129e297d6e7.jpg&amp;size=m" alt="站酷意大利体"></p>
<p>适用于比较方正、边缘平滑的版式，常用于字体重设计、标题字、短文案。</p>
<h2 id="18站酷文艺体">18、站酷文艺体</h2>
<p>站酷文艺体，由字体设计师刘兵克确定字形和规范，结构上选用了略扁的形态，其笔画粗细基本保持一致，字形新颖独特，简洁有力，清新淡雅，文艺范十足。在字形细节里，适当的圆角设计，“口”字形部件右上角的竖线设计，以及撇捺笔画的曲直对比设计，这些崭新的形态以及组合，都让这款字体具备了更多的独创性。</p>
<p>适用于广告字体，海报字体，电商标题字体，正文字体⋯⋯</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F01f0935dd73cd7a8012053c073bbc3.jpg&amp;size=m" alt="站酷文艺体"></p>
<h2 id="19汉仪贤二体">19、汉仪贤二体</h2>
<p>贤二体是北京龙泉寺动漫中心与汉仪字库联合推出的一款商用免费字体。贤二体的字形偏长，起笔收笔锋利且粗细对比明显，笔画笨拙微带曲线感。字体组合结构松散，重心不稳，达到诙谐幽默，惹人喜爱的效果。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F01e8a35dd73ce5a8012129e23e5f3c.jpg&amp;size=m" alt="汉仪贤二体"></p>
<h2 id="20tanukimagic麦克笔手绘体">20、TanukiMagic麦克笔手绘体</h2>
<p>TanukiMagic麦克笔手绘体：这是一款手绘POP风格的字体，这款来自日本的字体除了有 POP效果外，还有手写文字效果，生动活泼（由于是日系字体，所以简体用字存在缺字情况，繁体会效果好一些）。</p>
<p>适用于海报设计。</p>
<h2 id="21清松手写体">21、清松手写体</h2>
<p>清松手写体是一款来自台湾的字体，它由游清松建立，不论是中文、英文、符号数字，目前开放给所有人(包含商用)免费使用。</p>
<p>适用于计算机屏幕上阅读、排版，打印出来效果也很棒的！</p>
<h2 id="22超极细字型">22、超极细字型</h2>
<p>这个极细体真的细的很夸张，比平时我们见到的所有细体都还要细。</p>
<p>适用于一些女性主题设计。</p>
<h2 id="23台湾明体">23、台湾明体</h2>
<p>台湾明体是一款旧字形外观，在一定程度上仿照古籍《康熙字典》字体，字形构架稳固，庄重而大方。</p>
<p>适用于古籍文献印刷。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F016fab5dd7444ea8012129e2fd91e8.jpg&amp;size=m" alt="台湾明体"></p>
<h2 id="24包图小白体">24、包图小白体</h2>
<p>包图小白体，定义为一款简单可爱的创意字体。在字形笔画上去除了折笔的弧形，换之以平直的笔画，竖弯钩转为竖折，同时弱化了钩笔画，省去了许多笔画末尾的小尾巴，显得更加直白可爱。粗短的笔画，像柯基的小短腿，相比细长的字体能给人更多的轻松感。整体形态采用了镂空的制作技巧，增强了字体的立体感。</p>
<p>适用于品牌标志、海报、包装、影视综艺、游戏、漫画等场景。 .</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F017e975dd73cf2a8012053c0eeaaca.jpg&amp;size=m" alt="包图小白体"></p>
<h2 id="25王汉宗系列字型">25、王汉宗系列字型</h2>
<p>王汉宗自由字型由研发天蚕字库的台湾中原大学数学系王汉宗教授先分别在2000年和2004年先后捐出十套WCL系列字型和32套新字型，全部以GNU GPL许可分发。</p>
<p>10套WCL：波浪体、特明体、波卡体空阴、综艺体双空阴、标楷体空心、仿宋体、粗钢体、粗黑体实阴、粗圆体双空、海报体半天水。</p>
<p>32套新字型：细明、中明、粗明、特明、超明、细圆、特圆、细黑、特黑、中隶书、中仿宋、叠圆、勘流亭、综艺体、颜体、中行书、酷俪海报、正海报、钢笔行楷、超黑俏丽动物、中明注音体、中明破音字1、中明破音字2、中明破音字3、中楷注音体、中楷破音字1、中楷破音字2、中楷破音字3、粗楷体简体、中魏碑简体、中仿宋简体、细新宋简体。</p>
<p><strong>注：文鼎公司主张侵权的王汉宗字型：王汉宗中仿宋、王汉宗中仿宋简体、王汉宗隶书体、王汉宗中明体、 王汉宗粗明体、王汉宗特明体、王汉宗细圆体、王汉宗特圆体、王汉宗迭圆体、王汉宗勘亭流、王汉宗综艺体、王汉宗中行书、王汉宗综艺体双空阴、王汉宗粗楷体简体。文鼎公司主张以上王汉宗字型侵权，使用前请斟酌。其他部分的王汉宗字体则无争议。</strong></p>
<h2 id="26濑户字体">26、濑户字体</h2>
<p>濑户字体，是一款偏可爱风的字体，支持简体中文、繁体中文、日文，包含CJK常用汉字、平片假名、JIS第一至四级，共30000余字。由日本的一位业余字体设计师濑户のぞみ所制作。</p>
<h2 id="27全字库系列字体">27、全字库系列字体</h2>
<p>免费字体：全字库说文解字、全字库正宋体、全字库正楷体。</p>
<p>《说文解字》是中国第一部系统地分析汉字字形和考究字源的字书。许慎着，成于安帝建光元年(121年)。原书十四篇，叙目一篇，正文以小篆为主，收9353字，又古文、籀文等异体同文1163字，解释十三万余字。</p>
<h2 id="28fandol系列字体">28、Fandol系列字体</h2>
<p>Fandol系列字体来自一家已经破产的字体公司，现在已经开源了。</p>
<p>包含FandolFang、FandolHei、FandolKai、FandolSong四个字体，基于GNU GENERAL PUBLIC LICENSE Version 3 释出，可商用。</p>
<h2 id="29台湾教育部字体">29、台湾教育部字体</h2>
<p>免费字体：台湾教育部标准楷书、台湾教育部标准宋体、台湾教育部国字隶书。</p>
<h2 id="30郑庆科黄油体">30、郑庆科黄油体</h2>
<p>黄油体是一款个人设计师推出的中文字体，由郑庆科设计。</p>
<p>适用于店招、banner、标志等领域。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F01dc835dd73d02a8012053c0155330.jpg&amp;size=m" alt="郑庆科黄油体"></p>
<h2 id="31阿里巴巴普惠体">31、阿里巴巴普惠体</h2>
<p>阿里巴巴普惠体是一款由中国企业首次发布的可面向全场景使用的免费商用正文字体。</p>
<p>阿里巴巴普惠体共收录 116,895 个全形汉字（含 5 个字重），西文 Alibaba Sans 共 7,205 个拉丁字母（2 种风格、共 11 个字重），覆盖 172 个语种（覆盖大部分欧语国家），并可以满足阿里巴巴集团及其经济体公司在全球化业务下的多个应用场景需求。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0117035dd73d0ba8012053c09d5b21.jpg&amp;size=m" alt="阿里巴巴普惠体"></p>
<h2 id="32阿里汉仪智能黑体">32、阿里汉仪智能黑体</h2>
<p>阿里汉仪智能黑体由阿里巴巴和汉仪字库合作推出的首款人工智能字体。这套首款人工智能字体是由汉仪字库协同阿里人机自然交互实验室，通过强大的计算能力自学生成的。</p>
<p><strong>注：仅限阿里平台用户使用。</strong></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0134dd5dd73d16a8012129e24a6c8d.jpg&amp;size=m" alt="阿里汉仪智能黑体"></p>
<h2 id="33华康字体仅阿里平台">33、华康字体（仅阿里平台）</h2>
<p>华康字体：布丁体、彩带体、儿风体、方圆体、钢笔体、海报体、手札体W5、手札体W7、翩翩体W3、翩翩体W5、黑体W3、黑体W5、黑体W7、黑体W9、黑体W12、金文体Std W3、楷体Std W5、勘亭流Std W9、俪金黑Std W8、隶书体Std W7、龙门石碑Std W9、墨字体Std W9、POP1体Std W5、POP2体Std W9、POP3体12、少女文字Std W5、饰艺体Std W7、瘦金体Std W3、宋体Std W3、宋体Std W5、宋体Std W7、标题宋Std W9、宋体Std W12、唐风隶Std W5、娃娃体Std W5、魏碑Std W7、正颜楷体Std W7、雅宋体Std W9、雅艺体Std W6、圆体Std W3、圆体Std W5、圆体Std W7、圆体Std W9、新综艺Std W7、新综艺Std W9。</p>
<p><strong>注：上述45款华康仅限阿里平台使用，其他平台使用，依然是需要获取授权的。</strong></p>
<h2 id="34汉仪字体仅京东平台">34、汉仪字体（仅京东平台）</h2>
<p>13款汉仪字体（仅可以在京东平台上免费使用）：汉仪中黑(简/繁)、汉仪细简黑(简)、汉仪中简黑(简)、汉仪楷体(简/繁)、汉仪书宋一(简)、汉仪书宋二(繁)、汉仪粗仿宋(简)、汉仪水滴体(简/繁)、汉仪珍珠隶(简/繁)。</p>
<h2 id="35免费可商用英文字体">35、免费可商用英文字体</h2>
<p>AiDeep：是由网络尖刀用户体验中心UED团队出品的一套由公司品牌命名的开源字体。开源字体，意味着你是可以将AiDeep字体用于任何商业用途，无需担心侵权问题的。</p>
<p>IBM Plex-IBM发布的免费字体：是IBM发布的一套全新的开源字体，这套字体的设计灵感来源于IBM的LOGO，IBM Plex这款字体包含衬线、无衬线、等宽 3 个变化，共计 48 个样式。</p>
<p>Morganite时尚英文字体：是印度设计师Rajesh Rajput制作的一套免费可商用的时尚英文字体。质量比很多商业字体还要高，Morganite包括了18种字体风格，并且包含标点、符号、数字统一设计，从细到粗，还有倾斜体，整套字体风格优美时尚。</p>
<p>非常适合用在时尚、高端类型的海报设计作品，比如女性、电影类海报等方面。</p>
<p>Public Sans：“有力的、中性的”是一款通用、便于识别的无衬线英文字体。</p>
<blockquote>
 <p>链接：<a href="https://pan.baidu.com/s/1cks-OR62MPS_8jwDZoggNQ">百度网盘</a><br>
   提取码：2a8i</p>
</blockquote>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F19%2F0111ba5d6383c4a80120695ca174f2.png&amp;size=m" alt="下载链接"></p>
<hr>
<p>本文转自 <a href="https://www.zcool.com.cn/article/ZMTAyMTQ4NA==.html">免费可商用字体简介及适用范围</a></p>]]></description><guid isPermaLink="false">/archives/82.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 19 Jul 2020 13:21:00 GMT</pubDate></item><item><title><![CDATA[利用ossfs进行阿里云OSS挂载]]></title><link>https://blog.ccrui.cn/archives/77.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E5%88%A9%E7%94%A8ossfs%E8%BF%9B%E8%A1%8C%E9%98%BF%E9%87%8C%E4%BA%91OSS%E6%8C%82%E8%BD%BD&amp;url=/archives/77.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="快速安装">快速安装</h1>
<p>ossfs能让您在Linux系统中，将对象存储OSS的存储空间（Bucket）挂载到本地文件系统中，您能够像操作本地文件一样操作OSS的对象（Object），实现数据的共享。</p>
<h2 id="运行环境">运行环境</h2>
<ul>
 <li>Linux系统 
  <ul>
   <li>CentOS 7.0及以上版本</li>
   <li>Ubuntu 14.04及以上版本</li>
  </ul></li>
 <li>fuse 2.8.4以上版本</li>
</ul>
<h2 id="下载地址">下载地址</h2>
<table>
 <thead>
  <tr>
   <th>Linux发行版</th>
   <th>下载</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>Ubuntu 18.04 (x64)</td>
   <td><a href="http://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_ubuntu18.04_amd64.deb?spm=a2c4g.11186623.2.15.1e587358NHgNPo&amp;file=ossfs_1.80.6_ubuntu18.04_amd64.deb">ossfs_1.80.6_ubuntu18.04_amd64.deb</a></td>
  </tr>
  <tr>
   <td>Ubuntu 16.04 (x64)</td>
   <td><a href="http://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_ubuntu16.04_amd64.deb?spm=a2c4g.11186623.2.16.1e587358NHgNPo&amp;file=ossfs_1.80.6_ubuntu16.04_amd64.deb">ossfs_1.80.6_ubuntu16.04_amd64.deb</a></td>
  </tr>
  <tr>
   <td>Ubuntu 14.04 (x64)</td>
   <td><a href="http://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_ubuntu14.04_amd64.deb?spm=a2c4g.11186623.2.17.1e587358NHgNPo&amp;file=ossfs_1.80.6_ubuntu14.04_amd64.deb">ossfs_1.80.6_ubuntu14.04_amd64.deb</a></td>
  </tr>
  <tr>
   <td>CentOS 7.0 (x64)</td>
   <td><a href="http://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_centos7.0_x86_64.rpm?spm=a2c4g.11186623.2.18.1e587358NHgNPo&amp;file=ossfs_1.80.6_centos7.0_x86_64.rpm">ossfs_1.80.6_centos7.0_x86_64.rpm</a></td>
  </tr>
  <tr>
   <td>CentOS 6.5 (x64)</td>
   <td><a href="http://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_centos6.5_x86_64.rpm?spm=a2c4g.11186623.2.19.1e587358NHgNPo&amp;file=ossfs_1.80.6_centos6.5_x86_64.rpm">ossfs_1.80.6_centos6.5_x86_64.rpm</a></td>
  </tr>
 </tbody>
</table>
<h2 id="快速安装-1">快速安装</h2>
<p>由于低版本的Linux系统内核版本比较低，ossfs进程在运行过程中容易出现掉线或者其他问题。因此建议您将操作系统升级到CentOS 7.0或者Ubuntu 14.04及以上版本。</p>
<ol>
 <li>
  <p>下载安装包。<br>
    以下载CentOS 7.0 (x64)版本为例：<br><code>wget http://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_centos7.0_x86_64.rpm</code></p></li>
 <li>
  <p>安装ossfs。</p>
  <ul>
   <li>Ubuntu系统的安装命令： 
    <pre><code class="language-Linux">sudo apt-get update
sudo apt-get install gdebi-core
sudo gdebi your_ossfs_package
</code></pre></li>
   <li>CentOS6.5及以上系统版本的安装命令： 
    <pre><code class="language-Linux">sudo yum localinstall your_ossfs_package
</code></pre>
    <blockquote>
     <p>说明 对于使用yum安装rpm包的客户端，如果客户端节点网络环境特殊，无法直接用yum下载依赖包。可以在网络正常的、相同版本操作系统的节点上，使用yum下载依赖包并拷贝到网络特殊的节点。例如，ossfs需要依赖fuse 2.8.4以上版本，可使用如下命令，下载yum源中最新的fuse到本地：<br><code>sudo yum install --downloadonly --downloaddir=./ fuse</code><br>
       如果需要下载其他依赖包，则将fuse换成对应包的名称。</p>
    </blockquote></li>
   <li>CentOS5系统版本的安装命令： 
    <pre><code class="language-Linux">sudo yum localinstall your_ossfs_package --nogpgcheck
</code></pre></li>
  </ul></li>
 <li>
  <p>配置账号访问信息。<br>
    将Bucket名称以及具有此Bucket访问权限的AccessKeyId/AccessKeySecret信息存放在/etc/passwd-ossfs文件中。注意这个文件的权限必须正确设置，建议设为640。</p>
  <pre><code class="language-Linux">echo my-bucket:my-access-key-id:my-access-key-secret &gt; /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
</code></pre></li>
 <li>
  <p>将Bucket挂载到指定目录。</p>
  <pre><code class="language-Linux">ossfs my-bucket my-mount-point -ourl=my-oss-endpoint
</code></pre>
  <p>挂载示例：将杭州地域名称为bucket-test的Bucket挂载到/tmp/ossfs目录下。</p>
  <pre><code class="language-Linux">echo bucket-test:LTAIbZcdVCmQ****:MOk8x0y9hxQ31coh7A5e2MZEUz**** &gt; /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
mkdir /tmp/ossfs
ossfs bucket-test /tmp/ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com
</code></pre>
  <blockquote>
   <p>注意 如果您使用从阿里云购买的云服务器（ECS）来提供ossfs服务，您可以使用内网域名，在这个示例中您可以将OSS endpoint 改为<code>oss-cn-hangzhou-internal.aliyuncs.com</code>，这样可以节省流量费用。OSS的内网域名请参见<a href="https://help.aliyun.com/document_detail/31837.html?spm=a2c4g.11186623.2.20.1e587358NHgNPo#concept-zt4-cvy-5db">访问域名和数据中心</a>。</p>
  </blockquote></li>
 <li>
  <p>如果您不希望继续挂载此Bucket，您可以将其卸载。</p>
  <pre><code class="language-Linux">fusermount -u /tmp/ossfs
</code></pre></li>
</ol>
<blockquote>
 <p>说明 更多详细信息请参见<a href="https://github.com/aliyun/ossfs?spm=a2c4g.11186623.2.21.1e587358NHgNPo#ossfs">GitHub ossfs</a>。</p>
</blockquote>
<h2 id="版本日志">版本日志</h2>
<p>版本日志信息，请参见GitHub ChangeLog。</p>
<hr>
<p>本文转自<a href="https://help.aliyun.com/document_detail/153892.html?spm=a2c4g.11186623.2.11.5a0321edDXqCDw#concept-kkp-lmb-wdb">阿里云官方文档</a></p>]]></description><guid isPermaLink="false">/archives/77.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 19 Jul 2020 11:16:00 GMT</pubDate></item><item><title><![CDATA[调教Chevereto——给Chevereto图床套上阿里云CDN]]></title><link>https://blog.ccrui.cn/archives/56.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=%E8%B0%83%E6%95%99Chevereto%E2%80%94%E2%80%94%E7%BB%99Chevereto%E5%9B%BE%E5%BA%8A%E5%A5%97%E4%B8%8A%E9%98%BF%E9%87%8C%E4%BA%91CDN&amp;url=/archives/56.html" width="1" height="1" alt="" style="opacity:0;">
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F17%2FcheveretoCDN.png&amp;size=m" alt="阿里云"></p>
<p>Chevereto图床自带一个CDN功能，可以替换掉程序的一些图片链接以及css等链接，如果放chevereto程序的服务器带宽不给力，那么可以考虑开启这个功能。</p>
<p>这篇主要说的用阿里云家的CDN，别家的CDN也可以参考这篇文章，就是有些地方会有些不同。</p>
<h2 id="开通阿里云oss">开通阿里云OSS</h2>
<p>首先开通阿里云的对象存储OSS，新建一个Bucket：</p>
<p><span>BucketName：随便填</span></p>
<p><span>所属地域：离你近的地域</span></p>
<p><span>存储类型：标准存储</span></p>
<p><span>读写权限：公共读</span></p>
<h2 id="设置回源规则">设置回源规则</h2>
<p>创建好之后，点中刚刚创建好的Bucket，点击Bucket属性，点击回源设置，添加规则：</p>
<p><span>回源类型：镜像</span></p>
<p><span>回源条件：默认</span></p>
<p><span>回源地址：填你的图床域名</span></p>
<p><span>回源参数：勾上</span></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F17%2FQQ20170502222859.png&amp;size=m" alt="回源"></p>
<h2 id="添加cdn解析">添加CDN解析</h2>
<p>然后再点击域名管理，添加你准备给图床准备的CDN域名。注意：域名必须备案了！！！</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F17%2FQQ20170502223511.png&amp;size=m" alt="域名管理"></p>
<p>OSS这里操作好之后，回到CDN管理这儿。</p>
<p>点击域名管理-添加域名：</p>
<p><span>加速域名：你准备的CDN域名</span></p>
<p><span>业务类型：图片小文件</span></p>
<p><span>源站类型：OSS域名，选中之后找到你OSS的那个外网域名，看图。然后端口两个随意。</span></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F17%2FQQ20170502224030.png&amp;size=m" alt="填写"></p>
<p>然后你只需要去给你的CDN域名添加一个CNAME就好了。</p>
<p>最后进入你的图床站后台，设置-外部服务-CDN，选启用。然后下面的CDN URL处填写你的CDN域名。然后保存修改，然后再访问你的图床站首页，会发现有的图片打不开或者css没了，这个时候不要着急，等回源完成就好，回源时间看你服务器的网速跟性能。</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F17%2FQQ20170502224727.png&amp;size=m" alt="目录"></p>
<p>等到OSS有你网站的内容了，那么回源基本上都好了，这时候打开你的网站，查看源代码，会发现有些链接变成了你添加的CDN域名。到这就设置好了。图床站打开速度也会变快一点。</p>
<p>过程中遇到各种各样的问题或者chevereto遇到各种各样的问题可以在下面留言，只要我知道就一定会回复的~</p>
<h2 id="字体图标解决方案">字体图标解决方案</h2>
<p>注：CDN解析后字体图标无法显示解决方法 <img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F17%2FSnipaste_2020-07-17_19-01-17.png&amp;size=m" alt="图片"></p>
<blockquote>
 <p>本文转载至 <a href="https://mikublog.com/tech/1501" title="调教Chevereto（一）——给Chevereto图床套上阿里云CDN">调教Chevereto（一）——给Chevereto图床套上阿里云CDN</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/56.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Fri, 17 Jul 2020 09:39:00 GMT</pubDate></item><item><title><![CDATA[Menhera表情包]]></title><link>https://blog.ccrui.cn/archives/55.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Menhera%E8%A1%A8%E6%83%85%E5%8C%85&amp;url=/archives/55.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="menhera表情包">Menhera表情包</h1>
<p>这里在网上找到了一组敲级可爱的Menhera表情包<br>
  而且清晰度超级高<br>
  需要的话可以根据该链接来下载</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F15%2FSnipaste_2020-07-15_19-46-06.png&amp;size=m" alt="Menhera表情包"></p>
<blockquote>
 <p><a href="https://cloud.ccrui.cn/#/s/8piJ">私人网盘下载链接</a><br><a href="https://share.weiyun.com/ieApNUuz">腾讯微云下载链接</a><br><strong>注：压缩文件解压密码：Menhera</strong></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/55.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Wed, 15 Jul 2020 11:53:00 GMT</pubDate></item><item><title><![CDATA[.md文件错误代码]]></title><link>https://blog.ccrui.cn/archives/44.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=.md%E6%96%87%E4%BB%B6%E9%94%99%E8%AF%AF%E4%BB%A3%E7%A0%81&amp;url=/archives/44.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="rules">Rules</h1>
<p>This document contains a description of all rules, what they are checking for,<br>
  as well as an examples of documents that break the rule and corrected<br>
  versions of the examples. Any rule whose heading is 
 <del>struck through</del> is<br>
  deprecated, but still provided for backward-compatibility.</p>
<p><a name="user-content-md001"></a></p>
<h2 id="md001---heading-levels-should-only-increment-by-one-level-at-a-time">MD001 - Heading levels should only increment by one level at a time</h2>
<p>Tags: headings, headers</p>
<p>Aliases: heading-increment, header-increment</p>
<p>This rule is triggered when you skip heading levels in a markdown document, for<br>
  example:</p>
<pre><code class="language-markdown"># Heading 1

### Heading 3

We skipped out a 2nd level heading in this document
</code></pre>
<p>When using multiple heading levels, nested headings should increase by only one<br>
  level at a time:</p>
<pre><code class="language-markdown"># Heading 1

## Heading 2

### Heading 3

#### Heading 4

## Another Heading 2

### Another Heading 3
</code></pre>
<p>Rationale: Headings represent the structure of a document and can be confusing<br>
  when skipped - especially for accessibility scenarios. More information:<br><a href="https://www.w3.org/WAI/tutorials/page-structure/headings/">https://www.w3.org/WAI/tutorials/page-structure/headings/</a>.</p>
<p><a name="user-content-md002"></a></p>
<h2 id="md002---first-heading-should-be-a-top-level-heading">
 <del>MD002 - First heading should be a top level heading</del></h2>
<p>Tags: headings, headers</p>
<p>Aliases: first-heading-h1, first-header-h1</p>
<p>Parameters: level (number; default 1)</p>
<blockquote>
 <p>Note: <em>MD002 has been deprecated and is disabled by default.</em><br><a href="https://blog.ccrui.cn#md041">MD041/first-line-heading</a> offers an improved implementation.</p>
</blockquote>
<p>This rule is intended to ensure document headings start at the top level and<br>
  is triggered when the first heading in the document isn't an h1 heading:</p>
<pre><code class="language-markdown">## This isn't an H1 heading

### Another heading
</code></pre>
<p>The first heading in the document should be an h1 heading:</p>
<pre><code class="language-markdown"># Start with an H1 heading

## Then use an H2 for subsections
</code></pre>
<p>Note: The <code>level</code> parameter can be used to change the top level (ex: to h2) in<br>
  cases where an h1 is added externally.</p>
<p>Rationale: The top level heading often acts as the title of a document. More<br>
  information: <a href="https://cirosantilli.com/markdown-style-guide#top-level-header">https://cirosantilli.com/markdown-style-guide#top-level-header</a>.</p>
<p><a name="user-content-md003"></a></p>
<h2 id="md003---heading-style">MD003 - Heading style</h2>
<p>Tags: headings, headers</p>
<p>Aliases: heading-style, header-style</p>
<p>Parameters: style ("consistent", "atx", "atx_closed", "setext",<br>
  "setext_with_atx", "setext_with_atx_closed"; default "consistent")</p>
<p>This rule is triggered when different heading styles (atx, setext, and 'closed'<br>
  atx) are used in the same document:</p>
<pre><code class="language-markdown"># ATX style H1

## Closed ATX style H2 ##

Setext style H1
===============
</code></pre>
<p>Be consistent with the style of heading used in a document:</p>
<pre><code class="language-markdown"># ATX style H1

## ATX style H2
</code></pre>
<p>The setext_with_atx and setext_with_atx_closed doc styles allow atx-style<br>
  headings of level 3 or more in documents with setext style headings:</p>
<pre><code class="language-markdown">Setext style H1
===============

Setext style H2
---------------

### ATX style H3
</code></pre>
<p>Note: the configured heading style can be a specific style to use (atx,<br>
  atx_closed, setext, setext_with_atx, setext_with_atx_closed), or simply require<br>
  that the usage be consistent within the document.</p>
<p>Rationale: Consistent formatting makes it easier to understand a document.</p>
<p><a name="user-content-md004"></a></p>
<h2 id="md004---unordered-list-style">MD004 - Unordered list style</h2>
<p>Tags: bullet, ul</p>
<p>Aliases: ul-style</p>
<p>Parameters: style ("consistent", "asterisk", "plus", "dash", "sublist"; default<br>
  "consistent")</p>
<p>This rule is triggered when the symbols used in the document for unordered<br>
  list items do not match the configured unordered list style:</p>
<pre><code class="language-markdown">* Item 1
+ Item 2
- Item 3
</code></pre>
<p>To fix this issue, use the configured style for list items throughout the<br>
  document:</p>
<pre><code class="language-markdown">* Item 1
* Item 2
* Item 3
</code></pre>
<p>The configured list style can be a specific symbol to use (asterisk, plus, dash),<br>
  can require that usage be consistent within the document, or can require that each<br>
  sublist have a consistent symbol that is different from its parent list.</p>
<p>For example, the following is valid for the <code>sublist</code> style because the outer-most<br>
  indent uses asterisk, the middle indent uses plus, and the inner-most indent uses dash:</p>
<pre><code class="language-markdown">* Item 1
  + Item 2
    - Item 3
  + Item 4
* Item 4
  + Item 5
</code></pre>
<p>Rationale: Consistent formatting makes it easier to understand a document.</p>
<p><a name="user-content-md005"></a></p>
<h2 id="md005---inconsistent-indentation-for-list-items-at-the-same-level">MD005 - Inconsistent indentation for list items at the same level</h2>
<p>Tags: bullet, ul, indentation</p>
<p>Aliases: list-indent</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when list items are parsed as being at the same level,<br>
  but don't have the same indentation:</p>
<pre><code class="language-markdown">* Item 1
  * Nested Item 1
  * Nested Item 2
   * A misaligned item
</code></pre>
<p>Usually this rule will be triggered because of a typo. Correct the indentation<br>
  for the list to fix it:</p>
<pre><code class="language-markdown">* Item 1
  * Nested Item 1
  * Nested Item 2
  * Nested Item 3
</code></pre>
<p>Sequentially-ordered list markers are usually left-aligned such that all items<br>
  have the same starting column:</p>
<pre><code class="language-markdown">...
8. Item
9. Item
10. Item
11. Item
...
</code></pre>
<p>This rule also supports right-alignment of list markers such that all items have<br>
  the same ending column:</p>
<pre><code class="language-markdown">...
 8. Item
 9. Item
10. Item
11. Item
...
</code></pre>
<p>Rationale: Violations of this rule can lead to improperly rendered content.</p>
<p><a name="user-content-md006"></a></p>
<h2 id="md006---consider-starting-bulleted-lists-at-the-beginning-of-the-line">
 <del>MD006 - Consider starting bulleted lists at the beginning of the line</del></h2>
<p>Tags: bullet, ul, indentation</p>
<p>Aliases: ul-start-left</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when top level lists don't start at the beginning of a<br>
  line:</p>
<pre><code class="language-markdown">Some text

  * List item
  * List item
</code></pre>
<p>To fix, ensure that top level list items are not indented:</p>
<pre><code class="language-markdown">Some test

* List item
* List item
</code></pre>
<p>Note: This rule is triggered for the following scenario because the unordered<br>
  sublist is not recognized as such by the parser. Not being nested 3 characters<br>
  as required by the outer ordered list, it creates a top-level unordered list<br>
  instead.</p>
<pre><code class="language-markdown">1. List item
  - List item
  - List item
1. List item
</code></pre>
<p>Rationale: Starting lists at the beginning of the line means that nested list<br>
  items can all be indented by the same amount when an editor's indent function<br>
  or the tab key is used to indent. Starting a list 1 space in means that the<br>
  indent of the first nested list is less than the indent of the second level (3<br>
  characters if you use 4 space tabs, or 1 character if you use 2 space tabs).</p>
<p><a name="user-content-md007"></a></p>
<h2 id="md007---unordered-list-indentation">MD007 - Unordered list indentation</h2>
<p>Tags: bullet, ul, indentation</p>
<p>Aliases: ul-indent</p>
<p>Parameters: indent, start_indented (number; default 2, boolean; default false)</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when list items are not indented by the configured<br>
  number of spaces (default: 2).</p>
<p>Example:</p>
<pre><code class="language-markdown">* List item
   * Nested list item indented by 3 spaces
</code></pre>
<p>Corrected Example:</p>
<pre><code class="language-markdown">* List item
  * Nested list item indented by 2 spaces
</code></pre>
<p>Note: This rule applies to a sublist only if its parent lists are all also<br>
  unordered (otherwise, extra indentation of ordered lists interferes with the<br>
  rule).</p>
<p>The <code>start_indented</code> parameter allows the first level of lists to be indented by<br>
  the configured number of spaces rather than starting at zero (the inverse of<br>
  MD006).</p>
<p>Rationale: Indenting by 2 spaces allows the content of a nested list to be in<br>
  line with the start of the content of the parent list when a single space is<br>
  used after the list marker. Indenting by 4 spaces is consistent with code blocks<br>
  and simpler for editors to implement. Additionally, this can be a compatibility<br>
  issue for multi-markdown parsers, which require a 4-space indents. More information:<br><a href="https://cirosantilli.com/markdown-style-guide#indentation-of-content-inside-lists">https://cirosantilli.com/markdown-style-guide#indentation-of-content-inside-lists</a><br>
  and <a href="http://support.markedapp.com/discussions/problems/21-sub-lists-not-indenting">http://support.markedapp.com/discussions/problems/21-sub-lists-not-indenting</a>.</p>
<p><a name="user-content-md009"></a></p>
<h2 id="md009---trailing-spaces">MD009 - Trailing spaces</h2>
<p>Tags: whitespace</p>
<p>Aliases: no-trailing-spaces</p>
<p>Parameters: br_spaces, list_item_empty_lines, strict (number; default 2, boolean; default false, boolean; default false)</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered on any lines that end with unexpected whitespace. To fix this,<br>
  remove the trailing space from the end of the line.</p>
<p>The <code>br_spaces</code> parameter allows an exception to this rule for a specific number<br>
  of trailing spaces, typically used to insert an explicit line break. The default<br>
  value allows 2 spaces to indicate a hard break (&lt;br&gt; element).</p>
<p>Note: You must set <code>br_spaces</code> to a value &gt;= 2 for this parameter to take effect.<br>
  Setting <code>br_spaces</code> to 1 behaves the same as 0, disallowing any trailing spaces.</p>
<p>By default, this rule will not trigger when the allowed number of spaces is used,<br>
  even when it doesn't create a hard break (for example, at the end of a paragraph).<br>
  To report such instances as well, set the <code>strict</code> parameter to <code>true</code>.</p>
<pre><code class="language-markdown">Text text text
text[2 spaces]
</code></pre>
<p>Using spaces to indent blank lines inside a list item is usually not necessary,<br>
  but some parsers require it. Set the <code>list_item_empty_lines</code> parameter to <code>true</code><br>
  to allow this (even when <code>strict</code> is <code>true</code>):</p>
<pre><code class="language-markdown">- list item text
  [2 spaces]
  list item text
</code></pre>
<p>Rationale: Except when being used to create a line break, trailing whitespace<br>
  has no purpose and does not affect the rendering of content.</p>
<p><a name="user-content-md010"></a></p>
<h2 id="md010---hard-tabs">MD010 - Hard tabs</h2>
<p>Tags: whitespace, hard_tab</p>
<p>Aliases: no-hard-tabs</p>
<p>Parameters: code_blocks (boolean; default true)</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered by any lines that contain hard tab characters instead<br>
  of using spaces for indentation. To fix this, replace any hard tab characters<br>
  with spaces instead.</p>
<p>Example:</p>
<pre><code class="language-markdown">Some text

	* hard tab character used to indent the list item
</code></pre>
<p>Corrected example:</p>
<pre><code class="language-markdown">Some text

    * Spaces used to indent the list item instead
</code></pre>
<p>You have the option to exclude this rule for code blocks. To do so, set the<br><code>code_blocks</code> parameter to <code>false</code>. Code blocks are included by default since<br>
  handling of tabs by tools is often inconsistent (ex: using 4 vs. 8 spaces).</p>
<p>Rationale: Hard tabs are often rendered inconsistently by different editors and<br>
  can be harder to work with than spaces.</p>
<p><a name="user-content-md011"></a></p>
<h2 id="md011---reversed-link-syntax">MD011 - Reversed link syntax</h2>
<p>Tags: links</p>
<p>Aliases: no-reversed-links</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when text that appears to be a link is encountered, but<br>
  where the syntax appears to have been reversed (the <code>[]</code> and <code>()</code> are<br>
  reversed):</p>
<pre><code class="language-markdown">(Incorrect link syntax)[https://www.example.com/]
</code></pre>
<p>To fix this, swap the <code>[]</code> and <code>()</code> around:</p>
<pre><code class="language-markdown">[Correct link syntax](https://www.example.com/)
</code></pre>
<p>Note: <a href="https://en.wikipedia.org/wiki/Markdown_Extra">Markdown Extra</a>-style footnotes do not trigger this rule:</p>
<pre><code class="language-markdown">For (example)[^1]
</code></pre>
<p>Rationale: Reversed links are not rendered as usable links.</p>
<p><a name="user-content-md012"></a></p>
<h2 id="md012---multiple-consecutive-blank-lines">MD012 - Multiple consecutive blank lines</h2>
<p>Tags: whitespace, blank_lines</p>
<p>Aliases: no-multiple-blanks</p>
<p>Parameters: maximum (number; default 1)</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when there are multiple consecutive blank lines in the<br>
  document:</p>
<pre><code class="language-markdown">Some text here


Some more text here
</code></pre>
<p>To fix this, delete the offending lines:</p>
<pre><code class="language-markdown">Some text here

Some more text here
</code></pre>
<p>Note: this rule will not be triggered if there are multiple consecutive blank<br>
  lines inside code blocks.</p>
<p>Note: The <code>maximum</code> parameter can be used to configure the maximum number of<br>
  consecutive blank lines.</p>
<p>Rationale: Except in a code block, blank lines serve no purpose and do not<br>
  affect the rendering of content.</p>
<p><a name="user-content-md013"></a></p>
<h2 id="md013---line-length">MD013 - Line length</h2>
<p>Tags: line_length</p>
<p>Aliases: line-length</p>
<p>Parameters: line_length, heading_line_length, code_block_line_length, code_blocks, tables, headings, headers, strict, stern (number; default 80 for *_length, boolean; default true (except strict/stern which default false))</p>
<blockquote>
 <p>If <code>headings</code> is not provided, <code>headers</code> (deprecated) will be used.</p>
</blockquote>
<p>This rule is triggered when there are lines that are longer than the<br>
  configured <code>line_length</code> (default: 80 characters). To fix this, split the line<br>
  up into multiple lines. To set a different maximum length for headings, use<br><code>heading_line_length</code>. To set a different maximum length for code blocks, use<br><code>code_block_line_length</code></p>
<p>This rule has an exception when there is no whitespace beyond the configured<br>
  line length. This allows you to still include items such as long URLs without<br>
  being forced to break them in the middle. To disable this exception, set the<br><code>strict</code> parameter to <code>true</code> to report an issue when any line is too long.<br>
  To warn for lines that are too long and could be fixed but allow lines without<br>
  spaces, set the <code>stern</code> parameter to <code>true</code>.</p>
<p>For example (assuming normal behavior):</p>
<pre><code class="language-markdown">IF THIS LINE IS THE MAXIMUM LENGTH
This line is okay because there are-no-spaces-beyond-that-length
And this line is a violation because there are
This-line-is-also-okay-because-there-are-no-spaces
</code></pre>
<p>In <code>strict</code> or <code>stern</code> modes, the two middle lines above are a violation. The<br>
  third line is a violation in <code>strict</code> mode, but allowed in <code>stern</code> mode.</p>
<p>You have the option to exclude this rule for code blocks, tables, or headings.<br>
  To do so, set the <code>code_blocks</code>, <code>tables</code>, or <code>headings</code> parameter(s) to false.</p>
<p>Code blocks are included in this rule by default since it is often a<br>
  requirement for document readability, and tentatively compatible with code<br>
  rules. Still, some languages do not lend themselves to short lines.</p>
<p>Rationale: Extremely long lines can be difficult to work with in some editors.<br>
  More information: <a href="https://cirosantilli.com/markdown-style-guide#line-wrapping">https://cirosantilli.com/markdown-style-guide#line-wrapping</a>.</p>
<p><a name="user-content-md014"></a></p>
<h2 id="md014---dollar-signs-used-before-commands-without-showing-output">MD014 - Dollar signs used before commands without showing output</h2>
<p>Tags: code</p>
<p>Aliases: commands-show-output</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when there are code blocks showing shell commands to be<br>
  typed, and <em>all</em> of the shell commands are preceded by dollar signs ($):</p>
<pre><code class="language-markdown">$ ls
$ cat foo
$ less bar
</code></pre>
<p>The dollar signs are unnecessary in this situation, and should not be<br>
  included:</p>
<pre><code class="language-markdown">ls
cat foo
less bar
</code></pre>
<p>Showing output for commands preceded by dollar signs does not trigger this rule:</p>
<pre><code class="language-markdown">$ ls
foo bar
$ cat foo
Hello world
$ cat bar
baz
</code></pre>
<p>Because some commands do not produce output, it is not a violation if <em>some</em><br>
  commands do not have output:</p>
<pre><code class="language-markdown">$ mkdir test
mkdir: created directory 'test'
$ ls test
</code></pre>
<p>Rationale: It is easier to copy/paste and less noisy if the dollar signs<br>
  are omitted when they are not needed. See<br><a href="https://cirosantilli.com/markdown-style-guide#dollar-signs-in-shell-code">https://cirosantilli.com/markdown-style-guide#dollar-signs-in-shell-code</a><br>
  for more information.</p>
<p><a name="user-content-md018"></a></p>
<h2 id="md018---no-space-after-hash-on-atx-style-heading">MD018 - No space after hash on atx style heading</h2>
<p>Tags: headings, headers, atx, spaces</p>
<p>Aliases: no-missing-space-atx</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when spaces are missing after the hash characters<br>
  in an atx style heading:</p>
<pre><code class="language-markdown">#Heading 1

##Heading 2
</code></pre>
<p>To fix this, separate the heading text from the hash character by a single<br>
  space:</p>
<pre><code class="language-markdown"># Heading 1

## Heading 2
</code></pre>
<p>Rationale: Violations of this rule can lead to improperly rendered content.</p>
<p><a name="user-content-md019"></a></p>
<h2 id="md019---multiple-spaces-after-hash-on-atx-style-heading">MD019 - Multiple spaces after hash on atx style heading</h2>
<p>Tags: headings, headers, atx, spaces</p>
<p>Aliases: no-multiple-space-atx</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when more than one space is used to separate the<br>
  heading text from the hash characters in an atx style heading:</p>
<pre><code class="language-markdown">#  Heading 1

##  Heading 2
</code></pre>
<p>To fix this, separate the heading text from the hash character by a single<br>
  space:</p>
<pre><code class="language-markdown"># Heading 1

## Heading 2
</code></pre>
<p>Rationale: Extra space has no purpose and does not affect the rendering of<br>
  content.</p>
<p><a name="user-content-md020"></a></p>
<h2 id="md020---no-space-inside-hashes-on-closed-atx-style-heading">MD020 - No space inside hashes on closed atx style heading</h2>
<p>Tags: headings, headers, atx_closed, spaces</p>
<p>Aliases: no-missing-space-closed-atx</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when spaces are missing inside the hash characters<br>
  in a closed atx style heading:</p>
<pre><code class="language-markdown">#Heading 1#

##Heading 2##
</code></pre>
<p>To fix this, separate the heading text from the hash character by a single<br>
  space:</p>
<pre><code class="language-markdown"># Heading 1 #

## Heading 2 ##
</code></pre>
<p>Note: this rule will fire if either side of the heading is missing spaces.</p>
<p>Rationale: Violations of this rule can lead to improperly rendered content.</p>
<p><a name="user-content-md021"></a></p>
<h2 id="md021---multiple-spaces-inside-hashes-on-closed-atx-style-heading">MD021 - Multiple spaces inside hashes on closed atx style heading</h2>
<p>Tags: headings, headers, atx_closed, spaces</p>
<p>Aliases: no-multiple-space-closed-atx</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when more than one space is used to separate the<br>
  heading text from the hash characters in a closed atx style heading:</p>
<pre><code class="language-markdown">#  Heading 1  #

##  Heading 2  ##
</code></pre>
<p>To fix this, separate the heading text from the hash character by a single<br>
  space:</p>
<pre><code class="language-markdown"># Heading 1 #

## Heading 2 ##
</code></pre>
<p>Note: this rule will fire if either side of the heading contains multiple<br>
  spaces.</p>
<p>Rationale: Extra space has no purpose and does not affect the rendering of<br>
  content.</p>
<p><a name="user-content-md022"></a></p>
<h2 id="md022---headings-should-be-surrounded-by-blank-lines">MD022 - Headings should be surrounded by blank lines</h2>
<p>Tags: headings, headers, blank_lines</p>
<p>Aliases: blanks-around-headings, blanks-around-headers</p>
<p>Parameters: lines_above, lines_below (number; default 1)</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when headings (any style) are either not preceded or not<br>
  followed by at least one blank line:</p>
<pre><code class="language-markdown"># Heading 1
Some text

Some more text
## Heading 2
</code></pre>
<p>To fix this, ensure that all headings have a blank line both before and after<br>
  (except where the heading is at the beginning or end of the document):</p>
<pre><code class="language-markdown"># Heading 1

Some text

Some more text

## Heading 2
</code></pre>
<p>The <code>lines_above</code> and <code>lines_below</code> parameters can be used to specify a different<br>
  number of blank lines (including 0) above or below each heading.</p>
<p>Note: If <code>lines_above</code> or <code>lines_below</code> are configured to require more than one<br>
  blank line, <a href="https://blog.ccrui.cn#md012">MD012/no-multiple-blanks</a> should also be customized.</p>
<p>Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will<br>
  not parse headings that don't have a blank line before, and will parse them as<br>
  regular text.</p>
<p><a name="user-content-md023"></a></p>
<h2 id="md023---headings-must-start-at-the-beginning-of-the-line">MD023 - Headings must start at the beginning of the line</h2>
<p>Tags: headings, headers, spaces</p>
<p>Aliases: heading-start-left, header-start-left</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when a heading is indented by one or more spaces:</p>
<pre><code class="language-markdown">Some text

  # Indented heading
</code></pre>
<p>To fix this, ensure that all headings start at the beginning of the line:</p>
<pre><code class="language-markdown">Some text

# Heading
</code></pre>
<p>Rationale: Headings that don't start at the beginning of the line will not be<br>
  parsed as headings, and will instead appear as regular text.</p>
<p><a name="user-content-md024"></a></p>
<h2 id="md024---multiple-headings-with-the-same-content">MD024 - Multiple headings with the same content</h2>
<p>Tags: headings, headers</p>
<p>Aliases: no-duplicate-heading, no-duplicate-header</p>
<p>Parameters: siblings_only, allow_different_nesting (boolean; default <code>false</code>)</p>
<p>This rule is triggered if there are multiple headings in the document that have<br>
  the same text:</p>
<pre><code class="language-markdown"># Some text

## Some text
</code></pre>
<p>To fix this, ensure that the content of each heading is different:</p>
<pre><code class="language-markdown"># Some text

## Some more text
</code></pre>
<p>If the parameter <code>siblings_only</code> (alternatively <code>allow_different_nesting</code>) is<br>
  set to <code>true</code>, heading duplication is allowed for non-sibling headings (common<br>
  in change logs):</p>
<pre><code class="language-markdown"># Change log

## 1.0.0

### Features

## 2.0.0

### Features
</code></pre>
<p>Rationale: Some markdown parsers generate anchors for headings based on the<br>
  heading name; headings with the same content can cause problems with that.</p>
<p><a name="user-content-md025"></a></p>
<h2 id="md025---multiple-top-level-headings-in-the-same-document">MD025 - Multiple top level headings in the same document</h2>
<p>Tags: headings, headers</p>
<p>Aliases: single-title, single-h1</p>
<p>Parameters: level, front_matter_title (number; default 1, string; default "^\s*title:")</p>
<p>This rule is triggered when a top level heading is in use (the first line of<br>
  the file is an h1 heading), and more than one h1 heading is in use in the<br>
  document:</p>
<pre><code class="language-markdown"># Top level heading

# Another top level heading
</code></pre>
<p>To fix, structure your document so that there is a single h1 heading that is<br>
  the title for the document, and all later headings are h2 or lower level<br>
  headings:</p>
<pre><code class="language-markdown"># Title

## Heading

## Another heading
</code></pre>
<p>Note: The <code>level</code> parameter can be used to change the top level (ex: to h2) in<br>
  cases where an h1 is added externally.</p>
<p>If <a href="https://en.wikipedia.org/wiki/YAML">YAML</a> front matter is present and contains<br>
  a <code>title</code> property (commonly used with blog posts), this rule treats that as a top<br>
  level heading and will report a violation for any subsequent top level headings.<br>
  To use a different property name in front matter, specify the text of a regular<br>
  expression via the <code>front_matter_title</code> parameter. To disable the use of front<br>
  matter by this rule, specify <code>""</code> for <code>front_matter_title</code>.</p>
<p>Rationale: A top level heading is an h1 on the first line of the file, and<br>
  serves as the title for the document. If this convention is in use, then there<br>
  can not be more than one title for the document, and the entire document<br>
  should be contained within this heading.</p>
<p><a name="user-content-md026"></a></p>
<h2 id="md026---trailing-punctuation-in-heading">MD026 - Trailing punctuation in heading</h2>
<p>Tags: headings, headers</p>
<p>Aliases: no-trailing-punctuation</p>
<p>Parameters: punctuation (string; default ".,;:!?。，；：！？")</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered on any heading that has one of the specified normal or<br>
  full-width punctuation characters as the last character in the line:</p>
<pre><code class="language-markdown"># This is a heading.
</code></pre>
<p>To fix this, remove the trailing punctuation:</p>
<pre><code class="language-markdown"># This is a heading
</code></pre>
<p>Note: The <code>punctuation</code> parameter can be used to specify what characters count<br>
  as punctuation at the end of a heading. For example, you can change it to<br><code>".,;:!"</code> to allow headings that end with a question mark, such as in an FAQ.<br>
  Setting the <code>punctuation</code> parameter to <code>""</code> allows all characters - and is<br>
  equivalent to disabling the rule.</p>
<p>Rationale: Headings are not meant to be full sentences. More information:<br><a href="https://cirosantilli.com/markdown-style-guide#punctuation-at-the-end-of-headers">https://cirosantilli.com/markdown-style-guide#punctuation-at-the-end-of-headers</a></p>
<p><a name="user-content-md027"></a></p>
<h2 id="md027---multiple-spaces-after-blockquote-symbol">MD027 - Multiple spaces after blockquote symbol</h2>
<p>Tags: blockquote, whitespace, indentation</p>
<p>Aliases: no-multiple-space-blockquote</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when blockquotes have more than one space after the<br>
  blockquote (<code>&gt;</code>) symbol:</p>
<pre><code class="language-markdown">&gt;  This is a block quote with bad indentation
&gt;  there should only be one.
</code></pre>
<p>To fix, remove any extraneous space:</p>
<pre><code class="language-markdown">&gt; This is a blockquote with correct
&gt; indentation.
</code></pre>
<p>Rationale: Consistent formatting makes it easier to understand a document.</p>
<p><a name="user-content-md028"></a></p>
<h2 id="md028---blank-line-inside-blockquote">MD028 - Blank line inside blockquote</h2>
<p>Tags: blockquote, whitespace</p>
<p>Aliases: no-blanks-blockquote</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when two blockquote blocks are separated by nothing<br>
  except for a blank line:</p>
<pre><code class="language-markdown">&gt; This is a blockquote
&gt; which is immediately followed by

&gt; this blockquote. Unfortunately
&gt; In some parsers, these are treated as the same blockquote.
</code></pre>
<p>To fix this, ensure that any blockquotes that are right next to each other<br>
  have some text in between:</p>
<pre><code class="language-markdown">&gt; This is a blockquote.

And Jimmy also said:

&gt; This too is a blockquote.
</code></pre>
<p>Alternatively, if they are supposed to be the same quote, then add the<br>
  blockquote symbol at the beginning of the blank line:</p>
<pre><code class="language-markdown">&gt; This is a blockquote.
&gt;
&gt; This is the same blockquote.
</code></pre>
<p>Rationale: Some markdown parsers will treat two blockquotes separated by one<br>
  or more blank lines as the same blockquote, while others will treat them as<br>
  separate blockquotes.</p>
<p><a name="user-content-md029"></a></p>
<h2 id="md029---ordered-list-item-prefix">MD029 - Ordered list item prefix</h2>
<p>Tags: ol</p>
<p>Aliases: ol-prefix</p>
<p>Parameters: style ("one", "ordered", "one_or_ordered", "zero"; default "one_or_ordered")</p>
<p>This rule is triggered for ordered lists that do not either start with '1.' or<br>
  do not have a prefix that increases in numerical order (depending on the<br>
  configured style). The less-common patterns of using '0.' as a first prefix or<br>
  for all prefixes is also supported.</p>
<p>Example valid list if the style is configured as 'one':</p>
<pre><code class="language-markdown">1. Do this.
1. Do that.
1. Done.
</code></pre>
<p>Examples of valid lists if the style is configured as 'ordered':</p>
<pre><code class="language-markdown">1. Do this.
2. Do that.
3. Done.
</code></pre>
<pre><code class="language-markdown">0. Do this.
1. Do that.
2. Done.
</code></pre>
<p>All three examples are valid when the style is configured as 'one_or_ordered'.</p>
<p>Example valid list if the style is configured as 'zero':</p>
<pre><code class="language-markdown">0. Do this.
0. Do that.
0. Done.
</code></pre>
<p>Example invalid list for all styles:</p>
<pre><code class="language-markdown">1. Do this.
3. Done.
</code></pre>
<p>This rule supports 0-prefixing ordered list items for uniform indentation:</p>
<pre><code class="language-markdown">...
08. Item
09. Item
10. Item
11. Item
...
</code></pre>
<p>Note: This rule will report violations for cases like the following where an improperly-indented code block (or similar) appears between two list items and "breaks" the list in two:</p>
<pre><code class="language-markdown">1. First list

```text
Code block
```

1. Second list
</code></pre>
<p>The fix is to indent the code block so it becomes part of the preceding list item as intended:</p>
<pre><code class="language-markdown">1. First list

   ```text
   Code block
   ```

2. Still first list
</code></pre>
<p>Rationale: Consistent formatting makes it easier to understand a document.</p>
<p><a name="user-content-md030"></a></p>
<h2 id="md030---spaces-after-list-markers">MD030 - Spaces after list markers</h2>
<p>Tags: ol, ul, whitespace</p>
<p>Aliases: list-marker-space</p>
<p>Parameters: ul_single, ol_single, ul_multi, ol_multi (number; default 1)</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule checks for the number of spaces between a list marker (e.g. '<code>-</code>',<br>
  '<code>*</code>', '<code>+</code>' or '<code>1.</code>') and the text of the list item.</p>
<p>The number of spaces checked for depends on the document style in use, but the<br>
  default is 1 space after any list marker:</p>
<pre><code class="language-markdown">* Foo
* Bar
* Baz

1. Foo
1. Bar
1. Baz

1. Foo
   * Bar
1. Baz
</code></pre>
<p>A document style may change the number of spaces after unordered list items<br>
  and ordered list items independently, as well as based on whether the content<br>
  of every item in the list consists of a single paragraph, or multiple<br>
  paragraphs (including sub-lists and code blocks).</p>
<p>For example, the style guide at<br><a href="https://cirosantilli.com/markdown-style-guide#spaces-after-list-marker">https://cirosantilli.com/markdown-style-guide#spaces-after-list-marker</a><br>
  specifies that 1 space after the list marker should be used if every item in<br>
  the list fits within a single paragraph, but to use 2 or 3 spaces (for ordered<br>
  and unordered lists respectively) if there are multiple paragraphs of content<br>
  inside the list:</p>
<pre><code class="language-markdown">* Foo
* Bar
* Baz
</code></pre>
<p>vs.</p>
<pre><code class="language-markdown">*   Foo

    Second paragraph

*   Bar
</code></pre>
<p>or</p>
<pre><code class="language-markdown">1.  Foo

    Second paragraph

1.  Bar
</code></pre>
<p>To fix this, ensure the correct number of spaces are used after list marker<br>
  for your selected document style.</p>
<p>Rationale: Violations of this rule can lead to improperly rendered content.</p>
<p><a name="user-content-md031"></a></p>
<h2 id="md031---fenced-code-blocks-should-be-surrounded-by-blank-lines">MD031 - Fenced code blocks should be surrounded by blank lines</h2>
<p>Tags: code, blank_lines</p>
<p>Aliases: blanks-around-fences</p>
<p>Parameters: list_items (boolean; default true)</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when fenced code blocks are either not preceded or not<br>
  followed by a blank line:</p>
<pre><code class="language-markdown">Some text
```
Code block
```

```
Another code block
```
Some more text
</code></pre>
<p>To fix this, ensure that all fenced code blocks have a blank line both before<br>
  and after (except where the block is at the beginning or end of the document):</p>
<pre><code class="language-markdown">Some text

```
Code block
```

```
Another code block
```

Some more text
</code></pre>
<p>Set the <code>list_items</code> parameter to <code>false</code> to disable this rule for list items.<br>
  Disabling this behavior for lists can be useful if it is necessary to create a<br><a href="https://spec.commonmark.org/0.29/#tight">tight</a> list containing a code fence.</p>
<p>Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will<br>
  not parse fenced code blocks that don't have blank lines before and after them.</p>
<p><a name="user-content-md032"></a></p>
<h2 id="md032---lists-should-be-surrounded-by-blank-lines">MD032 - Lists should be surrounded by blank lines</h2>
<p>Tags: bullet, ul, ol, blank_lines</p>
<p>Aliases: blanks-around-lists</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when lists (of any kind) are either not preceded or not<br>
  followed by a blank line:</p>
<pre><code class="language-markdown">Some text
* Some
* List

1. Some
2. List
Some text
</code></pre>
<p>To fix this, ensure that all lists have a blank line both before and after<br>
  (except where the block is at the beginning or end of the document):</p>
<pre><code class="language-markdown">Some text

* Some
* List

1. Some
2. List

Some text
</code></pre>
<p>Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will<br>
  not parse lists that don't have blank lines before and after them.</p>
<p><a name="user-content-md033"></a></p>
<h2 id="md033---inline-html">MD033 - Inline HTML</h2>
<p>Tags: html</p>
<p>Aliases: no-inline-html</p>
<p>Parameters: allowed_elements (array of string; default empty)</p>
<p>This rule is triggered whenever raw HTML is used in a markdown document:</p>
<pre><code class="language-markdown">&lt;h1&gt;Inline HTML heading&lt;/h1&gt;
</code></pre>
<p>To fix this, use 'pure' markdown instead of including raw HTML:</p>
<pre><code class="language-markdown"># Markdown heading
</code></pre>
<p>Note: To allow specific HTML elements, use the 'allowed_elements' parameter.</p>
<p>Rationale: Raw HTML is allowed in markdown, but this rule is included for<br>
  those who want their documents to only include "pure" markdown, or for those<br>
  who are rendering markdown documents in something other than HTML.</p>
<p><a name="user-content-md034"></a></p>
<h2 id="md034---bare-url-used">MD034 - Bare URL used</h2>
<p>Tags: links, url</p>
<p>Aliases: no-bare-urls</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered whenever a URL is given that isn't surrounded by angle<br>
  brackets:</p>
<pre><code class="language-markdown">For more information, see https://www.example.com/.
</code></pre>
<p>To fix this, add angle brackets around the URL:</p>
<pre><code class="language-markdown">For more information, see &lt;https://www.example.com/&gt;.
</code></pre>
<p>Note: To use a bare URL without it being converted into a link, enclose it in<br>
  a code block, otherwise in some markdown parsers it <em>will</em> be converted:</p>
<pre><code class="language-markdown">`https://www.example.com`
</code></pre>
<p>Note: The following scenario does <em>not</em> trigger this rule to avoid conflicts<br>
  with <code>MD011</code>/<code>no-reversed-links</code>:</p>
<pre><code class="language-markdown">[https://www.example.com]
</code></pre>
<p>The use of quotes around a bare link will <em>not</em> trigger this rule, either:</p>
<pre><code class="language-markdown">"https://www.example.com"
'https://www.example.com'
</code></pre>
<p>Rationale: Without angle brackets, the URL isn't converted into a link by many<br>
  markdown parsers.</p>
<p><a name="user-content-md035"></a></p>
<h2 id="md035---horizontal-rule-style">MD035 - Horizontal rule style</h2>
<p>Tags: hr</p>
<p>Aliases: hr-style</p>
<p>Parameters: style ("consistent", "---", "***", or other string specifying the<br>
  horizontal rule; default "consistent")</p>
<p>This rule is triggered when inconsistent styles of horizontal rules are used<br>
  in the document:</p>
<pre><code class="language-markdown">---

- - -

***

* * *

****
</code></pre>
<p>To fix this, ensure any horizontal rules used in the document are consistent,<br>
  or match the given style if the rule is so configured:</p>
<pre><code class="language-markdown">---

---
</code></pre>
<p>Note: by default, this rule is configured to just require that all horizontal<br>
  rules in the document are the same, and will trigger if any of the horizontal<br>
  rules are different than the first one encountered in the document. If you<br>
  want to configure the rule to match a specific style, the parameter given to<br>
  the 'style' option is a string containing the exact horizontal rule text that<br>
  is allowed.</p>
<p>Rationale: Consistent formatting makes it easier to understand a document.</p>
<p><a name="user-content-md036"></a></p>
<h2 id="md036---emphasis-used-instead-of-a-heading">MD036 - Emphasis used instead of a heading</h2>
<p>Tags: headings, headers, emphasis</p>
<p>Aliases: no-emphasis-as-heading, no-emphasis-as-header</p>
<p>Parameters: punctuation (string; default ".,;:!?。，；：！？")</p>
<p>This check looks for instances where emphasized (i.e. bold or italic) text is<br>
  used to separate sections, where a heading should be used instead:</p>
<pre><code class="language-markdown">**My document**

Lorem ipsum dolor sit amet...

_Another section_

Consectetur adipiscing elit, sed do eiusmod.
</code></pre>
<p>To fix this, use markdown headings instead of emphasized text to denote<br>
  sections:</p>
<pre><code class="language-markdown"># My document

Lorem ipsum dolor sit amet...

## Another section

Consectetur adipiscing elit, sed do eiusmod.
</code></pre>
<p>Note: This rule looks for single line paragraphs that consist entirely<br>
  of emphasized text. It won't fire on emphasis used within regular text,<br>
  multi-line emphasized paragraphs, or paragraphs ending in punctuation<br>
  (normal or full-width). Similarly to rule MD026, you can configure what<br>
  characters are recognized as punctuation.</p>
<p>Rationale: Using emphasis instead of a heading prevents tools from inferring<br>
  the structure of a document. More information:<br><a href="https://cirosantilli.com/markdown-style-guide#emphasis-vs-headers">https://cirosantilli.com/markdown-style-guide#emphasis-vs-headers</a>.</p>
<p><a name="user-content-md037"></a></p>
<h2 id="md037---spaces-inside-emphasis-markers">MD037 - Spaces inside emphasis markers</h2>
<p>Tags: whitespace, emphasis</p>
<p>Aliases: no-space-in-emphasis</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when emphasis markers (bold, italic) are used, but they<br>
  have spaces between the markers and the text:</p>
<pre><code class="language-markdown">Here is some ** bold ** text.

Here is some * italic * text.

Here is some more __ bold __ text.

Here is some more _ italic _ text.
</code></pre>
<p>To fix this, remove the spaces around the emphasis markers:</p>
<pre><code class="language-markdown">Here is some **bold** text.

Here is some *italic* text.

Here is some more __bold__ text.

Here is some more _italic_ text.
</code></pre>
<p>Rationale: Emphasis is only parsed as such when the asterisks/underscores<br>
  aren't completely surrounded by spaces. This rule attempts to detect where<br>
  they were surrounded by spaces, but it appears that emphasized text was<br>
  intended by the author.</p>
<p><a name="user-content-md038"></a></p>
<h2 id="md038---spaces-inside-code-span-elements">MD038 - Spaces inside code span elements</h2>
<p>Tags: whitespace, code</p>
<p>Aliases: no-space-in-code</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered for code span elements that have spaces adjacent to the<br>
  backticks:</p>
<pre><code class="language-markdown">`some text `

` some text`
</code></pre>
<p>To fix this, remove any spaces adjacent to the backticks:</p>
<pre><code class="language-markdown">`some text`
</code></pre>
<p>Note: A single leading and trailing space is allowed by the specification and<br>
  automatically trimmed (to allow for embedded backticks):</p>
<pre><code class="language-markdown">`` `backticks` ``
</code></pre>
<p>Note: A single leading or trailing space is allowed if used to separate codespan<br>
  markers from an embedded backtick:</p>
<pre><code class="language-markdown">`` ` embedded backtick``
</code></pre>
<p>Rationale: Violations of this rule can lead to improperly rendered content.</p>
<p><a name="user-content-md039"></a></p>
<h2 id="md039---spaces-inside-link-text">MD039 - Spaces inside link text</h2>
<p>Tags: whitespace, links</p>
<p>Aliases: no-space-in-links</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered on links that have spaces surrounding the link text:</p>
<pre><code class="language-markdown">[ a link ](https://www.example.com/)
</code></pre>
<p>To fix this, remove the spaces surrounding the link text:</p>
<pre><code class="language-markdown">[a link](https://www.example.com/)
</code></pre>
<p>Rationale: Consistent formatting makes it easier to understand a document.</p>
<p><a name="user-content-md040"></a></p>
<h2 id="md040---fenced-code-blocks-should-have-a-language-specified">MD040 - Fenced code blocks should have a language specified</h2>
<p>Tags: code, language</p>
<p>Aliases: fenced-code-language</p>
<p>This rule is triggered when fenced code blocks are used, but a language isn't<br>
  specified:</p>
<pre><code class="language-markdown">
```
#!/bin/bash
echo Hello world
```

</code></pre>
<p>To fix this, add a language specifier to the code block:</p>
<pre><code class="language-markdown">​```bash
#!/bin/bash
echo Hello world
```
</code></pre>
<p>Rationale: Specifying a language improves content rendering by using the<br>
  correct syntax highlighting for code. More information:<br><a href="https://cirosantilli.com/markdown-style-guide#option-code-fenced">https://cirosantilli.com/markdown-style-guide#option-code-fenced</a>.</p>
<p><a name="user-content-md041"></a></p>
<h2 id="md041---first-line-in-file-should-be-a-top-level-heading">MD041 - First line in file should be a top level heading</h2>
<p>Tags: headings, headers</p>
<p>Aliases: first-line-heading, first-line-h1</p>
<p>Parameters: level, front_matter_title (number; default 1, string; default "^\s*title:")</p>
<p>This rule is intended to ensure documents have a title and is triggered when<br>
  the first line in the file isn't a top level (h1) heading:</p>
<p>​```markdown<br>
  This is a file without a heading</p>
<pre><code>
To fix this, add a top level heading to the beginning of the file:

```markdown
# File with heading

This is a file with a top level heading
</code></pre>
<p>Note: The <code>level</code> parameter can be used to change the top level (ex: to h2) in cases<br>
  where an h1 is added externally.</p>
<p>If <a href="https://en.wikipedia.org/wiki/YAML">YAML</a> front matter is present and contains a<br><code>title</code> property (commonly used with blog posts), this rule will not report a<br>
  violation. To use a different property name in front matter, specify the text<br>
  of a regular expression via the <code>front_matter_title</code> parameter. To disable the<br>
  use of front matter by this rule, specify <code>""</code> for <code>front_matter_title</code>.</p>
<p>Rationale: The top level heading often acts as the title of a document. More<br>
  information: <a href="https://cirosantilli.com/markdown-style-guide#top-level-header">https://cirosantilli.com/markdown-style-guide#top-level-header</a>.</p>
<p><a name="user-content-md042"></a></p>
<h2 id="md042---no-empty-links">MD042 - No empty links</h2>
<p>Tags: links</p>
<p>Aliases: no-empty-links</p>
<p>This rule is triggered when an empty link is encountered:</p>
<pre><code class="language-markdown">[an empty link]()
</code></pre>
<p>To fix the violation, provide a destination for the link:</p>
<pre><code class="language-markdown">[a valid link](https://example.com/)
</code></pre>
<p>Empty fragments will trigger this rule:</p>
<pre><code class="language-markdown">[an empty fragment](#)
</code></pre>
<p>But non-empty fragments will not:</p>
<pre><code class="language-markdown">[a valid fragment](#fragment)
</code></pre>
<p>Rationale: Empty links do not lead anywhere and therefore don't function as links.</p>
<p><a name="user-content-md043"></a></p>
<h2 id="md043---required-heading-structure">MD043 - Required heading structure</h2>
<p>Tags: headings, headers</p>
<p>Aliases: required-headings, required-headers</p>
<p>Parameters: headings, headers (array of string; default <code>null</code> for disabled)</p>
<blockquote>
 <p>If <code>headings</code> is not provided, <code>headers</code> (deprecated) will be used.</p>
</blockquote>
<p>This rule is triggered when the headings in a file do not match the array of<br>
  headings passed to the rule. It can be used to enforce a standard heading<br>
  structure for a set of files.</p>
<p>To require exactly the following structure:</p>
<pre><code class="language-markdown"># Head
## Item
### Detail
</code></pre>
<p>Set the <code>headings</code> parameter to:</p>
<pre><code class="language-json">[
    "# Head",
    "## Item",
    "### Detail"
]
</code></pre>
<p>To allow optional headings as with the following structure:</p>
<pre><code class="language-markdown"># Head
## Item
### Detail (optional)
## Foot
### Notes (optional)
</code></pre>
<p>Use the special value <code>"*"</code> meaning "one or more unspecified headings" and set<br>
  the <code>headings</code> parameter to:</p>
<pre><code class="language-json">[
    "# Head",
    "## Item",
    "*",
    "## Foot",
    "*"
]
</code></pre>
<p>When an error is detected, this rule outputs the line number of the first<br>
  problematic heading (otherwise, it outputs the last line number of the file).</p>
<p>Note that while the <code>headings</code> parameter uses the "## Text" ATX heading style for<br>
  simplicity, a file may use any supported heading style.</p>
<p>Rationale: Projects may wish to enforce a consistent document structure across<br>
  a set of similar content.</p>
<p><a name="user-content-md044"></a></p>
<h2 id="md044---proper-names-should-have-the-correct-capitalization">MD044 - Proper names should have the correct capitalization</h2>
<p>Tags: spelling</p>
<p>Aliases: proper-names</p>
<p>Parameters: names, code_blocks (string array; default <code>null</code>, boolean; default <code>true</code>)</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when any of the strings in the <code>names</code> array do not have<br>
  the specified capitalization. It can be used to enforce a standard letter case<br>
  for the names of projects and products.</p>
<p>For example, the language "JavaScript" is usually written with both the 'J' and<br>
  'S' capitalized - though sometimes the 's' or 'j' appear in lower-case. To enforce<br>
  the proper capitalization, specify the desired letter case in the <code>names</code> array:</p>
<pre><code class="language-json">[
    "JavaScript"
]
</code></pre>
<p>Set the <code>code_blocks</code> parameter to <code>false</code> to disable this rule for code blocks.</p>
<p>Rationale: Incorrect capitalization of proper names is usually a mistake.</p>
<p><a name="user-content-md045"></a></p>
<h2 id="md045---images-should-have-alternate-text-alt-text">MD045 - Images should have alternate text (alt text)</h2>
<p>Tags: accessibility, images</p>
<p>Aliases: no-alt-text</p>
<p>This rule is triggered when an image is missing alternate text (alt text) information.</p>
<p>Alternate text is commonly specified inline as:</p>
<pre><code class="language-markdown">![Alternate text](image.jpg)
</code></pre>
<p>Or with reference syntax as:</p>
<pre><code class="language-markdown">![Alternate text][ref]

...

[ref]: image.jpg "Optional title"
</code></pre>
<p>Guidance for writing alternate text is available from the <a href="https://www.w3.org/WAI/alt/">W3C</a>,<br><a href="https://en.wikipedia.org/wiki/Alt_attribute">Wikipedia</a>, and<br><a href="https://www.phase2technology.com/blog/no-more-excuses-definitive-guide-alt-text-field">other locations</a>.</p>
<p>Rationale: Alternate text is important for accessibility and describes the<br>
  content of an image for people who may not be able to see it.</p>
<p><a name="user-content-md046"></a></p>
<h2 id="md046---code-block-style">MD046 - Code block style</h2>
<p>Tags: code</p>
<p>Aliases: code-block-style</p>
<p>Parameters: style ("consistent", "fenced", "indented"; default "consistent")</p>
<p>This rule is triggered when unwanted or different code block styles are used in<br>
  the same document.</p>
<p>In the default configuration this rule reports a violation for the following document:</p>
<pre><code>Some text.

    # Indented code

More text.

```ruby
# Fenced code
```

More text.
</code></pre>
<p>To fix violations of this rule, use a consistent style (either indenting or code fences).</p>
<p>The specified style can be specific (<code>fenced</code>, <code>indented</code>) or simply require that usage<br>
  be consistent within the document (<code>consistent</code>).</p>
<p>Rationale: Consistent formatting makes it easier to understand a document.</p>
<p><a name="user-content-md047"></a></p>
<h2 id="md047---files-should-end-with-a-single-newline-character">MD047 - Files should end with a single newline character</h2>
<p>Tags: blank_lines</p>
<p>Aliases: single-trailing-newline</p>
<p>Fixable: Most violations can be fixed by tooling</p>
<p>This rule is triggered when there is not a single newline character at the end of a file.</p>
<p>Example that triggers the rule:</p>
<pre><code class="language-markdown"># Heading

This file ends without a newline.[EOF]
</code></pre>
<p>To fix the violation, add a newline character to the end of the file:</p>
<pre><code class="language-markdown"># Heading

This file ends with a newline.
[EOF]
</code></pre>
<p>Rationale: Some programs have trouble with files that do not end with a newline.<br>
  More information: <a href="https://unix.stackexchange.com/questions/18743/whats-the-point-in-adding-a-new-line-to-the-end-of-a-file">https://unix.stackexchange.com/questions/18743/whats-the-point-in-adding-a-new-line-to-the-end-of-a-file</a>.</p>
<p><a name="user-content-md048"></a></p>
<h2 id="md048---code-fence-style">MD048 - Code fence style</h2>
<p>Tags: code</p>
<p>Aliases: code-fence-style</p>
<p>Parameters: style ("consistent", "tilde", "backtick"; default "consistent")</p>
<p>This rule is triggered when the symbols used in the document for fenced code blocks do not match the configured code fence style:</p>
<pre><code class="language-markdown">​```ruby
# Fenced code
```

~~~ruby
# Fenced code
~~~
</code></pre>
<p>To fix this issue, use the configured code fence style throughout the<br>
  document:</p>
<p>​````markdown<br>
  ​```ruby</p>
<h1 id="fenced-code">Fenced code</h1>
<pre><code>
```ruby
# Fenced code
</code></pre>
<pre><code>
The configured list style can be a specific symbol to use (backtick, tilde), or
can require that usage be consistent within the document.

Rationale: Consistent formatting makes it easier to understand a document.

</code></pre>]]></description><guid isPermaLink="false">/archives/44.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sun, 12 Jul 2020 11:11:00 GMT</pubDate></item><item><title><![CDATA[handsome主题常用操作]]></title><link>https://blog.ccrui.cn/archives/19.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=handsome%E4%B8%BB%E9%A2%98%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C&amp;url=/archives/19.html" width="1" height="1" alt="" style="opacity:0;">
<blockquote>
 <p><a href="https://handsome.ihewro.com/">完整版使用文档</a></p>
</blockquote>
<h2 id="文章中插入短代码高亮文本">文章中插入短代码高亮文本</h2>
<pre><code class="language-html">[scode type="share"]这是灰色的短代码框，常用来引用资料什么的[/scode]
[scode type='yellow']这是黄色的短代码框，常用来做提示，引起读者注意。[/scode]
[scode type='red']这是红色的短代码框，用于严重警告什么的。[/scode]
[scode type="blue"]这是浅蓝色的短代码框，用于显示一些信息。[/scode]
[scode type="green"]这是绿色的短代码框，显示一些推荐信息。[/scode]
</code></pre>
<h3 id="显示效果">显示效果</h3>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F11%2FSnipaste_2020-07-11_23-49-25.png&amp;size=m" alt="常用操作"></p>
<h2 id="更新主题">更新主题</h2>
<p>先删除/usr/themes/handsome/目录中的内容，然后新主题中的内容复制到/usr/themes/handsome/目录。</p>
<p><strong>注意<br>
   切换主题的时候typecho会自动清空上一个主题的所有备份数据，备份数据存储在数据库中。</strong></p>
<p><strong>只要不切换主题，删除主题旧版本主题文件夹再上传新版本主题文件夹，是不会丢失以前的配置数据。</strong></p>
<h2 id="备份外观设置">备份外观设置</h2>
<p>切换主题，会自动清空当前被切换的主题的外观数据，但是如果你备份了数据，切换主题，再切换回来通过恢复备份就可以恢复之前的数据了。</p>
<h2 id="添加友情链接">添加友情链接</h2>
<p><strong>一定要填写链接分类！！！否则前台不会输出任何信息。</strong></p>
<h3 id="关于链接分类的说明"><em>关于链接分类的说明：</em></h3>
<p>ten ：是全站链接，就是在首页的左侧边栏展示的<br>
  one ：是内页链接，在独立页面中的自定义模板友情链接中显示<br>
  good ：是推荐链接，在独立页面的自定义模板友情链接中显示</p>
<h2 id="文章目录树">文章目录树</h2>
<p>文章中的目录树已经内置代码，仅当文章有h2 h3 h4标题才会生成目录树，并且手机端不显示目录树。</p>
<p><em>注意：如果文章中没有h2标题，只有h3 h4标题是不会生成目录树的。</em></p>
<h2 id="文章内部分隐藏回复可见百度mip模式下失效最好不要使用">文章内部分隐藏回复可见(百度mip模式下失效，最好不要使用)</h2>
<p>在文章使用使用</p>
<pre><code class="language-html">此处内容需要评论回复后（审核通过）方可阅读。
</code></pre>
<p>标签包裹住你想要隐藏的内容，游客必须先回复后才能查看隐藏内容。</p>
<h2 id="自定义图标使用方法">自定义图标使用方法</h2>
<p>举个例子：</p>
<pre><code class="language-html">&lt;!--iconfont图标--&gt;
&lt;i class="iconfont icon-xxx"&gt;&lt;/i&gt;

&lt;!--Glyphicons图标--&gt;
&lt;i class="glyphicon glyphicon-eur"&gt;&lt;/i&gt;

&lt;!--fontello图标--&gt;
&lt;i class="fontello fontello-xxx"&gt;&lt;/i&gt;
</code></pre>
<h2 id="左侧边栏导航">左侧边栏导航</h2>
<h3 id="添加自定义按钮">添加自定义按钮：</h3>
<p>name：代表显示栏目/按钮的名称<br>
  class：表示栏目/按钮的网页图标的样式<br>
  link：代表栏目/按钮的链接<br>
  target（可选）:代表定在何处打开链接文档，如_blank:浏览器总在一个新打开、未命名的窗口中载入目标文档。_self:代表在当前窗口打开。不填则为：_blank。</p>
<pre><code class="language-html">{"name":"音乐","class":"glyphicon glyphicon-music","link":"xxx.com"},
{"name":"笔记","class":"glyphicon glyphicon-book","link":"xxx.com"},
{"name":"相册","class":"fontello fontello-picture","link":"xxx.com","target":"_self"}
</code></pre>
<p>每两项之间，用英文逗号(,)隔开，最后一项请勿加上逗号。</p>
<h3 id="隐藏默认栏目">隐藏默认栏目：</h3>
<p>左侧边栏目默认加载首页按钮。隐藏方法：</p>
<p>{"name":"home","status":"hide"}</p>
<h2 id="顶部导航栏目">顶部导航栏目</h2>
<h3 id="添加自定义按钮-1">添加自定义按钮：</h3>
<p>与左侧边栏导航配置的书写规则完全相同：</p>
<pre><code class="language-html">{"name":"音乐","class":"fa fa-music","link":"xxx.com"},
{"name":"相册","class":"fontello fontello-picture","link":"xxx.com","target":"_self"}
</code></pre>
<h3 id="隐藏默认栏目-顶部导航按钮默认加载闲言碎语按钮隐藏方法">隐藏默认栏目： 顶部导航按钮默认加载闲言碎语按钮。隐藏方法：</h3>
<pre><code>{"name":"talk","status":"hide"}
</code></pre>
<h2 id="时光机社会化图标">时光机社会化图标</h2>
<p>默认已经填入了配置，书写规则和上面基本类似：</p>
<p>name：代表显示按钮的名称<br>
  class：表示按钮的网页图标的样式<br>
  link：代表按钮的链接<br>
  status：当status值为single时，特指页面中的绿色文字按钮，此时无需填写class项。</p>
<pre><code class="language-html">{"name":"twitter","class":"fa fa-twitter","link":"#"},
{"name":"facebook","class":"fa fa-facebook","link":"#"},
{"name":"googlepluse","class":"fa fa-google-plus","link":"#"},
{"name":"github","status":"single","link":"#"}
</code></pre>
<h2 id="时光机联系方式">时光机联系方式</h2>
<p>默认已经填写email、QQ、微博以及网易云音乐的配置：</p>
<p>name：代表显示栏目的名称<br>
  img：表示该联系方式的图标（图片格式）<br>
  link：代表联系方式的地址</p>
<pre><code class="language-html">{"name":"email","img":"https://ww4.sinaimg.cn/large/a15b4afegy1fg2pmtjbaej201s01s0aw","value":"ihewro@163.com","link":"#"},
{"name":"QQ","img":"https://ww4.sinaimg.cn/large/a15b4afegy1fg2pnirhr2j201s01va9u","value":"535425690","link":"#"},
{"name":"微博","img":"https://ww4.sinaimg.cn/large/a15b4afegy1fg2pofbz5fj201s01swe9","value":"@i超级男孩","link":"http://weibo.com/hewro"},
{"name":"网易云音乐","img":"https://ww4.sinaimg.cn/large/a15b4afegy1fg2pouholzj201s01s0ja","value":"@许多年以后我依然是我","link":"http://music.163.com/#/user/home?id=83271175"}
</code></pre>
<blockquote>
 <p>本文转载至：<a href="https://blog.mioshu.com/archives/52.html">https://blog.mioshu.com/archives/52.html</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/19.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 11 Jul 2020 15:43:00 GMT</pubDate></item><item><title><![CDATA[handsome主题使用方式]]></title><link>https://blog.ccrui.cn/archives/14.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=handsome%E4%B8%BB%E9%A2%98%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F&amp;url=/archives/14.html" width="1" height="1" alt="" style="opacity:0;">
<h1 id="以下内容是从handsome主题使用文档搬来的">以下内容是从handsome主题使用文档搬来的</h1>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F07%2F11%2F4632089521.png&amp;size=m" alt="宣传图"></p>
<h2 id="相册">相册</h2>
<p>创建相册<br>
  新建分类：分类的缩略名称为image（这个是固定的，标识该分类是相册）。分类描述会输出到相册列表页面<br>
  创建属于该分类的一篇文章，即创建了一个新的相册。文章的标题即相册的标题。<br>
  在文章的自定义字段中添加字段名album，值为你的相册描述<br>
  上传相片<br>
  在属于相册分类新建一篇文章，在编辑器中添加图片即可。</p>
<p>添加图片：允许以下的几种方式：</p>
<p>使用自带的附件功能，上传并插入编辑器中<br>
  使用markdown的图片语法，支持外站链接<br>
  使用html语法，支持外站链接</p>
<p>举例：</p>
<pre><code class="language-html">
![相片描述](图片地址)

&lt;img src="图片地址" alt="图片描述"&gt;

![奔跑的日子](http://localhost/build/usr/uploads/2018/05/1374653827.png)

&lt;img src="http://localhost/build/usr/uploads/2018/05/1374653827.png" alt="奔跑的日子"&gt;
</code></pre>
<p>主题代码会自动解析代码，并显示为相片格式，编辑器内多余的文字将不会显示</p>
<h2 id="灯箱插件">灯箱插件</h2>
<p>文章中如果某个图片不想显示灯箱效果，可以给图片标签中加入 <code>nogallery</code> 属性：</p>
<p><code>&lt;img nogallery src=""&gt;</code><br>
  如果某张图片高度很大，想折叠展示，可以给图片标签加入max属性：</p>
<p><code>&lt;img max src=""&gt;</code></p>
<h2 id="文章目录树">文章目录树</h2>
<p>文章中的目录树已经内置代码，仅当文章有 <code>h2 h3 h4</code> 标题<br>
  才会生成目录树，并且手机端不显示目录树。</p>
<p>注意：如果文章中没有 <code>h2</code> 标题，只有 <code>h3 h4</code> 标题是不会生成目录树的。</p>
<h2 id="自定义摘要字数">自定义摘要字数</h2>
<p>大版式头图默认摘要字数200字，小版式头图默认摘要字数80字。你可以在后台外观设置-&gt;自定义大版式头图摘要/自定义小版式头图摘要来改变这两个默认值。</p>
<p>你还可以使用摘要分隔符进行自主截断内容输出，但是自主生成的摘要不会超过默认摘要字数。</p>
<p>举例：你的默认摘要字数设置为200字，使用摘要分隔符截断的摘要为230字，则摘要只会显示200字。</p>
<p><code>&lt;!--more--&gt;</code></p>
<h2 id="添加自定义图标">添加自定义图标</h2>
<p>主题已经内置的图标列表，详见图标列表</p>
<p>如果不能满足你的图标需求，可以使用以下方法扩充主题图标：</p>
<h3 id="方法一傻瓜式扩充fontawesome图标">方法一：傻瓜式扩充fontawesome图标</h3>
<p>直接引入全套的fontawesome图标：</p>
<p>在主题外观设置——开发者设置——自定义输出head 头部的HTML代码，填入：</p>
<p><code>link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"</code><br>
  上面的fontawesome 的css文件来自bootcdn.css<br>
  公共cdn提供，你可以替换成自己的文件。</p>
<h3 id="方法二自定义添加iconfont图标列表">方法二：自定义添加iconfont图标列表</h3>
<p>主题内置fontello图标来自网站 <code>http://fontello.com/</code><br>
  你可以在该网站中导入主题目录下的 <code>assets/fonts/fontello的config.json</code> ，然后重新生成字体文件。</p>
<p>覆盖到 <code>assets/fonts/fontello</code> 下，并且需要修改 <code>assets/css/handsome.css</code> 中形如 <code>.fontello-*:before</code> ，替换为下载的新的标签。</p>
<p>（难度较大，不推荐……）</p>
<h2 id="文章中插入按钮">文章中插入按钮</h2>
<p>handsome支持以下类型的按钮：</p>
<p>矩形文字按钮<br>
  椭圆形文字按钮<br>
  矩形图标文字按钮</p>
<pre><code class="language-html">[button]矩形按钮文字[/button]
[button color="succees"]矩形按钮文字[/button]
[button type="round" color="success"]椭圆形按钮文字[/button]
[button color="succees" icon="glyphicon glyphicon-eur"]图标按钮文字[/button]
</code></pre>
<ul>
 <li><code>type</code> ：选填，不填默认为矩形按钮。可选值：</li>
 <li><code>round</code> ：椭圆形按钮</li>
 <li><code>color</code> ： 选填，不填默认为success（绿色），可选值：</li>
 <li><code>light</code> ：白色</li>
 <li><code>info</code> ：蓝色</li>
 <li><code>dark</code> ：深色</li>
 <li><code>success</code> ：绿色</li>
 <li><code>black</code> ：黑色</li>
 <li><code>warning</code> ：黄色</li>
 <li><code>primary</code> ：紫色</li>
 <li><code>danger</code> ：红色</li>
 <li><code>icon</code> ：选填，不填默认为文字按钮，可用按钮见<a href="https://www.529i.com/go/aHR0cHM6Ly9oYW5kc29tZS5paGV3cm8uY29tLyMvLi9pY29ucw==">图标列表</a></li>
</ul>
<h2 id="文章内插入音乐">文章内插入音乐</h2>
<p>点击编辑器的插入音乐图标可以在文章内可以插入音乐歌曲地址，支持云解析和本地MP3地址两种方式：</p>
<p>时光机的音乐插入按钮也是同样的操作</p>
<p>云解析歌曲：暂时支持解析单曲，不支持歌单，支持以下媒体：</p>
<ul>
 <li>网易云音乐：<a href="https://www.529i.com/go/aHR0cDovL211c2ljLjE2My5jb20vIy9zb25nP2lkPTQwMTQ3NTU2">http://music.163.com/#/song?id=40147556</a></li>
 <li>QQ音乐：<a href="https://www.529i.com/go/aHR0cHM6Ly95LnFxLmNvbS9uL3lxcS9zb25nLzAwMGpEUVdQNEppQjN5Lmh0bWw=">https://y.qq.com/n/yqq/song/000jDQWP4JiB3y.html</a></li>
 <li>虾米音乐：<a href="https://www.529i.com/go/aHR0cDovL3d3dy54aWFtaS5jb20vc29uZy9iZjA4RE5UMzAzNWY=">http://www.xiami.com/song/bf08DNT3035f</a></li>
 <li>酷狗音乐：<a href="https://www.529i.com/go/aHR0cDovL3d3dy5rdWdvdS5jb20vc29uZy8jaGFzaD0wOUU4REU3MEEyNEM5N0I5MkEyOUY2QTE5RjM1MjhBMg==">http://www.kugou.com/song/#hash=09E8DE70A24C97B92A29F6A19F3528A2</a></li>
 <li>百度音乐：<a href="https://www.529i.com/go/aHR0cDovL211c2ljLmJhaWR1LmNvbS9zb25nLzI2ODI3NTMyNA==">http://music.baidu.com/song/268275324</a></li>
</ul>
<p>本地mp3地址播放：</p>
<p>示例：直接在输入框中输入 <code>.mp3</code> 结尾的地址，并填写歌曲名和歌手的名称。</p>
<pre><code class="language-html">[hplayer title="歌曲名" author="歌手" url="http:\/\/xxx.com\/xxx.mp3" size="large" /]
</code></pre>
<p>文章页面插入播放器 <code>size</code> 默认为 <code>large</code> 时光机插入播放器 <code>size</code> 默认为 <code>small</code><br>
  你也可以手动改动这个标签的内容以选择不同的播放器样式:)</p>
<h2 id="文章内插入视频">文章内插入视频</h2>
<p>点击编辑器的插入音乐图标可以插入视频，只支持本地的视频地址的播放</p>
<p>时光机的视频插入按钮也是同样的操作</p>
<p>直接在输入框中输入视频的地址即可，一般以.mp4结尾的资源地址。</p>
<p>示例：</p>
<pre><code class="language-html">[vplayer url="http://xxx.com/xxx.mp4" pic="http://xxx.com/xxx.png"]
url：视频地址
pic：视频背景图片
</code></pre>
<h2 id="文章内调用其他文章">文章内调用其他文章</h2>
<p>点击编辑器的调用文章的按钮可以调用其他文章并显示。</p>
<pre><code class="language-html">post cid="1"  
post cid="1" cover="http:\/\/localhost\/build\/usr\/themes\/handsome\/usr\/img\/sj\/6.jpg"/
</code></pre>
<p><code>cid</code> ：必填，是文章的唯一编号，在后台的编辑文章的地址可以看到，比如 <code>http://localhost/build/admin/write-post.php?cid=23,值为23</code> <br><code>cover</code> ：可选项，调用文章显示的封面，如果不填则默认显示随机缩略图。</p>
<h2 id="文章中使用mathjax公式">文章中使用mathJax公式</h2>
<p>需要在后台外观设置——主题增强功能中启用公式（MathJax）选项。</p>
<ul>
 <li>语法格式：</li>
</ul>
<pre><code class="language-html">//块级公式：
$$ 公式内容 $$
$$ x = \dfrac{-b \pm \sqrt{b^2 - 4ac}}{2a} $$

// 行内公式：
$ 行内公式内容 $
\\( 行内公式内容 \\)

$\Gamma(n) = (n-1)!\quad\forall n\in\mathbb N$

\\( x = \dfrac{-b \pm \sqrt{b^2 - 4ac}}{2a} \\)
</code></pre>
<h2 id="文章内部分隐藏回复可见">文章内部分隐藏回复可见</h2>
<p>在文章中使用</p>
<pre><code>`
此处内容需要评论回复后（审核通过）方可阅读。
[/hide]`
</code></pre>
<p>标签包裹住你想要隐藏的内容，游客必须先回复后才能查看隐藏内容。</p>
<h2 id="文章内部分内容登录可见">文章内部分内容登录可见</h2>
<p>为什么增加这样的功能呢？因为有时候一篇文章并不想完全的加密，部分内容由于隐私问题需要加密。该部分内容仅登录用户（如果是个人博客就是仅博主）可见。</p>
<p>在文章中使用</p>
<pre><code>`

该部分仅登录用户可见

该部分仅登录用户可见

`
</code></pre>
<h2 id="文章中插入短代码高亮文本">文章中插入短代码高亮文本</h2>
<pre><code>这是灰色的短代码框，常用来引用资料什么的
这是黄色的短代码框，常用来做提示，引起读者注意。
这是红色的短代码框，用于严重警告什么的。
这是浅蓝色的短代码框，用于显示一些信息。
这是绿色的短代码框，显示一些推荐信息。

</code></pre>
<h2 id="文章中插入收缩框">文章中插入收缩框</h2>
<p>示例代码：</p>
<pre><code class="language-html">        
    标题
      
      
        
        
          一些文字内容
        
 

        
    标题
      
      
        
        
          一些文字内容
        
 
</code></pre>
<p>其中 <code>status</code> 为 <code>false</code> 表示默认不显示文字内容，为 <code>true</code> 表示默认显示内容。</p>
<p>不写 <code>status</code> 属性，默认是展开内容的。</p>
<blockquote>
 <p>本文章转载来自于 <a href="https://www.529i.com/archives/190.html">https://www.529i.com/archives/190.html</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/14.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 11 Jul 2020 15:16:00 GMT</pubDate></item><item><title><![CDATA[Adobe Premiere Pro CC2019 安装教程]]></title><link>https://blog.ccrui.cn/archives/5.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=Adobe%20Premiere%20Pro%20CC2019%20%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B&amp;url=/archives/5.html" width="1" height="1" alt="" style="opacity:0;">
<h2 id="1--解压">1. 解压</h2>
<p>软件下载链接<a href="https://www.yun.chengrui.xyz/index.php?share/file&amp;user=1&amp;sid=qmgbUdrM">私人云盘下载</a></p>
<p>双击 <code>Adobe Premiere Pro CC 2019 SP YIPOJIE.zip</code>打开压缩包<br>
  点击解压<br><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FSnipaste_2020-06-29_17-18-38.png&amp;size=m" alt="解压"></p>
<h2 id="2--安装">2. 安装</h2>
<p>**&lt;font color=red size=10 face=“黑体”&gt;第一步关闭网络！！**</p>
<p>双击 <code>Set-up.exe</code><br>
  开启安装界面</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FSnipaste_2020-06-29_17-22-21.png&amp;size=m" alt="安装"></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FSnipaste_2020-06-29_17-24-26.png&amp;size=m" alt="安装位置"></p>
<p>等待安装 安装大致需要5-10分钟（安装速度与电脑性能与磁盘性能有直接关系）</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FSnipaste_2020-06-29_17-27-03.png&amp;size=m" alt="等待界面"></p>
<h2 id="3--安装完毕">3. 安装完毕</h2>
<p>显示成功安装后点击关闭按键</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FSnipaste_2020-06-29_17-28-48.png&amp;size=m" alt="安装完成"></p>
<p>按下win键或点击左下角windows按键打开开始菜单<br>
  在最近添加中找到Adobe Premiere Pro CC2019</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FSnipaste_2020-06-29_17-30-22.png&amp;size=m" alt="Adobe Premiere Pro CC2019"></p>
<p>右击<code>Adobe Premiere Pro CC2019</code>-<code>更多</code>-<code>打开文件位置</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FSnipaste_2020-06-29_17-31-26.png&amp;size=m" alt="打开文件位置"></p>
<p>将<code>Adobe Premiere Pro CC2019</code>复制到桌面即可<br>
  双击桌面<code>Adobe Premiere Pro CC2019</code>快捷方式即可打开软件</p>
<h2 id="4--使用">4. 使用</h2>
<p>在打开pr后点击左上角<code>文件</code>选择<code>新建</code>-<code>项目</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FSnipaste_2020-06-29_17-34-22.png&amp;size=m" alt="项目"></p>
<p>根据软件提示创建项目即可使用pr</p>
<blockquote>
 <p>pr具体使用方法与教学可以在网络上搜索与查看<br>
   pr学习网址：<a href="https://www.bilibili.com/video/av52742833/">哔哩哔哩pr新手入门教程</a></p>
</blockquote>]]></description><guid isPermaLink="false">/archives/5.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 11 Jul 2020 12:47:00 GMT</pubDate></item><item><title><![CDATA[surface pro4 安装deepin教程]]></title><link>https://blog.ccrui.cn/archives/3.html</link><description><![CDATA[<img src="https://blog.ccrui.cn/plugins/feed/assets/telemetry.gif?title=surface%20pro4%20%E5%AE%89%E8%A3%85deepin%E6%95%99%E7%A8%8B&amp;url=/archives/3.html" width="1" height="1" alt="" style="opacity:0;">
<pre><code class="language-text">注意：  
请保持在系统部署与安装期间网络通畅并连接电源  
并且保证有键盘接入  
理论上该教程surface系列通用  
  
在deepin20 beat版本中surface pro4无法使用触摸屏  
若需使用触屏 请使用deepin15进行安装  
安装流程与下文流程一致
</code></pre>
<div class="vditor-toc" data-block="0" data-type="toc-block" contenteditable="false">
 <ul>
  <li><span data-target-id="1--下载"><strong>1. 下载</strong></span></li>
  <li><span data-target-id="2--部署启动盘"><strong>2. 部署启动盘</strong></span></li>
  <li><span data-target-id="3--安装准备"><strong>3. 安装准备</strong></span>
   <ul>
    <li><span data-target-id="3-1--分区准备"><strong>3.1. 分区准备</strong></span></li>
    <li><span data-target-id="3-2--bios解锁准备"><strong>3.2. bios解锁准备</strong></span></li>
   </ul></li>
  <li><span data-target-id="4--系统安装"><strong>4. 系统安装</strong></span></li>
 </ul>
</div>
<h2 id="1--下载"><strong>1. 下载</strong></h2>
<p>从官网下载镜像文件与启动盘制作工具</p>
<blockquote>
 <p><a href="https://www.deepin.org/zh/download/">deepin官网下载链接</a></p>
</blockquote>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FSnipaste_2020-06-29_10-03-55.png&amp;size=m" alt="官方下载，“下载深度启动盘制作工具”"></p>
<h2 id="2--部署启动盘"><strong>2. 部署启动盘</strong></h2>
<p>点击</p>
<p><code>deepin-boot-maker.exe</code></p>
<p>根据流程进行安装<br>
  选择需要制作启动盘的U盘<br>
  提前备份好U盘中数据，并在第二步中选择格式化U盘</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FSnipaste_2020-06-29_10-04-22.png&amp;size=m" alt="安装界面"></p>
<h2 id="3--安装准备"><strong>3. 安装准备</strong></h2>
<h3 id="3-1--分区准备"><strong>3.1. 分区准备</strong></h3>
<p>在surface pro4上 使用搜索功能搜索磁盘管理<br>
  点击第一个搜索项“创建并格式化硬盘分区”</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2F-2020-06-29-101222.png&amp;size=m" alt="磁盘管理"></p>
<p>右键点击c盘选择压缩卷 并输入压缩空间量20000M（20G）<br>
  右键点击压缩后的20G未分配卷 选择新建简单卷 一路下一步可以成功分配卷</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2F-2020-06-29-101729.png&amp;size=m" alt="分配卷"></p>
<h3 id="3-2--bios解锁准备"><strong>3.2. bios解锁准备</strong></h3>
<p>将surface pro4关机,然后等待大概10秒钟确保其处于关闭状态<br>
  按住Surface上的调高音量按钮(音量+)，同时按下并释放电源按钮<br>
  进入surface bios界面<br>
  点击security</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FIMG_20200629_103029.jpg&amp;size=m" alt="security"></p>
<p>进入如图界面后 点击change configuration<br>
  并选择None</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FIMG_20200629_103101.jpg&amp;size=m" alt="change configuration"></p>
<p>选择Exit后重启surface<br>
  若开机时屏幕上方出现红色色条，并出现解锁标志说明bios解锁成功</p>
<h2 id="4--系统安装"><strong>4. 系统安装</strong></h2>
<p>将surface pro4关机,然后等待大概10秒钟确保其处于关闭状态<br>
  按住Surface上的调高音量按钮(音量+)，同时按下并释放电源按钮<br>
  进入surface bios界面</p>
<p>点击左侧Boot configuration 选项<br>
  并将USB Storage 拖动到启动项最上方</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FIMG_20200629_104409.jpg&amp;size=m" alt="USB Storage"></p>
<p>将U盘插入后<br>
  选择Exit后重启surface<br>
  稍等两分钟，若不出意外则进入deepin安装界面</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FIMG_20200629_104544.jpg&amp;size=m" alt="deepin安装界面"></p>
<p>成功进入安装界面并成功选择语言后<br>
  进入选择安装位置界面<br>
  点击手动安装并选择在之前步骤中分的20G deepin分区</p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FIMG_20200629_105056.jpg&amp;size=m" alt="安装位置"></p>
<p>点击后 若此时选择开始安装会显示 <code>需要添加一个根分区才能继续安装</code><br>
  此时点击分区右边的小笔一样的图标<br>
  进入磁盘编辑选项<br>
  如图选择后点击新建<br><code>文件系统：ext4，挂载点：/，格式化该分区</code></p>
<p><img src="https://blog.ccrui.cn/apis/api.storage.halo.run/v1alpha1/thumbnails/-/via-uri?uri=https%3A%2F%2Fimg-cdn.ccrui.cn%2F2020%2F06%2F29%2FIMG_20200629_105554.jpg&amp;size=m" alt="文件系统：ext4，挂载点：/，格式化该分区"></p>
<p>此时再次点击开始安装<br>
  静等安装<br><code>安装速度与设备运行速度和U盘读写速度有关</code><br>
  安装成功后点击立即体验后，迅速拔出U盘后等待系统开机<br>
  开机后正常设置时区与账户即可完成系统安装</p>]]></description><guid isPermaLink="false">/archives/3.html</guid><dc:creator>zgccrui</dc:creator><pubDate>Sat, 11 Jul 2020 10:50:00 GMT</pubDate></item></channel></rss>