初始化知识库
This commit is contained in:
60
.github/workflows/deploy-pages.yml
vendored
Normal file
60
.github/workflows/deploy-pages.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
name: Deploy Pages
|
||||
|
||||
on:
|
||||
# 推送时执行
|
||||
push:
|
||||
branches: [main, master]
|
||||
# pr时执行
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
# 定时执行 00:01
|
||||
schedule:
|
||||
- cron: 1 0 * * *
|
||||
# 可手动执行
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
# 任务1: 部署 GitHub Pages
|
||||
deploy-github-pages:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# 1、检出源码
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# 2、安装模块并打包
|
||||
- name: Install and Build
|
||||
run: |
|
||||
yarn install
|
||||
yarn build
|
||||
|
||||
# 3、部署 GitHub Pages
|
||||
- name: Deploy GitHub Pages
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
with:
|
||||
BRANCH: pages
|
||||
FOLDER: repos/.vitepress/dist
|
||||
|
||||
# 任务2: 部署 Gitee Pages
|
||||
deploy-gitee-pages:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# 1、同步内容到 Gitee
|
||||
- name: Sync to Gitee
|
||||
uses: wearerequired/git-mirror-action@master #使用action库
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} #Gitee私钥
|
||||
with:
|
||||
source-repo: git@github.com:Charles7c/charles7c.github.io.git #GitHub 源仓库地址
|
||||
destination-repo: git@gitee.com:Charles7c/charles7c.git #Gitee 目标仓库地址
|
||||
# 2、部署 Gitee Pages
|
||||
- name: Deploy Gitee Pages
|
||||
# 手动执行时只同步内容, 不进行部署
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
uses: yanglbme/gitee-pages-action@main
|
||||
with:
|
||||
gitee-username: ${{ secrets.GITEE_USERNAME }} #Gitee 用户名
|
||||
gitee-password: ${{ secrets.GITEE_PASSWORD }} #Gitee 密码
|
||||
gitee-repo: Charles7c/charles7c #Gitee 仓库
|
||||
branch: pages #要部署的分支,默认是 master,若是其他分支,则需要指定(指定的分支必须存在)
|
30
.gitignore
vendored
Normal file
30
.gitignore
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# Node modules
|
||||
node_modules/
|
||||
|
||||
# Dist files
|
||||
dist/
|
||||
lib/
|
||||
|
||||
# Test coverage files
|
||||
coverage/
|
||||
|
||||
# MacOS Desktop Services Store
|
||||
.DS_Store
|
||||
|
||||
# Log files
|
||||
*.log
|
||||
|
||||
# IDE setting files
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
# Temp files
|
||||
yarn.lock
|
||||
package-lock.json
|
||||
.vite_opt_cache
|
||||
|
||||
# Other files
|
||||
/src/client/shared.ts
|
||||
/src/node/shared.ts
|
||||
pnpm-global
|
||||
TODOs.md
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2019-present Charles7c
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
22
README.en.md
Normal file
22
README.en.md
Normal file
@@ -0,0 +1,22 @@
|
||||
English | [中文](./README.md)
|
||||
|
||||
<h1 align="center">Charles's Repositories</h1>
|
||||
<p align="center">
|
||||
<a href="http://creativecommons.org/licenses/by-sa/4.0/" target="_blank">
|
||||
<img src="https://img.shields.io/badge/Post%20License-CC%204.0%20BY--SA-blue.svg">
|
||||
</a>
|
||||
<a href="https://github.com/Charles7c/charles7c.github.io/blob/main/LICENSE" target="_blank">
|
||||
<img src="https://img.shields.io/badge/Code%20License-MIT-blue.svg">
|
||||
</a>
|
||||
<a href="https://github.com/Charles7c/charles7c.github.io/actions/workflows/deploy-pages.yml" target="_blank">
|
||||
<img src="https://github.com/Charles7c/charles7c.github.io/actions/workflows/deploy-pages.yml/badge.svg">
|
||||
</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
📝 <strong>This is the charles's personal knowledge repositories website.</strong>
|
||||
</p>
|
||||
<p align="center">
|
||||
🐢 GitHub Pages:<a href="https://blog.charles7c.top">https://blog.charles7c.top</a><br>
|
||||
🐇 Gitee Pages:<a href="https://charles7c.gitee.io">https://charles7c.gitee.io</a>
|
||||
</p>
|
||||
|
22
README.md
Normal file
22
README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
[English](./README.en.md) | 中文
|
||||
|
||||
<h1 align="center">查尔斯的知识库</h1>
|
||||
<p align="center">
|
||||
<a href="http://creativecommons.org/licenses/by-sa/4.0/" target="_blank">
|
||||
<img src="https://img.shields.io/badge/Post%20License-CC%204.0%20BY--SA-blue.svg">
|
||||
</a>
|
||||
<a href="https://github.com/Charles7c/charles7c.github.io/blob/main/LICENSE" target="_blank">
|
||||
<img src="https://img.shields.io/badge/Code%20License-MIT-blue.svg">
|
||||
</a>
|
||||
<a href="https://github.com/Charles7c/charles7c.github.io/actions/workflows/deploy-pages.yml" target="_blank">
|
||||
<img src="https://github.com/Charles7c/charles7c.github.io/actions/workflows/deploy-pages.yml/badge.svg">
|
||||
</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
📝 <strong>查尔斯的个人知识库,记录 & 分享个人碎片化、结构化、体系化的知识内容。</strong>
|
||||
</p>
|
||||
<p align="center">
|
||||
🐢 GitHub Pages:<a href="https://blog.charles7c.top">https://blog.charles7c.top</a><br>
|
||||
🐇 Gitee Pages:<a href="https://charles7c.gitee.io">https://charles7c.gitee.io</a>
|
||||
</p>
|
||||
|
17
package.json
Normal file
17
package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "MyRepos",
|
||||
"version": "1.0.0",
|
||||
"description": "Charles's personal knowledge repositories.",
|
||||
"main": "index.js",
|
||||
"author": "Charles7c",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "vitepress dev repos",
|
||||
"build": "vitepress build repos",
|
||||
"serve": "vitepress serve repos"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vitepress": "^1.0.0-alpha.4",
|
||||
"vue": "^3.2.37"
|
||||
}
|
||||
}
|
64
repos/.vitepress/config.js
Normal file
64
repos/.vitepress/config.js
Normal file
@@ -0,0 +1,64 @@
|
||||
export default ({
|
||||
lang: 'zh-CN',
|
||||
title: '查尔斯的知识库',
|
||||
description: '个人知识库,记录 & 分享个人碎片化、结构化、体系化的知识内容。',
|
||||
|
||||
lastUpdated: true, // 启用最后更新时间
|
||||
|
||||
// <head>设置
|
||||
head: [
|
||||
['link', { rel: 'icon', href: '/favicon.ico' }]
|
||||
],
|
||||
|
||||
themeConfig: {
|
||||
logo: '/logo.jpg',
|
||||
lastUpdatedText: '最后更新时间', // 最后更新时间文本
|
||||
docFooter: {
|
||||
prev: '上一页',
|
||||
next: '下一页'
|
||||
},
|
||||
// 编辑链接
|
||||
editLink: {
|
||||
pattern: 'https://github.com/Charles7c/charles7c.github.io/edit/main/repos/:path',
|
||||
text: '在 GitHub 上编辑此页面'
|
||||
},
|
||||
|
||||
// 社交链接
|
||||
socialLinks: [
|
||||
{ icon: 'github', link: 'https://github.com/Charles7c/charles7c.github.io' }
|
||||
],
|
||||
|
||||
// 版权标识
|
||||
footer: {
|
||||
message: 'Released under the MIT License.',
|
||||
copyright: 'Copyright © 2019-present Charles7c'
|
||||
},
|
||||
|
||||
// 导航栏
|
||||
nav: nav(),
|
||||
|
||||
// 侧边栏
|
||||
sidebar: {
|
||||
'/issues/': sidebarIssues()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function nav() {
|
||||
return [
|
||||
{
|
||||
text: 'Bug万象集',
|
||||
link: '/issues/index'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
function sidebarIssues() {
|
||||
return [
|
||||
{
|
||||
items: [
|
||||
{ text: 'JavaScript 无法存储 Java Long 类型数据问题', link: '/issues/2022/01/JavaScript 无法存储 Java Long 类型数据问题' }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
31
repos/index.md
Normal file
31
repos/index.md
Normal file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
layout: home
|
||||
|
||||
title: 查尔斯的知识库
|
||||
titleTemplate: 个人知识库
|
||||
|
||||
hero:
|
||||
name: 查尔斯的知识库
|
||||
text: 专注 & 洞察 & 分享
|
||||
tagline: 个人知识库,记录 & 分享个人碎片化、结构化、体系化的知识内容。
|
||||
#image: /logo.png
|
||||
actions:
|
||||
- theme: brand
|
||||
text: Get Started
|
||||
link: /issues/
|
||||
- theme: alt
|
||||
text: View on GitHub
|
||||
link: https://github.com/Charles7c/charles7c.github.io
|
||||
|
||||
features:
|
||||
- icon: ⚡️
|
||||
title: 保持专注
|
||||
details: “简单比复杂更难,你必须努力让你的想法变得清晰明了,让它变得简单。一旦你做到了简单,你就能搬动大山。” -- 乔布斯
|
||||
- icon: 🌌
|
||||
title: 善于洞察
|
||||
details: 我既没有突出的理解力,也没有过人的机智。只在觉察那些稍纵即逝的事物并对其进行精细观察的能力上,我可能在普通人之上。 -- 达尔文
|
||||
- icon: 🌟
|
||||
title: 乐于分享
|
||||
details: 关于分享,有形的东西越分越少,无形的东西越分越多。在记录与分享的过程中, 梳理所学, 交流所得, 必有所获。
|
||||
---
|
||||
|
139
repos/issues/2022/01/JavaScript 无法存储 Java Long 类型数据问题.md
Normal file
139
repos/issues/2022/01/JavaScript 无法存储 Java Long 类型数据问题.md
Normal file
@@ -0,0 +1,139 @@
|
||||
---
|
||||
title: JavaScript 无法存储 Java Long 类型数据问题
|
||||
author: Charles7c
|
||||
date: 2022/01/26 09:07
|
||||
categories:
|
||||
- Bug万象集
|
||||
tags:
|
||||
- JavaScript
|
||||
---
|
||||
|
||||
# JavaScript 无法存储 Java Long 类型数据问题
|
||||
|
||||
## 问题描述
|
||||
|
||||
今天在解决一个需求问题的时候,遇到了一个难得一见的 JS 问题。这个问题大概是和一些同学在开发环境使用 == 来比较包装类型的整数一样,由于比较的数值在缓存范围内,因缘际会的错过了 bug 的出现。
|
||||
|
||||
简单说一下问题经过,是这样的,笔者这个需求最终要求接口返回一组自定义结构的 k-v (不是单纯的键值对)数据,用于在前端表单中进行分类展示。
|
||||
|
||||
后端响应的数据结构类似如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"errorMsg": "",
|
||||
"result": [
|
||||
{
|
||||
"extend": null,
|
||||
"items": [
|
||||
{
|
||||
"extend": null,
|
||||
"key": "CentOS 8.1 64位",
|
||||
"val": 8014753905961037835
|
||||
},
|
||||
{
|
||||
"extend": null,
|
||||
"key": "CentOS 8.0 64位",
|
||||
"val": 8014753905961037838
|
||||
},
|
||||
],
|
||||
"key": "CentOS",
|
||||
"pubProperty": "",
|
||||
"val": 14
|
||||
},
|
||||
{
|
||||
"extend": null,
|
||||
"items": [
|
||||
{
|
||||
"extend": null,
|
||||
"key": "RedHat Enterprise Linux 8.0 64位",
|
||||
"val": 7979917486755315712
|
||||
},
|
||||
{
|
||||
"extend": null,
|
||||
"key": "RedHat Enterprise Linux 7.7 64位",
|
||||
"val": 8014753905961037829
|
||||
}
|
||||
],
|
||||
"key": "Redhat",
|
||||
"pubProperty": "",
|
||||
"val": 5
|
||||
}
|
||||
],
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
在前端表单中的展示效果大概如下:
|
||||
|
||||

|
||||
|
||||
## 原因分析
|
||||
|
||||
笔者相信各位同学都应该猜得到,当提交表单的时候,前端肯定会把选中的镜像的 val 值传递给后端,然后由后端继续进行处理。
|
||||
|
||||
但是就在这个环节,由前端传给后端的 val 值竟然错了,例如:当选中了 CentOS 8.1 64 位这个镜像时,本该传递的 val 值为 8014753905961037835,实际传递的却是: 8014753905961038000。
|
||||
|
||||
后端接口测试的响应数据没问题,那问题显然就是出在前端了。
|
||||
|
||||
最终,配合前端开发定位这个问题的原因是因为: JavaScript 中无法存储 Java 中的 Long 类型数据,当位数超过 JavaScript 整数存储的范围,就会以0来代替了。
|
||||
|
||||

|
||||
|
||||
## 解决方案
|
||||
|
||||
JavaScript 存储不了就存储不了吧,咱们这个需求还得解决啊,最终的解决方法就是将后端响应回来的 Long 类型数据转换为字符串。
|
||||
|
||||
```java
|
||||
// 在序列化为 JSON 时将该字段转换为 String 类型
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Long val;
|
||||
```
|
||||
|
||||
后端响应的数据结构类似如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"errorMsg": "",
|
||||
"result": [
|
||||
{
|
||||
"extend": null,
|
||||
"items": [
|
||||
{
|
||||
"extend": null,
|
||||
"key": "CentOS 8.1 64位",
|
||||
"val": "8014753905961037835"
|
||||
},
|
||||
{
|
||||
"extend": null,
|
||||
"key": "CentOS 8.0 64位",
|
||||
"val": "8014753905961037838"
|
||||
},
|
||||
],
|
||||
"key": "CentOS",
|
||||
"pubProperty": "",
|
||||
"val": 14
|
||||
},
|
||||
{
|
||||
"extend": null,
|
||||
"items": [
|
||||
{
|
||||
"extend": null,
|
||||
"key": "RedHat Enterprise Linux 8.0 64位",
|
||||
"val": "7979917486755315712"
|
||||
},
|
||||
{
|
||||
"extend": null,
|
||||
"key": "RedHat Enterprise Linux 7.7 64位",
|
||||
"val": "8014753905961037829"
|
||||
}
|
||||
],
|
||||
"key": "Redhat",
|
||||
"pubProperty": "",
|
||||
"val": 5
|
||||
}
|
||||
],
|
||||
"success": true
|
||||
}
|
||||
```
|
5
repos/issues/index.md
Normal file
5
repos/issues/index.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Bug万象集
|
||||
|
||||
::: warning
|
||||
你读过的书,遇过的人,扛过的事,写过的 Bug,构成了你开发者人生的格局。:smile:
|
||||
:::
|
1
repos/public/CNAME
Normal file
1
repos/public/CNAME
Normal file
@@ -0,0 +1 @@
|
||||
blog.charles7c.top
|
BIN
repos/public/favicon.ico
Normal file
BIN
repos/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
BIN
repos/public/img/2022/01/202201260941889.png
Normal file
BIN
repos/public/img/2022/01/202201260941889.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
BIN
repos/public/img/2022/01/202201260942561.png
Normal file
BIN
repos/public/img/2022/01/202201260942561.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
repos/public/logo.jpg
Normal file
BIN
repos/public/logo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
Reference in New Issue
Block a user