forked from vbenjs/vue-vben-admin
-
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.
Merge branch 'gavin/v4-dev' into gavin/v4-dev-customrouter-merge1
* gavin/v4-dev: (68 commits) feat: 组建修改 fix:修复气泡确认框的底部按钮换行的问题 (vbenjs#3413) style: tabs bottom double line fix (vbenjs#3415) feat(IconPicker): IconPicker could allowClear and readonly for form (vbenjs#3414) fix(FormTable): Invert select bug (vbenjs#3412) chore: 自定义组件默认rule校验默认触发逻辑为blur chore(ApiRadioGroup): 移除多余的change事件 fix(ApiSelect): 修复监听不到params的变动 fix(BasicForm->ApiRadioGroup): when options click, duplicate requests. resolve vbenjs#3387 Revert "feat: table搜索表单值发生改变可以触发reload (vbenjs#3378)" (vbenjs#3407) fix(BasicTable): ColumnSetting mistake when use setColumns (vbenjs#3408) fix: navigator.clipboard 兼容问题 vbenjs#3372 (vbenjs#3403) feat: ColumnSetting and SizeSetting persist (vbenjs#3398) fix(BasicDrawer): remove toRaw props (vbenjs#3399) feat(hooks): useWatermark添加水印防篡改功能(vbenjs#3395) (vbenjs#3397) fix: table height calc when fullcontent and footer visible change (vbenjs#3392) fix(BasicTable): table表格宽度自适应,隐藏的列导致宽度增加 (vbenjs#3388) fix: 使用suffix时,label没有垂直居中 (vbenjs#3384) feat: table搜索表单值发生改变可以触发reload (vbenjs#3378) feat(treeTable): add function collapseRows and demo (vbenjs#3375) ... # Conflicts: # pnpm-lock.yaml # src/components/Application/src/AppProvider.vue # src/components/Container/src/ScrollContainer.vue # src/components/Drawer/src/BasicDrawer.vue # src/components/Form/src/BasicForm.vue # src/components/Form/src/componentMap.ts # src/components/Form/src/components/FormAction.vue # src/components/Form/src/hooks/useFormEvents.ts # src/components/Modal/src/BasicModal.vue # src/components/Modal/src/components/ModalWrapper.vue # src/components/Scrollbar/src/Scrollbar.vue # src/components/SimpleMenu/src/SimpleSubMenu.vue # src/hooks/web/usePermission.ts # src/layouts/default/content/index.vue # src/layouts/default/header/MultipleHeader.vue # src/layouts/default/menu/index.vue # src/layouts/default/tabs/components/TabContent.vue # src/layouts/default/tabs/index.vue # src/layouts/page/index.vue # src/locales/lang/en/common.json # src/locales/lang/en/sys.json # src/locales/lang/zh-CN/sys.json # src/router/guard/permissionGuard.ts # src/router/helper/routeHelper.ts # src/router/routes/basic.ts # src/router/routes/index.ts # src/router/routes/modules/about.ts # src/router/routes/modules/dashboard.ts # src/router/routes/modules/demo/charts.ts # src/router/routes/modules/demo/comp.ts # src/router/routes/modules/demo/feat.ts # src/router/routes/modules/demo/flow.ts # src/router/routes/modules/demo/iframe.ts # src/router/routes/modules/demo/level.ts # src/router/routes/modules/demo/page.ts # src/router/routes/modules/demo/permission.ts # src/router/routes/modules/demo/setup.ts # src/router/routes/modules/demo/system.ts # src/store/modules/multipleTab.ts # src/store/modules/permission.ts # src/store/modules/user.ts # src/utils/auth/index.ts # src/utils/env.ts # src/views/demo/form/UseForm.vue # src/views/demo/system/account/DeptTree.vue # src/views/sys/login/LoginForm.vue
- Loading branch information
Showing
597 changed files
with
12,828 additions
and
16,240 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 |
---|---|---|
|
@@ -13,3 +13,4 @@ dist | |
.local | ||
/bin | ||
Dockerfile | ||
package.json |
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
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
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
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
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 |
---|---|---|
@@ -1 +1,9 @@ | ||
dist | ||
*.sh | ||
node_modules | ||
*.md | ||
*.woff | ||
*.ttf | ||
.turbo | ||
dist | ||
package.json |
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 |
---|---|---|
@@ -1 +1,9 @@ | ||
dist | ||
*.sh | ||
node_modules | ||
*.md | ||
*.woff | ||
*.ttf | ||
.turbo | ||
dist | ||
package.json |
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 |
---|---|---|
@@ -1 +1,9 @@ | ||
dist | ||
*.sh | ||
node_modules | ||
*.md | ||
*.woff | ||
*.ttf | ||
.turbo | ||
dist | ||
package.json |
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
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
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
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 |
---|---|---|
@@ -1,31 +1,104 @@ | ||
import GenerateConfig from 'unplugin-config/vite'; | ||
import colors from 'picocolors'; | ||
import { readPackageJSON } from 'pkg-types'; | ||
import { type PluginOption } from 'vite'; | ||
|
||
import { getEnvConfig } from '../utils/env'; | ||
import { strToHex } from '../utils/hash'; | ||
import { createContentHash } from '../utils/hash'; | ||
|
||
const GLOBAL_CONFIG_FILE_NAME = '_app.config.js'; | ||
// This constant sets the output directory for the Vite package | ||
const OUTPUT_DIR = 'dist'; | ||
export async function createConfigPluginConfig( | ||
shouldGenerateConfig: boolean, | ||
): Promise<PluginOption> { | ||
const config = await getEnvConfig(); | ||
// LINK /src/utils/env.ts -> getVariableName | ||
const APP_NAME = strToHex(config?.VITE_GLOB_APP_TITLE ?? '__APP'); | ||
// https://github.com/kirklin/unplugin-config | ||
return GenerateConfig({ | ||
appName: APP_NAME, | ||
envVariables: { | ||
prefix: 'VITE_GLOB_', | ||
const PLUGIN_NAME = 'app-config'; | ||
|
||
async function createAppConfigPlugin({ | ||
root, | ||
isBuild, | ||
}: { | ||
root: string; | ||
isBuild: boolean; | ||
}): Promise<PluginOption> { | ||
let publicPath: string; | ||
let source: string; | ||
if (!isBuild) { | ||
return { | ||
name: PLUGIN_NAME, | ||
}; | ||
} | ||
const { version = '' } = await readPackageJSON(root); | ||
|
||
return { | ||
name: PLUGIN_NAME, | ||
async configResolved(_config) { | ||
const appTitle = _config?.env?.VITE_GLOB_APP_TITLE ?? ''; | ||
// appTitle = appTitle.replace(/\s/g, '_').replace(/-/g, '_'); | ||
publicPath = _config.base; | ||
source = await getConfigSource(appTitle); | ||
}, | ||
configFile: { | ||
generate: shouldGenerateConfig, | ||
fileName: GLOBAL_CONFIG_FILE_NAME, | ||
outputDir: OUTPUT_DIR, | ||
async transformIndexHtml(html) { | ||
publicPath = publicPath.endsWith('/') ? publicPath : `${publicPath}/`; | ||
|
||
const appConfigSrc = `${ | ||
publicPath || '/' | ||
}${GLOBAL_CONFIG_FILE_NAME}?v=${version}-${createContentHash(source)}`; | ||
|
||
return { | ||
html, | ||
tags: [ | ||
{ | ||
tag: 'script', | ||
attrs: { | ||
src: appConfigSrc, | ||
}, | ||
}, | ||
], | ||
}; | ||
}, | ||
htmlInjection: { | ||
decodeEntities: true, | ||
async generateBundle() { | ||
try { | ||
this.emitFile({ | ||
type: 'asset', | ||
fileName: GLOBAL_CONFIG_FILE_NAME, | ||
source, | ||
}); | ||
|
||
console.log(colors.cyan(`✨configuration file is build successfully!`)); | ||
} catch (error) { | ||
console.log( | ||
colors.red('configuration file configuration file failed to package:\n' + error), | ||
); | ||
} | ||
}, | ||
}); | ||
}; | ||
} | ||
|
||
/** | ||
* Get the configuration file variable name | ||
* @param env | ||
*/ | ||
const getVariableName = (title: string) => { | ||
function strToHex(str: string) { | ||
const result: string[] = []; | ||
for (let i = 0; i < str.length; ++i) { | ||
const hex = str.charCodeAt(i).toString(16); | ||
result.push(('000' + hex).slice(-4)); | ||
} | ||
return result.join('').toUpperCase(); | ||
} | ||
return `__PRODUCTION__${strToHex(title) || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, ''); | ||
}; | ||
|
||
async function getConfigSource(appTitle: string) { | ||
const config = await getEnvConfig(); | ||
const variableName = getVariableName(appTitle); | ||
const windowVariable = `window.${variableName}`; | ||
// Ensure that the variable will not be modified | ||
let source = `${windowVariable}=${JSON.stringify(config)};`; | ||
source += ` | ||
Object.freeze(${windowVariable}); | ||
Object.defineProperty(window, "${variableName}", { | ||
configurable: false, | ||
writable: false, | ||
}); | ||
`.replace(/\s/g, ''); | ||
return source; | ||
} | ||
|
||
export { createAppConfigPlugin }; |
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
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
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
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
Oops, something went wrong.