Przeglądaj źródła

feat(home): open hosted html guides

Developer 1 tydzień temu
rodzic
commit
534e79e3d0
5 zmienionych plików z 31 dodań i 10 usunięć
  1. 2 1
      main.js
  2. 10 5
      pages/home.vue
  3. 8 4
      pages/webView.vue
  4. 5 0
      tests/assetUrl.test.js
  5. 6 0
      utils/assetUrl.js

+ 2 - 1
main.js

@@ -17,10 +17,11 @@ Vue.use(dateFormat);
 
 import regTest from './utils/reg.js'
 import api from '@/http/index.js'
-import { getProfileImageUrl, imageUrl } from '@/utils/assetUrl.js'
+import { getProfileImageUrl, htmlUrl, imageUrl } from '@/utils/assetUrl.js'
 Vue.prototype.$api = api;
 Vue.prototype.$reg = regTest;
 Vue.prototype.$imageUrl = imageUrl;
+Vue.prototype.$htmlUrl = htmlUrl;
 Vue.prototype.$profileImageUrl = getProfileImageUrl;
 Vue.prototype.$imgBase = imageUrl('');
 //微信支付

+ 10 - 5
pages/home.vue

@@ -65,11 +65,11 @@
 		<view class="common">
 			<view class="common-title">常用功能</view>
 			<view class="common-menu adf">
-				<view class="common-menu-pre adffcac" @click="toTurn('/pages/perillPgjs')">
+				<view class="common-menu-pre adffcac" @click="openHtml('PERILL团队发展动态评估系统介绍.html')">
 					<image :src="imgBase+'home_img_pinggu.png'"></image>
 					<text>PERILL团队发展动态评估介绍</text>
 				</view>
-				<view class="common-menu-pre adffcac" @click="toTurn('/pages/perillPgsm')">
+				<view class="common-menu-pre adffcac" @click="openHtml('PERILL团队发展动态评估系统使用说明.html')">
 					<image :src="imgBase+'home_img_baogao.png'"></image>
 					<text>PERILL团队发展动态评估说明</text>
 				</view>
@@ -77,7 +77,7 @@
 					<image :src="imgBase+'home_img_guanli.png'"></image>
 					<text>问卷管理</text>
 				</view>
-				<view class="common-menu-pre adffcac" @click="toTurn('/pages/support')">
+				<view class="common-menu-pre adffcac" @click="openHtml('PERILL常见问题与支持.html')">
 					<image :src="imgBase+'home_img_qywx.png'" style="width: 74rpx;"></image>
 					<text>常见问题与支持</text>
 				</view>
@@ -194,8 +194,13 @@
 			}
 			if(uni.getStorageSync('newUser')) this.newUserFreeShow = true;
 		},
-		methods:{
-			getBannerList(){
+		methods:{
+			openHtml(filename){
+				uni.navigateTo({
+					url:'/pages/webView?src='+encodeURIComponent(this.$htmlUrl(filename))
+				})
+			},
+			getBannerList(){
 				//space	广告位置: 1首页 2发布问卷
 				//type	类型: 1 banner区 2弹框
 				this.$api.get('/core/advertisement/manage/page',{

+ 8 - 4
pages/webView.vue

@@ -9,9 +9,13 @@
 				src:''
 			}
 		},
-		onLoad(options) {
-			this.src = options.src;
-		},
+		onLoad(options) {
+			try {
+				this.src = decodeURIComponent(options.src || '');
+			} catch (error) {
+				this.src = options.src || '';
+			}
+		},
 		methods:{
 			
 		}
@@ -20,4 +24,4 @@
 
 <style scoped lang="less">
 	
-</style>
+</style>

+ 5 - 0
tests/assetUrl.test.js

@@ -6,6 +6,7 @@ const {
 	DEFAULT_PROFILE_IMAGE_BASE_URL,
 	getAssetBaseUrl,
 	getProfileImageUrl,
+	htmlUrl,
 	imageUrl
 } = require('../utils/assetUrl')
 
@@ -27,6 +28,10 @@ assert.equal(
 	getProfileImageUrl('2025/06/16/avatar.png', { VUE_APP_PROFILE_IMAGE_BASE_URL: 'https://test.example/profile/' }),
 	'https://test.example/profile/2025/06/16/avatar.png'
 )
+assert.equal(
+	htmlUrl('PERILL常见问题与支持.html'),
+	'https://transcend.ringzle.com/web/assets/html/PERILL%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E4%B8%8E%E6%94%AF%E6%8C%81.html'
+)
 assert.equal(
 	imageUrl('fm_logo.png'),
 	'https://transcend.ringzle.com/web/assets/images/fm_logo.png'

+ 6 - 0
utils/assetUrl.js

@@ -11,6 +11,11 @@ function imageUrl(filename, env = process.env) {
 	return `${getAssetBaseUrl(env)}${IMAGE_PATH}${encodeURIComponent(normalizedFilename)}`
 }
 
+function htmlUrl(filename, env = process.env) {
+	const normalizedFilename = String(filename || '').replace(/^\/+/, '')
+	return `${getAssetBaseUrl(env)}/html/${encodeURIComponent(normalizedFilename)}`
+}
+
 function getProfileImageUrl(filename, env = process.env) {
 	const normalizedFilename = String(filename || '').replace(/^\/+/, '')
 	const baseUrl = String(env.VUE_APP_PROFILE_IMAGE_BASE_URL || DEFAULT_PROFILE_IMAGE_BASE_URL).replace(/\/+$/, '')
@@ -22,5 +27,6 @@ module.exports = {
 	DEFAULT_PROFILE_IMAGE_BASE_URL,
 	getAssetBaseUrl,
 	getProfileImageUrl,
+	htmlUrl,
 	imageUrl
 }