refactor: update icon system, fix login and add temp auth

refactor all icon map references from zniconsMap to iconsMap across the codebase
standardize icon import paths and add complete src/assets/fonts/znicons.ts definition file
fix login page query selector typo and replace hardcoded client ID with environment variable
add temporary auth token injection in request utility using env var
update ZnIcon documentation and development environment config
This commit is contained in:
DEV_DSW
2026-05-28 11:56:13 +08:00
parent 9d0890b541
commit 9af30b8b8a
12 changed files with 26 additions and 22 deletions

View File

@@ -11,4 +11,7 @@ VITE_API_TIMEOUT_MS = 10000
VITE_SOCKET_BASE_URL = "/ingress/agent/ws/chat" VITE_SOCKET_BASE_URL = "/ingress/agent/ws/chat"
# Client ID # Client ID
VITE_CLIENT_ID = "12" VITE_CLIENT_ID = "12"
# Token
VITE_TOKEN = "eyJraWQiOiJiMTVhZTk0Mi03MjI5LTMyOWUtODA1Yi0wNjFlNmRjYTE1MDQiLCJhbGciOiJSUzI1NiJ9.eyJ0ZW5hbnRfaWQiOjEsInN1YiI6ImJyb3RoZXI4IiwiY2xpZW50SWQiOiJwaWciLCJpc3MiOiJodHRwczovL3BpZzRjbG91ZC5jb20iLCJjbGllbnRfaWQiOiJwaWciLCJhdXRob3JpdGllcyI6WyIvbWFya2V0aW5nL2luZGV4IiwiUk9MRV8xIiwiY29kZWdlbl9ncm91cF9hZGQiLCJjb2RlZ2VuX2dyb3VwX2RlbCIsImNvZGVnZW5fZ3JvdXBfZWRpdCIsImNvZGVnZW5fZ3JvdXBfZXhwb3J0IiwiY29kZWdlbl9ncm91cF92aWV3IiwiY29kZWdlbl90ZW1wbGF0ZV9hZGQiLCJjb2RlZ2VuX3RlbXBsYXRlX2RlbCIsImNvZGVnZW5fdGVtcGxhdGVfZWRpdCIsImNvZGVnZW5fdGVtcGxhdGVfZXhwb3J0IiwiY29kZWdlbl90ZW1wbGF0ZV92aWV3Iiwiam9iX3N5c19qb2JfYWRkIiwiam9iX3N5c19qb2JfZGVsIiwiam9iX3N5c19qb2JfZWRpdCIsImpvYl9zeXNfam9iX2V4cG9ydCIsImpvY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zAzMywianRpIjoiNzhiM2E3ODgtOGUwZS00Zjc2LWEwMDgtOGYxYzI4M2YxN2ZiIiwidXNlcm5hbWUiOiJicm90aGVyOCJ9.p6GSKT9JPbXD_L7BBGx4j4-amhqZZmzSVnjOZrAZ7klA3WfqWfNw6xgOgKyJHNeXgdJpFlJ-vw3vTTPxuaUJJ-57ugGc60PjH4PC5ARVGvGe4psbXDEw3oYJPBquzLSFDqwCpYThAvTxXmjE6EA6mlrw5y6__-dF5HREu0Bspew2z5a3DvUR4swBFz3g3yZnQCoYXoY32W7akJ5xz2oYjsib411_bAOkFTSsmde2qXqOZ2ij2hUjImCtEaURP0Exep8J_1AOFBp0VoWuhFlPHj6B1-JmyOW4d_aDEa3bUpo46iA_GsXOfSqVzekdhO1bU0KZQzCmiNqawhECdtW3Jw"

View File

