Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenPotato137 committed Nov 20, 2024
0 parents commit af460e8
Show file tree
Hide file tree
Showing 72 changed files with 4,628 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/doc-build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Document Build & Deploy

on:
push:
branches:
- dev
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository master branch
uses: actions/checkout@master
with:
fetch-depth: '0'

- name: Setup Node.js 10.x
uses: actions/setup-node@master
with:
node-version: 20

- name: Setup Dependencies And Build
run: |
cd GalgameManager.Doc/
npm install
npm run docs:build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# - name: Login to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_TOKEN }}
#
# - name: Build & Push Docker image
# run: |
# cd GalgameManager.Doc/.vitepress/dist
# docker build --tag goldenpotato137/potatovn.net:latest .
# docker push goldenpotato137/potatovn.net:latest
#
# - name: Verify deployment
# run: echo "The image has been successfully pushed to Docker Hub."
#
# deploy-to-my-server:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Setup Private Key
# env:
# PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
# run: |
# sudo timedatectl set-timezone "Asia/Shanghai"
# mkdir -p ~/.ssh/
# echo "$PRIVATE_KEY" > ~/.ssh/id_rsa
# chmod 600 ~/.ssh/id_rsa
# ssh-keyscan potatovn.net >> ~/.ssh/known_hosts
# - name: Deploy
# run: |
# ssh [email protected] "\
# echo 'Starting deployment...'; \
# echo 'Pull new image...'; \
# docker pull goldenpotato137/potatovn.net:latest; \
# echo 'Stop old container...'; \
# docker stop potatovn.net; \
# echo 'Remove old container...'; \
# docker rm potatovn.net; \
# echo 'Run new container...'; \
# docker run -d --name potatovn.net -p 9002:80 goldenpotato137/potatovn.net:latest; \
# echo 'Deployment completed.'; \
# "
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
.vitepress/cache
.vitepress/dist
pnpm-lock.yaml

.idea
.vscode
21 changes: 21 additions & 0 deletions .vitepress/SideBar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Options, generateSidebar} from 'vitepress-sidebar';

const vitepressSidebarOptions: Options[] = [
{
scanStartPath : 'usage',
resolvePath : '/usage/',
useTitleFromFileHeading: true,
useFolderTitleFromIndexFile: true,
sortMenusByFrontmatterOrder: true,
},
{
scanStartPath : 'development',
resolvePath : '/development/',
useTitleFromFileHeading: true,
useFolderTitleFromIndexFile: true,
sortMenusByFrontmatterOrder: true,
collapseDepth: 2,
},
];

export default generateSidebar(vitepressSidebarOptions);
63 changes: 63 additions & 0 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { defineConfig } from 'vitepress'
import {
GitChangelog,
GitChangelogMarkdownSection,
} from '@nolebase/vitepress-plugin-git-changelog/vite'
import SideBar from "./SideBar";

// https://vitepress.dev/reference/site-config
export default defineConfig({
// Git Changelog
// https://nolebase-integrations.ayaka.io/pages/zh-CN/integrations/vitepress-plugin-git-changelog/
vite: {
plugins: [
GitChangelog({
repoURL: () => 'https://github.com/GoldenPotato137/PotatoVN',
}),
GitChangelogMarkdownSection(),
],
},

title: "PotatoVN",
description: "PotatoVN Official Website",
head: [
['link', {rel: 'icon', href: '/favicon-16x16.png', sizes:'16x16'}],
['link', {rel: 'icon', href: '/favicon-32x32.png', sizes:'32x32'}],
],
lang: 'zh-CN',
lastUpdated: true,
markdown: {
math: true,
container: {
tipLabel: '提示',
warningLabel: '警告',
dangerLabel: '危险',
infoLabel: '信息',
detailsLabel: '详细信息',
noteLabel: '为什么',
},
},
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
logo: "/avatar.png",
nav: [
{ text: '主页', link: '/' },
{ text: '使用指北', link: '/usage/how-to-use/brief' },
{ text: '一起开发', link: '/development' },
],
search: { provider: 'local' },
sidebar: SideBar,
socialLinks: [
{ icon: 'github', link: 'https://github.com/GoldenPotato137/PotatoVN' }
],
docFooter: {
prev: '上一页',
next: '下一页',
},
footer:{
message: '<a href="https://beian.miit.gov.cn/">桂ICP备20002051号-2</a>',
copyright: 'Power by <a href="https://vitepress.dev/">VitePress</a> | Copyright © 2024 PotatoVN.net | <a href="https://github.com/GoldenPotato137/PotatoVN?tab=Apache-2.0-1-ov-file#readme">Apache2 License</a>',
}
}
})

17 changes: 17 additions & 0 deletions .vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script setup lang="ts">
import DefaultTheme from 'vitepress/theme'
import Giscus from "./components/giscus.vue";
const { Layout } = DefaultTheme
</script>

<template>
<Layout>
<template #doc-after>
<Giscus/>
</template>
</Layout>
</template>

<style scoped>
</style>
25 changes: 25 additions & 0 deletions .vitepress/theme/components/MsStoreBadge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- MsStoreBadge.vue -->
<template>
<div id="ms-store-badge-container"></div>
</template>

