fix:使用异步方法修复firebase
This commit is contained in:
parent
392f8db834
commit
ee4e5c9e3c
19
.github/workflows/Code-review.yml
vendored
19
.github/workflows/Code-review.yml
vendored
|
@ -1,23 +1,26 @@
|
|||
name: Code Review
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ main ] # 只有针对主分支的 PR 会触发此工作流程
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
code-review:
|
||||
name: Code Review
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3 # 检查代码库,将其检出到 runner 中
|
||||
- uses: actions/checkout@v2 # 将代码库检出到 Runner 中
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3 # 安装 Node.js 运行环境和依赖包
|
||||
uses: actions/setup-node@v2 # 安装 Node.js 运行环境和依赖项
|
||||
with:
|
||||
node-version: '12.x'
|
||||
- name: Setup code review
|
||||
uses: reviewdog/action-eslint@v1 # 使用 reviewdog 工具进行代码审查
|
||||
node-version: '14.x'
|
||||
- name: Install dependencies
|
||||
run: npm install # 安装依赖项
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1 # 初始化 CodeQL 环境
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }} # 授权访问 GitHub API
|
||||
eslint_level: error # 设置 Eslint 输出级别为 error
|
||||
languages: javascript
|
||||
- name: Analyze JavaScript code with CodeQL
|
||||
uses: github/codeql-action/analyze@v1 # 使用 CodeQL 对 JavaScript 代码进行分析
|
||||
|
||||
# 这个 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`。
|
||||
#
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="095f8482-7199-413b-83e3-876b2fdc1c5d" name="更改" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.github/workflows/Code-review.yml" beforeDir="false" afterPath="$PROJECT_DIR$/.github/workflows/Code-review.yml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/rustedwarfareapicode/.vitepress/theme/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/rustedwarfareapicode/.vitepress/theme/index.js" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
|
@ -86,8 +86,8 @@
|
|||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="npm.docs:preview" />
|
||||
<item itemvalue="npm.docs:dev" />
|
||||
<item itemvalue="npm.docs:build" />
|
||||
<item itemvalue="npm.docs:dev" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
|
@ -106,7 +106,7 @@
|
|||
<workItem from="1681463573643" duration="628000" />
|
||||
<workItem from="1681464227973" duration="709000" />
|
||||
<workItem from="1681573027219" duration="321000" />
|
||||
<workItem from="1681573363358" duration="331000" />
|
||||
<workItem from="1681573363358" duration="1732000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
|
|
@ -6,23 +6,38 @@ import { initializeApp } from "firebase/app";
|
|||
import { getAnalytics } from "firebase/analytics";
|
||||
import { getPerformance } from "firebase/performance";
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: "AIzaSyANVvapu0ihi1cM8ZzuXTkwjx9lM_J1RyQ",
|
||||
authDomain: "rw-api-code-d0779.firebaseapp.com",
|
||||
projectId: "rw-api-code-d0779",
|
||||
storageBucket: "rw-api-code-d0779.appspot.com",
|
||||
messagingSenderId: "363611843335",
|
||||
appId: "1:363611843335:web:f15aef7ab427f52b4033a2",
|
||||
measurementId: "G-XJH5TKP5VL"
|
||||
const initializeFirebase = () => {
|
||||
const firebaseConfig = {
|
||||
apiKey: "AIzaSyANVvapu0ihi1cM8ZzuXTkwjx9lM_J1RyQ",
|
||||
authDomain: "rw-api-code-d0779.firebaseapp.com",
|
||||
projectId: "rw-api-code-d0779",
|
||||
storageBucket: "rw-api-code-d0779.appspot.com",
|
||||
messagingSenderId: "363611843335",
|
||||
appId: "1:363611843335:web:f15aef7ab427f52b4033a2",
|
||||
measurementId: "G-XJH5TKP5VL",
|
||||
};
|
||||
|
||||
// Initialize Firebase
|
||||
const app = initializeApp(firebaseConfig);
|
||||
const analytics = getAnalytics(app);
|
||||
const perf = getPerformance(app);
|
||||
|
||||
return "Firebase initialized successfully";
|
||||
};
|
||||
// Initialize Firebase
|
||||
const app = initializeApp(firebaseConfig);
|
||||
const analytics = getAnalytics(app);
|
||||
const perf = getPerformance(app);
|
||||
|
||||
(async function () {
|
||||
try {
|
||||
const result = await initializeFirebase();
|
||||
console.log(result);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})();
|
||||
|
||||
function wait(timeout) {
|
||||
return new Promise((resolve) => setTimeout(resolve, timeout));
|
||||
}
|
||||
|
||||
async function requestClipboardPermission() {
|
||||
try {
|
||||
await navigator.permissions.query({ name: "clipboard-write" });
|
||||
|
@ -30,6 +45,7 @@ async function requestClipboardPermission() {
|
|||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function init() {
|
||||
try {
|
||||
await wait(1000);
|
||||
|
@ -73,24 +89,23 @@ async function init() {
|
|||
}
|
||||
|
||||
setTimeout(() => {
|
||||
const notFoundDiv = document.querySelector('.NotFound')
|
||||
// 添加404图片
|
||||
const img = document.createElement('img')
|
||||
img.src = 'https://img.quankexia.com/kelongwo/wp-content/uploads/2021/07/2021072708045950.png'
|
||||
img.alt = '404 Error'
|
||||
notFoundDiv.insertBefore(img, notFoundDiv.firstChild)
|
||||
const notFoundDiv = document.querySelector(".NotFound");
|
||||
// 添加404图片
|
||||
const img = document.createElement("img");
|
||||
img.src =
|
||||
"https://img.quankexia.com/kelongwo/wp-content/uploads/2021/07/2021072708045950.png";
|
||||
img.alt = "404 Error";
|
||||
notFoundDiv.insertBefore(img, notFoundDiv.firstChild);
|
||||
|
||||
// 将PAGE NOT FOUND改为无法找到该页面
|
||||
notFoundDiv.querySelector('.title').textContent = '无法找到该页面'
|
||||
// 将PAGE NOT FOUND改为无法找到该页面
|
||||
notFoundDiv.querySelector(".title").textContent = "无法找到该页面";
|
||||
|
||||
// 将But if you don't change your direction, and if you keep looking, you may end up where you are heading.改为无法找到该页面
|
||||
notFoundDiv.querySelector('.quote').textContent = '无法找到该页面'
|
||||
|
||||
// 将 Take me home 按钮文字替换为返回首页
|
||||
notFoundDiv.querySelector('.link').textContent = '返回首页'
|
||||
// 将But if you don't change your direction, and if you keep looking, you may end up where you are heading.改为无法找到该页面
|
||||
notFoundDiv.querySelector(".quote").textContent = "无法找到该页面";
|
||||
|
||||
// 将 Take me home 按钮文字替换为返回首页
|
||||
notFoundDiv.querySelector(".link").textContent = "返回首页";
|
||||
}, 200);
|
||||
|
||||
|
||||
init();
|
||||
export default DefaultTheme;
|
||||
|
|
Loading…
Reference in New Issue
Block a user