Skip to content

Commit a87aad4

Browse files
committed
api select
1 parent 0abfb2f commit a87aad4

File tree

17 files changed

+127
-94
lines changed

17 files changed

+127
-94
lines changed

docs/.vuepress/components/Desktop.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { NButtonGroup, NImage, NSpace, NButton, NDropdown } from 'naive-ui';
33
import { computed, ref } from 'vue';
4+
import { api } from './api'
45
56
const platform = navigator.platform.toLowerCase()
67
const plat = ref<"win" | 'linux' | 'mac'>('win')
@@ -14,7 +15,7 @@ if (platform.includes('win')) {
1415
1516
console.log(plat.value)
1617
17-
const res = await fetch('https://api.nn.ci/proxy/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop-proxy.json')
18+
const res = await fetch(`${api()}/proxy/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop-proxy.json`)
1819
const data = await res.json()
1920
const version = (data.name as string).slice(1)
2021
const urls = {

docs/.vuepress/components/NormalPage.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</div>
1212
<div class="wwads wwads-cn wwads-horizontal" data-id="213" style="width:100% !important" v-else>
1313
</div>
14+
<ApiSelect v-if="isTool" />
1415
</div>
1516
</template>
1617
<template #contentAfter>
@@ -26,18 +27,21 @@ import NormalPage from "vuepress-theme-hope/components/NormalPage";
2627
import { usePageFrontmatter } from "@vuepress/client";
2728
import { computed } from "vue";
2829
import { usePageData } from '@vuepress/client'
30+
import NaiveClient from './NaiveClient.vue'
31+
import ApiSelect from "./api/ApiSelect.vue";
2932
3033
const pageData = usePageData()
3134
3235
// get is enable sidebar from frontmatter
3336
const frontmatter = usePageFrontmatter();
34-
const showMingdao = computed(() => {
37+
const isTool = computed(() => {
3538
if (pageData.value.path.startsWith("/tool/")) {
3639
return true;
3740
}
3841
const sidebar = frontmatter.value.sidebar;
3942
return sidebar === false;
4043
})
44+
const showMingdao = isTool
4145
4246
const spStr = computed(() => {
4347
if (pageData.value.path.startsWith("/zh/")) {
@@ -76,6 +80,7 @@ const spStr = computed(() => {
7680
justify-content: center;
7781
margin-top: 20px;
7882
}
83+
7984
.ads-container {
8085
padding-top: 0 !important;
8186
padding-bottom: 0 !important;

docs/.vuepress/components/Sidebar.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
target="_blank"><img src="/img/ss/mingdao.png" alt="" /></a>
88
<span>{{ spStr }}</span>
99
</div>
10+
<div style="padding-right: 8px;" v-if="isDrivers">
11+
<ApiSelect />
12+
</div>
1013
</div>
1114
</template>
1215
</Sidebar>
@@ -15,6 +18,7 @@
1518
import Sidebar from "vuepress-theme-hope/modules/sidebar/components/Sidebar";
1619
import { usePageData } from '@vuepress/client'
1720
import { computed } from "vue";
21+
import ApiSelect from "./api/ApiSelect.vue";
1822
1923
const pageData = usePageData()
2024
const spStr = computed(() => {
@@ -23,7 +27,9 @@ const spStr = computed(() => {
2327
}
2428
return "Sponsorship";
2529
})
26-
30+
const isDrivers = computed(() => {
31+
return pageData.value.path.includes("/drivers/");
32+
})
2733
</script>
2834

2935
<style scoped lang="scss">
@@ -48,4 +54,5 @@ const spStr = computed(() => {
4854
font-size: small;
4955
color: #999;
5056
}
51-
}</style>
57+
}
58+
</style>

docs/.vuepress/components/aliyundrive/Callback.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts" setup>
22
import { NAlert, NSpace, NSpin, NInput } from 'naive-ui';
33
import { ref } from 'vue';
4+
import { api } from '../api';
45
56
const url = new URL(window.location.href);
67
const code = url.searchParams.get("code");
@@ -18,10 +19,9 @@ interface Token {
1819
const token = ref<Token>();
1920
2021
// const api = "http://localhost:3000"
21-
const api = "https://api.nn.ci"
2222
2323
const getToken = async () => {
24-
const resp = await fetch(api + `/alist/ali_open/code`, {
24+
const resp = await fetch(api() + `/alist/ali_open/code`, {
2525
method: "POST",
2626
headers: {
2727
"Content-Type": "application/json",

docs/.vuepress/components/aliyundrive/Request.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts" setup>
2-
import { NButton, NSpace, NAlert, NImage, useMessage } from 'naive-ui';
2+
import { NButton, NSpace, NAlert, NImage, useMessage, NSelect } from 'naive-ui';
33
import { ref } from 'vue';
4+
import { api } from '../api'
45
56
const alist_redirect_uri = "https://alist.nn.ci/tool/aliyundrive/callback"
67
const app_id = "76917ccccd4441c39457a04f6084fb2f"
@@ -30,15 +31,12 @@ interface QrCodeResp {
3031
3132
const qrcode = ref<QrCodeResp>()
3233
33-
// const api = "http://localhost:3000"
34-
const api = "https://api.nn.ci"
35-
3634
const gettingQrCode = ref(false)
3735
3836
async function getQrCode() {
3937
try {
4038
gettingQrCode.value = true
41-
const resp = await fetch(api + "/alist/ali_open/qr", {
39+
const resp = await fetch(api() + "/alist/ali_open/qr", {
4240
method: "POST",
4341
headers: {
4442
"Content-Type": "application/json"
@@ -72,7 +70,7 @@ const message = useMessage()
7270
async function haveScan() {
7371
try {
7472
gettingScanStatus.value = true
75-
const resp = await fetch(`${api}/proxy/https://open.aliyundrive.com/oauth/qrcode/${qrcode.value?.sid}/status`)
73+
const resp = await fetch(`${api()}/proxy/https://open.aliyundrive.com/oauth/qrcode/${qrcode.value?.sid}/status`)
7674
const res: ScanStatus = await resp.json()
7775
scanStatus.value = res
7876
if (res.status === "LoginSuccess") {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script setup lang="ts">
2+
import { NSelect } from 'naive-ui';
3+
import { computed, ref, watch } from 'vue';
4+
import { apis, defaultApi } from '.';
5+
import NaiveClient from '../NaiveClient.vue';
6+
7+
const cur_api_name = ref(defaultApi)
8+
const api = computed(() => apis[cur_api_name.value] as string)
9+
watch(api, (v) => {
10+
localStorage.setItem("api", v)
11+
})
12+
const api_options = Object.entries(apis).map(([key, value]) => ({ label: `${value} (${key})`, value: key }))
13+
</script>
14+
15+
<template>
16+
<NaiveClient>
17+
<NSelect v-model:value="cur_api_name" size="large" :options="api_options" style="margin-bottom: 4px;"></NSelect>
18+
</NaiveClient>
19+
</template>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const apis = {
2+
raw_jp: "https://api.nn.ci",
3+
cf: "https://api-cf.nn.ci",
4+
cn: "https://api.xhofe.top",
5+
};
6+
export const defaultApi = "cf";
7+
export const api = () => {
8+
return localStorage.getItem("api") || apis[defaultApi];
9+
};

docs/.vuepress/components/baidu/Callback.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts" setup>
22
import { NAlert, NSpace, NSpin, NInput } from 'naive-ui';
33
import { ref } from 'vue';
4+
import { api } from '../api';
45
56
const client_id = "iYCeC9g08h5vuP9UqvPHKKSVrKFXGa1v";
67
const client_secret = "jXiFMOPVPCWlO2M5CwWQzffpNPaGTRBG";
@@ -24,7 +25,7 @@ interface Token {
2425
const token = ref<Token>();
2526
2627
const getToken = async () => {
27-
const resp = await fetch(`https://api.nn.ci/alist/baidu/get_refresh_token?code=${code}`);
28+
const resp = await fetch(`${api()}/alist/baidu/get_refresh_token?code=${code}`);
2829
const res: Token = await resp.json();
2930
token.value = res;
3031
};
@@ -36,7 +37,7 @@ if (code && !error) {
3637
</script>
3738

3839
<template>
39-
<NAlert :title="error || 'Error'" type="error" v-if="!code || error">
40+
<NAlert :title="error || 'Error'" type="error" v-if="!code || error">
4041
{{ error_description }}
4142
</NAlert>
4243
<NSpace vertical size="large" v-else>

docs/.vuepress/components/onedrive/Callback.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts" setup>
22
import { NAlert, NButton, NInput, NSpace, NSpin } from 'naive-ui';
33
import { reactive } from 'vue';
4+
import { api } from '../api';
45
56
const url = new URL(window.location.href);
67
const code = url.searchParams.get("code");
@@ -21,7 +22,7 @@ const data = reactive({
2122
})
2223
2324
const getToken = () => {
24-
fetch("https://api.nn.ci/alist/onedrive/get_refresh_token", {
25+
fetch(`${api()}/alist/onedrive/get_refresh_token`, {
2526
method: "POST",
2627
headers: {
2728
"Content-Type": "application/json",
@@ -51,7 +52,7 @@ const [client_id, client_secret, zone] = atob(client as string).split("::");
5152
5253
const getSiteId = () => {
5354
data.gettingSiteId = true;
54-
fetch("https://api.nn.ci/alist/onedrive/get_site_id", {
55+
fetch(`${api()}/alist/onedrive/get_site_id`, {
5556
method: "POST",
5657
headers: {
5758
"Content-Type": "application/json",
@@ -101,7 +102,8 @@ const getSiteId = () => {
101102
<NAlert :title="data.error2" type="error" v-if="data.error2 || data.errorMessage2">
102103
{{ data.errorMessage2 }}
103104
</NAlert>
104-
<NInput placeholder="input site url (https://xx.sharepoint.xx/sites/xx)" size="large" v-model:value="data.siteUrl" />
105+
<NInput placeholder="input site url (https://xx.sharepoint.xx/sites/xx)" size="large"
106+
v-model:value="data.siteUrl" />
105107
<NButton type="primary" size="large" @click="getSiteId">Get SiteID</NButton>
106108
<NSpin v-if="data.gettingSiteId" />
107109
<p v-else-if="data.siteId"><b>site_id: </b>{{ data.siteId }}</p>

docs/.vuepress/components/wopan/Token.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { NInput, NSpace, NButton, NAlert, NTag } from 'naive-ui'
33
import { reactive, ref } from 'vue';
4+
import { api } from '../api';
45
const input = reactive({
56
phone: '',
67
password: '',
@@ -17,7 +18,7 @@ const token = ref()
1718
1819
async function getVerifyCode() {
1920
loading1.value = true
20-
const res = await fetch('https://api.nn.ci/alist/wopan/login', {
21+
const res = await fetch(`${api()}/alist/wopan/login`, {
2122
method: 'POST',
2223
headers: {
2324
'Content-Type': 'application/json'
@@ -33,7 +34,7 @@ async function getVerifyCode() {
3334
}
3435
async function getToken() {
3536
loading2.value = true
36-
const res = await fetch('https://api.nn.ci/alist/wopan/verify_code', {
37+
const res = await fetch(`${api()}/alist/wopan/verify_code`, {
3738
method: 'POST',
3839
headers: {
3940
'Content-Type': 'application/json'
@@ -57,7 +58,8 @@ async function getToken() {
5758

5859
<NInput size="large" placeholder="Phone number" v-model:value="input.phone"></NInput>
5960
<NInput size="large" placeholder="Password" v-model:value="input.password" type="password"></NInput>
60-
<NButton type="primary" secondary size="large" block @click="getVerifyCode" :loading="loading1">Get Verify Code</NButton>
61+
<NButton type="primary" secondary size="large" block @click="getVerifyCode" :loading="loading1">Get Verify Code
62+
</NButton>
6163
<NAlert title="Error" type="error" v-if="err1">
6264
{{ err1 }}
6365
</NAlert>

0 commit comments

Comments
 (0)