web-component-gallery 2.1.22 → 2.2.0

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.
@@ -103,12 +103,12 @@ async function processLessFiles(theme) {
103
103
  fs.writeFileSync(outputPath, processedContent)
104
104
 
105
105
  // 转换为 "xxx:111;" 格式
106
- const formattedString = Object.entries(fileAVariables)
107
- .map(([key, value]) => `${key}: ${value};`)
108
- .join('\n') // 每行一个键值对
106
+ // const formattedString = Object.entries(fileAVariables)
107
+ // .map(([key, value]) => `${key}: ${value};`)
108
+ // .join('\n') // 每行一个键值对
109
109
 
110
- const themeOutputPath = path.join(basePath, `${theme}.less`)
111
- fs.writeFileSync(themeOutputPath, formattedString)
110
+ // const themeOutputPath = path.join(basePath, `${theme}.less`)
111
+ // fs.writeFileSync(themeOutputPath, formattedString)
112
112
 
113
113
  return fileAVariables
114
114
  } catch (error) {
@@ -203,9 +203,11 @@ function createGeneratorTheme(theme) {
203
203
  const options = {
204
204
  antDir: path.join(hostPath, 'ant-design-vue'),
205
205
  // 指定项目自定义样式文件目录
206
- stylesDir: path.join(hostPath, '../src/styles'),
206
+ stylesDir: path.join(hostPath, 'ant-design-vue/lib/style/themes'),
207
+ // 指定项目自定义样式文件目录
208
+ // stylesDir: path.join(hostPath, '../src/styles'),
207
209
  // 指定自定义主题变量文件路径
208
- varFile: path.join(hostPath, `../src/styles/${resetTheme}.less`),
210
+ // varFile: path.join(hostPath, `../src/styles/${resetTheme}.less`),
209
211
  // 列出需要动态替换的主题变量
210
212
  themeVariables: Object.keys(themeVariables).filter(key => !notIncludes.includes(key)),
211
213
  outputFilePath: path.join(hostPath, '../public/static/style/antdVue.less')
@@ -7,14 +7,21 @@ const colorPalette = require('../utils/ColorPalette')
7
7
 
8
8
  // 获取并解析LESS文件
9
9
  async function fetchAndParseLessFile(fileName, isParseVariables) {
10
- // 默认值需要给一个内外网都能访问到的固定地址
11
- let origin = process.env.VUE_APP_API_BASE_URL || 'http://qxfnkj.com'
10
+ // 确定请求源地址
11
+ let origin = 'http://qxfnkj.com'
12
+
13
+ // 浏览器环境:使用当前页面的origin
14
+ if (typeof window !== 'undefined' && window.location && window.location.origin && process.env.NODE_ENV !== 'development') origin = window.location.origin
15
+
12
16
  const response = await fetch(`${origin}/base-subject/themes/${fileName}.less`)
17
+
18
+ if (!response.ok) throw new Error(`${fileName}文件请求失败!`)
19
+
13
20
  const responseText = await response.text()
14
21
 
15
22
  return isParseVariables
16
- ? await parseLessVariables(responseText)
17
- : responseText
23
+ ? await parseLessVariables(responseText)
24
+ : responseText
18
25
  }
19
26
 
20
27
  // 解析LESS变量
@@ -22,7 +22,7 @@ import PageLoading from "./PageLoading"
22
22
  * 全局切换主题
23
23
  * @theme 主题key 使用方法: this.$setTheme(@theme)
24
24
  * */
25
- // import setTheme from './Theme'
25
+ import { updateTheme } from './UpdateTheme'
26
26
 
27
27
  /**
28
28
  * 全局挂载组件自定义指令
@@ -57,7 +57,7 @@ export default {
57
57
  /** 加载便捷弹窗等 */
58
58
  Vue.use(Dialog)
59
59
  Vue.use(PageLoading)
60
- // Vue.use(setTheme)
60
+ Vue.prototype.$setTheme = updateTheme
61
61
 
62
62
  // 指令注册
63
63
  Object.keys(Directives).forEach(key => {
@@ -1,6 +1,3 @@
1
- @import '~ant-design-vue/lib/style/themes/default.less';
2
- @import './mixins.less';
3
-
4
1
  html,
5
2
  body,
6
3
  #app, #root {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-component-gallery",
3
- "version": "2.1.22",
3
+ "version": "2.2.0",
4
4
  "description": "基础vue、antdvue、less实现的私有组件库",
5
5
  "main": "dist/index.umd.js",
6
6
  "files": [