refactor: 重构组件模板,统一使用相对路径和内部路由 style: 调整CSS样式,修复布局和间距问题 fix: 修复投票和offer组件链接错误问题 chore: 添加新图片资源并更新相关引用路径 perf: 移除调试日志,优化页面加载性能 docs: 更新组件注释和文档说明 test: 更新测试用例以适配新功能 ci: 调整构建配置以支持新资源文件 build: 更新依赖项以兼容新功能
83 lines
4.2 KiB
JavaScript
83 lines
4.2 KiB
JavaScript
// my-component.js
|
||
// 引入全局 Vue 对象(因在 HTML 中通过 script 引入,Vue 已挂载到 window)
|
||
const { defineComponent, ref, provide } = Vue;
|
||
import { itemBottom } from "../item-bottom/item-bottom.js";
|
||
import { itemHead } from "../item-head/item-head.js";
|
||
|
||
// 定义组件(直接使用模板)
|
||
export const itemOffer = defineComponent({
|
||
name: "item-offer",
|
||
props: {
|
||
itemdata: {
|
||
type: Object,
|
||
default: () => {},
|
||
},
|
||
},
|
||
|
||
setup(props) {
|
||
let item = ref({ ...props.itemdata });
|
||
item.value["url"] = "/details/" + item.value.uniqid;
|
||
|
||
// let isLogin = ref(true);
|
||
// let realname = ref(1); // 是否已经实名
|
||
// let userInfoWin = ref({
|
||
// authority: ["comment.edit", "comment.delete", "offercollege.hide", "offersummary.hide", "mj.hide", "topic:manager", "topic:hide"],
|
||
// avatar: "https://nas.gter.net:9008/avatar/97K4EWIMLrsbGTWXslC2WFVSEKWOikN42jDKLNjtax7HL4xtfMOJSdU9oWFhY2E~/middle?random=1761733169",
|
||
// groupid: 3,
|
||
// nickname: "肖荣豪",
|
||
// realname: 1,
|
||
// token: "01346a38444d71aaadb3adad52b52c39",
|
||
// uid: 500144,
|
||
// uin: 4238049,
|
||
// });
|
||
|
||
// let permissions = ref([]);
|
||
|
||
// const getUserInfoWin = () => {
|
||
// const checkUser = () => {
|
||
// const user = window.userInfoWin;
|
||
// if (!user) return;
|
||
// document.removeEventListener("getUser", checkUser);
|
||
// realname.value = user.realname;
|
||
// userInfoWin.value = user;
|
||
// if (user?.uin > 0 || user?.uid > 0) isLogin.value = true;
|
||
// };
|
||
// document.addEventListener("getUser", checkUser);
|
||
// };
|
||
|
||
// const openAttest = () => {
|
||
// const handleAttestClose = () => {
|
||
// document.removeEventListener("closeAttest", handleAttestClose);
|
||
// realname.value = window.userInfoWin?.realname || 0;
|
||
// };
|
||
// // 启动认证流程时添加监听
|
||
// document.addEventListener("closeAttest", handleAttestClose);
|
||
// loadAttest(2);
|
||
// };
|
||
|
||
// // 跳转登录
|
||
// const goLogin = () => {
|
||
// if (typeof window === "undefined") return;
|
||
// if (window["userInfoWin"] && Object.keys(window["userInfoWin"]).length !== 0) {
|
||
// if (window["userInfoWin"]["uid"]) isLogin.value = true;
|
||
// else ajax_login();
|
||
// } else ajax_login();
|
||
// };
|
||
|
||
// provide("isLogin", isLogin);
|
||
// provide("userInfoWin", userInfoWin);
|
||
// provide("realname", realname);
|
||
// provide("openAttest", openAttest);
|
||
// provide("goLogin", goLogin);
|
||
|
||
return { item };
|
||
},
|
||
|
||
components: {
|
||
itemBottom,
|
||
itemHead,
|
||
},
|
||
|
||
template: `<div class="item-box item-offer"> <item-head :itemdata="item"></item-head> <a class="school flexacenter" :href="item.url" target="_blank"> <img class="icon" v-if="item.data.schoollogo" :src="item.data.schoollogo" mode="heightFix"></image> <div class="text flex1 one-line-display">{{ item.data.schoolname }}</div> </a> <a class="major flexacenter" v-if="item.data.professional" :href="item.url" target="_blank"> <div class="key">{{ item.data.project ? '专业' : '项目/专业' }}</div> <div class="value flex1 one-line-display">{{ item.data.professional }}</div> </a> <a class="major flexacenter" v-if="item.data.project" :href="item.url" target="_blank"> <div class="key">项目</div> <div class="value flex1 one-line-display">{{ item.data.project }}</div> </a> <a class="info flexacenter" :href="item.url" target="_blank"> {{ item.data.semester }} <div class="line"></div> {{ item.data.degree }} <div class="line"></div> <div class="results" :class="['r' + item.data.apply_results]">{{ item.data.apply_results_text }}</div> </a> <a class="message" v-if="item.content" :href="item.url" target="_blank">{{ item.content }}</a> <item-bottom :itemdata="item"></item-bottom></div>`,
|
||
});
|