diff --git a/codesandbox@3/02-client/02-use-watcher/react-search.en.jsx b/codesandbox@3/02-client/02-use-watcher/react-search.en.jsx index 5fa87e4ee7..fd5789dd4b 100644 --- a/codesandbox@3/02-client/02-use-watcher/react-search.en.jsx +++ b/codesandbox@3/02-client/02-use-watcher/react-search.en.jsx @@ -1,4 +1,4 @@ -import { useWatcher } from 'alova'; +import { useWatcher } from 'alova/client'; import { useState } from 'react'; import { alovaInstance } from './api'; diff --git a/codesandbox@3/02-client/02-use-watcher/react-search.zh.jsx b/codesandbox@3/02-client/02-use-watcher/react-search.zh.jsx index 3b78e2fde5..98e0f66ab6 100644 --- a/codesandbox@3/02-client/02-use-watcher/react-search.zh.jsx +++ b/codesandbox@3/02-client/02-use-watcher/react-search.zh.jsx @@ -1,4 +1,4 @@ -import { useWatcher } from 'alova'; +import { useWatcher } from 'alova/client'; import { useState } from 'react'; import { alovaInstance } from './api'; diff --git a/codesandbox@3/02-client/02-use-watcher/svelte-search.en.svelte b/codesandbox@3/02-client/02-use-watcher/svelte-search.en.svelte index 8abd29e142..31072c38f7 100644 --- a/codesandbox@3/02-client/02-use-watcher/svelte-search.en.svelte +++ b/codesandbox@3/02-client/02-use-watcher/svelte-search.en.svelte @@ -1,33 +1,34 @@ - - - - - -{#if $loading} -
Loading...
-{:else} - -{/if} \ No newline at end of file + + + + + +{#if $loading} +
Loading...
+{:else} + +{/if} diff --git a/codesandbox@3/02-client/02-use-watcher/svelte-search.zh.svelte b/codesandbox@3/02-client/02-use-watcher/svelte-search.zh.svelte index e2ed7b7f02..84beb80acb 100644 --- a/codesandbox@3/02-client/02-use-watcher/svelte-search.zh.svelte +++ b/codesandbox@3/02-client/02-use-watcher/svelte-search.zh.svelte @@ -1,33 +1,34 @@ - - - - - -{#if $loading} -
Loading...
-{:else} - -{/if} \ No newline at end of file + + + + + +{#if $loading} +
Loading...
+{:else} + +{/if} diff --git a/codesandbox@3/02-client/02-use-watcher/vueComposition-search.en.vue b/codesandbox@3/02-client/02-use-watcher/vueComposition-search.en.vue index 000bd74870..a26b96aef8 100644 --- a/codesandbox@3/02-client/02-use-watcher/vueComposition-search.en.vue +++ b/codesandbox@3/02-client/02-use-watcher/vueComposition-search.en.vue @@ -17,7 +17,7 @@ + + `, + hidden: true + }, + ...commonConfig.files + }, + customSetup: { + entry: '/index.js', + dependencies: { + svelte: '^3.59.2', + ...commonConfig.customSetup.dependencies + } + }, + main: '/App.svelte', + environment: 'svelte' + }) +}; + +interface Props { + template: SandpackPredefinedTemplate; + mainFile: string; + externalFiles?: Record; + containBaseURL?: boolean; + containResponded?: boolean; + editorHeight?: number; + style?: 'options'; +} +const EmbedSandpack = ({ + template, + mainFile, + externalFiles = {}, + containBaseURL = true, + containResponded = true, + editorHeight, + style +}: Props) => { + const themes = { + light: amethyst, + dark: monokaiPro + }; + const targetEntry = fileEntry[template + (style ? `-${style}` : '')]; + const files = { + [targetEntry.root]: mainFile, + ...(targetEntry.files ? targetEntry.files : {}), + ...externalFiles + }; + + const apiFileKey = Object.keys(files).find(file => /api\.js$/.test(file)); + if (files[apiFileKey]) { + // if don't need to contain baseURL, remove it. + if (!containBaseURL) { + files[apiFileKey] = files[apiFileKey].replace(/baseURL.+?\s{4}/, ''); + } + // if don't need to contain responded, remove it. + if (!containResponded) { + files[apiFileKey] = files[apiFileKey].replace(/,\s+responded.+json\(\)/, ''); + } + } + + const dependencies = { + alova: '^2', + ...(targetEntry.deps || {}) + }; + const { colorMode } = useColorMode(); + let config = { + files, + template, + customSetup: { + dependencies + } + }; + config = customSetup[template] ? customSetup[template](config) : config; + return ( + + ); +}; + +export default EmbedSandpack; diff --git a/src/components/Examples.tsx b/src/components/Examples.tsx index 4c5425e0f7..34d1c1cbcf 100644 --- a/src/components/Examples.tsx +++ b/src/components/Examples.tsx @@ -1,7 +1,7 @@ import Link from '@docusaurus/Link'; import IconFont from '@site/src/components/IconFont'; -const linkPartCommon = '/alovajs/alova/tree/examples/'; +const linkPartCommon = '/alovajs/alova/tree/main/examples/'; const exampleList = [ { id: 'React', diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 1e1b0c9f79..1f3ccabacc 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -41,12 +41,11 @@ function HomepageHeader() {

- Lightweight request strategy library + Creative Next Generation Request Tool

- One line of code completes network requests in various complex scenarios. Don’t - spend time on the small matter of requesting. Leave it to us. + Extremely improve your API using efficiency and save brainpower Just one step

diff --git a/versioned_docs/version-v2/tutorial/02-getting-started/02-quick-start.md b/versioned_docs/version-v2/tutorial/02-getting-started/02-quick-start.md index ae2aaf5759..8c5928dfea 100644 --- a/versioned_docs/version-v2/tutorial/02-getting-started/02-quick-start.md +++ b/versioned_docs/version-v2/tutorial/02-getting-started/02-quick-start.md @@ -4,7 +4,7 @@ title: Quick Start import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import EmbedSandpack from "@site/src/components/EmbedSandpack"; +import EmbedSandpack from "@site/src/components/EmbedSandpackV2"; import quickStartGET from '!!raw-loader!@site/codesandbox/01-getting-started/02-first-request/get.js'; import quickStartPOST from '!!raw-loader!@site/codesandbox/01-getting-started/02-first-request/post.js'; diff --git a/versioned_docs/version-v2/tutorial/03-combine-framework/02-use-request.md b/versioned_docs/version-v2/tutorial/03-combine-framework/02-use-request.md index 7494c8bee6..f104ae098e 100644 --- a/versioned_docs/version-v2/tutorial/03-combine-framework/02-use-request.md +++ b/versioned_docs/version-v2/tutorial/03-combine-framework/02-use-request.md @@ -5,7 +5,7 @@ title: Auto Manage States import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; -import EmbedSandpack from "@site/src/components/EmbedSandpack"; +import EmbedSandpack from "@site/src/components/EmbedSandpackV2"; import useRequestVue from '!!raw-loader!@site/codesandbox/01-getting-started/03-combine-framework/vueComposition-useRequest.zh.vue'; import useRequestReact from '!!raw-loader!@site/codesandbox/01-getting-started/03-combine-framework/react-useRequest.zh.jsx'; diff --git a/versioned_docs/version-v2/tutorial/03-combine-framework/03-use-watcher.md b/versioned_docs/version-v2/tutorial/03-combine-framework/03-use-watcher.md index 26126a5f4e..21924ebe2f 100644 --- a/versioned_docs/version-v2/tutorial/03-combine-framework/03-use-watcher.md +++ b/versioned_docs/version-v2/tutorial/03-combine-framework/03-use-watcher.md @@ -4,7 +4,7 @@ title: Watching Request import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -import EmbedSandpack from "@site/src/components/EmbedSandpack"; +import EmbedSandpack from "@site/src/components/EmbedSandpackV2"; import CodeBlock from '@theme/CodeBlock'; import useWatcherSearchVue from '!!raw-loader!@site/codesandbox/03-learning/04-use-watcher/vueComposition-search.en.vue'; import useWatcherSearchReact from '!!raw-loader!@site/codesandbox/03-learning/04-use-watcher/react-search.en.jsx';