-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b026b82
commit d81e8bb
Showing
26 changed files
with
419 additions
and
420 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
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,27 +1,27 @@ | ||
// @ts-check | ||
import td from "typedoc"; | ||
import path from "path"; | ||
import td from "typedoc" | ||
import path from "path" | ||
|
||
const template = ` | ||
<select onchange="location.href = event.target.selectedOptions[0].dataset.url + location.hash;"> | ||
<option data-url="{ROOT}/JP/{PAGE}" lang="ja">日本語</option> | ||
<option data-url="{ROOT}/EN/{PAGE}" lang="en">English</option> | ||
<option data-url="{ROOT}/CN/{PAGE}" lang="zh-CN">中文 (简体)</option> | ||
<option data-url="{ROOT}/JP/{PAGE}" lang="ja">日本語</option> | ||
<option data-url="{ROOT}/EN/{PAGE}" lang="en">English</option> | ||
<option data-url="{ROOT}/CN/{PAGE}" lang="zh-CN">中文 (简体)</option> | ||
</select> | ||
`; | ||
` | ||
|
||
/** @param {td.Application} app */ | ||
export function load(app) { | ||
app.renderer.hooks.on("pageSidebar.begin", (context) => { | ||
const language = app.options.getValue("htmlLang"); | ||
app.renderer.hooks.on("pageSidebar.begin", (context) => { | ||
const language = app.options.getValue("htmlLang") | ||
|
||
const root = path.posix.join(context.relativeURL("./"), ".."); | ||
const html = template | ||
.trim() | ||
.replace(/\{ROOT\}/g, root) | ||
.replace(/\{PAGE\}/g, context.page.url) | ||
.replace(`lang="${language}"`, `lang="${language}" selected`); | ||
const root = path.posix.join(context.relativeURL("./"), "..") | ||
const html = template | ||
.trim() | ||
.replace(/\{ROOT\}/g, root) | ||
.replace(/\{PAGE\}/g, context.page.url) | ||
.replace(`lang="${language}"`, `lang="${language}" selected`) | ||
|
||
return td.JSX.createElement(td.JSX.Raw, { html }); | ||
}); | ||
return td.JSX.createElement(td.JSX.Raw, { html }) | ||
}) | ||
} |
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 |
---|---|---|
|
@@ -29,4 +29,4 @@ export default [ | |
"fs", | ||
] | ||
} | ||
]; | ||
] |
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,27 +1,27 @@ | ||
import { execSync } from 'child_process'; | ||
import { join } from 'path'; | ||
import { existsSync } from 'fs'; | ||
import { execSync } from 'child_process' | ||
import { join } from 'path' | ||
import { existsSync } from 'fs' | ||
|
||
// 获取旧的 PATH 环境变量 | ||
const oldPath = process.env.PATH; | ||
const oldPath = process.env.PATH | ||
|
||
// 获取脚本的路径 | ||
const repoPath = join(__dirname, '..') | ||
|
||
// 切换到用户的主目录 | ||
process.chdir(process.env.USERPROFILE); | ||
process.chdir(process.env.USERPROFILE) | ||
|
||
// 测试node_modules/jsstp是否存在 | ||
if (!existsSync(join(process.env.USERPROFILE, 'node_modules', 'jsstp'))) { | ||
if (!existsSync(join(process.env.USERPROFILE, 'node_modules', 'jsstp'))) | ||
// 如果不存在则创建软链接 | ||
execSync(`npm link ${repoPath}`); | ||
} | ||
execSync(`npm link ${repoPath}`) | ||
|
||
|
||
// 测试node_modules是否存在 | ||
if (!existsSync(join(repoPath, 'node_modules'))) { | ||
if (!existsSync(join(repoPath, 'node_modules'))) | ||
// 如果不存在则创建软链接 | ||
execSync(`cmd /c mklink /j "${join(repoPath, 'node_modules')}" "${join(process.env.USERPROFILE, 'node_modules')}"`); | ||
} | ||
execSync(`cmd /c mklink /j "${join(repoPath, 'node_modules')}" "${join(process.env.USERPROFILE, 'node_modules')}"`) | ||
|
||
|
||
// 切换回旧的路径 | ||
process.chdir(oldPath); | ||
process.chdir(oldPath) |
Oops, something went wrong.