@varlet/cli 3.2.14 ā 3.2.15-alpha.1718196322899
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/index.js +5 -6
- package/lib/node/commands/create.js +1 -2
- package/lib/node/commands/dev.js +5 -3
- package/lib/node/commands/icons.js +2 -3
- package/lib/node/compiler/compileModule.js +1 -2
- package/lib/node/compiler/compileScript.js +1 -2
- package/lib/node/compiler/compileSiteEntry.js +1 -2
- package/lib/node/compiler/compileStyle.js +1 -2
- package/lib/node/compiler/compileStyleVars.js +1 -2
- package/lib/node/compiler/compileTemplateHighlight.js +2 -3
- package/lib/node/compiler/compileTypes.js +3 -6
- package/lib/node/config/varlet.config.d.ts +1 -1
- package/lib/node/config/varlet.config.js +2 -3
- package/lib/node/config/vite.config.js +19 -21
- package/package.json +18 -19
- package/site/mobile/App.vue +29 -27
- package/site/mobile/AppHome.vue +1 -1
- package/site/mobile/main.ts +4 -8
- package/site/pc/App.vue +6 -5
- package/site/pc/Layout.vue +6 -7
- package/site/pc/components/AppAd.vue +1 -2
- package/site/pc/components/AppHeader.vue +13 -14
- package/site/pc/components/code-example/CodeExample.vue +14 -13
- package/site/pc/main.ts +8 -10
- package/site/pc/pages/index/index.vue +6 -7
- package/site/utils.ts +0 -4
- package/template/generators/base/package.json +0 -1
package/lib/client/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import config from '@config';
|
|
|
2
2
|
import AppType from './appType';
|
|
3
3
|
import { Themes, StyleProvider } from '@varlet/ui';
|
|
4
4
|
import { onMounted, onUnmounted } from 'vue';
|
|
5
|
-
import { get } from 'lodash-es';
|
|
6
5
|
export function getPCLocationInfo() {
|
|
7
6
|
const [, language, path] = window.location.hash.split('/');
|
|
8
7
|
const [menuName, hash = ''] = path?.split('#') ?? [];
|
|
@@ -18,9 +17,9 @@ function getHashSearch() {
|
|
|
18
17
|
return new URLSearchParams(hashSearch);
|
|
19
18
|
}
|
|
20
19
|
export function getBrowserTheme() {
|
|
21
|
-
const themeKey =
|
|
22
|
-
const defaultLightTheme =
|
|
23
|
-
const defaultDarkTheme =
|
|
20
|
+
const themeKey = config?.themeKey;
|
|
21
|
+
const defaultLightTheme = config?.defaultLightTheme;
|
|
22
|
+
const defaultDarkTheme = config?.defaultDarkTheme;
|
|
24
23
|
const storageTheme = window.localStorage.getItem(themeKey);
|
|
25
24
|
if (!storageTheme) {
|
|
26
25
|
const preferTheme = window.matchMedia?.('(prefers-color-scheme: dark)').matches
|
|
@@ -70,7 +69,7 @@ const themeMap = {
|
|
|
70
69
|
md3DarkTheme: Themes.md3Dark,
|
|
71
70
|
};
|
|
72
71
|
export function setTheme(theme) {
|
|
73
|
-
const siteStyleVars = withSiteConfigNamespace(
|
|
72
|
+
const siteStyleVars = withSiteConfigNamespace(config[theme] || {});
|
|
74
73
|
const styleVars = { ...siteStyleVars, ...(themeMap[theme] ?? {}) };
|
|
75
74
|
StyleProvider(styleVars);
|
|
76
75
|
setColorScheme(theme);
|
|
@@ -82,7 +81,7 @@ export function onThemeChange(cb) {
|
|
|
82
81
|
});
|
|
83
82
|
}
|
|
84
83
|
export function getSiteStyleVars(theme) {
|
|
85
|
-
return withSiteConfigNamespace(
|
|
84
|
+
return withSiteConfigNamespace(config[theme] || {});
|
|
86
85
|
}
|
|
87
86
|
export function setColorScheme(theme) {
|
|
88
87
|
document.documentElement.style.setProperty('color-scheme', theme.toLowerCase().includes('dark') ? 'dark' : 'light');
|
|
@@ -3,7 +3,6 @@ import fse from 'fs-extra';
|
|
|
3
3
|
import logger from '../shared/logger.js';
|
|
4
4
|
import { bigCamelize, camelize, kebabCase } from '@varlet/shared';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
|
-
import { get } from 'lodash-es';
|
|
7
6
|
import { resolve } from 'path';
|
|
8
7
|
import { glob } from '../shared/fsUtils.js';
|
|
9
8
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
@@ -25,7 +24,7 @@ async function renderTemplates(componentFolder, componentFolderName, renderData)
|
|
|
25
24
|
}
|
|
26
25
|
export async function create(options) {
|
|
27
26
|
logger.title('\nš¦š¦ Create a component ! \n');
|
|
28
|
-
const namespace =
|
|
27
|
+
const { namespace } = await getVarletConfig();
|
|
29
28
|
const renderData = {
|
|
30
29
|
namespace,
|
|
31
30
|
bigCamelizeNamespace: bigCamelize(namespace),
|
package/lib/node/commands/dev.js
CHANGED
|
@@ -6,7 +6,6 @@ import { ES_DIR, SRC, SRC_DIR, VARLET_CONFIG } from '../shared/constant.js';
|
|
|
6
6
|
import { buildSiteEntry } from '../compiler/compileSiteEntry.js';
|
|
7
7
|
import { getDevConfig } from '../config/vite.config.js';
|
|
8
8
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
9
|
-
import { get, merge } from 'lodash-es';
|
|
10
9
|
import { resolve } from 'path';
|
|
11
10
|
import { generateEsEntryTemplate, getScriptExtname } from '../compiler/compileScript.js';
|
|
12
11
|
import { getPublicDirs } from '../shared/fsUtils.js';
|
|
@@ -15,7 +14,7 @@ const { ensureDirSync, pathExistsSync, readFileSync, outputFileSync, removeSync
|
|
|
15
14
|
let server;
|
|
16
15
|
let watcher;
|
|
17
16
|
async function stub(varletConfig) {
|
|
18
|
-
const name = kebabCase(
|
|
17
|
+
const name = kebabCase(varletConfig?.name || '');
|
|
19
18
|
// keep esm and css file for playground
|
|
20
19
|
const esmFile = resolve(ES_DIR, `${name}.esm.js`);
|
|
21
20
|
const cssFile = resolve(ES_DIR, `style.css`);
|
|
@@ -44,7 +43,10 @@ async function startServer(options) {
|
|
|
44
43
|
// build all config
|
|
45
44
|
await buildSiteEntry(options.draft ?? false);
|
|
46
45
|
const devConfig = getDevConfig(varletConfig);
|
|
47
|
-
const inlineConfig =
|
|
46
|
+
const inlineConfig = {
|
|
47
|
+
...devConfig,
|
|
48
|
+
...(options.force ? { optimizeDeps: { force: true } } : {}),
|
|
49
|
+
};
|
|
48
50
|
// create all instance
|
|
49
51
|
server = await createServer(inlineConfig);
|
|
50
52
|
await server.listen();
|
|
@@ -4,7 +4,6 @@ import chokidar from 'chokidar';
|
|
|
4
4
|
import logger from '../shared/logger.js';
|
|
5
5
|
import { parse, resolve } from 'path';
|
|
6
6
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
7
|
-
import { get } from 'lodash-es';
|
|
8
7
|
import { buildIcons, getIo } from '@varlet/icon-builder';
|
|
9
8
|
import { ICONS_PNG_DIR_NAME } from '../shared/constant.js';
|
|
10
9
|
const { removeSync, ensureDirSync, readdirSync } = fse;
|
|
@@ -46,11 +45,11 @@ async function buildPNG(io) {
|
|
|
46
45
|
logger.success('build png success!');
|
|
47
46
|
}
|
|
48
47
|
export async function build(varletConfig, io) {
|
|
49
|
-
await Promise.all([buildPNG(io), buildIcons(
|
|
48
|
+
await Promise.all([buildPNG(io), buildIcons(varletConfig?.icons)]);
|
|
50
49
|
}
|
|
51
50
|
export async function icons({ watch = false } = {}) {
|
|
52
51
|
const varletConfig = await getVarletConfig();
|
|
53
|
-
const io = getIo(
|
|
52
|
+
const io = getIo(varletConfig?.icons);
|
|
54
53
|
const task = () => build(varletConfig, io);
|
|
55
54
|
if (watch) {
|
|
56
55
|
await build(varletConfig, io);
|
|
@@ -9,12 +9,11 @@ import { clearLessFiles, clearScssFiles, compileLess, compileScss } from './comp
|
|
|
9
9
|
import { getBundleConfig } from '../config/vite.config.js';
|
|
10
10
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
11
11
|
import { generateReference } from './compileTypes.js';
|
|
12
|
-
import { get } from 'lodash-es';
|
|
13
12
|
import { kebabCase } from '@varlet/shared';
|
|
14
13
|
const { copy, ensureFileSync, readdir, removeSync } = fse;
|
|
15
14
|
export async function compileBundle() {
|
|
16
15
|
const varletConfig = await getVarletConfig();
|
|
17
|
-
const name = kebabCase(
|
|
16
|
+
const name = kebabCase(varletConfig?.name || '');
|
|
18
17
|
const buildOptions = [
|
|
19
18
|
{
|
|
20
19
|
format: 'es',
|
|
@@ -5,7 +5,6 @@ import { getVersion, isDir, isJsx, isTsx, replaceExt } from '../shared/fsUtils.j
|
|
|
5
5
|
import { extractStyleDependencies, IMPORT_CSS_RE, IMPORT_LESS_RE, IMPORT_SCSS_RE } from './compileStyle.js';
|
|
6
6
|
import { resolve, relative, extname, dirname } from 'path';
|
|
7
7
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
8
|
-
import { get } from 'lodash-es';
|
|
9
8
|
import fse from 'fs-extra';
|
|
10
9
|
import esbuild from 'esbuild';
|
|
11
10
|
const { writeFileSync, readdirSync, readFileSync, removeSync, writeFile, pathExistsSync } = fse;
|
|
@@ -119,7 +118,7 @@ export async function compileScriptByEsbuild(script) {
|
|
|
119
118
|
const varletConfig = await getVarletConfig();
|
|
120
119
|
const { code } = await esbuild.transform(script, {
|
|
121
120
|
loader: 'ts',
|
|
122
|
-
target:
|
|
121
|
+
target: varletConfig?.esbuild?.target,
|
|
123
122
|
format: 'esm',
|
|
124
123
|
});
|
|
125
124
|
return code;
|
|
@@ -3,7 +3,6 @@ import { slash } from '@varlet/shared';
|
|
|
3
3
|
import { DOCS_DIR_NAME, EXAMPLE_DIR_NAME, LOCALE_DIR_NAME, ROOT_DOCS_DIR, ROOT_PAGES_DIR, SITE, SITE_DIR, SITE_MOBILE_ROUTES, SITE_PC_DIR, SITE_PC_ROUTES, SRC_DIR, } from '../shared/constant.js';
|
|
4
4
|
import { glob, isDir, outputFileSyncOnChange } from '../shared/fsUtils.js';
|
|
5
5
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
6
|
-
import { get } from 'lodash-es';
|
|
7
6
|
const { copy } = fse;
|
|
8
7
|
const ROOT_DOCS_RE = /\/docs\/([-\w]+)\.([-\w]+)(?:.draft)?\.md/;
|
|
9
8
|
const PAGE_LOCALE_RE = /\/pages\/([-\w]+)\/locale\/([-\w]+)\.ts/;
|
|
@@ -59,7 +58,7 @@ export async function findRootDocs(draftMode) {
|
|
|
59
58
|
return filterDraftDocs(rootDocs, draftMode);
|
|
60
59
|
}
|
|
61
60
|
export async function findPageLocales() {
|
|
62
|
-
const defaultLanguage =
|
|
61
|
+
const { defaultLanguage } = await getVarletConfig();
|
|
63
62
|
const userPages = await glob(`${ROOT_PAGES_DIR}/*`);
|
|
64
63
|
const baseLocales = await glob(`${SITE}/pc/pages/**/${LOCALE_DIR_NAME}/*.ts`);
|
|
65
64
|
const userLocales = await userPages.reduce(async (userLocales, page) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fse from 'fs-extra';
|
|
2
2
|
import less from 'less';
|
|
3
|
-
import sass from '
|
|
3
|
+
import * as sass from 'sass';
|
|
4
4
|
import glob from 'glob';
|
|
5
5
|
import { replaceExt, smartAppendFileSync } from '../shared/fsUtils.js';
|
|
6
6
|
import { parse, resolve } from 'path';
|
|
@@ -60,7 +60,6 @@ export function compileScss(file) {
|
|
|
60
60
|
return { file: path };
|
|
61
61
|
},
|
|
62
62
|
});
|
|
63
|
-
console.log(css.toString('utf8'));
|
|
64
63
|
writeFileSync(replaceExt(file, '.css'), compressCss(css.toString('utf8')), 'utf-8');
|
|
65
64
|
}
|
|
66
65
|
export function clearLessFiles(dir) {
|
|
@@ -3,7 +3,6 @@ import { SRC_DIR, TYPES_DIR } from '../shared/constant.js';
|
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
import { isDir, isMD } from '../shared/fsUtils.js';
|
|
5
5
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
6
|
-
import { get } from 'lodash-es';
|
|
7
6
|
const { ensureDirSync, readdirSync, readFileSync, writeFileSync } = fse;
|
|
8
7
|
export function compileMD(path, keys) {
|
|
9
8
|
const content = readFileSync(path, 'utf-8');
|
|
@@ -24,7 +23,7 @@ export function compileDir(path, keys, defaultLanguage) {
|
|
|
24
23
|
}
|
|
25
24
|
export async function compileStyleVars() {
|
|
26
25
|
ensureDirSync(TYPES_DIR);
|
|
27
|
-
const defaultLanguage =
|
|
26
|
+
const { defaultLanguage } = await getVarletConfig();
|
|
28
27
|
const keys = new Set();
|
|
29
28
|
compileDir(SRC_DIR, keys, defaultLanguage);
|
|
30
29
|
const assistanceType = `type RemoveTwoDashes<T extends string> = T extends \`--$\{infer Rest}\` ? Rest : T
|
|
@@ -2,7 +2,6 @@ import fse from 'fs-extra';
|
|
|
2
2
|
import { SRC_DIR, HL_DIR, HL_API_RE, HL_COMPONENT_NAME_RE, HL_EN_MD, HL_EN_TITLE_ATTRIBUTES_RE, HL_EN_TITLE_EVENTS_RE, HL_EN_TITLE_SLOTS_RE, HL_EN_WEB_TYPES_JSON, HL_ZH_MD, HL_ZH_TITLE_ATTRIBUTES_RE, HL_ZH_TITLE_EVENTS_RE, HL_ZH_TITLE_SLOTS_RE, HL_ZH_WEB_TYPES_JSON, } from '../shared/constant.js';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
import { getCliVersion, isDir, isMD } from '../shared/fsUtils.js';
|
|
5
|
-
import { get } from 'lodash-es';
|
|
6
5
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
7
6
|
const { ensureDir, readdirSync, readFileSync, writeFileSync } = fse;
|
|
8
7
|
const TABLE_HEAD_RE = /\s*\|.*\|\s*\n\s*\|.*-+\s*\|\s*\n+/;
|
|
@@ -62,7 +61,7 @@ export function compileWebTypes(table, webTypes, componentName, varletConfig) {
|
|
|
62
61
|
description: row[1],
|
|
63
62
|
}));
|
|
64
63
|
webTypes.contributions.html.tags.push({
|
|
65
|
-
name: `${
|
|
64
|
+
name: `${varletConfig?.namespace}-${componentName}`,
|
|
66
65
|
attributes,
|
|
67
66
|
events,
|
|
68
67
|
slots,
|
|
@@ -97,7 +96,7 @@ export function compileLanguageMD(varletConfig, options) {
|
|
|
97
96
|
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
|
|
98
97
|
framework: 'vue',
|
|
99
98
|
version: getCliVersion(),
|
|
100
|
-
name:
|
|
99
|
+
name: varletConfig?.title,
|
|
101
100
|
contributions: {
|
|
102
101
|
html: {
|
|
103
102
|
tags: [],
|
|
@@ -3,7 +3,6 @@ import { TYPES_DIR, UI_PACKAGE_JSON } from '../shared/constant.js';
|
|
|
3
3
|
import { bigCamelize } from '@varlet/shared';
|
|
4
4
|
import { resolve, relative } from 'path';
|
|
5
5
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
6
|
-
import { get } from 'lodash-es';
|
|
7
6
|
import { compileStyleVars } from './compileStyleVars.js';
|
|
8
7
|
const { ensureDir, writeFileSync, readdir, writeFile, readJSONSync } = fse;
|
|
9
8
|
export function generateReference(moduleDir) {
|
|
@@ -14,17 +13,15 @@ export * from '${relative(moduleDir, TYPES_DIR)}'
|
|
|
14
13
|
export async function compileTypes() {
|
|
15
14
|
await ensureDir(TYPES_DIR);
|
|
16
15
|
compileStyleVars();
|
|
17
|
-
const
|
|
18
|
-
const namespace = get(varletConfig, 'namespace');
|
|
19
|
-
const directives = get(varletConfig, 'directives');
|
|
16
|
+
const { namespace = '', directives = '' } = await getVarletConfig();
|
|
20
17
|
const { name: libraryName } = readJSONSync(UI_PACKAGE_JSON);
|
|
21
18
|
const filenames = await readdir(TYPES_DIR);
|
|
22
|
-
const includeFilenames = filenames.filter((filename) =>
|
|
19
|
+
const includeFilenames = filenames.filter((filename) => !['index.d.ts', 'global.d.ts'].includes(filename));
|
|
23
20
|
const exports = [];
|
|
24
21
|
const componentDeclares = [];
|
|
25
22
|
const directiveDeclares = [];
|
|
26
23
|
includeFilenames.forEach((filename) => {
|
|
27
|
-
const folder = filename.
|
|
24
|
+
const folder = filename.replace('.d.ts', '');
|
|
28
25
|
const name = bigCamelize(folder);
|
|
29
26
|
exports.push(`export * from './${folder}'`);
|
|
30
27
|
if (filename.startsWith(namespace)) {
|
|
@@ -172,5 +172,5 @@ export interface VarletConfig {
|
|
|
172
172
|
directives?: string[];
|
|
173
173
|
}
|
|
174
174
|
export declare function defineConfig(config: VarletConfig): VarletConfig;
|
|
175
|
-
export declare function mergeStrategy(
|
|
175
|
+
export declare function mergeStrategy(_: any, srcValue: any, key: any, _object: any, _source: any): any[] | undefined;
|
|
176
176
|
export declare function getVarletConfig(emit?: boolean): Promise<Required<VarletConfig>>;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import fse from 'fs-extra';
|
|
2
|
-
import { mergeWith } from 'lodash-es';
|
|
3
2
|
import { VARLET_CONFIG, SITE_CONFIG } from '../shared/constant.js';
|
|
4
3
|
import { outputFileSyncOnChange } from '../shared/fsUtils.js';
|
|
5
|
-
import { isArray } from '@varlet/shared';
|
|
4
|
+
import { isArray, mergeWith } from '@varlet/shared';
|
|
6
5
|
import { pathToFileURL } from 'url';
|
|
7
6
|
const { pathExistsSync, statSync } = fse;
|
|
8
7
|
export function defineConfig(config) {
|
|
9
8
|
return config;
|
|
10
9
|
}
|
|
11
|
-
export function mergeStrategy(
|
|
10
|
+
export function mergeStrategy(_, srcValue, key, _object, _source) {
|
|
12
11
|
const keys = ['features', 'members'];
|
|
13
12
|
if (keys.includes(key) && isArray(srcValue)) {
|
|
14
13
|
return srcValue;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SRC_DIR, ES_DIR, SITE_CONFIG, SITE_DIR, SITE_MOBILE_ROUTES, SITE_OUTPUT_PATH, SITE_PC_ROUTES, SITE_PUBLIC_PATH, VITE_RESOLVE_EXTENSIONS, EXTENSION_ENTRY, } from '../shared/constant.js';
|
|
2
2
|
import { markdown, html, inlineCss, copy } from '@varlet/vite-plugins';
|
|
3
|
-
import { get } from 'lodash-es';
|
|
4
3
|
import { resolve } from 'path';
|
|
5
4
|
import vue from '@vitejs/plugin-vue';
|
|
6
5
|
import jsx from '@vitejs/plugin-vue-jsx';
|
|
@@ -20,9 +19,7 @@ export function getHtmlInject(inject) {
|
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
21
|
export function getDevConfig(varletConfig) {
|
|
23
|
-
const defaultLanguage =
|
|
24
|
-
const alias = get(varletConfig, 'alias', {});
|
|
25
|
-
const host = get(varletConfig, 'host');
|
|
22
|
+
const { defaultLanguage, alias = {}, host } = varletConfig;
|
|
26
23
|
const resolveAlias = Object.entries(alias).reduce((resolveAlias, [key, value]) => {
|
|
27
24
|
const isRelative = value.startsWith('.');
|
|
28
25
|
resolveAlias[key] = isRelative ? resolve(SRC_DIR, value) : value;
|
|
@@ -40,9 +37,9 @@ export function getDevConfig(varletConfig) {
|
|
|
40
37
|
},
|
|
41
38
|
},
|
|
42
39
|
server: {
|
|
43
|
-
port:
|
|
40
|
+
port: varletConfig?.port,
|
|
44
41
|
host: host === 'localhost' ? '0.0.0.0' : host,
|
|
45
|
-
proxy:
|
|
42
|
+
proxy: varletConfig?.proxy || {},
|
|
46
43
|
},
|
|
47
44
|
publicDir: SITE_PUBLIC_PATH,
|
|
48
45
|
plugins: [
|
|
@@ -50,20 +47,22 @@ export function getDevConfig(varletConfig) {
|
|
|
50
47
|
include: [/\.vue$/, /\.md$/],
|
|
51
48
|
}),
|
|
52
49
|
jsx(),
|
|
53
|
-
markdown({ style:
|
|
54
|
-
copy({ paths:
|
|
50
|
+
markdown({ style: varletConfig?.highlight?.style }),
|
|
51
|
+
copy({ paths: varletConfig?.copy || [] }),
|
|
55
52
|
html({
|
|
56
53
|
data: {
|
|
57
|
-
logo:
|
|
58
|
-
baidu:
|
|
59
|
-
pcTitle:
|
|
60
|
-
pcDescription:
|
|
61
|
-
pcKeywords:
|
|
62
|
-
pcHtmlInject: getHtmlInject(
|
|
63
|
-
mobileTitle:
|
|
64
|
-
mobileDescription:
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
logo: varletConfig?.logo,
|
|
55
|
+
baidu: varletConfig?.analysis?.baidu,
|
|
56
|
+
pcTitle: varletConfig?.pc?.title ? varletConfig?.pc?.title[defaultLanguage] : '',
|
|
57
|
+
pcDescription: varletConfig?.pc?.description ? varletConfig?.pc?.description[defaultLanguage] : '',
|
|
58
|
+
pcKeywords: varletConfig?.pc?.keywords ? varletConfig?.pc?.keywords[defaultLanguage] : '',
|
|
59
|
+
pcHtmlInject: getHtmlInject(varletConfig?.pc?.htmlInject || {}),
|
|
60
|
+
mobileTitle: varletConfig?.mobile?.title ? varletConfig?.mobile?.title[defaultLanguage] : '',
|
|
61
|
+
mobileDescription: varletConfig?.mobile?.description
|
|
62
|
+
? varletConfig?.mobile?.description[defaultLanguage]
|
|
63
|
+
: '',
|
|
64
|
+
mobileKeywords: varletConfig?.mobile?.keywords ? varletConfig?.mobile?.keywords[defaultLanguage] : '',
|
|
65
|
+
mobileHtmlInject: getHtmlInject(varletConfig?.mobile?.htmlInject || {}),
|
|
67
66
|
},
|
|
68
67
|
}),
|
|
69
68
|
],
|
|
@@ -90,9 +89,8 @@ export function getBuildConfig(varletConfig) {
|
|
|
90
89
|
}
|
|
91
90
|
export function getBundleConfig(varletConfig, buildOptions) {
|
|
92
91
|
const plugins = [];
|
|
93
|
-
const name =
|
|
94
|
-
const external =
|
|
95
|
-
const globals = get(varletConfig, 'bundle.globals', {});
|
|
92
|
+
const name = varletConfig?.name;
|
|
93
|
+
const { external = [], globals = {} } = varletConfig?.bundle || {};
|
|
96
94
|
const { fileName, output, format, emptyOutDir, removeEnv } = buildOptions;
|
|
97
95
|
if (format === 'umd') {
|
|
98
96
|
plugins.push(inlineCss({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.15-alpha.1718196322899",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -34,38 +34,38 @@
|
|
|
34
34
|
"url": "https://github.com/varletjs/varlet/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@varlet/release": "^0.2.5",
|
|
38
|
-
"@varlet/icon-builder": "0.2.14",
|
|
39
37
|
"@babel/core": "^7.22.5",
|
|
40
38
|
"@babel/preset-typescript": "^7.22.5",
|
|
39
|
+
"@varlet/icon-builder": "0.2.14",
|
|
40
|
+
"@varlet/release": "^0.2.5",
|
|
41
41
|
"@vitejs/plugin-vue": "5.0.4",
|
|
42
42
|
"@vitejs/plugin-vue-jsx": "3.1.0",
|
|
43
43
|
"@vue/babel-plugin-jsx": "1.2.1",
|
|
44
44
|
"@vue/compiler-sfc": "3.4.21",
|
|
45
45
|
"@vue/runtime-core": "3.4.21",
|
|
46
|
-
"vue": "3.4.21",
|
|
47
|
-
"vite": "5.0.10",
|
|
48
|
-
"esbuild": "0.19.3",
|
|
49
|
-
"vitest": "1.1.0",
|
|
50
46
|
"chokidar": "^3.5.2",
|
|
51
47
|
"commander": "^8.3.0",
|
|
52
48
|
"ejs": "^3.1.8",
|
|
49
|
+
"esbuild": "0.19.3",
|
|
53
50
|
"execa": "^5.0.0",
|
|
54
51
|
"fs-extra": "^9.0.1",
|
|
55
52
|
"glob": "^7.2.0",
|
|
56
53
|
"hash-sum": "^2.0.0",
|
|
57
54
|
"inquirer": "^9.1.4",
|
|
58
55
|
"less": "^3.12.2",
|
|
59
|
-
"node-sass": "9.0.0",
|
|
60
56
|
"lodash-es": "^4.17.21",
|
|
61
57
|
"markdown-it": "^12.2.3",
|
|
62
58
|
"nanospinner": "^1.1.0",
|
|
63
59
|
"picocolors": "^1.0.0",
|
|
60
|
+
"sass": "^1.77.4",
|
|
64
61
|
"semver": "^7.3.5",
|
|
65
62
|
"sharp": "0.31.1",
|
|
66
63
|
"typescript": "^5.1.5",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
64
|
+
"vite": "5.0.10",
|
|
65
|
+
"vitest": "1.1.0",
|
|
66
|
+
"vue": "3.4.21",
|
|
67
|
+
"@varlet/vite-plugins": "3.2.15-alpha.1718196322899",
|
|
68
|
+
"@varlet/shared": "3.2.15-alpha.1718196322899"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/babel__core": "^7.20.1",
|
|
@@ -80,24 +80,23 @@
|
|
|
80
80
|
"@types/semver": "^7.3.9",
|
|
81
81
|
"@types/sharp": "0.31.1",
|
|
82
82
|
"rimraf": "^5.0.1",
|
|
83
|
-
"@varlet/ui": "3.2.
|
|
84
|
-
"@varlet/icons": "3.2.
|
|
85
|
-
"@varlet/touch-emulator": "3.2.
|
|
83
|
+
"@varlet/ui": "3.2.15-alpha.1718196322899",
|
|
84
|
+
"@varlet/icons": "3.2.15-alpha.1718196322899",
|
|
85
|
+
"@varlet/touch-emulator": "3.2.15-alpha.1718196322899"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
|
+
"@vitest/coverage-istanbul": "1.1.0",
|
|
88
89
|
"@vue/runtime-core": "3.4.21",
|
|
89
90
|
"@vue/test-utils": "2.4.1",
|
|
90
|
-
"@vitest/coverage-istanbul": "1.1.0",
|
|
91
|
-
"vitest": "1.1.0",
|
|
92
|
-
"jsdom": "22.1.0",
|
|
93
91
|
"clipboard": "^2.0.6",
|
|
92
|
+
"jsdom": "22.1.0",
|
|
94
93
|
"live-server": "^1.2.1",
|
|
95
94
|
"lodash-es": "^4.17.21",
|
|
96
95
|
"vue": "3.4.21",
|
|
97
96
|
"vue-router": "4.2.0",
|
|
98
|
-
"@varlet/ui": "3.2.
|
|
99
|
-
"@varlet/icons": "3.2.
|
|
100
|
-
"@varlet/touch-emulator": "3.2.
|
|
97
|
+
"@varlet/ui": "3.2.15-alpha.1718196322899",
|
|
98
|
+
"@varlet/icons": "3.2.15-alpha.1718196322899",
|
|
99
|
+
"@varlet/touch-emulator": "3.2.15-alpha.1718196322899"
|
|
101
100
|
},
|
|
102
101
|
"scripts": {
|
|
103
102
|
"dev": "tsc --watch",
|
package/site/mobile/App.vue
CHANGED
|
@@ -3,19 +3,27 @@
|
|
|
3
3
|
<header>
|
|
4
4
|
<var-app-bar class="app-bar" title-position="left" :title="bigCamelizeComponentName">
|
|
5
5
|
<template #left>
|
|
6
|
-
<var-button
|
|
7
|
-
|
|
6
|
+
<var-button
|
|
7
|
+
v-if="showBackIcon"
|
|
8
|
+
style="margin-right: 6px"
|
|
9
|
+
text
|
|
10
|
+
round
|
|
11
|
+
@click="back"
|
|
12
|
+
color="transparent"
|
|
13
|
+
text-color="#fff"
|
|
14
|
+
>
|
|
15
|
+
<var-icon name="chevron-left" class="arrow-left" style="margin-top: 1px" />
|
|
8
16
|
</var-button>
|
|
9
17
|
<var-button
|
|
10
18
|
v-if="!showBackIcon && github"
|
|
11
|
-
style="margin-left: 2px; margin-right: 6px
|
|
19
|
+
style="margin-left: 2px; margin-right: 6px"
|
|
12
20
|
text
|
|
13
21
|
round
|
|
14
22
|
color="transparent"
|
|
15
23
|
text-color="#fff"
|
|
16
24
|
@click="toGithub"
|
|
17
25
|
>
|
|
18
|
-
<var-icon name="github" class="github" style="margin-top: 1px
|
|
26
|
+
<var-icon name="github" class="github" style="margin-top: 1px" />
|
|
19
27
|
</var-button>
|
|
20
28
|
</template>
|
|
21
29
|
<template #right>
|
|
@@ -27,8 +35,8 @@
|
|
|
27
35
|
text-color="#fff"
|
|
28
36
|
@click.stop="showThemeMenu = true"
|
|
29
37
|
>
|
|
30
|
-
<var-icon name="palette" :size="28" class="palette"/>
|
|
31
|
-
<var-icon name="chevron-down" class="arrow-down"/>
|
|
38
|
+
<var-icon name="palette" :size="28" class="palette" />
|
|
39
|
+
<var-icon name="chevron-down" class="arrow-down" />
|
|
32
40
|
</var-button>
|
|
33
41
|
<var-button
|
|
34
42
|
v-if="languages"
|
|
@@ -38,14 +46,14 @@
|
|
|
38
46
|
text-color="#fff"
|
|
39
47
|
@click.stop="showMenu = true"
|
|
40
48
|
>
|
|
41
|
-
<var-icon name="translate" class="i18n"/>
|
|
42
|
-
<var-icon name="chevron-down" class="arrow-down"/>
|
|
49
|
+
<var-icon name="translate" class="i18n" />
|
|
50
|
+
<var-icon name="chevron-down" class="arrow-down" />
|
|
43
51
|
</var-button>
|
|
44
52
|
</template>
|
|
45
53
|
</var-app-bar>
|
|
46
54
|
</header>
|
|
47
55
|
<div class="router-view__block">
|
|
48
|
-
<router-view/>
|
|
56
|
+
<router-view />
|
|
49
57
|
</div>
|
|
50
58
|
|
|
51
59
|
<transition name="site-menu">
|
|
@@ -82,19 +90,11 @@
|
|
|
82
90
|
|
|
83
91
|
<script lang="ts">
|
|
84
92
|
import config from '@config'
|
|
85
|
-
import { computed,
|
|
93
|
+
import { computed, defineComponent, ref, watch, type Ref, type ComputedRef } from 'vue'
|
|
86
94
|
import { useRoute } from 'vue-router'
|
|
87
|
-
import {
|
|
88
|
-
getBrowserTheme,
|
|
89
|
-
watchLang,
|
|
90
|
-
watchTheme,
|
|
91
|
-
setTheme,
|
|
92
|
-
getMobileIndex,
|
|
93
|
-
type Theme,
|
|
94
|
-
} from '@varlet/cli/client'
|
|
95
|
+
import { getBrowserTheme, watchLang, watchTheme, setTheme, getMobileIndex, type Theme } from '@varlet/cli/client'
|
|
95
96
|
import { removeEmpty, inIframe, isPhone } from '../utils'
|
|
96
97
|
import { bigCamelize } from '@varlet/shared'
|
|
97
|
-
import { get } from 'lodash-es'
|
|
98
98
|
|
|
99
99
|
export default defineComponent({
|
|
100
100
|
setup() {
|
|
@@ -104,18 +104,20 @@ export default defineComponent({
|
|
|
104
104
|
const showMenu: Ref<boolean> = ref(false)
|
|
105
105
|
const showThemeMenu: Ref<boolean> = ref(false)
|
|
106
106
|
const language: Ref<string> = ref('')
|
|
107
|
-
const languages: Ref<Record<string, string>> = ref(
|
|
108
|
-
const themes: Ref<Record<string, any>[]> = ref(
|
|
107
|
+
const languages: Ref<Record<string, string>> = ref(config?.mobile?.header?.i18n ?? {})
|
|
108
|
+
const themes: Ref<Record<string, any>[]> = ref(config?.mobile?.header?.themes ?? {})
|
|
109
109
|
const nonEmptyLanguages: ComputedRef<Record<string, string>> = computed(() => removeEmpty(languages.value))
|
|
110
|
-
const redirect =
|
|
111
|
-
const github: Ref<string> = ref(
|
|
112
|
-
const darkMode: Ref<string> = ref(
|
|
110
|
+
const redirect = config?.mobile?.redirect ?? ''
|
|
111
|
+
const github: Ref<string> = ref(config?.mobile?.header?.github ?? '')
|
|
112
|
+
const darkMode: Ref<string> = ref(config?.mobile?.header?.darkMode ?? '')
|
|
113
113
|
const currentTheme = ref(getBrowserTheme())
|
|
114
114
|
|
|
115
115
|
const changeLanguage = (lang: string) => {
|
|
116
116
|
language.value = lang
|
|
117
117
|
showMenu.value = false
|
|
118
|
-
window.location.href = `${getMobileIndex()}#${route.path}?language=${language.value}&replace=${
|
|
118
|
+
window.location.href = `${getMobileIndex()}#${route.path}?language=${language.value}&replace=${
|
|
119
|
+
route.query.replace
|
|
120
|
+
}`
|
|
119
121
|
|
|
120
122
|
if (!isPhone() && inIframe()) {
|
|
121
123
|
;(window.top as any).scrollToMenu(redirect.slice(1))
|
|
@@ -157,7 +159,7 @@ export default defineComponent({
|
|
|
157
159
|
const setCurrentTheme = (theme: Theme) => {
|
|
158
160
|
currentTheme.value = theme
|
|
159
161
|
setTheme(currentTheme.value)
|
|
160
|
-
window.localStorage.setItem(
|
|
162
|
+
window.localStorage.setItem(config?.themeKey, currentTheme.value)
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
const toggleTheme = (value: Theme) => {
|
|
@@ -216,7 +218,7 @@ body {
|
|
|
216
218
|
min-height: 100vh;
|
|
217
219
|
font-size: 16px;
|
|
218
220
|
font-family: 'Roboto', sans-serif;
|
|
219
|
-
-webkit-tap-highlight-color:
|
|
221
|
+
-webkit-tap-highlight-color: transparent;
|
|
220
222
|
background: var(--site-config-color-mobile-body);
|
|
221
223
|
color: var(--site-config-color-text);
|
|
222
224
|
transition: background-color 0.25s, color 0.25s;
|
package/site/mobile/AppHome.vue
CHANGED
package/site/mobile/main.ts
CHANGED
|
@@ -4,14 +4,13 @@ import App from './App.vue'
|
|
|
4
4
|
import Varlet from '@varlet/ui'
|
|
5
5
|
import { createApp } from 'vue'
|
|
6
6
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
7
|
-
import { get } from 'lodash-es'
|
|
8
7
|
import { inIframe, isPhone } from '../utils'
|
|
9
8
|
|
|
10
9
|
import '@varlet/touch-emulator'
|
|
11
10
|
import '@varlet/ui/es/style'
|
|
12
11
|
|
|
13
|
-
const redirect =
|
|
14
|
-
const defaultLanguage =
|
|
12
|
+
const redirect = config?.mobile?.redirect
|
|
13
|
+
const defaultLanguage = config?.defaultLanguage
|
|
15
14
|
|
|
16
15
|
redirect &&
|
|
17
16
|
routes.push({
|
|
@@ -21,7 +20,7 @@ redirect &&
|
|
|
21
20
|
|
|
22
21
|
routes.push({
|
|
23
22
|
path: '/home',
|
|
24
|
-
component: () => import('./AppHome.vue')
|
|
23
|
+
component: () => import('./AppHome.vue'),
|
|
25
24
|
})
|
|
26
25
|
|
|
27
26
|
const router = createRouter({
|
|
@@ -57,7 +56,4 @@ router.beforeEach((to: any) => {
|
|
|
57
56
|
}
|
|
58
57
|
})
|
|
59
58
|
|
|
60
|
-
createApp(App)
|
|
61
|
-
.use(router)
|
|
62
|
-
.use(Varlet)
|
|
63
|
-
.mount('#app')
|
|
59
|
+
createApp(App).use(router).use(Varlet).mount('#app')
|
package/site/pc/App.vue
CHANGED
|
@@ -3,24 +3,25 @@ import config from '@config'
|
|
|
3
3
|
import { defineComponent, onMounted, ref } from 'vue'
|
|
4
4
|
import { getPCLocationInfo, getMobileIndex } from '@varlet/cli/client'
|
|
5
5
|
import { isPhone } from '../utils'
|
|
6
|
-
import { get } from 'lodash-es'
|
|
7
6
|
|
|
8
7
|
export default defineComponent({
|
|
9
8
|
setup() {
|
|
10
|
-
const useMobile = ref(
|
|
11
|
-
const defaultLanguage =
|
|
9
|
+
const useMobile = ref(config?.useMobile)
|
|
10
|
+
const defaultLanguage = config?.defaultLanguage
|
|
12
11
|
|
|
13
12
|
const init = () => {
|
|
14
13
|
const { language, menuName } = getPCLocationInfo()
|
|
15
14
|
|
|
16
15
|
if (isPhone() && useMobile.value) {
|
|
17
|
-
window.location.href = `${getMobileIndex()}#/${menuName}?language=${
|
|
16
|
+
window.location.href = `${getMobileIndex()}#/${menuName}?language=${
|
|
17
|
+
language || defaultLanguage
|
|
18
|
+
}&platform=mobile`
|
|
18
19
|
return
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
onMounted(init)
|
|
23
|
-
}
|
|
24
|
+
},
|
|
24
25
|
})
|
|
25
26
|
</script>
|
|
26
27
|
|
package/site/pc/Layout.vue
CHANGED
|
@@ -7,15 +7,14 @@ import AppSidebar from './components/AppSidebar.vue'
|
|
|
7
7
|
import { Context } from '@varlet/ui'
|
|
8
8
|
import { nextTick, onMounted, ref, watch, type Ref } from 'vue'
|
|
9
9
|
import { useRoute } from 'vue-router'
|
|
10
|
-
import { get } from 'lodash-es'
|
|
11
10
|
import { getPCLocationInfo } from '@varlet/cli/client'
|
|
12
11
|
import { MenuTypes, type Menu } from '../utils'
|
|
13
12
|
import { type SiteContext } from '../types'
|
|
14
13
|
|
|
15
14
|
const context = Context as SiteContext
|
|
16
|
-
const menu: Ref<Menu[]> = ref(
|
|
17
|
-
const useMobile = ref(
|
|
18
|
-
const mobileRedirect =
|
|
15
|
+
const menu: Ref<Menu[]> = ref(config?.pc?.menu ?? [])
|
|
16
|
+
const useMobile = ref(config?.useMobile)
|
|
17
|
+
const mobileRedirect = config?.mobile?.redirect
|
|
19
18
|
const language: Ref<string> = ref('')
|
|
20
19
|
const componentName: Ref<string | undefined> = ref()
|
|
21
20
|
const menuName: Ref<string> = ref('')
|
|
@@ -89,8 +88,8 @@ watch(
|
|
|
89
88
|
menuName.value = _menuName
|
|
90
89
|
hash.value = _hash
|
|
91
90
|
language.value = lang
|
|
92
|
-
useMobile.value = menu.value.find((item) => item.doc === _menuName)?.useMobile ??
|
|
93
|
-
document.title =
|
|
91
|
+
useMobile.value = menu.value.find((item) => item.doc === _menuName)?.useMobile ?? config?.useMobile
|
|
92
|
+
document.title = config?.pc?.title[lang] as string
|
|
94
93
|
},
|
|
95
94
|
{ immediate: true }
|
|
96
95
|
)
|
|
@@ -199,7 +198,7 @@ watch(
|
|
|
199
198
|
}
|
|
200
199
|
|
|
201
200
|
.var-popup__content {
|
|
202
|
-
background-color:
|
|
201
|
+
background-color: transparent;
|
|
203
202
|
}
|
|
204
203
|
</style>
|
|
205
204
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import config from '@config'
|
|
3
|
-
import { get } from 'lodash-es'
|
|
4
3
|
import { ref } from 'vue'
|
|
5
4
|
|
|
6
5
|
defineProps({
|
|
@@ -10,7 +9,7 @@ defineProps({
|
|
|
10
9
|
},
|
|
11
10
|
})
|
|
12
11
|
|
|
13
|
-
const ad = ref(
|
|
12
|
+
const ad = ref(config?.pc?.ad)
|
|
14
13
|
const storageKey = `varlet-site-ad-closed-${ad.value?.id}`
|
|
15
14
|
const isClose = ref(localStorage.getItem(storageKey) == 'true')
|
|
16
15
|
|
|
@@ -116,7 +116,6 @@
|
|
|
116
116
|
<script lang="ts">
|
|
117
117
|
import config from '@config'
|
|
118
118
|
import { ref, computed, defineComponent } from 'vue'
|
|
119
|
-
import { get } from 'lodash-es'
|
|
120
119
|
import { getBrowserTheme, getPCLocationInfo, Theme, watchTheme, setTheme } from '@varlet/cli/client'
|
|
121
120
|
import { removeEmpty } from '../../utils'
|
|
122
121
|
import { useRouter } from 'vue-router'
|
|
@@ -130,22 +129,22 @@ export default defineComponent({
|
|
|
130
129
|
},
|
|
131
130
|
},
|
|
132
131
|
setup() {
|
|
133
|
-
const title: Ref<string> = ref(
|
|
134
|
-
const logo: Ref<string> = ref(
|
|
135
|
-
const languages: Ref<Record<string, string>> = ref(
|
|
136
|
-
const currentVersion: Ref<string> = ref(
|
|
137
|
-
const versions =
|
|
132
|
+
const title: Ref<string> = ref(config?.title)
|
|
133
|
+
const logo: Ref<string> = ref(config?.pc?.logo)
|
|
134
|
+
const languages: Ref<Record<string, string>> = ref(config?.pc?.header?.i18n ?? {})
|
|
135
|
+
const currentVersion: Ref<string> = ref(config?.pc?.header?.currentVersion ?? '')
|
|
136
|
+
const versions = config?.pc?.header?.versions
|
|
138
137
|
const isShowVersion: Ref<boolean> = ref(!!versions)
|
|
139
138
|
const versionItems: Ref<Array<Record<string, any>>> = ref(
|
|
140
139
|
(versions ?? []).find((i: any) => window.location.host.includes(i.name))?.items ?? versions?.[0]?.items ?? []
|
|
141
140
|
)
|
|
142
|
-
const playground: Ref<string> = ref(
|
|
143
|
-
const github: Ref<string> = ref(
|
|
144
|
-
const themes: Ref<Record<string, any>> = ref(
|
|
145
|
-
const changelog: Ref<string> = ref(
|
|
146
|
-
const ai: Ref<string> = ref(
|
|
147
|
-
const redirect =
|
|
148
|
-
const darkMode: Ref<boolean> = ref(
|
|
141
|
+
const playground: Ref<string> = ref(config?.pc?.header?.playground)
|
|
142
|
+
const github: Ref<string> = ref(config?.pc?.header?.github)
|
|
143
|
+
const themes: Ref<Record<string, any>> = ref(config?.pc?.header?.themes ?? {})
|
|
144
|
+
const changelog: Ref<string> = ref(config?.pc?.header?.changelog)
|
|
145
|
+
const ai: Ref<string> = ref(config?.pc?.header?.ai)
|
|
146
|
+
const redirect = config?.pc?.redirect ?? ''
|
|
147
|
+
const darkMode: Ref<boolean> = ref(config?.pc?.header?.darkMode ?? false)
|
|
149
148
|
const currentTheme = ref(getBrowserTheme())
|
|
150
149
|
|
|
151
150
|
const isOpenLanguageMenu: Ref<boolean> = ref(false)
|
|
@@ -168,7 +167,7 @@ export default defineComponent({
|
|
|
168
167
|
const setCurrentTheme = (theme: Theme) => {
|
|
169
168
|
currentTheme.value = theme
|
|
170
169
|
setTheme(currentTheme.value)
|
|
171
|
-
window.localStorage.setItem(
|
|
170
|
+
window.localStorage.setItem(config?.themeKey, currentTheme.value)
|
|
172
171
|
}
|
|
173
172
|
|
|
174
173
|
const getThemeMessage = () => ({ action: 'theme-change', from: 'pc', data: currentTheme.value })
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="var-site-code-example">
|
|
3
3
|
<div class="var-site-code-example__toolbar">
|
|
4
4
|
<var-button text round @click="toggle" v-if="fold && !disabledFold">
|
|
5
|
-
<var-icon name="xml" size="18"/>
|
|
5
|
+
<var-icon name="xml" size="18" />
|
|
6
6
|
</var-button>
|
|
7
7
|
|
|
8
8
|
<var-button
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
round
|
|
13
13
|
v-if="clipboard"
|
|
14
14
|
>
|
|
15
|
-
<var-icon name="content-copy" size="18"/>
|
|
15
|
+
<var-icon name="content-copy" size="18" />
|
|
16
16
|
</var-button>
|
|
17
17
|
|
|
18
18
|
<var-button text round @click="toPlayground" v-if="playground">
|
|
19
|
-
<var-icon name="code-json" size="18"/>
|
|
19
|
+
<var-icon name="code-json" size="18" />
|
|
20
20
|
</var-button>
|
|
21
21
|
</div>
|
|
22
22
|
<div
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
height: height >= 0 ? `${height}px` : undefined,
|
|
29
29
|
}"
|
|
30
30
|
>
|
|
31
|
-
<slot/>
|
|
31
|
+
<slot />
|
|
32
32
|
</div>
|
|
33
33
|
</div>
|
|
34
34
|
</template>
|
|
@@ -39,7 +39,6 @@ import Clipboard from 'clipboard'
|
|
|
39
39
|
import { Context, Snackbar } from '@varlet/ui'
|
|
40
40
|
import { defineComponent, nextTick, ref, onMounted, type Ref } from 'vue'
|
|
41
41
|
import { doubleRaf } from '@varlet/shared'
|
|
42
|
-
import { get } from 'lodash-es'
|
|
43
42
|
import { getBrowserTheme, getPCLocationInfo } from '@varlet/cli/client'
|
|
44
43
|
import { utoa } from '../../../utils'
|
|
45
44
|
import { type SiteContext } from '../../../types'
|
|
@@ -54,17 +53,19 @@ export default defineComponent({
|
|
|
54
53
|
props: {
|
|
55
54
|
playgroundIgnore: {
|
|
56
55
|
type: Boolean,
|
|
57
|
-
default: false
|
|
58
|
-
}
|
|
56
|
+
default: false,
|
|
57
|
+
},
|
|
59
58
|
},
|
|
60
59
|
setup(props) {
|
|
61
60
|
const code: Ref<HTMLElement | null> = ref(null)
|
|
62
61
|
const cid: Ref<number> = ref(clipId++)
|
|
63
|
-
const fold: Ref = ref(
|
|
62
|
+
const fold: Ref = ref(config?.pc?.fold)
|
|
64
63
|
const disabledFold: Ref<boolean> = ref(false)
|
|
65
|
-
const clipboard: Ref = ref(
|
|
64
|
+
const clipboard: Ref = ref(config?.pc?.clipboard || {})
|
|
66
65
|
const height: Ref<number> = ref(-1)
|
|
67
|
-
const playground: Ref<string | undefined> = ref(
|
|
66
|
+
const playground: Ref<string | undefined> = ref(
|
|
67
|
+
!props.playgroundIgnore ? config?.pc?.header?.playground : undefined
|
|
68
|
+
)
|
|
68
69
|
let timer: any = null
|
|
69
70
|
|
|
70
71
|
const toggle = async () => {
|
|
@@ -120,12 +121,12 @@ export default defineComponent({
|
|
|
120
121
|
clipboard,
|
|
121
122
|
playground,
|
|
122
123
|
toggle,
|
|
123
|
-
toPlayground
|
|
124
|
+
toPlayground,
|
|
124
125
|
}
|
|
125
|
-
}
|
|
126
|
+
},
|
|
126
127
|
})
|
|
127
128
|
</script>
|
|
128
129
|
|
|
129
130
|
<style lang="less">
|
|
130
|
-
@import
|
|
131
|
+
@import './codeExample';
|
|
131
132
|
</style>
|
package/site/pc/main.ts
CHANGED
|
@@ -5,14 +5,13 @@ import Varlet, { Snackbar } from '@varlet/ui'
|
|
|
5
5
|
import CodeExample from './components/code-example'
|
|
6
6
|
import { createApp } from 'vue'
|
|
7
7
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
8
|
-
import { get } from 'lodash-es'
|
|
9
8
|
|
|
10
9
|
import '@varlet/ui/es/style'
|
|
11
10
|
import '@varlet/touch-emulator'
|
|
12
11
|
|
|
13
|
-
const defaultLanguage =
|
|
14
|
-
const redirect =
|
|
15
|
-
const mobileRedirect =
|
|
12
|
+
const defaultLanguage = config?.defaultLanguage
|
|
13
|
+
const redirect = config?.pc?.redirect
|
|
14
|
+
const mobileRedirect = config?.mobile?.redirect
|
|
16
15
|
|
|
17
16
|
Snackbar.allowMultiple(true)
|
|
18
17
|
|
|
@@ -30,11 +29,11 @@ const router = createRouter({
|
|
|
30
29
|
return {
|
|
31
30
|
el: to.hash,
|
|
32
31
|
behavior: 'smooth',
|
|
33
|
-
top: 100
|
|
34
|
-
}
|
|
32
|
+
top: 100,
|
|
33
|
+
}
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
return { top: 0 }
|
|
36
|
+
return { top: 0 }
|
|
38
37
|
},
|
|
39
38
|
})
|
|
40
39
|
|
|
@@ -52,7 +51,6 @@ router.beforeEach((to: any, from: any) => {
|
|
|
52
51
|
}
|
|
53
52
|
})
|
|
54
53
|
|
|
55
|
-
|
|
56
54
|
Object.defineProperty(window, 'onMobileRouteChange', {
|
|
57
55
|
value: (path: string, language: string, replace: string, hash: string) => {
|
|
58
56
|
if (path === mobileRedirect) {
|
|
@@ -61,7 +59,7 @@ Object.defineProperty(window, 'onMobileRouteChange', {
|
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
router.replace(`/${language}${path}${hash}`)
|
|
64
|
-
}
|
|
62
|
+
},
|
|
65
63
|
})
|
|
66
64
|
|
|
67
65
|
Object.defineProperty(window, 'scrollToMenu', {
|
|
@@ -71,7 +69,7 @@ Object.defineProperty(window, 'scrollToMenu', {
|
|
|
71
69
|
const scroller = cell.parentNode as HTMLElement
|
|
72
70
|
scroller.scrollTo({ top: cell.offsetTop - scroller.offsetHeight / 2 })
|
|
73
71
|
})
|
|
74
|
-
}
|
|
72
|
+
},
|
|
75
73
|
})
|
|
76
74
|
|
|
77
75
|
createApp(App)
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import config from '@config'
|
|
3
3
|
import AppHeader from '../../components/AppHeader.vue'
|
|
4
4
|
import AppAd from '../../components/AppAd.vue'
|
|
5
|
-
import { get } from 'lodash-es'
|
|
6
5
|
import { ref, watch, type Ref } from 'vue'
|
|
7
6
|
import { useRoute, useRouter } from 'vue-router'
|
|
8
7
|
import { getPCLocationInfo, watchTheme, onThemeChange, getBrowserTheme, setTheme, type Theme } from '@varlet/cli/client'
|
|
@@ -10,10 +9,10 @@ import { getPCLocationInfo, watchTheme, onThemeChange, getBrowserTheme, setTheme
|
|
|
10
9
|
const route = useRoute()
|
|
11
10
|
const router = useRouter()
|
|
12
11
|
const currentTheme = ref(getBrowserTheme())
|
|
13
|
-
const github =
|
|
14
|
-
const title: Ref<string> = ref(
|
|
15
|
-
const language: Ref<string> = ref(
|
|
16
|
-
const indexPage: Ref<Record<string, any>> = ref(
|
|
12
|
+
const github = config?.pc?.header?.github
|
|
13
|
+
const title: Ref<string> = ref(config?.title)
|
|
14
|
+
const language: Ref<string> = ref(config?.defaultLanguage)
|
|
15
|
+
const indexPage: Ref<Record<string, any>> = ref(config?.pc?.indexPage)
|
|
17
16
|
|
|
18
17
|
const getStar = () => {
|
|
19
18
|
router.push(`/${language.value}/home`)
|
|
@@ -28,7 +27,7 @@ const getThemeMessage = () => ({ action: 'theme-change', from: 'pc', data: curre
|
|
|
28
27
|
const setCurrentTheme = (theme: Theme) => {
|
|
29
28
|
currentTheme.value = theme
|
|
30
29
|
setTheme(currentTheme.value)
|
|
31
|
-
window.localStorage.setItem(
|
|
30
|
+
window.localStorage.setItem(config?.themeKey, currentTheme.value)
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
const setLocale = () => {
|
|
@@ -36,7 +35,7 @@ const setLocale = () => {
|
|
|
36
35
|
if (!lang) return
|
|
37
36
|
|
|
38
37
|
language.value = lang
|
|
39
|
-
document.title =
|
|
38
|
+
document.title = config?.pc.title[lang] as string
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
const to = (url: string) => {
|
package/site/utils.ts
CHANGED