-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Add JSDoc for function and type
- Loading branch information
Showing
27 changed files
with
401 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
/** | ||
* @file 包含初始化看板娘小部件的函数。 | ||
* @module index | ||
*/ | ||
/** | ||
* 初始化看板娘小部件。 | ||
* @param {string | Config} config - 看板娘配置或配置路径。 | ||
* @param {string} [apiPath] - API 路径,如果 config 是字符串。 | ||
*/ | ||
declare function initWidget(config: string | Config, apiPath?: string): void; | ||
export default initWidget; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
/** | ||
* @file 包含显示看板娘消息的函数。 | ||
* @module message | ||
*/ | ||
/** | ||
* 显示看板娘消息。 | ||
* @param {string | string[]} text - 消息文本或文本数组。 | ||
* @param {number} timeout - 消息显示的超时时间(毫秒)。 | ||
* @param {number} priority - 消息的优先级。 | ||
*/ | ||
declare function showMessage(text: string | string[], timeout: number, priority: number): void; | ||
export default showMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
import randomSelection from "./utils.js"; | ||
/** | ||
* @file 包含显示看板娘消息的函数。 | ||
* @module message | ||
*/ | ||
import randomSelection from './utils.js'; | ||
var messageTimer = null; | ||
/** | ||
* 显示看板娘消息。 | ||
* @param {string | string[]} text - 消息文本或文本数组。 | ||
* @param {number} timeout - 消息显示的超时时间(毫秒)。 | ||
* @param {number} priority - 消息的优先级。 | ||
*/ | ||
function showMessage(text, timeout, priority) { | ||
if (!text || (sessionStorage.getItem("waifu-text") && Number(sessionStorage.getItem("waifu-text")) > priority)) | ||
if (!text || | ||
(sessionStorage.getItem('waifu-text') && | ||
Number(sessionStorage.getItem('waifu-text')) > priority)) | ||
return; | ||
if (messageTimer) { | ||
clearTimeout(messageTimer); | ||
messageTimer = null; | ||
} | ||
text = randomSelection(text); | ||
sessionStorage.setItem("waifu-text", String(priority)); | ||
var tips = document.getElementById("waifu-tips"); | ||
sessionStorage.setItem('waifu-text', String(priority)); | ||
var tips = document.getElementById('waifu-tips'); | ||
tips.innerHTML = text; | ||
tips.classList.add("waifu-tips-active"); | ||
tips.classList.add('waifu-tips-active'); | ||
messageTimer = setTimeout(function () { | ||
sessionStorage.removeItem("waifu-text"); | ||
tips.classList.remove("waifu-tips-active"); | ||
sessionStorage.removeItem('waifu-text'); | ||
tips.classList.remove('waifu-tips-active'); | ||
}, timeout); | ||
} | ||
export default showMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
/** | ||
* @file 包含看板娘模型加载和管理相关的类。 | ||
* @module model | ||
*/ | ||
/** | ||
* 看板娘模型类,负责加载和管理模型。 | ||
*/ | ||
declare class Model { | ||
private readonly useCDN; | ||
private readonly apiPath; | ||
private readonly cdnPath; | ||
private modelList; | ||
/** | ||
* 创建一个 Model 实例。 | ||
* @param {Object} config - 配置选项。 | ||
* @param {string} [config.apiPath] - API 路径。 | ||
* @param {string} [config.cdnPath] - CDN 路径。 | ||
*/ | ||
constructor(config: { | ||
apiPath?: string; | ||
cdnPath?: string; | ||
}); | ||
/** | ||
* 加载模型列表。 | ||
*/ | ||
loadModelList(): Promise<void>; | ||
/** | ||
* 加载指定模型。 | ||
* @param {number} modelId - 模型 ID。 | ||
* @param {number} modelTexturesId - 模型材质 ID。 | ||
* @param {string} message - 加载消息。 | ||
*/ | ||
loadModel(modelId: number, modelTexturesId: number, message: string): Promise<void>; | ||
/** | ||
* 加载随机材质的模型。 | ||
*/ | ||
loadRandModel(): Promise<void>; | ||
/** | ||
* 加载其他模型。 | ||
*/ | ||
loadOtherModel(): Promise<void>; | ||
} | ||
export default Model; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
/** | ||
* @file 包含实用工具函数。 | ||
* @module utils | ||
*/ | ||
/** | ||
* 从数组中随机选择一个元素,或返回原始值(如果不是数组)。 | ||
* @param {any} obj - 要选择的对象或数组。 | ||
* @returns {any} 随机选择的元素或原始值。 | ||
*/ | ||
declare function randomSelection(obj: any): any; | ||
export default randomSelection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
/** | ||
* @file 包含初始化看板娘小部件的入口。 | ||
* @module waifu-tips | ||
*/ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
import initWidget from "./index.js"; | ||
/** | ||
* @file 包含初始化看板娘小部件的入口。 | ||
* @module waifu-tips | ||
*/ | ||
import initWidget from './index.js'; | ||
window.initWidget = initWidget; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.