<script>
export default {
mounted() {
const script = document.createElement('script');
script.type = 'module';
script.src = 'https://get.microsoft.com/badge/ms-store-badge.bundled.js';
script.onload = () => {
const badge = document.createElement('ms-store-badge');
badge.setAttribute('productid', '9p9cbkd5hr3w');
badge.setAttribute('productname', 'PotatoVN');
badge.setAttribute('window-mode', 'full');
badge.setAttribute('theme', 'auto');
badge.setAttribute('language', 'zh-cn');
badge.setAttribute('animation', 'off');
this.$el.appendChild(badge);
};
document.head.appendChild(script);
}
}
</script>
41 changes: 41 additions & 0 deletions .vitepress/theme/components/giscus.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!--component from https://github.com/zotero-chinese/website-->
<!--Zotero Chinese-->
<!--MIT License-->

<script setup lang="ts">
import Giscus from '@giscus/vue'
import {useData} from 'vitepress'

const {frontmatter, title, isDark} = useData()
</script>

<template>
<div
v-if="frontmatter.comments !== false"
:key="title"
class="comments-container"
>
<Giscus
id="comments"
repo="GoldenPotato137/PotatoVN"
repo-id="R_kgDOJQYT9A"
category="文档评论区"
category-id="DIC_kwDOJQYT9M4CWRt3"
mapping="pathname"
strict="0"
reactions-enabled="1"
emit-metadata="0"
input-position="top"
:theme="isDark ? 'transparent_dark' : 'light'"
lang="zh-CN"
/>
</div>
</template>

<style>
.comments-container {
/* max-height: 640px; */
/* overflow-y: scroll; */
margin-top: 5rem;
}
</style>
19 changes: 19 additions & 0 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// .vitepress/theme/index.ts
import type { Theme } from 'vitepress'
import Layout from "./Layout.vue";
import DefaultTheme from 'vitepress/theme'
import MsStoreBadge from './components/MsStoreBadge.vue'
import {
NolebaseGitChangelogPlugin
} from '@nolebase/vitepress-plugin-git-changelog/client'
import '@nolebase/vitepress-plugin-git-changelog/client/style.css'

export default {
extends: DefaultTheme,
Layout: Layout,
enhanceApp({ app }) {
app.use(NolebaseGitChangelogPlugin)
// 注册自定义全局组件
app.component('MsStoreBadge', MsStoreBadge)
}
} satisfies Theme
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PotatoVN.Doc

> potatovn.net 的源代码
12 changes: 12 additions & 0 deletions development/client/converter/AnyToVisibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

# AnyToVisibilityConverter

当值不为null时,将值转换为Visibility.Visible,否则转换为Visibility.Collapsed。

```
例:ChangeSourceDialog.xaml
<InfoBar Severity="Error" IsOpen="True" Message="{x:Bind WarningText, Mode=OneWay}"
Visibility="{x:Bind WarningText, Mode=OneWay, Converter={StaticResource AnyToVisibility}}"/>
...
<converter:AnyToVisibilityConverter x:Key="AnyToVisibility" />
```
2 changes: 2 additions & 0 deletions development/client/converter/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

# 转换器
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions development/client/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

# 客户端开发
46 changes: 46 additions & 0 deletions development/client/info-event-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

# 消息、事件、报错
PotatoVN 采用统一的通知机制,通知分为两种类型:消息与事件。

![img.png](./images/info-event-error/info-event-error-1.png)

所有通知均需调用`InfoService`发送,你可以任何地方使用`App.GetService<IInfoService>`获取`InfoService`实例,
或是使用依赖注入的方式注入`IInfoService`

## 消息
消息仅会在当前页面显示,且不会记录到状态中心中,消息通常用于提示用户一些临时性的信息或用来显示某些操作的进度。

当页面切换的时候,消息会被清空。

调用```infoService.Info```来发送消息。

```cs
//例:帮助界面使用消息通知用户正在获取FAQ
private void ChangeInfoBar()
{
if (_faqService.IsUpdating)
_infoService.Info(InfoBarSeverity.Informational, msg: "HelpPage_GettingFaq".GetLocalized(),
displayTimeMs: 100000);
else
_infoService.Info(InfoBarSeverity.Informational); // 关闭InfoBar
}
```


## 事件
事件一般用于通知用户某个操作的结果或是报错,其会被记录到状态中心中,如下图所示。

![img.png](./images/info-event-error/info-event-error-2.png)

调用```infoService.Event```来发送事件。

事件有提醒与不提醒事件两种,对于提醒的事件,其会像本页头图那样显示在页面底部,同时左侧的状态中心未读数量会加一;
对于不提醒的事件,其只会记录到状态中心中,不会显示在页面底部。且不会影响状态中心未读数量。

可以在`InfoService``ShouldNotifyEvent`函数中判断事件是否要提醒(一般为读取设置)

特别的,有一种事件类型为开发者事件,其只会在设置中打开了开发者模式时才会被设置为提醒事件。
该事件一般用于没那么严重的异常,但又不希望直接return掉的情况,用于在某个事情没有成功时用户可以打开该选项从而便于开发者快速定位问题来源。

可以调用`InfoService``DeveloperEvent`来便捷的触发开发者事件。

2 changes: 2 additions & 0 deletions development/client/shortcut.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

# 快捷键
Binary file added development/images/CSharp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added development/images/DockerLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added development/images/HTML.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit af460e8

Please sign in to comment.