forked from Starlight-Dev-Team/fanbook-bot-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
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
be6b2d7
commit 684cc5e
Showing
31 changed files
with
4,182 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable quote-props */ | ||
|
||
const process = require('process'); | ||
|
||
const production = process.env.NODE_ENV === 'production'; | ||
|
||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true, | ||
}, | ||
extends: 'standard-with-typescript', | ||
parserOptions: { | ||
project: ['./tsconfig.json'], | ||
ecmaVersion: 11, | ||
sourceType: 'module', | ||
}, | ||
rules: { | ||
'promise/param-names': [0], | ||
'@typescript-eslint/comma-dangle': [2, 'always-multiline'], | ||
'@typescript-eslint/object-curly-spacing': [2, 'always'], | ||
'@typescript-eslint/member-delimiter-style': [2, { | ||
'multiline': { 'delimiter': 'semi', 'requireLast': true }, | ||
'singleline': { 'delimiter': 'semi', 'requireLast': true }, | ||
}], | ||
'@typescript-eslint/naming-convention': [0], | ||
'@typescript-eslint/no-debugger': production ? [2] : [0], | ||
'@typescript-eslint/no-floating-promises': [0], | ||
'@typescript-eslint/promise-function-async': [0], | ||
'@typescript-eslint/quotes': [2, 'single'], | ||
'@typescript-eslint/semi': [2, 'always'], | ||
'@typescript-eslint/space-before-function-paren': [2, 'never'], | ||
'@typescript-eslint/strict-boolean-expressions': [2, { | ||
'allowString': true, | ||
'allowNumber': true, | ||
'allowNullableObject': true, | ||
'allowNullableBoolean': true, | ||
'allowNullableString': true, | ||
'allowNullableNumber': true, | ||
}], | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
node_modules | ||
dist |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "启动调试", | ||
"type": "node-terminal", | ||
"request": "launch", | ||
"command": "yarn dev", | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"editor.tabSize": 2, | ||
"eslint.validate": [ | ||
"typescript" | ||
], | ||
"files.eol": "\n", | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"typescript.preferences.quoteStyle": "single", | ||
"eslint.run": "onType", | ||
"eslint.options": { | ||
"overrideConfigFile": "./.eslintrc.cjs" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="vite/client" /> |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="zh-CN"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "fanbook-bot-tools", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"setup": "npm install -g yarn eslint && yarn", | ||
"dev": "vite ", | ||
"build": "rm -rf dist && run-p type-check build-only && mv dist/index.html dist/404.html", | ||
"preview": "vite preview", | ||
"build-only": "vite build", | ||
"type-check": "vue-tsc --noEmit", | ||
"pre-lint": "npm install -g eslint && yarn add -D eslint-config-standard-with-typescript eslint-plugin-import eslint-plugin-n eslint-plugin-promise", | ||
"lint": "eslint src" | ||
}, | ||
"dependencies": { | ||
"@arco-design/web-vue": "^2.43.1", | ||
"@starlight-dev-team/fanbook-api-sdk": "^0.3.1", | ||
"@vitejs/plugin-vue-jsx": "^3.0.0", | ||
"pinia": "^2.0.28", | ||
"vue": "^3.2.45", | ||
"vue-router": "^4.1.6" | ||
}, | ||
"devDependencies": { | ||
"@rushstack/eslint-patch": "^1.1.4", | ||
"@types/node": "^18.11.12", | ||
"@vitejs/plugin-vue": "^4.0.0", | ||
"@vue/eslint-config-prettier": "^7.0.0", | ||
"@vue/eslint-config-typescript": "^11.0.0", | ||
"@vue/tsconfig": "^0.1.3", | ||
"eslint": "^8.34.0", | ||
"eslint-config-standard-with-typescript": "^34.0.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-n": "^15.6.1", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"eslint-plugin-vue": "^9.3.0", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.7.1", | ||
"typescript": "~4.7.4", | ||
"vite": "^4.0.0", | ||
"vue-tsc": "^1.0.12" | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<script lang="ts" setup> | ||
import { RouterView } from 'vue-router'; | ||
import { | ||
LayoutContent, | ||
LayoutFooter, | ||
LayoutHeader, | ||
} from '@arco-design/web-vue'; | ||
import '@arco-design/web-vue/dist/arco.css'; | ||
import Header from '@/components/Header.vue'; | ||
import Footer from '@/components/Footer.vue'; | ||
</script> | ||
|
||
<template> | ||
<LayoutHeader><Header /></LayoutHeader> | ||
<LayoutContent><RouterView /></LayoutContent> | ||
<LayoutFooter><Footer /></LayoutFooter> | ||
</template> | ||
|
||
<style> | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
*::-webkit-scrollbar { | ||
display: none; | ||
} | ||
#app { | ||
display: flex; | ||
min-height: 100vh; | ||
flex-direction: column; | ||
} | ||
header, footer { | ||
user-select: none; | ||
} | ||
footer { | ||
display: flex; | ||
width: 100vw; | ||
margin-bottom: 8px !important; | ||
align-self: baseline; | ||
flex-direction: column; | ||
justify-content: center; | ||
} | ||
</style> |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts" setup> | ||
import { Button, Result } from '@arco-design/web-vue'; | ||
</script> | ||
|
||
<template> | ||
<Result status='404' title='这里没有机器人存在'> | ||
<template #extra> | ||
<Button type='primary' @click='$router.back'>返回上一页</Button> | ||
</template> | ||
</Result> | ||
</template> |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script lang="ts" setup> | ||
import { Avatar, Space, TypographyText } from '@arco-design/web-vue'; | ||
import type { Profile } from '@starlight-dev-team/fanbook-api-sdk/dist/types'; | ||
export interface Props { | ||
/** | ||
* 显示的机器人资料信息。 | ||
*/ | ||
profile: Profile; | ||
} | ||
defineProps<Props>(); | ||
</script> | ||
|
||
<template> | ||
<Space> | ||
<Avatar class='bot-avatar' :image-url='profile.avatar' /> | ||
<TypographyText>{{ profile.name }}</TypographyText> | ||
</Space> | ||
</template> | ||
|
||
<style scoped> | ||
.bot-avatar { | ||
display: inline; | ||
background: none; | ||
} | ||
</style> |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script lang="ts" setup> | ||
import { | ||
Divider, | ||
Link as ALink, | ||
TypographyText, | ||
} from '@arco-design/web-vue'; | ||
import Link from './Link.vue'; | ||
export interface FooterItem { | ||
label: string; | ||
link: string; | ||
} | ||
const data: FooterItem[] = [{ | ||
label: 'Fanbook 开放平台', | ||
link: 'https://open.fanbook.mobi/', | ||
}, { | ||
label: '代码仓库', | ||
link: 'https://github.com/Starlight-Dev-Team/fanbook-bot-tools', | ||
}, { | ||
label: '关于', | ||
link: '/about', | ||
}]; | ||
</script> | ||
|
||
<template> | ||
<TypographyText> | ||
<TypographyText v-for='(item, index) in data'> | ||
<Divider v-if='!!index' direction='vertical' /> | ||
<Link v-if='item.link.startsWith("/")' :to='item.link'> | ||
{{ item.label }} | ||
</Link> | ||
<ALink v-else :href='item.link'> | ||
{{ item.label }} | ||
</ALink> | ||
</TypographyText> | ||
</TypographyText> | ||
<TypographyText> | ||
Released under | ||
<ALink href='https://opensource.org/license/mit/' :hoverable='false'> | ||
MIT License | ||
</ALink> | ||
, | ||
Copyright © 2023 星光工作室 | ||
</TypographyText> | ||
</template> | ||
|
||
<style scoped> | ||
span.arco-typography:deep() { | ||
text-align: center; | ||
} | ||
</style> |
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<script lang="ts" setup> | ||
import { onBeforeMount, ref } from 'vue'; | ||
import { | ||
Avatar, | ||
Button, | ||
Doption, | ||
Dropdown, | ||
Dsubmenu, | ||
PageHeader, | ||
Space, | ||
TypographyText, | ||
} from '@arco-design/web-vue'; | ||
import { useAccountStore } from '@/stores/account'; | ||
import { Bot } from '@starlight-dev-team/fanbook-api-sdk'; | ||
import type { Profile } from '@starlight-dev-team/fanbook-api-sdk/dist/types'; | ||
import BotInfo from './BotInfo.vue'; | ||
const accountStore = useAccountStore(); | ||
const defaultTitle = 'Fanbook 机器人工具'; | ||
let botsProfile: Record<string, Profile> = {}; | ||
let activeProfile = ref(undefined as Profile | undefined); | ||
onBeforeMount(async () => { | ||
const store = useAccountStore(); | ||
for (const token of store.botTokens) { | ||
const bot = new Bot(token); | ||
botsProfile[token] = await bot.getProfile(); | ||
} | ||
activeProfile.value = botsProfile[accountStore.activeBotToken ?? '']; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<PageHeader | ||
:title='$route.meta.title as string ?? defaultTitle' | ||
:show-back='$route.path !== "/"' | ||
@back='$router.back' | ||
> | ||
<template #extra> | ||
<Dropdown v-if='activeProfile' trigger='hover' position='br'> | ||
<BotInfo class='avatar' :profile='activeProfile' /> | ||
<template #content> | ||
<Dsubmenu trigger='hover'> | ||
<template #default>切换机器人</template> | ||
<template #content> | ||
<Doption class='bot-list' v-for='profile in botsProfile'> | ||
<BotInfo :profile='profile' /> | ||
</Doption> | ||
</template> | ||
</Dsubmenu> | ||
<Doption @click='() => $router.push("/login")'> | ||
添加机器人 | ||
</Doption> | ||
</template> | ||
</Dropdown> | ||
<Space v-else> | ||
<Button type='primary' @click='() => $router.push("/login")'> | ||
登录 | ||
</Button> | ||
</Space> | ||
</template> | ||
</PageHeader> | ||
</template> | ||
|
||
<style scoped> | ||
:deep(.arco-page-header-extra) { | ||
overflow: visible; | ||
height: 30px; | ||
} | ||
:deep(.avatar) { | ||
margin-top: -5px; | ||
} | ||
.bot-list { | ||
line-height: unset; | ||
} | ||
</style> |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script lang="ts" setup> | ||
import { RouterLink } from 'vue-router'; | ||
import { Link } from '@arco-design/web-vue'; | ||
export interface Props { | ||
to: string; | ||
hoverable?: boolean; | ||
} | ||
withDefaults(defineProps<Props>(), { | ||
hoverable: true, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<Link :hoverable='hoverable'> | ||
<RouterLink class='link' :to='to'> | ||
<slot /> | ||
</RouterLink> | ||
</Link> | ||
</template> | ||
|
||
<style scoped> | ||
.link { | ||
all: inherit; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> |
Oops, something went wrong.