@@ -14,8 +14,8 @@
- 字体映射表存在:`src/assets/fonts/znicons.js` - 字体映射表存在:`src/assets/fonts/znicons.js`
- 字体文件存在:`src/assets/fonts/znicons.ttf` - 字体文件存在:`src/assets/fonts/znicons.ttf`
- 组件骨架存在但为空:`src/components/ZnIcon/index.vue`0 行) - 组件骨架存在但为空:`src/components/ZnIcon/index.vue`0 行)
- 业务中大量使用 `<uni-icons fontFamily="znicons">` + `zniconsMap[...]` 的方式展示字体图标,并且存在历史路径导入: - 业务中大量使用 `<uni-icons fontFamily="znicons">` + `iconsMap[...]` 的方式展示字体图标,并且存在历史路径导入:
- `import { zniconsMap } from "@/static/fonts/znicons(.js)"`(仓库内当前没有 `src/static/` - `import { iconsMap } from "@/static/fonts/znicons(.js)"`(仓库内当前没有 `src/static/`
- 多处样式中通过 `@font-face` 引用 `@/static/fonts/znicons.ttf`,但仓库内无该字体路径,导致字体加载不稳定: - 多处样式中通过 `@font-face` 引用 `@/static/fonts/znicons.ttf`,但仓库内无该字体路径,导致字体加载不稳定:
- `src/components/ImageSwiper/styles/index.scss` - `src/components/ImageSwiper/styles/index.scss`
- `src/components/GoodDetail/index.vue` - `src/components/GoodDetail/index.vue`
@@ -42,7 +42,7 @@
#### Props 设计(建议) #### Props 设计(建议)
- `name: string`(必填;对应 `zniconsMap` 的 key - `name: string`(必填;对应 `iconsMap` 的 key
- `size?: number | string`(默认 16number 按 px 处理string 原样写入) - `size?: number | string`(默认 16number 按 px 处理string 原样写入)
- `color?: string`(可选;不传则使用 `currentColor`,便于 Tailwind `text-*` 控制) - `color?: string`(可选;不传则使用 `currentColor`,便于 Tailwind `text-*` 控制)
- `title?: string`(可选;用于无障碍/tooltip - `title?: string`(可选;用于无障碍/tooltip
@@ -72,9 +72,9 @@
### 3) 增加历史导入路径兼容层(不改业务代码也能编译) ### 3) 增加历史导入路径兼容层(不改业务代码也能编译)
新增文件:`src/static/fonts/znicons.js` 新增文件:`src/assets/fonts/znicons.js`
- 仅做 re-export`export { zniconsMap } from "@/assets/fonts/znicons.js"` - 仅做 re-export`export { iconsMap } from "@/assets/fonts/znicons"`
说明: 说明:

View File

@@ -1,4 +1,4 @@
export const zniconsMap = { export const iconsMap = {
"zn-wifi": "\ue681", "zn-wifi": "\ue681",
"zn-bath": "\ue69a", "zn-bath": "\ue69a",
"zn-frame": "\ue683", "zn-frame": "\ue683",

View File

@@ -38,7 +38,7 @@
<div v-else class="w-full h-full flex flex-items-center flex-justify-center" @click="handleChooseImage"> <div v-else class="w-full h-full flex flex-items-center flex-justify-center" @click="handleChooseImage">
<uni-icons fontFamily="znicons" size="24" color="#6A717F"> <uni-icons fontFamily="znicons" size="24" color="#6A717F">
{{ zniconsMap["zn-camera"] }} {{ iconsMap["zn-camera"] }}
</uni-icons> </uni-icons>
</div> </div>
</div> </div>
@@ -74,7 +74,7 @@ import { ref, computed, onMounted, nextTick, defineProps, watch } from "vue";
import { SCROLL_TO_BOTTOM } from "@/constants/constant"; import { SCROLL_TO_BOTTOM } from "@/constants/constant";
import { createWorkOrder } from "@/api/workOrder"; import { createWorkOrder } from "@/api/workOrder";
import { uploadFile } from "@/api/upload"; import { uploadFile } from "@/api/upload";
import { zniconsMap } from "@/assets/fonts/znicons"; import { iconsMap } from "@/assets/fonts/znicons";
const props = defineProps({ const props = defineProps({
toolCall: { toolCall: {

View File

@@ -13,7 +13,7 @@
}"> }">
<div class="flex flex-items-center flex-row flex-shrink-0 mr-8"> <div class="flex flex-items-center flex-row flex-shrink-0 mr-8">
<van-icon fontFamily="znicons" size="20" color="#333"> <van-icon fontFamily="znicons" size="20" color="#333">
{{ zniconsMap[moduleItem.moduleIcon] }} {{ iconsMap[moduleItem.moduleIcon] }}
</van-icon> </van-icon>
<span class="ml-4 font-size-14 color-171717 line-height-20"> <span class="ml-4 font-size-14 color-171717 line-height-20">
{{ moduleItem.moduleTitle }} {{ moduleItem.moduleTitle }}
@@ -33,7 +33,7 @@
import { defineProps } from "vue"; import { defineProps } from "vue";
import Vue3MarkdownIt from 'vue3-markdown-it'; import Vue3MarkdownIt from 'vue3-markdown-it';
import ModuleTitle from "@/components/ModuleTitle/index.vue"; import ModuleTitle from "@/components/ModuleTitle/index.vue";
import { zniconsMap } from "@/assets/fonts/znicons"; import { iconsMap } from "@/assets/fonts/znicons";
// Props定义 // Props定义
const props = defineProps({ const props = defineProps({

View File

@@ -12,7 +12,7 @@
<div class="border-box rounded-12 bg-white p-12 ml-12 mr-12 mb-40"> <div class="border-box rounded-12 bg-white p-12 ml-12 mr-12 mb-40">
<div class="flex flex-items-center mb-8"> <div class="flex flex-items-center mb-8">
<uni-icons fontFamily="znicons" size="20" color="#333"> <uni-icons fontFamily="znicons" size="20" color="#333">
{{ zniconsMap["zn-refund"] }} {{ iconsMap["zn-refund"] }}
</uni-icons> </uni-icons>
<span class="font-size-14 font-600 color-171717 ml-8"> <span class="font-size-14 font-600 color-171717 ml-8">
{{ refundTitle }} {{ refundTitle }}
@@ -29,7 +29,7 @@
<script setup> <script setup>
import { ref, computed, watch } from "vue"; import { ref, computed, watch } from "vue";
import { zniconsMap } from "@/static/fonts/znicons"; import { iconsMap } from "@/static/fonts/znicons";
// Props定义 // Props定义
const props = defineProps({ const props = defineProps({

View File

@@ -7,7 +7,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from "vue"; import { computed } from "vue";
import { zniconsMap } from "@/assets/fonts/znicons.js"; import { iconsMap } from "@/assets/fonts/znicons";
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@@ -22,7 +22,7 @@ const props = withDefaults(
); );
const glyph = computed(() => { const glyph = computed(() => {
const value = (zniconsMap as Record<string, string>)[props.name]; const value = (iconsMap as Record<string, string>)[props.name];
return value ?? ""; return value ?? "";
}); });

View File

@@ -24,7 +24,7 @@
</template> </template>
<script setup> <script setup>
import { zniconsMap } from "@/assets/fonts/znicons"; import { iconsMap } from "@/assets/fonts/znicons";
import { defineProps } from "vue"; import { defineProps } from "vue";
// Props定义 // Props定义

View File

@@ -33,7 +33,7 @@ function loadGoogleIdentityServices(): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const src = "https://accounts.google.com/gsi/client"; const src = "https://accounts.google.com/gsi/client";
const existing = document.querySelector < HTMLScriptElement > ( const existing = document.querySelector<HTMLScriptElement>(
`script[src="${src}"]`, `script[src="${src}"]`,
); );
@@ -84,7 +84,7 @@ onMounted(() => {
// 【后续业务】:你可以将这串 idToken 通过 axios 发送给你自己的后端接口 // 【后续业务】:你可以将这串 idToken 通过 axios 发送给你自己的后端接口
// 或者是直接利用第三方平台(如 Firebase / Supabase完成纯前端鉴权 // 或者是直接利用第三方平台(如 Firebase / Supabase完成纯前端鉴权
console.log("拿到的 ID Token 是:", idToken); console.log("拿到的 ID Token 是:", idToken);
oauthToken({ clientId: '6', openIdCode: [idToken], grant_type: 'google' }) oauthToken({ clientId: import.meta.env.VITE_CLIENT_ID, openIdCode: [idToken], grant_type: 'google' })
.then((res) => { .then((res) => {
console.log("获取到的 oauth token:", res) console.log("获取到的 oauth token:", res)

View File

@@ -8,7 +8,7 @@
<div class="tab-item-inner flex flex-items-center"> <div class="tab-item-inner flex flex-items-center">
<uni-icons :class="['icon mr-4', activeIndex === index && 'icon-active']" fontFamily="znicons" size="20" <uni-icons :class="['icon mr-4', activeIndex === index && 'icon-active']" fontFamily="znicons" size="20"
color="opacity"> color="opacity">
{{ zniconsMap[item.iconCode] }} {{ iconsMap[item.iconCode] }}
</uni-icons> </uni-icons>
<span :class="[ <span :class="[
@@ -28,7 +28,7 @@
<script setup> <script setup>
import { onMounted, ref, watch } from "vue"; import { onMounted, ref, watch } from "vue";
import { zniconsMap } from "@/static/fonts/znicons"; import { iconsMap } from "@/static/fonts/znicons";
import { commodityTypePageList } from "@/api/goods"; import { commodityTypePageList } from "@/api/goods";
// Props // Props

View File

@@ -1,2 +0,0 @@
export { zniconsMap } from "@/assets/fonts/znicons.js";

View File

@@ -99,6 +99,9 @@ function resolveRequestLanguage(): string | null {
function buildContextHeaders(options?: RequestOptions): Record<string, string> { function buildContextHeaders(options?: RequestOptions): Record<string, string> {
const headers: Record<string, string> = {}; const headers: Record<string, string> = {};
// 临时token后续需要从登录获取token
setAuthToken(import.meta.env.VITE_TOKEN);
if (!options?.skipAuth && context.token) { if (!options?.skipAuth && context.token) {
headers.Authorization = `Bearer ${context.token}`; headers.Authorization = `Bearer ${context.token}`;
} }