Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions examples/sites/demos/pc/webdoc/develop-demo-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,13 @@ npm install @opentiny/vue@3
Then modify the`vite.config.js`, add the following code highlighted section:

```js {8-10}
//vite.config.js
// vite.config.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
plugins: [vue()],
define: {
'process.env': { ...process.env }
}
plugins: [vue()]
})
```

Expand Down
5 changes: 1 addition & 4 deletions examples/sites/demos/pc/webdoc/develop-demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
plugins: [vue()],
define: {
'process.env': { ...process.env }
}
plugins: [vue()]
})
```

Expand Down
5 changes: 1 addition & 4 deletions examples/sites/demos/pc/webdoc/installation-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
plugins: [vue()],
define: {
'process.env': { ...process.env }
}
plugins: [vue()]
})
```

Expand Down
5 changes: 1 addition & 4 deletions examples/sites/demos/pc/webdoc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
plugins: [vue()],
define: {
'process.env': { ...process.env }
}
plugins: [vue()]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

The Vite configuration has been simplified, but without updating the documentation

The code example has been simplified to remove the define property, but the tip in line 50 still references configuring TINY_MODE in process.env, which is no longer shown in the example. This creates a disconnect between the instructions and the provided code example.

Consider updating the tip to explain how to set environment variables with the new simplified configuration or add the proper configuration example:

  plugins: [vue()]
+ // If you need to set environment variables:
+ define: {
+   'process.env': {
+     TINY_MODE: 'pc'
+   }
+ }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
plugins: [vue()]
plugins: [vue()]
// If you need to set environment variables:
define: {
'process.env': {
TINY_MODE: 'pc'
}
}

})
```

Expand Down
45 changes: 45 additions & 0 deletions examples/sites/src/views/docs/docs.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<template>
<div class="ti-f-r ti-pt48 ti-pl48 ti-pr48 docs-container">
<tiny-modal v-model="showModal" title="请注意" status="warning" show-footer>
<div class="modal-body">
TinyVue 从 <span class="modal-body-keyword">3.13.0</span> 开始不需要在
<span class="modal-body-keyword">vite.config.js</span> 文件中配置
<span class="modal-body-keyword">define: { 'process.env': { ...process.env } }</span>
这段代码,这段代码会导致环境变量被打包到构建产物中,引起信息安全风险,请业务尽快升级到
<span class="modal-body-keyword">3.13.0</span> 或以上版本!如果不升级版本可以改成:<span
class="modal-body-keyword"
>define: { 'process.env': { }}</span
>
同样也可以解决此问题!感谢您对 TinyVue 的支持!
</div>
<template #footer>
<tiny-button type="primary" :disabled="disabled" @click="handleConfirm">{{
disabled ? `${time} S后可关闭此提示` : '确认将不再弹出此提示'
}}</tiny-button>
<tiny-button @click="handleCancel">取消</tiny-button>
</template>
</tiny-modal>
<component id="doc_wrap" :is="docCmp" class="ti-w0 ti-fi-1" />
<!-- 目录列表 TODO: 需要锚点组件配置整改,处理id中的特殊字符 -->
<!-- <div v-if="anchorLinks.length > 0" class="docs-page-anchor catalog w128 sticky top32 ml24">
Expand All @@ -11,10 +30,33 @@

<script setup>
import { ref, nextTick, watch, onMounted, shallowRef } from 'vue'
import { Modal as TinyModal, Button as TinyButton } from '@opentiny/vue'
import { getWord } from '@/tools'
import docMDs from './docConfig.js'
import { router } from '@/router.js'

const tipFlag = localStorage.getItem('tiny-vue-env-tip')
const showModal = ref(tipFlag !== 'never')
const disabled = ref(true)
let time = ref(5)
if (showModal.value) {
let timer = setInterval(() => {
if (time.value > 0) {
time.value = time.value - 1
} else {
disabled.value = false
clearInterval(timer)
timer = null
}
}, 1000)
}
const handleConfirm = () => {
showModal.value = false
localStorage.setItem('tiny-vue-env-tip', 'never')
}
const handleCancel = () => {
showModal.value = false
}
const isOpen = import.meta.env.VITE_BUILD_TARGET === 'open'
const openDocMap = {
'envpreparation': 'envpreparation-open'
Expand Down Expand Up @@ -54,6 +96,9 @@ onMounted(() => {
</script>

<style lang="less">
.modal-body .modal-body-keyword {
color: var(--tv-base-color-error-6);
}
.docs-container {
flex: 1;
display: flex;
Expand Down
Loading