Skip to content

Commit ee4e5c9

Browse files
committed
fix:使用异步方法修复firebase
1 parent 392f8db commit ee4e5c9

3 files changed

Lines changed: 55 additions & 37 deletions

File tree

.github/workflows/Code-review.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
name: Code Review
22
on:
33
pull_request:
4-
branches: [ main ] # 只有针对主分支的 PR 会触发此工作流程
4+
branches: [ main ]
55

66
jobs:
77
code-review:
88
name: Code Review
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v3 # 检查代码库,将其检出到 runner
11+
- uses: actions/checkout@v2 # 将代码库检出到 Runner
1212
- name: Setup Node.js
13-
uses: actions/setup-node@v3 # 安装 Node.js 运行环境和依赖包
13+
uses: actions/setup-node@v2 # 安装 Node.js 运行环境和依赖项
1414
with:
15-
node-version: '12.x'
16-
- name: Setup code review
17-
uses: reviewdog/action-eslint@v1 # 使用 reviewdog 工具进行代码审查
15+
node-version: '14.x'
16+
- name: Install dependencies
17+
run: npm install # 安装依赖项
18+
- name: Initialize CodeQL
19+
uses: github/codeql-action/init@v1 # 初始化 CodeQL 环境
1820
with:
19-
github_token: ${{ secrets.GITHUB_TOKEN }} # 授权访问 GitHub API
20-
eslint_level: error # 设置 Eslint 输出级别为 error
21+
languages: javascript
22+
- name: Analyze JavaScript code with CodeQL
23+
uses: github/codeql-action/analyze@v1 # 使用 CodeQL 对 JavaScript 代码进行分析
2124

2225
# 这个 workflow 文件使用 `pull_request` 事件来监听新的 PR 提交,并且只有针对主分支的操作才会触发它。code-review job 使用 `actions/checkout` action 将代码库检出到 runner 中,使用 `actions/setup-node` action 安装 Node.js 运行环境和依赖包,接着通过运行 `npm run lint` 进行代码风格检查和运行 `npm test` 命令来运行测试。最后,在 Setup code review 步骤中,我们使用 `reviewdog/action-eslint` action 来进行代码审查,并将输出级别设置为 `error`。
2326
#

.idea/workspace.xml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rustedwarfareapicode/.vitepress/theme/index.js

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,46 @@ import { initializeApp } from "firebase/app";
66
import { getAnalytics } from "firebase/analytics";
77
import { getPerformance } from "firebase/performance";
88

9-
const firebaseConfig = {
10-
apiKey: "AIzaSyANVvapu0ihi1cM8ZzuXTkwjx9lM_J1RyQ",
11-
authDomain: "rw-api-code-d0779.firebaseapp.com",
12-
projectId: "rw-api-code-d0779",
13-
storageBucket: "rw-api-code-d0779.appspot.com",
14-
messagingSenderId: "363611843335",
15-
appId: "1:363611843335:web:f15aef7ab427f52b4033a2",
16-
measurementId: "G-XJH5TKP5VL"
9+
const initializeFirebase = () => {
10+
const firebaseConfig = {
11+
apiKey: "AIzaSyANVvapu0ihi1cM8ZzuXTkwjx9lM_J1RyQ",
12+
authDomain: "rw-api-code-d0779.firebaseapp.com",
13+
projectId: "rw-api-code-d0779",
14+
storageBucket: "rw-api-code-d0779.appspot.com",
15+
messagingSenderId: "363611843335",
16+
appId: "1:363611843335:web:f15aef7ab427f52b4033a2",
17+
measurementId: "G-XJH5TKP5VL",
18+
};
19+
20+
// Initialize Firebase
21+
const app = initializeApp(firebaseConfig);
22+
const analytics = getAnalytics(app);
23+
const perf = getPerformance(app);
24+
25+
return "Firebase initialized successfully";
1726
};
18-
// Initialize Firebase
19-
const app = initializeApp(firebaseConfig);
20-
const analytics = getAnalytics(app);
21-
const perf = getPerformance(app);
27+
28+
(async function () {
29+
try {
30+
const result = await initializeFirebase();
31+
console.log(result);
32+
} catch (error) {
33+
console.error(error);
34+
}
35+
})();
2236

2337
function wait(timeout) {
2438
return new Promise((resolve) => setTimeout(resolve, timeout));
2539
}
40+
2641
async function requestClipboardPermission() {
2742
try {
2843
await navigator.permissions.query({ name: "clipboard-write" });
2944
} catch (error) {
3045
console.error(error);
3146
}
3247
}
48+
3349
async function init() {
3450
try {
3551
await wait(1000);
@@ -73,24 +89,23 @@ async function init() {
7389
}
7490

7591
setTimeout(() => {
76-
const notFoundDiv = document.querySelector('.NotFound')
77-
// 添加404图片
78-
const img = document.createElement('img')
79-
img.src = 'https://img.quankexia.com/kelongwo/wp-content/uploads/2021/07/2021072708045950.png'
80-
img.alt = '404 Error'
81-
notFoundDiv.insertBefore(img, notFoundDiv.firstChild)
92+
const notFoundDiv = document.querySelector(".NotFound");
93+
// 添加404图片
94+
const img = document.createElement("img");
95+
img.src =
96+
"https://img.quankexia.com/kelongwo/wp-content/uploads/2021/07/2021072708045950.png";
97+
img.alt = "404 Error";
98+
notFoundDiv.insertBefore(img, notFoundDiv.firstChild);
8299

83-
// 将PAGE NOT FOUND改为无法找到该页面
84-
notFoundDiv.querySelector('.title').textContent = '无法找到该页面'
100+
// 将PAGE NOT FOUND改为无法找到该页面
101+
notFoundDiv.querySelector(".title").textContent = "无法找到该页面";
85102

86-
// 将But if you don't change your direction, and if you keep looking, you may end up where you are heading.改为无法找到该页面
87-
notFoundDiv.querySelector('.quote').textContent = '无法找到该页面'
88-
89-
// 将 Take me home 按钮文字替换为返回首页
90-
notFoundDiv.querySelector('.link').textContent = '返回首页'
103+
// 将But if you don't change your direction, and if you keep looking, you may end up where you are heading.改为无法找到该页面
104+
notFoundDiv.querySelector(".quote").textContent = "无法找到该页面";
91105

106+
// 将 Take me home 按钮文字替换为返回首页
107+
notFoundDiv.querySelector(".link").textContent = "返回首页";
92108
}, 200);
93109

94-
95110
init();
96111
export default DefaultTheme;

0 commit comments

Comments
 (0)